From d943925245dc902a43be7ee3253ec40e11b9c35d Mon Sep 17 00:00:00 2001 From: fatih <34196005+fcakyon@users.noreply.github.com> Date: Thu, 27 Oct 2022 21:00:03 +0200 Subject: [PATCH] better exception handling for hublike loading (#167) --- yolov5/helpers.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/yolov5/helpers.py b/yolov5/helpers.py index 8ed3d9c..13ca325 100644 --- a/yolov5/helpers.py +++ b/yolov5/helpers.py @@ -40,8 +40,12 @@ def load_model(model_path, device=None, autoshape=True, verbose=False): LOGGER.warning('WARNING ⚠️ YOLOv5 SegmentationModel is not yet AutoShape compatible. ' 'You will not be able to run inference with this model.') else: - model = AutoShape(model) # for file/URI/PIL/cv2/np inputs and NMS - except Exception: + try: + model = AutoShape(model) # for file/URI/PIL/cv2/np inputs and NMS + except Exception as e: + LOGGER.warning(f'WARNING ⚠️ autoshape failed: {e}') + except Exception as e: + LOGGER.warning(f'WARNING ⚠️ DetectMultiBackend failed: {e}') model = attempt_load(model_path, device=device, fuse=False) # arbitrary model if not verbose: