Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
e27b3925
Unverified
Commit
e27b3925
authored
Jun 10, 2021
by
Anirudh
Committed by
GitHub
Jun 10, 2021
Browse files
Port test_datasets_video_utils.py to pytest (#4035)
parent
8ea04d13
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
6 deletions
+6
-6
test/test_datasets_video_utils.py
test/test_datasets_video_utils.py
+6
-6
No files found.
test/test_datasets_video_utils.py
View file @
e27b3925
import
contextlib
import
contextlib
import
os
import
os
import
torch
import
torch
import
unit
test
import
py
test
from
torchvision
import
io
from
torchvision
import
io
from
torchvision.datasets.video_utils
import
VideoClips
,
unfold
from
torchvision.datasets.video_utils
import
VideoClips
,
unfold
...
@@ -31,7 +31,7 @@ def get_list_of_videos(num_videos=5, sizes=None, fps=None):
...
@@ -31,7 +31,7 @@ def get_list_of_videos(num_videos=5, sizes=None, fps=None):
yield
names
yield
names
class
Test
er
(
unittest
.
TestCase
)
:
class
Test
Video
:
def
test_unfold
(
self
):
def
test_unfold
(
self
):
a
=
torch
.
arange
(
7
)
a
=
torch
.
arange
(
7
)
...
@@ -58,7 +58,7 @@ class Tester(unittest.TestCase):
...
@@ -58,7 +58,7 @@ class Tester(unittest.TestCase):
])
])
assert_equal
(
r
,
expected
,
check_stride
=
False
)
assert_equal
(
r
,
expected
,
check_stride
=
False
)
@
unit
test
.
skip
I
f
(
not
io
.
video
.
_av_available
(),
"this test requires av"
)
@
py
test
.
mark
.
skip
i
f
(
not
io
.
video
.
_av_available
(),
reason
=
"this test requires av"
)
def
test_video_clips
(
self
):
def
test_video_clips
(
self
):
with
get_list_of_videos
(
num_videos
=
3
)
as
video_list
:
with
get_list_of_videos
(
num_videos
=
3
)
as
video_list
:
video_clips
=
VideoClips
(
video_list
,
5
,
5
,
num_workers
=
2
)
video_clips
=
VideoClips
(
video_list
,
5
,
5
,
num_workers
=
2
)
...
@@ -82,7 +82,7 @@ class Tester(unittest.TestCase):
...
@@ -82,7 +82,7 @@ class Tester(unittest.TestCase):
assert
video_idx
==
v_idx
assert
video_idx
==
v_idx
assert
clip_idx
==
c_idx
assert
clip_idx
==
c_idx
@
unit
test
.
skip
I
f
(
not
io
.
video
.
_av_available
(),
"this test requires av"
)
@
py
test
.
mark
.
skip
i
f
(
not
io
.
video
.
_av_available
(),
reason
=
"this test requires av"
)
def
test_video_clips_custom_fps
(
self
):
def
test_video_clips_custom_fps
(
self
):
with
get_list_of_videos
(
num_videos
=
3
,
sizes
=
[
12
,
12
,
12
],
fps
=
[
3
,
4
,
6
])
as
video_list
:
with
get_list_of_videos
(
num_videos
=
3
,
sizes
=
[
12
,
12
,
12
],
fps
=
[
3
,
4
,
6
])
as
video_list
:
num_frames
=
4
num_frames
=
4
...
@@ -124,7 +124,7 @@ class Tester(unittest.TestCase):
...
@@ -124,7 +124,7 @@ class Tester(unittest.TestCase):
num_frames
=
32
num_frames
=
32
orig_fps
=
30
orig_fps
=
30
new_fps
=
13
new_fps
=
13
with
self
.
assertW
arns
(
UserWarning
):
with
pytest
.
w
arns
(
UserWarning
):
clips
,
idxs
=
VideoClips
.
compute_clips_for_video
(
video_pts
,
num_frames
,
num_frames
,
clips
,
idxs
=
VideoClips
.
compute_clips_for_video
(
video_pts
,
num_frames
,
num_frames
,
orig_fps
,
new_fps
)
orig_fps
,
new_fps
)
assert
len
(
clips
)
==
0
assert
len
(
clips
)
==
0
...
@@ -132,4 +132,4 @@ class Tester(unittest.TestCase):
...
@@ -132,4 +132,4 @@ class Tester(unittest.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unit
test
.
main
()
py
test
.
main
(
[
__file__
]
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment