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
f514ab64
Unverified
Commit
f514ab64
authored
Aug 24, 2023
by
Philip Meier
Committed by
GitHub
Aug 24, 2023
Browse files
test output_format in video datasets (#7879)
parent
b82d8833
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
test/datasets_utils.py
test/datasets_utils.py
+17
-5
torchvision/datasets/video_utils.py
torchvision/datasets/video_utils.py
+3
-3
No files found.
test/datasets_utils.py
View file @
f514ab64
...
@@ -662,27 +662,39 @@ class VideoDatasetTestCase(DatasetTestCase):
...
@@ -662,27 +662,39 @@ class VideoDatasetTestCase(DatasetTestCase):
FEATURE_TYPES
=
(
torch
.
Tensor
,
torch
.
Tensor
,
int
)
FEATURE_TYPES
=
(
torch
.
Tensor
,
torch
.
Tensor
,
int
)
REQUIRED_PACKAGES
=
(
"av"
,)
REQUIRED_PACKAGES
=
(
"av"
,)
DEFAULT_
FRAMES_PER_CLIP
=
1
FRAMES_PER_CLIP
=
1
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
().
__init__
(
*
args
,
**
kwargs
)
super
().
__init__
(
*
args
,
**
kwargs
)
self
.
dataset_args
=
self
.
_set_default_frames_per_clip
(
self
.
dataset_args
)
self
.
dataset_args
=
self
.
_set_default_frames_per_clip
(
self
.
dataset_args
)
def
_set_default_frames_per_clip
(
self
,
inject_fake_data
):
def
_set_default_frames_per_clip
(
self
,
dataset_args
):
argspec
=
inspect
.
getfullargspec
(
self
.
DATASET_CLASS
.
__init__
)
argspec
=
inspect
.
getfullargspec
(
self
.
DATASET_CLASS
.
__init__
)
args_without_default
=
argspec
.
args
[
1
:
(
-
len
(
argspec
.
defaults
)
if
argspec
.
defaults
else
None
)]
args_without_default
=
argspec
.
args
[
1
:
(
-
len
(
argspec
.
defaults
)
if
argspec
.
defaults
else
None
)]
frames_per_clip_last
=
args_without_default
[
-
1
]
==
"frames_per_clip"
frames_per_clip_last
=
args_without_default
[
-
1
]
==
"frames_per_clip"
@
functools
.
wraps
(
inject_fake_data
)
@
functools
.
wraps
(
dataset_args
)
def
wrapper
(
tmpdir
,
config
):
def
wrapper
(
tmpdir
,
config
):
args
=
inject_fake_data
(
tmpdir
,
config
)
args
=
dataset_args
(
tmpdir
,
config
)
if
frames_per_clip_last
and
len
(
args
)
==
len
(
args_without_default
)
-
1
:
if
frames_per_clip_last
and
len
(
args
)
==
len
(
args_without_default
)
-
1
:
args
=
(
*
args
,
self
.
DEFAULT_
FRAMES_PER_CLIP
)
args
=
(
*
args
,
self
.
FRAMES_PER_CLIP
)
return
args
return
args
return
wrapper
return
wrapper
def
test_output_format
(
self
):
for
output_format
in
[
"TCHW"
,
"THWC"
]:
with
self
.
create_dataset
(
output_format
=
output_format
)
as
(
dataset
,
_
):
for
video
,
*
_
in
dataset
:
if
output_format
==
"TCHW"
:
num_frames
,
num_channels
,
*
_
=
video
.
shape
else
:
# output_format == "THWC":
num_frames
,
*
_
,
num_channels
=
video
.
shape
assert
num_frames
==
self
.
FRAMES_PER_CLIP
assert
num_channels
==
3
@
test_all_configs
@
test_all_configs
def
test_transforms_v2_wrapper
(
self
,
config
):
def
test_transforms_v2_wrapper
(
self
,
config
):
# `output_format == "THWC"` is not supported by the wrapper. Thus, we skip the `config` if it is set explicitly
# `output_format == "THWC"` is not supported by the wrapper. Thus, we skip the `config` if it is set explicitly
...
...
torchvision/datasets/video_utils.py
View file @
f514ab64
...
@@ -187,9 +187,9 @@ class VideoClips:
...
@@ -187,9 +187,9 @@ class VideoClips:
}
}
return
type
(
self
)(
return
type
(
self
)(
video_paths
,
video_paths
,
self
.
num_frames
,
clip_length_in_frames
=
self
.
num_frames
,
self
.
step
,
frames_between_clips
=
self
.
step
,
self
.
frame_rate
,
frame_rate
=
self
.
frame_rate
,
_precomputed_metadata
=
metadata
,
_precomputed_metadata
=
metadata
,
num_workers
=
self
.
num_workers
,
num_workers
=
self
.
num_workers
,
_video_width
=
self
.
_video_width
,
_video_width
=
self
.
_video_width
,
...
...
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