/Fundus-Quality-Detection

ML Assignment from Radical AI. Involves classifying Fundus mages to good or bad quality.

Primary LanguageJupyter Notebook

Introduction

The fundus of the eye is the interior surface of the eye opposite the lens and includes the retina, optic disc, macula, fovea, and posterior pole. The fundus can be examined by ophthalmoscopy and/or fundus photography.

FUNDUS

Medical signs that can be detected from observation of eye fundus (generally by funduscopy) include hemorrhages, exudates, cotton wool spots, blood vessel abnormalities (tortuosity, pulsation and new vessels) and pigmentation. Arteriolar constriction, seen as "silver wiring", and vascular tortuosities are seen in hypertensive retinopathy.The eye's fundus is the only part of the human body where the microcirculation can be observed directly.

In all but the most high-end cameras, fundus images which are manually taken by trained optometrists often have flaws caused due to poor illumination, shot angles, and head movement. These factors result in poor quality images which are not useful.

Good Image

Bad Image

Incorrect Positioning / Outliers

This Repository experiments with automating the process of adjustment of the camera settings. We use the DRIMDB (Diabetic Retinopathy Image Database) dataset to classify fundus imagery into Good or Bad quality.

Dependencies

  • Pytorch
  • numpy
  • sklearn
  • tqdm
  • gradcam
  • PIL
  • matplotlib

Installation

pip install torch
pip install numpy
pip install scikit-learn
pip install tqdm
pip install pytorch-gradcam
pip install pillow
pip install matplotlib

Here's a link to the DIRMDB dataset.

http://academictorrents.com/details/99811ba62918f8e73791d21be29dcc372d660305

Approach

Through visual data analysis, we can see that good quality images tend to show the important features of the eye like

  • Blood vessels
  • Retinal Artery
  • Retinal Vein
  • Macula
  • Optic Disc

Bad quality images do not clearly show these features due to poor illumination, angle adjustment or blurry images. Therefore, we need the model of our choice to identify these features.

Repository

  • Fundus.ipynb - Jupyter notebook where the whole training takes place
  • GradCAM.ipynb - Jupyter notebook where gradcam is applied on falsely classified images for debugging
  • data.py - Script which contains the custom dataset class and dataloader functions
  • model.py - Contains the class AlexNet which has the architecture of the CNN
  • utils.py - Utility functions

Training

We choose the AlexNet architecture which is a relatively simpler architecture and good enough for the task at hand. The model architecture is present in model.py. The whole training process is present in Fundus.ipynb. Run the whole notebook to train the model, save checkpoint for best model, visualize the training process and resulting test set accuracy.

Hyper parameters:

Learning rate = 0.005

Epochs = 500

Batch Size = 16

Validation Split = 0.2

                                    Loss                                                        Accuracy

GradCAM visualization

True Positives:

We can see that the model is learning to identify parts like optical disc and some veins to declare the above image as a true positive.

On exploration with the false positives and false negatives, I noticed that many of the outliers are classified incorrectly. Which could be explained because they show geatures like pupil which the model interprets as an optic disc. Also the blood vessels on the sclera also reinforce that conclusion.

Future Work

  • Outlier images are usually classified wrong, come up with a clever solution to solve this
  • Try other architectures
  • Try other augmentations
  • Library for hyper parameter tuning