"vscode:/vscode.git/clone" did not exist on "63e2ba23c6d0422c86b7f86b44aed7d9c40af3f4"
Unverified Commit 21790df9 authored by Philip Meier's avatar Philip Meier Committed by GitHub
Browse files

Update deprecation messages stating APIs will be removed in 0.14 (#5387)



* properly deprecate legacy implementation

* cleanup

* use warning over deprecation directive

* remove patch version

* fix link in Kinetics docstring

* Some more

* fix affine functional tests
Co-authored-by: default avatarNicolas Hug <nicolashug@fb.com>
parent 97f543f3
......@@ -128,6 +128,7 @@ Video classification
:template: class_dataset.rst
HMDB51
Kinetics
Kinetics400
UCF101
......
......@@ -2,6 +2,7 @@ import colorsys
import itertools
import math
import os
import re
from typing import Sequence
import numpy as np
......@@ -23,7 +24,6 @@ from common_utils import (
)
from torchvision.transforms import InterpolationMode
NEAREST, BILINEAR, BICUBIC = InterpolationMode.NEAREST, InterpolationMode.BILINEAR, InterpolationMode.BICUBIC
......@@ -141,7 +141,13 @@ class TestRotate:
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 @@ class TestAffine:
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 @@ class TestAffine:
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.
......
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
......
......@@ -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");
}
......
......@@ -20,7 +20,7 @@ def _dl_wrap(tarpath: str, videopath: str, line: str) -> None:
class Kinetics(VisionDataset):
"""` Generic Kinetics <https://deepmind.com/research/open-source/open-source-datasets/kinetics/>`_
"""`Generic Kinetics <https://deepmind.com/research/open-source/open-source-datasets/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 <https://deepmind.com/research/open-source/open-source-datasets/kinetics/>`_
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 @@ class Kinetics400(Kinetics):
**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(
......
......@@ -23,7 +23,7 @@ model_urls = {
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,
)
......
......@@ -5,6 +5,6 @@ from . import * # noqa: F401, F403
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."
)
......@@ -288,13 +288,11 @@ class MultiScaleRoIAlign(nn.Module):
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 @@ class MultiScaleRoIAlign(nn.Module):
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(
......
......@@ -3,7 +3,10 @@ import warnings
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):
......
......@@ -22,7 +22,10 @@ __all__ = [
]
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):
......
......@@ -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)):
......
......@@ -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 @@ class RandomRotation(torch.nn.Module):
_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 @@ class RandomAffine(torch.nn.Module):
_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 @@ class RandomAffine(torch.nn.Module):
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
......
......@@ -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
......
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