SambaGuard Pest & Disease Detector

Overview

SambaGuard Pest & Disease Detector is a YOLOv8s-based object detection model trained to detect 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.

This model is the strongest performing version across all SambaGuard training experiments, achieving mAP50 of 0.459 across 5 classes β€” surpassing all previous versions including the FAW-only v2 model (mAP50 = 0.347).

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 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 5

Dataset

The model was trained on a subset of the KaraAgro AI Maize dataset, accessed via Dataset Ninja in Supervisely format. 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: CC0 1.0).

Dataset preparation steps:

  • Retained only the 5 most meaningful classes: FAW egg, frass, larva, larval damage, and maize streak disease
  • Dropped healthy maize, healthy images, and none-healthy classes
  • No manual augmentation applied β€” YOLOv8 built-in augmentation only
  • No oversampling applied
  • Annotations converted from Supervisely JSON format to YOLOv8 normalized bounding box format
  • Out-of-bounds coordinates clipped to the valid range of 0.0 to 1.0
Split Images Labels
Train 5,084 5,084
Val 1,715 1,715
Test 664 664

Training Configuration

Parameter Value
Base model yolov8s.pt (COCO pretrained)
Epochs 50
Batch size 16
Image size 640
Seed 42
Workers 2
Augmentation YOLOv8 built-in only
Oversampling None
Hardware NVIDIA Tesla T4 GPU

Validation Results

Best checkpoint obtained at epoch 49.

Overall

Metric Value
Precision 0.500
Recall 0.466
mAP50 0.459
mAP50-95 0.220

Per-Class Performance

Class Precision Recall mAP50 mAP50-95
Fall Armyworm Egg β€” 0.135 0.090 0.030
Fall Armyworm Frass 0.404 0.249 0.228 0.074
Fall Armyworm Larva 0.796 0.875 0.893 0.352
Fall Armyworm Larval Damage 0.464 0.328 0.316 0.110
Maize Streak Disease 0.645 0.743 0.767 0.535

Fall Armyworm Larva achieves the strongest detection performance (mAP50 = 0.893), and Maize Streak Disease is detected with high reliability (mAP50 = 0.767) due to its visually distinct symptoms. Egg detection remains the weakest class due to the small size and low image count of the class in the training data.


Comparison with Previous Versions

Version Dataset Classes Epochs mAP50 mAP50-95
v1 KaraAgro FAW-only 4 50 0.368 β€”
v2 KaraAgro FAW-only (cleaned) 4 100 (best 55) 0.347 0.144
v3 Roboflow 6-class 6 100 (best 49) 0.161 0.122
v4 Roboflow 6-class + oversampling 6 100 (best 56) 0.166 0.123
This model KaraAgro 5-class 5 50 0.459 0.220

Key finding: returning to the original KaraAgro dataset with minimal preprocessing β€” no augmentation, no oversampling, just class filtering β€” produced the best results across all experiments.


Repository Structure

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 detection performance is low (mAP50 = 0.090) due to the small visual size of eggs and limited training examples for this class
  • Frass detection is moderate β€” frass can resemble soil particles and other debris in field conditions
  • Model has not yet been validated in real field deployment conditions

Future Work

  • 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
  • Larger annotated dataset for egg and frass classes

Related Resources


Citation

@misc{sambaguard2026,
  author       = {Annastacia Ndunge},
  title        = {SambaGuard Pest and Disease Detector: YOLOv8s for Fall Armyworm and Maize Streak Disease Detection},
  year         = {2026},
  howpublished = {\url{https://huggingface.co/ndunge23/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
46
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using ndunge23/disease-detector 1