Datasets:
Calf Identity Tracking Masks
Per-frame masks and identity labels for four dairy calves in one pen, filmed from above for a week in April 2024. Every frame at 5 fps has one mask per calf, and a small file per day says which calf each mask belongs to, including after each night when the camera was off. Code and method: Re-id-for-tracking. The paper is in preparation.
![]()
Masks before and after refinement, 2024-04-22. The clip is in videos/, next to one video for each day of the week.
Use it to train or test instance segmentation, multi-object tracking or re-identification on calves, or to build per-animal activity records over a week. The masks come from a SAM 3 tracker with a distilled backbone (FarmSAM) and an offline identity layer. The tracker backbone and the calf detector are in Sonam5/Calf-Identity-Tracking-Weights.
What is here
| Set | Days | Clips | What it is |
|---|---|---|---|
| Generated | 04-22 to 04-28 | 217 | Final refined masks, with identity rules for each day |
| Verified | 04-18, 04-19, 04-22, 04-23, 04-24 | 132 | Masks of the earlier two-day pass, with identity labels checked or reviewed as described below |
How identity was checked. A veterinarian (a co-author) checked identity across the training days 04-18 and 04-19, and reviewed the full overlay video of 04-22 and of 04-23 from start to end. The verified 04-22 and 04-23 chains carry that review; two 04-22 segments were relabelled as a result. The 04-24 folder holds the pipeline's own labels; the reference for 04-24 is a reviewer's notes of every identity change they saw, which are not published here. 04-25 to 04-28 were reviewed once at 50× speed. "Verified" refers to identity: mask boundaries were not hand-drawn on any day.
Which identity pass. The generated set, its relabel_week_<day>.json rules and the day videos in videos/week/ all come from the seven-day pass, whose pool of known calves grows over the week. The verified 04-22 and 04-23 chains come from the earlier two-day pass.
The video is camera FarmA_R1 of the Calf Play Behavior Dataset (doi:10.57967/hf/11689, CC0), described in its dataset paper (arXiv:2611.21706). This dataset holds no source video.
File layout
README.md
LICENSE_SAM.txt the SAM License
clips.csv one row per clip, with its video path
generated_refined_v5/<YYYY-MM-DD>/
masks_<clip>.json.gz refined masks per frame
refine_<clip>.json.gz one record per refinement trigger
segments.json anonymous segments
events.jsonl tracker events
ROOT_CONFIG.json, REFINE_CONFIG.json settings of the run
generated_identity/
relabel_week_<YYYYMMDD>.json slot to calf rules, 7 days
verified/
<YYYY-MM-DD>/... masks, segments and labels for that day
labels_train/ identity rules for 04-18 and 04-19
identity_key/ map from training keys to week ids
assets/ figures for this card
videos/ renders with the masks drawn on, 50x speed (one frame per 2 s)
20240422_1641-1748_refine_side_by_side.mp4 masks before and after refinement
20240423_1800-2400_teacher_student.mp4 tracker with the SAM 3 backbone and with the student,
side by side; colours are tracker slots (_stacked: phone)
week/<YYYYMMDD>_identities.mp4 one video per day, 04-22 to 04-28, colours are calves
In the day videos the picture is mosaicked while people are in the pen, with a margin of at least 60 s on each side. In all videos the feed alley beyond the rail is mosaicked in every frame, because staff walk there.
Formats
masks_<clip>.json.gz is gzipped JSON:
{"frames": [{"frame_idx": 0, "t_sec": 0.0,
"masks": {"0": {"size": [1296, 2304], "counts": [12, 40, 7]}, "1": null},
"prov": {"0": "k"}}]}
- Keys
0to3are tracker slots of that day. They are not calves. nullmeans the slot has no mask in that frame.countsis uncompressed COCO run-length data, in column-major order, starting with a run of background.provis in refined files only, per slot:kuntouched,rtrigger refused,d,corgchanged.- The example above is shortened. Real
countssum to height × width.
relabel_week_<YYYYMMDD>.json turns slots into calves:
{"day": "20240425", "rules": {"0": [["<from ISO time>", "<to ISO time>", 2]]}, "hidden": []}
A slot with no rule at a given time has no decided identity. It is shown as ?. Identities 0 to 3 hold across the week.
Decoding with pycocotools
import gzip, json
from pycocotools import mask as mask_utils
with gzip.open("masks_FarmA_R1_ch01-20240425-054428-061038.json.gz", "rt") as f:
clip = json.load(f)
for frame in clip["frames"]:
for slot, rle in frame["masks"].items():
if rle is None:
continue
h, w = rle["size"]
binary = mask_utils.decode(mask_utils.frPyObjects(rle, h, w)) # h x w, uint8
A version that needs only NumPy is in examples/decode_masks.py.
Link to the source video
Mask files are named after clips:
| Mask file | Video in the parent dataset |
|---|---|
masks_FarmA_R1_ch01-20240425-054428-061038.json.gz |
videos/FarmA_R1/2024-04-25/FarmA_R1_ch01-20240425-054428-061038.mp4 |
The separator differs by day: ch01_ on 04-18 and 04-19, ch01- from 04-22. clips.csv gives each pair. One 04-18 clip, 11:33, was corrupt at source and is not in the parent dataset, so it has no masks and no row here.
Time base. t_sec is seconds from the start of the clip. Wall time is the clip start from the file name plus t_sec. The parent dataset reads the burned-in clock instead, because the recorder drops frames, so the two can differ by a few seconds.
Good to know
- Slots are tracker slots, not calves. Always go through
relabel_week_<day>.json; a slot with no rule at that time is?. - Some masks flicker from frame to frame, and a few short stretches have no mask for a calf.
- Labels are missing for stretches on 04-25 to 04-28, mostly at dusk and in the last minutes of the day, where the identity layer chose
?. - At the start of 04-28 one calf has the wrong label until 06:00.
- People entered the pen on some days, so a calf mask can include part of a person standing next to the calf. On 04-23, from 15:36 to 15:50, the tracker followed a person instead of a calf in some slots; those masks are set to
null.
Licence and citation
Masks and labels: SAM License. They were made with SAM 3 and a student distilled from it, so we apply its terms to be safe. Anyone who passes them on must do so under those terms and include a copy of the licence. Its trade control limits apply. The videos stay CC0 in the parent dataset, doi:10.57967/hf/11689. The dataset documentation states that the observational study was approved by the Animal Welfare Body of Utrecht University (approval 10818-2024-02).
Identity decisions used DINOv3 ViT-S/16 embeddings. If you use the masks in a publication, you must acknowledge SAM 3 by Meta (clause 1.b.ii of the SAM License). Please acknowledge DINOv3 too, as its licence asks.
The paper is in preparation. Until it is out, please cite this dataset, the parent dataset (doi:10.57967/hf/11689) and its dataset paper (arXiv:2611.21706), and the distillation paper (arXiv:2604.27128).
- Downloads last month
- 258