@@ -183,14 +183,18 @@ def test_combined_targets(self):
183183 ), "Type of the combined target does not match the type of the corresponding individual target: "
184184 f"{ actual } is not { expected } " ,
185185
186+ def test_transforms_v2_wrapper_spawn (self ):
187+ with self .create_dataset (target_type = "category" ) as (dataset , _ ):
188+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
189+
186190
187191class Caltech256TestCase (datasets_utils .ImageDatasetTestCase ):
188192 DATASET_CLASS = datasets .Caltech256
189193
190194 def inject_fake_data (self , tmpdir , config ):
191195 tmpdir = pathlib .Path (tmpdir ) / "caltech256" / "256_ObjectCategories"
192196
193- categories = ((1 , "ak47" ), (127 , "laptop-101 " ), (257 , "clutter " ))
197+ categories = ((1 , "ak47" ), (2 , "american-flag " ), (3 , "backpack " ))
194198 num_images_per_category = 2
195199
196200 for idx , category in categories :
@@ -258,6 +262,10 @@ def inject_fake_data(self, tmpdir, config):
258262
259263 return split_to_num_examples [config ["split" ]]
260264
265+ def test_transforms_v2_wrapper_spawn (self ):
266+ with self .create_dataset () as (dataset , _ ):
267+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
268+
261269
262270class CityScapesTestCase (datasets_utils .ImageDatasetTestCase ):
263271 DATASET_CLASS = datasets .Cityscapes
@@ -382,6 +390,11 @@ def test_feature_types_target_polygon(self):
382390 assert isinstance (polygon_img , PIL .Image .Image )
383391 (polygon_target , info ["expected_polygon_target" ])
384392
393+ def test_transforms_v2_wrapper_spawn (self ):
394+ for target_type in ["instance" , "semantic" , ["instance" , "semantic" ]]:
395+ with self .create_dataset (target_type = target_type ) as (dataset , _ ):
396+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
397+
385398
386399class ImageNetTestCase (datasets_utils .ImageDatasetTestCase ):
387400 DATASET_CLASS = datasets .ImageNet
@@ -413,6 +426,10 @@ def inject_fake_data(self, tmpdir, config):
413426 torch .save ((wnid_to_classes , None ), tmpdir / "meta.bin" )
414427 return num_examples
415428
429+ def test_transforms_v2_wrapper_spawn (self ):
430+ with self .create_dataset () as (dataset , _ ):
431+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
432+
416433
417434class CIFAR10TestCase (datasets_utils .ImageDatasetTestCase ):
418435 DATASET_CLASS = datasets .CIFAR10
@@ -607,6 +624,11 @@ def test_images_names_split(self):
607624
608625 assert merged_imgs_names == all_imgs_names
609626
627+ def test_transforms_v2_wrapper_spawn (self ):
628+ for target_type in ["identity" , "bbox" , ["identity" , "bbox" ]]:
629+ with self .create_dataset (target_type = target_type ) as (dataset , _ ):
630+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
631+
610632
611633class VOCSegmentationTestCase (datasets_utils .ImageDatasetTestCase ):
612634 DATASET_CLASS = datasets .VOCSegmentation
@@ -694,6 +716,10 @@ def add_bndbox(obj, bndbox=None):
694716
695717 return data
696718
719+ def test_transforms_v2_wrapper_spawn (self ):
720+ with self .create_dataset () as (dataset , _ ):
721+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
722+
697723
698724class VOCDetectionTestCase (VOCSegmentationTestCase ):
699725 DATASET_CLASS = datasets .VOCDetection
@@ -714,6 +740,10 @@ def test_annotations(self):
714740
715741 assert object == info ["annotation" ]
716742
743+ def test_transforms_v2_wrapper_spawn (self ):
744+ with self .create_dataset () as (dataset , _ ):
745+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
746+
717747
718748class CocoDetectionTestCase (datasets_utils .ImageDatasetTestCase ):
719749 DATASET_CLASS = datasets .CocoDetection
@@ -784,6 +814,10 @@ def _create_json(self, root, name, content):
784814 json .dump (content , fh )
785815 return file
786816
817+ def test_transforms_v2_wrapper_spawn (self ):
818+ with self .create_dataset () as (dataset , _ ):
819+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
820+
787821
788822class CocoCaptionsTestCase (CocoDetectionTestCase ):
789823 DATASET_CLASS = datasets .CocoCaptions
@@ -800,6 +834,11 @@ def test_captions(self):
800834 _ , captions = dataset [0 ]
801835 assert tuple (captions ) == tuple (info ["captions" ])
802836
837+ def test_transforms_v2_wrapper_spawn (self ):
838+ # We need to define this method, because otherwise the test from the super class will
839+ # be run
840+ pytest .skip ("CocoCaptions is currently not supported by the v2 wrapper." )
841+
803842
804843class UCF101TestCase (datasets_utils .VideoDatasetTestCase ):
805844 DATASET_CLASS = datasets .UCF101
@@ -966,6 +1005,10 @@ def inject_fake_data(self, tmpdir, config):
9661005 )
9671006 return num_videos_per_class * len (classes )
9681007
1008+ def test_transforms_v2_wrapper_spawn (self ):
1009+ with self .create_dataset (output_format = "TCHW" ) as (dataset , _ ):
1010+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
1011+
9691012
9701013class HMDB51TestCase (datasets_utils .VideoDatasetTestCase ):
9711014 DATASET_CLASS = datasets .HMDB51
@@ -1193,6 +1236,10 @@ def _create_segmentation(self, size):
11931236 def _file_stem (self , idx ):
11941237 return f"2008_{ idx :06d} "
11951238
1239+ def test_transforms_v2_wrapper_spawn (self ):
1240+ with self .create_dataset (mode = "segmentation" ) as (dataset , _ ):
1241+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
1242+
11961243
11971244class FakeDataTestCase (datasets_utils .ImageDatasetTestCase ):
11981245 DATASET_CLASS = datasets .FakeData
@@ -1642,6 +1689,10 @@ def inject_fake_data(self, tmpdir, config):
16421689
16431690 return split_to_num_examples [config ["train" ]]
16441691
1692+ def test_transforms_v2_wrapper_spawn (self ):
1693+ with self .create_dataset () as (dataset , _ ):
1694+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
1695+
16451696
16461697class SvhnTestCase (datasets_utils .ImageDatasetTestCase ):
16471698 DATASET_CLASS = datasets .SVHN
@@ -2516,6 +2567,10 @@ def _meta_to_split_and_classification_ann(self, meta, idx):
25162567 breed_id = "-1"
25172568 return (image_id , class_id , species , breed_id )
25182569
2570+ def test_transforms_v2_wrapper_spawn (self ):
2571+ with self .create_dataset () as (dataset , _ ):
2572+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
2573+
25192574
25202575class StanfordCarsTestCase (datasets_utils .ImageDatasetTestCase ):
25212576 DATASET_CLASS = datasets .StanfordCars
0 commit comments