10
10
11
11
12
12
def process (model_type : str , model_path : str , filename : str ) -> str :
13
+ if model_type .startswith ("yolo11" ):
14
+ model_type = model_type .replace ("yolo11" , "yolov11" )
15
+
16
+ if model_type .startswith ("yolo12" ):
17
+ model_type = model_type .replace ("yolo12" , "yolov12" )
18
+
13
19
processor = _get_processor_function (model_type )
14
20
return processor (model_type , model_path , filename )
15
21
16
22
17
23
def _get_processor_function (model_type : str ) -> Callable :
18
- if model_type .startswith ("yolo11" ):
19
- model_type = model_type .replace ("yolo11" , "yolov11" )
20
-
21
24
supported_models = [
22
25
"yolov5" ,
23
26
"yolov7-seg" ,
24
27
"yolov8" ,
25
28
"yolov9" ,
29
+ "yolov10" ,
30
+ "yolov11" ,
31
+ "yolov12" ,
26
32
"yolonas" ,
27
33
"paligemma" ,
28
34
"paligemma2" ,
29
- "yolov10" ,
30
35
"florence-2" ,
31
- "yolov11" ,
32
36
]
33
37
34
38
if not any (supported_model in model_type for supported_model in supported_models ):
@@ -109,6 +113,18 @@ def _process_yolo(model_type: str, model_path: str, filename: str) -> str:
109
113
110
114
print_warn_for_wrong_dependencies_versions ([("ultralytics" , ">=" , "8.3.0" )], ask_to_continue = True )
111
115
116
+ elif "yolov12" in model_type :
117
+ try :
118
+ import torch
119
+ import ultralytics
120
+ except ImportError :
121
+ raise RuntimeError (
122
+ "The ultralytics python package is required to deploy yolov12"
123
+ " models. Please install it with `pip install ultralytics`"
124
+ )
125
+
126
+ print_warn_for_wrong_dependencies_versions ([("ultralytics" , ">=" , "8.3.78" )], ask_to_continue = True )
127
+
112
128
model = torch .load (os .path .join (model_path , filename ))
113
129
114
130
if isinstance (model ["model" ].names , list ):
@@ -120,9 +136,9 @@ def _process_yolo(model_type: str, model_path: str, filename: str) -> str:
120
136
class_names .sort (key = lambda x : x [0 ])
121
137
class_names = [x [1 ] for x in class_names ]
122
138
123
- if "yolov8" in model_type or "yolov10" in model_type or "yolov11" in model_type :
139
+ if "yolov8" in model_type or "yolov10" in model_type or "yolov11" in model_type or "yolov12" in model_type :
124
140
# try except for backwards compatibility with older versions of ultralytics
125
- if "-cls" in model_type or model_type .startswith ("yolov10" ) or model_type .startswith ("yolov11" ):
141
+ if "-cls" in model_type or model_type .startswith ("yolov10" ) or model_type .startswith ("yolov11" ) or model_type . startswith ( "yolov12" ) :
126
142
nc = model ["model" ].yaml ["nc" ]
127
143
args = model ["train_args" ]
128
144
else :
0 commit comments