Tune Trackers
Use Optuna to tune tracker hyperparameters automatically and maximize your target metric on MOT-format evaluation data.
What you'll learn:
- Install tuning dependencies
- Prepare ground truth and detection files for tuning
- Run tuning from CLI and Python
- Save and apply the best parameter set
Install
Install the tuning extra to enable Optuna-based hyperparameter search.
For more options, see the install guide.
Prepare Data
The tuner needs matching MOT files for ground truth and detections.
data
├── gt
│ ├── MOT17-02-FRCNN.txt
│ ├── MOT17-04-FRCNN.txt
│ └── ...
└── detections
├── MOT17-02-FRCNN.txt
├── MOT17-04-FRCNN.txt
└── ...
Each sequence must exist in both directories with the same filename ({sequence}.txt).
Use MOT format lines:
For detections, use id=-1. For more details on the format and evaluation workflow, see the evaluation guide.
Quickstart
Tune ByteTrack and optimize HOTA.
Tune a Sequence Subset
Use a seqmap file when you want to tune on a specific subset of sequences.
Use Best Parameters
Apply tuned values by unpacking the saved JSON dictionary into your tracker constructor.
import json
from trackers import ByteTrackTracker
with open("./results/bytetrack-best.json", "r", encoding="utf-8") as f:
best_params = json.load(f)
tracker = ByteTrackTracker(**best_params)
CLI Reference
All arguments accepted by trackers tune.
| Argument | Description | Default |
|---|---|---|
--tracker |
Tracker name to tune. Common values: bytetrack, sort, ocsort. |
— |
--gt-dir |
Directory with ground-truth MOT files ({sequence}.txt). |
— |
--detections-dir |
Directory with detection MOT files ({sequence}.txt), one file per sequence. |
— |
--objective |
Metric to maximize: MOTA, HOTA, or IDF1. |
HOTA |
--n-trials |
Number of Optuna trials to run. | 100 |
--metrics |
Metric families to compute: CLEAR, HOTA, Identity. The family required by --objective is added automatically. |
CLEAR |
--threshold |
IoU threshold used during evaluation matching for CLEAR and Identity. Higher values make scoring stricter, lower values make it more permissive. |
0.5 |
--seqmap |
Optional path to a sequence map file. When set, only listed sequences are tuned. | all files in --detections-dir |
--output, -o |
Path to save best parameters as JSON. | None |