Built to order

Diabetic Retinopathy Grading from Fundus Images using CNN

This project builds a convolutional neural network that grades diabetic retinopathy into five stages (No DR, Mild, Moderate, Severe, Proliferative) from retinal fundus photographs, trained with transfer learning on the APTOS 2019 set of 3,662 labeled images. It ships with a training notebook, the trained EfficientNetB0 model, and an interactive web demo showing the predicted stage, per-class probabilities and a lesion-highlight overlay. Every performance figure is stated as an honest design target. Suitable for B.E./B.Tech final-year projects in AI & Machine Learning, Computer Science and IT.

AI & Machine Learning GitPython 3TensorFlow · KerasHTML · CSS · JavaScript demoAPTOS 2019 fundus datasetEfficientNetB0 transfer learningOpenCV · NumPy · scikit-learnGrad-CAM attention overlaysSoftware
Diabetic Retinopathy Grading from Fundus Images using CNN — project thumbnail preview
More project photos (3)

The problem

Diabetic retinopathy is a leading cause of preventable blindness: chronic high blood sugar damages the small vessels of the retina, progressing silently from microaneurysms to hemorrhages, exudates and finally fragile new blood vessels that can bleed into the eye. Systematic fundus-photograph screening catches it early, but there are far fewer trained ophthalmologists than diabetic patients who need screening. This project builds that screening idea as an honest educational prototype: an EfficientNetB0 network fine-tuned on the public APTOS 2019 Blindness Detection set grades a fundus photograph into the five International Clinical Diabetic Retinopathy stages, evaluated with quadratic weighted kappa and per-class AUC rather than a single accuracy number. The interactive demo lets you select a sample fundus image, run the grading, and inspect the predicted stage with per-class probabilities and a lesion-highlight overlay — while every page of the project states plainly that this is a teaching build, not a diagnostic device.

SYSTEM FLOW

5 components 6 connections

Live flow
Drag to explore
100%
storageAPTOS 2019

3,662 labeled fundus photographs across the five ICDR stages.

Follow the working sequence

How it works

  1. The 3,662 labeled APTOS 2019 fundus images are circular-cropped to remove black borders, CLAHE-enhanced, resized to 224×224×3 and normalized with ImageNet statistics.
  2. Stratified 80/10/10 train/validation/test splits preserve the stage ratio; augmentation (rotation, flips, brightness jitter) is applied during training.
  3. EfficientNetB0 (ImageNet weights) is fine-tuned with a custom head — GAP → Dense(256, ReLU) → Dropout(0.4) → Dense(5, softmax) — using weighted categorical cross-entropy and Adam (lr 1e-4).
  4. Training runs with early stopping on validation quadratic weighted kappa; the best checkpoint is kept and the curves recorded.
  5. The held-out test split is evaluated once: quadratic weighted kappa, per-class AUC and the confusion matrix are generated for the report.
  6. In the web demo, a selected fundus image is preprocessed identically and passed through the saved weights; the app shows the predicted stage, probability bars and the lesion overlay. All outputs are labeled illustrative — not a diagnosis.

Tech stack:

  • Python 3, TensorFlow/Keras
  • EfficientNetB0 (ImageNet pretraining, fine-tuned)
  • OpenCV, NumPy, scikit-learn (preprocessing & metrics)
  • Jupyter Notebook (training & evaluation)
  • HTML5 + JavaScript (interactive grading demo)
  • APTOS 2019 Blindness Detection set (Kaggle, 3,662 images)

Dataset & model details

  • Dataset: APTOS 2019 Blindness Detection (Kaggle, Asia Pacific Tele-Ophthalmology Society) — 3,662 labeled retinal fundus photographs across 5 ICDR stages: No DR 1,805 / Mild 370 / Moderate 999 / Severe 193 / Proliferative 295; plus 1,928 test images with hidden labels.
  • Task: 5-class image classification; input = 224×224×3 RGB fundus image, output = probability distribution over the 5 DR stages.
  • Model: EfficientNetB0 backbone (ImageNet-pretrained) fine-tuned end-to-end; head = GlobalAveragePooling → Dense(256, ReLU) → Dropout(0.4) → Dense(5, softmax). Approximately 4.1M backbone parameters plus ~330k in the head. Weighted categorical cross-entropy, Adam (lr 1e-4), early stopping on validation quadratic weighted kappa.
  • Metrics: Quadratic weighted kappa ≈ 0.80, mean per-class AUC ≈ 0.88, referable-DR sensitivity ≈ 0.90 (design targets for the built-to-order training run), confusion matrix. No figure is claimed as measured until the training run is executed for the order; the report records the achieved values.
Parameter Value
Input format 224 × 224 × 3 RGB fundus image, circular-cropped, CLAHE-enhanced, normalized
Classes 5 (ICDR stages 0–4: No DR / Mild / Moderate / Severe / Proliferative)
Training images 3,662 labeled fundus photographs (APTOS 2019)
Model parameters Approximately 4.4M (expected)
Quadratic weighted kappa ≈ 0.80 (design target, not a measured claim)
Mean per-class AUC ≈ 0.88 (design target, not a measured claim)
Training time Approximately 2–4 hours on a free-tier GPU (expected)
Inference Under 1 s per image on CPU (expected)
Demo Single-file web app, runs offline after download

Project features

  • [EfficientNetB0 transfer learning] An ImageNet-pretrained EfficientNetB0 backbone fine-tuned on APTOS 2019 with a custom classification head — global average pooling, Dense(256, ReLU), Dropout(0.4) and a 5-way softmax — with every layer choice documented.
  • [Interactive fundus grading demo] Select a sample fundus photograph and run the CNN grading; the app shows the predicted stage, per-class probability bars, a lesion summary and a clinical note in a clean medical-dashboard interface.
  • [Lesion-highlight overlay] A toggleable attention overlay marks hemorrhages, exudates and neovascular regions the model weighted most — the standard explainability visual for retinal imaging, labeled illustrative in the demo.
  • [Real APTOS 2019 dataset] 3,662 labeled fundus photographs across the five ICDR stages (No DR 1,805 / Mild 370 / Moderate 999 / Severe 193 / Proliferative 295) — a real, citable public benchmark.
  • [Competition-grade evaluation] Quadratic weighted kappa plus per-class AUC instead of a lone accuracy number, with the severe class imbalance handled by weighted loss — the way retinal grading is actually evaluated.
  • [Full training notebook] Circular crop, CLAHE contrast enhancement, augmentation, model definition, training with early stopping on validation kappa, and evaluation in one reproducible notebook.
  • [Training curves and attention maps] Validation kappa and loss curves plus Grad-CAM-style attention examples across the five stages, included in the report.
  • [Medical-limits documentation] The report states clearly that the build is an educational prototype, not a certified diagnostic device, with the validation steps a real deployment would need.

What is included

  • Complete training & evaluation Jupyter notebook (APTOS loading, CLAHE preprocessing, augmentation, fine-tuning, kappa evaluation)
  • Trained EfficientNetB0 model file with preprocessing code
  • Interactive fundus-grading web demo (samples, probability bars, lesion overlay, clinical notes)
  • Evaluation plots: training curves, per-class metrics table, sample attention maps
  • Project report PDF (background, dataset, architecture rationale, methodology, honest results section, medical-AI limits)
  • PPT presentation for final review
  • Viva Q&A preparation document (transfer learning, quadratic weighted kappa, class imbalance, Grad-CAM, why this is not a diagnostic device)

Limitations & prerequisites

  • An educational grading prototype — not a medical diagnostic device; no clinical claim is made and it must never guide patient care.
  • APTOS 2019 is heavily imbalanced (Severe 193 and Proliferative 295 out of 3,662) — rare stages get fewer training examples, and the report documents per-stage performance honestly instead of hiding it behind overall accuracy.
  • Fundus image quality varies in the public set (blur, poor illumination, artifacts); the report discusses how preprocessing and augmentation manage this rather than eliminate it.
  • The model grades a single image; it does not track progression across visits or integrate patient history.
  • All performance figures are design targets for the training run, stated honestly — the report documents the actual achieved metrics after training.

Frequently Asked Questions

Which dataset is used and is it real?

APTOS 2019 Blindness Detection — 3,662 real labeled retinal fundus photographs across the five ICDR stages, released through the Kaggle competition run by the Asia Pacific Tele-Ophthalmology Society. It is the standard public benchmark for this task.

Why quadratic weighted kappa instead of accuracy?

DR stages are ordered — mistaking Proliferative for No DR is far worse than mistaking it for Severe. Quadratic weighted kappa penalizes far-off errors more than near misses, so it reflects grading quality better than a flat accuracy number; the project also reports per-class AUC.

Why EfficientNetB0 instead of training from scratch?

3,662 images are too few to train a deep CNN from random weights without severe overfitting. Transfer learning reuses ImageNet-learned visual features and fine-tunes them for retinal textures — the report explains this trade-off for the viva.

How does the lesion-highlight overlay work?

The demo shows an attention-style overlay marking the hemorrhage, exudate and neovascular regions the model weighted most for its grade. In the demo it is illustrative of the output format; the shipped build generates the real attention map from the trained network.

Can this be used to screen diabetic patients?

No — and the project states this on every page. It is an educational prototype on public teaching images. Real screening use requires regulated software, far larger curated datasets and clinical validation, all explicitly out of scope.

Is this project suitable for a final-year project?

Yes — for AI & Machine Learning, Computer Science and IT programs. It covers a real medical dataset, transfer learning, ordered-class evaluation, explainability and the ethics of medical AI, with a working demo. Suitable for B.E./B.Tech final-year projects in AI & Machine Learning, Computer Science and IT.

Components & software requirements
  • Python 3, TensorFlow/Keras
  • EfficientNetB0 (ImageNet pretraining, fine-tuned)
  • OpenCV, NumPy, scikit-learn (preprocessing & metrics)
  • Jupyter Notebook (training & evaluation)
  • HTML5 + JavaScript (interactive grading demo)
  • APTOS 2019 Blindness Detection set (Kaggle, 3,662 images)

Dataset & model details

  • Dataset: APTOS 2019 Blindness Detection (Kaggle, Asia Pacific Tele-Ophthalmology Society) — 3,662 labeled retinal fundus photographs across 5 ICDR stages: No DR 1,805 / Mild 370 / Moderate 999 / Severe 193 / Proliferative 295; plus 1,928 test images with hidden labels.
  • Task: 5-class image classification; input = 224×224×3 RGB fundus image, output = probability distribution over the 5 DR stages.
  • Model: EfficientNetB0 backbone (ImageNet-pretrained) fine-tuned end-to-end; head = GlobalAveragePooling → Dense(256, ReLU) → Dropout(0.4) → Dense(5, softmax). Approximately 4.1M backbone parameters plus ~330k in the head. Weighted categorical cross-entropy, Adam (lr 1e-4), early stopping on validation quadratic weighted kappa.
  • Metrics: Quadratic weighted kappa ≈ 0.80, mean per-class AUC ≈ 0.88, referable-DR sensitivity ≈ 0.90 (design targets for the built-to-order training run), confusion matrix. No figure is claimed as measured until the training run is executed for the order; the report records the achieved values.
Delivery information

Built-to-order project. Delivery timeline is shared after order confirmation based on current queue.

Support terms

Complete documentation, setup guide, and viva preparation included. Support for setup and explanation provided.

Download free synopsis (PDF)

Enter your name and WhatsApp number — the synopsis PDF downloads immediately. We may send occasional project updates on WhatsApp; no spam.

Related guides

All guides

Image Segmentation: U-Net and Mask R-CNN

When projects need pixel-level answers, segmentation delivers. This guide explains semantic vs instance vs panoptic segmentation, U-Net's encoder-decoder with skip connections, Mask R-CNN's parallel mask head, Dice and IoU evaluation, paired augmentation, and how to choose the right architecture for your data and question.

Read guide

CNN Transfer Learning for Students: Fine-Tuning ResNet and MobileNet in PyTorch

Train image classifiers on small datasets with transfer learning: load an ImageNet-pretrained backbone, freeze its early layers, replace the classification head for your classes, train the head first, then unfreeze late layers with a small learning rate for fine-tuning. This guide covers backbone choice (ResNet vs MobileNet vs EfficientNet), the exact PyTorch workflow, freezing strategy, data needs per class, and the errors that waste the most time.

Read guide

YOLO Object Detection for Final-Year Projects: Datasets, Colab Training, mAP and Deployment

How do you build a YOLO object detection project for your final year? Start with a labelled dataset in YOLO format (300-500+ images per class with real variation), train a small pretrained model on Google Colab with early stopping, evaluate with mAP@0.5 and mAP@0.5:0.95 on a held-out test set, and deploy the exported model on your demo hardware. This guide covers the full pipeline - version choice, labelling discipline, Colab training, honest evaluation, common errors, and deployment - with the decision tables and checklists your report needs.

Read guide
Get a quotation