Unverified Commit 0c2373d0 authored by Nicolas Hug's avatar Nicolas Hug Committed by GitHub
Browse files

Remove APIs that were deprecated before 0.8 (#5386)

* Remove APIs that were deprecated before 0.8

* More stuff

* Some more

* oops
parent 97eddc5d
...@@ -119,7 +119,6 @@ Transforms on PIL Image and torch.\*Tensor ...@@ -119,7 +119,6 @@ Transforms on PIL Image and torch.\*Tensor
RandomPerspective RandomPerspective
RandomResizedCrop RandomResizedCrop
RandomRotation RandomRotation
RandomSizedCrop
RandomVerticalFlip RandomVerticalFlip
Resize Resize
TenCrop TenCrop
......
...@@ -982,12 +982,6 @@ class TestFrozenBNT: ...@@ -982,12 +982,6 @@ class TestFrozenBNT:
bn.load_state_dict(state_dict) bn.load_state_dict(state_dict)
torch.testing.assert_close(fbn(x), bn(x), rtol=1e-5, atol=1e-6) torch.testing.assert_close(fbn(x), bn(x), rtol=1e-5, atol=1e-6)
def test_frozenbatchnorm2d_n_arg(self):
"""Ensure a warning is thrown when passing `n` kwarg
(remove this when support of `n` is dropped)"""
with pytest.warns(DeprecationWarning):
ops.misc.FrozenBatchNorm2d(32, eps=1e-5, n=32)
class TestBoxConversion: class TestBoxConversion:
def _get_box_sequences(): def _get_box_sequences():
......
import os import os
import shutil import shutil
import tempfile import tempfile
import warnings
from contextlib import contextmanager from contextlib import contextmanager
from typing import Any, Dict, List, Iterator, Optional, Tuple from typing import Any, Dict, List, Iterator, Optional, Tuple
...@@ -40,18 +39,7 @@ class ImageNet(ImageFolder): ...@@ -40,18 +39,7 @@ class ImageNet(ImageFolder):
targets (list): The class_index value for each image in the dataset targets (list): The class_index value for each image in the dataset
""" """
def __init__(self, root: str, split: str = "train", download: Optional[str] = None, **kwargs: Any) -> None: def __init__(self, root: str, split: str = "train", **kwargs: Any) -> None:
if download is True:
msg = (
"The dataset is no longer publicly accessible. You need to "
"download the archives externally and place them in the root "
"directory."
)
raise RuntimeError(msg)
elif download is False:
msg = "The use of the download flag is deprecated, since the dataset is no longer publicly accessible."
warnings.warn(msg, RuntimeWarning)
root = self.root = os.path.expanduser(root) root = self.root = os.path.expanduser(root)
self.split = verify_str_arg(split, "split", ("train", "val")) self.split = verify_str_arg(split, "split", ("train", "val"))
......
import warnings
from typing import Callable, List, Optional from typing import Callable, List, Optional
import torch import torch
...@@ -7,36 +6,6 @@ from torch import Tensor ...@@ -7,36 +6,6 @@ from torch import Tensor
from ..utils import _log_api_usage_once from ..utils import _log_api_usage_once
class Conv2d(torch.nn.Conv2d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn(
"torchvision.ops.misc.Conv2d is deprecated and will be "
"removed in future versions, use torch.nn.Conv2d instead.",
FutureWarning,
)
class ConvTranspose2d(torch.nn.ConvTranspose2d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn(
"torchvision.ops.misc.ConvTranspose2d is deprecated and will be "
"removed in future versions, use torch.nn.ConvTranspose2d instead.",
FutureWarning,
)
class BatchNorm2d(torch.nn.BatchNorm2d):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
warnings.warn(
"torchvision.ops.misc.BatchNorm2d is deprecated and will be "
"removed in future versions, use torch.nn.BatchNorm2d instead.",
FutureWarning,
)
interpolate = torch.nn.functional.interpolate interpolate = torch.nn.functional.interpolate
...@@ -54,12 +23,7 @@ class FrozenBatchNorm2d(torch.nn.Module): ...@@ -54,12 +23,7 @@ class FrozenBatchNorm2d(torch.nn.Module):
self, self,
num_features: int, num_features: int,
eps: float = 1e-5, eps: float = 1e-5,
n: Optional[int] = None,
): ):
# n=None for backward-compatibility
if n is not None:
warnings.warn("`n` argument is deprecated and has been renamed `num_features`", DeprecationWarning)
num_features = n
super().__init__() super().__init__()
_log_api_usage_once(self) _log_api_usage_once(self)
self.eps = eps self.eps = eps
......
...@@ -438,13 +438,6 @@ def resize( ...@@ -438,13 +438,6 @@ def resize(
return F_t.resize(img, size=size, interpolation=interpolation.value, max_size=max_size, antialias=antialias) return F_t.resize(img, size=size, interpolation=interpolation.value, max_size=max_size, antialias=antialias)
def scale(*args, **kwargs):
if not torch.jit.is_scripting() and not torch.jit.is_tracing():
_log_api_usage_once(scale)
warnings.warn("The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.")
return resize(*args, **kwargs)
def pad(img: Tensor, padding: List[int], fill: int = 0, padding_mode: str = "constant") -> Tensor: def pad(img: Tensor, padding: List[int], fill: int = 0, padding_mode: str = "constant") -> Tensor:
r"""Pad the given image on all sides with the given "pad" value. r"""Pad the given image on all sides with the given "pad" value.
If the image is torch Tensor, it is expected If the image is torch Tensor, it is expected
......
...@@ -3,7 +3,6 @@ from typing import Optional, Tuple, List ...@@ -3,7 +3,6 @@ from typing import Optional, Tuple, List
import torch import torch
from torch import Tensor from torch import Tensor
from torch.jit.annotations import BroadcastingList2
from torch.nn.functional import grid_sample, conv2d, interpolate, pad as torch_pad from torch.nn.functional import grid_sample, conv2d, interpolate, pad as torch_pad
...@@ -249,74 +248,6 @@ def adjust_gamma(img: Tensor, gamma: float, gain: float = 1) -> Tensor: ...@@ -249,74 +248,6 @@ def adjust_gamma(img: Tensor, gamma: float, gain: float = 1) -> Tensor:
return result return result
def center_crop(img: Tensor, output_size: BroadcastingList2[int]) -> Tensor:
"""DEPRECATED"""
warnings.warn(
"This method is deprecated and will be removed in future releases. Please, use ``F.center_crop`` instead."
)
_assert_image_tensor(img)
_, image_width, image_height = img.size()
crop_height, crop_width = output_size
# crop_top = int(round((image_height - crop_height) / 2.))
# Result can be different between python func and scripted func
# Temporary workaround:
crop_top = int((image_height - crop_height + 1) * 0.5)
# crop_left = int(round((image_width - crop_width) / 2.))
# Result can be different between python func and scripted func
# Temporary workaround:
crop_left = int((image_width - crop_width + 1) * 0.5)
return crop(img, crop_top, crop_left, crop_height, crop_width)
def five_crop(img: Tensor, size: BroadcastingList2[int]) -> List[Tensor]:
"""DEPRECATED"""
warnings.warn(
"This method is deprecated and will be removed in future releases. Please, use ``F.five_crop`` instead."
)
_assert_image_tensor(img)
assert len(size) == 2, "Please provide only two dimensions (h, w) for size."
_, image_width, image_height = img.size()
crop_height, crop_width = size
if crop_width > image_width or crop_height > image_height:
msg = "Requested crop size {} is bigger than input size {}"
raise ValueError(msg.format(size, (image_height, image_width)))
tl = crop(img, 0, 0, crop_width, crop_height)
tr = crop(img, image_width - crop_width, 0, image_width, crop_height)
bl = crop(img, 0, image_height - crop_height, crop_width, image_height)
br = crop(img, image_width - crop_width, image_height - crop_height, image_width, image_height)
center = center_crop(img, (crop_height, crop_width))
return [tl, tr, bl, br, center]
def ten_crop(img: Tensor, size: BroadcastingList2[int], vertical_flip: bool = False) -> List[Tensor]:
"""DEPRECATED"""
warnings.warn(
"This method is deprecated and will be removed in future releases. Please, use ``F.ten_crop`` instead."
)
_assert_image_tensor(img)
assert len(size) == 2, "Please provide only two dimensions (h, w) for size."
first_five = five_crop(img, size)
if vertical_flip:
img = vflip(img)
else:
img = hflip(img)
second_five = five_crop(img, size)
return first_five + second_five
def _blend(img1: Tensor, img2: Tensor, ratio: float) -> Tensor: def _blend(img1: Tensor, img2: Tensor, ratio: float) -> Tensor:
ratio = float(ratio) ratio = float(ratio)
bound = 1.0 if img1.is_floating_point() else 255.0 bound = 1.0 if img1.is_floating_point() else 255.0
......
...@@ -26,7 +26,6 @@ __all__ = [ ...@@ -26,7 +26,6 @@ __all__ = [
"ToPILImage", "ToPILImage",
"Normalize", "Normalize",
"Resize", "Resize",
"Scale",
"CenterCrop", "CenterCrop",
"Pad", "Pad",
"Lambda", "Lambda",
...@@ -37,7 +36,6 @@ __all__ = [ ...@@ -37,7 +36,6 @@ __all__ = [
"RandomHorizontalFlip", "RandomHorizontalFlip",
"RandomVerticalFlip", "RandomVerticalFlip",
"RandomResizedCrop", "RandomResizedCrop",
"RandomSizedCrop",
"FiveCrop", "FiveCrop",
"TenCrop", "TenCrop",
"LinearTransformation", "LinearTransformation",
...@@ -355,17 +353,6 @@ class Resize(torch.nn.Module): ...@@ -355,17 +353,6 @@ class Resize(torch.nn.Module):
return self.__class__.__name__ + detail return self.__class__.__name__ + detail
class Scale(Resize):
"""
Note: This transform is deprecated in favor of Resize.
"""
def __init__(self, *args, **kwargs):
warnings.warn("The use of the transforms.Scale transform is deprecated, please use transforms.Resize instead.")
super().__init__(*args, **kwargs)
_log_api_usage_once(self)
class CenterCrop(torch.nn.Module): class CenterCrop(torch.nn.Module):
"""Crops the given image at the center. """Crops the given image at the center.
If the image is torch Tensor, it is expected If the image is torch Tensor, it is expected
...@@ -976,20 +963,6 @@ class RandomResizedCrop(torch.nn.Module): ...@@ -976,20 +963,6 @@ class RandomResizedCrop(torch.nn.Module):
return format_string return format_string
class RandomSizedCrop(RandomResizedCrop):
"""
Note: This transform is deprecated in favor of RandomResizedCrop.
"""
def __init__(self, *args, **kwargs):
warnings.warn(
"The use of the transforms.RandomSizedCrop transform is deprecated, "
+ "please use transforms.RandomResizedCrop instead."
)
super().__init__(*args, **kwargs)
_log_api_usage_once(self)
class FiveCrop(torch.nn.Module): class FiveCrop(torch.nn.Module):
"""Crop the given image into four corners and the central crop. """Crop the given image into four corners and the central crop.
If the image is torch Tensor, it is expected If the image is torch Tensor, it is expected
......
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