Lab 5 · Species Classifier on MegaDetector Crops

Worth: 20 points  |  Due: end of Day 3 (morning)  |  Files to submit: training script, species_classifier.pt, confusion.png, and a 1-page PDF.
Pre-reading: PyTorch tutorial and "Classification on detected crops".

Biological motivation

The "detect-then-classify" pipeline is the standard production approach for camera traps. A generic detector (MegaDetector) finds animals; a project-specific classifier identifies them. The advantage: you can swap the classifier when species change without re-training detection. In this lab you train the classifier half on Oregon Critters crops.

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.

Cropped JPGs of single animals (one animal per image), 8 classes:

oregon_critters_crops/
├── train/
│   ├── deer/        ~600
│   ├── black_bear/  ~300
│   ├── cougar/      ~80
│   ├── coyote/      ~200
│   ├── elk/         ~250
│   ├── bobcat/      ~120
│   ├── raccoon/     ~180
│   └── other/       ~150
└── val/             (~25% per class, by site)

Tasks

Task 1 — fine-tune ResNet-50 (5 pts)

Adapt lab2_train.py to:

Task 2 — honest evaluation (5 pts)

Report:

Task 3 — calibration (5 pts)

A model that's right 70% of the time might say 0.99 on most of its outputs. That's a calibration problem and it matters for downstream occupancy modeling (Lab 10).

Compute a reliability diagram: bin val predictions by predicted confidence (10 bins from 0–1), then plot the fraction actually correct in each bin vs the bin center. Save as reliability.png. A perfectly calibrated model lies on the diagonal.

Task 4 — written report (5 pts)

In 250 words: discuss the worst-confused pairs (often biologically reasonable — coyote vs. small dog?), the calibration plot, and what your number means for someone using this classifier on a 10,000-image deployment.

Go-further

Add a "unknown" output: at inference, if the top class probability is below 0.6, label as unknown. How does this change precision/recall per species, and what fraction of images become unknown?

Rubric

ComponentPoints
Training script runs and saves a usable model5
Honest per-class evaluation5
Reliability diagram and calibration analysis4
Written report6
Total20