Automated detection of diabetic retinopathy from retinal images using deep learning. This project utilizes an ensemble of EfficientNet-B3 models trained with 5-fold cross-validation to achieve high accuracy and robustness.
- Model: EfficientNet-B3 (Ensemble of 5 folds)
- Input Resolution: 300x300
- Test Set QWK: 0.9091 (on held-out test split)
- Validation QWK: ~0.78 (Mean across 5 folds)
# Create virtual environment
python -m venv venv
source venv/bin/activate # Linux/Mac
# venv\Scripts\activate # Windows
# Install dependencies
pip install -r requirements.txtEnsure your data is organized as follows:
dr_detection/
├── dataset_3500/ # Directory containing all training images
├── trainLabels.csv # CSV with 'image' and 'level' columns
├── src/ # Source code
├── checkpoints/ # Saved models
└── outputs/ # Test splits and predictions
The training script automatically handles 5-fold cross-validation and creates a held-out test split.
# Train with default settings (EfficientNet-B3, 300x300, 50 epochs)
python src/main.py --data-dir dataset_3500 --test-split-ratio 0.2
# Custom training parameters
python src/main.py \
--data-dir dataset_3500 \
--backbone efficientnet_b3 \
--image-size 300 \
--batch-size 8 \
--epochs 50 \
--test-split-ratio 0.2Evaluate the trained ensemble on the held-out test set.
# Evaluate ensemble on the test split generated during training
python src/evaluate.py \
--data-dir dataset_3500 \
--test-file outputs/test_split.csv \
--backbone efficientnet_b3 \
--image-size 300 \
--batch-size 8 \
--ensembleCreate Custom Split:
If you need to regenerate a test split manually:
python src/create_split.py --data-dir dataset_3500 --test-size 0.2Cleanup Checkpoints:
To remove intermediate checkpoints and keep only the best models per fold:
python cleanup_checkpoints.pysrc/main.py: Main training orchestration (CV loops, logging).src/trainer.py: Training loop logic, checkpointing, and validation.src/model.py: Model architecture definitions (ResNet, EfficientNet).src/dataset.py: Data loading, preprocessing, and augmentation.src/evaluate.py: Evaluation scripts for single models and ensembles.src/args.py: Command-line argument definitions.