Skip to content
ModelListedExternal
Browse files

Cattle Vision Framework

Pretrained model weights for the Cattle Vision Framework, an MS thesis project on multi-behavior recognition in dairy cattle from surveillance video.

KindOtherVersionRevision bc8d551

Model source

Kind
Other
File size
127–386 MB
Version
vRevision bc8d551
Updated
Sep 27, 2026
Downloads
0
Tasks
Object detection
Source
Hugging Face

Source description

Cattle Vision Framework — Model Weights

Pretrained model weights for the Cattle Vision Framework, an MS thesis project on multi-behavior recognition in dairy cattle from surveillance video.

Pipeline: RF-DETR detection → SAM2 segmentation → OC-SORT tracking → VideoMAE behavior classification

Datasets: CBVD-5 (indoor barn, 12 GB) and CVB (outdoor pasture, 15 GB)


Available Weights

FilenameSizeDescriptionVal Metric
rf-detr-medium.pth387 MBRF-DETR-Medium backbone (COCO pretrained, not fine-tuned)—
rf-detr-seg-medium.pt137 MBRF-DETR-Seg-Medium fine-tuned on SAM2 pseudo-labels (Phase 3b)—
rfdetr_combined_v1_best.pth128 MBRF-DETR cattle detector, trained on CBVD-5 + CVB combined70.4% mAP@50
videomae_combined_v1.pt330 MBVideoMAE Config 5: trained on CBVD-5+CVB, eval on bothmacro-F1=0.7537
videomae_cvb_v1.pt330 MBVideoMAE Config 2: trained on CVB, eval on CVBmacro-F1=0.7607
videomae_cbvd5_v1.pt330 MBVideoMAE Config 1: trained on CBVD-5, eval on CBVD-5macro-F1=0.3149
videomae_cbvd5_to_cvb_v1.pt330 MBVideoMAE Config 3: trained on CBVD-5, eval on CVB (cross-domain)macro-F1=0.1690
videomae_cvb_to_cbvd5_v1.pt330 MBVideoMAE Config 4: trained on CVB, eval on CBVD-5 (cross-domain)macro-F1=0.1789

7-Class Behavior Taxonomy

IDBehaviorDatasets
0StandingCBVD-5, CVB
1LyingCBVD-5, CVB
2Foraging/GrazingCBVD-5, CVB
3DrinkingCBVD-5, CVB
4RuminatingCBVD-5, CVB
5GroomingCVB only
6OtherCVB only

Cross-dataset evaluation uses IDs 0–4 only.


Behavior Classification Results (VideoMAE)

ConfigTrainEvalmacro-F1F1-StandingF1-LyingF1-ForagingF1-DrinkingF1-Ruminating
Config 1CBVD-5CBVD-50.31490.9060.3030.8960.0000.100
Config 2CVBCVB0.76070.8600.8450.9790.8810.801
Config 3CBVD-5CVB0.16900.2150.2810.0060.1880.493
Config 4CVBCBVD-50.17890.6750.1450.4320.0000.000
Config 5CBVD-5+CVBBoth0.75370.8700.8230.9800.8760.772

Training Configs

Behavior Classification (videomae_combined_v1.pt)

experiment_name: videomae_combined_v1
model_name: MCG-NJU/videomae-base-finetuned-kinetics
num_classes: 7

train:
  dataset_filter: null   # combined CBVD-5 + CVB
  split_filter: train

batch_size: 8
grad_accum_steps: 4      # effective batch = 32
num_epochs: 30
lr: 5.0e-5
lr_head: 1.0e-3
weight_decay: 0.05
warmup_epochs: 3
early_stopping_patience: 8
use_class_weights: true

Detection (rfdetr_combined_v1_best.pth)

experiment_name: rfdetr_combined_v1
model:
  type: RFDETRMedium
  pretrained: true
dataset:
  name: combined
  num_classes: 1          # single class: cattle
training:
  epochs: 100
  batch_size: 2
  grad_accum_steps: 8     # effective batch = 16
  resolution: 576         # must be divisible by 64
  lr: 1.0e-4
  lr_encoder: 1.5e-4
  gradient_checkpointing: true
  use_ema: true

Usage

Download a weight file

# Install CLI
pip install huggingface-hub

# Download best behavior model
huggingface-cli download sakifkhan98/cattle-vision-framework videomae_combined_v1.pt \
  --local-dir weights/

# Download backbone
huggingface-cli download sakifkhan98/cattle-vision-framework rf-detr-medium.pth \
  --local-dir weights/

Load behavior classifier

import torch
from transformers import VideoMAEForVideoClassification

# Load checkpoint
ckpt = torch.load("weights/videomae_combined_v1.pt", map_location="cpu")
model = VideoMAEForVideoClassification.from_pretrained(
    "MCG-NJU/videomae-base-finetuned-kinetics",
    num_labels=7,
    ignore_mismatched_sizes=True,
)
model.load_state_dict(ckpt["model_state_dict"])
model.eval()

LABEL_NAMES = {
    0: "Standing", 1: "Lying", 2: "Foraging",
    3: "Drinking", 4: "Ruminating", 5: "Grooming", 6: "Other"
}

Load RF-DETR detector

from rfdetr import RFDETRMedium
import torch

model = RFDETRMedium()
ckpt = torch.load("weights/rfdetr_combined_v1_best.pth", map_location="cpu")
model.load_state_dict(ckpt["model"])
model.eval()

Citation

@mastersthesis{khan2026cattle,
  author  = {Sakif Khan},
  title   = {Multi-Behavior Recognition in Dairy Cattle from Surveillance Video},
  school  = {Texas State University},
  year    = {2026},
}

License

MIT License. See LICENSE.

Sources

1 source
Hugging FacePrimaryVersion bc8d5519191fa67fb55a6ac574b018ade9f75709
huggingface.co/sakifkhan98/cattle-vision-framework/tree/bc8d5519191fa67fb55a6ac574b018ade9f75709

Verified Sep 27

Download files

Model artifacts

8 artifacts

rf-detr-medium.pth

pth · 386 MB · SHA-256 749ff6071828…68c8 · Hugging Face

Download file

rf-detr-seg-medium.pt

pt · 136 MB · SHA-256 3ad325094735…ea58 · Hugging Face

Download file

rfdetr_combined_v1_best.pth

pth · 127 MB · SHA-256 eb700fdca964…ab38 · Hugging Face

Download file

videomae_cbvd5_to_cvb_v1.pt

pt · 329 MB · SHA-256 3497b471e3b2…80a5 · Hugging Face

Download file

videomae_cbvd5_v1.pt

pt · 329 MB · SHA-256 7526a0a854b4…8b02 · Hugging Face

Download file

videomae_combined_v1.pt

pt · 329 MB · SHA-256 0428a1e282ab…976f · Hugging Face

Download file

videomae_cvb_to_cbvd5_v1.pt

pt · 329 MB · SHA-256 2b461b863cd4…a86b · Hugging Face

Download file

videomae_cvb_v1.pt

pt · 329 MB · SHA-256 b0b32753f3f6…aaf8 · Hugging Face

Download file

Source excerpts

2 excerpts

--- license: mit language: - en tags: - cattle - behavior-recognition - object-detection - video-classification - pytorch - rfdetr - videomae - animal-behavior datasets: - sakifkhan98/cattle-vision-data --- # Cattle Vision Framework — Model Weights Pretrained model weights for the [Cattle Vision Framework](https://github.com/sakifkhan98/cattle-vision-framework), an MS thesis project on multi-behavior recognition in dairy cattle from surveillance video. **Pipeline:** RF-DETR detection → SAM2 segmentation → OC-SORT tracking → VideoMAE behavior classification **Datasets:** CBVD-5 (indoor barn, 12 GB) and CVB (outdoor pasture, 15 GB) --- ## Available Weights | Filename | Size | Description | Val Metric | |----------|------|-------------|------------| | `rf-detr-medium.pth` | 387 MB | RF-DETR-Medium backbone (COCO pretrained, not fine-tuned) | — | | `rf-detr-seg-medium.pt` | 137 MB | RF-DETR-Seg-Medium fine-tuned on SAM2 pseudo-labels (Phase 3b) | — | | `rfdetr_combined_v1_best.pth` | 128 MB | RF-DETR cattle detector, trained on CBVD-5 + CVB combined | 70.4% mAP@50 | | `videomae_combined_v1.pt` | 330 MB | VideoMAE Config 5: trained on CBVD-5+CVB, eval on both | macro-F1=0.7537 | | `videomae_cvb_v1.pt` | 330 MB | VideoMAE Config 2: trained on CVB, eval on CVB | macro-F1=0.7607 | | `videomae_cbvd5_v1.pt` | 330 MB | VideoMAE Config 1: trained on CBVD-5, eval on CBVD-5 | macro-F1=0.3149 | | `videomae_cbvd5_to_cvb_v1.pt` | 330 MB | VideoMAE Config 3: trained on CBVD-5, eval on CVB (cross-domain) | macro-F1=0.1690 | | `videomae_cvb_to_cbvd5_v1.pt` | 330 MB | VideoMAE Config 4: trained on CVB, eval on CBVD-5 (cross-domain) | macro-F1=0.1789 | --- ## 7-Class Behavior Taxonomy | ID | Behavior | Datasets | |----|----------|---------| | 0 | Standing | CBVD-5, CVB | | 1 | Lying | CBVD-5, CVB | | 2 | Foraging/Grazing | CBVD-5, CVB | | 3 | Drinking | CBVD-5, CVB | | 4 | Ruminating | CBVD-5, CVB | | 5 | Grooming | CVB only | | 6 | Other | CVB only | Cross-dataset evaluation uses IDs 0–4 only. --- ## Behavior Classification Results (VideoMAE) | Config | Train | Eval | macro-F1 | F1-Standing | F1-Lying | F1-Foraging | F1-Drinking | F1-Ruminating | |--------|-------|------|----------|-------------|----------|-------------|-------------|---------------| | Config 1 | CBVD-5 | CBVD-5 | 0.3149 | 0.906 | 0.303 | 0.896 | 0.000 | 0.100 | | Config 2 | CVB | CVB | **0.7607...

Source context: 0 downloads · 0 likes · Pipeline object-detection · Repo sakifkhan98/cattle-vision-framework