@@ -183,8 +183,9 @@ def test_combined_targets(self):
183
183
), "Type of the combined target does not match the type of the corresponding individual target: "
184
184
f"{ actual } is not { expected } " ,
185
185
186
- def test_transforms_v2_wrapper (self ):
187
- datasets_utils .check_transforms_v2_wrapper (self , config = dict (target_type = "category" ))
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 )
188
189
189
190
190
191
class Caltech256TestCase (datasets_utils .ImageDatasetTestCase ):
@@ -261,8 +262,9 @@ def inject_fake_data(self, tmpdir, config):
261
262
262
263
return split_to_num_examples [config ["split" ]]
263
264
264
- def test_transforms_v2_wrapper (self ):
265
- datasets_utils .check_transforms_v2_wrapper (self , supports_target_keys = True )
265
+ def test_transforms_v2_wrapper_spawn (self ):
266
+ with self .create_dataset () as (dataset , _ ):
267
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
266
268
267
269
268
270
class CityScapesTestCase (datasets_utils .ImageDatasetTestCase ):
@@ -388,9 +390,10 @@ def test_feature_types_target_polygon(self):
388
390
assert isinstance (polygon_img , PIL .Image .Image )
389
391
(polygon_target , info ["expected_polygon_target" ])
390
392
391
- def test_transforms_v2_wrapper (self ):
393
+ def test_transforms_v2_wrapper_spawn (self ):
392
394
for target_type in ["instance" , "semantic" , ["instance" , "semantic" ]]:
393
- datasets_utils .check_transforms_v2_wrapper (self , config = dict (target_type = target_type ))
395
+ with self .create_dataset (target_type = target_type ) as (dataset , _ ):
396
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
394
397
395
398
396
399
class ImageNetTestCase (datasets_utils .ImageDatasetTestCase ):
@@ -423,8 +426,9 @@ def inject_fake_data(self, tmpdir, config):
423
426
torch .save ((wnid_to_classes , None ), tmpdir / "meta.bin" )
424
427
return num_examples
425
428
426
- def test_transforms_v2_wrapper (self ):
427
- datasets_utils .check_transforms_v2_wrapper (self )
429
+ def test_transforms_v2_wrapper_spawn (self ):
430
+ with self .create_dataset () as (dataset , _ ):
431
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
428
432
429
433
430
434
class CIFAR10TestCase (datasets_utils .ImageDatasetTestCase ):
@@ -620,9 +624,10 @@ def test_images_names_split(self):
620
624
621
625
assert merged_imgs_names == all_imgs_names
622
626
623
- def test_transforms_v2_wrapper (self ):
627
+ def test_transforms_v2_wrapper_spawn (self ):
624
628
for target_type in ["identity" , "bbox" , ["identity" , "bbox" ]]:
625
- datasets_utils .check_transforms_v2_wrapper (self , config = dict (target_type = target_type ))
629
+ with self .create_dataset (target_type = target_type ) as (dataset , _ ):
630
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
626
631
627
632
628
633
class VOCSegmentationTestCase (datasets_utils .ImageDatasetTestCase ):
@@ -711,8 +716,9 @@ def add_bndbox(obj, bndbox=None):
711
716
712
717
return data
713
718
714
- def test_transforms_v2_wrapper (self ):
715
- datasets_utils .check_transforms_v2_wrapper (self )
719
+ def test_transforms_v2_wrapper_spawn (self ):
720
+ with self .create_dataset () as (dataset , _ ):
721
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
716
722
717
723
718
724
class VOCDetectionTestCase (VOCSegmentationTestCase ):
@@ -734,9 +740,9 @@ def test_annotations(self):
734
740
735
741
assert object == info ["annotation" ]
736
742
737
- def test_transforms_v2_wrapper (self ):
738
- for target_type in [ "identity" , "bbox" , [ "identity" , "bbox" ]] :
739
- datasets_utils .check_transforms_v2_wrapper ( self , supports_target_keys = True )
743
+ def test_transforms_v2_wrapper_spawn (self ):
744
+ with self . create_dataset () as ( dataset , _ ) :
745
+ datasets_utils .check_transforms_v2_wrapper_spawn ( dataset )
740
746
741
747
742
748
class CocoDetectionTestCase (datasets_utils .ImageDatasetTestCase ):
@@ -808,8 +814,9 @@ def _create_json(self, root, name, content):
808
814
json .dump (content , fh )
809
815
return file
810
816
811
- def test_transforms_v2_wrapper (self ):
812
- datasets_utils .check_transforms_v2_wrapper (self , supports_target_keys = True )
817
+ def test_transforms_v2_wrapper_spawn (self ):
818
+ with self .create_dataset () as (dataset , _ ):
819
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
813
820
814
821
815
822
class CocoCaptionsTestCase (CocoDetectionTestCase ):
@@ -827,7 +834,7 @@ def test_captions(self):
827
834
_ , captions = dataset [0 ]
828
835
assert tuple (captions ) == tuple (info ["captions" ])
829
836
830
- def test_transforms_v2_wrapper (self ):
837
+ def test_transforms_v2_wrapper_spawn (self ):
831
838
# We need to define this method, because otherwise the test from the super class will
832
839
# be run
833
840
pytest .skip ("CocoCaptions is currently not supported by the v2 wrapper." )
@@ -998,8 +1005,9 @@ def inject_fake_data(self, tmpdir, config):
998
1005
)
999
1006
return num_videos_per_class * len (classes )
1000
1007
1001
- def test_transforms_v2_wrapper (self ):
1002
- datasets_utils .check_transforms_v2_wrapper (self , config = dict (output_format = "TCHW" ))
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 )
1003
1011
1004
1012
1005
1013
class HMDB51TestCase (datasets_utils .VideoDatasetTestCase ):
@@ -1228,8 +1236,9 @@ def _create_segmentation(self, size):
1228
1236
def _file_stem (self , idx ):
1229
1237
return f"2008_{ idx :06d} "
1230
1238
1231
- def test_transforms_v2_wrapper (self ):
1232
- datasets_utils .check_transforms_v2_wrapper (self , config = dict (mode = "segmentation" ))
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 )
1233
1242
1234
1243
1235
1244
class FakeDataTestCase (datasets_utils .ImageDatasetTestCase ):
@@ -1680,8 +1689,9 @@ def inject_fake_data(self, tmpdir, config):
1680
1689
1681
1690
return split_to_num_examples [config ["train" ]]
1682
1691
1683
- def test_transforms_v2_wrapper (self ):
1684
- datasets_utils .check_transforms_v2_wrapper (self , supports_target_keys = True )
1692
+ def test_transforms_v2_wrapper_spawn (self ):
1693
+ with self .create_dataset () as (dataset , _ ):
1694
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
1685
1695
1686
1696
1687
1697
class SvhnTestCase (datasets_utils .ImageDatasetTestCase ):
@@ -2557,8 +2567,9 @@ def _meta_to_split_and_classification_ann(self, meta, idx):
2557
2567
breed_id = "-1"
2558
2568
return (image_id , class_id , species , breed_id )
2559
2569
2560
- def test_transforms_v2_wrapper (self ):
2561
- datasets_utils .check_transforms_v2_wrapper (self )
2570
+ def test_transforms_v2_wrapper_spawn (self ):
2571
+ with self .create_dataset () as (dataset , _ ):
2572
+ datasets_utils .check_transforms_v2_wrapper_spawn (dataset )
2562
2573
2563
2574
2564
2575
class StanfordCarsTestCase (datasets_utils .ImageDatasetTestCase ):
0 commit comments