Skip to content

Commit

Permalink
[fbsync] allow size to be generic Sequence in Resize (#7999)
Browse files Browse the repository at this point in the history
Reviewed By: vmoens

Differential Revision: D50789091

fbshipit-source-id: e9d6cebe293c2c8052b2ae0f731b0a5888309829

Co-authored-by: Nicolas Hug <[email protected]>
Co-authored-by: Nicolas Hug <[email protected]>
  • Loading branch information
3 people authored and facebook-github-bot committed Oct 30, 2023
1 parent bb644e8 commit 31a0e2d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion test/test_transforms_v2_refactored.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ def test_interpolation_int(self, interpolation, make_input):
assert_equal(actual, expected)

def test_transform_unknown_size_error(self):
with pytest.raises(ValueError, match="size can either be an integer or a list or tuple of one or two integers"):
with pytest.raises(ValueError, match="size can either be an integer or a sequence of one or two integers"):
transforms.Resize(size=object())

@pytest.mark.parametrize(
Expand Down
4 changes: 2 additions & 2 deletions torchvision/transforms/v2/_geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ def __init__(

if isinstance(size, int):
size = [size]
elif isinstance(size, (list, tuple)) and len(size) in {1, 2}:
elif isinstance(size, Sequence) and len(size) in {1, 2}:
size = list(size)
else:
raise ValueError(
f"size can either be an integer or a list or tuple of one or two integers, " f"but got {size} instead."
f"size can either be an integer or a sequence of one or two integers, but got {size} instead."
)
self.size = size

Expand Down

0 comments on commit 31a0e2d

Please sign in to comment.