File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff 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" ])))
You can’t perform that action at this time.
0 commit comments