Skip to content

Add Tuner class #301

Open
omkar-334 wants to merge 16 commits intoroboflow:feat/cli/tune-hyperparameter-optimizationfrom
omkar-334:feat/cli/tune-stage2
Open

Add Tuner class #301
omkar-334 wants to merge 16 commits intoroboflow:feat/cli/tune-hyperparameter-optimizationfrom
omkar-334:feat/cli/tune-stage2

Conversation

@omkar-334
Copy link
Contributor

What does this PR do?

This PR adds the Tuner class and the corresponding tests for it.

#260 cc @SkalskiP

Type of Change

  • New feature (non-breaking change that adds functionality)

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

@omkar-334 omkar-334 requested a review from SkalskiP as a code owner February 27, 2026 17:53
@omkar-334
Copy link
Contributor Author

@SkalskiP here's the colab for testing this out - https://colab.research.google.com/drive/1Y9l8SIYUdRwDChzh73ScobSZ59n0kgZG?usp=sharing

Since we're saving the optuna study as a class variable, the user has the convenience of plotting it or saving it too. I think this is nice.

@omkar-334
Copy link
Contributor Author

Screenshot 2026-02-27 at 11 34 34 PM Screenshot 2026-02-27 at 11 34 07 PM

@SkalskiP
Copy link
Collaborator

Hi @omkar-334, this is so cool! 🔥 I'm so excited for this feature.

Is there a way we could summerize those experiments in a table? Or return information about all experiments at the end of tuning?

@omkar-334
Copy link
Contributor Author

omkar-334 commented Feb 28, 2026

Is there a way we could summerize those experiments in a table? Or return information about all experiments at the end of tuning?

hey @SkalskiP , optuna has study.trials_dataframe() built-in which returns a proper DataFrame with all trial info.
Screenshot 2026-03-01 at 12 11 15 AM

This is really handy and since we already save the optuna study as a class variable, the user can access it anytime.

@omkar-334
Copy link
Contributor Author

omkar-334 commented Mar 4, 2026

hey @SkalskiP , just a nudge, can you review this

@SkalskiP
Copy link
Collaborator

SkalskiP commented Mar 6, 2026

Hi @omkar-334, I’m very sorry. I was sick all week. I only started to feel a bit better yesterday, so today I’m getting back to GitHub.

@omkar-334
Copy link
Contributor Author

Hi @omkar-334, I’m very sorry. I was sick all week. I only started to feel a bit better yesterday, so today I’m getting back to GitHub.

no worries, @SkalskiP ... take care. I was working on the 3rd part. will make a PR for this after you review this.
Thanks!

@SkalskiP
Copy link
Collaborator

SkalskiP commented Mar 9, 2026

Hi @omkar-334,

Heads up. I rebased your branch onto the latest feat/cli/tune-hyperparameter-optimization. The base branch was behind develop by 22 commits.

First, I merged develop into the base branch. Then I rebased your 5 commits on top.

There was one conflict in pyproject.toml. I resolved the conflict by keeping both changes.

[project.optional-dependencies]
detection = ["inference-models>=0.19.0"]
tune = ["optuna>=3.0.0"]

This rebase rewrote the commit history and required a force push. If you have local changes on this branch, sync your local branch with the remote before continuing.

@SkalskiP
Copy link
Collaborator

SkalskiP commented Mar 9, 2026

@omkar-334, I am working on the code review and have a few comments. I also want to run several local tests to compare the results with those from #309, but I need to consult with the rest of the Trackers team first to ensure I do this correctly.

@SkalskiP
Copy link
Collaborator

SkalskiP commented Mar 9, 2026

@omkar-334 Can you also add a search_space to the OC-SORT tracker (trackers/core/ocsort/tracker.py)?

OC-SORT was recently added to the codebase (merged into develop), so it's now available on this branch after the rebase. SORT and ByteTrack already have their search_space defined. OC-SORT is the only tracker missing one. Here are the recommended ranges:

search_space: ClassVar[dict[str, dict]] = {
    "lost_track_buffer": {"type": "randint", "range": [10, 61]},
    "minimum_iou_threshold": {"type": "uniform", "range": [0.1, 0.5]},
    "minimum_consecutive_frames": {"type": "randint", "range": [3, 6]},
    "direction_consistency_weight": {"type": "uniform", "range": [0.0, 0.5]},
    "high_conf_det_threshold": {"type": "uniform", "range": [0.4, 0.8]},
    "delta_t": {"type": "randint", "range": [1, 4]},
}

@omkar-334
Copy link
Contributor Author

omkar-334 commented Mar 9, 2026

@omkar-334 Can you also add a search_space to the OC-SORT tracker (trackers/core/ocsort/tracker.py)?

OC-SORT was recently added to the codebase (merged into develop), so it's now available on this branch after the rebase. SORT and ByteTrack already have their search_space defined. OC-SORT is the only tracker missing one. Here are the recommended ranges:

Done , I've added search_space to OC-SORT.

@omkar-334, I am working on the code review and have a few comments. I also want to run several local tests to compare the results with those from #309, but I need to consult with the rest of the Trackers team first to ensure I do this correctly.

Even i wanted to know how the comparison looks like... do let me know. Thanks!

@omkar-334
Copy link
Contributor Author

@SkalskiP how was tuning done in #309? the search space, metrics and n_trials?

@SkalskiP
Copy link
Collaborator

SkalskiP commented Mar 9, 2026

@AlexBodner can you tell @omkar-334 more about methodology we used? (or share link to docs once we update it)

I think it's crucial we get similar outcomes with Tuner and our internal tuning expariments.

@AlexBodner
Copy link
Collaborator

Hello @omkar-334. You can find the code for the parameter tuning in #309 in the following repo: https://github.com/AlexBodner/trackers-parameter-tuning/tree/main
and just added in #309 docs/comparison.md more detail on the methodology, but summarizing:

  • Detections are from YoloX detector following what ByteTrack authors propose.
  • Sets used can be found on comparison.md
  • Search spaces can also be found in the notebooks in the repository. for each tracker we use the same search space along the different datasets (but different per tracker)

pre-commit-ci bot and others added 2 commits March 9, 2026 22:36
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.15.4 → v0.15.5](astral-sh/ruff-pre-commit@v0.15.4...v0.15.5)
- [github.com/codespell-project/codespell: v2.4.1 → v2.4.2](codespell-project/codespell@v2.4.1...v2.4.2)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* added parameter tuned results for sportsmot, soccernet and MOT17

* fix(pre_commit): 🎨 auto format pre-commit hooks

* added parameter tuned results for dancetrack

* added parameter tuned results for dancetrack

* docs: redesign tracker comparison page with tabbed Default/Tuned layout

Reorganize benchmark tables into content tabs for each dataset (MOT17, SportsMOT, SoccerNet, DanceTrack). The "Tuned" tab includes grid-search parameter configurations as copyable YAML blocks. Fix SoccerNet table formatting bug where default and tuned results were merged into a single table. Unify row ordering to SORT/ByteTrack/OC-SORT across all tables. Add warning callout for DanceTrack explaining CodaLab discontinuation.

* fix(pre_commit): 🎨 auto format pre-commit hooks

* checked numbers and added Notes on used sets + detections

* added methodology section:

* docs: improve comparison page callouts and methodology section

Move per-dataset notes into info callouts positioned before the results tables. Fix spelling of Codabench and YOLOX. Rewrite the Methodology section for clarity: drop the Tracking subsection, simplify Detections and Tuning descriptions, and clean up split selection rules.

* fix(pre_commit): 🎨 auto format pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Piotr Skalski <piotr.skalski92@gmail.com>
@omkar-334
Copy link
Contributor Author

Thanks @AlexBodner ! I'll take a look at it and try to replicate the results with my code. interesting.

@AlexBodner
Copy link
Collaborator

great @omkar-334 ! Do you have any notebook or script running on any full dataset? I'm trying to use Tuner and seems that i'm inputting the dataset format incorrectly. I flattened both gts and dets to different directories and im passing the path to both directories, but the metric received is 0.0 (HOTA).

@omkar-334
Copy link
Contributor Author

@SkalskiP here's the colab for testing this out - https://colab.research.google.com/drive/1Y9l8SIYUdRwDChzh73ScobSZ59n0kgZG?usp=sharing

Since we're saving the optuna study as a class variable, the user has the convenience of plotting it or saving it too. I think this is nice.

@AlexBodner you can take a look at this colab notebook

@omkar-334
Copy link
Contributor Author

do you think the dataset handling and flattening should be done by the tuner? ideally it should just work when user plugs in our drive links of the dataset.

@AlexBodner
Copy link
Collaborator

I dont think so, but maybe lets be clear with the expected format (i know it says mot, but lets invite the users to check the detections format of their dataset. For example, dancetrack uses different coordinates and 6 comma separated values instead of the 10 in MOT. So I would specify : # MOT format: , , <bb_x_left>, <bb_y_left>, <bb_width>, <bb_height>, , -1, -1, -1

maybe in the future we provide an utility for converting to MOT17 format

JVSCHANDRADITHYA and others added 6 commits March 11, 2026 13:49
…sMOT support (roboflow#262)

* Added Dataset Manifests

* Dataset Download API

* Added Download Helpers, mds_checksum_verification

* Added Download Tool Logic

* Added Download subparser

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Fixed annotations and types

* fix(pre_commit): 🎨 auto format pre-commit hooks

* refactor(datasets): apply code review fixes to download feature
  - Remove duplicated download logic from scripts/download.py; delegate
    to download_dataset() in datasets/download.py
  - Rename download() to download_dataset() and export from top-level
    trackers package
  - Add persistent ZIP cache (~/.cache/trackers) with MD5 verification
    to avoid re-downloading when output is deleted
  - Replace tqdm with rich.progress for consistent CLI styling
  - Add rich.panel formatting for --list output
  - Fix duplicate copyright header, section-divider comments, stale
    comments in manifest
  - Prefix all internal symbols with underscore (_DATASETS, _download_file,
    _extract_zip, etc.)
  - Add from __future__ import annotations to all new files
  - Add full type annotations and Google-style docstrings
  - Extract magic numbers into named constants
  - Rename abbreviated variables (dst, tmp, zf, ds, c, f)
  - Add requests to pyproject.toml dependencies; remove tqdm
  - Update SportsMOT base URL to sportsmot-v1
  - Add API docs page (docs/api/datasets.md) and mkdocs.yml nav entry

* refactor(datasets): introduce enums, refine API, and improve docs
  - Add Dataset, DatasetSplit, and DatasetAsset str enums to manifest.py
    for type-safe, discoverable dataset identification; export all three
    from top-level trackers package
  - Rename `content` parameter to `asset` across API, CLI, and docs
  - Accept enums, strings, or lists of either for `split` and `asset`
    parameters in download_dataset
  - Extract validation logic into _resolve_dataset, _resolve_splits, and
    _resolve_assets helper functions; _resolve_splits now validates that
    requested splits exist
  - Extract _normalize_list into trackers/utils/general.py for reuse;
    enum members are converted to plain string values
  - Import _DEFAULT_OUTPUT_DIR and _DEFAULT_CACHE_DIR constants in CLI
    script instead of hardcoding defaults
  - Tighten _DATASETS type annotation from dict[Dataset, dict] to
    dict[Dataset, dict[str, Any]]
  - Trim download_dataset docstring: shorten Args descriptions, condense
    Raises, add enum and string usage examples
  - Add unit tests for _resolve_dataset, _resolve_splits, _resolve_assets,
    and _normalize_list using parametrized top-level test functions
  - Update docs/learn/download.md with dataset table (license column,
    coming-soon entries), enum-based Python snippets, asset terminology,
    and 80-char CLI line wrapping
  - Consolidate CLI argument tables in docs/learn/track.md into a single
    CLI Reference section with 80-char line wrapping
  - Update mkdocs.yml nav titles to match page headings; reorder entries
  - Add DatasetSplit and DatasetAsset to docs/api/datasets.md

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Piotr Skalski <piotr.skalski92@gmail.com>
…stractor filtering (roboflow#322)

* Rewrite install.md to follow track.md and download.md patterns

* Rewrite evaluate.md, fix GT distractor filtering, and support frameless tracking

* Rewrite index.md to showcase CLI, Python, and evaluation workflows

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Add detection quality guide comparing four detectors on MOT17

* fix(pre_commit): 🎨 auto format pre-commit hooks

* fix(eval): implement MOT Challenge distractor preprocessing (roboflow#323)

* fix(eval): implement MOT Challenge distractor preprocessing in evaluator
  Add Hungarian-matching distractor removal to _prepare_mot_sequence,
  matching the MOT Challenge evaluation protocol used by TrackEval.
  Tracker detections overlapping ignored GT regions (conf==0) are now
  removed before scoring, so they are neither penalized as FP nor
  rewarded as TP.

* refactor(eval): extract helpers from _prepare_mot_sequence and improve readability

Break the monolithic `_prepare_mot_sequence` into focused helper functions:
- `_resolve_num_frames`
- `_build_id_mappings`
- `_extract_ground_truth_frame`
- `_extract_tracker_frame`
- `_remove_distractor_matches`
- `_remap_ids`

Replace cryptic abbreviations with descriptive variable names.
Add inline TrackEval source references.
Remove forbidden module-level docstring.
Replace magic numbers with named constants.

* Finalize detection quality guide and drop IDSW from docs

Fill in all TODOs in `detection-quality.md` with final prose.
Add a Detection Models section with COCmO benchmarks, tabbed single-sequence
and all-sequences CLI snippets, and updated results with verified Colab
numbers for YOLO26 Nano, RF-DETR Nano, and RF-DETR Medium.
Remove YOLOv11 Nano from the guide.

Drop the IDSW column from eval commands and output blocks across:
- `evaluate.md`
- `index.md`
- `detection-quality.md`

Enable `navigation.footer` in `mkdocs.yml` for Previous/Next page buttons.
Align the footer with the page layout via CSS.
Update the copyright year to 2026.

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Add COCO benchmark chart and tracking demo videos to detection quality guide

Embed the RF-DETR latency-accuracy chart in the Detection Models section.

Add per-detector tracking videos for MOT17-13 below each CLI snippet in
Run the Experiment.

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Add RF-DETR + Trackers YouTube callout and trim algorithm table

Link the RF-DETR + Trackers live stream video in `index.md` (below Install)
and `track.md` (below Install, above Quickstart).

Remove BoT-SORT and McByte placeholder rows from the tracking algorithms
table in `index.md`.

* Rewrite README.md to surface CLI, evaluation, and detection quality features

Replace outdated evaluation numbers with verified MOT17 FRCNN results.

Add:
- Download Datasets section
- Detection Quality section
- Documentation link to trackers.roboflow.com

Move the HF Playground section below Algorithms.

Remove BoT-SORT and McByte placeholder rows from the algorithms table.

* Rewrite README.md to surface more Trackers features

Expand the algorithms table with HOTA scores across four benchmarks:
- MOT17
- SportsMOT
- SoccerNet
- DanceTrack

Complete the eval output with all seven MOT17 val sequences using
verified numbers.

Add:
- Dataset table from the download guide
- RF-DETR + Trackers YouTube callout
- Links to docs pages for install, tracking, evaluation, download,
  and tracker comparison

Move the HF Playground section below Algorithms.

Remove BoT-SORT and McByte placeholder rows from the algorithms table.

* Update README.md structure and algorithms table

Move the Algorithms section above Evaluate.

Update the algorithms table:
- Add a Class column with Python class names
- Restore BoT-SORT and McByte as "coming soon"

Remove:
- Interactive command builder reference
- `--output` flag from the download command

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Polish README.md algorithms table and add missing links

Update the algorithms table:
- Add a Description column with one-sentence tracker summaries
- Move "Coming soon" to the description for BoT-SORT and McByte
- Use dashes in metric columns for those rows
- Remove the Class column

Add a link from "Track from Python" to the documentation.

Break the download command into multiple lines for readability.

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Polish README.md algorithms table and add missing links

Update the algorithms table:
- Add a Description column with one-sentence tracker summaries
- Move "Coming soon" to the description for BoT-SORT and McByte
- Use dashes in metric columns for those rows
- Remove the Class column

Add a link from "Track from Python" to the documentation.

Break the download command into multiple lines for readability.

* fix(pre_commit): 🎨 auto format pre-commit hooks

* Polish README.md algorithms table and add missing links

Update the algorithms table:
- Add a Description column with one-sentence tracker summaries
- Move "Coming soon" to the description for BoT-SORT and McByte
- Use dashes in metric columns for those rows
- Remove the Class column

Add a link from "Track from Python" to the documentation.

Break the download command into multiple lines for readability.

* fix(pre_commit): 🎨 auto format pre-commit hooks

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Release `trackers` 2.3.0 (from 2.3.0rc0).

Update `docs/index.md` to match the README:
- Rewrite CLI and Python section descriptions
- Use the `rfdetr-medium` model
- Fix the Python example (`cap.isOpened`, `tracked` variable)

Update the algorithms table:
- Add tracker descriptions
- Add paper links
- Add DanceTrack HOTA scores
- Correct OC-SORT scores

Add:
- Full eval output for all MOT17 sequences
- Download Datasets section
- Try It section
* add search spaces in trackers

* add validation

* add tests

* update search spaces and fixes

* remove unnecessary tests

* fix errors
@omkar-334 omkar-334 force-pushed the feat/cli/tune-stage2 branch from cf0a877 to 315f502 Compare March 15, 2026 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants