Music-and-Culture-Technology-Lab / omnizart

Omniscient Mozart, being able to transcribe everything in the music, including vocal, drum, chord, beat, instruments, and more.
https://music-and-culture-technology-lab.github.io/omnizart-doc/
MIT License
1.64k stars 99 forks source link

Colab issue on using models - runtime error due to name conflict with built-in Keras model #47

Closed mongrelite closed 2 years ago

mongrelite commented 2 years ago

Hey there,

I was able to get Colab to install omnizart with the deprecated-legacy command mentioned in an earlier issue thread. However, I'm unable to run the chords, vocals and most other models without getting the error below

2021-11-26 13:30:18 Extracting feature 2021-11-26 13:30:24 Loading model 2021-11-26 13:30:24 Using built-in model /usr/local/lib/python3.7/dist-packages/omnizart/checkpoints/chord/chord_v1 for transcription. WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model. Please ensure that you are saving the model with model.save() or tf.keras.models.save_model(), NOT tf.saved_model.save(). To confirm, there should be a file named "keras_metadata.pb" in the SavedModel directory.

RuntimeError Traceback (most recent call last)

in () 34 }[model] 35 ---> 36 midi = app.transcribe(f"{uploaded_audio}.wav", model_path=model_path) 37 38 # Synthesize MIDI and play 3 frames /usr/local/lib/python3.7/dist-packages/keras/saving/saved_model/load.py in _revive_layer_or_model_from_config(self, metadata, node_id) 536 'your class with `@keras.utils.register_keras_serializable` and ' 537 'include that file in your program, or pass your class in a ' --> 538 '`keras.utils.CustomObjectScope` that wraps this load call.') from e 539 else: 540 raise RuntimeError: Unable to restore object of class 'MultiHeadAttention' likely due to name conflict with built-in Keras class ''. To override the built-in Keras definition of the object, decorate your class with `@keras.utils.register_keras_serializable` and include that file in your program, or pass your class in a `keras.utils.CustomObjectScope` that wraps this load call. This practically means that most of the model is broken, at least on my end. I'm only able to run the first two models. I'd really like to be able to use the other ones- any solutions?
BreezeWhite commented 2 years ago

Hi, I've updated the colab and fixed the chord module bug. But looks like there are other problems not relating to omnizart but the official setup of colab session, I can't test other modules. The problem might not exist on your side, so if you could help run some tests, I will be very appreciative.

mongrelite commented 2 years ago

Hey again, after your update the environment setup works pretty well. However now there's a problem with the transcription part, specifically no matter what module I try I get the following error

OpError: /content/omnizart/omnizart/checkpoints/music/music_piano/variables/variables.data-00000-of-00001; No such file or directory

BreezeWhite commented 2 years ago

This could be due to the inconsistency between the path of downloaded checkpoints and imported module. Since after the setup, the current path is in /content/omnizart, so when execute omnizart or importing anything from omnizart will refer to current path, not the installed one (which should be in /usr/local/lib/python3.7/dist-packages/omnizart). That's why the module can't find the checkpoints because the checkpoints were saved in a different path.

Try %cd to other directory should fix the problem and make sure this comes before importing omnizart.

mongrelite commented 2 years ago

Hey again,

Your advice worked to fix that error message, but now I get this across all models:

UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above. [[node model_1/conv2d_1/Conv2D (defined at /usr/local/lib/python3.7/dist-packages/omnizart/music/prediction.py:183) ]] [Op:__inference_predict_function_135953]

Function call stack: predict_function

Thank you for your speedy responses by the way, I appreciate it

BreezeWhite commented 2 years ago

Yes, that is exactly what I mentioned about. This issue seems like the default environment setup of colab is broken, more specifically, the cuDNN and cuda setup. This also happened before. I've also confirmed that if you build a new simple convolution model and feed input to it, it will also fail. So this is not an issue relates to omnizart.

skgoh95 commented 2 years ago

Hi, I had a similar issue with cuDNN and cuda setup error, and I resolved it by changing the runtime to TPU on colab

BreezeWhite commented 2 years ago

I think this issue should be fixed now, since the remaining runtime error is not related to this project.