我想使用转换为 tflite 的模型执行对象检测

问题描述 投票:0回答:1

我刚刚从 TensorHub 下载了一个模型并将其转换为 TFlite。 我试图使用转换后的模型进行对象检测,但它根本不起作用。 由于它不起作用,我想知道我是否一开始就错误地转换了模型。 下面的流程有问题吗?

  1. 从 TensorFlowHub 下载模型
  2. 解压下载的模型(我使用tar -zxvf model.tar.gz来解压)
  3. 转换模型 以下用于转换模型
import tensorflow as tf

saved_model_dir = 'model_directory'
converter = tf.lite.TFLiteConverter.from_saved_model(saved_model_dir)

# In some cases the following code was also used
# converter.target_spec.supported_ops = [
# tf.lite.OpsSet.TFLITE_BUILTINS, # enable TensorFlow Lite ops.
# tf.lite.OpsSet.SELECT_TF_OPS # enable TensorFlow ops.
# ]

tflite_model = converter.convert()

# save the model.
with open('faster-rcnn-1024-test2.tflite', 'wb') as f: f.write(tflite_model)
  f.write(tflite_model)

tflite 文件已输出,没有任何错误。 但是,该文件不允许进行良好的对象检测(它首先无法处理错误)。

python-3.x tensorflow tensorflow-lite
1个回答
0
投票

我认为你需要先将其转换为冻结图(.pb),然后再将其转换为.tflite。

© www.soinside.com 2019 - 2024. All rights reserved.