Teaching a Model to Recognise My Garden
What started as a weekend camera trap turned into six months of training an image classifier on my own back porch — and a lesson about which photographs actually matter.
The first useful thing I learned was that the model did not care about my photography.
It cared about consistency — the same feeder, the same angle, the same harsh afternoon light. I had been feeding it my best shots: clean bokeh, a wing frozen mid-beat, the kind of frame you keep. Those images taught it almost nothing.
The boring frames mattered most
What the model wanted was the frames I would have deleted. The blurry ones. The empty ones. The forty-seven near-identical exposures where nothing happened at all.
That last category turned out to be the important one. A classifier that has only ever seen birds will confidently find a bird in an empty frame, because it has never been given permission to say nothing here.
Every dataset of interesting things needs an equal weight of boring things, or the model never learns where the interesting stops.
What the pipeline looks like
Nothing exotic. A motion-triggered capture, a nightly batch job, and a small fine-tuned model:
def label_batch(frames, model, threshold=0.82):
"""Return only frames the model is genuinely confident about."""
results = []
for frame in frames:
pred, confidence = model.predict(frame)
# Anything below threshold goes to manual review rather than
# silently entering the training set as a bad label.
results.append(pred if confidence >= threshold else None)
return resultsThe threshold is the whole trick. Set it too low and the model poisons its own training set with confident nonsense. Set it too high and you label everything by hand forever.
Where it stands
| Species | Images | Accuracy |
|---|---|---|
| Ruby-throated | 1,240 | 94.2% |
| Black-chinned | 310 | 81.7% |
| Not a bird | 2,905 | 99.1% |
The gap between those first two rows is just data volume. The third row is the one I am proudest of.
Next: getting it to tell individuals apart. Which, as far as I can tell, may not be possible from a feeder camera at all.
Tags
- machine-learning
- photography
- birds