Skip to content

Commit a40d5ed

Browse files
authored
Merge branch 'master' into tests-sbu
2 parents d238159 + b266c2f commit a40d5ed

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

test/test_transforms_video.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
import torch
2-
import torchvision.transforms._transforms_video as transforms
32
from torchvision.transforms import Compose
43
import unittest
54
import random
65
import numpy as np
6+
import warnings
77

88
try:
99
from scipy import stats
1010
except ImportError:
1111
stats = None
1212

1313

14+
with warnings.catch_warnings(record=True):
15+
warnings.simplefilter("always")
16+
import torchvision.transforms._transforms_video as transforms
17+
18+
1419
class TestVideoTransforms(unittest.TestCase):
1520

1621
def test_random_crop_video(self):

torchvision/models/mobilenetv2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import torch
12
from torch import nn
23
from torch import Tensor
34
from .utils import load_state_dict_from_url
@@ -189,8 +190,9 @@ def _forward_impl(self, x: Tensor) -> Tensor:
189190
# This exists since TorchScript doesn't support inheritance, so the superclass method
190191
# (this one) needs to have a name other than `forward` that can be accessed in a subclass
191192
x = self.features(x)
192-
# Cannot use "squeeze" as batch-size can be 1 => must use reshape with x.shape[0]
193-
x = nn.functional.adaptive_avg_pool2d(x, (1, 1)).reshape(x.shape[0], -1)
193+
# Cannot use "squeeze" as batch-size can be 1
194+
x = nn.functional.adaptive_avg_pool2d(x, (1, 1))
195+
x = torch.flatten(x, 1)
194196
x = self.classifier(x)
195197
return x
196198

torchvision/transforms/_functional_video.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
import torch
2+
import warnings
3+
4+
5+
warnings.warn(
6+
"The _functional_video module is deprecated. Please use the functional module instead."
7+
)
28

39

410
def _is_tensor_video_clip(clip):

torchvision/transforms/_transforms_video.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import numbers
44
import random
5+
import warnings
56

67
from torchvision.transforms import (
78
RandomCrop,
@@ -21,6 +22,11 @@
2122
]
2223

2324

25+
warnings.warn(
26+
"The _transforms_video module is deprecated. Please use the transforms module instead."
27+
)
28+
29+
2430
class RandomCropVideo(RandomCrop):
2531
def __init__(self, size):
2632
if isinstance(size, numbers.Number):

0 commit comments

Comments
 (0)