Skip to content

Commit c391607

Browse files
[Cherry Pick] Support for dynamic input YOLO models (1.4.2) (#971)
* initial commit * bump version to 1.4.2 --------- Co-authored-by: Benjamin Fineran <[email protected]>
1 parent 9d96eef commit c391607

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

Diff for: src/deepsparse/version.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
from deepsparse.generated_version import is_enterprise, is_release, splash, version
4040
except Exception:
4141
# otherwise, fall back to version info in this file
42-
version = "1.4.1"
42+
version = "1.4.2"
4343
is_release = False
4444
is_enterprise = False
4545
splash = (

Diff for: src/deepsparse/yolo/pipelines.py

+6
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ class properties into an inference ready onnx file to be compiled by the
158158
model_path = model_to_path(self.model_path)
159159
if self._image_size is None:
160160
self._image_size = get_onnx_expected_image_shape(onnx.load(model_path))
161+
if self._image_size == (0, 0):
162+
raise ValueError(
163+
"The model does not have a static image size shape. "
164+
"Specify the expected image size by passing the"
165+
"`image_size` argument to the pipeline."
166+
)
161167
else:
162168
# override model input shape to given image size
163169
if isinstance(self._image_size, int):

Diff for: src/deepsparse/yolo/utils/utils.py

+2
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,8 @@ def modify_yolo_onnx_input_shape(
359359
model_input = model.graph.input[0]
360360

361361
initial_x, initial_y = get_onnx_expected_image_shape(model)
362+
if initial_x == initial_y == 0:
363+
initial_x, initial_y = image_shape
362364

363365
if not (isinstance(initial_x, int) and isinstance(initial_y, int)):
364366
return model_path, None # model graph does not have static integer input shape

Diff for: tests/test_benchmark.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def test_benchmark_help():
7575
),
7676
(
7777
"zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/base-none",
78-
["-pin", "numa"],
78+
["-pin", "numa", "-shapes", "[1,3,640,640]"],
7979
),
8080
(
8181
"zoo:cv/detection/yolov5-s/pytorch/ultralytics/coco/pruned-aggressive_96",

0 commit comments

Comments
 (0)