[英]Tensorflow: TFLiteConverter (Saved Model -> TFLite) in SSD_mobilenet_v2_2
I have installed tensorflow 2.3.1, my ssd_mobile_net_v2_2 was downloaded from https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2 .我已经安装了 tensorflow 2.3.1,我的 ssd_mobile_net_v2_2 是从https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2下载的。 I want to convert this model to tf_lite version.
我想将此模型转换为 tf_lite 版本。 My code is:
我的代码是:
But error occurs:但是出现错误:
tensorflow.lite.python.convert.ConverterError: :0: error: loc("Func/StatefulPartitionedCall/input/_0"): requires all operands and results to have compatible element types :0: note: loc("Func/StatefulPartitionedCall/input/_0"): see current operation: %1 = "tf.Identity"(%arg0) {device = ""} : (tensor<1x320x320x3x!tf.quint8>) -> tensor<1x320x320x3xui8> tensorflow.lite.python.convert.ConverterError: :0: error: loc("Func/StatefulPartitionedCall/input/_0"): 要求所有操作数和结果具有兼容的元素类型:0: 注意: loc("Func/StatefulPartitionedCall/ input/_0"):查看当前操作:%1 = "tf.Identity"(%arg0) {device = ""} : (tensor<1x320x320x3x!tf.quint8>) -> tensor<1x320x320x3xui8>
it seems I need to set the input-data-type, but I don't know how to do that.似乎我需要设置输入数据类型,但我不知道该怎么做。
Thanks a lot for your replying.非常感谢您的回复。
I looked at this and found this:我看着这个,发现这个:
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model("ssd_mobilenet_v2_2",signature_keys=['serving_default'])
converter.optimizations = [tf.lite.Optimize.DEFAULT]
converter.experimental_new_converter = True
converter.target_spec.supported_ops = [tf.lite.OpsSet.TFLITE_BUILTINS, tf.lite.OpsSet.SELECT_TF_OPS]
model = converter.convert()
open("converted_model.tflite", "wb").write(model)
I'm using tensorflow-nightly
I didn't tried with another version我
tensorflow-nightly
在使用tensorflow-nightly
我没有尝试过其他版本
solution from: https://github.com/tensorflow/tensorflow/issues/42114#issuecomment-671593386解决方案来自: https : //github.com/tensorflow/tensorflow/issues/42114#issuecomment-671593386
note: tf-nightly==2.4注意:tf-nightly==2.4
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.