简体   繁体   English

Tensorflow:SSD_mobilenet_v2_2 中的 TFLiteConverter(已保存模型 -> TFLite)

[英]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 versiontensorflow-nightly在使用tensorflow-nightly我没有尝试过其他版本

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从saved_model(SSD MobileNet)创建tflite文件 - How to create a tflite file from saved_model (SSD MobileNet) Tensorflow: TFLiteConverter (Saved Model -&gt; TFLite) 要求所有操作数和结果都具有兼容的元素类型 - Tensorflow: TFLiteConverter (Saved Model -> TFLite) requires all operands and results to have compatible element types 如何在 google colab tensorflow 1.15.2 上训练自定义对象检测模型 ssd_mobilenet_v1_coco 和 ssd_inception_v2_coco? - how to train a custom object detection model ssd_mobilenet_v1_coco and ssd_inception_v2_coco on google colab tensorflow 1.15.2? model_main.py 无法训练 mobilenet ssd v2 - tensorflow object 检测 api - model_main.py fails to traing mobilenet ssd v2 - tensorflow object detection api 张量流理解“ ssd_mobilenet_v1_pets.config” - tensorflow understanding “ssd_mobilenet_v1_pets.config” 使用 Tensorflow 对象检测 API 导出没有 NMS 和边界框解码逻辑的 TFlite ssd-mobilenet - Export TFlite ssd-mobilenet without NMS and with bounding boxes decoding logic using Tensorflow Object Detection API TensorFlow将模型导出转换保存为tflite - TensorFlow saved model export conversion to tflite 对象检测tensorflow api中的ssd mobilenet v1可以尝试使用不同于默认值的调整大小形状吗? - Can ssd mobilenet v1 in object detection tensorflow api be tried with different resize shapes than the default ones? Tensorflow 的 pb 和 pbtxt 文件在重新训练 MobileNet SSD V1 COCO 后不适用于 OpenCV - Tensorflow' pb and pbtxt files don't work with OpenCV after retraining MobileNet SSD V1 COCO 使用tensorflow时,在哪里可以找到ssd_mobilenet_v1_coco的标签映射文件(pbtxt)? - Where can I find the label map file(pbtxt) of ssd_mobilenet_v1_coco when using tensorflow?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM