Skip to content

Commit fa5df4c

Browse files
NicolasHugilouzlpmeier
authored andcommitted
[fbsync] proper comparison of input and outpus size before resizing (#7519)
Reviewed By: vmoens Differential Revision: D45523937 fbshipit-source-id: e01d76b0eded5dc71206a523eab95ab06674efea Co-authored-by: Liron <[email protected]> Co-authored-by: Philip Meier <[email protected]>
1 parent 139e53a commit fa5df4c

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

test/test_transforms.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,16 @@ def test_resize_size_equals_small_edge_size(height, width):
463463
assert max(result.size) == max_size
464464

465465

466+
def test_resize_equal_input_output_sizes():
467+
# Regression test for https://github.com/pytorch/vision/issues/7518
468+
height, width = 28, 27
469+
img = Image.new("RGB", size=(width, height))
470+
471+
t = transforms.Resize((height, width), antialias=True)
472+
result = t(img)
473+
assert result is img
474+
475+
466476
class TestPad:
467477
@pytest.mark.parametrize("fill", [85, 85.0])
468478
def test_pad(self, fill):

torchvision/transforms/functional.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def resize(
478478
size = [size]
479479
output_size = _compute_resized_output_size((image_height, image_width), size, max_size)
480480

481-
if (image_height, image_width) == output_size:
481+
if [image_height, image_width] == output_size:
482482
return img
483483

484484
antialias = _check_antialias(img, antialias, interpolation)

0 commit comments

Comments
 (0)