【发布时间】:2020-01-19 21:41:28
【问题描述】:
我在 Windows 10 上使用 Tensorflow 2,我从 TensorFlow Detection Model Zoo. 下载了一个模型
我使用的模型是ssd.mobilenetv2.oid4
型号详情如下:
[<tf.Tensor 'image_tensor:0' shape=(None, None, None, 3) dtype=uint8>]
注意:我还提供了 freeze_inference_graph.pb 以及配置文件和检查点。
我使用 TensorFlowLiteConverter Snippet 将 saved_model.pb 文件转换为具有自定义形状的 .tflite:
import tensorflow as tf
input_dir = "D:\\Models\\ssd_mobilenet_v2_oid_v4_2018_12_12\\saved_model"
model = tf.saved_model.load(input_dir)
concrete_func = model.signatures[
tf.saved_model.DEFAULT_SERVING_SIGNATURE_DEF_KEY]
concrete_func.inputs[0].set_shape([None, None, None, 3])
converter = tf.lite.TFLiteConverter.from_concrete_functions([concrete_func])
tflite_model = converter.convert()
我收到以下错误:
Traceback (most recent call last):
File "C:\Users\Bhavin\Desktop\TensorFlow_pb_converter.py", line 10, in <module>
tflite_model = converter.convert()
File "C:\Users\Bhavin\AppData\Local\Programs\Python\Python36\lib\site-packages\tensorflow_core\lite\python\lite.py", line 428, in convert
"invalid shape '{1}'.".format(_get_tensor_name(tensor), shape_list))
ValueError: None is only supported in the 1st dimension. Tensor 'image_tensor' has invalid shape '[None, None, None, 3]'
我尝试使用 toco 和 tflite_convert 但我得到了同样的错误。
我做错了什么以及如何将此 pb 文件转换为 tflite 文件?
【问题讨论】:
-
您的问题解决了吗?我也有同样的需求。@Renegade
标签: tensorflow2.0 tensorflow-lite