@@ -56,7 +56,7 @@ def _get_processor_function(model_type: str) -> Callable:
56
56
57
57
if "yolonas" in model_type :
58
58
return _process_yolonas
59
-
59
+
60
60
if "yolov12" in model_type :
61
61
return _process_yolov12
62
62
@@ -123,11 +123,7 @@ def _process_yolo(model_type: str, model_path: str, filename: str) -> str:
123
123
124
124
if "yolov8" in model_type or "yolov10" in model_type or "yolov11" in model_type :
125
125
# try except for backwards compatibility with older versions of ultralytics
126
- if (
127
- "-cls" in model_type
128
- or model_type .startswith ("yolov10" )
129
- or model_type .startswith ("yolov11" )
130
- ):
126
+ if "-cls" in model_type or model_type .startswith ("yolov10" ) or model_type .startswith ("yolov11" ):
131
127
nc = model ["model" ].yaml ["nc" ]
132
128
args = model ["train_args" ]
133
129
else :
@@ -215,44 +211,27 @@ def _process_yolov12(model_type: str, model_path: str, filename: str) -> str:
215
211
216
212
# Find any .pt file in model path
217
213
model_files = os .listdir (model_path )
218
- pt_file = next ((f for f in model_files if f .endswith (' .pt' )), None )
219
-
214
+ pt_file = next ((f for f in model_files if f .endswith (" .pt" )), None )
215
+
220
216
if pt_file is None :
221
217
raise RuntimeError ("No .pt model file found in the provided path" )
222
218
223
219
# Copy the .pt file to weights.pt if not already named weights.pt
224
220
if pt_file != "weights.pt" :
225
- shutil .copy (
226
- os .path .join (model_path , pt_file ),
227
- os .path .join (model_path , "weights.pt" )
228
- )
221
+ shutil .copy (os .path .join (model_path , pt_file ), os .path .join (model_path , "weights.pt" ))
229
222
230
- required_files = [
231
- "weights.pt"
232
- ]
223
+ required_files = ["weights.pt" ]
233
224
234
- optional_files = [
235
- "results.csv" ,
236
- "results.png" ,
237
- "model_artifacts.json"
238
- ]
225
+ optional_files = ["results.csv" , "results.png" , "model_artifacts.json" ]
239
226
240
227
zip_file_name = "roboflow_deploy.zip"
241
228
with zipfile .ZipFile (os .path .join (model_path , zip_file_name ), "w" ) as zipMe :
242
229
for file in required_files :
243
- zipMe .write (
244
- os .path .join (model_path , file ),
245
- arcname = file ,
246
- compress_type = zipfile .ZIP_DEFLATED
247
- )
248
-
230
+ zipMe .write (os .path .join (model_path , file ), arcname = file , compress_type = zipfile .ZIP_DEFLATED )
231
+
249
232
for file in optional_files :
250
233
if os .path .exists (os .path .join (model_path , file )):
251
- zipMe .write (
252
- os .path .join (model_path , file ),
253
- arcname = file ,
254
- compress_type = zipfile .ZIP_DEFLATED
255
- )
234
+ zipMe .write (os .path .join (model_path , file ), arcname = file , compress_type = zipfile .ZIP_DEFLATED )
256
235
257
236
return zip_file_name
258
237
0 commit comments