Lab 7 · PNW-Cnet + Train a Custom Spectrogram CNN
Biological motivation
You are monitoring an old-growth forest where the species of management interest is the barred owl pair duet — a distinctive antiphonal call between a male and a female. PNW-Cnet has a "barred owl" class but it's trained on single-bird calls and treats duets the same as solo calls. You need a classifier that specifically detects the duet to estimate pair occupancy.
Data
You'll use two pieces:
data_sample/audio/— the 97-clip iNaturalist sample shipped with the course (~5–30 s each), indexed indata_sample/audio_index.csvby ground-truth species. We'll treat this as a "stand-in soundscape" for the inference task. (A real deployment would have 4–8 h of continuous ARU recordings; for Lab 7's smoke test the per-recording snippets are enough.)- Custom-CNN training set: the 97 iNat clips (10 per species, except 9 varied thrush and 8 robin) above,
grouped into three biologically distinct super-classes that a small CNN
can plausibly learn:
owl: barred owl + northern spotted owl (20 clips)songbird: thrushes, wren, junco, robin (60 clips)other: pileated woodpecker, olive-sided flycatcher (20)
Tasks
Task 1 — PNW-Cnet inference via pycnet-audio (4 pts)
Install pycnet-audio in its own conda env (see the
bioacoustics tutorial):
conda create -n pycnet -c conda-forge sox python=3.11 -y
conda activate pycnet
pip install pycnet-audio
Then run the end-to-end pipeline on the soundscape directory using PNW-Cnet v5:
pycnet process /path/to/soundscapes -c v5 -w 4 -a
This generates 12-second non-overlapping spectrograms, scores them, and writes:
soundscapes_v5_class_scores.csv— one row per 12-s segment,Filename+ 135 class-score columns.soundscapes_v5_detection_summary.csv— aggregated counts by date / threshold.soundscapes_review_kscope.csv— review file for Kaleidoscope-format human verification.
Convert the class-scores CSV to long form (one row per above-threshold detection) and save
as pnwcnet_detections.csv. Report the top 5 detected classes by frequency and
note which (if any) are barred owl variants (e.g., STVA_8Note,
STVA_Duet).
Task 2 — train custom 3-class CNN (8 pts)
Use train_spec_cnn.py (from the bioacoustics tutorial) as a starting point, adapting for 3 classes (duet, solo_barred, background). Run for at least 10 epochs. Save:
training_curves.png(train + val loss, train + val accuracy).val_confusion.png.custom_cnn.pt(best validation epoch).
Task 3 — compare custom CNN to PNW-Cnet on the duet question (4 pts)
For each 5-second window in the soundscape:
- Get PNW-Cnet's barred-owl score for the overlapping segment.
- Get your custom CNN's duet score for the same window.
Plot a scatter of the two scores. Comment on how well PNW-Cnet's general "barred owl" score serves as a proxy for the more specific "duet" event you actually care about.
Task 4 — interpretation (4 pts)
In 200 words: when does the off-the-shelf model suffice, and when do you need to train your own? What does your custom CNN's failure mode look like (listen to a few false positives) and how would you improve it?
Go-further
Augment the duet class by temporally jittering and pitch-shifting clips (± 1 semitone) and re-train. Did augmentation help?
Rubric
| Component | Points |
|---|---|
| PNW-Cnet runs and outputs are summarised | 4 |
| Custom CNN trains with all required outputs | 8 |
| Cross-model comparison and scatter | 4 |
| Interpretation | 4 |
| Total | 20 |