From 800b9402ec2541aa8fa7aad187499cffe6981638 Mon Sep 17 00:00:00 2001 From: Guillem Orellana Trullols Date: Tue, 5 May 2020 20:44:01 +0200 Subject: [PATCH] Update ucf101.py Now the dataset is not working properly because of this line of code `indices = [i for i in range(len(video_list)) if video_list[i][len(self.root) + 1:] in selected_files]`. Performing the `len(self.root) + 1` only make sense if there is no training / to root ``` >>> root = 'data/ucf-101/videos' >>> video_path = 'data/ucf-101/videos/activity/video.avi' >>> video_path [len(root ):] '/activity/video.avi' >>> video_path [len(root ) + 1:] 'activity/video.avi' ``` Appending the root path also to the selected files is a simple solution and make the dataset works with and without a trailing slash. --- torchvision/datasets/ucf101.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torchvision/datasets/ucf101.py b/torchvision/datasets/ucf101.py index 43d8124bd4b..464eb0018f2 100644 --- a/torchvision/datasets/ucf101.py +++ b/torchvision/datasets/ucf101.py @@ -88,10 +88,10 @@ def _select_fold(self, video_list, annotation_path, fold, train): with open(f, "r") as fid: data = fid.readlines() data = [x.strip().split(" ") for x in data] - data = [x[0] for x in data] + data = [os.path.join(self.root, x[0]) for x in data] selected_files.extend(data) selected_files = set(selected_files) - indices = [i for i in range(len(video_list)) if video_list[i][len(self.root) + 1:] in selected_files] + indices = [i for i in range(len(video_list)) if video_list[i] in selected_files] return indices def __len__(self):