From 590b9ad6559ffdae6413e264a182719af1f1139f Mon Sep 17 00:00:00 2001 From: Muhammad Rizwan Munawar Date: Mon, 13 Jan 2025 16:26:39 +0500 Subject: [PATCH] Warn and set `task=detect` and `mode=track` for `task=track` (#18620) Signed-off-by: Glenn Jocher Co-authored-by: UltralyticsAssistant Co-authored-by: Ultralytics Assistant <135830346+UltralyticsAssistant@users.noreply.github.com> Co-authored-by: Glenn Jocher --- ultralytics/cfg/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ultralytics/cfg/__init__.py b/ultralytics/cfg/__init__.py index bd06af1d..8cb29bc2 100644 --- a/ultralytics/cfg/__init__.py +++ b/ultralytics/cfg/__init__.py @@ -280,7 +280,7 @@ def get_cfg(cfg: Union[str, Path, Dict, SimpleNamespace] = DEFAULT_CFG_DICT, ove Examples: >>> from ultralytics.cfg import get_cfg >>> config = get_cfg() # Load default configuration - >>> config = get_cfg("path/to/config.yaml", overrides={"epochs": 50, "batch_size": 16}) + >>> config_with_overrides = get_cfg("path/to/config.yaml", overrides={"epochs": 50, "batch_size": 16}) Notes: - If both `cfg` and `overrides` are provided, the values in `overrides` will take precedence. @@ -919,7 +919,13 @@ def entrypoint(debug=""): f" {MODES - {'track'}}.\n{CLI_HELP_MSG}" ) elif task not in TASKS: - raise ValueError(f"Invalid 'task={task}'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}") + if task == "track": + LOGGER.warning( + "WARNING ⚠️ invalid 'task=track', setting 'task=detect' and 'mode=track'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}." + ) + task, mode = "detect", "track" + else: + raise ValueError(f"Invalid 'task={task}'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}") if "model" not in overrides: overrides["model"] = TASK2MODEL[task]