"...text-generation-inference.git" did not exist on "f9ee2c41b9664ad299f593ecdb500eba29373d63"
Unverified Commit 14af9de6 authored by Guillem Orellana Trullols's avatar Guillem Orellana Trullols Committed by GitHub
Browse files

Update ucf101.py (#2186)

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.
parent 8c958554
...@@ -88,10 +88,10 @@ class UCF101(VisionDataset): ...@@ -88,10 +88,10 @@ class UCF101(VisionDataset):
with open(f, "r") as fid: with open(f, "r") as fid:
data = fid.readlines() data = fid.readlines()
data = [x.strip().split(" ") for x in data] 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.extend(data)
selected_files = set(selected_files) 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 return indices
def __len__(self): def __len__(self):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment