Skip to content

Commit 2f1c302

Browse files
committed
Only stretch image to resize if format is Stretch
1 parent 594bff7 commit 2f1c302

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

roboflow/models/object_detection.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,16 @@ def predict( # type: ignore[override]
179179
import cv2
180180
import numpy as np
181181

182+
should_resize = "resize" in self.preprocessing.keys() and "Stretch" in self.preprocessing["resize"]["format"]
183+
182184
if isinstance(image_path, str):
183185
image = Image.open(image_path).convert("RGB")
184186
dimensions = image.size
185187
original_dimensions = copy.deepcopy(dimensions)
186188

187189
# Here we resize the image to the preprocessing settings
188190
# before sending it over the wire
189-
if "resize" in self.preprocessing.keys():
191+
if should_resize:
190192
if dimensions[0] > int(self.preprocessing["resize"]["width"]) or dimensions[1] > int(
191193
self.preprocessing["resize"]["height"]
192194
):
@@ -245,7 +247,7 @@ def predict( # type: ignore[override]
245247
if self.format == "json":
246248
resp_json = resp.json()
247249

248-
if resize and original_dimensions is not None:
250+
if should_resize and original_dimensions is not None:
249251
new_preds = []
250252
for p in resp_json["predictions"]:
251253
p["x"] = int(p["x"] * (int(original_dimensions[0]) / int(self.preprocessing["resize"]["width"])))

0 commit comments

Comments
 (0)