Unverified Commit 44252c81 authored by kylematoba's avatar kylematoba Committed by GitHub
Browse files

Deprecate int as interpolation argument type (#5974)

* Requested here https://github.com/pytorch/vision/pull/5898#discussion_r864765799

.

* Fix tests

* ufmt, not black
Co-authored-by: default avatarPhilip Meier <github.pmeier@posteo.de>
Co-authored-by: default avatarVasilis Vryniotis <datumbox@users.noreply.github.com>
parent 4176556e
...@@ -156,7 +156,13 @@ class TestRotate: ...@@ -156,7 +156,13 @@ class TestRotate:
def test_rotate_interpolation_type(self): def test_rotate_interpolation_type(self):
tensor, _ = _create_data(26, 26) tensor, _ = _create_data(26, 26)
# assert changed type warning # assert changed type warning
with pytest.warns(UserWarning, match=r"Argument interpolation should be of type InterpolationMode"): with pytest.warns(
UserWarning,
match=re.escape(
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please use InterpolationMode enum."
),
):
res1 = F.rotate(tensor, 45, interpolation=2) res1 = F.rotate(tensor, 45, interpolation=2)
res2 = F.rotate(tensor, 45, interpolation=BILINEAR) res2 = F.rotate(tensor, 45, interpolation=BILINEAR)
assert_equal(res1, res2) assert_equal(res1, res2)
...@@ -384,7 +390,13 @@ class TestAffine: ...@@ -384,7 +390,13 @@ class TestAffine:
assert_equal(res1, res2) assert_equal(res1, res2)
# assert changed type warning # assert changed type warning
with pytest.warns(UserWarning, match=r"Argument interpolation should be of type InterpolationMode"): with pytest.warns(
UserWarning,
match=re.escape(
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please use InterpolationMode enum."
),
):
res1 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=2) res1 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=2)
res2 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=BILINEAR) res2 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=BILINEAR)
assert_equal(res1, res2) assert_equal(res1, res2)
...@@ -504,7 +516,13 @@ def test_perspective_interpolation_warning(): ...@@ -504,7 +516,13 @@ def test_perspective_interpolation_warning():
spoints = [[0, 0], [33, 0], [33, 25], [0, 25]] spoints = [[0, 0], [33, 0], [33, 25], [0, 25]]
epoints = [[3, 2], [32, 3], [30, 24], [2, 25]] epoints = [[3, 2], [32, 3], [30, 24], [2, 25]]
tensor = torch.randint(0, 256, (3, 26, 26)) tensor = torch.randint(0, 256, (3, 26, 26))
with pytest.warns(UserWarning, match="Argument interpolation should be of type InterpolationMode"): with pytest.warns(
UserWarning,
match=re.escape(
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please use InterpolationMode enum."
),
):
res1 = F.perspective(tensor, startpoints=spoints, endpoints=epoints, interpolation=2) res1 = F.perspective(tensor, startpoints=spoints, endpoints=epoints, interpolation=2)
res2 = F.perspective(tensor, startpoints=spoints, endpoints=epoints, interpolation=BILINEAR) res2 = F.perspective(tensor, startpoints=spoints, endpoints=epoints, interpolation=BILINEAR)
assert_equal(res1, res2) assert_equal(res1, res2)
...@@ -584,7 +602,13 @@ def test_resize_asserts(device): ...@@ -584,7 +602,13 @@ def test_resize_asserts(device):
tensor, pil_img = _create_data(26, 36, device=device) tensor, pil_img = _create_data(26, 36, device=device)
# assert changed type warning # assert changed type warning
with pytest.warns(UserWarning, match=r"Argument interpolation should be of type InterpolationMode"): with pytest.warns(
UserWarning,
match=re.escape(
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please use InterpolationMode enum."
),
):
res1 = F.resize(tensor, size=32, interpolation=2) res1 = F.resize(tensor, size=32, interpolation=2)
res2 = F.resize(tensor, size=32, interpolation=BILINEAR) res2 = F.resize(tensor, size=32, interpolation=BILINEAR)
......
...@@ -1878,7 +1878,13 @@ def test_random_rotation(): ...@@ -1878,7 +1878,13 @@ def test_random_rotation():
assert t.interpolation == transforms.InterpolationMode.BILINEAR assert t.interpolation == transforms.InterpolationMode.BILINEAR
# assert changed type warning # assert changed type warning
with pytest.warns(UserWarning, match=r"Argument interpolation should be of type InterpolationMode"): with pytest.warns(
UserWarning,
match=re.escape(
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please use InterpolationMode enum."
),
):
t = transforms.RandomRotation((-10, 10), interpolation=2) t = transforms.RandomRotation((-10, 10), interpolation=2)
assert t.interpolation == transforms.InterpolationMode.BILINEAR assert t.interpolation == transforms.InterpolationMode.BILINEAR
...@@ -2233,7 +2239,13 @@ def test_random_affine(): ...@@ -2233,7 +2239,13 @@ def test_random_affine():
assert t.fill == 10 assert t.fill == 10
# assert changed type warning # assert changed type warning
with pytest.warns(UserWarning, match=r"Argument interpolation should be of type InterpolationMode"): with pytest.warns(
UserWarning,
match=re.escape(
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please use InterpolationMode enum."
),
):
t = transforms.RandomAffine(10, interpolation=2) t = transforms.RandomAffine(10, interpolation=2)
assert t.interpolation == transforms.InterpolationMode.BILINEAR assert t.interpolation == transforms.InterpolationMode.BILINEAR
......
...@@ -392,7 +392,8 @@ def resize( ...@@ -392,7 +392,8 @@ def resize(
:class:`torchvision.transforms.InterpolationMode`. :class:`torchvision.transforms.InterpolationMode`.
Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``, Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``,
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported. ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
max_size (int, optional): The maximum allowed for the longer edge of max_size (int, optional): The maximum allowed for the longer edge of
the resized image: if the longer edge of the image is greater the resized image: if the longer edge of the image is greater
than ``max_size`` after being resized according to ``size``, then than ``max_size`` after being resized according to ``size``, then
...@@ -414,8 +415,8 @@ def resize( ...@@ -414,8 +415,8 @@ def resize(
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -572,8 +573,8 @@ def resized_crop( ...@@ -572,8 +573,8 @@ def resized_crop(
:class:`torchvision.transforms.InterpolationMode`. :class:`torchvision.transforms.InterpolationMode`.
Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``, Default is ``InterpolationMode.BILINEAR``. If input is Tensor, only ``InterpolationMode.NEAREST``,
``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported. ``InterpolationMode.BILINEAR`` and ``InterpolationMode.BICUBIC`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
Returns: Returns:
PIL Image or Tensor: Cropped image. PIL Image or Tensor: Cropped image.
""" """
...@@ -652,7 +653,8 @@ def perspective( ...@@ -652,7 +653,8 @@ def perspective(
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed fill (sequence or number, optional): Pixel fill value for the area outside the transformed
image. If given a number, the value is used for all bands respectively. image. If given a number, the value is used for all bands respectively.
...@@ -671,8 +673,8 @@ def perspective( ...@@ -671,8 +673,8 @@ def perspective(
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -1012,7 +1014,8 @@ def rotate( ...@@ -1012,7 +1014,8 @@ def rotate(
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
expand (bool, optional): Optional expansion flag. expand (bool, optional): Optional expansion flag.
If true, expands the output image to make it large enough to hold the entire rotated image. If true, expands the output image to make it large enough to hold the entire rotated image.
If false or omitted, make the output image the same size as the input image. If false or omitted, make the output image the same size as the input image.
...@@ -1048,8 +1051,8 @@ def rotate( ...@@ -1048,8 +1051,8 @@ def rotate(
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -1105,7 +1108,8 @@ def affine( ...@@ -1105,7 +1108,8 @@ def affine(
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
fill (sequence or number, optional): Pixel fill value for the area outside the transformed fill (sequence or number, optional): Pixel fill value for the area outside the transformed
image. If given a number, the value is used for all bands respectively. image. If given a number, the value is used for all bands respectively.
...@@ -1137,8 +1141,8 @@ def affine( ...@@ -1137,8 +1141,8 @@ def affine(
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
......
...@@ -297,7 +297,8 @@ class Resize(torch.nn.Module): ...@@ -297,7 +297,8 @@ class Resize(torch.nn.Module):
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` and If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` and
``InterpolationMode.BICUBIC`` are supported. ``InterpolationMode.BICUBIC`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
max_size (int, optional): The maximum allowed for the longer edge of max_size (int, optional): The maximum allowed for the longer edge of
the resized image: if the longer edge of the image is greater the resized image: if the longer edge of the image is greater
than ``max_size`` after being resized according to ``size``, then than ``max_size`` after being resized according to ``size``, then
...@@ -329,8 +330,8 @@ class Resize(torch.nn.Module): ...@@ -329,8 +330,8 @@ class Resize(torch.nn.Module):
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -754,7 +755,8 @@ class RandomPerspective(torch.nn.Module): ...@@ -754,7 +755,8 @@ class RandomPerspective(torch.nn.Module):
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
fill (sequence or number): Pixel fill value for the area outside the transformed fill (sequence or number): Pixel fill value for the area outside the transformed
image. Default is ``0``. If given a number, the value is used for all bands respectively. image. Default is ``0``. If given a number, the value is used for all bands respectively.
""" """
...@@ -767,8 +769,8 @@ class RandomPerspective(torch.nn.Module): ...@@ -767,8 +769,8 @@ class RandomPerspective(torch.nn.Module):
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -868,8 +870,8 @@ class RandomResizedCrop(torch.nn.Module): ...@@ -868,8 +870,8 @@ class RandomResizedCrop(torch.nn.Module):
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` and If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` and
``InterpolationMode.BICUBIC`` are supported. ``InterpolationMode.BICUBIC`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
""" """
def __init__(self, size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), interpolation=InterpolationMode.BILINEAR): def __init__(self, size, scale=(0.08, 1.0), ratio=(3.0 / 4.0, 4.0 / 3.0), interpolation=InterpolationMode.BILINEAR):
...@@ -887,8 +889,8 @@ class RandomResizedCrop(torch.nn.Module): ...@@ -887,8 +889,8 @@ class RandomResizedCrop(torch.nn.Module):
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -1267,7 +1269,8 @@ class RandomRotation(torch.nn.Module): ...@@ -1267,7 +1269,8 @@ class RandomRotation(torch.nn.Module):
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
expand (bool, optional): Optional expansion flag. expand (bool, optional): Optional expansion flag.
If true, expands the output to make it large enough to hold the entire rotated image. If true, expands the output to make it large enough to hold the entire rotated image.
If false or omitted, make the output image the same size as the input image. If false or omitted, make the output image the same size as the input image.
...@@ -1300,8 +1303,8 @@ class RandomRotation(torch.nn.Module): ...@@ -1300,8 +1303,8 @@ class RandomRotation(torch.nn.Module):
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -1388,7 +1391,8 @@ class RandomAffine(torch.nn.Module): ...@@ -1388,7 +1391,8 @@ class RandomAffine(torch.nn.Module):
interpolation (InterpolationMode): Desired interpolation enum defined by interpolation (InterpolationMode): Desired interpolation enum defined by
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``. :class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported. If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still acceptable. For backward compatibility integer values (e.g. ``PIL.Image[.Resampling].NEAREST``) are still accepted,
but deprecated since 0.13 and will be removed in 0.15. Please use InterpolationMode enum.
fill (sequence or number): Pixel fill value for the area outside the transformed fill (sequence or number): Pixel fill value for the area outside the transformed
image. Default is ``0``. If given a number, the value is used for all bands respectively. image. Default is ``0``. If given a number, the value is used for all bands respectively.
fillcolor (sequence or number, optional): fillcolor (sequence or number, optional):
...@@ -1429,8 +1433,8 @@ class RandomAffine(torch.nn.Module): ...@@ -1429,8 +1433,8 @@ class RandomAffine(torch.nn.Module):
# Backward compatibility with integer value # Backward compatibility with integer value
if isinstance(interpolation, int): if isinstance(interpolation, int):
warnings.warn( warnings.warn(
"Argument interpolation should be of type InterpolationMode instead of int. " "Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
"Please, use InterpolationMode enum." "Please use InterpolationMode enum."
) )
interpolation = _interpolation_modes_from_int(interpolation) interpolation = _interpolation_modes_from_int(interpolation)
...@@ -1727,9 +1731,7 @@ class RandomErasing(torch.nn.Module): ...@@ -1727,9 +1731,7 @@ class RandomErasing(torch.nn.Module):
# cast self.value to script acceptable type # cast self.value to script acceptable type
if isinstance(self.value, (int, float)): if isinstance(self.value, (int, float)):
value = [ value = [self.value]
self.value,
]
elif isinstance(self.value, str): elif isinstance(self.value, str):
value = None value = None
elif isinstance(self.value, tuple): elif isinstance(self.value, tuple):
......
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