Skip to content

cli: add hyperparameter tuning for trackers #260

@SkalskiP

Description

@SkalskiP

Description

Add a trackers tune CLI subcommand that runs hyperparameter optimization for any registered tracker. The tuner takes pre-computed detections (MOT format) and ground-truth annotations, repeatedly instantiates the tracker with different parameter configurations proposed by Optuna, evaluates each configuration using the existing evaluate_mot_sequences engine, and reports the best-found parameters.

# Basic usage — tune ByteTrack on MOT17 with 100 trials
trackers tune \
  --tracker bytetrack \
  --gt-dir path/to/gt/ \
  --detections-dir path/to/detections/ \
  --n-trials 100

# Pick objective metric and metric families to compute
trackers tune \
  --tracker sort \
  --gt-dir path/to/gt/ \
  --detections-dir path/to/detections/ \
  --metrics HOTA MOTA IDF1 \
  --objective HOTA \
  --n-trials 200

Search space definition

Each tracker declares a search_space class variable alongside its __init__ parameters.

class ByteTrackTracker(BaseTracker):
    search_space: ClassVar[dict[str, dict]] = {
        "lost_track_buffer": {"type": "randint", "range": [10, 61]},
        "track_activation_threshold": {"type": "uniform", "range": [0.5, 0.9]},
        "minimum_iou_threshold": {"type": "uniform", "range": [0.05, 0.5]},
        "high_conf_det_threshold": {"type": "uniform", "range": [0.3, 0.8]},
    }

Tasks

  • Define search_space: ClassVar[dict[str, dict]] on SORTTracker and ByteTrackTracker with sensible ranges for each tunable parameter. Validate that every key in search_space matches a parameter name in __init__.
  • Implement a Tuner class that wraps an Optuna study: converts search_space to Optuna distributions, runs trials calling the objective function.
  • Register the tune subcommand in trackers/scripts/__main__.py with arguments: --tracker, --gt-dir, --detections-dir, --metrics, --objective, --n-trials, --output, --resume.
  • Add optuna as an optional dependency under trackers[tune] in pyproject.toml.
  • Document usage: expected input format for detections-dir and gt-dir, how to generate detections with trackers track, example commands, and the meaning of output files.

Metadata

Metadata

Assignees

Labels

cliLI commands and terminal interfacehelp wantedExtra attention is needed

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions