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
Torchaudio
Commits
47f502a6
Unverified
Commit
47f502a6
authored
Oct 03, 2023
by
Oren Amsalem
Committed by
GitHub
Oct 03, 2023
Browse files
change modality naming inconsistency (visual & video) (#3631)
* Update transforms.py * Update train.py
parent
92ded610
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
5 deletions
+6
-5
examples/avsr/train.py
examples/avsr/train.py
+1
-0
examples/avsr/transforms.py
examples/avsr/transforms.py
+5
-5
No files found.
examples/avsr/train.py
View file @
47f502a6
...
...
@@ -59,6 +59,7 @@ def parse_args():
"--modality"
,
type
=
str
,
help
=
"Modality"
,
choices
=
[
"audio"
,
"video"
,
"audiovisual"
],
required
=
True
,
)
parser
.
add_argument
(
...
...
examples/avsr/transforms.py
View file @
47f502a6
...
...
@@ -55,7 +55,7 @@ def _extract_features(video_pipeline, audio_pipeline, samples, args):
raw_videos
=
[]
raw_audios
=
[]
for
sample
in
samples
:
if
args
.
modality
==
"vi
sual
"
:
if
args
.
modality
==
"vi
deo
"
:
raw_videos
.
append
(
sample
[
0
])
if
args
.
modality
==
"audio"
:
raw_audios
.
append
(
sample
[
0
])
...
...
@@ -64,7 +64,7 @@ def _extract_features(video_pipeline, audio_pipeline, samples, args):
raw_audios
.
append
(
sample
[
0
][:
length
*
640
])
raw_videos
.
append
(
sample
[
1
][:
length
])
if
args
.
modality
==
"vi
sual
"
or
args
.
modality
==
"audiovisual"
:
if
args
.
modality
==
"vi
deo
"
or
args
.
modality
==
"audiovisual"
:
videos
=
torch
.
nn
.
utils
.
rnn
.
pad_sequence
(
raw_videos
,
batch_first
=
True
)
videos
=
video_pipeline
(
videos
)
video_lengths
=
torch
.
tensor
([
elem
.
shape
[
0
]
for
elem
in
videos
],
dtype
=
torch
.
int32
)
...
...
@@ -72,7 +72,7 @@ def _extract_features(video_pipeline, audio_pipeline, samples, args):
audios
=
torch
.
nn
.
utils
.
rnn
.
pad_sequence
(
raw_audios
,
batch_first
=
True
)
audios
=
audio_pipeline
(
audios
)
audio_lengths
=
torch
.
tensor
([
elem
.
shape
[
0
]
//
640
for
elem
in
audios
],
dtype
=
torch
.
int32
)
if
args
.
modality
==
"vi
sual
"
:
if
args
.
modality
==
"vi
deo
"
:
return
videos
,
video_lengths
if
args
.
modality
==
"audio"
:
return
audios
,
audio_lengths
...
...
@@ -105,7 +105,7 @@ class TrainTransform:
self
.
train_video_pipeline
,
self
.
train_audio_pipeline
,
samples
,
self
.
args
)
return
Batch
(
audios
,
audio_lengths
,
targets
,
target_lengths
)
if
self
.
args
.
modality
==
"vi
sual
"
:
if
self
.
args
.
modality
==
"vi
deo
"
:
videos
,
video_lengths
=
_extract_features
(
self
.
train_video_pipeline
,
self
.
train_audio_pipeline
,
samples
,
self
.
args
)
...
...
@@ -140,7 +140,7 @@ class ValTransform:
self
.
valid_video_pipeline
,
self
.
valid_audio_pipeline
,
samples
,
self
.
args
)
return
Batch
(
audios
,
audio_lengths
,
targets
,
target_lengths
)
if
self
.
args
.
modality
==
"vi
sual
"
:
if
self
.
args
.
modality
==
"vi
deo
"
:
videos
,
video_lengths
=
_extract_features
(
self
.
valid_video_pipeline
,
self
.
valid_audio_pipeline
,
samples
,
self
.
args
)
...
...
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