Research-to-product AI system for non-invasive cardiovascular risk prediction from retinal fundus images.
Python
PyTorch
FastAPI
Docker
License
CI
IMPORTANT DISCLAIMER: This project is a research prototype for educational and experimental use only. It is not intended for clinical diagnosis, treatment decisions, or as a substitute for professional medical advice. Always consult a qualified healthcare professional.
Problem Statement
Cardiovascular disease (CVD) remains the leading cause of mortality worldwide. Traditional screening methods are often invasive, expensive, and inaccessible. Recent research has established that the retinal vasculature shares embryological and physiological properties with the coronary vasculature, making retinal fundus imaging a potential non-invasive window into cardiovascular health.
CardioRetina-AI leverages deep learning to analyze retinal fundus images alongside clinical health metrics to predict heart disease risk, enabling early screening in settings where traditional cardiac imaging may be unavailable.
Why Retinal Images?
The retinal microvasculature is the only directly observable vascular bed in the human body. Changes in retinal vessel caliber, tortuosity, and branching patterns have been associated with:
Hypertension and atherosclerosis
Coronary artery disease
Stroke risk
Diabetic vascular complications
Architecture
mermaid
1graph TD
2 A[Retinal Fundus Image<br/>224x224 RGB]--> B[EfficientNet-B3<br/>Local Features]3 A --> C[Vision Transformer<br/>Global Context]4 D[Clinical Data<br/>8 Features]--> E[Dense Network<br/>64 → 32]5 B --> F[Feature Fusion Layer]6 C --> F
7 E --> F
8 F --> G[Classification<br/>128 → 64 → 32 → 1]9 G --> H[Sigmoid Output<br/>Risk Probability 0-1]10 H --> I[Grad-CAM / SHAP<br/>Explainability]
Component
Details
CNN Backbone
EfficientNet-B3 (ImageNet pretrained, frozen early layers)
ViT Module
ViT-Base-Patch16-224 with projection layer
Clinical Network
Dense 64→32 for 8 health metrics
Fusion
Concatenation → 128→64→32 with BatchNorm + Dropout
Output
Sigmoid → [0, 1] risk probability
Loss
Binary Cross-Entropy
Optimizer
Adam (lr=0.001, weight_decay=1e-4)
Scheduler
ReduceLROnPlateau (patience=5, factor=0.5)
Early Stopping
patience=10
Features
Hybrid CNN + ViT architecture for complementary local and global feature extraction
Compares: CNN-only, ViT-only, CNN+ViT, CNN+ViT+Clinical. Outputs markdown table and JSON.
Inference API
bash
1# Start the API server2uvicorn cardioretina.api.app:app --host 0.0.0.0 --port 800034# Or with environment variables5MODEL_CHECKPOINT=checkpoints/best_model.pt uvicorn cardioretina.api.app:app
1# Build and run2cddocker3docker compose up --build
45# Or with Docker directly6docker build -f docker/Dockerfile -t cardioretina-ai .7docker run -p 8000:8000 cardioretina-ai
GPU support: Uncomment the GPU section in docker/docker-compose.yml.
1# Run all tests2pytest tests/ -v
34# Run with coverage5pytest tests/ -v --tb=short
67# Lint check8ruff check cardioretina/ tests/
Research References
Poplin, R., et al. (2018). "Prediction of cardiovascular risk factors from retinal fundus photographs via deep learning." Nature Biomedical Engineering, 2(3), 158-164.
Wong, T. Y., & Mitchell, P. (2004). "Hypertensive retinopathy." New England Journal of Medicine, 351(22), 2310-2317.
Tan, M., & Le, Q. V. (2019). "EfficientNet: Rethinking Model Scaling for Convolutional Neural Networks." ICML 2019.
Dosovitskiy, A., et al. (2021). "An Image is Worth 16x16 Words: Transformers for Image Recognition at Scale." ICLR 2021.
Selvaraju, R. R., et al. (2017). "Grad-CAM: Visual Explanations from Deep Networks via Gradient-based Localization." ICCV 2017.
Limitations
No clinical validation: This system has not been validated in a clinical setting
Dataset dependency: Performance depends on the quality and diversity of training data
Dataset bias: Retinal datasets may underrepresent certain demographics
Interpretability: Grad-CAM highlights are supportive, not definitive diagnostic indicators
Single-image analysis: Does not account for longitudinal changes
Generalization: Model may not generalize across different fundus camera types
Future Work
External validation on independent clinical cohorts
Larger, multi-center datasets
Doctor-facing clinical dashboard with patient management
Federated learning for privacy-preserving multi-institution training
Model calibration and threshold optimization
ONNX/TensorRT deployment on cloud GPU
Clinical workflow integration via FHIR/HL7
Multi-task learning for concurrent disease prediction
Attention visualization for ViT patches
License
This project is licensed under the MIT License. See LICENSE for details.
CardioRetina-AI is a research prototype. Not for clinical use.