Skip to content

Commit 2f4c88b

Browse files
authored
Merge pull request #329 from roboflow/yolov11-model-upload
Add yolov11 model deploy support
2 parents 7d4357f + 2db07cc commit 2f4c88b

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

roboflow/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from roboflow.models import CLIPModel, GazeModel # noqa: F401
1616
from roboflow.util.general import write_line
1717

18-
__version__ = "1.1.45"
18+
__version__ = "1.1.46"
1919

2020

2121
def check_key(api_key, model, notebook, num_retries=0):

roboflow/core/version.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,8 +459,20 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best
459459
model_path (str): File path to the model weights to be uploaded.
460460
filename (str, optional): The name of the weights file. Defaults to "weights/best.pt".
461461
"""
462-
463-
supported_models = ["yolov5", "yolov7-seg", "yolov8", "yolov9", "yolonas", "paligemma", "yolov10", "florence-2"]
462+
if model_type.startswith("yolo11"):
463+
model_type = model_type.replace("yolo11", "yolov11")
464+
465+
supported_models = [
466+
"yolov5",
467+
"yolov7-seg",
468+
"yolov8",
469+
"yolov9",
470+
"yolonas",
471+
"paligemma",
472+
"yolov10",
473+
"florence-2",
474+
"yolov11",
475+
]
464476

465477
if not any(supported_model in model_type for supported_model in supported_models):
466478
raise (ValueError(f"Model type {model_type} not supported. Supported models are" f" {supported_models}"))
@@ -519,6 +531,19 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best
519531
" Please install it with `pip install torch`"
520532
)
521533

534+
elif "yolov11" in model_type:
535+
try:
536+
import torch
537+
import ultralytics
538+
539+
except ImportError:
540+
raise RuntimeError(
541+
"The ultralytics python package is required to deploy yolov10"
542+
" models. Please install it with `pip install ultralytics`"
543+
)
544+
545+
print_warn_for_wrong_dependencies_versions([("ultralytics", ">=", "8.3.0")], ask_to_continue=True)
546+
522547
model = torch.load(os.path.join(model_path, filename))
523548

524549
if isinstance(model["model"].names, list):
@@ -530,9 +555,9 @@ def deploy(self, model_type: str, model_path: str, filename: str = "weights/best
530555
class_names.sort(key=lambda x: x[0])
531556
class_names = [x[1] for x in class_names]
532557

533-
if "yolov8" in model_type or "yolov10" in model_type:
558+
if "yolov8" in model_type or "yolov10" in model_type or "yolov11" in model_type:
534559
# try except for backwards compatibility with older versions of ultralytics
535-
if "-cls" in model_type or model_type.startswith("yolov10"):
560+
if "-cls" in model_type or model_type.startswith("yolov10") or model_type.startswith("yolov11"):
536561
nc = model["model"].yaml["nc"]
537562
args = model["train_args"]
538563
else:

0 commit comments

Comments
 (0)