小编pta*_*s90的帖子

Tensorflow对象检测-将.pb文件转换为tflite

我尝试将冻结的SSD mobilenet v2模型转换为TFLITE格式以供Android使用。这是我所有的步骤:

  1. 我使用模型动物园的ssd_mobilenet_v2_coco_2018_03_29模型对TF Object Detection API的train.py文件进行了重新训练。(好)

  2. 使用TF Object Detection API也提供的export_inference_graph.p y 将训练后的model.ckpt导出到冻结的模型文件。(好)

  3. 使用GPU和仅允许CPU在python中测试冻结的图形。有用。(好)

不利之处在于,我尝试使用以下代码:

import tensorflow as tf
tf.enable_eager_execution()
saved_model_dir = 'inference_graph/saved_model/'
converter = tf.contrib.lite.TFLiteConverter.from_saved_model(saved_model_dir,input_arrays=input_arrays,output_arrays=output_arrays,input_shapes={"image_tensor": [1, 832, 832, 3]})
converter.post_training_quantize = True
Run Code Online (Sandbox Code Playgroud)

首先,我尝试不向函数添加输入shapes参数,但是没有用。从那时起,我读到您可以在这里写任何无关紧要的内容。

直到这一行的输出:

INFO:tensorflow:Saver not created because there are no variables in the graph to restore
INFO:tensorflow:The specified SavedModel has no variables; no checkpoints were restored.
INFO:tensorflow:The given SavedModel MetaGraphDef contains SignatureDefs with the following keys: {'serving_default'}
INFO:tensorflow:input …
Run Code Online (Sandbox Code Playgroud)

python converters tensorflow tensorflow-lite toco

5
推荐指数
1
解决办法
4388
查看次数

标签 统计

converters ×1

python ×1

tensorflow ×1

tensorflow-lite ×1

toco ×1