【问题标题】:Tensorflow frozen_graph to tflite for android appTensorflow freeze_graph 到 tflite for android app
【发布时间】:2020-01-27 17:29:41
【问题描述】:

我是 TensorFlow 对象检测库的新手。我有一个特定的数据集,我必须自己制作并用数千张 jpg 进行标记。我已经运行该文件以从这些图像中检测对象.. 以任何方式。过程结束时我得到了 freeze_graph 并从中我将 model.ckpl 文件导出到推理图文件夹一切正常,并且我已经测试了 model.ckpl object_detection.ipynb 文件上的模型它工作正常。直到这一步,没有问题。 但是,我无法理解如何将该 model.ckpl 文件转换为 model.tflite 文件以在 android studio 应用程序上使用。

我看到很多东西 like 但我不知道 input_tensors = [...] 输出张量 = [...] 我可能已经知道,但它实际上是什么......

你能告诉我如何转换它吗?

【问题讨论】:

    标签: tensorflow tensorflow-lite


    【解决方案1】:

    如果您从头开始训练模型,则必须拥有 .meta 文件。您还需要指定输出节点名称,您可以使用该名称创建 .pb 文件。有关创建此文件的步骤,请参阅以下链接:

    Tensorflow: How to convert .meta, .data and .index model files into one graph.pb file

    创建后,您可以进一步将 .pb 转换为 tflite,如下所示:

    import tensorflow as tf
    
    graph_def_file = "model.pb"
    input_arrays = ["model_inputs"]
    output_arrays = ["model_outputs"]
    
    converter = tf.lite.TFLiteConverter.from_frozen_graph(
            graph_def_file, input_arrays, output_arrays)
    
    tflite_model = converter.convert()
    
    open("converted_model.tflite", "wb").write(tflite_model)
    

    【讨论】:

      【解决方案2】:

      如果您不知道自己的输入和输出,请使用 summarise_graph 工具并将其提供给您的冻结模型。 在这里查看命令 https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/graph_transforms#inspecting-graphs

      【讨论】:

        【解决方案3】:

        【讨论】:

        • 感谢您的努力,但我还没有找到。最好的问候。
        猜你喜欢
        • 1970-01-01
        • 2020-07-13
        • 2019-07-12
        • 1970-01-01
        • 1970-01-01
        • 2019-01-22
        • 1970-01-01
        • 2019-06-10
        • 1970-01-01
        相关资源
        最近更新 更多