behavert / README.md
ShinSeungJ's picture
Release BehaVERT checkpoints
204768a verified
|
Raw History Blame Contribute Delete
5.61 kB
---
license: mit
library_name: behavert
tags:
- animal-behavior
- pose
- keypoints
- mouse
- behavior-classification
- attention
datasets:
- ShinSeungJ/behavert-data
---
# BehaVERT models
Pretrained models for **BehaVERT**, a transformer that reads animal pose
keypoints as a sequence of tokens and decodes behavior from them
(Shin et al., *International Journal of Computer Vision* 2026,
[doi:10.1007/s11263-026-02834-y](https://doi.org/10.1007/s11263-026-02834-y)).
Code: <https://github.com/ShinSeungJ/BehaVERT>.
| Model | Predicts | Input | Head |
|---|---|---|---|
| [`calms21-task1/`](https://huggingface.co/ShinSeungJ/behavert/tree/main/calms21-task1) | attack / investigation / mount / other, every frame | 2 mice × 7 keypoints, 2D | token (per frame) |
| [`mabe22-strain/`](https://huggingface.co/ShinSeungJ/behavert/tree/main/mabe22-strain) | strain of a mouse triplet, WT / TG | 3 mice × 12 keypoints, 2D | sequence (`[CLS]`) |
| [`oft-behavior/`](https://huggingface.co/ShinSeungJ/behavert/tree/main/oft-behavior) | 7 open-field behaviors, every frame | 1 mouse × 11 keypoints, 2D | token (per frame) |
Each folder holds `config.json` (architecture, classes, keypoint layout,
drawing settings) and `model.safetensors` (about 86M parameters). The
matching pose models are in [ShinSeungJ/behavert-pose](https://huggingface.co/ShinSeungJ/behavert-pose).
## Use
```bash
pip install "behavert[pose] @ git+https://github.com/ShinSeungJ/BehaVERT"
behavert decode --video my_videos/ --model oft-behavior --overlay --sync # video -> behavior
behavert decode --keypoints session.csv --model calms21-task1 --video session.mp4 --sync
```
```python
from behavert import BehaVERT
from behavert.inference import predict_recording
model = BehaVERT.from_pretrained("calms21-task1") # downloads calms21-task1/ from this repo
pred = predict_recording(model, keypoints) # keypoints [T, mouse, keypoint, (x, y)]
pred.labels # one class per frame
```
`behavert decode` writes per-frame behaviors, a summary per behavior, a video
with the skeleton and behavior drawn on, and a synchronized panel video with
window embeddings (t-SNE), attention and confidence. `behavert attention` and
`behavert embed` analyse attention and embeddings over a whole dataset.
## `calms21-task1` — CalMS21 Task 1
Resident–intruder pairs; frame-level attack, investigation, mount or other.
Pretrained by masked keypoint modeling on all CalMS21 keypoints, then fine-tuned
on Task 1 ("BehaVERT (self-supervision)" in Table 1 of the paper).
- **Input:** 2 mice (resident, intruder) × 7 keypoints (nose, left ear, right
ear, neck, left hip, right hip, tail base) × (x, y) = 28 values per frame;
MARS pixel coordinates of a 1024 × 570 video.
- **Windows:** 128 frames at 30 fps, step 64, overlapping predictions averaged.
- **Test set** (19 sessions, 211,325 scored frames; "other" frames not scored):
| attack | investigation | mount | macro F1 |
|---|---|---|---|
| 0.794 | 0.889 | 0.930 | 0.871 |
## `mabe22-strain` — MABe22 strain
Mouse triplets; the strain (WT or TG) of 64-frame windows, combined into one
prediction per video. The strain model of Table 4 and the model analysed in
Fig. 8 (attention) of the paper.
- **Input:** 3 mice × 12 keypoints (nose, left ear, right ear, neck, left
forepaw, right forepaw, center back, left hindpaw, right hindpaw, tail base,
tail middle, tail tip) × (x, y) = 72 values per frame; MABe22 pixel
coordinates as distributed, missing keypoints 0.
- **Windows:** 64 frames at 30 fps, step 32; a video's label comes from its
averaged window probabilities.
- **Test set** (1,121 videos; video-level split 60/20/20, seed 42):
| | WT F1 | TG F1 | macro F1 |
|---|---|---|---|
| video level | 0.867 | 0.771 | 0.819 |
| window level | 0.809 | 0.696 | 0.753 |
## `oft-behavior` — open-field behavior
Single mouse, top-view open-field test; frame-level **supported rearing**,
**unsupported rearing**, **grooming**, **freezing**, **jumping**, **backwards
walking** or **others**. Reads the keypoints of the `oft-pose` model, so
`behavert decode --video … --model oft-behavior` goes from video to behavior in one step.
- **Input:** 1 mouse × 11 keypoints (nose, left ear, right ear, left forelimb,
right forelimb, tail base, left hindlimb, right hindlimb, tail middle, tail
tip, body center) × (x, y) = 22 values per frame, normalized to [0, 1] by
frame width and height; frames without a detection are linearly interpolated.
These are `oft-pose` keypoints 0, 1, 2, 4–11 (its thoracic center is not used).
- **Windows:** 64 frames at 30 fps, step 32, overlapping predictions averaged.
- **Training data:** top-view open-field recordings of single mice with
frame-level behavior annotations made in our lab. Results depend on a similar
setup (camera above a square open field, one mouse); check predictions on a
few of your own videos before relying on them.
## Citation
```bibtex
@article{shin2026behavert,
title = {BehaVERT: A Transformer-Based Motion Language Model for Decoding Behavioral Semantics in Mice},
author = {Shin, Seung Jae and Lee, Junesu and Ko, Chang and Kim, Daesoo},
journal = {International Journal of Computer Vision},
volume = {134},
pages = {303},
year = {2026},
doi = {10.1007/s11263-026-02834-y}
}
```
`calms21-task1` was trained on CalMS21 (Sun et al., NeurIPS 2021 Datasets and
Benchmarks) and `mabe22-strain` on MABe22 (Sun et al., ICML 2023); please cite
those datasets as well when you use the models.