Lab 4 · Fine-Tune YOLOv8 on Oregon Critters (4 classes)

Worth: 20 points  |  Due: end of Day 2  |  Files to submit: training run directory (curves, confusion matrix, best.pt), a 1-page PDF with mAP table and per-class confusion.
Pre-reading: "Training your own YOLO" section of the YOLO tutorial.

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

Get the data: aiecol_cameratraps.zip (297 MB) — or the full bundle aiecol_data_sample.zip (395 MB). See the downloads page for layout.

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:

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.

This is one of the most important and most overlooked points in applied CV for ecology. Random-split metrics flatter your model; site-held-out metrics tell you what to expect at the next deployment. Both go in your paper, with the held-out number as the headline.

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

ComponentPoints
Baseline training run with all required metrics6
Class-imbalance experiment with comparison4
Site-held-out evaluation4
Interpretation with deployment recommendation6
Total20