Move `task=classify` with `mode=track` warning to tracker `on_predict_start` (#18837)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
pull/18810/merge
Laughing 4 weeks ago committed by GitHub
parent d6272f258e
commit d29023f85f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 7
      ultralytics/cfg/__init__.py
  2. 3
      ultralytics/trackers/track.py

@ -921,12 +921,7 @@ def entrypoint(debug=""):
# Task
task = overrides.pop("task", None)
if task:
if task == "classify" and mode == "track":
raise ValueError(
f"❌ Classification doesn't support 'mode=track'. Valid modes for classification are"
f" {MODES - {'track'}}.\n{CLI_HELP_MSG}"
)
elif task not in TASKS:
if task not in TASKS:
if task == "track":
LOGGER.warning(
"WARNING ⚠ invalid 'task=track', setting 'task=detect' and 'mode=track'. Valid tasks are {TASKS}.\n{CLI_HELP_MSG}."

@ -31,6 +31,9 @@ def on_predict_start(predictor: object, persist: bool = False) -> None:
>>> predictor = SomePredictorClass()
>>> on_predict_start(predictor, persist=True)
"""
if predictor.args.task == "classify":
raise ValueError("❌ Classification doesn't support 'mode=track'")
if hasattr(predictor, "trackers") and persist:
return

Loading…
Cancel
Save