Explainable Deep Learning for Corn Gray Leaf Spot Detection
This repository provides four PyTorch models trained for binary classification of corn (maize) leaf images into the following categories:
- Healthy
- Gray Leaf Spot (Cercospora Leaf Spot)
The models were developed as part of a research study focused on improving the transparency and trustworthiness of deep learning–based plant disease detection systems using explainable artificial intelligence techniques.
Models Included
- ResNet50 (trained without random data augmentation)
- ResNet50 (trained with random data augmentation)
- EfficientNet-B0 (trained without random data augmentation)
- EfficientNet-B0 (trained with random data augmentation)
Dataset
Training Dataset:
PlantVillage dataset (Corn Healthy and Corn Gray Leaf Spot classes)External Evaluation Dataset:
PlantDoc dataset (used to evaluate generalization performance)
Explainability
All trained models were analyzed using Gradient-weighted Class Activation Mapping (Grad-CAM) to visualize the spatial regions of the leaf images that most strongly influenced model predictions. This helps verify whether the models focus on biologically meaningful disease symptoms rather than irrelevant background features.
Inference Instructions
Users can perform inference on their own corn leaf images using the provided
inference.py script.
Step 1: Clone the Repository
git clone https://huggingface.co/PulinduVR/corn-gray-leaf-spot-xai
Step 1: Create and Activate a Virtual Environment
python -m venv venv
source venv/bin/activate # Linux / macOS
venv\Scripts\activate # Windows
Step 2: Install the dependencies
pip install -r requirements.txt
Step 3: Run inference on a test image
python inference.py --image ./path/to/image --model_path ./saved_models/path/to/model/you/want --model_type [EfficientNet / ResNet]
Examples
python inference.py --image ./test_images/healthy.jpg --model_path ./saved_models/EfficientNet_basic/model.pth --model_type EfficientNet
python inference.py --image ./test_images/diseased.jpg --model_path ./saved_models/ResNet50_basic/model.pth --model_type ResNet
Sample Test Images
Below are examples of the corn leaf.
| Healthy Maize Leaf | Gray Leaf Spot (Cercospora zeae-maydis) |
|---|---|
![]() |
![]() |
| Prediction: Healthy | Prediction: Gray Leaf Spot |
Usage
Refer to inference.py for implementation details related to:
- Model loading
- Image preprocessing
- Prediction logic
Citation
If you use these models or this repository in your research, please cite our paper:
Explainable Deep Learning for Early Detection of Corn Gray Leaf Spot Using Grad-CAM
Notes
- These models are intended for research and educational purposes.
- Performance may vary under real-world field conditions with complex backgrounds.
- Grad-CAM visualizations are provided to support interpretability and trust.
License
This project is intended for academic and research use.
Please review the licenses of the PlantVillage and PlantDoc datasets before any
commercial deployment.
Evaluation results
- accuracy on Maizeself-reported0.999

