thesis · computer vision · 2024

Pest Advisor

A solar camera trap in the rice paddy that counts insects every morning and tells farmers whether it's actually time to spray.

roleTeam lead · web app & models
schoolLSPU – Santa Cruz
awardBest in Thesis · CCS 2024
Pest Advisor detection view with bounding boxes and insect counts
one morning's sticky trap — YOLOv8 + SAHI boxes, with counts per species on the right
01 — why

Farmers often spray too early — and kill the insects that were protecting the crop.

Insect pests are one of the leading causes of rice crop damage. The early-warning method is sampling the insect population, and in practice that means sweep netting — slow, manual, and easy to skip. Pest Advisor does the sampling automatically, every day.

02 — the trap
Off-grid, in the field
06:00CaptureWebcam photographs the yellow sticky trap once a day
detectYOLOv8 + SAHITiled inference finds and classifies each insect
storeFlask + SQLAlchemyCounts per species, per device, per day
adviseDashboardSpray or wait, for farmers and extension workers
computeOrange Pi · Armbian (Ubuntu Jammy)
cameraUSB webcam facing a yellow sticky trap
powerSolar panel, charge controller, battery, step-down module
networkUSB Wi-Fi · exposed via ngrok
03 — dataset
Labelled by hand, one insect at a time
752trap images
47,622annotations
26insect classes
5 MPavg · 2592×1944
Pests12
Green LeafhopperZigzag LeafhopperWhite Stem BorerWhorl MaggotRice BugBlack BugRice Shoot FlyMiridLong-horned GrasshopperShort-horned GrasshopperCricketField Roach
Beneficial12
Dwarf SpiderWolf SpiderLong-jawed SpiderLynx SpiderLady BeetleGround BeetleSmall WaspIchneumon WaspTachinid FlyTrichommaMud DauberSepedon
Neutral2
House FlyFruit Fly
dataset on Roboflow Universe ↗
04 — hardest part
Picking the model, then making it see small bugs

I trained YOLO v5, v7 and v8 on Colab. Most insects on a trap are tiny relative to a 5 MP frame, so plain YOLO missed them. SAHI slices the image into tiles, runs detection on each, and merges the results — it pushed v5’s recall from 46% to 63%, and gave v8 the best precision of the lot.

field trials · 3 rice paddies
YOLOv5
65.53%
YOLOv5 + SAHI
66.80%
YOLOv7
68.70%
YOLOv8
66.24%
YOLOv8 + SAHI ★
72.01%
05 — decision support
Counts and species, then one recommendation

Farmers and agricultural extension workers see what landed on each trap, by species. When destructive insects spike, the app recommends insecticide — and when the trap is mostly spiders and lady beetles, it doesn’t. Devices are registered with their ngrok URL and pinned on a Google map.

Adding a trap device with its location on a map
06 — stack
modelYOLOv8 (Ultralytics) · SAHI · PyTorch
trainingGoogle Colab · Roboflow
visionOpenCV · supervision · NumPy
backendPython 3.10 · Flask · APScheduler · Flask-Session · SQLAlchemy
frontendJinja2 · Bootstrap 5.3 · HTML · CSS · JavaScript
mapsGoogle Cloud (Maps)
hostingPythonAnywhere · ngrok on the trap
07 — team

I led the group, built the web app and trained the models. My teammates set up and retrieved the traps, labelled insects alongside me, and wrote the paper. It won Best in Thesis in the College of Computer Studies, LSPU – Santa Cruz, 2024.