MouseLite
Real-time mouse detection, segmentation and pose estimation.
MouseLite wraps fine-tuned RF-DETR models in a video pipeline: it predicts per frame, links predictions across frames with a multi-object tracker, writes an annotated video, and exports the predictions as a COCO dataset you can re-track or analyse later.
Three model kinds are available:
| Kind | Sizes | Output |
|---|---|---|
detection |
nano, small, medium, large |
bounding boxes |
segmentation |
nano, small, medium, large |
boxes + instance masks |
keypoints |
single checkpoint | boxes + pose keypoints |
Installation
Requires Python ≥ 3.12.
pip install mouselite
With uv:
uv add mouselite
The Gradio demo is an optional extra:
pip install "mouselite[app]"
From a checkout:
git clone https://github.com/juan-cobos/mouselite
cd mouselite
uv sync --extra app
Model weights are downloaded from the Hugging Face Hub on first use and cached;
pass --checkpoint to use your own instead.
CLI
mouselite --help
run — inference on a video
mouselite run video.mp4 --kind keypoints
Writes two things under --output-dir (default output/):
output/
├── video_annotated.mp4 # annotated video
└── video_coco/
├── annotations.json # COCO export (boxes, masks, keypoints, track ids)
└── images/ # the frames inference ran on
Common options:
| Option | Default | Meaning |
|---|---|---|
--kind |
required | detection, segmentation or keypoints |
--size |
medium |
model size; ignored by keypoints |
--checkpoint |
— | path to your own weights, skipping the Hub download |
--tracker |
bytetrack |
tracking algorithm (see list-trackers) |
--threshold |
0.5 |
minimum confidence for a prediction to be kept |
--nms-threshold |
0.5 |
drop the lower-scoring of two predictions overlapping above this |
--top-k |
— | keep only the N highest-scoring predictions per frame |
--every |
1 |
run inference on 1 of every N frames, reusing predictions in between |
--output-dir |
output |
where the video and COCO export are written |
--save-path |
— | write annotations.json somewhere else |
--show |
off | preview the annotated frames in a window while running |
--hud |
off | draw a live FPS counter on the output |
--dtype |
float32 |
inference precision |
--batch-size |
1 |
inference batch size |
--compile |
off | torch.compile the model — slower to start, faster per frame |
--no-show-progress |
— | silence the progress bar |
Two animals, pose, half the frames, with a preview window:
mouselite run video.mp4 --kind keypoints --top-k 2 --every 2 --tracker ocsort --show
retrack — re-run tracking without re-running inference
Tracking is usually what you end up tuning, and it is far cheaper than inference.
retrack replays an existing COCO export through a different tracker:
mouselite retrack output/video_coco/annotations.json --tracker ocsort
Writes output/video_retracked.mp4 and updates each annotation's track_id in
annotations.json in place, so the export always reflects the last tracking pass
(-1 for detections the tracker did not confirm). The frame rate is read from the
export (run records it, divided by --every), falling back to 30; pass --fps to
override.
The two knobs that matter most for mice are how long a track survives an occlusion and how loosely a detection may match it:
| Option | Default (tracker's) | Meaning |
|---|---|---|
--lost-track-buffer |
30 |
frames a track is kept alive without a match, at 30 fps |
--minimum-iou-threshold |
0.1–0.3 |
minimum IoU to match a detection to an existing track |
Both are forwarded as-is to the tracker class.
mouselite retrack output/video_coco/annotations.json --tracker ocsort --lost-track-buffer 90 --minimum-iou-threshold 0.15
app — Gradio demo
mouselite app # needs the [app] extra
mouselite app --no-share --port 7860
Upload a video, pick a model and tracker, run, and retrack the same predictions with a different tracker without paying for inference again.
list-models / list-trackers
$ mouselite list-models
detection: nano, small, medium, large
segmentation: nano, small, medium, large
keypoints
$ mouselite list-trackers
botsort
ocsort
bytetrack
sort
cbiou
mcbyte
Python API
The CLI is a thin wrapper over three pieces: a model, a tracker, and a Pipeline
that joins them.
import supervision as sv
from mouselite.models import get_model
from mouselite.pipeline import Pipeline
from mouselite.tracker import get_tracker
model = get_model("keypoints")
fps = sv.VideoInfo.from_video_path("video.mp4").fps
tracker = get_tracker("ocsort", frame_rate=fps)
pipeline = Pipeline(model, tracker, threshold=0.5, top_k=2)
annotated_path = pipeline.run("video.mp4", output_dir="output")
get_model
model = get_model(
"segmentation", # "detection", "segmentation" or "keypoints"
size="large", # ignored for "keypoints"
checkpoint=None, # path to your own weights; otherwise pulled from the Hub
dtype="float32",
batch_size=1,
compile=False,
)
Returns an RF-DETR model already put in inference mode. Any object with a
predict(frame, threshold) -> sv.Detections | sv.KeyPoints method and a class_names
attribute works in its place — that is the whole MLModel protocol the pipeline
depends on.
get_tracker
tracker = get_tracker("bytetrack", frame_rate=30)
Any name from mouselite.tracker.TRACKERS; keyword arguments go straight to the
underlying trackers class.
Pipeline
pipeline = Pipeline(
model,
tracker,
threshold=0.5, # confidence floor
nms_threshold=0.5, # NMS IoU threshold
top_k=None, # cap on predictions per frame, by confidence
every=1, # run inference on 1 of every N frames
)
annotated_path = pipeline.run(
"video.mp4",
output_dir="output",
save_path=None, # override the annotations.json location
show=False, # live preview window
hud=False, # FPS overlay
show_progress=True,
)
run returns the path of the annotated video and writes the COCO export beside it.
Keypoint predictions are converted to sv.Detections for tracking — keeping the
model's own box rather than a box fitted to the keypoints — and carried through to the
export as COCO keypoints/num_keypoints fields.
retrack
from mouselite.tracker import retrack
retracked_path = retrack(
"output/video_coco/annotations.json",
"ocsort",
output_dir="output",
fps=None, # recorded by `run`, else 30
lost_track_buffer=90, # any further kwargs go to the tracker class
)
Training
The code behind the released models — fine-tuning RF-DETR and the DeepLabCut
SuperAnimal baseline, plus the scripts that scored them — lives in
training/. It is for reproducing the paper; to just run the
models, use the package above.
Acknowledgements
MouseLite is built on work by others:
- RF-DETR — the real-time detection transformer behind every MouseLite model. The detection, segmentation and keypoints-preview architectures are RF-DETR's; MouseLite fine-tunes them on mice.
- supervision — detection and keypoint containers, NMS, annotators, video I/O and the COCO format helpers. It is the vocabulary the whole pipeline is written in.
- trackers — every multi-object tracker MouseLite offers. ByteTrack, BoT-SORT, OC-SORT, SORT, C-BIoU and McByte all come from it unchanged; MouseLite only picks one and hands it detections.
- DeepLabCut — the reference point for markerless animal pose estimation, and the SuperAnimal baseline MouseLite is evaluated against. This project exists because of the problem DeepLabCut defined and the community it built around it.
Metadata
Release files for mouselite 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mouselite-0.1.1.tar.gz | 11.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mouselite-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 25.1 kB
Release files / mouselite-0.1.1.tar.gz
| Download URL | mouselite-0.1.1.tar.gz |
|---|---|
| Size | 11.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2588d4d06585e22b4ad5c61d66db6aa16de02203f62294dce817ac119d2edb80
|
|
BLAKE2b-256 checksum How to use checksums |
8c588c47ff19d39c8efeacb1c172499e0d523576a0329c10ba7c4cec1ef36c35
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / mouselite-0.1.1-py3-none-any.whl
| Download URL | mouselite-0.1.1-py3-none-any.whl |
|---|---|
| Size | 14.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a8bfd4a1e34aa47df83545c7891337f98817782c1c5aae91ce7d6b97d82a202e
|
|
BLAKE2b-256 checksum How to use checksums |
d052976b2dcc5f06f96582dec30c1acebfa38fdd7857a671e433c6931b86c1d1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Manjaro Linux","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|