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/.
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.
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 whose identity chain people checked |
How identity was checked. A veterinarian checked identity across the training days 04-18 and 04-19 and, with the first author, the full identity chains of 04-22 and 04-23. On 04-24 reviewers noted every identity change they saw. 04-25 to 04-28 were reviewed once at 50× speed. "Verified" refers to identity: mask boundaries were not hand-drawn on any day.
The video is camera FarmA_R1 of the Calf Play Behavior Dataset (doi:10.57967/hf/10912, CC0). 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/ before and after clip of 04-22, with overlays
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 is corrupt at source, so it has no masks.
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/10912. 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 and the distillation paper (arXiv:2604.27128).
- Downloads last month
- 121