@@ -136,14 +136,14 @@ class TestSmoke:
136
136
(transforms .RandomCrop ([16 , 16 ], pad_if_needed = True ), None ),
137
137
(transforms .RandomHorizontalFlip (p = 1.0 ), None ),
138
138
(transforms .RandomPerspective (p = 1.0 ), None ),
139
- (transforms .RandomResize (min_size = 10 , max_size = 20 ), None ),
140
- (transforms .RandomResizedCrop ([16 , 16 ]), None ),
139
+ (transforms .RandomResize (min_size = 10 , max_size = 20 , antialias = True ), None ),
140
+ (transforms .RandomResizedCrop ([16 , 16 ], antialias = True ), None ),
141
141
(transforms .RandomRotation (degrees = 30 ), None ),
142
- (transforms .RandomShortestSize (min_size = 10 ), None ),
142
+ (transforms .RandomShortestSize (min_size = 10 , antialias = True ), None ),
143
143
(transforms .RandomVerticalFlip (p = 1.0 ), None ),
144
144
(transforms .RandomZoomOut (p = 1.0 ), None ),
145
145
(transforms .Resize ([16 , 16 ], antialias = True ), None ),
146
- (transforms .ScaleJitter ((16 , 16 ), scale_range = (0.8 , 1.2 )), None ),
146
+ (transforms .ScaleJitter ((16 , 16 ), scale_range = (0.8 , 1.2 ), antialias = True ), None ),
147
147
(transforms .ClampBoundingBox (), None ),
148
148
(transforms .ConvertBoundingBoxFormat (datapoints .BoundingBoxFormat .CXCYWH ), None ),
149
149
(transforms .ConvertDtype (), None ),
@@ -1514,7 +1514,7 @@ class TestRandomShortestSize:
1514
1514
def test__get_params (self , min_size , max_size , mocker ):
1515
1515
spatial_size = (3 , 10 )
1516
1516
1517
- transform = transforms .RandomShortestSize (min_size = min_size , max_size = max_size )
1517
+ transform = transforms .RandomShortestSize (min_size = min_size , max_size = max_size , antialias = True )
1518
1518
1519
1519
sample = mocker .MagicMock (spec = datapoints .Image , num_channels = 3 , spatial_size = spatial_size )
1520
1520
params = transform ._get_params ([sample ])
@@ -1595,7 +1595,7 @@ def test__get_params(self):
1595
1595
min_size = 3
1596
1596
max_size = 6
1597
1597
1598
- transform = transforms .RandomResize (min_size = min_size , max_size = max_size )
1598
+ transform = transforms .RandomResize (min_size = min_size , max_size = max_size , antialias = True )
1599
1599
1600
1600
for _ in range (10 ):
1601
1601
params = transform ._get_params ([])
@@ -1791,15 +1791,21 @@ def test_classif_preset(image_type, label_type, dataset_return_type, to_tensor):
1791
1791
else :
1792
1792
sample = image , label
1793
1793
1794
+ if to_tensor is transforms .ToTensor :
1795
+ with pytest .warns (UserWarning , match = "deprecated and will be removed" ):
1796
+ to_tensor = to_tensor ()
1797
+ else :
1798
+ to_tensor = to_tensor ()
1799
+
1794
1800
t = transforms .Compose (
1795
1801
[
1796
- transforms .RandomResizedCrop ((224 , 224 )),
1802
+ transforms .RandomResizedCrop ((224 , 224 ), antialias = True ),
1797
1803
transforms .RandomHorizontalFlip (p = 1 ),
1798
1804
transforms .RandAugment (),
1799
1805
transforms .TrivialAugmentWide (),
1800
1806
transforms .AugMix (),
1801
1807
transforms .AutoAugment (),
1802
- to_tensor () ,
1808
+ to_tensor ,
1803
1809
# TODO: ConvertImageDtype is a pass-through on PIL images, is that
1804
1810
# intended? This results in a failure if we convert to tensor after
1805
1811
# it, because the image would still be uint8 which make Normalize
@@ -1830,10 +1836,17 @@ def test_classif_preset(image_type, label_type, dataset_return_type, to_tensor):
1830
1836
@pytest .mark .parametrize ("sanitize" , (True , False ))
1831
1837
def test_detection_preset (image_type , data_augmentation , to_tensor , sanitize ):
1832
1838
torch .manual_seed (0 )
1839
+
1840
+ if to_tensor is transforms .ToTensor :
1841
+ with pytest .warns (UserWarning , match = "deprecated and will be removed" ):
1842
+ to_tensor = to_tensor ()
1843
+ else :
1844
+ to_tensor = to_tensor ()
1845
+
1833
1846
if data_augmentation == "hflip" :
1834
1847
t = [
1835
1848
transforms .RandomHorizontalFlip (p = 1 ),
1836
- to_tensor () ,
1849
+ to_tensor ,
1837
1850
transforms .ConvertImageDtype (torch .float ),
1838
1851
]
1839
1852
elif data_augmentation == "lsj" :
@@ -1847,7 +1860,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
1847
1860
# ),
1848
1861
transforms .RandomCrop ((1024 , 1024 ), pad_if_needed = True ),
1849
1862
transforms .RandomHorizontalFlip (p = 1 ),
1850
- to_tensor () ,
1863
+ to_tensor ,
1851
1864
transforms .ConvertImageDtype (torch .float ),
1852
1865
]
1853
1866
elif data_augmentation == "multiscale" :
@@ -1856,7 +1869,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
1856
1869
min_size = (480 , 512 , 544 , 576 , 608 , 640 , 672 , 704 , 736 , 768 , 800 ), max_size = 1333 , antialias = True
1857
1870
),
1858
1871
transforms .RandomHorizontalFlip (p = 1 ),
1859
- to_tensor () ,
1872
+ to_tensor ,
1860
1873
transforms .ConvertImageDtype (torch .float ),
1861
1874
]
1862
1875
elif data_augmentation == "ssd" :
@@ -1865,14 +1878,14 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
1865
1878
transforms .RandomZoomOut (fill = defaultdict (lambda : (123.0 , 117.0 , 104.0 ), {datapoints .Mask : 0 })),
1866
1879
transforms .RandomIoUCrop (),
1867
1880
transforms .RandomHorizontalFlip (p = 1 ),
1868
- to_tensor () ,
1881
+ to_tensor ,
1869
1882
transforms .ConvertImageDtype (torch .float ),
1870
1883
]
1871
1884
elif data_augmentation == "ssdlite" :
1872
1885
t = [
1873
1886
transforms .RandomIoUCrop (),
1874
1887
transforms .RandomHorizontalFlip (p = 1 ),
1875
- to_tensor () ,
1888
+ to_tensor ,
1876
1889
transforms .ConvertImageDtype (torch .float ),
1877
1890
]
1878
1891
if sanitize :
@@ -1907,7 +1920,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
1907
1920
1908
1921
out = t (sample )
1909
1922
1910
- if to_tensor is transforms .ToTensor and image_type is not datapoints .Image :
1923
+ if isinstance ( to_tensor , transforms .ToTensor ) and image_type is not datapoints .Image :
1911
1924
assert is_simple_tensor (out ["image" ])
1912
1925
else :
1913
1926
assert isinstance (out ["image" ], datapoints .Image )
0 commit comments