Lab 4 · Fine-Tune YOLOv8 on Oregon Critters (4 classes)
Biological motivation
MegaDetector tells you where animals are, not what they are. For most field questions you need species ID. Fine-tuning YOLO directly on labeled crops is one of two common approaches (the other is "detect then classify", which is Lab 5). This lab teaches you how to read a training run, recognize overfitting, and produce defensible per-class performance numbers.
Data
A 4-class subset of Oregon Critters built from the
data_sample/ teaching set. The
build script
converts the COCO-style CSV into YOLO format:
oregon_critters_4cls/
├── images/{train, val}/
├── labels/{train, val}/
└── data.yaml # classes:
# 0 = black-tailed deer
# 1 = roosevelt elk
# 2 = black bear
# 3 = bobcat
~120 train, ~30 val in the course sample (we use the 4 mammal species that have enough crops). Class balance is intentionally uneven (deer most common, bobcat fewest) — this is realistic and you'll need to deal with it. A full Oregon Critters run from LILA would scale to ~1,200 training images for the same classes.
Tasks
Task 1 — baseline train (5 pts)
Use train_oregon_critters.py as-is (50 epochs, YOLOv8s, default augmentation). Report:
- Final mAP@0.5 and mAP@0.5:0.95.
- Per-class precision, recall, AP@0.5.
- The confusion matrix.
Task 2 — class imbalance experiment (5 pts)
Bobcat is the rarest class in the course sample and will probably be the
worst-performing. Use Ultralytics' class_weights argument (or
oversample bobcat crops in your training labels) to upweight the rare
classes. Retrain. Compare to the baseline. Did bobcat recall improve? At
what cost to deer precision?
Task 3 — site-stratified eval (5 pts)
The val set in data.yaml is a random split, which overestimates how well
your model will work at a new camera. Create a second val set where the held-out sites are
completely separate cameras (use val_by_site.yaml provided). Re-evaluate. How
much does mAP drop? Report both numbers.
Task 4 — interpretation (5 pts)
In 200 words: discuss the random-split vs site-held-out gap, and the class-imbalance tradeoff. What would you recommend to the project lead about deploying this model?
Go-further
Try yolov8m instead of yolov8s. Does the bigger model help, or does
it just overfit faster on this dataset size? Show the val curves of both.
Rubric
| Component | Points |
|---|---|
| Baseline training run with all required metrics | 6 |
| Class-imbalance experiment with comparison | 4 |
| Site-held-out evaluation | 4 |
| Interpretation with deployment recommendation | 6 |
| Total | 20 |