tensorflow: tf.lite.Interpreter can not be used on the newest nightly version

I use the version tf-nightly==2.5.0-dev20201029 and tested the tflite model

when I use the code below to test the performance of the fastspeech tflite model, the first input can be converted to audio correctly. However, the second would be converted to audio full of noise. Only when I reload the interpreter, the model can be used for the next input.

the next audio full of noise:

interpreter = tf.lite.Interpreter(model_path="model.tflite")
for samples in data_queue:
            input_details = interpreter.get_input_details()
            output_details = interpreter.get_output_details()
            interpreter.resize_tensor_input(input_details[0]['index'], samples["input"].shape)
            interpreter.allocate_tensors()
            interpreter.set_tensor(input_details[0]['index'], samples["input"])
            interpreter.invoke()
            features = interpreter.get_tensor(output_details[0]['index'])
            self.vocoder(features.numpy()) 

correct:

for samples in data_queue:
            interpreter = tf.lite.Interpreter(model_path="model.tflite")
            input_details = interpreter.get_input_details()
            output_details = interpreter.get_output_details()
            interpreter.resize_tensor_input(input_details[0]['index'], samples["input"].shape)
            interpreter.allocate_tensors()
            interpreter.set_tensor(input_details[0]['index'], samples["input"])
            interpreter.invoke()
            features = interpreter.get_tensor(output_details[0]['index'])
            self.vocoder(features.numpy()) 

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 38 (20 by maintainers)

Commits related to this issue

Most upvoted comments

Patch is merged. Nightly build tonight will have the fix.

I’ve root caused the issue. Preparing a fix.