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/recipes/ include a SORT port (IoU + Kalman bounding-box state) and a class-and-score-gated overlap tracker. The six-notebook tour under 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.0.tar.gz (409.0 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.0-py3-none-any.whl (449.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unitrack-2.0.0.tar.gz
  • Upload date:
  • Size: 409.0 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.0.tar.gz
Algorithm Hash digest
SHA256 adc69dc534c55df5596afe51392414d926bc1902c7473f28f28c6a84741f9714
MD5 cb14fc5ca88c92ab20ced02a5a2f1939
BLAKE2b-256 c1e57dfdbbeba4e31a99c94bd0a5bcdc7243e92666cfbe15423a9d2fa95b177e

See more details on using hashes here.

Provenance

The following attestation bundles were made for unitrack-2.0.0.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.0-py3-none-any.whl.

File metadata

  • Download URL: unitrack-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 449.8 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ccb529bb7b0cb67ee300ba9ed0d72f1df29779d93816dfb83d305255a148c42
MD5 f6ddda88b412db39f800c0e22872c747
BLAKE2b-256 e35783e907fb48e4ad15c78b7e367e835312e5da518b1b42ca422a4393f7444c

See more details on using hashes here.

Provenance

The following attestation bundles were made for unitrack-2.0.0-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

2.0.1

2 files

This release

2.0.0 This release

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