π Live Demo: https://dr.duminduthushan.com
An AI-powered multi-modal system for diabetic retinopathy risk assessment combining clinical data analysis with retinal image processing
- Overview
- Features
- Architecture
- Tech Stack
- Installation
- Usage
- API Documentation
- Model Performance
- Deployment
- Project Structure
- Contributing
- License
- Contact
The Diabetic Retinopathy Detection System is a comprehensive healthcare AI solution that combines clinical data analysis with retinal image processing to provide accurate risk assessments for diabetic retinopathy. The system employs ensemble machine learning models and deep learning techniques to achieve high accuracy in early detection.
- Early Detection: Identify DR risk before symptoms appear
- Multi-Modal Analysis: Combine clinical and imaging data for better accuracy
- Accessible Healthcare: Provide rapid, automated screening
- Clinical Decision Support: Assist healthcare providers with AI-powered insights
- 13+ Clinical Parameters: Comprehensive health metrics analysis
- Real-time Risk Assessment: Instant prediction results
- Ensemble Models: XGBoost + Random Forest for robust predictions
- 87.8% Accuracy: Validated on PIMA Indian Diabetes Dataset
- Retinal Image Processing: Advanced preprocessing with CLAHE
- Transfer Learning: MobileNetV2 architecture
- Multi-class Classification: 5-stage DR severity detection
- Real-time Processing: Fast inference for clinical use
- Multi-Modal Integration: Combines clinical and image predictions
- Weighted Risk Scoring: Intelligent risk aggregation
- Confidence Metrics: Prediction reliability indicators
- Feature Importance: Shows key risk factors
- Responsive Design: Works on desktop, tablet, and mobile
- Real-time Validation: Immediate input feedback
- Interactive Visualizations: Risk meters and progress bars
- Professional Medical UI: Healthcare-grade interface
graph TB
subgraph "Frontend - Vercel"
A[React App] --> B[Form Validation]
B --> C[API Client]
end
subgraph "Backend - Contabo VPS"
D[FastAPI Server] --> E[Model Pipeline]
E --> F[Clinical Model]
E --> G[Image Model]
E --> H[Fusion Model]
end
subgraph "ML Pipeline"
I[Data Preprocessing] --> J[Feature Engineering]
J --> K[Model Inference]
K --> L[Risk Calculation]
end
C -->|HTTPS| D
F --> L
G --> L
H --> L
L --> M[Results]
| Technology | Purpose |
|---|---|
| Core programming language | |
| REST API framework | |
| Deep learning framework | |
| Machine learning library | |
| Image processing | |
| Numerical computing | |
| Data manipulation |
| Technology | Purpose |
|---|---|
| UI framework | |
| Programming language | |
| Styling | |
| HTTP client |
| Technology | Purpose |
|---|---|
| Containerization | |
| Frontend hosting | |
| Reverse proxy | |
| Server OS |
- Python 3.9+
- Node.js 16+
- Git
git clone https://github.com/yourusername/diabetic-retinopathy-ai.git
cd diabetic-retinopathy-ai# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Train models (optional - pre-trained models included)
python ml-pipeline/src/train_clinical_model.py
python ml-pipeline/src/train_image_model.py
# Start backend server
python backend/main.py# Navigate to frontend directory
cd frontend
# Install dependencies
npm install
# Start development server
npm start# Build and run with Docker Compose
docker-compose up --build
# Access application
# Frontend: http://localhost:3000
# Backend: http://localhost:8000| Metric | Score |
|---|---|
| Accuracy | 87.8% |
| Precision | 84.5% |
| Recall | 89.2% |
| F1-Score | 86.8% |
| AUC-ROC | 0.921 |
| Metric | Score |
|---|---|
| Accuracy | 85.0%* |
| Precision | 82.3%* |
| Recall | 87.6%* |
| F1-Score | 84.9%* |
| AUC-ROC | 0.904* |
*Note: Image model currently trained on synthetic data for demonstration. Production deployment would use APTOS 2019 or EyePACS datasets for real clinical accuracy.
| Metric | Score |
|---|---|
| Combined Accuracy | 92.0% |
| Clinical Weight | 0.6 |
| Image Weight | 0.4 |
diabetic-retinopathy-ai/
βββ π backend/
β βββ main.py # FastAPI application
β βββ models.py # Pydantic models
β βββ utils.py # Utility functions
β βββ requirements.txt # Python dependencies
β
βββ π frontend/
β βββ π src/
β β βββ App.js # Main React component
β β βββ App.css # Styles
β β βββ π components/ # React components
β βββ package.json # Node dependencies
β βββ public/ # Static assets
β
βββ π ml-pipeline/
β βββ π src/
β β βββ train_clinical_model.py
β β βββ train_image_model.py
β β βββ train_fusion_model.py
β βββ π models/ # Trained models
β βββ π data/ # Training data
β
βββ π docker/
β βββ Dockerfile
β βββ docker-compose.yml
β βββ nginx.conf
β
βββ README.md
https://api.dr.duminduthushan.com
GET /healthPOST /predict/clinical
Content-Type: application/json
{
"glucose": 120,
"blood_pressure": 70,
"bmi": 25.5,
"age": 35,
...
}POST /predict/combined
Content-Type: multipart/form-data
Form Data:
- data: JSON clinical data
- image: Retinal image fileGET /models/infoThe system is deployed using a distributed architecture:
- Frontend: Vercel (Global CDN)
- Backend: Contabo VPS (4 vCPU, 8GB RAM)
- Domain: Cloudflare DNS
- SSL: Let's Encrypt
# Frontend (Vercel)
vercel --prod
# Backend (VPS)
ssh user@vps-ip
cd /opt/dr-detection
docker-compose up -dContributions are welcome! Please follow these steps:
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This system is designed for educational and research purposes only. It should not be used as a substitute for professional medical diagnosis or treatment. Always consult qualified healthcare providers for medical decisions.
This project is licensed under the MIT License - see the LICENSE file for details.
Dumindu Thushan
- Website: duminduthushan.com
- Project Link: https://github.com/yourusername/diabetic-retinopathy-ai
- Live Demo: https://dr.duminduthushan.com