Skip to content

Commit f01b533

Browse files
authored
fix UCF101 on Windows (#5129)
1 parent b5aa091 commit f01b533

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

test/test_datasets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ def _annotation_file_name(self, fold, train):
854854

855855
def _create_annotation_file(self, root, name, video_files):
856856
with open(pathlib.Path(root) / name, "w") as fh:
857-
fh.writelines(f"{file}\n" for file in sorted(video_files))
857+
fh.writelines(f"{str(file).replace(os.sep, '/')}\n" for file in sorted(video_files))
858858

859859

860860
class LSUNTestCase(datasets_utils.ImageDatasetTestCase):

torchvision/datasets/ucf101.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ def _select_fold(self, video_list: List[str], annotation_path: str, fold: int, t
108108
with open(f) as fid:
109109
data = fid.readlines()
110110
data = [x.strip().split(" ")[0] for x in data]
111-
data = [os.path.join(self.root, x) for x in data]
111+
data = [os.path.join(self.root, *x.split("/")) for x in data]
112112
selected_files.update(data)
113113
indices = [i for i in range(len(video_list)) if video_list[i] in selected_files]
114114
return indices

0 commit comments

Comments
 (0)