Code Monkey home page Code Monkey logo

Comments (8)

fbravosanchez avatar fbravosanchez commented on July 26, 2024 1

In tensorflow 2.10.1 I still have the same problem. I tracked it down to the PB model having multiple signatures.
I resolved by replacing the line:
prediction = model.predict(data)
with:
prediction = model.signatures["basic"](inputs = data)
I hope this helps anyone that may still have this issue.

from birdnet-analyzer.

abfleishman avatar abfleishman commented on July 26, 2024

@lagunabravo I did not get that error. Seems like maybe a path issue?

from birdnet-analyzer.

lagunabravo avatar lagunabravo commented on July 26, 2024

Thank you @abfleishman for the suggestion. I'm pretty sure it is not a path issue, as the model loads. I was quite succinct in my first post, the warning it gives, hinted in my question is:
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.
A "keras_metadata.pb" is present with the 2k model, so I thought it may be just an absent file. I wonder if there is something else I'm missing, I'm using TF/Keras 2.6. You do successfully run the protobuf not the .tflite one?

from birdnet-analyzer.

abfleishman avatar abfleishman commented on July 26, 2024

@iamjeff any thoughts for lagunabravo?

from birdnet-analyzer.

rehroman avatar rehroman commented on July 26, 2024

I am running into the same issue.
As @lagunabravo wrote: The "keras_metadata.pb" is still present with the 2k model, and so does the following operation work without the error messages _UserObject' object has no attribute 'predict And also without the mentioned warning.

The error would occur already after the following lines. In this case it works, as it is the V2.1.
model = tf.keras.models.load_model(".../BirdNET-Analyzer/checkpoints/V2.1/BirdNET_GLOBAL_2K_V2.1_Model/") print(model.summary())

As the warning says,maybe it was either not saved correctly: Please ensure that you are saving the model with model.save() or tf.keras.models.save_model(), *NOT* tf.saved_model.save().
Or it was saved with a TF version prior to 2.5?
WARNING:tensorflow:SavedModel saved prior to TF 2.5 detected when loading Keras model.

Update:
I think the issue is explained quite well here: tensorflow/models#8990 (comment)

from birdnet-analyzer.

Josef-Haupt avatar Josef-Haupt commented on July 26, 2024

This issue concerns an outdated model.
Please reopen if encountered again.

from birdnet-analyzer.

sulzbals avatar sulzbals commented on July 26, 2024

The problem persists with the most recent checkpoint (V2.4). I tested all checkpoints starting from V2.0 and the protobuf model does not seem to work since V2.2.

I tried running the analyze.py script (latest code - 8762884) with default parameters on the example input file. I only changed the config.py file in order to select the protobuf model and to adjust the model paths for testing each checkpoint ranging from V2.0 to V2.4. It worked perfectly with checkpoints V2.0 and V2.1, but when using any of the checkpoints starting from V2.2 onward I always got this same problem.

The full error message I got:

Traceback (most recent call last):
  File "/home/sulzbals/git/BirdNET-Analyzer/analyze.py", line 287, in analyzeFile
    p = predict(samples)
  File "/home/sulzbals/git/BirdNET-Analyzer/analyze.py", line 225, in predict
    prediction = model.predict(data)
  File "/home/sulzbals/git/BirdNET-Analyzer/model.py", line 330, in predict
    prediction = PBMODEL.predict(sample)
AttributeError: '_UserObject' object has no attribute 'predict'

from birdnet-analyzer.

Josef-Haupt avatar Josef-Haupt commented on July 26, 2024

I tested this with the current repo and tensorflow 2.15.0.
The PB model is working for me.

from birdnet-analyzer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.