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

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Laughing 2025-01-23 20:52:59 +08:00 committed by GitHub
parent d6272f258e
commit d29023f85f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 6 deletions

View file

@ -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}."

View file

@ -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