Spaces:
Sleeping
A newer version of the Gradio SDK is available:
6.6.0
title: Eye Disease Detection Models
emoji: ππ
colorFrom: green
colorTo: blue
sdk: gradio
sdk_version: 5.29.0
python_version: 3.12
app_file: gradio-inference.py
pinned: true
short_description: Eye disease detection using deep learning models
license: apache-2.0
Eye Disease Detection
This repository contains a Gradio web application for eye disease detection using deep learning models. The application allows users to upload fundus photographs and get predictions for common eye conditions.
Features
- Easy-to-use web interface for eye disease detection
- Support for multiple model architectures (MobileNetV4, LeViT, EfficientViT, GENet, RegNetX)
- Custom model loading from saved model checkpoints
- Visualization of prediction probabilities
- Dockerized deployment option
Supported Eye Conditions
The system can detect the following eye conditions:
- Central Serous Chorioretinopathy
- Diabetic Retinopathy
- Disc Edema
- Glaucoma
- Healthy (normal eye)
- Macular Scar
- Myopia
- Retinal Detachment
- Retinitis Pigmentosa
Installation
Prerequisites
- Python 3.12+
- PyTorch 2.7.0+
- CUDA-compatible GPU (optional, but recommended for faster inference)
Option 1: Local Installation
Clone this repository:
git clone https://github.com/GilbertKrantz/eye-disease-detection.git cd eye-disease-detectionInstall the required packages:
pip install -r requirements.txtRun the application:
python gradio_inference.pyOpen your browser and go to http://localhost:7860
Option 2: Docker Installation
Build the Docker image:
docker build -t eye-disease-detection .Run the container:
docker run -p 7860:7860 eye-disease-detectionOpen your browser and go to http://localhost:7860
Usage
- Upload a fundus image of the eye
- (Optional) Specify the path to your trained model file (.pth)
- Select the model architecture (MobileNetV4, LeViT, EfficientViT, GENet, RegNetX)
- Click "Analyze Image" to get the prediction
- View the results and probability distribution
Model Training
This repository focuses on inference. For training your own models, refer to the main training script and follow these steps:
- Prepare your dataset in the required directory structure
- Train a model using the main.py script:
python main.py --train-dir "/path/to/training/data" --eval-dir "/path/to/eval/data" --model mobilenetv4 --epochs 20 --save-model "my_model.pth" - Use the saved model with the inference application
Project Structure
.
βββ gradio_inference.py # Main Gradio application
βββ requirements.txt # Python dependencies
βββ Dockerfile # Docker configuration
βββ README.md # This documentation
βββ utils/ # Utility modules
β βββ ModelCreator.py # Model architecture definitions
β βββ Evaluator.py # Model evaluation utilities
β βββ DatasetHandler.py # Dataset handling utilities
β βββ Trainer.py # Model training utilities
β βββ Callback.py # Training callbacks
βββ main.py # Main training script
Performance
The performance of the models depends on the quality of training data and the specific architecture used. In general, these models can achieve accuracy rates of 85-95% on standard eye disease datasets.
Customization
You can customize the application in several ways:
- Add example images in the Gradio interface
- Extend the list of supported classes by modifying the CLASSES variable in gradio_inference.py
- Add support for additional model architectures in ModelCreator.py
License
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Acknowledgments
- The models are built using PyTorch and the TIMM library
- The web interface is built using Gradio
- Special thanks to the open-source community for making this project possible