From 7584cd8d02e84e08a26151be8250ab08e19cf844 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Mon, 27 Dec 2021 08:40:44 +0100 Subject: [PATCH] fix UCF101 on Windows --- test/test_datasets.py | 2 +- torchvision/datasets/ucf101.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_datasets.py b/test/test_datasets.py index edda3aeaf64..4095332ba8c 100644 --- a/test/test_datasets.py +++ b/test/test_datasets.py @@ -853,7 +853,7 @@ def _annotation_file_name(self, fold, train): def _create_annotation_file(self, root, name, video_files): with open(pathlib.Path(root) / name, "w") as fh: - fh.writelines(f"{file}\n" for file in sorted(video_files)) + fh.writelines(f"{str(file).replace(os.sep, '/')}\n" for file in sorted(video_files)) class LSUNTestCase(datasets_utils.ImageDatasetTestCase): diff --git a/torchvision/datasets/ucf101.py b/torchvision/datasets/ucf101.py index 950bbc076d2..caf849860e4 100644 --- a/torchvision/datasets/ucf101.py +++ b/torchvision/datasets/ucf101.py @@ -108,7 +108,7 @@ def _select_fold(self, video_list: List[str], annotation_path: str, fold: int, t with open(f) as fid: data = fid.readlines() data = [x.strip().split(" ")[0] for x in data] - data = [os.path.join(self.root, x) for x in data] + data = [os.path.join(self.root, *x.split("/")) for x in data] selected_files.update(data) indices = [i for i in range(len(video_list)) if video_list[i] in selected_files] return indices