tapir / README.md
Flor's picture
card: update from fastforks 1cbf1671
7cc46a8 verified
|
Raw History Blame Contribute Delete
7.63 kB
metadata
library_name: fastforks
pipeline_tag: keypoint-detection
license: apache-2.0
tags:
  - tracking
  - point-tracking
  - tracking-any-point
  - video
  - cuda
  - pytorch
  - fastforks
  - fastforks-card

TAPIR (fastforks)

TAPIR (Doersch, Yang, Vecerik et al., Google DeepMind 2023) and BootsTAPIR (Doersch et al. 2024, the same network trained further with BootsTAP self-training on unlabelled real videos): tracking any point offline over a whole video. A ResNet encodes every 256 x 256 frame; per frame, a cost volume against the query's features gives the initial position, visibility and uncertainty, then four PIPs-style refinements (local correlations, a depthwise-conv MLP mixer over the frames of each track) correct the whole track at once.

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/google-deepmind/tapnet at ceedd60bb9f6.

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.

variant weights (author link) SHA-256 weights licence commercial use
bootstapir@1 bootstapir_checkpoint_v2.pt 8493c7a69e02 Apache-2.0 yes
tapir@1 tapir_checkpoint_panning.pt 628611c656b3 Apache-2.0 yes

Licence

Original-code strings, recorded as they are (research-use package; check them before any other use). Code: Apache-2.0. Licence files: LICENSE.

Training data: Upstream: TAPIR is trained on synthetic Kubric MOVi-E sequences (the panning variant); BootsTAPIR is further trained with BootsTAP self-training on about 15 million unlabelled real video clips (not released). None has a dataset entry here yet..

Licence evidence: https://github.com/google-deepmind/tapnet/blob/ceedd60bb9f6c9f7c74796e4445aff6c6ddf7c9b/README.md#license-and-disclaimer

Input size

any H x W >= 32, padded to a multiple of 32 Tested up to (portable, fp16, RTX 5060 Ti 16 GB): bootstapir 3000x4000 (5.6 GiB peak allocated, 6.1 reserved); tapir 3000x4000 (5.5 GiB peak allocated, 6.0 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
bootstapir 243 234 192 1.3x 1.2x 639 / 774 508 / 628 508 / 628
tapir 187 182 141 1.3x 1.3x 498 / 574 463 / 548 463 / 548

Startup and first call

model load (s): original portable kernels first call (s): original portable kernels
bootstapir 0.60 0.32 1.14 0.90 0.80 0.66
tapir 0.35 0.19 1.13 0.83 0.84 0.69

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)
bootstapir 480x854 234 ms 183 ms 13.2 ms 192 ms 207 s 65.0 s 508 / 628 758 / 832 508 / 628 492 / 532
tapir 480x854 182 ms 131 ms 6.47 ms 141 ms 169 s 55.2 s 463 / 548 630 / 752 463 / 548 361 / 406

Fixed-size cells: time (ms) / peak allocated / peak reserved memory (MiB).

Hardware, protocol and caveats: benchmarks (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
bootstapir TAP-Vid DAVIS (query first), every 3rd video, AJ / delta_avg / OA % 65.49 / 76.75 / 92.56 65.53 / 76.72 / 92.55 65.56 / 76.78 / 92.44 65.51 / 76.72 / 92.51
bootstapir TAP-Vid DAVIS (query first), AJ / delta_avg / OA % 62.27 / 74.62 / 89.67 62.29 / 74.61 / 89.66 62.27 / 74.61 / 89.64
tapir TAP-Vid DAVIS (query first), every 3rd video, AJ / delta_avg / OA % 62.63 / 74.54 / 90.14 62.62 / 74.60 / 90.18 62.74 / 74.59 / 90.11 62.73 / 74.55 / 90.21

Measured on NVIDIA GeForce RTX 5060 Ti, torch 2.14.1+cu130, fastforks 8d5bccf, 2026-11-12 to 2026-11-13.

Parity with the original code

Every variant is checked against reference outputs of the original code at its pinned commit. CPU, float32: max |diff| <= 3.5e-05 vs the original. GPU, float16 (the default), portable and kernels: mean |diff| <= 0.0079 and p99 <= 0.028 (absolute error of the output tracks).

Limitations

  • Offline: the whole video is encoded before tracking (features of every frame in memory, about 3 MB per frame); for live video use an online tracker (TAPNext).
  • Frames are resized to 256 x 256 (the training size and that of upstream's TAP-Vid numbers), whatever their size and aspect ratio. Upstream's higher-resolution refinement (best at 512 x 512 for BootsTAPIR) is not ported.
  • One video per call; all queries of a call share the video.

Usage

from fastforks import tracking

model = tracking.load("bootstapir")  # 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: bootstapir, tapir.

Kernels backend

tracking.load("bootstapir", 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.