From 52c96eae0822b72a1f587d9474d2cc0a85c56405 Mon Sep 17 00:00:00 2001 From: Peter Date: Mon, 10 Jun 2024 04:33:16 -0700 Subject: [PATCH] Add support for yolov10 model deploy (#259) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add support for yolov10 model deploy * fix(pre_commit): 🎨 auto format pre-commit hooks * style * Fix elif branch * bump version for yolov10 upload --------- Co-authored-by: SolomonLake Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- roboflow/__init__.py | 2 +- roboflow/core/version.py | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/roboflow/__init__.py b/roboflow/__init__.py index 833aaad8..ca54d67b 100644 --- a/roboflow/__init__.py +++ b/roboflow/__init__.py @@ -14,7 +14,7 @@ from roboflow.models import CLIPModel, GazeModel # noqa: F401 from roboflow.util.general import write_line -__version__ = "1.1.31" +__version__ = "1.1.32" def check_key(api_key, model, notebook, num_retries=0): diff --git a/roboflow/core/version.py b/roboflow/core/version.py index 4cd388eb..e83a1352 100644 --- a/roboflow/core/version.py +++ b/roboflow/core/version.py @@ -433,7 +433,7 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best filename (str, optional): The name of the weights file. Defaults to "weights/best.pt". """ - supported_models = ["yolov5", "yolov7-seg", "yolov8", "yolov9", "yolonas", "paligemma"] + supported_models = ["yolov5", "yolov7-seg", "yolov8", "yolov9", "yolonas", "paligemma", "yolov10"] if not any(supported_model in model_type for supported_model in supported_models): raise (ValueError(f"Model type {model_type} not supported. Supported models are" f" {supported_models}")) @@ -459,6 +459,17 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best print_warn_for_wrong_dependencies_versions([("ultralytics", "==", "8.0.196")], ask_to_continue=True) + elif "yolov10" in model_type: + try: + import torch + import ultralytics + + except ImportError: + raise ( + "The ultralytics python package is required to deploy yolov10" + " models. Please install it with `pip install ultralytics`" + ) + elif "yolov5" in model_type or "yolov7" in model_type or "yolov9" in model_type: try: import torch @@ -479,7 +490,7 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best class_names.sort(key=lambda x: x[0]) class_names = [x[1] for x in class_names] - if "yolov8" in model_type: + if "yolov8" in model_type or "yolov10" in model_type: # try except for backwards compatibility with older versions of ultralytics if "-cls" in model_type: nc = model["model"].yaml["nc"]