Skip to content

Commit bac678c

Browse files
authored
remove functionality scheduled for 0.15 after deprecation (#7176)
1 parent a05d817 commit bac678c

35 files changed

+0
-600
lines changed

test/test_functional_tensor.py

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import itertools
33
import math
44
import os
5-
import re
65
from functools import partial
76
from typing import Sequence
87

@@ -144,20 +143,6 @@ def test_rotate_batch(self, device, dt):
144143
center = (20, 22)
145144
_test_fn_on_batch(batch_tensors, F.rotate, angle=32, interpolation=NEAREST, expand=True, center=center)
146145

147-
def test_rotate_interpolation_type(self):
148-
tensor, _ = _create_data(26, 26)
149-
# assert changed type warning
150-
with pytest.warns(
151-
UserWarning,
152-
match=re.escape(
153-
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
154-
"Please use InterpolationMode enum."
155-
),
156-
):
157-
res1 = F.rotate(tensor, 45, interpolation=2)
158-
res2 = F.rotate(tensor, 45, interpolation=BILINEAR)
159-
assert_equal(res1, res2)
160-
161146

162147
class TestAffine:
163148

@@ -364,22 +349,6 @@ def test_batches(self, device, dt):
364349

365350
_test_fn_on_batch(batch_tensors, F.affine, angle=-43, translate=[-3, 4], scale=1.2, shear=[4.0, 5.0])
366351

367-
@pytest.mark.parametrize("device", cpu_and_gpu())
368-
def test_warnings(self, device):
369-
tensor, pil_img = _create_data(26, 26, device=device)
370-
371-
# assert changed type warning
372-
with pytest.warns(
373-
UserWarning,
374-
match=re.escape(
375-
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
376-
"Please use InterpolationMode enum."
377-
),
378-
):
379-
res1 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=2)
380-
res2 = F.affine(tensor, 45, translate=[0, 0], scale=1.0, shear=[0.0, 0.0], interpolation=BILINEAR)
381-
assert_equal(res1, res2)
382-
383352

384353
def _get_data_dims_and_points_for_perspective():
385354
# Ideally we would parametrize independently over data dims and points, but
@@ -478,23 +447,6 @@ def test_perspective_batch(device, dims_and_points, dt):
478447
)
479448

480449

481-
def test_perspective_interpolation_warning():
482-
# assert changed type warning
483-
spoints = [[0, 0], [33, 0], [33, 25], [0, 25]]
484-
epoints = [[3, 2], [32, 3], [30, 24], [2, 25]]
485-
tensor = torch.randint(0, 256, (3, 26, 26))
486-
with pytest.warns(
487-
UserWarning,
488-
match=re.escape(
489-
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
490-
"Please use InterpolationMode enum."
491-
),
492-
):
493-
res1 = F.perspective(tensor, startpoints=spoints, endpoints=epoints, interpolation=2)
494-
res2 = F.perspective(tensor, startpoints=spoints, endpoints=epoints, interpolation=BILINEAR)
495-
assert_equal(res1, res2)
496-
497-
498450
@pytest.mark.parametrize("device", cpu_and_gpu())
499451
@pytest.mark.parametrize("dt", [None, torch.float32, torch.float64, torch.float16])
500452
@pytest.mark.parametrize(
@@ -568,19 +520,6 @@ def test_resize_asserts(device):
568520

569521
tensor, pil_img = _create_data(26, 36, device=device)
570522

571-
# assert changed type warning
572-
with pytest.warns(
573-
UserWarning,
574-
match=re.escape(
575-
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
576-
"Please use InterpolationMode enum."
577-
),
578-
):
579-
res1 = F.resize(tensor, size=32, interpolation=2)
580-
581-
res2 = F.resize(tensor, size=32, interpolation=BILINEAR)
582-
assert_equal(res1, res2)
583-
584523
for img in (tensor, pil_img):
585524
exp_msg = "max_size should only be passed if size specifies the length of the smaller edge"
586525
with pytest.raises(ValueError, match=exp_msg):

test/test_prototype_transforms_consistency.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,6 @@ def __init__(
8787
ArgsKwargs((32, 29)),
8888
ArgsKwargs((31, 28), interpolation=prototype_transforms.InterpolationMode.NEAREST),
8989
ArgsKwargs((33, 26), interpolation=prototype_transforms.InterpolationMode.BICUBIC),
90-
# FIXME: these are currently failing, since the new transform only supports the enum. The int input is
91-
# already deprecated and scheduled to be removed in 0.15. Should we support ints on the prototype
92-
# transform? I guess it depends if we roll out before 0.15 or not.
93-
# ArgsKwargs((30, 27), interpolation=0),
94-
# ArgsKwargs((35, 29), interpolation=2),
95-
# ArgsKwargs((34, 25), interpolation=3),
9690
NotScriptableArgsKwargs(31, max_size=32),
9791
ArgsKwargs([31], max_size=32),
9892
NotScriptableArgsKwargs(30, max_size=100),

test/test_transforms.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1872,17 +1872,6 @@ def test_random_rotation():
18721872
# Checking if RandomRotation can be printed as string
18731873
t.__repr__()
18741874

1875-
# assert changed type warning
1876-
with pytest.warns(
1877-
UserWarning,
1878-
match=re.escape(
1879-
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
1880-
"Please use InterpolationMode enum."
1881-
),
1882-
):
1883-
t = transforms.RandomRotation((-10, 10), interpolation=2)
1884-
assert t.interpolation == transforms.InterpolationMode.BILINEAR
1885-
18861875

18871876
def test_random_rotation_error():
18881877
# assert fill being either a Sequence or a Number
@@ -2212,17 +2201,6 @@ def test_random_affine():
22122201
t = transforms.RandomAffine(10, interpolation=transforms.InterpolationMode.BILINEAR)
22132202
assert "bilinear" in t.__repr__()
22142203

2215-
# assert changed type warning
2216-
with pytest.warns(
2217-
UserWarning,
2218-
match=re.escape(
2219-
"Argument 'interpolation' of type int is deprecated since 0.13 and will be removed in 0.15. "
2220-
"Please use InterpolationMode enum."
2221-
),
2222-
):
2223-
t = transforms.RandomAffine(10, interpolation=2)
2224-
assert t.interpolation == transforms.InterpolationMode.BILINEAR
2225-
22262204

22272205
def test_elastic_transformation():
22282206
with pytest.raises(TypeError, match=r"alpha should be float or a sequence of floats"):

torchvision/datasets/utils.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,6 @@ def _urlretrieve(url: str, filename: str, chunk_size: int = 1024 * 32) -> None:
4848
_save_response_content(iter(lambda: response.read(chunk_size), b""), filename, length=response.length)
4949

5050

51-
def gen_bar_updater() -> Callable[[int, int, int], None]:
52-
warnings.warn("The function `gen_bar_update` is deprecated since 0.13 and will be removed in 0.15.")
53-
pbar = tqdm(total=None)
54-
55-
def bar_update(count, block_size, total_size):
56-
if pbar.total is None and total_size:
57-
pbar.total = total_size
58-
progress_bytes = count * block_size
59-
pbar.update(progress_bytes - pbar.n)
60-
61-
return bar_update
62-
63-
6451
def calculate_md5(fpath: str, chunk_size: int = 1024 * 1024) -> str:
6552
# Setting the `usedforsecurity` flag does not change anything about the functionality, but indicates that we are
6653
# not using the MD5 checksum for cryptography. This enables its usage in restricted environments like FIPS. Without

torchvision/models/alexnet.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,3 @@ def alexnet(*, weights: Optional[AlexNet_Weights] = None, progress: bool = True,
117117
model.load_state_dict(weights.get_state_dict(progress=progress))
118118

119119
return model
120-
121-
122-
# The dictionary below is internal implementation detail and will be removed in v0.15
123-
from ._utils import _ModelURLs
124-
125-
126-
model_urls = _ModelURLs(
127-
{
128-
"alexnet": AlexNet_Weights.IMAGENET1K_V1.url,
129-
}
130-
)

torchvision/models/densenet.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -446,16 +446,3 @@ def densenet201(*, weights: Optional[DenseNet201_Weights] = None, progress: bool
446446
weights = DenseNet201_Weights.verify(weights)
447447

448448
return _densenet(32, (6, 12, 48, 32), 64, weights, progress, **kwargs)
449-
450-
451-
# The dictionary below is internal implementation detail and will be removed in v0.15
452-
from ._utils import _ModelURLs
453-
454-
model_urls = _ModelURLs(
455-
{
456-
"densenet121": DenseNet121_Weights.IMAGENET1K_V1.url,
457-
"densenet169": DenseNet169_Weights.IMAGENET1K_V1.url,
458-
"densenet201": DenseNet201_Weights.IMAGENET1K_V1.url,
459-
"densenet161": DenseNet161_Weights.IMAGENET1K_V1.url,
460-
}
461-
)

torchvision/models/detection/faster_rcnn.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -841,16 +841,3 @@ def fasterrcnn_mobilenet_v3_large_fpn(
841841
trainable_backbone_layers=trainable_backbone_layers,
842842
**kwargs,
843843
)
844-
845-
846-
# The dictionary below is internal implementation detail and will be removed in v0.15
847-
from .._utils import _ModelURLs
848-
849-
850-
model_urls = _ModelURLs(
851-
{
852-
"fasterrcnn_resnet50_fpn_coco": FasterRCNN_ResNet50_FPN_Weights.COCO_V1.url,
853-
"fasterrcnn_mobilenet_v3_large_320_fpn_coco": FasterRCNN_MobileNet_V3_Large_320_FPN_Weights.COCO_V1.url,
854-
"fasterrcnn_mobilenet_v3_large_fpn_coco": FasterRCNN_MobileNet_V3_Large_FPN_Weights.COCO_V1.url,
855-
}
856-
)

torchvision/models/detection/fcos.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -769,14 +769,3 @@ def fcos_resnet50_fpn(
769769
model.load_state_dict(weights.get_state_dict(progress=progress))
770770

771771
return model
772-
773-
774-
# The dictionary below is internal implementation detail and will be removed in v0.15
775-
from .._utils import _ModelURLs
776-
777-
778-
model_urls = _ModelURLs(
779-
{
780-
"fcos_resnet50_fpn_coco": FCOS_ResNet50_FPN_Weights.COCO_V1.url,
781-
}
782-
)

torchvision/models/detection/keypoint_rcnn.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -470,16 +470,3 @@ def keypointrcnn_resnet50_fpn(
470470
overwrite_eps(model, 0.0)
471471

472472
return model
473-
474-
475-
# The dictionary below is internal implementation detail and will be removed in v0.15
476-
from .._utils import _ModelURLs
477-
478-
479-
model_urls = _ModelURLs(
480-
{
481-
# legacy model for BC reasons, see https://github.com/pytorch/vision/issues/1606
482-
"keypointrcnn_resnet50_fpn_coco_legacy": KeypointRCNN_ResNet50_FPN_Weights.COCO_LEGACY.url,
483-
"keypointrcnn_resnet50_fpn_coco": KeypointRCNN_ResNet50_FPN_Weights.COCO_V1.url,
484-
}
485-
)

torchvision/models/detection/mask_rcnn.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -585,14 +585,3 @@ def maskrcnn_resnet50_fpn_v2(
585585
model.load_state_dict(weights.get_state_dict(progress=progress))
586586

587587
return model
588-
589-
590-
# The dictionary below is internal implementation detail and will be removed in v0.15
591-
from .._utils import _ModelURLs
592-
593-
594-
model_urls = _ModelURLs(
595-
{
596-
"maskrcnn_resnet50_fpn_coco": MaskRCNN_ResNet50_FPN_Weights.COCO_V1.url,
597-
}
598-
)

0 commit comments

Comments
 (0)