Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing bug related with trailing slash on UCF-101 dataset. #2186

Merged
merged 1 commit into from
May 7, 2020

Conversation

Guillem96
Copy link
Contributor

@Guillem96 Guillem96 commented May 5, 2020

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 trailing slash to self.root.

Here I attach an example of how this operation can remove an extra letter:

>>> root = 'data/ucf-101/videos'
>>> video_path = 'data/ucf-101/videos/activity/video.avi'
>>> video_path [len(root ) + 1:] # Works well
'activity/video.avi'
>>> root_with_trailing = 'data/ucf-101/videos/'
>>> video_path [len(root_with_trailing) + 1:] # We remove an extra letter
'ctivity/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.

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.
Copy link
Member

@fmassa fmassa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@fmassa fmassa merged commit 14af9de into pytorch:master May 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants