Commit 26d1b5dc authored by Richard Vogl's avatar Richard Vogl
Browse files

fix transcribe

parent 997bce85
......@@ -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
......
......@@ -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():
......
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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment