【问题标题】:Tensorflow Convert pb file to tfliteTensorflow 将 pb 文件转换为 tflite
【发布时间】:2019-10-02 12:11:06
【问题描述】:

我有一个 .pb 文件扩展名。我需要将此文件转换为 .tflite 才能在 Android 上使用它。但我从来没有。

我正在使用以下代码:

tflite_convert \ 
--output_file=/outputs/retrained_graph.tflite \ 
--graph_def_file=/inference_graph/frozen_inference_graph.pb \ 
--input_arrays=Mul \ 
--output_arrays=Softmax

我收到这样的错误:

2019-10-02 14:52:07.693744: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll

usage: tflite_convert [-h] --output_file OUTPUT_FILE
                      (--saved_model_dir SAVED_MODEL_DIR | --keras_model_file KERAS_MODEL_FILE)
tflite_convert: error: one of the arguments --saved_model_dir --keras_model_file is required

谁能告诉我哪里出错了?我不确定输入和输出值,我不知道如何找到它,这可能是问题吗?

\research\object_detection\inference_graph:

【问题讨论】:

    标签: python android tensorflow model


    【解决方案1】:

    tflite_convert 仅支持 keras 模型文件和保存的模型转换为 TFLite。要转换 pb 文件,您有几个选择:

    1. 将您的 tensorflow 降级到 1.14 或更低版本。在那些TFLiteConverters中,有支持pb文件转换的。
    2. 否则,如果您可以编写 Python 脚本和命令行转换,则可以在 TF 2.0 中使用tf.compat.v1.TFLiteConverter

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-08
      • 1970-01-01
      • 1970-01-01
      • 2018-01-11
      • 2018-12-09
      相关资源
      最近更新 更多