Skip to content

Tensorflow 2.17.0 breaks embedding workflow #125

@acmiyaguchi

Description

@acmiyaguchi

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions