-
Notifications
You must be signed in to change notification settings - Fork 7.1k
UCF101 Sketchy Fix #4204
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
Open
bjuncek
wants to merge
6
commits into
pytorch:main
Choose a base branch
from
bjuncek:bkorbar/ucf_fix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
UCF101 Sketchy Fix #4204
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
8e76c79
initial commit
1ed7e52
videoclips now support pts_unit as a workaround
bjuncek d437d0d
Merge branch 'master' into bkorbar/ucf_fix
bjuncek 8d019cf
Merge branch 'master' into bkorbar/ucf_fix
bjuncek faeab4f
Merge branch 'master' into bkorbar/ucf_fix
bjuncek 659aeab
Merge branch 'main' into bkorbar/ucf_fix
bjuncek File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,14 +55,15 @@ class _VideoTimestampsDataset(object): | |
pickled when forking. | ||
""" | ||
|
||
def __init__(self, video_paths: List[str]): | ||
def __init__(self, video_paths: List[str], pts_unit: str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the class being private the reason for not having a default value for |
||
self.video_paths = video_paths | ||
self.pts_unit = pts_unit | ||
|
||
def __len__(self): | ||
return len(self.video_paths) | ||
|
||
def __getitem__(self, idx): | ||
return read_video_timestamps(self.video_paths[idx]) | ||
return read_video_timestamps(self.video_paths[idx], pts_unit=self.pts_unit) | ||
|
||
|
||
def _collate_fn(x): | ||
|
@@ -112,10 +113,13 @@ def __init__( | |
_video_max_dimension=0, | ||
_audio_samples=0, | ||
_audio_channels=0, | ||
_pts_unit="pts" | ||
): | ||
|
||
self.video_paths = video_paths | ||
self.num_workers = num_workers | ||
# a hack to avoid rounding errors | ||
self.pts_unit = _pts_unit | ||
|
||
# these options are not valid for pyav backend | ||
self._video_width = _video_width | ||
|
@@ -138,9 +142,8 @@ def _compute_frame_pts(self): | |
# strategy: use a DataLoader to parallelize read_video_timestamps | ||
# so need to create a dummy dataset first | ||
import torch.utils.data | ||
|
||
dl = torch.utils.data.DataLoader( | ||
_VideoTimestampsDataset(self.video_paths), | ||
_VideoTimestampsDataset(self.video_paths, self.pts_unit), | ||
batch_size=16, | ||
num_workers=self.num_workers, | ||
collate_fn=_collate_fn, | ||
|
@@ -327,7 +330,7 @@ def get_clip(self, idx): | |
if backend == "pyav": | ||
start_pts = clip_pts[0].item() | ||
end_pts = clip_pts[-1].item() | ||
video, audio, info = read_video(video_path, start_pts, end_pts) | ||
video, audio, info = read_video(video_path, start_pts, end_pts, pts_unit=self.pts_unit) | ||
else: | ||
info = _probe_video_from_file(video_path) | ||
video_fps = info.video_fps | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary new line, plus
,
at the end would be preferable.