@@ -1528,27 +1528,16 @@ def test_split(self, config):
1528
1528
class DatasetFolderTestCase (datasets_utils .ImageDatasetTestCase ):
1529
1529
DATASET_CLASS = datasets .DatasetFolder
1530
1530
1531
- # The dataset has no fixed return type since it is defined by the loader parameter. For testing, we use a loader
1532
- # that simply returns the path as type 'str' instead of loading anything. See the 'dataset_args()' method.
1533
- FEATURE_TYPES = (str , int )
1534
-
1535
- _IMAGE_EXTENSIONS = ("jpg" , "png" )
1536
- _VIDEO_EXTENSIONS = ("avi" , "mp4" )
1537
- _EXTENSIONS = (* _IMAGE_EXTENSIONS , * _VIDEO_EXTENSIONS )
1531
+ _EXTENSIONS = ("jpg" , "png" )
1538
1532
1539
1533
# DatasetFolder has two mutually exclusive parameters: 'extensions' and 'is_valid_file'. One of both is required.
1540
1534
# We only iterate over different 'extensions' here and handle the tests for 'is_valid_file' in the
1541
1535
# 'test_is_valid_file()' method.
1542
1536
DEFAULT_CONFIG = dict (extensions = _EXTENSIONS )
1543
- ADDITIONAL_CONFIGS = (
1544
- * datasets_utils .combinations_grid (extensions = [(ext ,) for ext in _IMAGE_EXTENSIONS ]),
1545
- dict (extensions = _IMAGE_EXTENSIONS ),
1546
- * datasets_utils .combinations_grid (extensions = [(ext ,) for ext in _VIDEO_EXTENSIONS ]),
1547
- dict (extensions = _VIDEO_EXTENSIONS ),
1548
- )
1537
+ ADDITIONAL_CONFIGS = datasets_utils .combinations_grid (extensions = [(ext ,) for ext in _EXTENSIONS ])
1549
1538
1550
1539
def dataset_args (self , tmpdir , config ):
1551
- return tmpdir , lambda x : x
1540
+ return tmpdir , datasets . folder . pil_loader
1552
1541
1553
1542
def inject_fake_data (self , tmpdir , config ):
1554
1543
extensions = config ["extensions" ] or self ._is_valid_file_to_extensions (config ["is_valid_file" ])
@@ -1559,14 +1548,8 @@ def inject_fake_data(self, tmpdir, config):
1559
1548
if ext not in extensions :
1560
1549
continue
1561
1550
1562
- create_example_folder = (
1563
- datasets_utils .create_image_folder
1564
- if ext in self ._IMAGE_EXTENSIONS
1565
- else datasets_utils .create_video_folder
1566
- )
1567
-
1568
1551
num_examples = torch .randint (1 , 3 , size = ()).item ()
1569
- create_example_folder (tmpdir , cls , lambda idx : self ._file_name_fn (cls , ext , idx ), num_examples )
1552
+ datasets_utils . create_image_folder (tmpdir , cls , lambda idx : self ._file_name_fn (cls , ext , idx ), num_examples )
1570
1553
1571
1554
num_examples_total += num_examples
1572
1555
classes .append (cls )
0 commit comments