@@ -136,14 +136,14 @@ class TestSmoke:
136136 (transforms .RandomCrop ([16 , 16 ], pad_if_needed = True ), None ),
137137 (transforms .RandomHorizontalFlip (p = 1.0 ), None ),
138138 (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 ),
141141 (transforms .RandomRotation (degrees = 30 ), None ),
142- (transforms .RandomShortestSize (min_size = 10 ), None ),
142+ (transforms .RandomShortestSize (min_size = 10 , antialias = True ), None ),
143143 (transforms .RandomVerticalFlip (p = 1.0 ), None ),
144144 (transforms .RandomZoomOut (p = 1.0 ), None ),
145145 (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 ),
147147 (transforms .ClampBoundingBox (), None ),
148148 (transforms .ConvertBoundingBoxFormat (datapoints .BoundingBoxFormat .CXCYWH ), None ),
149149 (transforms .ConvertDtype (), None ),
@@ -1514,7 +1514,7 @@ class TestRandomShortestSize:
15141514 def test__get_params (self , min_size , max_size , mocker ):
15151515 spatial_size = (3 , 10 )
15161516
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 )
15181518
15191519 sample = mocker .MagicMock (spec = datapoints .Image , num_channels = 3 , spatial_size = spatial_size )
15201520 params = transform ._get_params ([sample ])
@@ -1595,7 +1595,7 @@ def test__get_params(self):
15951595 min_size = 3
15961596 max_size = 6
15971597
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 )
15991599
16001600 for _ in range (10 ):
16011601 params = transform ._get_params ([])
@@ -1791,15 +1791,21 @@ def test_classif_preset(image_type, label_type, dataset_return_type, to_tensor):
17911791 else :
17921792 sample = image , label
17931793
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+
17941800 t = transforms .Compose (
17951801 [
1796- transforms .RandomResizedCrop ((224 , 224 )),
1802+ transforms .RandomResizedCrop ((224 , 224 ), antialias = True ),
17971803 transforms .RandomHorizontalFlip (p = 1 ),
17981804 transforms .RandAugment (),
17991805 transforms .TrivialAugmentWide (),
18001806 transforms .AugMix (),
18011807 transforms .AutoAugment (),
1802- to_tensor () ,
1808+ to_tensor ,
18031809 # TODO: ConvertImageDtype is a pass-through on PIL images, is that
18041810 # intended? This results in a failure if we convert to tensor after
18051811 # 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):
18301836@pytest .mark .parametrize ("sanitize" , (True , False ))
18311837def test_detection_preset (image_type , data_augmentation , to_tensor , sanitize ):
18321838 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+
18331846 if data_augmentation == "hflip" :
18341847 t = [
18351848 transforms .RandomHorizontalFlip (p = 1 ),
1836- to_tensor () ,
1849+ to_tensor ,
18371850 transforms .ConvertImageDtype (torch .float ),
18381851 ]
18391852 elif data_augmentation == "lsj" :
@@ -1847,7 +1860,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
18471860 # ),
18481861 transforms .RandomCrop ((1024 , 1024 ), pad_if_needed = True ),
18491862 transforms .RandomHorizontalFlip (p = 1 ),
1850- to_tensor () ,
1863+ to_tensor ,
18511864 transforms .ConvertImageDtype (torch .float ),
18521865 ]
18531866 elif data_augmentation == "multiscale" :
@@ -1856,7 +1869,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
18561869 min_size = (480 , 512 , 544 , 576 , 608 , 640 , 672 , 704 , 736 , 768 , 800 ), max_size = 1333 , antialias = True
18571870 ),
18581871 transforms .RandomHorizontalFlip (p = 1 ),
1859- to_tensor () ,
1872+ to_tensor ,
18601873 transforms .ConvertImageDtype (torch .float ),
18611874 ]
18621875 elif data_augmentation == "ssd" :
@@ -1865,14 +1878,14 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
18651878 transforms .RandomZoomOut (fill = defaultdict (lambda : (123.0 , 117.0 , 104.0 ), {datapoints .Mask : 0 })),
18661879 transforms .RandomIoUCrop (),
18671880 transforms .RandomHorizontalFlip (p = 1 ),
1868- to_tensor () ,
1881+ to_tensor ,
18691882 transforms .ConvertImageDtype (torch .float ),
18701883 ]
18711884 elif data_augmentation == "ssdlite" :
18721885 t = [
18731886 transforms .RandomIoUCrop (),
18741887 transforms .RandomHorizontalFlip (p = 1 ),
1875- to_tensor () ,
1888+ to_tensor ,
18761889 transforms .ConvertImageDtype (torch .float ),
18771890 ]
18781891 if sanitize :
@@ -1907,7 +1920,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
19071920
19081921 out = t (sample )
19091922
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 :
19111924 assert is_simple_tensor (out ["image" ])
19121925 else :
19131926 assert isinstance (out ["image" ], datapoints .Image )
0 commit comments