diff --git a/test/test_transforms.py b/test/test_transforms.py index 214f2963bfe..cef8d183938 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -2217,10 +2217,6 @@ def test_elastic_transformation(): with pytest.raises(ValueError, match=r"sigma is a sequence its length should be 2"): transforms.ElasticTransform(alpha=2.0, sigma=[1.0, 0.0, 1.0]) - with pytest.warns(UserWarning, match=r"Argument interpolation should be of type InterpolationMode"): - t = transforms.transforms.ElasticTransform(alpha=2.0, sigma=2.0, interpolation=2) - assert t.interpolation == transforms.InterpolationMode.BILINEAR - with pytest.raises(TypeError, match=r"fill should be int or float"): transforms.ElasticTransform(alpha=1.0, sigma=1.0, fill={}) diff --git a/torchvision/transforms/functional.py b/torchvision/transforms/functional.py index abf827a08c7..ae76d4fa47f 100644 --- a/torchvision/transforms/functional.py +++ b/torchvision/transforms/functional.py @@ -34,20 +34,6 @@ class InterpolationMode(Enum): LANCZOS = "lanczos" -# TODO: Once torchscript supports Enums with staticmethod -# this can be put into InterpolationMode as staticmethod -def _interpolation_modes_from_int(i: int) -> InterpolationMode: - inverse_modes_mapping = { - 0: InterpolationMode.NEAREST, - 2: InterpolationMode.BILINEAR, - 3: InterpolationMode.BICUBIC, - 4: InterpolationMode.BOX, - 5: InterpolationMode.HAMMING, - 1: InterpolationMode.LANCZOS, - } - return inverse_modes_mapping[i] - - pil_modes_mapping = { InterpolationMode.NEAREST: 0, InterpolationMode.BILINEAR: 2, @@ -1501,13 +1487,6 @@ def elastic_transform( """ if not torch.jit.is_scripting() and not torch.jit.is_tracing(): _log_api_usage_once(elastic_transform) - # Backward compatibility with integer value - if isinstance(interpolation, int): - warnings.warn( - "Argument interpolation should be of type InterpolationMode instead of int. " - "Please, use InterpolationMode enum." - ) - interpolation = _interpolation_modes_from_int(interpolation) if not isinstance(displacement, torch.Tensor): raise TypeError("Argument displacement should be a Tensor") diff --git a/torchvision/transforms/transforms.py b/torchvision/transforms/transforms.py index 9395ca674f4..bf9f52cf536 100644 --- a/torchvision/transforms/transforms.py +++ b/torchvision/transforms/transforms.py @@ -15,7 +15,7 @@ from ..utils import _log_api_usage_once from . import functional as F -from .functional import _interpolation_modes_from_int, InterpolationMode +from .functional import InterpolationMode __all__ = [ "Compose", @@ -2044,14 +2044,6 @@ def __init__(self, alpha=50.0, sigma=5.0, interpolation=InterpolationMode.BILINE sigma = [sigma[0], sigma[0]] self.sigma = sigma - - # Backward compatibility with integer value - if isinstance(interpolation, int): - warnings.warn( - "Argument interpolation should be of type InterpolationMode instead of int. " - "Please, use InterpolationMode enum." - ) - interpolation = _interpolation_modes_from_int(interpolation) self.interpolation = interpolation if isinstance(fill, (int, float)):