Skip to content

Commit 6a4283b

Browse files
NicolasHugfacebook-github-bot
authored andcommitted
[fbsync] remove videos from test for DatasetFolder (#7216)
Reviewed By: vmoens Differential Revision: D44416280 fbshipit-source-id: 9fc6193628125e8ae2bdc3cddfbaec082d04c396
1 parent de8dc19 commit 6a4283b

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

test/test_datasets.py

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,27 +1528,16 @@ def test_split(self, config):
15281528
class DatasetFolderTestCase(datasets_utils.ImageDatasetTestCase):
15291529
DATASET_CLASS = datasets.DatasetFolder
15301530

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")
15381532

15391533
# DatasetFolder has two mutually exclusive parameters: 'extensions' and 'is_valid_file'. One of both is required.
15401534
# We only iterate over different 'extensions' here and handle the tests for 'is_valid_file' in the
15411535
# 'test_is_valid_file()' method.
15421536
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])
15491538

15501539
def dataset_args(self, tmpdir, config):
1551-
return tmpdir, lambda x: x
1540+
return tmpdir, datasets.folder.pil_loader
15521541

15531542
def inject_fake_data(self, tmpdir, config):
15541543
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):
15591548
if ext not in extensions:
15601549
continue
15611550

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-
15681551
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)
15701553

15711554
num_examples_total += num_examples
15721555
classes.append(cls)

0 commit comments

Comments
 (0)