Built to order

Diabetic Retinopathy Detection using CNN

A medical-imaging AI that detects and grades diabetic retinopathy from retinal fundus photographs using a CNN trained on the APTOS 2019 dataset. The RetinaScan Streamlit app shows the severity grade (no DR to proliferative) with confidence and Grad-CAM heatmaps over lesions, plus a screening dashboard with grade distribution. A referral flag triggers for moderate DR and above. Screening support only — not a diagnostic device. Suitable for B.E./B.Tech final-year projects in AI, Computer Science and Biomedical.

RetinaScan screening app showing a retinal fundus photograph with the diabetic retinopathy severity grade and prediction confidence.
More project photos (2)

The problem

Diabetic retinopathy is one of the leading causes of preventable blindness, and it progresses silently — by the time vision blurs, the damage is often irreversible. Catching it early requires a trained ophthalmologist to examine retinal fundus photographs, but ophthalmologists are scarce, concentrated in cities, and the screening simply does not reach most diabetic patients in time. This is a pattern-matching problem at its core: the disease announces itself through visible lesions — microaneurysms, haemorrhages, exudates — scattered across the retina. Convolutional networks are well suited to exactly this kind of graded visual judgment, and public datasets like APTOS make it trainable as a student project. This build trains a CNN to grade fundus images across five severity levels, shows which lesions drove each decision through Grad-CAM heatmaps, and wraps it in a screening app — an assistive triage tool, explicitly not a diagnosis device.

How it works

  1. A fundus photograph is uploaded to the RetinaScan app (or selected from a batch folder).
  2. Preprocessing: the circular retinal region is cropped, resized to the model's input size, and enhanced with CLAHE to sharpen vessels and lesions.
  3. The image passes through the fine-tuned CNN backbone (EfficientNet/ResNet) trained with transfer learning.
  4. A classification head outputs probabilities for each of the five DR severity grades; the top grade and its confidence are selected.
  5. Grad-CAM computes an activation heatmap from the final convolutional layer, highlighting the lesion regions that drove the decision.
  6. The app displays the grade badge, confidence, per-grade probabilities and the heatmap toggle.
  7. Results are saved to the screening log with timestamps; the dashboard aggregates grade distribution for the session.

Project features

  • Five-grade DR classification (no DR / mild / moderate / severe / proliferative) from fundus photos
  • Transfer learning on EfficientNet/ResNet backbone, fine-tuned on the APTOS 2019 dataset
  • Grad-CAM lesion heatmaps overlaid on the retinal image for explainability
  • Confidence score with every prediction and per-grade probability breakdown
  • RetinaScan Streamlit app: image upload, drag-and-drop batch screening, result cards
  • Fundus image preprocessing: circular crop, contrast enhancement (CLAHE), artifact removal
  • Class-imbalance handling with weighted loss and data augmentation (rotations, flips, zooms)
  • Screening dashboard with grade distribution charts and patient screening history
  • Per-grade precision, recall and confusion matrix computed on a held-out test set
  • Referral recommendation flag: moderate DR and above triggers a "consult an ophthalmologist" alert

What is included

  • Complete, commented Python source code (preprocessing, training, evaluation, app)
  • Trained CNN model weights (fine-tuned on APTOS) ready to load and demo
  • RetinaScan Streamlit web application with screening dashboard
  • Project report PDF (literature survey, methodology, dataset analysis, results, per-grade metrics)
  • PPT presentation
  • Viva Q&A document (transfer learning, Grad-CAM, kappa metric, medical-imaging pitfalls)
  • Setup guide (environment, dependencies, dataset download steps)

FAQs

  1. Why is diabetic retinopathy a good deep-learning topic? It is a graded visual classification problem on a real clinical dataset (APTOS), with transfer learning, class-imbalance handling and Grad-CAM explainability — each a substantial technical chapter in the report.
  2. Which dataset is used? The APTOS 2019 blindness-detection dataset from Kaggle (3,662 labelled fundus images, five severity grades), with EyePACS covered in the literature survey.
  3. Is a GPU needed? Only for training — free Kaggle/Colab GPUs are enough for fine-tuning. The delivered trained model runs inference on a normal CPU laptop in seconds.
  4. What does Grad-CAM add? It shows which retinal regions the model attended to for each grade — the explainability answer to "how does the model decide," displayed as a heatmap over microaneurysms, haemorrhages and exudates.
  5. Can it be demoed live? Yes — the RetinaScan app takes any fundus photo and shows the severity grade, confidence and heatmap; a sample test set is included.
  6. What are the natural extensions? Multi-label lesion detection, a mobile screening app, OCT-image support, or federated learning across hospitals.

Limitations & prerequisites

  • Accuracy depends heavily on image quality — blurred, overexposed or poorly cropped fundus photos degrade grading.
  • The APTOS dataset has severe class imbalance (proliferative cases are rare); performance is weakest on the severe classes.
  • This is a screening aid, not a diagnostic device — it cannot replace an ophthalmologist and must never be presented as one.
  • Grad-CAM heatmaps are approximate localizations, not clinical lesion segmentations.
Components & software requirements
  • Python 3.9+ (NumPy, Pandas, scikit-learn)
  • TensorFlow/Keras (EfficientNet/ResNet transfer learning, fine-tuning)
  • OpenCV (fundus preprocessing, circular crop, CLAHE)
  • Streamlit (RetinaScan screening app)
  • Matplotlib/Seaborn (confusion matrix, training curves, grade distribution charts)
  • Grad-CAM implementation for lesion heatmaps

Specifications

Parameter Value
Task 5-class severity grading: no DR, mild, moderate, severe, proliferative
Dataset APTOS 2019 blindness detection (Kaggle) + EyePACS reference
Model EfficientNet/ResNet backbone, transfer learning with fine-tuned top layers
Input Fundus photographs (JPEG/PNG), resized to 224×224 / 384×384
Test accuracy ~78–86% five-class accuracy on held-out APTOS test split; documented per grade
Key metric Quadratic weighted kappa (~0.80–0.88) — the standard DR competition metric
Explainability Grad-CAM heatmaps over microaneurysms, haemorrhages and exudates
Augmentation Rotation, horizontal flip, zoom, brightness jitter for class imbalance
Web app Streamlit; single-image screening, batch mode, screening dashboard
Disclaimer Screening aid only; every moderate+ case flags ophthalmologist referral

Download abstract (PDF)

Related guides

All guides
Blueprint-style technical illustration of multiple decision trees voting together into one final predictionStudents with basic Python and pandas skills who want a reliable first classifier for ML coursework and tabular data projects.

Random Forests Explained: Why Decision Trees Vote Better Together

Decision trees are readable but overfit; random forests fix this by training hundreds of varied trees on bootstrapped data with random feature subsets, then letting them vote. This guide explains Gini impurity, bagging, out-of-bag validation and the four hyperparameters that matter, with a complete scikit-learn workflow, honest feature-importance practices, and the mistakes students keep making.

Read guide
Illustration of object tracking showing video frames with bounding boxes and persistent ID labels following people and vehicles, comparing motion prediction and appearance matching.B.E./B.Tech Computer Science and Electronics students building video analytics projects — people counting, vehicle tracking, sports analysis — who have detection working and need

Object Tracking: DeepSORT and ByteTrack Explained

Detection finds objects per frame; tracking keeps their identities across frames. This guide explains tracking-by-detection, Kalman motion models, DeepSORT's appearance embeddings vs ByteTrack's low-confidence box recovery, tracking metrics (HOTA, IDF1, ID switches), and the tuning parameters that determine real-world quality.

Read guide
Illustration of image segmentation showing U-Net's U-shaped encoder-decoder with skip connections producing pixel masks, alongside Mask R-CNN detecting instances with masks.B.E./B.Tech Computer Science and AI/ML students moving from image classification or detection to pixel-level understanding — medical imaging, defect detection, autonomous driving

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
Get a quotation