【问题标题】:Failing to convert .pb graph to tflite无法将 .pb 图形转换为 tflite
【发布时间】:2020-04-23 09:22:24
【问题描述】:

我正在为 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】:

    所以在做进一步的研究后,我发现这是因为模型的配置文件正在查看大小为 300 x 300 的图像。所以我将配置文件中的图像尺寸更改为 128 并且它起作用了。

    【讨论】:

      猜你喜欢
      • 2019-05-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多