Skip to content

Building a top-view mouse pose model from four public datasets ​

TUTORIAL 1 · MOUSEPOSE6_960_INT8

MousePose6 powers RodentFlow's RodentPose workflows. It was trained only on openly published videos, using the pose tracks that the dataset authors released alongside them as labels.

YOLO26n-pose6 keypoints960 pxCore ML · 8-bit weights

Model card ​

Shipped fileMousePose6_960_int8.mlpackage (2.76 MiB)
TaskOne class, mouse; six keypoints in this order: nose, left_ear, right_ear, neck, body_center, tail_base
Starting weightsUltralytics yolo26n-pose.pt (YOLO26 nano pose, pretrained by Ultralytics on COCO keypoints)
Size2,522,145 parameters
Input / output960 × 960 RGB image → tensor of shape (1, 300, 24) from the end-to-end (NMS-free) head
Training data8,840 images from 52 videos in four public datasets (6,140 train / 1,350 val / 1,350 test)
LabelsPose predictions released with the datasets (DeepLabCut for ETH; JAX's pose network for JABS), quality-filtered. Not human annotation.
SoftwareUltralytics 8.4.176, PyTorch 2.11.0 (CUDA 13.0), Python 3.13; one NVIDIA RTX PRO 6000 Blackwell GPU in Google Colab
ExportCore ML ML Program, coremltools 9.0, quantize=8, nms=False; package dated 13 October 2026
Licence field in the packageAGPL-3.0 (written by Ultralytics on export; see licences)
Sources: package metadata; notebooks `1012_MousePose_Dataset_Builder_v1`, `MousePose_YOLO_Train_v1`, `MousePose_iOS_Export_v1`.

The four data sources ​

All four datasets publish top-view videos of single mice together with pose files. The builder notebook downloaded a subset of videos from each, read the pose files and turned them into YOLO labels.

SourceRecordPose files released with itLicenceVideosTrain / val / test images
ETH Zurich BehaviorFlow — open field [D1]Zenodo 10.5281/zenodo.8186065DeepLabCut, 13 pointsCC BY 4.0201,680 / 360 / 360
ETH Zurich BehaviorFlow — marble burying, light–dark box, fear-conditioning box [D2]Zenodo 10.5281/zenodo.11235068DeepLabCut, 13 pointsCC BY 4.012960 / 240 / 240
JAX Kumar Lab strain survey, open field [D3]Harvard Dataverse 10.7910/DVN/SAPNJGJAX pose network, 12 points (*_pose_est_v6.h5)CC BY-NC-SA 4.0122,000 / 500 / 500
JAX Kumar Lab BxD survey, open field [D4]Harvard Dataverse 10.7910/DVN/RQYI04JAX pose network, 12 points (*_pose_est_v6.h5)CC BY-NC-SA 4.081,500 / 250 / 250
Total526,140 / 1,350 / 1,350

Each image contains one mouse. The JABS videos were sampled at 250 frames per video and the ETH videos at 120.

The ETH recordings and their DeepLabCut tracks are described in von Ziegler et al. 2024 (Nature Methods), the analysis framework that the datasets were released for. The JAX videos come from the JAX Animal Behavior System (JABS); their keypoints were produced by JAX's HRNet-based pose network (Sheppard et al. 2022) and are described with the datasets in Choudhary et al. 2026 (eLife). Full references are on the citation page.

INFO

WARNING

The two JAX datasets are CC BY-NC-SA 4.0: non-commercial, share-alike. Both Harvard Dataverse records (strain survey version 1.2, BxD version 1.0, viewed 20 October 2026) carry this licence: credit the authors, no commercial use, and adaptations must be shared under the same licence. 3,500 of MousePose6's 6,140 training images, with their keypoints, come from these two datasets. Whether trained weights legally count as an adaptation is not settled, but the cautious reading is that MousePose6 should not be used or distributed commercially, and that frames or labels derived from these datasets may only be redistributed under CC BY-NC-SA 4.0. That also sits uneasily with the AGPL-3.0 licence written into the model package, which permits commercial use. Before any commercial distribution of RodentFlow with this model, ask JAX (Kumar Lab) for permission, or retrain on the CC BY 4.0 ETH data alone (2,640 training images). This is not legal advice.

Step 1 · A shared keypoint set ​

The two labs use different keypoint schemes: JAX's network predicts 12 points, the ETH DeepLabCut models 13. Training on the union would leave half of the points unlabelled in half of the images, so the builder kept only points that every source provides (schema core6) and dropped tail mid and tip points everywhere.

core6 pointJAX JABS (12 points)ETH DeepLabCut (13 points)
nosenosenose
left_earleft_earearl
right_earright_earearr
neckbase_neckneck
body_centerDerived the same way for both: midpoint of neck and tail_base
tail_basebase_tailtailbase
droppedfour paws, center_spine, mid_tail, tip_tailheadcentre, bodycentre, bcl, bcr, hipl, hipr, tailcentre, tailtip

Why derive body_center? The sources place their body-centre points differently, so copying them would teach the model a compromise position. A geometric definition is identical everywhere. Its confidence is the lower of the two parent points.

# condensed from 1012_MousePose_Dataset_Builder_v1, sections 2 and 5
# JABS pose_est_v6.h5 stores points as (y, x); flip them to (x, y)
xy = pts[..., ::-1].astype(np.float32)

# body_center: identical definition for every source
X[..., BODY_CENTER, :] = (X[..., NECK, :] + X[..., TAIL_BASE, :]) / 2
C[..., BODY_CENTER]    = np.minimum(C[..., NECK], C[..., TAIL_BASE])

Step 2 · One meaning of “left” ​

Labs differ in whether “left” means the animal's left or the left of the image, and a mirrored convention silently breaks horizontal-flip augmentation. The builder therefore re-labelled the ears in every frame by top-view geometry: with the head axis running from neck to nose, the ear on the animal's left side (non-mirrored camera) is left_ear.

def cross2(a, b):
    return a[..., 0] * b[..., 1] - a[..., 1] * b[..., 0]

head = X[..., NOSE, :] - X[..., NECK, :]            # head axis, neck → nose
body = X[..., NECK, :] - X[..., TAIL_BASE, :]
cr = cross2(head, X[..., L_EAR, :] - X[..., R_EAR, :])
checkable = (C[..., L_EAR] >= thr) & (C[..., R_EAR] >= thr) & (np.abs(cr) > 0.02 * np.sum(body**2, -1))
wrong = checkable & (cr > 0)                        # convention: cross product < 0 for a correct pair
xa, xb = X[..., L_EAR, :].copy(), X[..., R_EAR, :].copy()
X[..., L_EAR, :] = np.where(wrong[..., None], xb, xa)   # swap (confidences are swapped the same way)
X[..., R_EAR, :] = np.where(wrong[..., None], xa, xb)

The notebook reports how often each source already matched the convention. In the first JABS strain-survey video, for example, 98.8 % of 98,672 checkable frames matched and 1,218 frames were swapped. The resulting flip_idx is [0, 2, 1, 3, 4, 5]: a horizontal flip exchanges the two ears and leaves the other points in place.

Step 3 · Quality filter and boxes ​

Because the labels are predictions, the builder removed frames where the prediction looked unreliable. A mouse instance was accepted only if all of the following held:

  • nose, neck, body_center and tail_base were above the confidence threshold (0.3 for JABS, 0.6 for ETH) and inside the image;
  • body length (nose to tail_base) was between 0.35 and 1.6 times the video's median, which keeps rearing postures;
  • neither the nose nor the body centre jumped more than half a median body length from the previous or next frame.

If any mouse in a frame failed, the whole frame was skipped, so no image contains an unlabelled animal. Points below the threshold were written as not visible.

Every source got the same box definition: a rectangle along the nose–tail_base axis, extended 10 % of body length in front of the nose and 5 % behind the tail base, 22 % of body length to each side, then made axis-aligned together with the visible keypoints.

L = np.linalg.norm(nose - tail_base); u = (nose - tail_base) / L; n = np.array([-u[1], u[0]])
front, back = nose + 0.10 * L * u, tail_base - 0.05 * L * u
corners = np.array([front + 0.22*L*n, front - 0.22*L*n, back + 0.22*L*n, back - 0.22*L*n])
pts = np.vstack([corners, visible_keypoints])
x0, y0 = np.clip(pts.min(0), 0, [W, H]); x1, y1 = np.clip(pts.max(0), 0, [W, H])

Step 4 · Sampling diverse frames ​

Consecutive video frames are nearly identical, and resting mice dominate long recordings. The builder considered every third frame (skipping the first and last 30), described each accepted frame by its body-centred, rotation-aligned pose plus its position in the arena, clustered these descriptions with mini-batch k-means, and took one frame per cluster, at least 15 frames apart. This gave 250 frames per JABS video and 120 per ETH video.

Step 5 · Splitting by video ​

Within each source, whole videos were assigned to train, validation and test in a 70 / 15 / 15 ratio (random seed 2026). Frames from one video never appear in two splits, so test scores are not inflated by near-duplicate frames. The resulting dataset.yaml:

names: {0: mouse}
kpt_shape: [6, 3]
flip_idx: [0, 2, 1, 3, 4, 5]
kpt_names: {0: [nose, left_ear, right_ear, neck, body_center, tail_base]}
kpt_oks_sigmas: [0.035, 0.035, 0.035, 0.05, 0.07, 0.05]

The OKS sigmas set how strictly each point is scored by the pose mAP metric (smaller is stricter); the sharply defined head points get the smallest values.

Step 6 · Training ​

from ultralytics import YOLO
model = YOLO('yolo26n-pose.pt')                  # COCO-pretrained YOLO26 nano pose model
model.train(data='dataset.yaml', imgsz=960, epochs=120, patience=30, batch=-1, seed=2026,
            fliplr=0.5, flipud=0.5, degrees=0.0, mosaic=1.0, close_mosaic=10,
            hsv_h=0.0, hsv_s=0.3, hsv_v=0.4, scale=0.5, translate=0.1)

The augmentation choices follow from the data, as the notebook explains:

  • horizontal and vertical flips, because a top view has no preferred orientation (flips swap the ears through flip_idx);
  • no rotation, because rotating enlarges the axis-aligned boxes and adds box noise;
  • no hue change and only mild saturation and brightness changes, because the data mix infrared greyscale and colour videos;
  • scale=0.5, because arena sizes and therefore mouse sizes differ a lot between labs;
  • mosaic switched off for the last 10 epochs.

All 120 epochs completed. The weights with the best validation fitness (best.pt) were copied to best_mousepose.pt, which is the file exported for the app. A second run with mosaic=0.2 was trained as an ablation; it is not the shipped model.

Step 7 · Evaluation ​

Two kinds of metrics were computed on the held-out splits. Keep in mind that the reference points are filtered model predictions, not human labels.

Ultralytics metrics ​

SplitBox mAP50Box mAP50-95Pose mAP50Pose mAP50-95
Validation (1,350 images)0.9420.7980.8590.665
Test (1,350 images)0.9650.8270.9010.697

Per-source error on the test split ​

For each reference mouse, the predicted box with the highest overlap was matched if IoU ≥ 0.5 (prediction confidence threshold 0.25). For matched mice the notebook measured each point's distance to the reference in pixels and as a fraction of the reference body length L (nose to tail_base). PCK@tL is the share of visible points within t × L. Missed mice are counted in the detection rate but not in the error and PCK columns.

SourceMiceDetectedMedian errorPCK@0.05LPCK@0.1LPCK@0.2LEars swapped
ETH MB / LDB / FC2401.0001.55 px0.8470.9730.9950.000
ETH open field3601.0001.19 px0.9250.9940.9990.000
JAX BxD2501.0000.86 px0.9110.9790.9910.016
JAX strain survey5000.8541.20 px0.7720.9150.9830.016
All1,3500.9461.17 px0.8570.9610.9910.009

Source: MousePose_YOLO_Train_v1, section 5. False detections with confidence above 0.5 were 0.001 per image overall.

The JAX strain-survey videos stand out: 14.6 % of their reference mice had no matching box. A miss here means no predicted box reached IoU 0.5 with the reference box; the notebook does not break down why those misses happened, so treat strain-survey-like videos with extra care.

Speed on the training GPU (PyTorch, batch 1) was 3.2 ms of inference and about 210 frames per second end to end. That figure says nothing about speed on a Mac.

Step 8 · Input size and export ​

The export notebook first compared 640 and 960 px input with the PyTorch weights on the test split. Its rule was to choose 640 px if it lost no more than one percentage point of detection rate and PCK@0.1L.

Input sizeDetectedPCK@0.1LMedian error
640 px0.9310.9501.24 px
960 px0.9460.9611.17 px

640 px lost 1.5 points of detection and 1.1 points of PCK, so 960 px was kept. The export itself is one call:

pip install "ultralytics[export-coreml]>=8.4.142"     # needs numpy ≤ 2.3.5; the run used numpy 2.1.3

from ultralytics import YOLO
YOLO('best_mousepose.pt').export(format='coreml', imgsz=960, quantize=8, nms=False)   # INT8
YOLO('best_mousepose.pt').export(format='coreml', imgsz=960, quantize=16, nms=False)  # FP16 alternative

The saved run of the export notebook used a forced size of 640 px; the package that ships is 960 px and dated 13 October 2026, so it was produced by the same call at 960 px. The notebook also built a Mac validation pack (300 test images, validate_on_mac.py) to compare the .pt, FP16 and INT8 versions on macOS, with the rule “use INT8 if it loses less than about one PCK point”. Tutorial 4 shows how to run that check.

Scope and licences ​

  • The training images show one mouse per image, filmed from above in open-field-like arenas in two laboratories. For other arenas, cameras or bedding, check the tracking on a few of your own videos; for a white mouse use WhiteMousePose6, for two mice the two-animal models.
  • The reference labels are the DeepLabCut and JAX predictions released with the datasets, so the test scores give agreement with those trackers.
  • More than half of the training images come from CC BY-NC-SA 4.0 datasets, which restricts commercial use (see data sources).

What to cite ​

If you publish results computed with MousePose6, cite RodentFlow (with its version), Ultralytics YOLO26, the four datasets, the papers that describe them, and DeepLabCut, whose predictions form the ETH labels. The citation page lists the exact references and gives an example methods paragraph.