PandoraMedia/music-audio-representations

Can't load pretrained model

giamic opened this issue · 4 comments

I have cloned the repo and installed the package, but when I try to use the CLI to analyse a song I get this error message:

Traceback (most recent call last):
  File "/Users/micchig/opt/miniconda3/envs/mule/bin/mule", line 33, in <module>
    sys.exit(load_entry_point('sxmp-mule', 'console_scripts', 'mule')())
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/click/core.py", line 1025, in __call__
    return self.main(*args, **kwargs)
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/click/core.py", line 955, in main
    rv = self.invoke(ctx)
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/click/core.py", line 1517, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/click/core.py", line 1279, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/click/core.py", line 710, in invoke
    return callback(*args, **kwargs)
  File "/Users/micchig/PycharmProjects/music-audio-representations/mule/cli/cli.py", line 43, in run
    analysis = Analysis(cfg)
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/scooch/configurable.py", line 84, in __init__
    obj = self._config_factory.construct(self.__CONFIGURABLES__[param_name], self._cfg[self.__class__.__name__][param_name])
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/scooch/configurable_factory.py", line 55, in construct
    output_obj = [self.construct(cfg_type.subtype, each_cfg) for each_cfg in cfg]
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/scooch/configurable_factory.py", line 55, in <listcomp>
    output_obj = [self.construct(cfg_type.subtype, each_cfg) for each_cfg in cfg]
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/scooch/configurable_factory.py", line 58, in construct
    output_obj = self._class_instance_for_config(cfg_type, Config(cfg))
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/scooch/configurable_factory.py", line 121, in _class_instance_for_config
    return self.get_class(base_class, config)(config)
  File "/Users/micchig/PycharmProjects/music-audio-representations/mule/features/transform_features/embedding_feature.py", line 63, in __init__
    self.load_model()
  File "/Users/micchig/PycharmProjects/music-audio-representations/mule/features/transform_features/embedding_feature.py", line 102, in load_model
    self._model = tf.keras.models.load_model(self._model_location, compile=False)
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/keras/utils/traceback_utils.py", line 67, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/Users/micchig/opt/miniconda3/envs/mule/lib/python3.10/site-packages/tensorflow/python/saved_model/loader_impl.py", line 105, in parse_saved_model
    raise IOError(f"Cannot parse file {path_to_pb}: {str(e)}.")
OSError: Cannot parse file b'./supporting_data/model/saved_model.pb': Wrong wire type in tag..

I'm not sure if this is related but I have a Mac M1 computer and, as you can see from issue #1 , I had to install the package in an unconventional way: I have commented out all the required packages inside setup.py and then used the following conda environment

name: mule
channels:
  - apple
  - conda-forge
  - defaults
dependencies:
  - python>=3.8
  - pip
  - tensorflow-deps==2.9
  - numpy
  - librosa
  - click>=8.0
  - pip:
    - tensorflow-macos==2.9.1
#    - tensorflow-metal  # this is causing issues, not sure if related to sxmp-mule
    - scooch>=1.0
    - -e .
  # nice to haves
  - seaborn
  - matplotlib
  - ipython
  - pandas

Hi Gianluca,

We've seen this error come up when git lfs is not installed. The model itself should be approximately 250MB. If you see that the models files don't amount to this size in your cloned repo, you can try installing git lfs and pulling the large asset as follows:

brew install git-lfs
git lfs install
git lfs pull

We're in the process of clarifying this in the README.md. New release coming very soon.

Let me know if this does or does not solve your issue and I'll update this issue accordingly.

I followed the instructions but when I do git lfs pull I have the following error:

batch response: This repository is over its data quota. Account responsible for LFS bandwidth should purchase more data packs to restore access.                                                                                   
Failed to fetch some objects from 'https://github.com/giamic/music-audio-representations.git/info/lfs'

This error is due to the PandoraMedia account exceeding the bandwidth of the git lfs plan we currently have for this month. I am looking into the possibility of extending this plan. In the mean time you can access the model files here:

https://drive.google.com/drive/folders/1D-Vo98KJ1p_lCJHgqslSupDMtKSViFF5?usp=sharing

Note these files follow the same CC BY-NC 4.0 license as those in this repository.

Our data egress caps for Git LFS have increased, and I have updated the readme with more specific info on using Git LFS. I'm going to consider this resolved for now. Re-open if there are any further issues.