我已經安裝了tensorflow 2.3.1,我的ssd_mobile_net_v2_2是從https://tfhub.dev/tensorflow/ssd_mobilenet_v2/2下載的。我想將此模型轉換為 tf_lite 版本。我的代碼是:但出現錯誤:tensorflow.lite.python.convert.ConverterError::0:錯誤:loc(“Func/StatefulPartitionedCall/input/_0”):要求所有操作數和結果具有兼容的元素類型:0:注意:loc(“Func/StatefulPartitionedCall/ input/_0"): 查看當前操作: %1 = "tf.Identity"(%arg0) {device = ""} : (tensor<1x320x320x3x!tf.quint8>) -> tensor<1x320x320x3xui8>看來我需要設置輸入數據類型,但我不知道該怎么做。非常感謝您的回復。
2 回答

慕雪6442864
TA貢獻1812條經驗 獲得超5個贊
解決方案來自: https: //github.com/tensorflow/tensorflow/issues/42114#issuecomment-671593386
注意:tf-nightly==2.4

瀟湘沐
TA貢獻1816條經驗 獲得超6個贊
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)
我正在使用tensorflow-nightly我沒有嘗試過其他版本
添加回答
舉報
0/150
提交
取消