Calf Identity Tracking: weights
The two trained models behind Re-id-for-tracking, which follows four dairy calves for a week and gives each calf its identity back every morning. The masks they produced are in Sonam5/Calf-Identity-Tracking-Masks, and the project page is sonam525.github.io/Re-id-for-tracking.
| Model | File | What it does |
|---|---|---|
| Calf tracker backbone | tracker/best_backbone_student_v2.pt |
TinyViT student that replaces SAM 3's image backbone in its video tracker (40.66 M parameters). Distilled on the two training days, day and night. |
| Calf detector | detector/checkpoint_best_total.pth |
RF-DETR-Seg Small at 624 px, one class (calf). Finds the calves at the start of each day and re-seeds the tracker when a calf is lost. |
Both were trained on camera FarmA_R1 of the Calf Play Behavior Dataset, 18 and 19 April 2024 only. The test week, 22 to 28 April, was never used for training. The same two files are also in Sonam5/FarmSAM, with the pig models. Hashes are in CHECKSUMS.sha256.
How to load
The tracker backbone needs SAM 3's own weights from Meta, under the gate of facebook/sam3, and the loader in FarmSAM:
import sys
from huggingface_hub import hf_hub_download
sys.path.insert(0, "FarmSAM/benchmark/core") # git clone https://github.com/Sonam525/FarmSAM
import bench_core as core
student, meta = core.load_student(hf_hub_download("Sonam5/Calf-Identity-Tracking-Weights", "tracker/best_backbone_student_v2.pt"), device="cuda")
The detector loads with RF-DETR:
from rfdetr import from_checkpoint # pip install rfdetr==1.10.1
detector = from_checkpoint(hf_hub_download("Sonam5/Calf-Identity-Tracking-Weights", "detector/checkpoint_best_total.pth"), resolution=624)
Pass the resolution: the file does not store it. The pipeline keeps detections above 0.35 and then cleans them up as described in detector/detector.json.
.pt and .pth files are pickle, so check the SHA-256 before you load one.
Intended use
Research on tracking and identifying animals from fixed farm cameras. Both models were trained on one pen, one camera and four black and white calves. Check them on your own pen before you rely on them. Not intended for tracking people or for decisions about individual animals without review.
Terms
Both models are released under the SAM License. The tracker backbone was trained to match SAM 3 features and runs inside SAM 3's tracker, and the detector was trained on masks from SAM 3, so we apply its terms to be safe. Anyone who passes a model on must do so under those terms and include a copy of LICENSE_SAM.txt. Its trade control limits apply, and publications that use these models must acknowledge SAM 3 (clause 1.b.ii). The training video is CC0 1.0. RF-DETR is Apache-2.0, and the tracker trunk starts from timm/tiny_vit_21m_512.dist_in22k_ft_in1k. This note is not legal advice.
Citation
Please cite the repository and the distillation preprint:
@misc{calf_identity_week,
title = {Which calf is which, across a week},
author = {Yang, Haiyu},
year = {2026},
url = {https://github.com/Sonam525/Re-id-for-tracking}
}
@misc{yang2026distillation,
title = {Lightweight Distillation of {SAM}~3 and {DINOv3} for Edge-Deployable
Individual-Level Livestock Monitoring and Longitudinal Visual Analytics},
author = {Yang, Haiyu and Hostens, Miel},
year = {2026},
eprint = {2604.27128},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2604.27128}
}