Downloads · 30 days
0
0xmudit/cattle-reid-hanwoo-vit-b16-phe
cattle-reid-hanwoo-vit-b16-phe is a image classification model from 0xmudit. Use it when you need a label for an image. The card lists the license as other.
A supervised cattle re-identification model following the HanwooReID approach: a Vision Transformer (ViT-B/16) backbone with a Pose-Guided Heatmap Encoder (PHE), a BatchNorm embedding head and a linear classifier.
Downloads · 30 days
0
Access
Public
Updated Aug 20, 2026
Repo size
347 MB
Likes
0
Public
Click a slice to open those files.
.pth347 MB · 100%
From the Hugging Face model README
A supervised cattle re-identification model following the HanwooReID approach: a Vision Transformer (ViT-B/16) backbone with a Pose-Guided Heatmap Encoder (PHE), a BatchNorm embedding head and a linear classifier.
Hanwoo cattle have no distinctive coat markings, so appearance-only re-identification fails. The pose-guided encoder injects keypoint heatmaps into the ViT patch embeddings to make the embedding view-invariant.
| File | Description |
|---|---|
hanwoo_reid_best.pth | Best checkpoint (mAP 99.91%), PyTorch state dict |
hanwoo_report_v3.json | Full per-epoch training report |
vit_base_patch16_224) + PHE (16×16 Gaussian heatmaps, 12 keypoints)
torch.compile0.1× the head LR (--backbone-lr-factor 0.1, backbone
3e-5, head/PHE/BN 3e-4, AdamW, cosine schedule, 5-epoch warmup)--weight-ce 0.3, loss = 0.3·CE(focal γ=2, label smoothing 0.1)
| Metric | Value |
|---|---|
| mAP | 99.91% |
| Rank-1 | 99.94% |
| Rank-5 | 99.97% |
| Rank-10 | 99.97% |
PHE adds no measurable gain at this scale (with/without PHE are equal); it is kept for view-invariance on CCTV footage.
The checkpoint is a raw torch.save dict:
import torch
ckpt = torch.load("hanwoo_reid_best.pth", map_location="cpu", weights_only=False)
state = ckpt["state"] # state dict (keys without _orig_mod.)
ncls = ckpt["config"]["ncls"] if "ncls" in ckpt["config"] else None
# number of classes is inferred from the classifier head:
ncls = state["classifier.weight"].shape[0]
import timm
class PHE(torch.nn.Module): ... # see repository training/reid_common.py
model = ... # HanwooReID(ncls) — ViT + PHE + BN head
model.load_state_dict(state, strict=False)
model.eval()
Embedding recipe (see training/reid_common.py in the source repo):
letterbox_crop to 256×256, normalize (x/255 - 0.5)/0.5emb, logits = model(x, heatmap); use emb (cosine similarity)The same checkpoint is used end-to-end in a cross-camera video pipeline
(DeepSORT + global ID fusion across videos) — see the source repository
training/video_reid_v6.py.
Model trained on a private cattle dataset (514 identities). For access to the training data or the full pipeline, open an issue on the source repo.