File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed
Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -312,10 +312,20 @@ def torch_wrapper(*args, **kwargs):
312312
313313torch .load = torch_wrapper
314314
315-
316315def load_yolo (model_path : str ):
317- return YOLO (model_path )
318-
316+ try :
317+ # Try the new PyTorch 2.6+ safe loading approach first
318+ with torch .serialization .safe_globals ([DetectionModel ]):
319+ return YOLO (model_path )
320+ except (AttributeError , TypeError ):
321+ # Fallback for older PyTorch versions that don't have safe_globals
322+ # or if safe_globals doesn't accept the DetectionModel class
323+ try :
324+ return YOLO (model_path )
325+ except Exception as e :
326+ # If both methods fail, log the error and re-raise
327+ logging .error (f"[Impact Pack/Subpack] Failed to load YOLO model from { model_path } : { e } " )
328+ raise
319329
320330def inference_bbox (
321331 model ,
You can’t perform that action at this time.
0 commit comments