Skip to main content

Unified Tracking in PyTorch

unitrack

unitrack is a PyTorch-native multi-object tracking library for researchers and ML engineers who want to assemble, not reimplement, a tracker. The library decomposes the SORT-family pipeline into typed primitives (stages, costs, gates, lifecycle policies, state recipes). Classical IoU+Kalman trackers, differentiable soft-assignment variants, and cascaded or parallel fusions all share the same scaffolding and run on a single Tracker core. Detections, tracklets, and frame context flow through the pipeline as structured TensorDict records, enabling multi-stream batching, clip-based inference, and torch.func.vmap compatibility without separate code paths.

Installation

  • python >= 3.13, < 3.14
  • torch >= 2.7
pip install unitrack

See docs/installation.md for the in-tree LAP solver extras and the development workflow.

Composable primitives

Each top-level subpackage covers one axis of the tracker:

  • unitrack.assignment — solvers for the linear assignment problem (Hungarian, Greedy, Auction, Jonker–Volgenant variants) plus soft companions for differentiable matching.
  • unitrack.costs — pairwise cost producers (cosine, L2, IoU family, Mahalanobis) and combinators (Reduce, Weighted, Sinkhorn).
  • unitrack.data — the typed records that flow through the pipeline: Detections, Tracklets, FrameContext, CostExpression, MatchOutcome, plus clip-shaped counterparts and the Gate algebra.
  • unitrack.gates — class, score, spatial, and motion gates that mask candidate pairs before cost computation.
  • unitrack.lifecycle — tracklet status policies (StandardLifecycle, ConfirmedOnly, NoLifecycle) and visibility filters.
  • unitrack.pipeline — the stage tree: Pipe, Sequential, Parallel, Gated, Filter, Iterate.
  • unitrack.states — per-feature state recipes (Identity, Replace, EMA) and the Kalman family (KalmanBBox, KalmanCentroid, KalmanUpdate).
  • unitrack.tracker — the top-level Tracker module and its wrappers: MultiStream, BatchTracker, ClipTracker, TrackletMemory.

Usage

This example tracks objects across a three-frame sequence using a distance cost and the Jonker–Volgenant solver.

import torch
import unitrack
from unitrack.assignment import Associate, Jonker
from unitrack.costs import CDist
from unitrack.data import Detections, FrameContext, TensorSpec
from unitrack.lifecycle import IncludeAll, NoLifecycle
from unitrack.pipeline import Pipe
from unitrack.states import FromDetectionField, Identity, Replace, State

tracker = unitrack.Tracker(
    root=Pipe(cost=CDist("position"), assoc=Associate(Jonker(threshold=10))),
    states={
        "position": State(
            schema=TensorSpec(shape=(1,), dtype=torch.float32),
            process=Identity("position"),
            observation=Replace("position"),
            init=FromDetectionField("position"),
        ),
    },
    lifecycle=NoLifecycle(),
    visibility=IncludeAll(),
)
ms = unitrack.MultiStream(tracker)

for frame in range(3):
    n = 1 + frame * 2
    pos = (torch.arange(n, dtype=torch.float32) + 1.0).unsqueeze(1)
    ds = Detections(
        index=torch.arange(n, dtype=torch.int64), position=pos, batch_size=[n]
    )
    res = ms.step(0, ds, FrameContext.make(frame, fps=15.0, stream_key=0))
    print(f"frame {frame}: ids={res.ids.tolist()}")

Recipes and tutorials

Ready-to-run tracker recipes in docs/2.recipes/ include a SORT port (IoU + Kalman bounding-box state) and a class-and-score-gated overlap tracker. The seven-notebook tour under docs/5.notebooks/tutorials/ covers the data model, cost and gate zoos, pipeline tree, state and lifecycle, and cascaded versus parallel fusion on synthetic data with known ground truth.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unitrack-2.0.1.tar.gz (409.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

unitrack-2.0.1-py3-none-any.whl (450.0 kB view details)

Uploaded Python 3

File details

Details for the file unitrack-2.0.1.tar.gz.

File metadata

  • Download URL: unitrack-2.0.1.tar.gz
  • Upload date:
  • Size: 409.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for unitrack-2.0.1.tar.gz
Algorithm Hash digest
SHA256 cc88aee5b9dfe54e09031d7e4554dfc82b95d6d0f718ca9f6d092728987a86ad
MD5 212e1dffb719eec03f3388080a061bb6
BLAKE2b-256 568536338cf55db44669e8a2613d96e92e6e69f24f8da9bfcb3e84a7d96c8aed

See more details on using hashes here.

Provenance

The following attestation bundles were made for unitrack-2.0.1.tar.gz:

Publisher: release.yml on tue-p8n/unitrack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file unitrack-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: unitrack-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 450.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for unitrack-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 926f660005580513471630c91c4aceccf9d019e4f7a74421563249b2598f7fd4
MD5 2875ba7198fdaaffeaef266aede85f46
BLAKE2b-256 87a31104c6e24bc35a2a0ffa28b8b7e753a5298c8e9139e7a27920deb6d78656

See more details on using hashes here.

Provenance

The following attestation bundles were made for unitrack-2.0.1-py3-none-any.whl:

Publisher: release.yml on tue-p8n/unitrack

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

2.0.1 This release

2 files

2.0.0

2 files

1.0.2

2 files

1.0.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page