【问题标题】:Why does the Dequantize node fail to prepare?为什么 Dequantize 节点准备失败?
【发布时间】:2020-10-02 17:25:57
【问题描述】:

背景

我正在使用 MediaPipe 进行手部跟踪,发现这对加载 MediaPipe 的 hand_landmark.tflite 模型很有用 wrapper。它在带有 Tensorflow 1.14.0 的 Ubuntu 18.04 上对我来说没有任何问题。

但是,当我尝试使用最近发布的model 时,我遇到了以下错误:

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.

查看 Netron 中的两个模型时,我可以看到较新的模型使用 Dequantize 类型的节点,这似乎会导致问题。由于我是 TensorFlow 的初学者,所以我真的不知道从哪里开始。

重现错误的代码

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()

问题

问题是否与我正在使用的 Tensorflow 版本有关,或者在加载 .tflite 模型时我做错了什么?

【问题讨论】:

    标签: python tensorflow mediapipe


    【解决方案1】:

    不适用于 TF 1.14.0。您至少需要 1.15.2

    【讨论】:

    • 您能否提供更多信息,因为它不适用于 1.14?
    • 不兼容。
    • @user13737663 谢谢,这实际上是问题所在!如果在使用pip 时找不到这个版本的Tensorflow,请确保pip 至少在version 1.19
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-03-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多