An advanced AI-powered web application for detecting and classifying diabetic retinopathy from retinal fundus images using deep learning.
- AI-Powered Detection: Uses ResNet-152 deep learning architecture for accurate classification
- 5 Severity Levels: Classifies diabetic retinopathy into 5 stages (No DR, Mild, Moderate, Severe, Proliferative DR)
- Modern Web Interface: Beautiful, responsive UI with real-time analysis
- High Accuracy: Trained model achieves medical-grade accuracy
- Detailed Results: Provides confidence scores, probability distributions, and medical recommendations
- Easy to Use: Simple drag-and-drop interface for image upload
- Features
- Installation
- Model Setup
- Usage
- API Documentation
- Project Structure
- Technology Stack
- Research Paper
- License
- Python 3.8 or higher
- pip package manager
- 4GB+ RAM recommended
- CUDA-capable GPU (optional, for faster inference)
git clone <repository-url>
cd Diabetic-Retinopathy-Detection-main# Windows
python -m venv venv
venv\Scripts\activate
# Linux/Mac
python3 -m venv venv
source venv/bin/activatepip install -r requirements.txtThe trained model file (classifier.pt) needs to be downloaded separately due to its large size.
-
Download the pre-trained ResNet-152 model from:
-
Place the
classifier.ptfile in the following location:Diabetic-Retinopathy-Detection-main/ βββ Retinal_blindness_detection_Pytorch-master/ βββ classifier.pt
Ensure the model path in app.py matches your setup:
MODEL_PATH = 'Retinal_blindness_detection_Pytorch-master/classifier.pt'-
Start the Backend Server:
python app.py
The server will start on
http://localhost:5000 -
Access the Web Interface:
- Open your browser and navigate to:
http://localhost:5000 - Or open
frontend/index.htmldirectly in your browser
- Open your browser and navigate to:
-
Upload Image:
- Click on the upload area or drag and drop a retinal fundus image
- Supported formats: PNG, JPG, JPEG (Max 16MB)
-
Analyze:
- Click the "Analyze Image" button
- Wait for the AI model to process the image
-
View Results:
- See the severity classification
- Review confidence scores and probability distribution
- Read medical recommendations
Test images are available in:
Retinal_blindness_detection_Pytorch-master/sampleimages/
http://localhost:5000/api
GET /api/healthResponse:
{
"status": "healthy",
"model_loaded": true,
"device": "cuda" | "cpu"
}POST /api/predictRequest:
- Content-Type:
multipart/form-data - Body:
file(image file)
Response:
{
"severity_value": 0,
"severity_class": "No DR",
"confidence": 98.5,
"probabilities": {
"No DR": 98.5,
"Mild": 1.2,
"Moderate": 0.2,
"Severe": 0.05,
"Proliferative DR": 0.05
},
"info": {
"level": "No DR",
"description": "No signs of diabetic retinopathy detected.",
"recommendation": "Continue regular eye examinations...",
"color": "#10b981",
"risk": "Low"
},
"image_data": "data:image/jpeg;base64,..."
}GET /api/classesResponse:
{
"classes": ["No DR", "Mild", "Moderate", "Severe", "Proliferative DR"],
"info": [...]
}Diabetic-Retinopathy-Detection-main/
βββ app.py # Flask backend server
βββ requirements.txt # Python dependencies
βββ README.md # This file
βββ LICENSE # License file
βββ Research Paper.pdf # Published research paper
β
βββ frontend/ # Web frontend
β βββ index.html # Main HTML file
β βββ styles.css # Styling
β βββ script.js # JavaScript logic
β
βββ Retinal_blindness_detection_Pytorch-master/
β βββ classifier.pt # Trained model (download separately)
β βββ model.py # Model architecture
β βββ blindness.py # Original GUI application
β βββ sampleimages/ # Test images
β βββ training.ipynb # Training notebook
β βββ inference.ipynb # Inference notebook
β βββ requirements.txt # Original requirements
β
βββ uploads/ # Temporary upload folder (auto-created)
- Framework: Flask 2.3.3
- Deep Learning: PyTorch 1.13.1
- Model: ResNet-152 (pretrained and fine-tuned)
- Image Processing: Pillow, torchvision
- API: RESTful API with CORS support
- HTML5: Semantic markup
- CSS3: Modern styling with gradients, animations, glassmorphism
- JavaScript: Vanilla JS (no frameworks)
- Fonts: Inter, Space Grotesk (Google Fonts)
- Base Model: ResNet-152
- Custom Classifier:
- Linear(2048 β 512) + ReLU
- Linear(512 β 5) + LogSoftmax
- Loss Function: Negative Log Likelihood Loss
- Optimizer: Adam
- Input Size: 224Γ224 RGB images
| Level | Classification | Description | Risk |
|---|---|---|---|
| 0 | No DR | No signs of diabetic retinopathy | Low |
| 1 | Mild | Mild non-proliferative diabetic retinopathy | Low-Medium |
| 2 | Moderate | Moderate non-proliferative diabetic retinopathy | Medium |
| 3 | Severe | Severe non-proliferative diabetic retinopathy | High |
| 4 | Proliferative DR | Proliferative diabetic retinopathy | Critical |
This project is based on published research on diabetic retinopathy detection using deep learning. The research paper is included in the repository as Research Paper.pdf.
- Ensure
classifier.ptis in the correct location - Check the
MODEL_PATHvariable inapp.py - Verify the model file is not corrupted
- Ensure Flask-CORS is installed:
pip install flask-cors - Check that the backend server is running
- Use CPU instead of GPU for inference
- Reduce batch size (already set to 1 for single image inference)
- Close other applications
- Change the port in
app.py:app.run(debug=True, host='0.0.0.0', port=5001)
Contributions are welcome! Please feel free to submit a Pull Request.
This tool is for educational and screening purposes only. It is not a substitute for professional medical diagnosis. Always consult with a qualified healthcare professional for medical advice and treatment.
This project is licensed under the MIT License - see the LICENSE file for details.
- Original Model & Research: [Research Team]
- Web Application: [Your Name]
- ResNet architecture by Microsoft Research
- PyTorch framework
- Kaggle for hosting the dataset and model weights
- Medical professionals for domain expertise
For questions or support, please open an issue in the repository.
Made with β€οΈ for early detection and prevention of diabetic retinopathy