Insect Detection: YOLOv8m Object Detection Model

This repository provides production-ready YOLOv8m (Medium) weights fine-tuned on 50,000 augmented agricultural images (specifly-3-rwm7i) for real-time localization and detection of insect pests in fields and greenhouses.


Performance Highlights & Overall Metrics

  • mAP@50: 85.72% (0.8572 peak, 0.8540 validation)
  • mAP@50-95: 51.87%
  • Precision: 83.46%
  • Recall: 85.86%
  • F1-Score: 82.40%
  • Inference Speed: 1.5 ms per image (~400+ FPS on NVIDIA A100)
  • Model Parameters: 23.23M | GFLOPs: 67.9

Detailed Per-Class Validation Breakdown (mAP@50)

Insect Class Images Instances Precision (P) Recall (R) mAP@50 mAP@50-95
All Classes 2,987 3,097 0.835 0.816 0.854 0.519
stem_borer 206 223 0.957 0.978 0.992 0.794
leafhopper 208 216 0.942 0.949 0.976 0.681
ladybug 174 177 0.954 0.977 0.976 0.622
dragonfly 18 18 0.903 0.944 0.959 0.662
butterfly 186 222 0.915 0.918 0.950 0.629
weevil 58 61 0.889 0.934 0.946 0.521
rice_bug 190 237 0.931 0.916 0.937 0.595
bees 211 236 0.887 0.915 0.920 0.551
mole_cricket 39 41 0.882 0.854 0.890 0.471
grasshopper 298 317 0.882 0.852 0.885 0.510
planthopper 116 429 0.815 0.855 0.872 0.471
spider 72 78 0.767 0.821 0.858 0.572
ant 71 173 0.733 0.761 0.813 0.373
cicada 55 78 0.808 0.744 0.797 0.423
caterpillar 173 208 0.853 0.716 0.791 0.400
stink_bug 123 123 0.727 0.724 0.777 0.535
aphid 36 163 0.686 0.632 0.669 0.332
mantis 96 97 0.493 0.206 0.361 0.202

Training Setup

  • Framework: Ultralytics YOLOv8 (v8.3.0)
  • Hardware: NVIDIA A100-SXM4-40GB
  • Epochs: 50
  • Batch Size: 56 | Image Size: 640 x 640
  • Optimizer: AdamW (lr0 = 0.0008, lrf = 0.00008 with Cosine Annealing)
  • Dataset Source: Roboflow specifly-3-rwm7i (Augmented Version)

Quick Usage

from ultralytics import YOLO
from huggingface_hub import hf_hub_download

# Download best weights
weights_path = hf_hub_download(
    repo_id="Mustafa5645344/insect-detection-yolov8",
    filename="best.pt"
)

# Run Inference
model = YOLO(weights_path)
results = model.predict(source="field_sample.jpg", conf=0.35, save=True)

for r in results:
    for box in r.boxes:
        cls_id = int(box.cls[0].item())
        conf = float(box.conf[0].item())
        print(f"Found: {model.names[cls_id]} with {conf*100:.1f}% confidence")
Downloads last month
27
Inference Providers NEW
This model isn't deployed by any Inference Provider. 🙋 Ask for provider support