Skip to content

Patch: seeding, default parameters initialization for tuner, images support and choice of fixing parameters #427

Merged
Borda merged 11 commits into
developfrom
patch/tuner-tries-default-combination-and-seed-
May 20, 2026
Merged

Patch: seeding, default parameters initialization for tuner, images support and choice of fixing parameters #427
Borda merged 11 commits into
developfrom
patch/tuner-tries-default-combination-and-seed-

Conversation

@AlexBodner
Copy link
Copy Markdown
Collaborator

@AlexBodner AlexBodner commented May 18, 2026

What does this PR do?

Improves the hyperparameter tuner with a baseline (default params) trial, fixed tracker options, optional MOT image loading for CMC, and reproducible Optuna sampling.

  • Baseline trial: By default, trial 0 runs the tracker’s init defaults (merged with fixed_params) before Optuna explores the search space.

  • fixed_params: Pin options like enable_cmc for every trial; fixed keys are excluded from sampling and included in run()’s returned best params.

  • images_dir: Load sequence frames during tuning so CMC-enabled trackers (e.g. BoTSORT) can use motion compensation; required when enable_cmc=True.

  • seed: Optional seed for Optuna’s TPE sampler so sampled trials are reproducible across runs.
    CLI/docs: --fixed-params, --images-dir, --no-enqueue-defaults, --seed; BoTSORT no longer exposes enable_cmc in search_space (use fixed_params instead).

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update

Testing

  • I have tested this change locally
  • I have added/updated tests for this change

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code where necessary, particularly in hard-to-understand areas
  • My changes generate no new warnings or errors
  • I have updated the documentation accordingly (if applicable)

Additional Context

@AlexBodner AlexBodner requested review from Borda and Copilot May 18, 2026 15:04
@AlexBodner AlexBodner marked this pull request as ready for review May 18, 2026 15:07
@AlexBodner AlexBodner requested a review from SkalskiP as a code owner May 18, 2026 15:07
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds reproducibility and configurability features to the Optuna-based tracker tuner: a seed for deterministic sampling, an enqueued baseline trial that evaluates each tracker's __init__ defaults first, a fixed_params mechanism to pin specific kwargs across all trials (validated against the tracker __init__ signature and excluded from the sampled search space), and an images_dir option that loads MOT-style frames so trackers needing image input (e.g. BoTSORT CMC) can run inside the tuner. The previously hard-coded enable_cmc=[False] choice in BoTSORT's search_space is removed now that the tuner can feed frames, and the CLI / docs gain matching flags and guidance.

Changes:

  • New Tuner arguments (seed, enqueue_defaults, fixed_params, images_dir) plus helpers _create_optuna_study, _default_trial_params, _validate_tracker_init_params, _load_mot_sequence_frame; _run_tracker_on_detections now optionally passes frames to tracker.update.
  • CLI trackers tune exposes --fixed-params, --images-dir, --no-enqueue-defaults, --seed; tune() forwards them; BoTSORT search space no longer locks enable_cmc to False.
  • Tests and docs/learn/tune.md updated to cover seeding, defaults enqueuing, fixed-param validation, and images-based CMC tuning.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/trackers/tune/tuner.py Core Tuner additions: seed/enqueue/fixed_params/images_dir, helpers, frame loading, merged best-params output.
src/trackers/scripts/tune.py New CLI flags and forwarding to tune()/Tuner.
src/trackers/core/botsort/tracker.py Removes the forced enable_cmc=[False] entry from BoTSORT's search space.
docs/learn/tune.md Documents baseline trial behavior, fixed_params, images_dir, and --seed.
tests/tune/test_tuner.py Tests for default trial params, fixed-params handling, seed reproducibility, enqueue behavior.
tests/scripts/test_tune.py Updates CLI delegation tests to include new kwargs.

Comment thread src/trackers/core/botsort/tracker.py
Comment thread src/trackers/tune/tuner.py
Comment thread src/trackers/tune/tuner.py Outdated
Comment thread src/trackers/tune/tuner.py Outdated
Comment thread src/trackers/tune/tuner.py Outdated
Default: CLEAR.
threshold: IoU threshold for CLEAR and Identity matching.
seqmap: Sequence map file listing sequences to evaluate.
fixed_params: Tracker kwargs held constant for every trial.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets rather expose seed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seed is already exposed in the CLI as --seed and passed through to Tuner(..., seed=...) (still present after f604246).

Comment on lines +68 to +72
fixed_params: Tracker ``__init__`` kwargs held constant for every trial
(including the baseline). Overrides ``search_space`` for the same
key. Use for options you do not want tuned, e.g.
``{"enable_cmc": False}`` or ``{"lost_track_buffer": 30}``.
Keys in ``fixed_params`` are not sampled by Optuna.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seem to duplicate the seed functionality?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its different. Seed is for managing pseudo-random numbers, and this is for explicitly setting parameters that one doesnt want to tune (eg: cmc enable, or State Estimator variant)

Comment thread src/trackers/tune/tuner.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Borda Borda added bug Something isn't working enhancement New feature or request labels May 18, 2026
@Borda Borda requested a review from tstanczyk95 May 18, 2026 17:39
Comment thread docs/learn/tune.md
--tracker botsort \
--gt-dir ./data/gt \
--detections-dir ./data/detections \
--fixed-params '{"enable_cmc": false}'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed is fine, or maybe frozen?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fixed has sometimes a task if fixing something broken...

@Borda Borda merged commit 0f87d0e into develop May 20, 2026
18 checks passed
@Borda Borda deleted the patch/tuner-tries-default-combination-and-seed- branch May 20, 2026 16:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants