我有一个与模型动物园中的所有模型相同的已保存的 tensorflow 模型。
我想将其转换为 tesorflow lite,我从 tensorflow github 中找到了以下方法(我的 tensorflw 版本是 2):
!wget http://download.tensorflow.org/models/object_detection/tf2/20200711/ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
# extract the downloaded file
!tar -xzvf ssd_resnet50_v1_fpn_640x640_coco17_tpu-8.tar.gz
Run Code Online (Sandbox Code Playgroud)
!pip install tf-nightly
import tensorflow as tf
converter = tf.lite.TFLiteConverter.from_saved_model('ssd_mobilenet_v2_320x320_coco17_tpu-8/saved_model')
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]
tflite_model = converter.convert()
open("m.tflite", "wb").write(tflite_model)
Run Code Online (Sandbox Code Playgroud)
但是转换模型的输出和输入形状与原始模型不匹配,请检查以下内容:
所以这里有问题!输入/输出形状应该与原始模型相匹配!任何的想法?