Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Alexander Fuchs
tensorflow2_trainer_template
Commits
978bb202
Commit
978bb202
authored
Aug 03, 2020
by
Alexander Fuchs
Browse files
Workaround for multiprocess bug
parent
c063d6b0
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/utils/data_loader.py
View file @
978bb202
...
...
@@ -143,7 +143,10 @@ class DataGenerator(object):
def
create_feature
(
self
,
sample
):
"""Creates the features by doing a STFT"""
filename
=
sample
[
'filename'
]
if
os
.
path
.
isfile
(
filename
.
replace
(
"mp3"
,
"npz"
))
and
not
(
self
.
force_feature_recalc
):
return
None
channels_str
=
sample
[
'channels'
]
channels
=
int
(
channels_str
.
split
(
" "
)[
0
])
if
channels
==
1
:
...
...
@@ -237,7 +240,7 @@ class DataGenerator(object):
pool
=
multiprocessing
.
Pool
(
os
.
cpu_count
())
for
i
,
_
in
enumerate
(
pool
.
imap_unordered
(
self
.
create_feature
,
samples
),
1
):
sys
.
stderr
.
write
(
'
\r
done {0:%}'
.
format
(
i
/
n
))
sys
.
stderr
.
write
(
'
\r
done {0:%}'
.
format
(
max
(
0
,
i
/
n
))
)
...
...
@@ -258,6 +261,8 @@ class DataGenerator(object):
#Create features via STFT if no file exists
spectra
=
self
.
create_feature
(
sample
)
sample
[
'spectra'
]
=
spectra
yield
sample
if
__name__
==
"__main__"
:
...
...
Write
Preview
Supports
Markdown
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