cotracker / README.md
Flor's picture
card: update from fastforks 1cbf1671
052df0f verified
|
Raw History Blame Contribute Delete
8.25 kB
---
library_name: "fastforks"
pipeline_tag: "keypoint-detection"
license: "cc-by-nc-4.0"
tags:
- "tracking"
- "point-tracking"
- "tracking-any-point"
- "video"
- "cuda"
- "pytorch"
- "fastforks"
- "fastforks-card"
base_model:
- "facebook/cotracker3"
---
# CoTracker3 (fastforks)
CoTracker3 (Karaev et al., Meta AI 2024): tracking any point with a transformer that tracks all points jointly. A CNN encodes every frame at 384 x 512 into 128-channel features at 1/4 resolution (a 4-level pyramid); each track correlates the 7 x 7 neighbourhood of its current position with the 7 x 7 support of its query on every level (an MLP encodes the 4D correlation), and a transformer with attention over time and, through 64 virtual tracks, across tracks updates positions, visibility and confidence in 6 iterations. Offline: the whole video at once; online: sliding windows of 16 frames, 8 new frames per step.
This repo is the model card only: it holds no weights. fastforks downloads the authors' weights from the links below and checks them against the SHA-256 in the model card. Code: <https://github.com/kleinicke/fastforks>. Kernels for the `kernels` backend: <https://huggingface.co/fastforks/kernels>. Original code: <https://github.com/facebookresearch/co-tracker> at `82e02e802975`.
Author weight repos: <https://huggingface.co/facebook/cotracker3>.
Task: tracking. Tier: experimental. Outputs: `tracks`, `visibility`. Backends: `portable`, `kernels`.
Input: a video (its frames in order) and query points `(t, x, y)`. Output: the position of every query in every frame and the probability that it is visible there.
## Variants
Weights are the authors' files (not hosted here). SHA-256 shortened to 12 hex digits; the full hashes are in [`card.toml`](https://github.com/kleinicke/fastforks/blob/main/src/fastforks/tracking/models/cotracker/card.toml).
| variant | weights (author link) | SHA-256 | weights licence | commercial use |
|---|---|---|---|---|
| `cotracker3-offline@1` | [scaled_offline.pth](https://huggingface.co/facebook/cotracker3/resolve/bf55ea50d4390e1820a267f131cd6587240fb2c5/scaled_offline.pth) | `2670d4562ed6` | CC-BY-NC-4.0 | **no** |
| `cotracker3-online@1` | [scaled_online.pth](https://huggingface.co/facebook/cotracker3/resolve/bf55ea50d4390e1820a267f131cd6587240fb2c5/scaled_online.pth) | `205d34789f19` | CC-BY-NC-4.0 | **no** |
## Licence
Original-code strings, recorded as they are (research-use package; check them before any other use). Code: CC-BY-NC-4.0. Licence files: `LICENSE.md`.
Training data: Upstream paper: trained on synthetic Kubric MOVi-F sequences, then fine-tuned by pseudo-labelling about 15k real internet videos with other trackers (not released). No dataset entry here yet..
Licence evidence: https://github.com/facebookresearch/co-tracker/blob/82e02e8029753ad4ef13cf06be7f4fc5facdda4d/LICENSE.md (CC BY-NC 4.0); https://github.com/facebookresearch/co-tracker/blob/82e02e8029753ad4ef13cf06be7f4fc5facdda4d/README.md#license; https://huggingface.co/facebook/cotracker3/blob/bf55ea50d4390e1820a267f131cd6587240fb2c5/README.md (license: cc-by-nc-4.0)
## Input size
any H x W >= 32, padded to a multiple of 32
Tested up to (portable, fp16, RTX 5060 Ti 16 GB): `cotracker3-offline` 3000x4000 (5.5 GiB peak allocated, 5.9 reserved); `cotracker3-online` 3000x4000 (5.5 GiB peak allocated, 5.9 reserved)
## Speed and memory
### Tracking, synthetic, 480x854
| model | time (ms): original | portable | kernels | kernels speed-up: vs original | vs portable | peak memory (MiB, allocated / reserved): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `cotracker3-offline` | 244 | 162 | 154 | 1.6x | 1.1x | 2221 / 2480 | 755 / 882 | 799 / 916 |
| `cotracker3-online` | 328 | 184 | 176 | 1.9x | 1.0x | 1659 / 1886 | 755 / 906 | 798 / 922 |
### Startup and first call
| model | load (s): original | portable | kernels | first call (s): original | portable | kernels |
| --- | --- | --- | --- | --- | --- | --- |
| `cotracker3-offline` | 0.65 | 0.28 | 0.19 | 0.87 | 0.42 | 0.52 |
| `cotracker3-online` | 0.54 | 0.65 | 0.18 | 0.54 | 0.39 | 0.54 |
### torch.compile and TensorRT
| model | input | time: portable | compile | TensorRT fp16 | kernels | preparation: compile (cold first call) | ONNX + engine build | peak MiB (alloc / reserved): portable | compile | kernels | TensorRT (engine + torch) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| `cotracker3-offline` | 480x854 | 162 ms | 135 ms | 25.9 ms | 154 ms | 36.5 s | 157 s | 755 / 882 | 755 / 902 | 799 / 916 | 519 / 586 |
| `cotracker3-online` | 480x854 | 184 ms | 159 ms | planned for 0.2.1 | 176 ms | 37.7 s | – | 755 / 906 | 701 / 846 | 798 / 922 | – |
Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).
Hardware, protocol and caveats: [benchmarks](https://github.com/kleinicke/fastforks/blob/main/docs/benchmarks.md) (RTX 5060 Ti 16 GB, sm_120). Original = the original code named above at the precision of portable (fp16, or `(fp32)` where fp16 is unsupported or not finite); original fp32 = its default fp32 run. Peak memory is the torch allocator's.
## Accuracy
### On public datasets
TAP-Vid protocol: frames resized to 256 x 256 (PIL Lanczos) before the model (AllTracker: the original frames, resized by the model), one query per track at its first visible point, tracked online (TAPNext, Track-On) or over the whole clip (TAPIR, AllTracker, LocoTrack); AJ, delta_avg (< 1, 2, 4, 8, 16 px at 256 x 256) and occlusion accuracy averaged over the videos. Original = the original code named under Details, same checkpoint and protocol.
| variant | dataset | original fp32 | original fp16 | portable | kernels | note |
|---|---|---|---|---|---|---|
| `cotracker3-offline` | TAP-Vid DAVIS (query first), every 3rd video, AJ / delta_avg / OA % | 65.02 / 78.75 / 88.24 | 65.08 / 78.78 / 88.27 | 65.07 / 78.75 / 88.26 | 65.06 / 78.72 / 88.27 | |
| `cotracker3-online` | TAP-Vid DAVIS (query first), every 3rd video, AJ / delta_avg / OA % | 70.34 / 80.63 / 94.28 | 70.28 / 80.62 / 94.26 | 70.32 / 80.62 / 94.26 | 70.25 / 80.63 / 94.22 | |
Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks f104019b, 2026-11-14.
### Parity with the original code
Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 6e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0027 and p99 <= 0.014 (absolute error of the output `tracks`).
## Limitations
- Frames are resized to 384 x 512 (the training size and that of upstream's predictor), whatever their size and aspect ratio.
- cotracker3-offline holds the features of every frame (about 4 MB per frame in float16); cotracker3-online processes 16-frame windows and only keeps the tracks.
- Visibility is upstream's score, rescaled so that 0.5 is upstream's threshold: the offline predictor's visibility > 0.9, the online predictor's visibility x confidence > 0.6.
- One video per call; all queries of a call share the video.
## Usage
```python
from fastforks import tracking
# non-commercial weights: run with FASTFORKS_NONCOMMERCIAL=1 in the environment
model = tracking.load("cotracker3-offline") # mode="auto": the preferred backend from recorded measurements
result = model(frames, [[0, x, y]]) # frames: the video's images in order; queries (t, x, y)
result.tracks # [T, Q, 2] float32: x, y in input pixels; result.visible [T, Q] bool
result.backend # what ran, e.g. Backend(mode='portable', device='cuda:0', dtype='float16')
```
Install with `pip install fastforks` (see <https://github.com/kleinicke/fastforks>). Other variants: `cotracker3-offline`, `cotracker3-online`.
## Kernels backend
`tracking.load("cotracker3-offline", mode="kernels")` runs our CUDA kernels (`fvm_conv`). It needs a prebuilt kernel for your GPU architecture (downloaded from <https://huggingface.co/fastforks/kernels> on first use) and a recent NVIDIA driver; if there is none it raises `BackendUnavailableError` with the reason and never falls back silently. `mode="auto"` picks `kernels` when it can run and logs the choice.
<!-- staged from fastforks 1cbf1671 (2026-11-15) -->