0

Background

I'm playing around with MediaPipe for hand tracking and found this useful wrapper for loading MediaPipe's hand_landmark.tflite model. It works without any problems for me on Ubuntu 18.04 with Tensorflow 1.14.0.

However, when I try use a newer recently released model, I run into the following error:

INFO: Initialized TensorFlow Lite runtime.
Traceback (most recent call last):
  File "/home/user/code/.../repo/models/test_model.py", line 12, in <module>
    use_mediapipe_model()
  File "/home/user/code/.../repo/models/test_model.py", line 8, in use_mediapipe_model
    interp_joint.allocate_tensors()
  File "/home/user/code/env/lib/python3.6/site-packages/tensorflow/lite/python/interpreter.py", line 95, in allocate_tensors
    return self._interpreter.AllocateTensors()
  File "/home/user/code/env/lib/python3.6/site-packages/tensorflow/lite/python/interpreter_wrapper/tensorflow_wrap_interpreter_wrapper.py", line 106, in AllocateTensors
    return _tensorflow_wrap_interpreter_wrapper.InterpreterWrapper_AllocateTensors(self)
RuntimeError: tensorflow/lite/kernels/dequantize.cc:62 op_context.input->type == kTfLiteUInt8 || op_context.input->type == kTfLiteInt8 was not true.Node number 0 (DEQUANTIZE) failed to prepare.

When looking at the two models in Netron, I can see that the newer model uses nodes of the type Dequantize which seem to cause the problem. As I'm a beginner when it comes to Tensorflow I don't really know where to go from here.

Code to reproduce the error

from pathlib import Path
import tensorflow as tf


def use_mediapipe_model():
    interp_joint = tf.lite.Interpreter(
        f"{Path(__file__).parent}/hand_landmark.tflite") # path to model
    interp_joint.allocate_tensors()


if __name__ == "__main__":
    use_mediapipe_model()

Question

Is the problem related to the version of Tensorflow that I'm using or am I doing something wrong when it comes to loading the .tflite models?

hlzl
  • 479
  • 2
  • 5
  • 17

1 Answers1

0

Doesn't work in TF 1.14.0. You need at least 1.15.2

  • can you provide more info because it is not work on 1.14 ? – Vidal Jun 13 '20 at 02:42
  • Not compatible. – user13737663 Jun 13 '20 at 03:02
  • @user13737663 Thanks, that in fact was the problem! If you can't find this version of Tensorflow when using `pip`, make sure `pip` is at least at [version 1.19](https://github.com/tensorflow/tensorflow/issues/34302). – hlzl Jun 18 '20 at 12:04