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

Tensorflow 2.17.0 breaks embedding workflow #125

Open
acmiyaguchi opened this issue Feb 21, 2025 · 1 comment
Open

Tensorflow 2.17.0 breaks embedding workflow #125

acmiyaguchi opened this issue Feb 21, 2025 · 1 comment

Comments

@acmiyaguchi
Copy link

I have a piece of code that extracts embeddings. This works perfectly fine tensorflow==2.16.1, but starts to break on tensorflow==2.17.0. I'm not sure why it starts to throw this error. The tensorflow changelog doesn't show anything egregious: https://github.com/tensorflow/tensorflow/releases/tag/v2.17.0

tests/inference/test_birdnet.py:6: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
inference/birdnet.py:87: in predict
    embeddings.append(self._infer(row))
inference/birdnet.py:70: in _infer
    recording.extract_embeddings()
/path/to/.venv/lib/python3.10/site-packages/birdnetlib/main.py:80: in extract_embeddings
    self.analyzer.extract_embeddings_for_recording(self)
/path/to/.venv/lib/python3.10/site-packages/birdnetlib/analyzer.py:381: in extract_embeddings_for_recording
    e = self._return_embeddings(data)[0].tolist()
/path/to/.venv/lib/python3.10/site-packages/birdnetlib/analyzer.py:454: in _return_embeddings
    features = self.interpreter.get_tensor(output_layer_index)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tensorflow.lite.python.interpreter.Interpreter object at 0xXXXXXXXXXXXX>, tensor_index = 545, subgraph_index = 0

    def get_tensor(self, tensor_index, subgraph_index=0):
      """Gets the value of the output tensor (get a copy).
    
      If you wish to avoid the copy, use `tensor()`. This function cannot be used
      to read intermediate results.
    
      Args:
        tensor_index: Tensor index of tensor to get. This value can be gotten from
          the 'index' field in get_output_details.
        subgraph_index: Index of the subgraph to fetch the tensor. Default value
          is 0, which means to fetch from the primary subgraph.
    
      Returns:
        a numpy array.
      """
>     return self._interpreter.GetTensor(tensor_index, subgraph_index)
E     ValueError: Tensor data is null. Run allocate_tensors() first

/path/to/.venv/lib/python3.10/site-packages/tensorflow/lite/python/interpreter.py:888: ValueError

The workaround is to pin tensorflow to the last known working version.

@acmiyaguchi acmiyaguchi changed the title Tensorflow 2.17.0 break embedding workflow Tensorflow 2.17.0 breaks embedding workflow Feb 21, 2025
@donnubio
Copy link

The same problem with 2.18.0.
After that, the error disappeared:

"You should load the tensorflow.lite model using:
interpreter = tf.lite.Interpreter(model_path=tflite_model_path, experimental_preserve_all_tensors=True)
..."

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

2 participants