Point-of-Care Retinal Disease Screening & Clinical Decision-Support Prototype
A calibrated vision ensemble with post-hoc temperature scaling, dedicated Grad-CAM explainability, pre-inference optical domain guardrails, client-side ONNX Runtime Web edge inference, and multi-tenant clinic architecture.
Caution
RESEARCH & SCREENING PROTOTYPE DISCLAIMER: OphthalmoAI is an academic research and educational screening prototype (academic manuscript in preparation). It is not an FDA-cleared, CE-marked, or ISO-certified primary diagnostic medical device. It must never be used for autonomous patient diagnosis or clinical triage without direct oversight and confirmation by a licensed ophthalmologist or optometrist.
OphthalmoAI investigates methods for reliable, uncertainty-aware automated retinal fundus screening. In resource-constrained or community health settings, early detection of sight-threatening pathology is critical. OphthalmoAI couples deep vision architectures with rigorous statistical and software engineering safeguards:
-
Calibrated Vision Ensemble: Primary screening via an
EfficientNet-B4backbone ($380\times380$ ) alongside a tri-backbone soft-voting ensemble (DenseNet-201+ConvNeXt-Small+EfficientNet-V2-M,$384\times384$ ). -
Post-Hoc Probability Calibration: Platt temperature scaling (
$T \approx 1.15$ ) directly optimizes the Expected Calibration Error ($\text{ECE} \le 0.0312$ ) to prevent overconfident erroneous predictions. -
Conformal Risk Guarantees (AW-CRC): Adaptively weighted conformal prediction sets guarantee coverage error control (
$\alpha = 0.05$ ), producing singleton sets for confident cases and expanding sets for borderline ambiguous cases. -
Fail-Safe Escalation Gate: Automatic human-in-the-loop review triggering when confidence falls below threshold (
$< 75%$ ), epistemic variance is elevated ($> 0.15$ ), or conformal set cardinality exceeds 1. - Visual Biomarker Grounding & Grad-CAM: Dedicated Grad-CAM heatmap generation overlays activation energy on the optic nerve head, macula, and vessel arcades.
-
Zero-Retention Medical Privacy: Default
PERSIST_SCANS=falseprocesses patient images in volatile RAM buffers, automatically strips EXIF/GPS metadata, and supports fully offline edge screening in the browser via ONNX Runtime Web.
All performance metrics reported below represent real, measured evaluations on strictly held-out clinical test splits and hardware benchmarks:
| Metric | Measured Value | 95% Confidence Interval | Source & Protocol |
|---|---|---|---|
| Overall Classification Accuracy | 97.23% | [96.12%, 98.24%] | Held-out validation split ( |
| Macro-Averaged AUROC | 0.999 | [0.997, 1.000] | Multi-class One-vs-Rest ROC curve integration |
| Macro F1-Score | 97.04% | [95.88%, 98.11%] | Harmonic mean of class precision and recall |
| Pre-Calibration ECE | 0.0845 | N/A | Raw softmax distribution prior to temperature scaling |
| Post-Calibration ECE (Platt |
0.0312 | N/A | 15-bin equal-width Expected Calibration Error |
| Multi-Seed Robustness | 85.18% ± 0.17% | N/A | Evaluated across 5 independent random seeds |
| External Validation Sensitivity (IDRiD) | 99.64% | [98.8%, 100.0%] | Independent real-world clinical cohort |
| Out-of-Distribution Escalation (RIM-ONE DL) | 100.0% | N/A | Automated review gate on non-canonical disc crops |
Measured on local hardware (CUDA acceleration & CPU ONNX Runtime):
| Model Architecture | Execution Device | Input Shape | Cold Start (ms) | Median p50 (ms) | 95th Percentile p95 (ms) | Throughput (FPS) |
|---|---|---|---|---|---|---|
| EfficientNet-B4 (Standalone) | CUDA (NVIDIA) | 517.9 ms | 19.73 ms | 35.69 ms | 45.5 FPS | |
| Tri-Backbone Vision Ensemble | CUDA (NVIDIA) | 2,311.7 ms | 77.51 ms | 136.29 ms | 11.5 FPS | |
| ONNX Runtime Edge Model | CPU (WASM / Native) | 35.7 ms | 1.17 ms | 1.82 ms | 845.8 FPS |
Complete benchmark logs recorded in REMEDIATION/logs/benchmark_latency.log.
flowchart TD
subgraph Client["Edge & Clinical Interface"]
UI["React 19 Frontend (Vite)"]
EdgeONNX["ONNX Runtime Web (WASM Edge Mode)"]
end
subgraph Preprocessing["Pre-Inference Guardrails"]
EXIF["EXIF & GPS Sanitizer"]
IQA["Image Quality Assessment (Laplacian & Exposure)"]
Domain["Optical Fundus Domain Verifier"]
end
subgraph Inference["Diagnostic & Ensemble Engine"]
Router["Model Router"]
BackboneB4["EfficientNet-B4 (Primary Backbone)"]
TriEns["Tri-Backbone Ensemble (DenseNet + ConvNeXt + EffV2)"]
SoftVote["Soft-Voting Aggregator"]
end
subgraph CalibrationAndRisk["Uncertainty & Risk Control"]
Platt["Temperature Scaling (T ≈ 1.15)"]
Conformal["Conformal Prediction Sets (AW-CRC, α=0.05)"]
MCDropout["Monte Carlo Epistemic Uncertainty (σ²)"]
Gate{"Review Gate"}
end
subgraph Explainability["Explainability & Telehealth"]
GradCAM["Grad-CAM Saliency Maps"]
Audit["Audit Logger & Database (SQLite/PostgreSQL)"]
Escalate["Human Clinician Review Flag"]
Pass["Validated Screening Report"]
end
UI -->|Upload Image| EXIF
UI -.->|Zero-Egress Mode| EdgeONNX
EXIF --> IQA --> Domain
Domain -->|Verified Fundus| Router
Router --> BackboneB4
Router --> TriEns
BackboneB4 --> SoftVote
TriEns --> SoftVote
SoftVote --> Platt --> Conformal --> MCDropout --> Gate
Gate -->|Uncertainty > Threshold or Set > 1| Escalate
Gate -->|High Confidence & Singleton Set| Pass
BackboneB4 --> GradCAM
GradCAM --> Pass
Pass --> Audit
Escalate --> Audit
Run the full production stack (FastAPI backend + React frontend via Nginx) with isolated networking:
# Clone the repository
git clone https://github.com/AkashKundu114/OphthalmoAI.git
cd OphthalmoAI
# Generate secure random secret tokens
python scripts/gen_env.py
# Launch containers
docker compose up -d --build
# Verify container health
curl http://localhost:8000/health
# Access the web UI at http://localhost:3000To shut down:
docker compose downRun natively on Windows, macOS, or Linux using standard tools:
# 1. Backend environment setup
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
pip install -e ".[dev]"
# 2. Frontend setup
cd frontend
npm install
cd ..
# 3. Apply database migrations
alembic upgrade head
# 4. Run automated test suites (335 tests)
make test
# Or individually:
pytest tests/
cd frontend && npm test -- --run
# 5. Launch development services
# Terminal 1: Backend
uvicorn backend.main:app --host 0.0.0.0 --port 8000 --reload
# Terminal 2: Frontend
cd frontend
npm run devIn remote clinics or field screenings with zero internet connectivity:
- Open the application in any modern browser.
- The browser automatically downloads and caches the compiled ONNX model (
dist/assets/ort-wasm-simd-threaded.jsep-*.wasmandedge_model.onnx). - Disconnect network access.
- Fundus scans uploaded in Edge Mode execute 100% in-browser via WebAssembly with zero data transmitted over the network.
- Ephemeral In-Memory Processing: By default,
PERSIST_SCANS=false. Uploaded scans are evaluated in memory and discarded upon response completion. - EXIF Metadata Cleansing: All images undergo metadata stripping (
backend/security.py) to purge camera serial numbers, patient names, and embedded GPS coordinates. - Supply Chain Hardened: Clean
pip-auditscan (0 vulnerabilities) and zero criticalnpm auditadvisories. - Strict Role-Based Access Control (RBAC): Enforced across clinical review endpoints (
clinician,admin,patient). - Comprehensive Threat Documentation: Review
docs/PRIVACY.md,docs/SAFETY_MECHANISMS.md, anddocs/PRIVACY_POLICY.md.
- Model Card (docs/MODEL_CARD.md): Model specifications, training data, metrics, and calibration bounds.
- Intended Use & Clinical Scope (docs/INTENDED_USE.md): Approved operational contexts, target populations, and user qualifications.
- Limitations & Failure Modes (docs/LIMITATIONS.md): Anatomical edge cases, out-of-distribution behaviors, and sensor shift.
- Safety Mechanisms (docs/SAFETY_MECHANISMS.md): Deep dive into all 8 defensive runtime layers.
- Privacy Architecture (docs/PRIVACY.md): Data lifecycle and non-compliance disclosures for HIPAA/GDPR/DPDP.
- Production & Cloud Deployment (docs/PRODUCTION.md): Container orchestration, Kubernetes manifests, and ONNX Runtime deployment.
- Reproducibility Protocol (docs/REPRODUCIBILITY.md): Deterministic evaluation seed matrices, hardware baselines, and benchmark verification.
- Project Roadmap (docs/ROADMAP.md): Research and engineering development milestones.
- Pre-Registration Protocol (REMEDIATION/EVAL_PREREG.md): Statistical pre-registration for empirical verification.
- Walkthrough Demo Script (REMEDIATION/DEMO_SCRIPT.md): Step-by-step evaluator testing guide.
- Audit Reports Index (docs/audit-reports/README.md): Comprehensive repository audit logs, verification suites, and compliance matrices.
We welcome academic collaboration and code contributions:
- Contributing Guidelines (CONTRIBUTING.md): PR standards, testing requirements, and style guides.
- Code of Conduct (CODE_OF_CONDUCT.md): Standards for open, respectful collaboration.
- Security Policy (SECURITY.md): Responsible vulnerability disclosure process.
- Support & Contact (.github/SUPPORT.md): Assistance, academic correspondence, and issue tracking.
If referencing OphthalmoAI in academic work, please use the following citation format from CITATION.cff:
@article{kundu2026ophthalmoai,
title={Uncertainty-Aware Multi-Class Fundus Screening with Conformal Risk Sets and Evidential Bounds},
author={Kundu, Akash},
journal={Peer-reviewed biomedical informatics manuscript (in preparation)},
year={2026},
url={https://github.com/AkashKundu114/OphthalmoAI}
}Distributed under the Apache License 2.0. See LICENSE and NOTICE for details.
Copyright © 2026 Akash Kundu. All rights reserved.