-
Notifications
You must be signed in to change notification settings - Fork 7.1k
add HMDB51 and UCF101 datasets as well as prototype for new style video decoding #5422
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
Draft
pmeier
wants to merge
11
commits into
pytorch:main
Choose a base branch
from
pmeier:datasets/video-decoding
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.
Draft
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
da670f0
add hmdb51 dataset and prototype for new style video decoding
pmeier 7bcb008
port UCF101
pmeier 32f813f
appease mypy
pmeier d37df01
fix resource loading
pmeier 9696a9d
add av to optional prototype requirements in CI
pmeier 0a4b477
add tests
pmeier 593ee8c
Merge branch 'main' into datasets/video-decoding
pmeier 673fc5a
basic changes to support various video backends
0e7dcc9
skeleton for implementing videousils tests
cb79fbc
add testing barebones
b8a1eac
Merge branch 'main' into datasets/video-decoding
pmeier 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
import math | ||
import os | ||
|
||
import pytest | ||
import torch | ||
from torchvision.io import _HAS_VIDEO_DECODER, _HAS_VIDEO_OPT, VideoReader | ||
from torchvision.prototype.features import EncodedData | ||
from torchvision.prototype.utils._internal import ReadOnlyTensorBuffer | ||
from torchvision.prototype.datasets.utils._video import KeyframeDecoder, RandomFrameDecoder | ||
try: | ||
import av | ||
except ImportError: | ||
av = None | ||
|
||
VIDEO_DIR = os.path.join(os.path.dirname(os.path.abspath(__file__)), "assets", "videos") | ||
|
||
|
||
@pytest.mark.skipif(av is None, reason="PyAV unavailable") | ||
class TestVideoDatasetUtils: | ||
# TODO: atm we separate backends in order to allow for testing on different systems; | ||
# once we have things packaged we should add this as test parametrisation | ||
# (this also applies for GPU decoding as well) | ||
|
||
@pytest.mark.parametrize( | ||
"video_file", | ||
[ | ||
"RATRACE_wave_f_nm_np1_fr_goo_37.avi", | ||
"TrumanShow_wave_f_nm_np1_fr_med_26.avi", | ||
"v_SoccerJuggling_g23_c01.avi", | ||
"v_SoccerJuggling_g24_c01.avi", | ||
"R6llTwEh07w.mp4", | ||
"SOX5yA1l24A.mp4", | ||
"WUzgd7C1pWA.mp4", | ||
], | ||
) | ||
def test_random_decoder_av(self, video_file): | ||
"""Read a sequence of random frames from a video | ||
Checks that files are valid video frames and no error is thrown during decoding. | ||
""" | ||
video_file = os.path.join(VIDEO_DIR, video_file) | ||
video = ReadOnlyTensorBuffer(EncodedData.from_path(video_file)) | ||
print(next(video)) | ||
pass | ||
|
||
def test_random_decoder_cpu(self, video_file): | ||
"""Read a sequence of random frames from a video using CPU backend | ||
Checks that files are valid video frames and no error is thrown during decoding, | ||
and compares them to `pyav` output. | ||
""" | ||
pass | ||
|
||
def test_random_decoder_GPU(self, video_file): | ||
"""Read a sequence of random frames from a video using GPU backend | ||
Checks that files are valid video frames and no error is thrown during decoding, | ||
and compares them to `pyav` output. | ||
""" | ||
pass | ||
|
||
def test_keyframe_decoder_av(self, video_file): | ||
"""Read all keyframes from a video; | ||
Compare the output to naive keyframe reading with `pyav` | ||
""" | ||
pass | ||
|
||
def test_keyframe_decoder_cpu(self, video_file): | ||
"""Read all keyframes from a video using CPU backend; | ||
ATM should raise a warning and default to `pyav` | ||
TODO: should we fail or default to a working backend | ||
""" | ||
pass | ||
|
||
def test_keyframe_decoder_GPU(self, video_file): | ||
"""Read all keyframes from a video using CPU backend; | ||
ATM should raise a warning and default to `pyav` | ||
TODO: should we fail or default to a working backend | ||
""" | ||
pass | ||
|
||
def test_clip_decoder(self, video_file): | ||
"""ATM very crude test: | ||
check only if fails, or if the clip sampling is correct, | ||
don't bother with the content just yet. | ||
""" | ||
pass | ||
|
||
|
||
if __name__ == "__main__": | ||
pytest.main([__file__]) |
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
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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
brush_hair | ||
cartwheel | ||
catch | ||
chew | ||
clap | ||
climb | ||
climb_stairs | ||
dive | ||
draw_sword | ||
dribble | ||
drink | ||
eat | ||
fall_floor | ||
fencing | ||
flic_flac | ||
golf | ||
handstand | ||
hit | ||
hug | ||
jump | ||
kick | ||
kick_ball | ||
kiss | ||
laugh | ||
pick | ||
pour | ||
pullup | ||
punch | ||
push | ||
pushup | ||
ride_bike | ||
ride_horse | ||
run | ||
shake_hands | ||
shoot_ball | ||
shoot_bow | ||
shoot_gun | ||
sit | ||
situp | ||
smile | ||
smoke | ||
somersault | ||
stand | ||
swing_baseball | ||
sword | ||
sword_exercise | ||
talk | ||
throw | ||
turn | ||
walk | ||
wave |
Oops, something went wrong.
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.