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
chenpangpang
parler-tts
Commits
b62f9f1e
Commit
b62f9f1e
authored
Feb 15, 2024
by
sanchit-gandhi
Browse files
apply random cropping to eval to prevent oom
parent
32092d53
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
9 deletions
+1
-9
run_audio_classification.py
run_audio_classification.py
+1
-9
No files found.
run_audio_classification.py
View file @
b62f9f1e
...
@@ -592,21 +592,13 @@ def main():
...
@@ -592,21 +592,13 @@ def main():
output_batch
[
"labels"
]
=
[
int
(
label2id
[
label
])
for
label
in
batch
[
"labels"
]]
output_batch
[
"labels"
]
=
[
int
(
label2id
[
label
])
for
label
in
batch
[
"labels"
]]
return
output_batch
return
output_batch
def
val_transforms
(
batch
):
"""Apply val_transforms across a batch."""
wavs
=
[
audio
[
"array"
]
for
audio
in
batch
[
"audio"
]]
inputs
=
feature_extractor
(
wavs
,
sampling_rate
=
sampling_rate
)
output_batch
=
{
model_input_name
:
inputs
.
get
(
model_input_name
)}
output_batch
[
"labels"
]
=
[
int
(
label2id
[
label
])
for
label
in
batch
[
"labels"
]]
return
output_batch
if
training_args
.
do_train
:
if
training_args
.
do_train
:
# Set the training transforms
# Set the training transforms
raw_datasets
[
"train"
].
set_transform
(
train_transforms
,
output_all_columns
=
False
)
raw_datasets
[
"train"
].
set_transform
(
train_transforms
,
output_all_columns
=
False
)
if
training_args
.
do_eval
:
if
training_args
.
do_eval
:
# Set the validation transforms
# Set the validation transforms
raw_datasets
[
"eval"
].
set_transform
(
val
_transforms
,
output_all_columns
=
False
)
raw_datasets
[
"eval"
].
set_transform
(
train
_transforms
,
output_all_columns
=
False
)
# Load the accuracy metric from the datasets package
# Load the accuracy metric from the datasets package
metric
=
evaluate
.
load
(
"accuracy"
,
cache_dir
=
model_args
.
cache_dir
)
metric
=
evaluate
.
load
(
"accuracy"
,
cache_dir
=
model_args
.
cache_dir
)
...
...
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