Instructions to use ndunge23/Pest_Disease_Detector with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- ultralytics
How to use ndunge23/Pest_Disease_Detector with ultralytics:
from huggingface_hub import hf_hub_download from ultralytics import YOLO # pick the weights file from this repo's "Files and versions" tab weights = hf_hub_download("ndunge23/Pest_Disease_Detector", "<weights>.pt") model = YOLO(weights) source = 'http://images.cocodataset.org/val2017/000000039769.jpg' model.predict(source=source, save=True) - Notebooks
- Google Colab
- Kaggle
Pest and Disease Detector β Maize Fall Armyworm and Maize Streak Disease Detection
Overview
This model is a YOLOv8s-based object detection model trained to detect both Fall Armyworm (FAW) pest infestations and Maize Streak Disease in smallholder maize farms. It is part of the SambaGuard AI system, developed at Dedan Kimathi University of Technology, Kenya, targeting edge deployment on resource-constrained devices such as the Raspberry Pi 5.
The model extends the FAW-only v2 model by adding disease detection capability, addressing the requirement for a unified pest and disease monitoring system that can operate offline in low-connectivity field environments.
This repository contains the trained model weights, evaluation metrics, training visualizations, and full experiment outputs.
Detected Classes
| Class ID | Class Name |
|---|---|
| 0 | Fall Armyworm Egg |
| 1 | Fall Armyworm Frass |
| 2 | Fall Armyworm Larva |
| 3 | Fall Armyworm Larval Damage |
| 4 | Healthy Maize |
| 5 | Maize Streak Disease |
Model Architecture
| Property | Value |
|---|---|
| Architecture | YOLOv8s |
| Framework | Ultralytics / PyTorch |
| Input size | 640 x 640 pixels |
| Parameters | 11.1M |
| GFLOPs | 28.4 |
| Export formats | ONNX, TFLite |
| Number of classes | 6 |
Dataset
The model was trained on the MaizeFall-Army dataset by CDAC, hosted on Roboflow Universe. The original dataset was collected by KaraAgro AI from maize farms across Ghana and is available on Harvard Dataverse (DOI: 10.7910/DVN/CXUMDS, License: CC BY 4.0).
Dataset preparation steps:
- Removed two ambiguous classes:
healthy-imagesandnone-healthy - Remapped remaining 6 classes to contiguous IDs (0β5)
- Oversampled minority classes (fall-armyworm-egg and maize-streak-disease) to approximately 2,000 images each
- Verified all image-label pairs across all splits
- Confirmed zero out-of-bounds bounding box coordinates
| Split | Images | Labels |
|---|---|---|
| Train | 20,659 | 20,659 |
| Val | 1,642 | 1,642 |
| Test | 839 | 839 |
Training Configuration
| Parameter | Value |
|---|---|
| Base model | yolov8s.pt (COCO pretrained) |
| Epochs | 100 |
| Early stopping patience | 20 |
| Batch size | 16 |
| Image size | 640 |
| Learning rate schedule | Cosine annealing |
| Cache | Disk |
| Seed | 42 |
| Hardware | NVIDIA Tesla T4 GPU |
Validation Results
Best checkpoint obtained at epoch 56.
Overall
| Metric | Value |
|---|---|
| Precision | 0.413 |
| Recall | 0.167 |
| mAP50 | 0.166 |
| mAP50-95 | 0.123 |
Per-Class Performance
| Class | Precision | Recall | mAP50 | mAP50-95 |
|---|---|---|---|---|
| Fall Armyworm Egg | 0.0917 | 0.00763 | 0.000923 | 0.000138 |
| Fall Armyworm Frass | 0.0555 | 0.000471 | 0.00657 | β |
| Fall Armyworm Larva | 0.330 | 0.248 | 0.178 | β |
| Fall Armyworm Larval Damage | 0.362 | 0.0148 | 0.0184 | β |
| Healthy Maize | 0.830 | 0.0746 | 0.125 | β |
| Maize Streak Disease | 0.810 | 0.658 | 0.666 | 0.607 |
Full per-class metrics, training curves, confusion matrix, and PR curves are available in the plots/ and metrics/ folders of this repository.
Experiment Log
| Version | Dataset | Classes | Epochs | mAP50 | Status |
|---|---|---|---|---|---|
| v1 | KaraAgro FAW-only | 4 | 50 | 0.368 | Complete |
| v2 | KaraAgro FAW-only (cleaned) | 4 | 100 (best 55) | 0.347 | Complete |
| v3 | Roboflow 6-class | 6 | 100 (best 49) | 0.161 | Complete |
| v4 (this model) | Roboflow 6-class + oversampling | 6 | 100 (best 56) | 0.166 | Complete |
Repository Structure
Pest-Disease-Detector/
βββ weights/
β βββ best.pt
β βββ last.pt
β βββ best.onnx
β βββ best.tflite
βββ metrics/
β βββ results.csv
βββ plots/
β βββ results.png
β βββ confusion_matrix.png
β βββ confusion_matrix_normalized.png
β βββ PR_curve.png
β βββ P_curve.png
β βββ R_curve.png
β βββ F1_curve.png
βββ args.yaml
βββ README.md
Usage
Install the required library:
pip install ultralytics
Run inference on an image:
from ultralytics import YOLO
model = YOLO("weights/best.pt")
results = model.predict(
source="image.jpg",
imgsz=640,
conf=0.25
)
results[0].show()
Known Limitations
- Egg and frass detection performance is low due to class imbalance in the training data β these classes are significantly underrepresented compared to larval damage and healthy maize
- Overall mAP50 (0.166) is lower than the FAW-only v2 model (0.347) β adding disease classes introduced class imbalance that reduced FAW detection performance
- Maize streak disease detection performs consistently well (estimated mAP50 ~0.65) due to its visually distinct symptoms
Future Work
- Improved class balancing strategy for minority FAW classes
- Larger and more diverse dataset for egg and frass classes
- Edge export optimization for Raspberry Pi 5 deployment
- Integration with Swahili-language LLM advisory layer for farmer SMS guidance
- Field validation with smallholder farmers in Kenya
Related Resources
- GitHub Repository: SambaGuard
- FAW-only model (v2): ndunge23/SambaGuard-v2
- Dataset: MaizeFall-Army on Roboflow
- Original dataset: KaraAgro AI Maize on Harvard Dataverse
Citation
@misc{sambaguard2026,
author = {Annastacia Ndunge},
title = {Pest and Disease Detector: YOLOv8s for Fall Armyworm and Maize Streak Disease Detection},
year = {2026},
howpublished = {\url{https://huggingface.co/ndunge23/Pest-Disease-Detector}},
note = {Part of the SambaGuard AI project}
}
License
This project is licensed under the Apache 2.0 License.
Author
Annastacia Ndunge Electrical and Electronic Engineering, Dedan Kimathi University of Technology, Kenya
GitHub: aneneahs-kanaks Hugging Face: ndunge23 LinkedIn: Annastacia Ndunge
- Downloads last month
- 49