Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'add_slot' failing in Windows 11 installation #117

Closed
pdduggan opened this issue Mar 15, 2024 · 7 comments
Closed

'add_slot' failing in Windows 11 installation #117

pdduggan opened this issue Mar 15, 2024 · 7 comments

Comments

@pdduggan
Copy link

Here is my output. I would appreciate any help in getting the tool working.

'_UserObject' object has no attribute 'add_slot'
Traceback (most recent call last):
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\basic_pitch\predict.py", line 132, in main
    predict_and_save(
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\basic_pitch\inference.py", line 383, in predict_and_save
    model = saved_model.load(str(model_path))
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\saved_model\load.py", line 912, in load
    result = load_partial(export_dir, None, tags, options)["root"]
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\saved_model\load.py", line 1042, in load_partial
    loader = Loader(object_graph_proto, saved_model_proto, export_dir,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\saved_model\load.py", line 223, in __init__
    self._load_all()
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\saved_model\load.py", line 320, in _load_all
    self._load_nodes()
  File "F:\Users\Paul\AppData\Local\Programs\Python\Python311\Lib\site-packages\tensorflow\python\saved_model\load.py", line 529, in _load_nodes
    slot_variable = optimizer_object.add_slot(
                    ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: '_UserObject' object has no attribute 'add_slot'

Thanks

@drubinstein
Copy link
Contributor

Hi. This is a problem we discovered recently as well. It's due to the tensorflow 2.16 release where keras 3 is now used for the saved model format. Currently the main branch has tensorflow pinned to <2.16 which should work until we push the new minor release (once we're sure there are no bugs in main).

@Dragonfore
Copy link

Hi @pdduggan ,

In the future, it is better to provide at least the following specifications as this can be a few possible issues. A few examples of what should be provided is (but exclusively)

  • System Specifications (CPU + Architecture, GPU + Architecture, RAM, and possibly other requirements depending)
  • Operating System (and terminal environment Win10 CMD or MacOS TERM, etc)
  • Python Environment + Pip Environment (VirtualEnv or Pyenv recommended)
  • Related pip module versions (Tensorflow, basic-audio)
  • Development Environment (Jupyter Lab, VSCode, Visual Studio Community/Professional, vim, ...)
  • Reproduction Steps
  • Screenshots / Terminal logs
  • Other related information

A few things that I have previously considered when setting this (or other Machine Learning projects is the following)
OS: Windows 11 - Command Line Terminal VIA VSCode
CPU & GPU: AMD Ryzen 5 PRO 7540U + AMD Radeon 740M Graphics (CPU-only, GPU disabled)
Python Version: 3.10.11 through Pyenv
PIP Versions:
(tensorflow-cpu<2.11 | basic-pitch | setuptools) -> installations required
Package Version


absl-py 2.1.0
asttokens 2.4.1
astunparse 1.6.3
audioread 3.0.1
basic-pitch 0.2.6
cachetools 5.3.3
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
colorama 0.4.6
comm 0.2.2
debugpy 1.8.1
decorator 5.1.1
dm-tree 0.1.8
exceptiongroup 1.2.0
executing 2.0.1
flatbuffers 24.3.7
future 1.0.0
gast 0.4.0
google-auth 2.28.2
google-auth-oauthlib 0.4.6
google-pasta 0.2.0
grpcio 1.62.1
h5py 3.10.0
idna 3.6
ipykernel 6.29.3
ipython 8.22.2
jedi 0.19.1
joblib 1.3.2
jupyter_client 8.6.1
jupyter_core 5.7.2
keras 2.10.0
keras-nightly 3.1.0.dev2024031503
Keras-Preprocessing 1.1.2
lazy_loader 0.3
libclang 16.0.6
librosa 0.10.1
llvmlite 0.42.0
Markdown 3.6
markdown-it-py 3.0.0
MarkupSafe 2.1.5
matplotlib-inline 0.1.6
mdurl 0.1.2
mido 1.3.2
mir-eval 0.7
ml-dtypes 0.3.2
msgpack 1.0.8
namex 0.0.7
nest-asyncio 1.6.0
numba 0.59.0
numpy 1.23.5
oauthlib 3.2.2
opt-einsum 3.3.0
packaging 23.2
parso 0.8.3
pip 23.0.1
platformdirs 4.2.0
pooch 1.8.1
pretty-midi 0.2.10
prompt-toolkit 3.0.43
protobuf 3.19.6
psutil 5.9.8
pure-eval 0.2.2
pyasn1 0.5.1
pyasn1-modules 0.3.0
pycparser 2.21
Pygments 2.17.2
python-dateutil 2.9.0.post0
pywin32 306
pyzmq 25.1.2
requests 2.31.0
requests-oauthlib 1.4.0
resampy 0.4.3
rich 13.7.1
rsa 4.9
scikit-learn 1.4.1.post1
scipy 1.12.0
setuptools 65.5.0
six 1.16.0
soundfile 0.12.1
soxr 0.3.7
stack-data 0.6.3
tb-nightly 2.17.0a20240315
tensorboard 2.10.1
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
tensorflow-cpu 2.10.1
tensorflow-directml-plugin 0.2.0.dev221020
tensorflow-estimator 2.10.0
tensorflow-intel 2.10.1
tensorflow-io-gcs-filesystem 0.31.0
termcolor 2.4.0
tf-nightly 2.17.0.dev20240306
tf_nightly_intel 2.17.0.dev20240306
threadpoolctl 3.3.0
tornado 6.4
traitlets 5.14.2
typing_extensions 4.10.0
urllib3 2.2.1
wcwidth 0.2.13
Werkzeug 3.0.1
wheel 0.43.0
wrapt 1.16.0
Other information: Jupyter on Visual Studio Code Insiders (Daily build)

Here are a few steps I took to solve it:

# Uses Spotify Open-Source Basic Pitch audio-to-midi conversion
from basic_pitch.inference import predict
from basic_pitch import ICASSP_2022_MODEL_PATH
from os.path import join as pathjoin
from os import sep
import tensorflow as tf

# Set variables
input_file_path = pathjoin("C:" + sep, "repo", "JupyterNotebooks", "cached_data", "blob_data", "nuvoleBianche.mp3")
output_file_path = pathjoin("C:" + sep, "repo", "JupyterNotebooks", "cached_data", "processed_data", "")

# Check version and load model (used as workaround in Windows)
print(tf.__version__)
tf.config.set_visible_devices([], "GPU")
basic_pitch_model = tf.saved_model.load(ICASSP_2022_MODEL_PATH)

# Perform prediction
(model_output, midi_data, note_events) = predict(
    input_file_path,
    basic_pitch_model,
)

# Do something with the data
print(note_events)

@Dragonfore
Copy link

@drubinstein I would recommend that this issue is set to closed based on the initial description and may be re-opened once the author provides more information or goes through the necessary steps based on input I provided.

@drubinstein
Copy link
Contributor

drubinstein commented Mar 15, 2024

Hi @Dragonfore . I'm gonna keep the issue open until he responds. I'm fairly confident the issue is with tensorflow 2.16.1 (released last week) as I ran into this error earlier this week when working on and merging #100.

Regardless, there's no reason to be a stickler here and close and reopen the issue. He provided enough detail to get started and I could always ask for more e.g. how he's invoking it. What could be useful is an issue template and I can make one or base one off of what you wrote. Thanks for your comments.

FYI your packages may have a slight conflict given that they install tensorflow-cpu<2.11 and tf-nightly 2.17.

@Dragonfore
Copy link

Hi @drubinstein Thanks for the FYI on the package conflicts! I do think that an issue template would be beneficial if you have some time or I might be able to create a PR to do this sometime in the next week or so.

Sorry about the recommendation to close, I should have waited until after a response was provided as there was a reasonable amount of detail. After re-reading, I did come across as a stickler, my goal only goal was trying to help out for the reporting of possible issues. I'll keep that in mind for the future.

Additionally, @pdduggan if you have any other questions please feel free to provide more info and sorry for one of my previous comment about closing prematurely.

@whythomedia
Copy link

I had the same issue and rolling back from tensorflow 2.16 to 2.15 fixed the problem for me.

I'm on OSX using python 3.11

@drubinstein
Copy link
Contributor

Until I can find a way to reserialize the model or find what transitive dependency is breaking model loading, I've pinned tensorflow to <2.15.1. I hope this doesn't impede any of your work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants