diff --git a/docs/source/datasets.rst b/docs/source/datasets.rst index 717142bb22d..bc0864083e0 100644 --- a/docs/source/datasets.rst +++ b/docs/source/datasets.rst @@ -128,6 +128,7 @@ Video classification :template: class_dataset.rst HMDB51 + Kinetics Kinetics400 UCF101 diff --git a/test/test_functional_tensor.py b/test/test_functional_tensor.py index b4807c11f51..11fa851ed21 100644 --- a/test/test_functional_tensor.py +++ b/test/test_functional_tensor.py @@ -2,6 +2,7 @@ import itertools import math import os +import re from typing import Sequence import numpy as np @@ -23,7 +24,6 @@ ) from torchvision.transforms import InterpolationMode - NEAREST, BILINEAR, BICUBIC = InterpolationMode.NEAREST, InterpolationMode.BILINEAR, InterpolationMode.BICUBIC @@ -141,7 +141,13 @@ def test_rotate_batch(self, device, dt): def test_rotate_deprecation_resample(self): tensor, _ = _create_data(26, 26) # assert deprecation warning and non-BC - with pytest.warns(UserWarning, match=r"Argument resample is deprecated and will be removed"): + with pytest.warns( + UserWarning, + match=re.escape( + "The parameter 'resample' is deprecated since 0.12 and will be removed 0.14. " + "Please use 'interpolation' instead." + ), + ): res1 = F.rotate(tensor, 45, resample=2) res2 = F.rotate(tensor, 45, interpolation=BILINEAR) assert_equal(res1, res2) @@ -365,7 +371,13 @@ def test_warnings(self, device): tensor, pil_img = _create_data(26, 26, device=device) # assert deprecation warning and non-BC - with pytest.warns(UserWarning, match=r"Argument resample is deprecated and will be removed"): + with pytest.warns( + UserWarning, + match=re.escape( + "The parameter 'resample' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'interpolation' instead." + ), + ): res1 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], resample=2) res2 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=BILINEAR) assert_equal(res1, res2) @@ -376,7 +388,13 @@ def test_warnings(self, device): res2 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=BILINEAR) assert_equal(res1, res2) - with pytest.warns(UserWarning, match=r"Argument fillcolor is deprecated and will be removed"): + with pytest.warns( + UserWarning, + match=re.escape( + "The parameter 'fillcolor' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'fill' instead." + ), + ): res1 = F.affine(pil_img, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], fillcolor=10) res2 = F.affine(pil_img, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], fill=10) # we convert the PIL images to numpy as assert_equal doesn't work on PIL images. diff --git a/test/test_transforms.py b/test/test_transforms.py index 41aafa5e271..160e4407d8b 100644 --- a/test/test_transforms.py +++ b/test/test_transforms.py @@ -1,6 +1,7 @@ import math import os import random +import re from functools import partial import numpy as np @@ -1828,7 +1829,13 @@ def test_random_rotation(): t.__repr__() # assert deprecation warning and non-BC - with pytest.warns(UserWarning, match=r"Argument resample is deprecated and will be removed"): + with pytest.warns( + UserWarning, + match=re.escape( + "The parameter 'resample' is deprecated since 0.12 and will be removed 0.14. " + "Please use 'interpolation' instead." + ), + ): t = transforms.RandomRotation((-10, 10), resample=2) assert t.interpolation == transforms.InterpolationMode.BILINEAR @@ -2167,11 +2174,23 @@ def test_random_affine(): assert "bilinear" in t.__repr__() # assert deprecation warning and non-BC - with pytest.warns(UserWarning, match=r"Argument resample is deprecated and will be removed"): + with pytest.warns( + UserWarning, + match=re.escape( + "The parameter 'resample' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'interpolation' instead." + ), + ): t = transforms.RandomAffine(10, resample=2) assert t.interpolation == transforms.InterpolationMode.BILINEAR - with pytest.warns(UserWarning, match=r"Argument fillcolor is deprecated and will be removed"): + with pytest.warns( + UserWarning, + match=re.escape( + "The parameter 'fillcolor' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'fill' instead." + ), + ): t = transforms.RandomAffine(10, fillcolor=10) assert t.fill == 10 diff --git a/torchvision/csrc/models/modelsimpl.h b/torchvision/csrc/models/modelsimpl.h index d4227647804..365726426be 100644 --- a/torchvision/csrc/models/modelsimpl.h +++ b/torchvision/csrc/models/modelsimpl.h @@ -36,8 +36,8 @@ inline bool double_compare(double a, double b) { inline void deprecation_warning() { TORCH_WARN_ONCE( - "The vision::models namespace is not actively maintained, use at " - "your own discretion. We recommend using Torch Script instead: " + "The vision::models namespace is deprecated since 0.12 and will be " + "removed in 0.14. We recommend using Torch Script instead: " "https://pytorch.org/tutorials/advanced/cpp_export.html"); } diff --git a/torchvision/datasets/kinetics.py b/torchvision/datasets/kinetics.py index 64111e4f475..189142a5e67 100644 --- a/torchvision/datasets/kinetics.py +++ b/torchvision/datasets/kinetics.py @@ -20,7 +20,7 @@ def _dl_wrap(tarpath: str, videopath: str, line: str) -> None: class Kinetics(VisionDataset): - """` Generic Kinetics `_ + """`Generic Kinetics `_ dataset. Kinetics-400/600/700 are action recognition video datasets. @@ -49,6 +49,7 @@ class Kinetics(VisionDataset): │ ├── class2 │ │ ├── clipx.mp4 │ │ └── ... + Note: split is appended automatically using the split argument. frames_per_clip (int): number of frames in a clip num_classes (int): select between Kinetics-400 (default), Kinetics-600, and Kinetics-700 @@ -247,6 +248,10 @@ class Kinetics400(Kinetics): `Kinetics-400 `_ dataset. + .. warning:: + This class was deprecated in ``0.12`` and will be removed in ``0.14``. Please use + ``Kinetics(..., num_classes='400')`` instead. + Kinetics-400 is an action recognition video dataset. This dataset consider every video as a collection of video clips of fixed size, specified by ``frames_per_clip``, where the step in frames between each clip is given by @@ -300,8 +305,8 @@ def __init__( **kwargs: Any, ) -> None: warnings.warn( - "Kinetics400 is deprecated and will be removed in a future release." - 'It was replaced by Kinetics(..., num_classes="400").' + "The Kinetics400 class is deprecated since 0.12 and will be removed in 0.14." + "Please use Kinetics(..., num_classes='400') instead." ) if any(value is not None for value in (num_classes, split, download, num_download_workers)): raise RuntimeError( diff --git a/torchvision/models/mobilenetv2.py b/torchvision/models/mobilenetv2.py index 1a470953df5..e24c5962d7e 100644 --- a/torchvision/models/mobilenetv2.py +++ b/torchvision/models/mobilenetv2.py @@ -23,7 +23,7 @@ class _DeprecatedConvBNAct(ConvNormActivation): def __init__(self, *args, **kwargs): warnings.warn( - "The ConvBNReLU/ConvBNActivation classes are deprecated and will be removed in future versions. " + "The ConvBNReLU/ConvBNActivation classes are deprecated since 0.12 and will be removed in 0.14. " "Use torchvision.ops.misc.ConvNormActivation instead.", FutureWarning, ) diff --git a/torchvision/models/segmentation/segmentation.py b/torchvision/models/segmentation/segmentation.py index 1c1d56f487c..ea05a0b0b7b 100644 --- a/torchvision/models/segmentation/segmentation.py +++ b/torchvision/models/segmentation/segmentation.py @@ -5,6 +5,6 @@ warnings.warn( - "The 'torchvision.models.segmentation.segmentation' module is deprecated. Please use directly the parent module " - "instead." + "The 'torchvision.models.segmentation.segmentation' module is deprecated since 0.12 and will be removed in " + "0.14. Please use the 'torchvision.models.segmentation' directly instead." ) diff --git a/torchvision/ops/poolers.py b/torchvision/ops/poolers.py index 05cf5e4032e..ceabb77732b 100644 --- a/torchvision/ops/poolers.py +++ b/torchvision/ops/poolers.py @@ -288,13 +288,11 @@ def __init__( self.canonical_level = canonical_level def convert_to_roi_format(self, boxes: List[Tensor]) -> Tensor: - # TODO: deprecate eventually - warnings.warn("`convert_to_roi_format` will no loger be public in future releases.", FutureWarning) + warnings.warn("The 'convert_to_roi_format' method is deprecated since 0.12 and will be removed in 0.14.") return _convert_to_roi_format(boxes) def infer_scale(self, feature: Tensor, original_size: List[int]) -> float: - # TODO: deprecate eventually - warnings.warn("`infer_scale` will no loger be public in future releases.", FutureWarning) + warnings.warn("The 'infer_scale' method is deprecated since 0.12 and will be removed in 0.14.") return _infer_scale(feature, original_size) def setup_setup_scales( @@ -302,8 +300,7 @@ def setup_setup_scales( features: List[Tensor], image_shapes: List[Tuple[int, int]], ) -> None: - # TODO: deprecate eventually - warnings.warn("`setup_setup_scales` will no loger be public in future releases.", FutureWarning) + warnings.warn("The 'setup_setup_scales' method is deprecated since 0.12 and will be removed in 0.14.") self.scales, self.map_levels = _setup_scales(features, image_shapes, self.canonical_scale, self.canonical_level) def forward( diff --git a/torchvision/transforms/_functional_video.py b/torchvision/transforms/_functional_video.py index 56633f9abf6..2ab7adb8af9 100644 --- a/torchvision/transforms/_functional_video.py +++ b/torchvision/transforms/_functional_video.py @@ -3,7 +3,10 @@ import torch -warnings.warn("The _functional_video module is deprecated. Please use the functional module instead.") +warnings.warn( + "The 'torchvision.transforms._functional_video' module is deprecated since 0.12 and will be removed in 0.14. " + "Please use the 'torchvision.transforms.functional' module instead." +) def _is_tensor_video_clip(clip): diff --git a/torchvision/transforms/_transforms_video.py b/torchvision/transforms/_transforms_video.py index 440a75f286c..32fa0191959 100644 --- a/torchvision/transforms/_transforms_video.py +++ b/torchvision/transforms/_transforms_video.py @@ -22,7 +22,10 @@ ] -warnings.warn("The _transforms_video module is deprecated. Please use the transforms module instead.") +warnings.warn( + "The 'torchvision.transforms._transforms_video' module is deprecated since 0.12 and will be removed in 0.14. " + "Please use the 'torchvision.transforms' module instead." +) class RandomCropVideo(RandomCrop): diff --git a/torchvision/transforms/functional.py b/torchvision/transforms/functional.py index 9b063e4b103..7c6aee1f376 100644 --- a/torchvision/transforms/functional.py +++ b/torchvision/transforms/functional.py @@ -1025,6 +1025,10 @@ def rotate( .. note:: In torchscript mode single int/float value is not supported, please use a sequence of length 1: ``[value, ]``. + resample (int, optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``interpolation`` + instead. Returns: PIL Image or Tensor: Rotated image. @@ -1036,7 +1040,8 @@ def rotate( _log_api_usage_once(rotate) if resample is not None: warnings.warn( - "Argument resample is deprecated and will be removed since v0.10.0. Please, use interpolation instead" + "The parameter 'resample' is deprecated since 0.12 and will be removed 0.14. " + "Please use 'interpolation' instead." ) interpolation = _interpolation_modes_from_int(resample) @@ -1107,10 +1112,13 @@ def affine( .. note:: In torchscript mode single int/float value is not supported, please use a sequence of length 1: ``[value, ]``. - fillcolor (sequence, int, float): deprecated argument and will be removed since v0.10.0. - Please use the ``fill`` parameter instead. - resample (int, optional): deprecated argument and will be removed since v0.10.0. - Please use the ``interpolation`` parameter instead. + fillcolor (sequence or number, optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``fill`` instead. + resample (int, optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``interpolation`` + instead. center (sequence, optional): Optional center of rotation. Origin is the upper left corner. Default is the center of the image. @@ -1121,7 +1129,8 @@ def affine( _log_api_usage_once(affine) if resample is not None: warnings.warn( - "Argument resample is deprecated and will be removed since v0.10.0. Please, use interpolation instead" + "The parameter 'resample' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'interpolation' instead." ) interpolation = _interpolation_modes_from_int(resample) @@ -1134,7 +1143,10 @@ def affine( interpolation = _interpolation_modes_from_int(interpolation) if fillcolor is not None: - warnings.warn("Argument fillcolor is deprecated and will be removed since v0.10.0. Please, use fill instead") + warnings.warn( + "The parameter 'fillcolor' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'fill' instead." + ) fill = fillcolor if not isinstance(angle, (int, float)): diff --git a/torchvision/transforms/transforms.py b/torchvision/transforms/transforms.py index 76f7b8b3e79..5fdc8df89f4 100644 --- a/torchvision/transforms/transforms.py +++ b/torchvision/transforms/transforms.py @@ -1272,8 +1272,10 @@ class RandomRotation(torch.nn.Module): Default is the center of the image. fill (sequence or number): Pixel fill value for the area outside the rotated image. Default is ``0``. If given a number, the value is used for all bands respectively. - resample (int, optional): deprecated argument and will be removed since v0.10.0. - Please use the ``interpolation`` parameter instead. + resample (int, optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``interpolation`` + instead. .. _filters: https://pillow.readthedocs.io/en/latest/handbook/concepts.html#filters @@ -1286,7 +1288,8 @@ def __init__( _log_api_usage_once(self) if resample is not None: warnings.warn( - "Argument resample is deprecated and will be removed since v0.10.0. Please, use interpolation instead" + "The parameter 'resample' is deprecated since 0.12 and will be removed 0.14. " + "Please use 'interpolation' instead." ) interpolation = _interpolation_modes_from_int(resample) @@ -1383,10 +1386,13 @@ class RandomAffine(torch.nn.Module): For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable. 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. - fillcolor (sequence or number, optional): deprecated argument and will be removed since v0.10.0. - Please use the ``fill`` parameter instead. - resample (int, optional): deprecated argument and will be removed since v0.10.0. - Please use the ``interpolation`` parameter instead. + fillcolor (sequence or number, optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``fill`` instead. + resample (int, optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``interpolation`` + instead. center (sequence, optional): Optional center of rotation, (x, y). Origin is the upper left corner. Default is the center of the image. @@ -1410,7 +1416,8 @@ def __init__( _log_api_usage_once(self) if resample is not None: warnings.warn( - "Argument resample is deprecated and will be removed since v0.10.0. Please, use interpolation instead" + "The parameter 'resample' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'interpolation' instead." ) interpolation = _interpolation_modes_from_int(resample) @@ -1424,7 +1431,8 @@ def __init__( if fillcolor is not None: warnings.warn( - "Argument fillcolor is deprecated and will be removed since v0.10.0. Please, use fill instead" + "The parameter 'fillcolor' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'fill' instead." ) fill = fillcolor diff --git a/torchvision/utils.py b/torchvision/utils.py index 34e36c553dd..d03802d9a47 100644 --- a/torchvision/utils.py +++ b/torchvision/utils.py @@ -43,6 +43,10 @@ def make_grid( value_range (tuple, optional): tuple (min, max) where min and max are numbers, then these numbers are used to normalize the image. By default, min and max are computed from the tensor. + range (tuple. optional): + .. warning:: + This parameter was deprecated in ``0.12`` and will be removed in ``0.14``. Please use ``value_range`` + instead. scale_each (bool, optional): If ``True``, scale each image in the batch of images separately rather than the (min, max) over all images. Default: ``False``. pad_value (float, optional): Value for the padded pixels. Default: ``0``. @@ -56,8 +60,10 @@ def make_grid( raise TypeError(f"tensor or list of tensors expected, got {type(tensor)}") if "range" in kwargs.keys(): - warning = "range will be deprecated, please use value_range instead." - warnings.warn(warning) + warnings.warn( + "The parameter 'range' is deprecated since 0.12 and will be removed in 0.14. " + "Please use 'value_range' instead." + ) value_range = kwargs["range"] # if list of tensors, convert to a 4D mini-batch Tensor