From 9b09740ecd35dd978574ab1d9ea31573fba96c70 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 28 Sep 2022 16:19:38 +0200 Subject: [PATCH 1/3] Add SegmentationModel unsupported warning Signed-off-by: Glenn Jocher --- hubconf.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/hubconf.py b/hubconf.py index 4224760a4732..1a3de0703ebd 100644 --- a/hubconf.py +++ b/hubconf.py @@ -30,7 +30,7 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo from models.common import AutoShape, DetectMultiBackend from models.experimental import attempt_load - from models.yolo import ClassificationModel, DetectionModel + from models.yolo import ClassificationModel, DetectionModel, SegmentationModel from utils.downloads import attempt_download from utils.general import LOGGER, check_requirements, intersect_dicts, logging from utils.torch_utils import select_device @@ -47,10 +47,12 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo model = DetectMultiBackend(path, device=device, fuse=autoshape) # detection model if autoshape: if model.pt and isinstance(model.model, ClassificationModel): - LOGGER.warning('WARNING ⚠️ YOLOv5 v6.2 ClassificationModel is not yet AutoShape compatible. ' + LOGGER.warning('WARNING ⚠️ YOLOv5 ClassificationModel is not yet AutoShape compatible. ' 'You must pass torch tensors in BCHW to this model, i.e. shape(1,3,224,224).') - else: - model = AutoShape(model) # for file/URI/PIL/cv2/np inputs and NMS + elif model.pt and isinstance(model.model, SegmentationModel): + LOGGER.warning('WARNING ⚠️ YOLOv5 SegmentationModel is not yet AutoShape compatible.') + else: + model = AutoShape(model) # for file/URI/PIL/cv2/np inputs and NMS except Exception: model = attempt_load(path, device=device, fuse=False) # arbitrary model else: From 4efcca7323c54cb8353bd5cef82af3dc23969094 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 28 Sep 2022 16:22:37 +0200 Subject: [PATCH 2/3] Update hubconf.py Signed-off-by: Glenn Jocher --- hubconf.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hubconf.py b/hubconf.py index 1a3de0703ebd..8d753b33ae47 100644 --- a/hubconf.py +++ b/hubconf.py @@ -50,7 +50,8 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo LOGGER.warning('WARNING ⚠️ YOLOv5 ClassificationModel is not yet AutoShape compatible. ' 'You must pass torch tensors in BCHW to this model, i.e. shape(1,3,224,224).') elif model.pt and isinstance(model.model, SegmentationModel): - LOGGER.warning('WARNING ⚠️ YOLOv5 SegmentationModel is not yet AutoShape compatible.') + 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: From e5d5ef5c64d217fe897367a51307f9d861320b25 Mon Sep 17 00:00:00 2001 From: Glenn Jocher Date: Wed, 28 Sep 2022 16:34:38 +0200 Subject: [PATCH 3/3] Update hubconf.py Signed-off-by: Glenn Jocher --- hubconf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hubconf.py b/hubconf.py index 8d753b33ae47..95b95a5c30cc 100644 --- a/hubconf.py +++ b/hubconf.py @@ -52,8 +52,8 @@ def _create(name, pretrained=True, channels=3, classes=80, autoshape=True, verbo elif model.pt and isinstance(model.model, SegmentationModel): 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 + else: + model = AutoShape(model) # for file/URI/PIL/cv2/np inputs and NMS except Exception: model = attempt_load(path, device=device, fuse=False) # arbitrary model else: