From 4be75faf414d7df55e0962df504a1f90af5ad55c Mon Sep 17 00:00:00 2001 From: dbogunowicz Date: Tue, 21 Mar 2023 15:55:20 +0000 Subject: [PATCH 1/2] initial commit --- src/deepsparse/yolo/pipelines.py | 6 ++++++ src/deepsparse/yolo/utils/utils.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/src/deepsparse/yolo/pipelines.py b/src/deepsparse/yolo/pipelines.py index c3866433f3..9ccdbf23df 100644 --- a/src/deepsparse/yolo/pipelines.py +++ b/src/deepsparse/yolo/pipelines.py @@ -163,6 +163,12 @@ class properties into an inference ready onnx file to be compiled by the model_path = model_to_path(self.model_path) if self._image_size is None: self._image_size = get_onnx_expected_image_shape(onnx.load(model_path)) + if self._image_size == (0, 0): + raise ValueError( + "The model does not have a static image size shape." + "Specify the expected image size by passing the" + "`image_size` argument to the pipeline." + ) else: # override model input shape to given image size if isinstance(self._image_size, int): diff --git a/src/deepsparse/yolo/utils/utils.py b/src/deepsparse/yolo/utils/utils.py index 07e7b87ec2..baa4c18721 100644 --- a/src/deepsparse/yolo/utils/utils.py +++ b/src/deepsparse/yolo/utils/utils.py @@ -359,6 +359,8 @@ def modify_yolo_onnx_input_shape( model_input = model.graph.input[0] initial_x, initial_y = get_onnx_expected_image_shape(model) + if initial_x == initial_y == 0: + initial_x, initial_y = image_shape if not (isinstance(initial_x, int) and isinstance(initial_y, int)): return model_path, None # model graph does not have static integer input shape From 4663e1faf00c96ddce3010385bbf08bab5e9da50 Mon Sep 17 00:00:00 2001 From: dbogunowicz <97082108+dbogunowicz@users.noreply.github.com> Date: Tue, 21 Mar 2023 16:59:00 +0100 Subject: [PATCH 2/2] Update src/deepsparse/yolo/pipelines.py --- src/deepsparse/yolo/pipelines.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/deepsparse/yolo/pipelines.py b/src/deepsparse/yolo/pipelines.py index 9ccdbf23df..935fc9a1d4 100644 --- a/src/deepsparse/yolo/pipelines.py +++ b/src/deepsparse/yolo/pipelines.py @@ -165,7 +165,7 @@ class properties into an inference ready onnx file to be compiled by the self._image_size = get_onnx_expected_image_shape(onnx.load(model_path)) if self._image_size == (0, 0): raise ValueError( - "The model does not have a static image size shape." + "The model does not have a static image size shape. " "Specify the expected image size by passing the" "`image_size` argument to the pipeline." )