An attention mechanism designed to suit the identification of micro and macro lesions in retinal fundus images for accurate diabetic retinopathy classification.
This paper has been accepted at IEEE International Conference on Image Processing (ICIP), 2024.
[IEEE Xplore][arXiv][Demo][Dataset]
Diabetic Retinopathy (DR) grading is a highly challenging task due to the complexity of lesion variability and their contribution to different severity grades. Lesions such as Microaneurysms, Exudates, Hemorrhages, and Cotton Wool Spots vary significantly in size, shape, and appearance, often misleading the classification process. Some lesions are barely visible, while others are prominent, yet every minor lesion plays a critical role in determining the correct severity grade. Misclassifying even a single lesion can lead to incorrect grading, as the distinction between severity grades is often subtle and highly dependent on lesion characteristics.
Our approach consists of three key sub-blocks:
- Context Formulation: Captures the global spatial context of the image.
- Channel Correlation: Identifies channel-wise relationships to enhance feature relevance.
- Guided Gating: Uses the global context as a guiding signal to zero in on localized lesions.
| Class | Acc | Prec | Rec | F1 | AUC | Support |
|---|---|---|---|---|---|---|
| No DR | 95.65 | 91.67 | 95.65 | 93.62 | 99.43 | 23 |
| Mild NPDR | 100.0 | 100.0 | 100.0 | 100.0 | 100.0 | 01 |
| Moderate NPDR | 75.00 | 80.00 | 75.00 | 77.42 | 92.97 | 16 |
| Severe NPDR | 100.0 | 97.37 | 100.0 | 98.67 | 100 | 37 |
| Very Severe NPDR | 55.56 | 66.67 | 55.56 | 60.61 | 92.68 | 18 |
| PDR | 97.14 | 94.44 | 97.14 | 95.77 | 99.56 | 35 |
| Advanced PDR | 95.45 | 91.3 | 95.45 | 93.33 | 99.09 | 22 |
| Macro | 90.13 | 88.78 | 88.4 | 88.49 | 97.80 | 152 |
| Weighted | - | 89.51 | 90.13 | 89.73 | 98.64 | - |
-
Creating a Virtual Environment:
- The command
python -m venv gcg_venvworks the same on Windows, macOS, and Linux.
- The command
-
Activating the Virtual Environment:
- On macOS/Linux, use
source gcg_venv/bin/activate. - On Windows, use
gcg_venv\Scripts\activate.
- On macOS/Linux, use
-
Installing the project:
pip install git+https://github.com/TejaCherukuri/Guided-Context-Gating.git-
Install all the necessary dependencies:
(Optional if using
pip install git+<url>, as dependencies are installed automatically.)
pip install -r requirements.txt- Prepare a list of test image paths (relative to your working directory).
- Pass the list of paths to the
predict()method from the inference pipeline. - The method will return predictions and generate visual outputs.
from gcg.pipelines import predict
# Example test image paths
image_paths = [
'test_images/image_1.jpg',
'test_images/image_2.jpg'
]
# Get predictions
predictions = predict(image_paths)
print(predictions)Outputs
- Predictions: The predicted classes for the provided images.
- Heatmaps and Superimposed Images:
- Generated for each test image.
- Saved to the
heatmapsdirectory in your working directory.
Example heatmap:
For those of you who prefer user interface over code, access the link to huggingface spaces [Demo]
If you find GCG useful for your research and applications, please cite using this BibTeX:
@article{cherukuri2024guided,
title={Guided Context Gating: Learning to leverage salient lesions in retinal fundus images},
author={Cherukuri, Teja Krishna and Shaik, Nagur Shareef and Ye, Dong Hye},
journal={arXiv preprint arXiv:2406.13126},
year={2024}
}This project is licensed under the MIT License. See LICENSE for details.


