无法将.pb图转换为tflite

问题描述 投票:0回答:1

我正在为Android创建自定义对象检测示例,我使用ssd_mobilenet_v1_coco预训练模型进行了转移学习,并获得了不错的准确性。我还使用终端中的此行代码成功地将model.ckpt-XXXX导出到.pb tflite图(从github克隆Tensorflow Object Detection API之后从object_detection文件夹运行):

python export_tflite_ssd_graph.py --pipeline_config_path=training/ssd_mobilenet_v1_coco.config --trained_checkpoint_prefix=training/model.ckpt-40500--output_directory=tflite --add_postprocessing_op=true

上面创建了一个文件夹tflite,其中包含2个文件:

  1. tflite_graph.pb
  2. tflite_graph.pbtxt

但是,当我想将tflite_graph.pb转换为detect.tflite时,出现以下错误,程序突然结束:

"TOCO failed. See console for info.\n%s\n%s\n" % (stdout, stderr))
tensorflow.lite.python.convert.ConverterError: TOCO failed.

.
.
.
Check failed: input_array_dims[i] == input_array_proto.shape().dims(i) (300 vs. 128)
Fatal Python error: Aborted
.
.
.

这是我用来将.pb转换为.tflite的命令:

tflite_convert --graph_def_file=tflite/tflite_graph.pb --output_file=tflite/detect.tflite --input_shapes=1,128,128,3 --input_arrays=normalized_input_image_tensor --output_arrays=TFLite_Detection_PostProcess,TFLite_Detection_PostProcess:1,TFLite_Detection_PostProcess:2,TFLite_Detection_PostProcess:3 --allow_custom_ops

我使用的图像尺寸为128x128,因此为什么我认为那将是input_shapes。我也已经安装了Toco。

任何帮助或建议,我们将不胜感激。

python android tensorflow object-detection tensorflow-lite
1个回答
0
投票

因此,在进行了进一步的研究后,我发现这是因为模型的配置文件正在查看尺寸为300 x 300的图像。因此,我将配置文件中的图像尺寸更改为128,并且可以正常工作。

© www.soinside.com 2019 - 2024. All rights reserved.