diff --git a/test/test_transforms_v2_refactored.py b/test/test_transforms_v2_refactored.py index 8530f1d762a..0ac51b114f9 100644 --- a/test/test_transforms_v2_refactored.py +++ b/test/test_transforms_v2_refactored.py @@ -822,7 +822,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( diff --git a/torchvision/transforms/v2/_geometry.py b/torchvision/transforms/v2/_geometry.py index df5d82e75ad..4d3f3fc7fc5 100644 --- a/torchvision/transforms/v2/_geometry.py +++ b/torchvision/transforms/v2/_geometry.py @@ -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