【问题标题】:How to convert CustomVision.ai TensorFlow/TensorFlow Lite model into something that works with TFLite Object Detection API?如何将 CustomVision.ai TensorFlow/TensorFlow Lite 模型转换为适用于 TFLite 对象检测 API 的模型?
【发布时间】:2021-08-14 03:40:06
【问题描述】:

我们有一个从 CustomVision.ai 导出的模型(它支持导出 TensorFlow .pb、TensorFlow Lite .tflite、Saved Model .pp 格式)。

我们希望将此模型集成到使用 TFLite 对象检测 API 的现有应用程序中,该应用程序需要以下输入和输出:

--input_arrays=normalized_input_image_tensor \
--output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' \

模型似乎有非常不同的输入和输出:

Inputs array: Placeholder
name: Placeholder
type: float32[1,416,416,3]
quantization: 0 ≤ q ≤ 255
location: 0

Outputs array: model_outputs
name: model_outputs
type: float32[1,13,13,45]
location: 44

如果我运行“tflite_convert”命令

tflite_convert \
    --graph_def_file=model.pb \
    --output_file=detect.tflite \
    --input_shapes=1,416,416,3 \
    --input_arrays=normalized_input_image_tensor \
    --output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' \
    --inference_type=FLOAT  \
    --allow_custom_ops

我明白了:

ValueError: Invalid tensors 'normalized_input_image_tensor' were found.

知道如何让它工作吗?我整天都在挖,结果只是干了……任何帮助将不胜感激!谢谢!

【问题讨论】:

    标签: tensorflow tensorflow-lite object-detection-api microsoft-custom-vision


    【解决方案1】:

    并非所有模型都与 TensorFlow Lite 对象检测 API 兼容。

    您的上述模型不适合 TensorFlow Lite 对象检测compatible

    例如,输入签名需要一个图像张量,输出签名需要 TensorFlow Lite 对象检测 API 获取四个张量。

    请考虑使用 TensorFlow Lite Model Maker 或 TF Model Garden 的 Object Detector API 来生成兼容的模型。

    【讨论】:

    • 感谢您的回复!有什么办法可以让模型兼容吗?
    猜你喜欢
    • 2021-01-15
    • 1970-01-01
    • 2020-12-03
    • 2020-10-14
    • 2019-05-06
    • 2018-09-07
    • 1970-01-01
    • 1970-01-01
    • 2019-04-14
    相关资源
    最近更新 更多