• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Medical image segmentation ( Eye vessel segmentation)

medical_image_segmentation

Medical image segmentation Code for : https://towardsdatascience.com/vessel-segmentation-with-python-and-keras-722f9fb71b21

Data

Available at https://www.isi.uu.nl/Research/Databases/DRIVE/

Unzip in ./input

Vessel Segmentation With Python and Keras

Motivation :

Automatic segmentation of medical images is an important step to extract useful information that can help doctors make a diagnosis. For example, it can be used to segment retinal vessels so that we can represent their structure and measure their width which in turn can help diagnose retinal diseases.

In this post we will implement a Neural baseline that does image segmentation applied to retinal vessel images.

Dataset :

http://www.isi.uu.nl/Research/Databases/DRIVE/browser.php

We use DRIVE (Digital Retinal Images for Vessel Extraction) data set for all the experiments throughout the post. It is a data set of 40 retinal images ( 20 for training and 20 for testing ) where blood vessel were annotated at the pixel level ( see example above) to mark the presence (1) or absence (0) of a blood vessel at each pixel (i, j) of the image.

Problem Setting :

Problem : We want to assign to each a pixel a β€œ1” label if it is part of a blood vessel in the image and β€œ0” otherwise.
Intuition/Hypothesis : The neighboring pixels values are important to make a prediction for each pixel (i, j) so we should take into account context. The predictions do not depend on the specific position on the image so the classifier should have some translation invariance.
Solution : Use CNNs ! We will use the U-net architecture to do blood vessel segmentation. It is an architecture that is widely used for semantic segmentation tasks especially in the medical domain.

Model :

U-net

The U-net Architecture is an encoder-decoder with some skip connections between the encoder and the decoder. The major advantage of this architecture is its ability to take into account a wider context when making a prediction for a pixel. This is thanks to the large number of channels used in the up-sampling operation.

Input image processing :

We apply this sequence of processing steps before feeding it to the CNN.

  • Normalization : we divide pixel intensities by 255 so they are in the 0–1 range.
  • Cropping : The network expects each dimension of the input image to be divisible by 2⁴ because of the pooling operations so we take a random crop of 64*64 from each image.
  • Data augmentation : Random flip (Horizontal or vertical or both), Random Shear, Random translation (Horizontal or vertical or both), Random Zoom. Performed during training only.

We train three variations of the model :

  • Pre-trained on ImageNet VGG encoder + data augmentation.
  • Trained from scratch + data augmentation.
  • Trained from scratch without data augmentation.

We will compare those three models using AUC ROC metric and we will only consider the pixels inside the retinal mask in the evaluation (meaning the black edges around the circle of the image won’t count).

Results :

  • Trained from scratch + data augmentation AUC ROC : 0.9820
  • Trained from scratch without augmentation AUC ROC : 0.9806
  • Pre-trained encoder + data augmentation AUC ROC : 0.9811

The performance is close for the three variations but it seems pretraining does not help in this case while data augmentation does a little bit.

Best model predictions

The predictions in the figure above look pretty cool ! πŸ˜„

Predictions on top of ground Truth

We also plot the differences between the predictions and the ground truth : False negatives in blue and false positives in red. We can see that the model have some difficulties predicting fine vessels that are just one or two pixels wide.

Conclusion :

In this post we implemented a neural network to do image segmentation applied to blood vessel detection in retinal images. We obtained an AUC ROC of **0.9820 **which is pretty close to the state of the art ( https://paperswithcode.com/search?q=vessel ). What I find most interesting about the results of the experiments is that for some tasks like this one we can train a deep neural network on as little as 20 images and still obtain a nice performance and pretty cool results.

Code to reproduce the results is available here : https://github.com/CVxTz/medical_image_segmentation

More Repositories

1

image_search_engine

Image search engine
Python
232
star
2

time_series_forecasting

Python
194
star
3

ECG_Heartbeat_Classification

CNN for heartbeat classification
Python
148
star
4

EEG_classification

EEG Sleep stage classification using CNN with Keras
Python
145
star
5

audio_classification

CNN 1D vs 2D audio classification
Jupyter Notebook
103
star
6

recommender_transformer

Python
82
star
7

graph_classification

Learning from graph data using Keras
Python
64
star
8

music_genre_classification

music genre classification : LSTM vs Transformer
Python
61
star
9

rubiks_cube

Rubik's Cube solver using reinforcement learning
Python
53
star
10

kinship_prediction

Deep Neural Networks for Kinship prediction using face photos
Python
47
star
11

face_age_gender

Can we predict the age and gender of someone given a picture of their face ?
Python
42
star
12

COLA_pytorch

COLA contrastive pre-training method implemented in PyTorch
Python
40
star
13

DeepTabular

Python
37
star
14

fingerprint_denoising

U-Net for fingerprint denoising
Python
26
star
15

IntegratedGradientsPytorch

Integrated gradients attribution method implemented in PyTorch
Python
23
star
16

sudoku_solver

Solving a Sudoku Puzzle from a screenshot
Python
22
star
17

llm-serve-tutorial

Python
21
star
18

RL

RL algorithm implementations from scratch.
Python
17
star
19

distill-llm

Python
17
star
20

FastImageClassification

A Step-By-Step tutorial to build and deploy an image classification API
Python
14
star
21

Recommender_keras

Basic recommendation system for Movilens dataset using Keras
Python
12
star
22

xumi

Python
9
star
23

ner_playground

Python
6
star
24

celery_ml_deploy

Python
6
star
25

knowledge_distillation

Knowledge Distillation
Python
5
star
26

gcp_model_deploy_example

Python
5
star
27

handwriting_forensics

Python
5
star
28

TagSuggestionImages

Suggest multiple Tags/Labels that better fit an image
Python
4
star
29

active_learning

Active Learning Applied to image and tabular data
Python
4
star
30

code_search

Python
4
star
31

nicegui_tutorial

Python
4
star
32

learning_to_abstain

Know what you don't know
Python
3
star
33

malignancy_detection

malignancy detection using CNNs with Keras
Python
3
star
34

LLM-Voice

Python
3
star
35

ReconstructionAuxLoss

Improve Neural Network's Generalization Performance By Adding an Unsupervised Auxiliary Loss - Pytorch Lightning
Python
2
star
36

bleach_bot

Python
2
star
37

doc-llm

Python
2
star
38

interpretable_nlp

Python
1
star
39

streamlit_demo

Python
1
star
40

prefect_mlops

1
star
41

dimensionality_reduction

HTML
1
star
42

ToyImageClassificationDataset

Toy Image Classification Dataset Annotated with Labelme
Python
1
star
43

constrained_llm_generation

Python
1
star