简体   繁体   中英

Tensorflow Convert pb file to tflite

I have one.pb file extension. I need to convert this file to.tflite to use it on Android. But I never did.

I'm using the following code:

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

And I get an error like this:

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

Can someone tell me where I made a mistake? I'm not sure of the input and output values, and I don't know how to find it, could this be the problem?

\research\object_detection\inference_graph:

\research\object_detection\inference_graph

tflite_convert only supports keras model file and saved models for conversion to TFLite. For converting a pb file, you have couple of options:

  1. Downgrade your tensorflow to 1.14 or lower version. In those TFLiteConverters , there is support for pb file conversion.
  2. Otherwise, you can make use of tf.compat.v1.TFLiteConverter in TF 2.0 if you are ok to write Python script and command-line conversions.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM