Diabetic retinopathy severity grading on APTOS 2019 fundus images using EfficientNet-B0, SMOTE-based class balancing, focal-loss variants, and Grad-CAM-based qualitative explainability.
- Python
3.13 uv
git clone https://github.com/yassyass2/DR-ENb0.git
cd DR-ENb0
uv synccapstone-project/
├── configs/ # Training configuration
├── models/ # Saved .keras models and model notebooks
│ └── preprocessed/ # Saved .npz dataset archive for inference
├── scripts/ # Standalone utility scripts
├── src/dr_grading/ # Package code
└── tests/ # Lightweight structural tests
pyproject.toml
uv.lock
Preprocess the dataset:
uv run dr-grading preprocessTrain with the default config:
uv run dr-grading trainList saved models:
uv run python capstone-project/scripts/predict_saved_model.py --list-modelsRun one saved model on one preprocessed sample:
uv run python capstone-project/scripts/predict_saved_model.py --model 1 --split test --index 0Interactive mode:
uv run python capstone-project/scripts/predict_saved_model.pyShow script help with the current discovered model names:
uv run python capstone-project/scripts/predict_saved_model.py --helpDownload the preprocessed .npz archive from Google Drive:
uv run python capstone-project/scripts/download_preprocessed_npz.pyThe capstone-project/models/ folder currently contains these final saved .keras models:
SMOTE.kerasSMOTE_+_Focal_Loss_IoU.kerasSMOTE_+_Focal_loss.kerasSMOTE_IoU.keras
The prediction script accepts:
- a model number from the discovered list
- a model filename such as
SMOTE_IoU.keras - a full filesystem path to a
.kerasfile
The saved-model prediction workflow uses:
capstone-project/models/preprocessed/dr_preprocessed_data.npz
It loads these arrays:
X_train,y_trainX_val,y_valX_test,y_test
By default the prediction script uses the .npz archive above, but it can also load a directory of split .npy arrays.
If the archive is missing locally, predict_saved_model.py now downloads it automatically from the configured Google Drive link before running inference.
You can also download it manually with:
uv run python capstone-project/scripts/download_preprocessed_npz.pyFor a selected image, the script prints:
- true label and class name
- predicted label and class name
- confidence of the top prediction
- whether the prediction was correct
- prediction margin between the top two classes
- entropy of the probability distribution
- per-class probabilities
APTOS 2019 Blindness Detection
Labels are the diabetic retinopathy severity grades 0 through 4.
- Adel
- Mark
- Musab
- Ozeir
- Yassine