Lab 3 · Run YOLO and MegaDetector on Oregon Critters
Biological motivation
Most camera-trap workflows in 2026 start with a "where is the animal?" detector before any species classifier. MegaDetector is the standard baseline. In this lab you'll compare MegaDetector v5 to a generic Ultralytics YOLOv8 on the same image set and reason about the precision/recall tradeoff for an ecologist's actual workflow.
Data
A 2,000-image evaluation set drawn from Oregon Critters with hand-drawn ground-truth
bounding boxes for every animal. Provided as
oregon_critters_eval/{images,labels_yolo}/ in YOLO format.
Tasks
Task 1 — MegaDetector baseline (5 pts)
Install the megadetector package:
pip install megadetector
megadetector run_detector_batch \
--model_file MDV5A.0.0.pt \
--image_dir oregon_critters_eval/images \
--output_file detections_megadetector.json \
--recursive
Convert the JSON to a tidy CSV with the columns
image, class_id, class_name, confidence, x1, y1, x2, y2.
Task 2 — YOLOv8 generic (4 pts)
Run detect_oregon_critters.py with
yolov8s.pt. (Note: YOLOv8 generic is trained on COCO — classes like
"dog", "horse", "bear". It will mis-classify many Oregon species,
but for detection only we'll collapse all classes to "animal".)
Task 3 — precision-recall curves (5 pts)
Match each predicted box to a ground-truth box at IoU ≥ 0.5. For each model:
- Sweep confidence threshold from 0 to 1 in 0.01 increments.
- Compute precision and recall at each threshold.
- Plot both models' P-R curves on one figure (
pr_curves.png).
A helper function for IoU is in iou_utils.py.
Task 4 — pick a threshold (3 pts)
You're advising a biologist who has 800,000 camera-trap images and will hand-verify every above-threshold detection. They can verify ~5,000 images. Which threshold do you recommend for MegaDetector to keep their workload under budget while losing as few real animals as possible? Show the math.
Task 5 — interpretation (3 pts)
In 150 words: where does each detector fail? Small animals far away? Cropped/edge animals? Glare? Show 2–3 thumbnails of failure modes in your PDF.
Go-further
Repeat the analysis stratified by daytime vs nighttime (use your Lab 2 classifier!) and report whether either detector is meaningfully worse at night.
Rubric
| Component | Points |
|---|---|
| Both detectors run and produce tidy CSVs | 9 |
| P-R curves correctly computed and plotted | 4 |
| Threshold recommendation with quantitative justification | 3 |
| Interpretation | 4 |
| Total | 20 |