magenta / magenta-js

Magenta.js: Music and Art Generation with Machine Learning in the browser
https://magenta.tensorflow.org
Apache License 2.0
2.01k stars 314 forks source link

Converting python onset and frames MAESTRO checkpoint to tfjs leads to incompatible model #265

Closed TGabor closed 5 years ago

TGabor commented 5 years ago

Thanks for sharing all these resources with the community!

I tried converting the OAF MAESTRO checkpoint using checkpoint_converter.py:

python checkpoint_converter.py train/model.ckpt maestrocp

Once I use my manually converted checkpoint in piano-scribe, I get the error

Uncaught (in promise) Error: Variable not found: onsets/cudnn_lstm/rnn/multi_rnn_cell/cell_0/cudnn_compatible_lstm_cell/kernel
    at getVar (music@1.2:81458)
    at setLstmWeights (music@1.2:81469)
    at Lstm.setWeights (music@1.2:81471)
    at music@1.2:81326
    at music@1.2:8586
    at Engine.scopedRun (music@1.2:8596)
    at Engine.tidy (music@1.2:8585)
    at Object.Environment.tidy (music@1.2:8928)
    at OnsetsAndFrames.build (music@1.2:81322)
    at OnsetsAndFrames.<anonymous> (music@1.2:81199)

The python checkpoint uses bidirectional LSTM layers, whereas the provided tfjs checkpoints (onsets_frames_uni, onsets_frames_uni_q2) use unidirectional models.

Is there an easy fix for this? Would it be possible to share the python checkpoints that were used to generate onsets_frames_uni and onsets_frames_uni_q2?

adarob commented 5 years ago

Here you go:

https://storage.googleapis.com/magentadata/js/checkpoints/transcription/onsets_frames_uni/model.ckpt-583632.data-00000-of-00001 https://storage.googleapis.com/magentadata/js/checkpoints/transcription/onsets_frames_uni/model.ckpt-583632.index

TGabor commented 5 years ago

Hi @adarob,

thanks for sharing!

Would it be possible to add the meta file for the checkpoint, too?

TimothyRoberts commented 5 years ago

Hi @TGabor,

would you mind explaining why I'm getting this error?

screenshot 2019-02-26 at 11 36 40

I have pip installed tensorflowjs already, does this checkpoint_converter file need to be saved somewhere in particular?

TGabor commented 5 years ago

@TimothyRoberts You either need to change to the magenta-js/scripts directory or call python scripts/checkpoint_converter.py from the magenta-js directory

TimothyRoberts commented 5 years ago

Thank you, sir! I hadn't cloned the magenta-js directory