我刚刚从 TensorHub 下载了一个模型并将其转换为 TFlite。 我试图使用转换后的模型进行对象检测,但它根本不起作用。 由于它不起作用,我想知道我是否一开始就错误地转换了模型。 下面的流程有问题吗?
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 文件已输出,没有任何错误。 但是,该文件不允许进行良好的对象检测(它首先无法处理错误)。
我认为你需要先将其转换为冻结图(.pb),然后再将其转换为.tflite。