trackflow-python-cuda 0.6.1__tar.gz

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,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,366 @@
1
+ Metadata-Version: 2.5
2
+ Name: trackflow-python-cuda
3
+ Version: 0.6.1
4
+ 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 CUDA build with bundled CUDA/cuDNN runtimes.)
5
+ Project-URL: Homepage, https://obendidi.github.io/trackflow/
6
+ Project-URL: Repository, https://github.com/obendidi/trackflow
7
+ Project-URL: Issues, https://github.com/obendidi/trackflow/issues
8
+ Author: Ouail Bendidi
9
+ License-Expression: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: boosttrack,botsort,bytetrack,clip,computer-vision,d-fine,homography,mot,multi-object-tracking,object-tracking,ocsort,onnxruntime,parquet,people-tracking,re-identification,rf-detr,rtdetr,siglip,video-tracking,webgpu
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: License :: OSI Approved :: Apache Software License
17
+ Classifier: Operating System :: OS Independent
18
+ Classifier: Programming Language :: Python :: 3
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Multimedia :: Video
24
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
25
+ Classifier: Topic :: Scientific/Engineering :: Image Recognition
26
+ Requires-Python: >=3.10
27
+ Requires-Dist: huggingface-hub>=0.24
28
+ Requires-Dist: numpy>=1.26
29
+ Requires-Dist: onnxruntime-gpu[cuda,cudnn]>=1.22
30
+ Requires-Dist: opencv-python-headless>=4.9
31
+ Requires-Dist: pyarrow>=15.0
32
+ Requires-Dist: rich>=13.7
33
+ Requires-Dist: scipy>=1.11
34
+ Requires-Dist: tokenizers>=0.19
35
+ Requires-Dist: typer>=0.12
36
+ Provides-Extra: dev
37
+ Requires-Dist: pytest>=8.0; extra == 'dev'
38
+ Requires-Dist: ruff>=0.6; extra == 'dev'
39
+ Provides-Extra: display
40
+ Requires-Dist: opencv-python>=4.9; extra == 'display'
41
+ Provides-Extra: transformers
42
+ Requires-Dist: sentence-transformers<7,>=6.1; extra == 'transformers'
43
+ Requires-Dist: torch>=2.6; extra == 'transformers'
44
+ Requires-Dist: torchvision>=0.21; extra == 'transformers'
45
+ Requires-Dist: transformers<6,>=5.18; extra == 'transformers'
46
+ Description-Content-Type: text/markdown
47
+
48
+ # Trackflow
49
+
50
+ [![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](https://github.com/obendidi/trackflow/blob/main/LICENSE)
51
+ [![Python](https://img.shields.io/badge/Python-3.10%2B-3776AB.svg)](https://pypi.org/project/trackflow-python/)
52
+
53
+ 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 or BoostTrack, 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.
54
+
55
+ ![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)
56
+
57
+ *`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.*
58
+
59
+ ![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)
60
+
61
+ *`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.*
62
+
63
+ Try it in the browser without installing anything: [obendidi.github.io/trackflow](https://obendidi.github.io/trackflow/).
64
+
65
+ ## Quickstart
66
+
67
+ One command for your hardware — no system CUDA Toolkit, cuDNN, or TensorRT setup required:
68
+
69
+ | Environment | Zero-install (`uvx`) | Installed (`pip`) | Notes |
70
+ | :--- | :--- | :--- | :--- |
71
+ | **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) |
72
+ | **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 |
73
+ | **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) |
74
+ | **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) |
75
+
76
+ Or run via Docker with zero Python setup (`--target cpu`, `cuda`, or `tensorrt` in [Dockerfile](Dockerfile)):
77
+
78
+ ```bash
79
+ docker build --target tensorrt -t trackflow:tensorrt .
80
+ docker run --rm --gpus all -v "$PWD:/work" \
81
+ -v "$HOME/.cache/huggingface:/root/.cache/huggingface" \
82
+ -v "$HOME/.cache/trackflow:/root/.cache/trackflow" \
83
+ trackflow:tensorrt run /work/street.mp4
84
+ ```
85
+
86
+ After a run finishes, open the local visual inspector:
87
+
88
+ ```bash
89
+ trackflow inspect # opens the most recent run
90
+ trackflow info # checks GPU, execution providers, and recommended command
91
+ ```
92
+
93
+ 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.
94
+
95
+ 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.*
96
+
97
+ <details>
98
+ <summary>Verified NVIDIA T4 GPU throughput & parity (CUDA FP32 vs TensorRT 10 FP16)</summary>
99
+
100
+ 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):
101
+
102
+ | Model | CUDA FP32 | TensorRT FP16 *(warm)* | Speedup vs CUDA | Mean IoU vs CPU | Cold build → Warm load |
103
+ | :--- | ---: | ---: | ---: | ---: | :--- |
104
+ | `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** |
105
+ | `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** |
106
+ | `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** |
107
+ | `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** |
108
+ | `rfdetr-nano` | **18.1 ms (55.4 FPS)** | FP32 (`trt_fp16=False`) | — | 1.000 (`30/30`) | Kept in FP32 (FP16 overflows DINOv2) |
109
+ | `rfdetr-medium` | **40.5 ms (24.7 FPS)** | FP32 (`trt_fp16=False`) | — | 1.000 (`31/31`) | Kept in FP32 (FP16 overflows DINOv2) |
110
+ | `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 |
111
+
112
+ </details>
113
+
114
+ ## Usage
115
+
116
+ ### Tracking and exports
117
+
118
+ ```bash
119
+ trackflow run crowd.mp4 \
120
+ --model rfdetr-medium \
121
+ --tracker botsort --reid osnet \
122
+ --classes person,backpack \
123
+ --export parquet,jsonl,csv,mot,html
124
+ ```
125
+
126
+ 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.
127
+
128
+ The Parquet export can be queried directly with DuckDB:
129
+
130
+ ```sql
131
+ SELECT track_id, COUNT(*) AS frames, AVG(confidence) AS avg_conf
132
+ FROM 'runs/run-1/tracks.parquet'
133
+ GROUP BY track_id ORDER BY frames DESC;
134
+ ```
135
+
136
+ `--export mot` writes `tracks.txt` in MOTChallenge format, which [TrackEval](https://github.com/JonathonLuiten/TrackEval) scores directly (HOTA, IDF1, MOTA).
137
+
138
+ ### Trackers
139
+
140
+ | `--tracker` | Algorithm | How it works |
141
+ | :--- | :--- | :--- |
142
+ | `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. |
143
+ | `botsort` | [BoT-SORT](https://arxiv.org/abs/2206.14651) (2022) | ByteTrack plus camera-motion compensation, and appearance matching with `--reid osnet`. |
144
+ | `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. |
145
+ | `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. |
146
+
147
+ All four 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.
148
+
149
+ #### Benchmarks across 4 official datasets (81 videos, ~59,800 frames)
150
+
151
+ ![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)
152
+
153
+ 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.
154
+
155
+ | Tracker | DanceTrack (25) | SportsMOT (45) | MOT17 (7) | MOT20 (4) | Mean HOTA | Total ID switches | Tracker FPS | End-to-End FPS |
156
+ | :--- | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
157
+ | **`botsort --reid osnet`** | **39.0** | 45.0 | **46.9** | **24.4** | **38.8** | 6,435 | 205 | 5.5 |
158
+ | **`ocsort`** *(no Re-ID)* | 37.9 | **46.0** | 46.3 | 23.3 | **38.4** | **5,501** | 203 | 9.2 |
159
+ | **`boosttrack`** *(no Re-ID)* | 37.5 | 44.4 | **46.9** | 24.0 | **38.2** | 5,549 | 201 | 9.2 |
160
+ | **`botsort`** *(no Re-ID)* | 36.7 | 44.3 | 46.5 | 24.3 | **37.9** | 6,475 | 221 | 9.3 |
161
+ | `bytetrack` *(also in browser)* | 33.1 | 39.8 | 45.1 | 23.5 | 35.4 | 7,038 | **2,900** | **9.7** |
162
+ | *Roboflow `cbiou` (`0.45/0.50`)* | 36.0 | 43.4 | 46.4 | 24.2 | 37.5 | 7,533 | 2,072 | 9.6 |
163
+ | *Roboflow `botsort` (`0.45/0.50`)* | 35.9 | 43.6 | 46.3 | 24.0 | 37.4 | 6,922 | 194 | 9.2 |
164
+ | *Roboflow `ocsort+cmc` (`0.45`)* | 33.4 | 43.8 | 44.2 | 15.9 | 34.3 | 8,057 | 196 | 9.2 |
165
+ | *Roboflow `botsort` (defaults `0.60/0.70`)* | 39.6 | 50.0 | 42.6 | 13.6 | 36.4 | 4,349 | 207 | 9.2 |
166
+
167
+ **How to read this chart and table:**
168
+ - **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.
169
+ - **ID switches (lower is better)**: How many times a tracker accidentally swaps or resets a person's ID mid-video.
170
+ - **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.
171
+ - **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).
172
+ - **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.
173
+
174
+ [`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`.
175
+
176
+ ### Text search and re-identification
177
+
178
+ ```bash
179
+ # Highlight matching people live (uses CLIP by default; --vlm embeddinggemma for clothing and accessories)
180
+ trackflow run mall.mp4 --query "person in red jacket with a backpack"
181
+
182
+ # Search a completed run later without re-running detection
183
+ # (requires a run created with --query or --vlm clip|siglip|siglip2|embeddinggemma)
184
+ trackflow search runs/run-1 "person carrying a suitcase"
185
+
186
+ # Export top search hits as time windows + normalized boxes for SAM 3 or a VLM
187
+ trackflow search runs/run-1 "person in red jacket" --top-k 5 --pad-s 1.0 --export-prompts prompts.json
188
+
189
+ # Give people who leave and come back their earlier ID (opt-in, uses person Re-ID)
190
+ trackflow run mall.mp4 --reid osnet --reid-merge
191
+ ```
192
+
193
+ ![Natural-language track search quality vs. speed across 23,287 labeled pedestrian crops](https://raw.githubusercontent.com/obendidi/trackflow/main/docs/benchmarks-search.png)
194
+
195
+ 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):
196
+
197
+ - **`--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).
198
+ - **`--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).
199
+ - **`--vlm clip`** *(default, pure ONNX INT8)*: fastest option (**146 crops/s** on CPU, `0.288 / 0.357` mAP).
200
+
201
+ 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.
202
+
203
+ ### Inspector, tracker comparison, and floorplan projection
204
+
205
+ ```bash
206
+ # Compare ByteTrack and BoT-SORT on the same video and open the inspector
207
+ trackflow compare crowd.mp4 --trackers bytetrack,botsort --inspect
208
+
209
+ # Open the inspector on any existing run
210
+ trackflow inspect runs/run-1
211
+ ```
212
+
213
+ `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.
214
+
215
+ ### Line counting
216
+
217
+ ```bash
218
+ # Count people crossing a doorway, in each direction
219
+ trackflow run entrance.mp4 --line "door=640,300,640,720"
220
+ ```
221
+
222
+ `--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.
223
+
224
+ 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`.
225
+
226
+ ### Anonymization
227
+
228
+ ```bash
229
+ # Blur the top of each person box, where the head usually is
230
+ trackflow run lobby.mp4 --anonymize face-blur
231
+
232
+ # Draw stick figures on a blank canvas (box-based, no pose model; no video pixels saved)
233
+ trackflow run lobby.mp4 --anonymize skeleton
234
+ ```
235
+
236
+ 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.
237
+
238
+ `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.
239
+
240
+ ### Benchmarking
241
+
242
+ ```bash
243
+ trackflow benchmark crowd.mp4 --models rfdetr-nano,rtdetr-v2-r18 --trackers bytetrack,botsort --split-screen
244
+ ```
245
+
246
+ 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.
247
+
248
+ 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.
249
+
250
+ ## Models
251
+
252
+ Weights download automatically from Hugging Face on first use. `trackflow models` lists every preset (`--json` for scripts).
253
+
254
+ | Preset | Model | Size (FP32) | License | Notes |
255
+ | :--- | :--- | ---: | :--- | :--- |
256
+ | `rtdetr-v2-r18` *(default)* | RT-DETRv2 ResNet-18 (640×640) | ~81 MB | Apache-2.0 | Balanced default for crowded scenes |
257
+ | `rfdetr-nano` | RF-DETR Nano (384×384) | ~108 MB | Apache-2.0 | Fast on Apple Silicon and WebGPU |
258
+ | `rfdetr-small` | RF-DETR Small (512×512) | ~115 MB | Apache-2.0 | |
259
+ | `rfdetr-medium` | RF-DETR Medium (576×576) | ~121 MB | Apache-2.0 | |
260
+ | `rfdetr-base` | RF-DETR Base (560×560) | ~108 MB | Apache-2.0 | |
261
+ | `rfdetr-large` | RF-DETR Large (704×704) | ~136 MB | Apache-2.0 | Most accurate preset; needs the `transformers` extra |
262
+ | `dfine-n` | D-FINE Nano (640×640) | ~15 MB | Apache-2.0 | Small download |
263
+ | `dfine-s` | D-FINE Small (640×640) | ~42 MB | Apache-2.0 | Compact COCO-only ONNX |
264
+ | `dfine-m` | D-FINE Medium (640×640) | ~79 MB | Apache-2.0 | Highest Apache-2.0 ONNX MOT17 HOTA |
265
+ | `yolo26n` … `yolo26x` | YOLO26 Nano to XLarge (640×640) | 10–223 MB | **AGPL-3.0** | Commercial use needs an Ultralytics license |
266
+ | `deimv2-atto` | DEIMv2 Atto (320×320) | ~2 MB | **Non-commercial** | Tiny edge model, FP32 only |
267
+ | `deimv2-s` | DEIMv2 Small, DINOv3 backbone (640×640) | ~41 MB | **Non-commercial** + DINOv3 | FP32 only |
268
+
269
+ 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):
270
+
271
+ | Preset | HOTA | IDF1 | MOTA |
272
+ | :--- | ---: | ---: | ---: |
273
+ | `dfine-m` | 46.5 | 55.1 | 39.2 |
274
+ | `rtdetr-v2-r18` *(default)* | 45.1 | 53.9 | 39.8 |
275
+ | `rfdetr-large` | 44.3 | 51.1 | 35.9 |
276
+ | `rfdetr-medium` | 42.9 | 49.7 | 34.8 |
277
+ | `yolo26n` | 37.4 | 41.4 | 27.9 |
278
+ | `rfdetr-nano` | 36.5 | 40.5 | 28.2 |
279
+
280
+ `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.
281
+
282
+ 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`:
283
+
284
+ ```bash
285
+ pip install "trackflow-python[transformers]"
286
+ trackflow run crowd.mp4 -m rfdetr-large
287
+ trackflow run crowd.mp4 -m hf:PekingU/rtdetr_v2_r50vd --device mps
288
+ ```
289
+
290
+ Re-ID and text-search models:
291
+
292
+ | Flag | Model | Size | License | Used for |
293
+ | :--- | :--- | ---: | :--- | :--- |
294
+ | `--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 and BoostTrack appearance, and `--reid-merge` |
295
+ | `--vlm clip` | CLIP ViT-B/32 (INT8) | ~153 MB | MIT | Default for `--query` and `search` |
296
+ | `--vlm siglip` | SigLIP Base (INT8) | ~205 MB | Apache-2.0 | Better on fine clothing/attribute queries |
297
+ | `--vlm siglip2` | SigLIP 2 Base (INT8) | ~378 MB | Apache-2.0 | Strongest pure-ONNX search (no PyTorch) |
298
+ | `--vlm embeddinggemma` | EmbeddingGemma 2 (PyTorch, needs `[transformers]`) | ~1.5 GB | Apache-2.0 | Best on clothing and accessory queries |
299
+
300
+ ## Python API
301
+
302
+ Run a video and write the same files as the CLI:
303
+
304
+ ```python
305
+ from trackflow import TrackflowPipeline
306
+
307
+ pipeline = TrackflowPipeline(
308
+ model="rfdetr-medium",
309
+ tracker="botsort",
310
+ reid="osnet", # person Re-ID for BoT-SORT
311
+ query="person wearing a red jacket", # scored with CLIP (vlm="clip" by default when query is set)
312
+ anonymize="face-blur",
313
+ )
314
+ summary = pipeline.run("crowd.mp4") # or output_dir="runs/crowd"
315
+ print(f"{summary.unique_tracks} unique tracks at {summary.avg_fps:.1f} FPS")
316
+ ```
317
+
318
+ Or feed frames from your own loop and get tracks back, with nothing written to disk:
319
+
320
+ ```python
321
+ import cv2
322
+ from trackflow import TrackflowPipeline
323
+
324
+ pipeline = TrackflowPipeline(model="rfdetr-nano")
325
+ cap = cv2.VideoCapture("rtsp://camera.local/stream")
326
+
327
+ def frames():
328
+ while True:
329
+ ok, frame = cap.read()
330
+ if not ok:
331
+ return
332
+ yield frame # BGR uint8
333
+
334
+ for result in pipeline.stream(frames(), fps=25):
335
+ for track in result.tracks:
336
+ print(result.frame_idx, track.track_id, track.class_name, track.bbox)
337
+ ```
338
+
339
+ 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.
340
+
341
+ ## Agent skills
342
+
343
+ 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)):
344
+
345
+ - [`trackflow`](skills/trackflow/SKILL.md): run local tracking, line counting, text search, floorplan projection, anonymization, and exports.
346
+ - [`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.
347
+
348
+ ```bash
349
+ npx skills add obendidi/trackflow
350
+ ```
351
+
352
+ ## Migration & integration guides
353
+
354
+ - [Migrating from Google Cloud Video Intelligence (`OBJECT_TRACKING`)](docs/migrate-google-video-intelligence.md)
355
+ - [Migrating from AWS Rekognition (`StartPersonTracking` / People Pathing)](docs/migrate-aws-rekognition.md)
356
+ - [Using Trackflow alongside SAM 3 (track & filter locally, segment selectively)](docs/sam3-handoff.md)
357
+
358
+ ## Changelog
359
+
360
+ 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).
361
+
362
+ ## License
363
+
364
+ 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)).
365
+
366
+ 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.