Skip to content

Commit

Permalink
keep reg_w and reg_h unchange if it's already multiply of strides
Browse files Browse the repository at this point in the history
  • Loading branch information
Pandede committed Apr 10, 2024
1 parent 39dcb0c commit 359cd1e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions wpodnet/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,13 @@ def _resize_to_fixed_ratio(self, image: Image.Image, dim_min: int, dim_max: int)
reg_w, reg_h = int(w * factor), int(h * factor)

# Ensure the both width and height are the multiply of `self._stride`
reg_w += self._stride - reg_w % self._stride
reg_h += self._stride - reg_h % self._stride
reg_w_mod = reg_w % self._stride
if reg_w_mod > 0:
reg_w += self._stride - reg_w_mod

reg_h_mod = reg_h % self._stride
if reg_h_mod > 0:
reg_h += self._stride - reg_h % self._stride

return image.resize((reg_w, reg_h))

Expand Down

0 comments on commit 359cd1e

Please sign in to comment.