Skip to content

Commit

Permalink
Add support for yolov10 model deploy (#259)
Browse files Browse the repository at this point in the history
* 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 <lakegh@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Jun 10, 2024
1 parent 76b4483 commit 52c96ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
2 changes: 1 addition & 1 deletion roboflow/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
15 changes: 13 additions & 2 deletions roboflow/core/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"))
Expand All @@ -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
Expand All @@ -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"]
Expand Down

0 comments on commit 52c96ea

Please sign in to comment.