Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix LetterResize bug with imrescale api #105

Merged
merged 10 commits into from
Sep 29, 2022
Prev Previous commit
Next Next commit
fix resize bug
  • Loading branch information
Nioolek committed Sep 29, 2022
commit 337410ec0fe3f55889f703d74216f49a95e5f822
17 changes: 6 additions & 11 deletions mmyolo/datasets/transforms/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,15 +201,11 @@ def _resize_img(self, results: dict):
self.scale[0] / image_shape[0], self.scale[1] / image_shape[1]
] # height, width ratios

# divide padding into 2 sides
padding_h /= 2
padding_w /= 2

if image_shape[::-1] != no_pad_shape:
if image_shape != no_pad_shape:
# compare with no resize and padding size
image = mmcv.imrescale(
image = mmcv.imresize(
image,
no_pad_shape,
(no_pad_shape[1], no_pad_shape[0]),
interpolation=self.interpolation,
backend=self.backend)

Expand All @@ -221,10 +217,9 @@ def _resize_img(self, results: dict):
results['scale_factor'] = scale_factor

# padding
top_padding, bottom_padding = int(round(padding_h - 0.1)), int(
round(padding_h + 0.1))
left_padding, right_padding = int(round(padding_w - 0.1)), int(
round(padding_w + 0.1))
top_padding, left_padding = int(round(padding_h // 2 - 0.1)), int(
round(padding_w // 2 + 0.1))
bottom_padding, right_padding = padding_h - top_padding, padding_w - left_padding

padding_list = [
top_padding, bottom_padding, left_padding, right_padding
Expand Down