@@ -15,20 +15,18 @@ def process(model_type: str, model_path: str, filename: str) -> str:
1515
1616
1717def _get_processor_function (model_type : str ) -> Callable :
18- if model_type .startswith ("yolo11" ):
19- model_type = model_type .replace ("yolo11" , "yolov11" )
20-
2118 supported_models = [
2219 "yolov5" ,
2320 "yolov7-seg" ,
2421 "yolov8" ,
2522 "yolov9" ,
23+ "yolov10" ,
24+ "yolov11" ,
25+ "yolov12" ,
2626 "yolonas" ,
2727 "paligemma" ,
2828 "paligemma2" ,
29- "yolov10" ,
3029 "florence-2" ,
31- "yolov11" ,
3230 ]
3331
3432 if not any (supported_model in model_type for supported_model in supported_models ):
@@ -59,6 +57,9 @@ def _get_processor_function(model_type: str) -> Callable:
5957 if "yolonas" in model_type :
6058 return _process_yolonas
6159
60+ if "yolov12" in model_type :
61+ return _process_yolov12
62+
6263 return _process_yolo
6364
6465
@@ -195,6 +196,46 @@ def _process_yolo(model_type: str, model_path: str, filename: str) -> str:
195196 return zip_file_name
196197
197198
199+ def _process_yolov12 (model_type : str , model_path : str , filename : str ) -> str :
200+ # For YOLOv12, since it uses a special Ultralytics version,
201+ # state dict extraction and model artifacts are handled during model conversion
202+
203+ print (
204+ "Note: Model must be trained using ultralytics from https://github.com/sunsmarterjie/yolov12 "
205+ "or through the Roboflow platform"
206+ )
207+
208+ # Check if model_path exists
209+ if not os .path .exists (model_path ):
210+ raise FileNotFoundError (f"Model path { model_path } does not exist." )
211+
212+ # Find any .pt file in model path
213+ model_files = os .listdir (model_path )
214+ pt_file = next ((f for f in model_files if f .endswith (".pt" )), None )
215+
216+ if pt_file is None :
217+ raise RuntimeError ("No .pt model file found in the provided path" )
218+
219+ # Copy the .pt file to weights.pt if not already named weights.pt
220+ if pt_file != "weights.pt" :
221+ shutil .copy (os .path .join (model_path , pt_file ), os .path .join (model_path , "weights.pt" ))
222+
223+ required_files = ["weights.pt" ]
224+
225+ optional_files = ["results.csv" , "results.png" , "model_artifacts.json" ]
226+
227+ zip_file_name = "roboflow_deploy.zip"
228+ with zipfile .ZipFile (os .path .join (model_path , zip_file_name ), "w" ) as zipMe :
229+ for file in required_files :
230+ zipMe .write (os .path .join (model_path , file ), arcname = file , compress_type = zipfile .ZIP_DEFLATED )
231+
232+ for file in optional_files :
233+ if os .path .exists (os .path .join (model_path , file )):
234+ zipMe .write (os .path .join (model_path , file ), arcname = file , compress_type = zipfile .ZIP_DEFLATED )
235+
236+ return zip_file_name
237+
238+
198239def _process_huggingface (
199240 model_type : str , model_path : str , filename : str = "fine-tuned-paligemma-3b-pt-224.f16.npz"
200241) -> str :
0 commit comments