Lab 2 · PyTorch: Train a Day-vs-Night Classifier

Worth: 20 points  |  Due: end of Day 1  |  Files to submit: lab2_train.py (modified), the saved weights day_night.pt, and a 1-page PDF with loss/accuracy curves and a confusion matrix.
Pre-reading: PyTorch Tutorial.

Biological motivation

Many camera-trap analyses condition on diel period. A simple but useful first model is a day-vs-night binary classifier on the image itself (no EXIF needed). It also lets us validate your software environment end-to-end before tackling species identification on Day 2.

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.

You will be given a curated day_night/ folder built from the Oregon Critters sample:

day_night/
├── train/
│   ├── day/    (800 images)
│   └── night/  (800 images)
└── val/
    ├── day/    (200 images)
    └── night/  (200 images)

Day/night labels were derived from EXIF timestamps and sunrise/sunset at site location, then hand-verified.

Tasks

Task 1 — run the starter (4 pts)

Run lab2_train.py unmodified. Confirm that:

Task 2 — train longer with augmentation (5 pts)

Edit the script to:

Task 3 — evaluate (5 pts)

Compute and save a confusion matrix on the validation set (fig_confusion.png). Also report:

Task 4 — interpretation (4 pts)

In 150 words: when do the model's mistakes happen? Heavy snow at midday? Bright IR illuminator at night? What features is your model probably using? Does the data leak any cues you didn't intend (e.g., a sticker on the lens visible only at night)?

Go-further (2 pts within the rubric)

Re-train using only the bottom 20% of each image (cropped at load time). How much does accuracy drop? Why?

Rubric

ComponentPoints
Code modifications run cleanly and produce required outputs10
Written interpretation including a hypothesis about failure modes6
Go-further (crop ablation) with written reasoning4
Total20

Starter: lab2_train.py