trackflow-python-tensorrt 0.7.0__cp310-abi3-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,421 @@
1
+ Metadata-Version: 2.4
2
+ Name: trackflow-python-tensorrt
3
+ Version: 0.7.0
4
+ Classifier: Development Status :: 3 - Alpha
5
+ Classifier: Environment :: Console
6
+ Classifier: Intended Audience :: Developers
7
+ Classifier: Intended Audience :: Science/Research
8
+ Classifier: License :: OSI Approved :: Apache Software License
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3.10
12
+ Classifier: Programming Language :: Python :: 3.11
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Topic :: Multimedia :: Video
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
18
+ Requires-Dist: huggingface-hub>=0.24
19
+ Requires-Dist: numpy>=1.26
20
+ Requires-Dist: onnxruntime-gpu[cuda,cudnn]>=1.28
21
+ Requires-Dist: tensorrt-cu13-libs>=10,<11
22
+ Requires-Dist: opencv-python-headless>=4.9
23
+ Requires-Dist: pyarrow>=15.0
24
+ Requires-Dist: rich>=13.7
25
+ Requires-Dist: scipy>=1.11
26
+ Requires-Dist: tokenizers>=0.19
27
+ Requires-Dist: typer>=0.12
28
+ Requires-Dist: pytest>=8.0 ; extra == 'dev'
29
+ Requires-Dist: ruff>=0.6 ; extra == 'dev'
30
+ Requires-Dist: opencv-python>=4.9 ; extra == 'display'
31
+ Requires-Dist: mkdocs-material>=9.6 ; extra == 'docs'
32
+ Requires-Dist: mkdocstrings[python]>=0.29 ; extra == 'docs'
33
+ Requires-Dist: transformers>=5.18,<6 ; extra == 'sam2'
34
+ Requires-Dist: torch>=2.6 ; extra == 'sam2'
35
+ Requires-Dist: torchvision>=0.21 ; extra == 'sam2'
36
+ Requires-Dist: transformers>=5.18,<6 ; extra == 'transformers'
37
+ Requires-Dist: torch>=2.6 ; extra == 'transformers'
38
+ Requires-Dist: torchvision>=0.21 ; extra == 'transformers'
39
+ Requires-Dist: sentence-transformers>=6.1,<7 ; extra == 'transformers'
40
+ Provides-Extra: dev
41
+ Provides-Extra: display
42
+ Provides-Extra: docs
43
+ Provides-Extra: sam2
44
+ Provides-Extra: transformers
45
+ License-File: LICENSE
46
+ Summary: Stream or export multi-object tracks with ONNX and optional Transformers detectors, ByteTrack, BoT-SORT, OC-SORT or BoostTrack, text search, floorplan projection, and anonymization. (NVIDIA TensorRT FP16 build with bundled CUDA 13/cuDNN/TensorRT 10 runtimes.)
47
+ Keywords: object-tracking,people-tracking,multi-object-tracking,mot,bytetrack,botsort,ocsort,boosttrack,rtdetr,rf-detr,d-fine,onnxruntime,computer-vision,video-tracking,re-identification,homography,parquet,webgpu,clip,siglip
48
+ Author: Ouail Bendidi
49
+ License-Expression: Apache-2.0
50
+ Requires-Python: >=3.11
51
+ Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
52
+ Project-URL: Documentation, https://obendidi.github.io/trackflow/docs/
53
+ Project-URL: Homepage, https://obendidi.github.io/trackflow/
54
+ Project-URL: Issues, https://github.com/obendidi/trackflow/issues
55
+ Project-URL: Repository, https://github.com/obendidi/trackflow
56
+
57
+ # Trackflow
58
+
59
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/obendidi/trackflow/blob/main/LICENSE)
60
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB.svg)](https://pypi.org/project/trackflow-python/)
61
+
62
+ Real-time people and object tracking in Python and in the browser. Trackflow runs current detectors (RF-DETR, RT-DETRv2, D-FINE, DEIMv2, YOLO26) with ByteTrack, BoT-SORT, OC-SORT, BoostTrack or NLTrack, streams or exports track data (Parquet, JSONL, CSV, MOTChallenge, HTML), and includes text-based track search, a local run inspector with 4-point floorplan projection, and anonymization.
63
+
64
+ ![Trackflow tracking people crossing Yonge and Dundas in Toronto, with an ID, box and trail on each person](https://raw.githubusercontent.com/obendidi/trackflow/main/docs/demo.webp)
65
+
66
+ *`trackflow run crossing.mp4` with the default settings, at 12 FPS on an Apple M4 Pro CPU. Footage: 8 seconds of [DiagonalCrosswalkYongeDundas.webm](https://commons.wikimedia.org/wiki/File:DiagonalCrosswalkYongeDundas.webm) by Raysonho, CC0.*
67
+
68
+ ![Trackflow Inspector showing live video playback, recovery jumps, two natural-language track searches ("person in white shirt" and "woman in pink shirt"), and ByteTrack vs BoT-SORT comparison](https://raw.githubusercontent.com/obendidi/trackflow/main/docs/inspect-demo.webp)
69
+
70
+ *`trackflow inspect` on the same clip: scrubbing with live video frames, jumping to recovery events, searching Track Cards with natural language, and comparing ByteTrack against BoT-SORT.*
71
+
72
+ Try it in the browser without installing anything: [obendidi.github.io/trackflow](https://obendidi.github.io/trackflow/) · Full docs & API reference: [obendidi.github.io/trackflow/docs](https://obendidi.github.io/trackflow/docs/).
73
+
74
+ ## Quickstart
75
+
76
+ One command for your hardware — no system CUDA Toolkit, cuDNN, or TensorRT setup required:
77
+
78
+ | Environment | Zero-install (`uvx`) | Installed (`pip`) | Notes |
79
+ | :--- | :--- | :--- | :--- |
80
+ | **CPU / macOS** *(default)* | `uvx trackflow-python run street.mp4` | `pip install trackflow-python` | Auto-pins Apple Silicon to P-cores (~14 FPS on M4 Pro CPU) |
81
+ | **macOS GPU (CoreML)** | `uvx trackflow-python run street.mp4 --device coreml` | `pip install trackflow-python` | Runs detector + static-batch OSNet Re-ID on Apple GPU |
82
+ | **NVIDIA CUDA** | `uvx trackflow-python-cuda run street.mp4` | `pip install trackflow-python-cuda` | Bundles CUDA + cuDNN; auto-selects CUDA (~37–105 FPS on T4) |
83
+ | **NVIDIA TensorRT** *(Py 3.11+)* | `uvx trackflow-python-tensorrt run street.mp4` | `pip install trackflow-python-tensorrt` | Bundles CUDA 13 + TensorRT 10 FP16; cached engines (~94–136 FPS on T4) |
84
+
85
+ Or run via Docker with zero Python setup (`--target cpu`, `cuda`, or `tensorrt` in [Dockerfile](Dockerfile)):
86
+
87
+ ```bash
88
+ docker build --target tensorrt -t trackflow:tensorrt .
89
+ docker run --rm --gpus all -v "$PWD:/work" \
90
+ -v "$HOME/.cache/huggingface:/root/.cache/huggingface" \
91
+ -v "$HOME/.cache/trackflow:/root/.cache/trackflow" \
92
+ trackflow:tensorrt run /work/street.mp4
93
+ ```
94
+
95
+ After a run finishes, open the local visual inspector:
96
+
97
+ ```bash
98
+ trackflow inspect # opens the most recent run
99
+ trackflow info # checks GPU, execution providers, and recommended command
100
+ ```
101
+
102
+ Each run writes to a new folder (`runs/run-1`, `runs/run-2`, …). Pass `-o <dir>` to choose one yourself; it must be empty, so a new run never mixes with files from an old one.
103
+
104
+ Model weights download from Hugging Face on first run and are cached locally. Every preset is pinned to a specific model revision, so the same command gives the same weights later. ONNX Runtime picks CUDA or CPU automatically; `--device cpu|cuda|coreml|tensorrt` forces one and fails loudly with the exact install command if the matching runtime isn't present. TensorRT builds and caches its engine once per model under `~/.cache/trackflow/trt_cache/` (subsequent runs load in <1s) and automatically keeps `rfdetr-*` in FP32 so DINOv2 activations don't overflow. *Never keep both `onnxruntime` and `onnxruntime-gpu` in the same environment—they share the `onnxruntime` import path and silently break GPU providers.*
105
+
106
+ <details>
107
+ <summary>Verified NVIDIA T4 GPU throughput & parity (CUDA FP32 vs TensorRT 10 FP16)</summary>
108
+
109
+ Measured on an isolated venv (system CUDA/TRT paths stripped, proving zero-config pip library preloading) on an NVIDIA Tesla T4 (`vtest.avi`, 5-frame box IoU parity vs CPU + 40-frame steady-state timing):
110
+
111
+ | Model | CUDA FP32 | TensorRT FP16 *(warm)* | Speedup vs CUDA | Mean IoU vs CPU | Cold build → Warm load |
112
+ | :--- | ---: | ---: | ---: | ---: | :--- |
113
+ | `rtdetr-v2-r18` *(default)* | 26.4 ms (37.9 FPS) | **8.95 ms (111.7 FPS)** | **3.0x** | 0.988 (`37/37`) | 205 s → **0.95 s** |
114
+ | `dfine-s` | 21.5 ms (46.5 FPS) | **8.21 ms (121.8 FPS)** | **2.6x** | 0.980 (`54/53`) | 262 s → **0.68 s** |
115
+ | `dfine-m` | 33.7 ms (29.6 FPS) | **10.65 ms (93.9 FPS)** | **3.2x** | 0.984 (`42/42`) | 247 s → **1.32 s** |
116
+ | `yolo26n` *(AGPL)* | 11.5 ms (86.8 FPS) | **7.37 ms (135.6 FPS)** | **1.6x** | 0.985 (`26/26`) | 261 s → **0.16 s** |
117
+ | `rfdetr-nano` | **18.1 ms (55.4 FPS)** | FP32 (`trt_fp16=False`) | — | 1.000 (`30/30`) | Kept in FP32 (FP16 overflows DINOv2) |
118
+ | `rfdetr-medium` | **40.5 ms (24.7 FPS)** | FP32 (`trt_fp16=False`) | — | 1.000 (`31/31`) | Kept in FP32 (FP16 overflows DINOv2) |
119
+ | `osnet` Re-ID *(8 crops)* | 19.2 ms | **10.5 ms** *(static B=8)* | **1.8x** | 1.000 cos (`0.99996`) | 0.15 s load |
120
+
121
+ </details>
122
+
123
+ <details>
124
+ <summary>Native Rust core &amp; version speed comparison (bundled by default in CPU, CUDA, and TensorRT wheels)</summary>
125
+
126
+ All three packages (`trackflow-python`, `trackflow-python-cuda`, and `trackflow-python-tensorrt`) bundle the compiled `trackflow._native` Rust extension (`abi3-py310`, zero extra packages or flags required). Cutting host-side preprocessing, DETR postprocessing, Re-ID crop batching, and multi-object tracking from `~6–10 ms/frame` down to `<1–2 ms/frame` keeps the CPU out of the way on CPU/CoreML runs and removes the host bottleneck on high-FPS CUDA and TensorRT GPUs. Set `TRACKFLOW_BACKEND=python` to force the pure-Python reference path, or check the active backend with `trackflow info`.
127
+
128
+ Measured interleaved on Apple M4 Pro (`OMP_NUM_THREADS=4`, 1080p inputs & 1,203 crowded `MOT20-03` frames, no-CMC pure engine time, `0` ID diffs across all 5 trackers):
129
+
130
+ | Component / Tracker | `v0.6.1` *(NumPy/SciPy)* | Pure-Python + OpenCV (`#148`) | **Rust default (`_native`)** | Speedup vs `v0.6.1` | Parity |
131
+ | :--- | ---: | ---: | ---: | ---: | :--- |
132
+ | `detector.preprocess` (`norm=False`, 1080p) | `0.888 ms/f` | `0.414 ms/f` | **`0.308 ms/f`** | **2.9x** | `0.0` diff |
133
+ | `detector.preprocess` (`norm=True`, 1080p) | `3.425 ms/f` | `0.479 ms/f` | **`0.304 ms/f`** | **11.3x** | `4.77e-7` |
134
+ | `ReidEmbedder` crop prep *(16 crops)* | `4.183 ms/f` | `0.960 ms/f` | **`0.587 ms/f`** | **7.1x** | `0.0` diff |
135
+ | `postprocess_detr_outputs` *(300×80)* | `0.197 ms/f` | `0.167 ms/f` | **`0.040 ms/f`** | **4.9x** | `0.0` box diff |
136
+ | `bytetrack` *(MOT20-03, 1,203f)* | `0.911 ms/f` | `0.878 ms/f` | **`0.079 ms/f`** *(12,671 FPS)* | **11.5x** | `0` ID diffs |
137
+ | `botsort` *(MOT20-03, 1,203f)* | `0.872 ms/f` | `0.841 ms/f` | **`0.092 ms/f`** *(10,906 FPS)* | **9.5x** | `0` ID diffs |
138
+ | `botsort + osnet` *(MOT20-03, 1,203f)* | `1.204 ms/f` | `1.201 ms/f` | **`0.151 ms/f`** *(6,626 FPS)* | **8.0x** | `0` ID diffs |
139
+ | `ocsort` *(MOT20-03, 1,203f)* | `0.949 ms/f` | `0.916 ms/f` | **`0.058 ms/f`** *(17,174 FPS)* | **16.3x** | `0` ID diffs |
140
+ | `boosttrack` *(MOT20-03, 1,203f)* | `1.280 ms/f` | `1.218 ms/f` | **`0.093 ms/f`** *(10,750 FPS)* | **13.8x** | `0` ID diffs |
141
+ | `boosttrack + osnet` *(MOT20-03, 1,203f)* | `1.608 ms/f` | `1.466 ms/f` | **`0.181 ms/f`** *(5,529 FPS)* | **8.9x** | `0` ID diffs |
142
+ | `nltrack` *(MOT20-03, 1,203f)* | — | `1.579 ms/f` | **`0.137 ms/f`** *(7,301 FPS)* | **11.5x** *(vs `#148`)* | `0` ID diffs |
143
+ | `nltrack + osnet` *(MOT20-03, 1,203f)* | — | `2.277 ms/f` | **`0.962 ms/f`** *(1,039 FPS)* | **2.4x** *(vs `#148`)* | `0` ID diffs |
144
+ | `postprocess_records` *(68.9k rows)* | — | `982.3 ms` | **`885.8 ms`** | **1.11x** *(vs `#148`)* | bit-exact |
145
+
146
+ Reproduce Python vs. Rust timings on your own CPU/CUDA/TensorRT machine with `uv run python scripts/bench_rust_vs_python.py`.
147
+
148
+ </details>
149
+
150
+ ## Usage
151
+
152
+ ### Tracking and exports
153
+
154
+ ```bash
155
+ trackflow run crowd.mp4 \
156
+ --model rfdetr-medium \
157
+ --tracker botsort --reid osnet \
158
+ --classes person,backpack \
159
+ --export parquet,jsonl,csv,mot,html
160
+ ```
161
+
162
+ The source can be a video file, a folder of images (read in natural order, `frame_2` before `frame_10`; set the rate with `--fps`), an RTSP/HTTP stream URL, or a camera index. Press Ctrl-C to stop a run: Trackflow stops reading frames and still writes every output, including the track cards that `trackflow search` and `trackflow inspect` read. A second Ctrl-C aborts without writing them.
163
+
164
+ The Parquet export can be queried directly with DuckDB:
165
+
166
+ ```sql
167
+ SELECT track_id, COUNT(*) AS frames, AVG(confidence) AS avg_conf
168
+ FROM 'runs/run-1/tracks.parquet'
169
+ GROUP BY track_id ORDER BY frames DESC;
170
+ ```
171
+
172
+ `--export mot` writes `tracks.txt` in MOTChallenge format, which [TrackEval](https://github.com/JonathonLuiten/TrackEval) scores directly (HOTA, IDF1, MOTA).
173
+
174
+ ### Trackers
175
+
176
+ | `--tracker` | Algorithm | How it works |
177
+ | :--- | :--- | :--- |
178
+ | `bytetrack` *(default)* | [ByteTrack](https://arxiv.org/abs/2110.06864) (ECCV 2022) | Matches boxes by overlap, then uses low-confidence detections to keep tracks through partial occlusion. The fastest option. |
179
+ | `botsort` | [BoT-SORT](https://arxiv.org/abs/2206.14651) (2022) | ByteTrack plus camera-motion compensation, and appearance matching with `--reid osnet`. |
180
+ | `ocsort` | [OC-SORT](https://arxiv.org/abs/2203.14360) (CVPR 2023) | Trusts detections over motion predictions: after an occlusion it re-matches a track to its last observed box and corrects the motion model along the gap. |
181
+ | `boosttrack` | [BoostTrack++](https://arxiv.org/abs/2408.13003) (2024) | Raises the confidence of weak detections that fit a track or look like a new object, and matches with motion, shape and, with `--reid osnet`, appearance. Compensates for camera motion. |
182
+ | `nltrack` | NLTrack *(pure Apache-2.0, zero extra weights)* | Non-linear motion tracker with damped dual-anchor prediction, observation-centric re-update, scene-calibrated clean-bank Re-ID (`--reid osnet`), and guarded lost-track recovery. Highest accuracy across all four benchmarks. |
183
+
184
+ All five keep a person and a bag in the same box as separate tracks, and only give out an ID once a track has been seen on more than one frame. OC-SORT and BoostTrack report a track again after a miss once it has matched three frames in a row; in between, the annotated video shows it as a coasting box. The browser playground uses ByteTrack.
185
+
186
+ #### Benchmarks across 4 official datasets (81 videos, ~59,800 frames)
187
+
188
+ ![Trackflow vs. Roboflow trackers speed and quality Pareto frontier and per-benchmark academic SOTA context](https://raw.githubusercontent.com/obendidi/trackflow/main/docs/benchmarks-trackers.png)
189
+
190
+ Every tracker below receives the exact same detections from Trackflow's default Apache-2.0 detector (`rtdetr-v2-r18`, confidence threshold `0.45`, Apple M4 Pro) so the comparison isolates the tracking algorithm.
191
+
192
+ | Tracker | DanceTrack (25) | SportsMOT (45) | MOT17 (7) | MOT20 (4) | Mean HOTA | Total ID switches | Tracker FPS | End-to-End FPS |
193
+ | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
194
+ | **`nltrack --reid osnet --postprocess`** *(offline)* | **47.5** | **52.5** | **50.8** | **27.9** | **44.7** | **4,294** | 131 | 5.4\* |
195
+ | **`nltrack --reid osnet`** | 47.1 | 50.2 | 48.1 | 26.1 | **42.9** | 5,193 | 133 | 5.4 |
196
+ | **`botsort --reid osnet --postprocess`** *(offline)* | 42.4 | 50.3 | 49.7 | 25.7 | **42.0** | 4,748 | 198 | 5.5\* |
197
+ | **`nltrack`** *(no Re-ID)* | 39.0 | 45.6 | 47.3 | 26.3 | **39.6** | 6,209 | 143 | 9.0 |
198
+ | **`botsort --reid osnet`** | 39.0 | 45.0 | 46.9 | 24.4 | 38.8 | 6,435 | 205 | 5.5 |
199
+ | **`ocsort`** *(no Re-ID)* | 37.9 | 46.0 | 46.3 | 23.3 | 38.4 | 5,501 | 203 | 9.2 |
200
+ | **`boosttrack`** *(no Re-ID)* | 37.5 | 44.4 | 46.9 | 24.0 | 38.2 | 5,549 | 201 | 9.2 |
201
+ | **`botsort`** *(no Re-ID)* | 36.7 | 44.3 | 46.5 | 24.3 | 37.9 | 6,475 | 221 | 9.3 |
202
+ | `bytetrack` *(also in browser)* | 33.1 | 39.8 | 45.1 | 23.5 | 35.4 | 7,038 | **2,900** | **9.7** |
203
+ | *Roboflow `cbiou` (`0.45/0.50`)* | 36.0 | 43.4 | 46.4 | 24.2 | 37.5 | 7,533 | 2,072 | 9.6 |
204
+ | *Roboflow `botsort` (`0.45/0.50`)* | 35.9 | 43.6 | 46.3 | 24.0 | 37.4 | 6,922 | 194 | 9.2 |
205
+ | *Roboflow `ocsort+cmc` (`0.45`)* | 33.4 | 43.8 | 44.2 | 15.9 | 34.3 | 8,057 | 196 | 9.2 |
206
+ | *Roboflow `botsort` (defaults `0.60/0.70`)* | 39.6 | 50.0 | 42.6 | 13.6 | 36.4 | 4,349 | 207 | 9.2 |
207
+
208
+ #### Offline post-processing (`--postprocess`)
209
+
210
+ ```bash
211
+ trackflow run game.mp4 --tracker botsort --reid osnet --postprocess
212
+ ```
213
+
214
+ For recorded video files and image folders, `--postprocess` runs a pure NumPy/SciPy pass after tracking finishes: it splits high-confidence mid-track swaps, stitches broken tracklets globally with camera-motion-compensated kinematics and sequence-calibrated OSNet similarity, fills short supported occlusion gaps, and smooths box jitter on steady tracks. Across all 81 validation videos, it improves every dataset and tracker (`+3.2` mean HOTA and `-1,687` ID switches vs the online table row on `botsort --reid osnet`; `+0.7` to `+1.1` without Re-ID) in `~64–265 ms/video` (max `397 ms`). It is opt-in, rejects live camera/RTSP streams, buffers track records and float16 Re-ID embeddings in memory (`~1 KB/observation` when `--reid osnet` is active — split multi-hour crowded clips or omit `--reid` if RAM is tight), and leaves `stream()` and browser ByteTrack untouched. \*Table End-to-End FPS (`5.5`) measures detection + tracking + postprocess (`--no-video`); saving `annotated.mp4` adds a second decode/render pass. Benchmarks used `frame_stride=1` on 14–30 fps footage; time horizons are expressed in seconds and frame stride. Combine with `--reid-merge` to also link long cross-exit re-entries in the same offline pass.
215
+
216
+ **How to read this chart and table:**
217
+ - **HOTA (0–100, higher is better)**: Overall tracking accuracy. It combines two halves equally: finding the right people in each frame and keeping the same ID on each person as they move and cross paths.
218
+ - **ID switches (lower is better)**: How many times a tracker accidentally swaps or resets a person's ID mid-video.
219
+ - **Tracker FPS vs. End-to-End FPS**: Tracker FPS is the matching step alone; End-to-End FPS includes running the object detector (and person Re-ID crops when enabled) on every frame on a laptop.
220
+ - **The 4 benchmarks**: **DanceTrack** (25 videos of dancers wearing identical outfits—tests motion tracking when appearance doesn't help), **SportsMOT** (45 fast-moving basketball, football, and volleyball clips with panning cameras), **MOT17** (7 busy street scenes), and **MOT20** (4 dense pedestrian crowds, second halves).
221
+ - **Why academic SOTA is higher (~66–77 HOTA)**: Leaderboard papers train a specialist detector (usually YOLOX-X) directly on each benchmark—so it learns, for example, to ignore spectators in SportsMOT stands—and often fill gaps offline after the video ends. Trackflow runs one off-the-shelf, general-purpose Apache-2.0 COCO detector live, frame by frame. On SportsMOT, Roboflow's high default threshold (`0.60/0.70`) similarly filters out blurry spectators (`50.0` HOTA), at the cost of dropping occluded pedestrians on MOT17 (`42.6`) and MOT20 (`13.6`). Pass `--threshold 0.6` in Trackflow on sports broadcasts if you want the same crowd filtering.
222
+
223
+ [`scripts/eval_benchmarks.py`](https://github.com/obendidi/trackflow/blob/main/scripts/eval_benchmarks.py) reproduces all four datasets and the Roboflow `trackers==2.7.0` controls (scored with `trackers eval`, which matches TrackEval). Scenes vary widely, so test on footage like yours with `trackflow compare` or `--export mot`.
224
+
225
+ ### Text search and re-identification
226
+
227
+ ```bash
228
+ # Highlight matching people live (uses CLIP by default; --vlm embeddinggemma for clothing and accessories)
229
+ trackflow run mall.mp4 --query "person in red jacket with a backpack"
230
+
231
+ # Search a completed run later without re-running detection
232
+ # (requires a run created with --query or --vlm clip|siglip|siglip2|embeddinggemma)
233
+ trackflow search runs/run-1 "person carrying a suitcase"
234
+
235
+ # Export top search hits as time windows + normalized boxes for SAM 3 or a VLM
236
+ trackflow search runs/run-1 "person in red jacket" --top-k 5 --pad-s 1.0 --export-prompts prompts.json
237
+
238
+ # Give people who leave and come back their earlier ID (opt-in, uses person Re-ID)
239
+ trackflow run mall.mp4 --reid osnet --reid-merge
240
+ ```
241
+
242
+ ![Natural-language track search quality vs. speed across 23,287 labeled pedestrian crops](https://raw.githubusercontent.com/obendidi/trackflow/main/docs/benchmarks-search.png)
243
+
244
+ Tested across all **23,287 labeled pedestrian crops** in the PA-100K (10,000 crops, 18 clothing/accessory queries) and UPAR (13,287 crops, 20 color/attribute queries) validation sets, measured with **mAP** (Mean Average Precision, 0–1: how accurately matching people rank at the top of search results) via [`scripts/eval_text_search.py`](https://github.com/obendidi/trackflow/blob/main/scripts/eval_text_search.py):
245
+
246
+ - **`--vlm embeddinggemma`** *(PyTorch, needs `pip install "trackflow-python[transformers]"`)*: highest accuracy (**0.507** PA-100K / **0.561** UPAR mAP, ~10 crops/s on M4 Pro MPS).
247
+ - **`--vlm siglip2`** *(pure ONNX INT8, zero PyTorch)*: best lightweight choice (**0.442** PA-100K / **0.488** UPAR mAP at ~45 crops/s on CPU—both faster and more accurate than SigLIP 1 at `0.420 / 0.459` and ~28 crops/s).
248
+ - **`--vlm clip`** *(default, pure ONNX INT8)*: fastest option (**146 crops/s** on CPU, `0.288 / 0.357` mAP).
249
+
250
+ CLIP, SigLIP, SigLIP 2 and EmbeddingGemma 2 match images to *text*; they cannot reliably distinguish two people in similar clothes, so they are never used for identity. `--reid osnet` runs a dedicated person re-identification model. Re-entry merging only considers people who left before the new track appeared and stayed gone longer than the tracker's own recovery window, and merges only when one earlier person is clearly the best match; look-alikes stay separate. It can still make mistakes on low-resolution footage, which is why it is off by default.
251
+
252
+ ### Inspector, tracker comparison, and floorplan projection
253
+
254
+ ```bash
255
+ # Compare ByteTrack and BoT-SORT on the same video and open the inspector
256
+ trackflow compare crowd.mp4 --trackers bytetrack,botsort --inspect
257
+
258
+ # Open the inspector on any existing run
259
+ trackflow inspect runs/run-1
260
+ ```
261
+
262
+ `trackflow inspect` starts a local web UI where you can scrub through frames, jump to flagged ID switches or recoveries, search track cards, compare two runs, and click 4 ground corners to project 2D tracks onto a top-down floorplan.
263
+
264
+ ### Line counting
265
+
266
+ ```bash
267
+ # Count people crossing a doorway, in each direction
268
+ trackflow run entrance.mp4 --line "door=640,300,640,720"
269
+ ```
270
+
271
+ `--line` takes a line segment in image pixels as `name=x1,y1,x2,y2` (the name is optional) and can be repeated. A track crosses when the bottom center of its box moves from one side of the segment to the other and stays there for 0.3 seconds, so a box edge that jumps back and forth when people overlap doesn't count each jump. A crossing to the right of the direction from the first point to the second counts as `in`, the other way as `out`. For a line drawn left to right, `in` means moving down the frame, and the annotated video shows an arrow on the `in` side. Every crossing counts, so someone who steps back over the line adds one in each direction. Put the line where people's feet stay in view: when someone closer to the camera hides a person's legs, that person's box ends higher, and a line just above their feet can count a crossing that didn't happen.
272
+
273
+ The totals go to the run summary, `summary.json` (`line_counts`) and the HTML report. Each crossing is also a `line_crossed` event in `events.json`, with the track ID, class and direction. In Python, pass `lines=[CountingLine("door", (640, 300), (640, 720))]` to `TrackflowPipeline`; `stream()` reports crossings in each frame's `events`.
274
+
275
+ ### Anonymization
276
+
277
+ ```bash
278
+ # Blur the top of each person box, where the head usually is
279
+ trackflow run lobby.mp4 --anonymize face-blur
280
+
281
+ # Draw stick figures on a blank canvas (box-based, no pose model; no video pixels saved)
282
+ trackflow run lobby.mp4 --anonymize skeleton
283
+ ```
284
+
285
+ Available modes are `face-blur`, `blur`, `pixelate`, and `skeleton`. Anonymization covers every detected person box (including low-confidence detections and people briefly missed by the tracker), even when you track other classes, and anonymized runs do not write person crops or thumbnails. It is best effort: if the detector misses someone in a frame, that person is not blurred in that frame.
286
+
287
+ `face-blur` runs no face detector. It blurs an ellipse over the top 30% of each person box, so it misses a face that isn't there, for example on someone lying down, bending over or holding their arms up. Use `blur` or `pixelate` to cover the whole person.
288
+
289
+ ### Benchmarking
290
+
291
+ ```bash
292
+ trackflow benchmark crowd.mp4 --models rfdetr-nano,rtdetr-v2-r18 --trackers bytetrack,botsort --split-screen
293
+ ```
294
+
295
+ Runs the selected detector/tracker pairs on a video (or a generated synthetic clip if no video is given) and writes a Markdown and JSON report. `--split-screen` also renders the first run's annotated video next to a panel with the 2017 version's published speed. The 2017 README only gives that number, not per-frame results to replay.
296
+
297
+ FPS and track counts don't tell you whether IDs are right. For accuracy, run on a labeled sequence with `--export mot` and score the result with TrackEval.
298
+
299
+ ## Models
300
+
301
+ Weights download automatically from Hugging Face on first use. `trackflow models` lists every preset (`--json` for scripts).
302
+
303
+ | Preset | Model | Size (FP32) | License | Notes |
304
+ | :--- | :--- | ---: | :--- | :--- |
305
+ | `rtdetr-v2-r18` *(default)* | RT-DETRv2 ResNet-18 (640×640) | ~81 MB | Apache-2.0 | Balanced default for crowded scenes |
306
+ | `rfdetr-nano` | RF-DETR Nano (384×384) | ~108 MB | Apache-2.0 | Fast on Apple Silicon and WebGPU |
307
+ | `rfdetr-small` | RF-DETR Small (512×512) | ~115 MB | Apache-2.0 | |
308
+ | `rfdetr-medium` | RF-DETR Medium (576×576) | ~121 MB | Apache-2.0 | |
309
+ | `rfdetr-base` | RF-DETR Base (560×560) | ~108 MB | Apache-2.0 | |
310
+ | `rfdetr-large` | RF-DETR Large (704×704) | ~136 MB | Apache-2.0 | Most accurate preset; needs the `transformers` extra |
311
+ | `dfine-n` | D-FINE Nano (640×640) | ~15 MB | Apache-2.0 | Small download |
312
+ | `dfine-s` | D-FINE Small (640×640) | ~42 MB | Apache-2.0 | Compact COCO-only ONNX |
313
+ | `dfine-m` | D-FINE Medium (640×640) | ~79 MB | Apache-2.0 | Highest Apache-2.0 ONNX MOT17 HOTA |
314
+ | `yolo26n` … `yolo26x` | YOLO26 Nano to XLarge (640×640) | 10–223 MB | **AGPL-3.0** | Commercial use needs an Ultralytics license |
315
+ | `deimv2-atto` | DEIMv2 Atto (320×320) | ~2 MB | **Non-commercial** | Tiny edge model, FP32 only |
316
+ | `deimv2-s` | DEIMv2 Small, DINOv3 backbone (640×640) | ~41 MB | **Non-commercial** + DINOv3 | FP32 only |
317
+
318
+ Most presets also have `--precision fp16` and `int8` variants. Trackflow itself is Apache-2.0, but each model's weights carry their own license, so check the table before shipping a product. With ByteTrack on the MOT17 split used for the [tracker scores](#trackers):
319
+
320
+ | Preset | HOTA | IDF1 | MOTA |
321
+ | :--- | ---: | ---: | ---: |
322
+ | `dfine-m` | 46.5 | 55.1 | 39.2 |
323
+ | `rtdetr-v2-r18` *(default)* | 45.1 | 53.9 | 39.8 |
324
+ | `rfdetr-large` | 44.3 | 51.1 | 35.9 |
325
+ | `rfdetr-medium` | 42.9 | 49.7 | 34.8 |
326
+ | `yolo26n` | 37.4 | 41.4 | 27.9 |
327
+ | `rfdetr-nano` | 36.5 | 40.5 | 28.2 |
328
+
329
+ `dfine-m` scores highest here (`46.5` HOTA with ByteTrack, `46.9` with BoT-SORT) while `rtdetr-v2-r18` remains the faster default (`10.0` vs `7.3` FPS on M4 Pro CoreML). Test on footage like yours before switching.
330
+
331
+ You aren't limited to presets. `-m` also takes any compatible ONNX repo on Hugging Face (`owner/repo`), a local `.onnx` file, or, with the extra installed, any Transformers object-detection checkpoint as `hf:owner/repo`:
332
+
333
+ ```bash
334
+ pip install "trackflow-python[transformers]"
335
+ trackflow run crowd.mp4 -m rfdetr-large
336
+ trackflow run crowd.mp4 -m hf:PekingU/rtdetr_v2_r50vd --device mps
337
+ ```
338
+
339
+ Re-ID, text-search, and optional mask fallback models:
340
+
341
+ | Flag | Model | Size | License | Used for |
342
+ | :--- | :--- | ---: | :--- | :--- |
343
+ | `--reid osnet` | OSNet-AIN x1.0 person Re-ID | ~9 MB | MIT code; weights trained on MSMT17 (check dataset terms for commercial use) | BoT-SORT, BoostTrack, and NLTrack appearance, and `--reid-merge` |
344
+ | `--vlm clip` | CLIP ViT-B/32 (INT8) | ~153 MB | MIT | Default for `--query` and `search` |
345
+ | `--vlm siglip` | SigLIP Base (INT8) | ~205 MB | Apache-2.0 | Better on fine clothing/attribute queries |
346
+ | `--vlm siglip2` | SigLIP 2 Base (INT8) | ~378 MB | Apache-2.0 | Strongest pure-ONNX search (no PyTorch) |
347
+ | `--vlm embeddinggemma` | EmbeddingGemma 2 (PyTorch, needs `[transformers]`) | ~1.5 GB | Apache-2.0 | Best on clothing and accessory queries |
348
+ | `--mask-fallback sam2.1-tiny` | SAM 2.1 Hiera-Tiny (needs `[sam2]`) | ~156 MB | Apache-2.0 | Default selective occlusion mask fallback |
349
+ | `--mask-fallback edgetam` | EdgeTAM (needs `[sam2]`) | ~56 MB | Apache-2.0 | Fastest / lowest-VRAM selective mask fallback |
350
+ | `--mask-fallback sam2.1-small` | SAM 2.1 Hiera-Small (needs `[sam2]`) | ~184 MB | Apache-2.0 | Optional SAM 2.1 Small mask fallback |
351
+ | `--mask-fallback sam2.1-base-plus` | SAM 2.1 Hiera-Base+ (needs `[sam2]`) | ~324 MB | Apache-2.0 | Higher-capacity SAM 2.1 Base+ mask fallback |
352
+ | `--mask-fallback sam2.1-large` | SAM 2.1 Hiera-Large (needs `[sam2]`) | ~898 MB | Apache-2.0 | Largest SAM 2.1 mask fallback for GPU |
353
+
354
+ ## Python API
355
+
356
+ Run a video and write the same files as the CLI:
357
+
358
+ ```python
359
+ from trackflow import TrackflowPipeline
360
+
361
+ pipeline = TrackflowPipeline(
362
+ model="rfdetr-medium",
363
+ tracker="botsort",
364
+ reid="osnet", # person Re-ID for BoT-SORT
365
+ query="person wearing a red jacket", # scored with CLIP (vlm="clip" by default when query is set)
366
+ anonymize="face-blur",
367
+ )
368
+ summary = pipeline.run("crowd.mp4") # or output_dir="runs/crowd"
369
+ print(f"{summary.unique_tracks} unique tracks at {summary.avg_fps:.1f} FPS")
370
+ ```
371
+
372
+ Or feed frames from your own loop and get tracks back, with nothing written to disk:
373
+
374
+ ```python
375
+ import cv2
376
+ from trackflow import TrackflowPipeline
377
+
378
+ pipeline = TrackflowPipeline(model="rfdetr-nano")
379
+ cap = cv2.VideoCapture("rtsp://camera.local/stream")
380
+
381
+ def frames():
382
+ while True:
383
+ ok, frame = cap.read()
384
+ if not ok:
385
+ return
386
+ yield frame # BGR uint8
387
+
388
+ for result in pipeline.stream(frames(), fps=25):
389
+ for track in result.tracks:
390
+ print(result.frame_idx, track.track_id, track.class_name, track.bbox)
391
+ ```
392
+
393
+ To use your own model, pass any object with a `detect(frame_bgr) -> list[Detection]` method as `detector=`. A custom tracker goes in `tracker_factory=`, which takes any object with `update(detections, frame_bgr=None) -> list[Track]`. The built-in trackers are exported too (`ByteTracker`, `BotSortTracker`, `OcSortTracker`, `BoostTracker`), so you can tune one, for example `tracker_factory=lambda: BoostTracker(use_cmc=False)` for a fixed camera. The package ships type hints (`py.typed`), and `Detector` and `Tracker` are exported as protocols.
394
+
395
+ ## Agent skills
396
+
397
+ Use Trackflow — and its ONNX computer-vision deployment checklist — from Claude Code, Codex, Antigravity, Cursor, or OpenCode by installing the bundled skills (or point doc-fetchers at [`llms.txt`](https://obendidi.github.io/trackflow/llms.txt)):
398
+
399
+ - [`trackflow`](skills/trackflow/SKILL.md): run local tracking, line counting, text search, floorplan projection, anonymization, and exports.
400
+ - [`onnx-vision-deploy`](skills/onnx-vision-deploy/SKILL.md): empirical checklist for ONNX vision deployment across CPU, CUDA, Apple Silicon CoreML, and browser WebGPU/WASM parity.
401
+
402
+ ```bash
403
+ npx skills add obendidi/trackflow
404
+ ```
405
+
406
+ ## Migration & integration guides
407
+
408
+ - [Migrating from Google Cloud Video Intelligence (`OBJECT_TRACKING`)](docs/migrate-google-video-intelligence.md)
409
+ - [Migrating from AWS Rekognition (`StartPersonTracking` / People Pathing)](docs/migrate-aws-rekognition.md)
410
+ - [Using Trackflow alongside SAM 3 (track & filter locally, segment selectively)](docs/sam3-handoff.md)
411
+
412
+ ## Changelog
413
+
414
+ What changed in each version is in [CHANGELOG.md](https://github.com/obendidi/trackflow/blob/main/CHANGELOG.md) and on the [releases page](https://github.com/obendidi/trackflow/releases).
415
+
416
+ ## License
417
+
418
+ Apache-2.0 — see [LICENSE](https://github.com/obendidi/trackflow/blob/main/LICENSE). Model weights are downloaded separately and keep their own licenses (see [Models](#models)).
419
+
420
+ The original 2017 `Tracking-with-darkflow` codebase (YOLOv2 + DeepSORT + TensorFlow 1.0) is kept on the [`legacy-2017`](https://github.com/obendidi/trackflow/tree/legacy-2017) branch and [`v1.0-legacy-2017`](https://github.com/obendidi/trackflow/releases/tag/v1.0-legacy-2017) tag under GPL-3.0.
421
+
@@ -0,0 +1,33 @@
1
+ Cargo.lock,sha256=9JWgllwSC57C6rUtfPTOs-RewdPuq2VdY7E9hjtc2F8,3523
2
+ LICENSE,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
3
+ README.md,sha256=ArJqcCr7QJmD3TJqerVNlnFEDPO_zhB7og5WxZ6xlsM,29723
4
+ trackflow/__init__.py,sha256=trX4-XXYmDtDPNCdw_JSS_uez2tkN356mMkHymMHX6I,2248
5
+ trackflow/_accel.py,sha256=0CNH1tz-3BH1vlmKFNkl0UZbfcZcoZGuratdXgySlGM,1282
6
+ trackflow/_native.pyd,sha256=ZJE1pdZQ9MdL1O_hG1-CXKt-thNOI2xSIT-YGh6dWPI,957440
7
+ trackflow/benchmark.py,sha256=CZ0QuM7hXVcqMRp8f-fzqcbTq_gBRMvmleD0XGLRH-I,9939
8
+ trackflow/boosttrack.py,sha256=4zQNLZwobRLCga2cduzFe1dJ_AT9b6_S_EzmwcdK2V8,21853
9
+ trackflow/cli.py,sha256=cxnilCGLKT3i2k45gTs72wbdROKwU0yq2PXFLOghW-Q,27015
10
+ trackflow/detector.py,sha256=ONHr0R9bA0xCL4JE5GIZ3Zpv9qwfsE6fzQJaI3oQ6w4,35002
11
+ trackflow/homography.py,sha256=UndTeIL6KjuodNuhqeI8hOEbf1XaFgEgS0fSgxu4wM4,9914
12
+ trackflow/inspector.py,sha256=Z25OEwqx4aMqn6XS0HswUlQmXbLxI5vKiRYYd2VfN1E,19062
13
+ trackflow/inspector_ui.html,sha256=OHrmvUa3eJy0amEBn6YEcXSFXZPv-sGPftOuLCw4NW8,24305
14
+ trackflow/lines.py,sha256=Mvz04bJO0X85axInzDuBkEJ1Pgp5r5LUlODK93jYbBg,5332
15
+ trackflow/mask_fallback.py,sha256=wIqi2Uf2R0A2J5oHkJQC3VYGgZImREmJAwqkPs8EKfU,44918
16
+ trackflow/models.py,sha256=m9BX29M4SBU1rG0DFcvgXFzZirw8bXuirkgJOkCthx8,18831
17
+ trackflow/nltrack.py,sha256=x-9ttB-ypLKqQGHXt1QkVZL87jIqSRuo3BDFuxWDWSk,47831
18
+ trackflow/ocsort.py,sha256=7_dCxS1dLzK73i8-pqeFqfOZtVcJkli2nDFg7aiYsn0,17407
19
+ trackflow/pipeline.py,sha256=Z9xZbyCeSGm9DWxP7OumVk4Hyff1tNrLZf0i_tc-5ao,63294
20
+ trackflow/postprocess.py,sha256=rng7T9yMVI5kjmtG77SjcZQHgGH2FHKGkoSFkih0U7E,79030
21
+ trackflow/privacy.py,sha256=QgxnAs_SG3g6AjCLb_xlP0oP2PZif3bqpWAPNotpT9A,11173
22
+ trackflow/py.typed,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
23
+ trackflow/reid.py,sha256=3x7AKG9NcasNB1UBsTpUU3TCK9Ok-RnG9_B3ta-UoDE,43760
24
+ trackflow/sam2_adapter.py,sha256=R2uOA5OLLF-OCrh9QJhf0QirwG58ntYRjK-ap4CPNq0,8527
25
+ trackflow/sinks.py,sha256=WwF6qzYnTTBas-hZKuyHbK2O_5wWjzkwenIRH6yfaWQ,17727
26
+ trackflow/tracker.py,sha256=OVP5kXUlUHEuEd9k2smZholLXcPEI6kyjc_XIz_QBcw,53593
27
+ trackflow/types.py,sha256=RSpIeL-pJmiilO4ADO3vALlJFjULM2p-kbeYFfegz8k,8630
28
+ trackflow_python_tensorrt-0.7.0.dist-info/METADATA,sha256=Qpv3iVSmuICgWlviAPBvmxoEsGWSsYGsZB2UKOUZ49o,32532
29
+ trackflow_python_tensorrt-0.7.0.dist-info/WHEEL,sha256=TzjyIyBUptJHnlQyOymQYLWjtXe7MGI0m3QvmcG7PpI,96
30
+ trackflow_python_tensorrt-0.7.0.dist-info/entry_points.txt,sha256=TvRFJQIE_XO5DztBO4Xpcot0EEy_R9Qp5H3pCQYxfwk,99
31
+ trackflow_python_tensorrt-0.7.0.dist-info/licenses/LICENSE,sha256=Pd-b5cKP4n2tFDpdx27qJSIq0d1ok0oEcGTlbtL6QMU,11560
32
+ trackflow_python_tensorrt-0.7.0.dist-info/sboms/trackflow-native.cyclonedx.json,sha256=uqStt0gxs6m8Doedpp92Q2EsXXC0Ph5RhyLdyTHSQig,16220
33
+ trackflow_python_tensorrt-0.7.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: maturin (1.16.0)
3
+ Root-Is-Purelib: false
4
+ Tag: cp310-abi3-win_amd64
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ trackflow=trackflow.cli:app
3
+ trackflow-python-tensorrt=trackflow.cli:app_tensorrt