Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Richard Vogl
piano_transcription
Commits
26d1b5dc
Commit
26d1b5dc
authored
Jun 17, 2018
by
Richard Vogl
Browse files
fix transcribe
parent
997bce85
Changes
3
Hide whitespace changes
Inline
Side-by-side
piano_transcription/models/crnn_1.py
View file @
26d1b5dc
...
...
@@ -2,6 +2,7 @@
import
numpy
as
np
import
theano
import
theano.tensor
as
T
import
lasagne
from
lasagne.layers.dnn
import
Conv2DDNNLayer
as
Conv2DLayer
...
...
@@ -82,9 +83,9 @@ def predict(pfun, X, max_seq_len, out_len):
i0
=
batch
*
MAX_PRED_SIZE
i1
=
i0
+
MAX_PRED_SIZE
i1o
=
min
(
i1
,
seq_len
)
p_b
[
i0
:
i1o
]
=
pfun
(
[
X_pred
[:,
i0
:
i1
],
m_b
[:,
i0
:
i1
]
]
)[
0
,
0
:(
i1o
-
i0
)]
p_b
[
i0
:
i1o
]
=
pfun
(
X_pred
[:,
i0
:
i1
],
m_b
[:,
i0
:
i1
])[
0
,
0
:(
i1o
-
i0
)]
else
:
p_b
=
pfun
(
[
X_pred
,
m_b
]
)[
0
,
:
seq_len
]
p_b
=
pfun
(
X_pred
,
m_b
)[
0
,
:
seq_len
]
return
p_b
...
...
piano_transcription/models/rnn_1.py
View file @
26d1b5dc
...
...
@@ -33,7 +33,7 @@ def predict(pfun, X, max_seq_len, out_len):
X_pred
=
np
.
pad
(
X
,
((
0
,
max_seq_len
-
seq_len
),
(
0
,
0
)),
'constant'
).
astype
(
theano
.
config
.
floatX
)
m_b
=
np
.
pad
(
m_b
,
((
0
,
0
),
(
0
,
max_seq_len
-
seq_len
)),
'constant'
).
astype
(
theano
.
config
.
floatX
)
return
pfun
(
[
X_pred
,
m_b
]
)[
0
,
:
seq_len
]
return
pfun
(
X_pred
,
m_b
)[
0
,
:
seq_len
]
def
get_batch_iterator_train
():
...
...
piano_transcription/transcribe.py
View file @
26d1b5dc
import
argparse
import
os
import
lasagne
import
numpy
as
np
from
madmom.features.notes
import
NotePeakPickingProcessor
from
piano_transcription
import
BEST_MODEL_FILE_NAME
,
SETTINGS_FILE_NAME
,
LOSSES_FILE
from
piano_transcription
import
BEST_MODEL_FILE_NAME
,
SETTINGS_FILE_NAME
from
piano_transcription.utils
import
select_model
,
collect_inputs
from
piano_transcription.data
import
FEAT_SIZE
,
OUT_SIZE
from
piano_transcription.data.annotations
import
write_txt_annotation
from
piano_transcription.data.features
import
extract_features
from
piano_transcription.data
import
OUT_SIZE
from
piano_transcription.data.annotations
import
write_txt_annotation
,
posprocess_annotations
from
piano_transcription.data.features
import
extract_features
,
note_offset
import
theano
import
lasagne
...
...
@@ -49,7 +48,7 @@ def run(model_path, input_file):
peak_picker
=
NotePeakPickingProcessor
(
pitch_offset
=
0
)
notes
=
peak_picker
.
process
(
pred
)
write_txt_annotation
(
open
(
input_file
+
'out.txt'
,
'w'
),
notes
)
write_txt_annotation
(
input_file
+
'out.txt'
,
posprocess_annotations
(
notes
,
offset
=-
note_offset
,
num_classes
=
127
)
)
def
main
():
...
...
@@ -67,5 +66,5 @@ def main():
if
__name__
==
'__main__'
:
#run('/Users/rich/python-workspace/piano_trans/piano_transcription/output/2018-06-17-16-57-22', '/Users/rich/Desktop/piano_test/CH/MAPS_ISOL_CH0.3_F_AkPnBsdf.flac')
#
run('/Users/rich/python-workspace/piano_trans/piano_transcription/output/2018-06-17-16-57-22', '/Users/rich/Desktop/piano_test/CH/MAPS_ISOL_CH0.3_F_AkPnBsdf.flac')
main
()
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