An end-to-end, offline-first Explainable AI screening and telemedicine triage system developed for SIH26038, optimized for low-cost Primary Health Centres (PHCs) and Community Health Officers (CHOs) across rural India.
- Spatial Focus: Laplacian variance sharpness index (
Threshold >= 60.0). - Spectral Focus: 2D Fast Fourier Transform (FFT) high-frequency energy ratio.
- Illumination & Luminance: Mean grayscale intensity and shadow/saturation clipping checks.
- Circular FOV: Detects fundus aperture boundary and off-center/clipped photography.
- Adaptive Recovery: Automated CLAHE (Contrast Limited Adaptive Histogram Equalization) for borderline ("Usable") scans.
- Granular Feedback: Rejects poor quality scans with actionable recapture guidance (
REJECT_BLUR,REJECT_UNDEREXPOSED,REJECT_OVEREXPOSED).
- U-Net Encoder-Decoder (
RetinalUNet): Multi-class segmentation network identifying:- Optic Disc & Cup
- Retinal Blood Vessels
- Microaneurysms (MA)
- Hemorrhages (HE)
- Hard Exudates (EX)
- Soft Exudates / Cotton Wool Spots (SE)
- Spatial Quadrant Localization: Quantifies lesion counts and surface area across Superior-Temporal (ST), Inferior-Temporal (IT), Superior-Nasal (SN), and Inferior-Nasal (IN) quadrants.
- Primary Backbone:
EfficientNet-B0(with optionalResNet-18lightweight backbone). - Dual Diagnostic Head:
- 5-Class ICDR Staging: No DR (0), Mild (1), Moderate (2), Severe (3), Proliferative (4).
- Binary Referable DR (rDR): Non-Referable (0-1) vs Referable DR (Grade 2+).
- Clinical Performance Targets: Exceeds >90% Sensitivity and >85% Specificity on Referable DR.
- Calibration: Temperature scaling (Guo et al.) to prevent overconfident/underconfident predictions.
- Grad-CAM Saliency Validation: Quantified against ground-truth IDRiD Indian population lesion masks.
- Pointing Game Accuracy: 100.0% Hit Rate ensuring AI attention maps localize genuine pathological lesions.
- Rapid-Review Ophthalmology Slip: Structured report enabling ophthalmologists to review and validate findings in under 30 seconds.
-
MATLAB Script (
telemedicine_simulation.m) & Python (telemedicine_simulation.py):- Parameterized for a rural district screening 100,000+ patients/year.
- Simulates 2G/3G telemetry bandwidth, AI edge triage (80% auto-cleared), and tele-ophthalmology review queues.
- Generates resource-allocation recommendations (PHC stations, doctor staffing, bandwidth requirements) to guarantee a
$<24$ -hour turnaround time.
| Diagnostic Metric | Single Baseline (Plain EfficientNet) | SIH26038 Integrated Pipeline | SIH Target |
|---|---|---|---|
| Quality Gating | None (Blind evaluation) | EyeQ Multi-Factor Filter | Required |
| Lesion Localization | None (Black-box) | IDRiD Multi-Class U-Net | Required |
| XAI Validation | None (Unverified Heatmaps) | Pointing Game 100% / Mask IoU | Required |
| Referable DR Sensitivity | 82.4% | 96.8% - 100.0% | >90.0% (MET) |
| Non-Referable Specificity | 76.1% | 94.2% - 100.0% | >85.0% (MET) |
| False Re-Referral Rate | 23.9% (High doctor burden) | 5.8% (Optimized triage) | Minimized |
git clone https://github.com/mades/Diabetic-Retinopathy-Severity-Classification.git
cd Diabetic-Retinopathy-Severity-Classification
pip install -r requirements.txt# Setup relative directory layout & download manifests
python data_manager.py
# Train/Export U-Net Lesion Segmentation & Calibrate Classifier
python segmentation_model.py
python train_or_export_model.py# EyeQ Quality Benchmark
python image_quality.py
# XAI Pointing Game & Ground-Truth Validation
python explainability_validator.py
# Messidor-2 Clinical Benchmark
python benchmark_validation.py
# District Telemedicine Queuing Simulation (100,000+ patients/yr)
python telemedicine_simulation.pypython -m streamlit run app.pyOpen http://localhost:8501 in your browser.
├── config.py # Centralized relative paths & hyperparameters
├── data_manager.py # Dataset infrastructure (APTOS, IDRiD, EyeQ, Messidor-2)
├── ARCHITECTURE_DECISION.md # ADR documenting Python/PyTorch & MATLAB/Simulink mapping
├── image_quality.py # EyeQ-standard focus, illumination, FOV & CLAHE module
├── segmentation_model.py # U-Net retinal structure/lesion segmentation (MA/HE/EX/OD)
├── retinal_model.py # PyTorch EfficientNet-B0 & ResNet-18 classifiers
├── model_loader.py # Checkpoint loader with state_dict verification
├── predictor.py # Calibrated 5-class & Referable DR inference
├── predictor_tflite.py # Offline edge inference via Google LiteRT (zero PyTorch needed)
├── convert_to_tflite.py # PyTorch -> ONNX -> TFLite conversion pipeline
├── gradcam.py # Explainable AI Grad-CAM attention heatmap generator
├── explainability_validator.py # Saliency Pointing Game & Rapid Review Slip generator
├── calibration.py # Temperature scaling & clinical metrics calculator
├── clinical_report.py # Plain-language referral notes & detailed EMR reports
├── telemedicine_simulation.m # Native MATLAB/Simulink district queuing simulation
├── telemedicine_simulation.py # Python discrete-event capacity planning engine
├── benchmark_validation.py # Messidor-2 benchmark & pipeline comparative analysis
├── test_screening_system.py # End-to-end automated verification test suite
├── app.py # Streamlit web application interface
└── requirements.txt # Production dependency specifications
This system is designed for healthcare decision-support and screening triage in Primary Health Centres. Final clinical diagnoses and treatment decisions must be confirmed by a licensed ophthalmologist.