我尝试将冻结的SSD mobilenet v2模型转换为TFLITE格式以供Android使用。这是我所有的步骤:
我使用模型动物园的ssd_mobilenet_v2_coco_2018_03_29模型对TF Object Detection API的train.py文件进行了重新训练。(好)
使用TF Object Detection API也提供的export_inference_graph.p y 将训练后的model.ckpt导出到冻结的模型文件。(好)
使用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)