CPU-Constrained Evaluation of Modern Hybrid Transformers and CNN Architectures for Tomato Leaf Disease Classification Using the PlantVillage Datase π±
This project evaluates modern CNNs and hybrid Transformer architectures β ResNet-50, ConvNeXt-Tiny, and FastViT-T8 β for tomato leaf disease classification on the PlantVillage dataset.
The focus is on CPU-constrained environments to make plant disease detection feasible in resource-limited regions where GPU access is rare.
-
Dataset: Tomato subset of PlantVillage (16,012 images, 10 classes).
-
Architectures: ResNet-50, ConvNeXt-Tiny, FastViT-T8 (via timm).
-
Training:
- Two-phase transfer learning (frozen backbone β full fine-tuning)
- Mixed-precision support (AMP)
- Early stopping & checkpointing
-
Evaluation: Accuracy, precision, recall, F1-score, confusion matrix, inference latency.
-
Deployment: Designed for CPU-only training & inference.
| Model | Params (M) | Accuracy | Weighted F1 | Latency (s/img) |
|---|---|---|---|---|
| ResNet-50 | 25.6 | 99.50% | 0.995 | 0.0352 |
| ConvNeXt-Tiny | 29.0 | 99.88% | 0.9988 | 0.0508 |
| FastViT-T8 | 27.4 | 99.66% | 0.997 | 0.0219 |
- ConvNeXt-Tiny β Highest accuracy
- FastViT-T8 β Fastest inference
- ResNet-50 β Strong classical baseline
efficient-leaf-disease/
βββ datasets/ # PlantVillage (tomato subset)
βββ src/ # Training & evaluation scripts
β βββ train.py # Main training loop (works for all models)
βββ trained_models/ # Saved checkpoints (.pth)
βββ evaluation_results/ # Metrics JSON + confusion matrices
βββ logs/ # Training logs (CSV)
βββ README.md
git clone https://github.com/your-username/efficient-leaf-disease.git
cd efficient-leaf-disease
pip install -r requirements.txtrequirements.txt
torch
torchvision
timm
scikit-learn
matplotlib
seaborn
tqdm
numpy
python src/train.py --model resnet50
python src/train.py --model convnext_tiny
python src/train.py --model fastvit_t8After training, evaluation metrics and confusion matrix will be saved in evaluation_results/.
Example:
cat evaluation_results/resnet50_metrics.jsonevaluation_results/<model>_metrics.jsonβ Accuracy, F1, latency, per-class reportevaluation_results/<model>_metrics.pngβ Confusion matrix plottrained_models/β All checkpoints (last.pth,best.pth, per-epoch.pth)logs/<model>.csvβ Training logs (loss & accuracy per epoch)
- Edge & mobile AI for agriculture
- Real-time tomato disease detection
- Low-resource decision support for farmers
If you use this work, please cite: Rahman, O., et al. (2025) CPU-Constrained Evaluation of Modern Hybrid Transformers and CNN Architectures for Tomato Leaf Disease Classification Using the PlantVillage Dataset.