NetraScan is a clinical-grade AI and systems-engineering platform for automated Diabetic Retinopathy (DR) screening, triage, and district-level healthcare capacity planning. It integrates deep learning (MATLAB-trained ResNet-18 via ONNX Runtime), Explainable AI (Grad-CAM on res5b_relu), automated clinical report synthesis, and MATLAB/Simulink capacity modeling for rural and urban tele-ophthalmology networks.
+-------------------+
| Raw Fundus Scan | (Color fundus photograph from camera or smartphone adapter)
+---------+---------+
|
v
+---------+---------+
| Quality Gate | (OpenCV Laplacian Variance Blur & Integrity Gatekeeper: >= 100.0)
+---------+---------+
|
+----[ Blur / Corrupt ]---> [ Return Recapture Advice (Status 200) ]
|
v [ Passed Quality Check ]
+---------+---------+
| CLAHE | (Channel-wise Adaptive Histogram Equalization matching MATLAB preprocess_fundus.m)
+---------+---------+
|
v
+---------+---------+
| MATLAB ResNet-18 | (5-Class ICDR Severity Classification: Grade 0 - 4 via ONNX Runtime)
+---------+---------+
|
v
+---------+---------------------------------+
| ICDR Grade + Grad-CAM Heatmap Overlay | (res5b_relu Layer Explainable AI Biomarker Localization)
+---------+---------------------------------+
|
v
+---------+---------+
| Referral Triage | (Calibrated 0.35 Referable DR Threshold: Grade 2, 3, 4 sum >= 0.35)
+---------+---------+
|
v
+---------+---------+
| Report Engine | (Styled Clinical HTML & Printable Diagnostic Report)
+---------+---------+
|
v
+---------+---------+
| Simulink Queue | (District Tele-Ophthalmology Patient Flow & Triage Simulation)
+-------------------+
NetraScan/
├── backend/ # FastAPI backend services, schemas, and API routes
│ ├── main.py # Application entrypoint & dynamic AI service loader
│ ├── schemas.py # Pydantic data contracts & response models
│ ├── requirements.txt # Python dependency specifications (onnxruntime, fastapi, opencv)
│ ├── services/
│ │ ├── ai_service.py # Finalized MATLAB ResNet-18 ONNX Runtime inference service
│ │ ├── preprocessing.py # MATLAB-consistent channel-wise CLAHE preprocessing
│ │ ├── gradcam.py # Authentic res5b_relu Grad-CAM / CAM explainability engine
│ │ ├── file_validation_service.py # Image integrity & Laplacian blur gatekeeper
│ │ ├── mock_ai_service.py # Mock AI service for offline UI development
│ │ └── report_service.py # Clinical HTML report generator & storage
│ └── tests/
│ └── test_ml_pipeline.py # Automated test suite for ONNX inference & Grad-CAM
│
├── frontend/ # Web user interface & tele-ophthalmology dashboard
│ ├── src/ # React / Vite components, pages, context, and styles
│ ├── public/ # Static assets, branding, sample fundus images
│ └── package.json # Frontend dependencies & build scripts
│
├── ml-training/ # Deep learning models, MATLAB preprocessing & explainability
│ ├── models/
│ │ └── NetraScan_ResNet18.onnx # Finalized 5-class MATLAB ResNet-18 ONNX model
│ ├── preprocessing/
│ │ └── preprocess_fundus.m # Canonical MATLAB preprocessing reference
│ └── explainability/
│ └── NetraScan_Explainability.m # MATLAB Grad-CAM reference implementation
│
├── demo_samples/ # Validated sample fundus scans (Normal, Moderate DR, Blurry)
└── simulink/ # District workflow & tele-ophthalmology capacity models
# Navigate to backend directory
cd backend
# Create and activate virtual environment
python3 -m venv ../venv
source ../venv/bin/activate # On Windows: ..\venv\Scripts\activate
# Install required dependencies
pip install -r requirements.txtexport NETRASCAN_USE_MOCK=false
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadexport NETRASCAN_USE_MOCK=true
uvicorn main:app --host 0.0.0.0 --port 8000 --reloadInteractive Swagger API docs available at: http://127.0.0.1:8000/docs
| Method | Endpoint | Description | Payload / Query | Response Type |
|---|---|---|---|---|
GET |
/health |
System health, model name (NetraScan ResNet-18), runtime (onnxruntime), target layer (res5b_relu) |
None | HealthResponse (JSON) |
POST |
/analyze |
Fundus image quality check, 5-class DR classification, res5b_relu Grad-CAM | file: UploadFile (multipart) |
AnalysisResponse (Union) |
POST |
/report/generate |
Generates & persists branded clinical HTML report | ReportGenerateRequest (JSON) |
{ status, report_id, view_url, download_url } |
GET |
/report/{id} |
Views report in browser or downloads file (?download=true) |
id: str, download: bool |
text/html |
| Clinical Metric | Target Benchmark | Measured Performance | Clinical Justification |
|---|---|---|---|
| Model Architecture | ResNet-18 (224x224x3) | MATLAB ResNet-18 ONNX | Finalized deep convolutional model. |
| Referable DR Sensitivity | Minimizes false negatives for sight-threatening DR (Grade |
||
| Referable DR Specificity | Prevents overwhelming tertiary referral centers with false positives. | ||
| Overall Accuracy | Multi-class ICDR grading accuracy. | ||
| Referable Decision Threshold | 0.35 | 0.35 | Calibrated probability threshold for Grade 2+ referral. |
| Quality Gate Filtering | Laplacian |
100% Reject Blur | Rejects ungradable/blurry fundus images prior to inference. |
| Explainability (Grad-CAM) | res5b_relu |
Real CAM Layer | Attention maps on retinal lesions and vascular abnormalities. |
| Inference Latency | Real-time point-of-care screening in tele-ophthalmology clinics. |
This project is licensed under the MIT License - see the LICENSE file for details.