PhD work update · November 2026

Identifying individual dairy cows across six barn cameras without labels

Can we recognise 60 Holstein cows in a barn day after day using only cameras, with no ear-tag readers and no hand-labelled identities? This page summarises where the work stands.

0.47 → 0.65detector mAP@0.5 after fine-tuning on 120 hand-corrected images
2,290 → 1,020identities on an unseen day after label-free fine-tuning (herd: 60)
89 %of matches correct within one hour on the same camera (manual check)
27 → 54 %correct matches across different cameras

1Setup

A naturally ventilated research barn with 60 Holstein cows and six time-synchronised cameras: four inside (north, west, east, south), one at the outside feeding area and one in the outside yard. Each camera takes a snapshot every 15 minutes, and all six snapshots are taken within about 2 s of each other. Two cameras also record 24-hour video. I used two full days: 1 Sep and 10 Oct 2026.

Six camera views of the barn with coloured polygons marking regions seen by two cameras
The six camera views at the same moment. The coloured polygons mark areas that two cameras see at once (16 polygons on 8 camera pairs). The yellow dots are matching points marked by hand.

2Approach

The pipeline has two parts. (a) On any day: detect the cows, crop them, compute a DINOv3 embedding ("fingerprint") for each crop, then group the fingerprints into identities. (b) Fine-tune DINOv3 without any identity labels, using pairs whose answer the recording setup already gives:

Training uses a group-masked InfoNCE loss, so negatives are taken only from pairs known to be different cows. The same "cannot be the same cow" rules also act as cannot-link constraints when grouping. The similarity threshold is set so that only 1 % of known-different pairs would be merged.

Pipeline diagram: snapshot, crops, DINOv3, constrained grouping, identities; below, the label-free training pairs
(a) Identification pipeline. (b) Label-free training from video tracks, still cows, camera overlaps and same-image negatives.

3Cow detection

I corrected 1,338 cow boxes on 120 snapshots (20 per camera) by hand and fine-tuned the YOLO11n detector on 90 of them. I evaluated on the remaining 30 (329 boxes).

mAP@0.5AllNorthWestEastSouthFeedingYard
Original detector0.4730.5070.5690.6620.2830.5230.106
Fine-tuned0.6540.6360.7200.7780.5290.7510.424

Posture (lying/standing) is correct for 95 % of the detected cows.

4A surprise: a better detector made video identification worse

On 24 hours of video from one camera, an online DINOv3 gallery created 382 identities with the original detector. With the better detector it created 634. The new detector finds 56 % more cows, and each extra hard case (short, small, moving) starts a new identity. The identities that never match again are seen for a median of only 4 s.

The bottleneck is when a new identity is created, not the detector. This is why I moved to the synchronised snapshot pipeline above.

5Identities from the snapshots

Evaluated on 1 Sep, a day the fine-tuned model never saw during training (about 4,300 cow crops):

DINOv3 off-the-shelfFine-tuned (label-free)
Identities at 1 % false-match rate2,2871,024
Singletons1,668318
Still-cow pairs kept together81 %95 %
AUC (same still cow vs. known different)0.9840.996
Crops in identities seen for ≥ 1 h40 %74 %
Largest identities found with off-the-shelf DINOv3
Largest identities, off-the-shelf DINOv3 (scroll)
Largest identities found with fine-tuned DINOv3
Largest identities, fine-tuned (scroll). Each row is one identity across the day.

6Manual check

Without ground-truth identities, I checked 450 pairs by eye, blind to which model produced them.

Correct matches (precision)Off-the-shelfFine-tuned
Same camera, within 1 h86 %89 %
Same camera, over hours47 %53 %
Different cameras27 %54 %
Across days (10 Oct ↔ 1 Sep)34 %44 %
Overall (weighted)55 %60 %

The fine-tuned model also finds about twice as many correct links (~10,300 vs ~4,900).

7What the fingerprints encode

UMAP of fingerprints coloured by posture and by camera for three models
UMAP of the fingerprints, coloured by posture (top) and by camera (bottom). After fine-tuning, resting cows form tight per-stall clusters, but 80 % of each crop's 10 nearest neighbours still come from the same camera (chance: 21 %).
Main open problem: the embeddings are still organised by camera viewpoint and stall more than by the individual cow. The method is reliable over short periods on one camera. Matching across cameras and across days is not solved yet.

Training

Training loss curves for two label-free fine-tuning runs
Group InfoNCE loss for the two label-free runs. Run 2 adds cross-camera pairs and viewpoint augmentation.

8Side result: lying behaviour

Share of lying cows per camera and hour on both days
Share of detected cows lying, per camera and hour of day. It is about 39 % on both days. The inside cameras dip around 08–10 h and 16 h, probably at milking.

9Next steps