Skip to content

LeafDisease-AI is the first framework for cross-domain tomato leaf disease detection, bridging the gap between laboratory research and real-world agricultural deployment. This repository implements a unified optimization approach integrating ensemble learning, knowledge distillation, and quantization for edge-compatible disease detection.

Notifications You must be signed in to change notification settings

junayed-hasan/leaf-disease-ai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

LeafDisease-AI: Deployable Deep Learning for Cross-Domain Plant Leaf Disease Detection via Ensemble Learning, Knowledge Distillation, and Quantization

License: MIT Python 3.8+ PyTorch Paper

LeafDisease-AI Architecture

🌟 Overview

LeafDisease-AI is the first comprehensive framework for cross-domain tomato leaf disease detection, bridging the gap between laboratory research and real-world agricultural deployment. This repository implements a unified optimization approach integrating ensemble learning, knowledge distillation, and quantization for edge-compatible disease detection.

🎯 Key Contributions

  • First Open Cross-Domain Benchmark: Unifying PlantVillage and TomatoVillage datasets into 15 harmonized disease classes
  • Unified Optimization Framework: Integrating ensemble learning, knowledge distillation, and quantization
  • Edge-Compatible Deployment: Achieving 671Γ— compression (1.46 MB) with 97.46% accuracy
  • Real-World Validation: Cross-domain evaluation on field condition datasets
  • Explainable AI: Grad-CAM++ and LIME-based interpretability analysis

πŸ“Š Performance Highlights

Model Accuracy F1-Score Parameters Size Inference Time
Ensemble (Teacher) 99.15% 97.07% 163M 652 MB 12.6ms
ShuffleNetV2 (Student) 98.53% 96.12% 1M 4.2 MB 0.29ms
Quantized INT8 97.46% 95.36% 1M 1.46 MB 0.29ms

πŸ—οΈ Repository Structure

LeafDisease-AI/
β”œβ”€β”€ src/                          # Source code
β”‚   β”œβ”€β”€ configurations/           # Configuration files
β”‚   β”œβ”€β”€ data_augmentation/        # Data augmentation strategies
β”‚   β”œβ”€β”€ data_balancing/          # ADASYN-based balancing
β”‚   β”œβ”€β”€ datasets/                # Dataset loaders and utilities
β”‚   β”œβ”€β”€ distillation/            # Knowledge distillation
β”‚   β”œβ”€β”€ ensemble/                # Ensemble learning
β”‚   β”œβ”€β”€ evaluation/              # Model evaluation scripts
β”‚   β”œβ”€β”€ explainable_ai/          # Interpretability analysis
β”‚   β”œβ”€β”€ hyperparameter_tuning/   # Hyperparameter optimization
β”‚   β”œβ”€β”€ models/                  # Model architectures
β”‚   β”œβ”€β”€ quantization/            # Model quantization
β”‚   └── utils/                   # Utility functions
β”œβ”€β”€ data/                        # Datasets (available under data/)
β”‚   β”œβ”€β”€ combined/                # Unified dataset
β”‚   β”œβ”€β”€ plantvillage/           # PlantVillage dataset (lab conditions)
β”‚   └── tomatovillage/          # TomatoVillage dataset (field conditions)
β”œβ”€β”€ docs/                        # Documentation
β”œβ”€β”€ scripts/                     # Training and evaluation scripts
β”œβ”€β”€ outputs/                     # Model outputs and results
└── checkpoints/                 # Trained model checkpoints

πŸš€ Quick Start

Prerequisites

# Python 3.8+ required
pip install -r requirements.txt
pip install -r requirements_balancing.txt

Dataset Preparation

  1. Download Datasets:

    Extract datasets to data/plantvillage/ and data/tomatovillage/ respectively.

  2. Datasets are also available under data/ directory

Training Pipeline

1. Baseline Training

python scripts/train.py --model densenet121 --dataset combined --epochs 100

2. Ensemble Training

python src/ensemble/train_best_ensemble.py

3. Knowledge Distillation

python src/distillation/train_best_kd.py

4. Quantization

python src/quantization/mobile_quantization_pipeline.py

Evaluation

# Cross-domain evaluation
python src/evaluation/evaluate_kd_on_test_datasets.py

# Interpretability analysis
python src/explainable_ai/interpretability_analysis.py

πŸ”¬ Research Methodology

Cross-Domain Benchmark

Our framework addresses three fundamental challenges:

  1. Cross-Domain Generalization: Unified PlantVillage (lab conditions) and TomatoVillage (field conditions) datasets
  2. Class Imbalance: ADASYN-based balancing for 75:1 imbalance ratio
  3. Computational Constraints: Knowledge distillation and quantization for edge deployment

Optimization Pipeline

  1. Data Preprocessing: Strategic augmentation and ADASYN balancing
  2. Hyperparameter Tuning: Systematic optimization across 24 architectures
  3. Ensemble Learning: Four-model soft voting ensemble
  4. Knowledge Distillation: Teacher-student framework with temperature scaling
  5. Quantization: INT8 quantization for mobile deployment

Explainable AI

  • Grad-CAM++: Attention visualization for model interpretability
  • LIME: Local interpretable model-agnostic explanations
  • Biological Validation: Alignment with plant pathology principles

πŸ“ˆ Experimental Results

Cross-Dataset Performance

Dataset Accuracy F1-Score Precision Recall
Combined Test 99.15% 97.07% 97.23% 96.91%
PlantVillage 98.87% 96.45% 96.78% 96.12%
TomatoVillage 95.70% 93.62% 94.01% 93.23%

Computational Analysis

Model Parameters FLOPs Memory Inference Time
DenseNet-121 7.98M 2.87G 32.4 MB 3.2ms
ResNet-101 44.55M 7.83G 179.8 MB 4.1ms
ShuffleNetV2 1.26M 146M 5.1 MB 0.29ms
Quantized INT8 1.26M 146M 1.46 MB 0.29ms

πŸ† Disease Classes

The framework detects 15 tomato leaf disease classes:

  1. Healthy
  2. Bacterial Spot
  3. Early Blight
  4. Late Blight
  5. Leaf Mold
  6. Septoria Leaf Spot
  7. Spider Mites
  8. Target Spot
  9. Yellow Leaf Curl Virus
  10. Mosaic Virus
  11. Powdery Mildew
  12. Nutrient Deficiency
  13. Pest Damage
  14. Environmental Stress
  15. Other Diseases

πŸ“š Documentation

Detailed documentation is available in the docs/ directory:

🀝 Contributing

We welcome contributions! Please see our Contributing Guidelines:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ Citation

If you use this work in your research, please cite: [citation coming soon]

πŸ“ž Contact

Mohammad Junayed Hasan

πŸ“œ License

This project is licensed under the MIT License - see the LICENSE file for details.

MIT License

Copyright (c) 2024 Mohammad Junayed Hasan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

πŸ™ Acknowledgments

  • PlantVillage dataset contributors
  • TomatoVillage dataset contributors
  • PyTorch and timm library developers
  • Agricultural research community

🌱 Bridging AI Research and Agricultural Reality 🌱

About

LeafDisease-AI is the first framework for cross-domain tomato leaf disease detection, bridging the gap between laboratory research and real-world agricultural deployment. This repository implements a unified optimization approach integrating ensemble learning, knowledge distillation, and quantization for edge-compatible disease detection.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages