"torchvision/git@developer.sourcefind.cn:OpenDAS/vision.git" did not exist on "0fd0f503a14ccf3f51d291c2f89721a7bc36c7b8"
Unverified Commit f33e387f authored by Gu Wang's avatar Gu Wang Committed by GitHub
Browse files

allow size to be generic Sequence in Resize (#7999)


Co-authored-by: default avatarNicolas Hug <contact@nicolas-hug.com>
Co-authored-by: default avatarNicolas Hug <nh.nicolas.hug@gmail.com>
parent a8c4875c
...@@ -699,7 +699,7 @@ class TestResize: ...@@ -699,7 +699,7 @@ class TestResize:
assert_equal(actual, expected) assert_equal(actual, expected)
def test_transform_unknown_size_error(self): 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()) transforms.Resize(size=object())
@pytest.mark.parametrize( @pytest.mark.parametrize(
......
...@@ -135,11 +135,11 @@ class Resize(Transform): ...@@ -135,11 +135,11 @@ class Resize(Transform):
if isinstance(size, int): if isinstance(size, int):
size = [size] 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) size = list(size)
else: else:
raise ValueError( 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 self.size = size
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment