我正在为android创建一个自定义对象检测示例,我使用了ssd_mobilenet_v1_coco
预训练模型进行迁移学习,获得了相当高的精度。我还成功地在终端中使用这行代码将model.ckpt-XXXX
导出为.pb
tflite图(从github克隆Tensorflow对象检测API后从object_检测文件夹运行):
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个文件:
但是,当我想将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,因此我认为这是输入的形状。我也安装了Toco
任何帮助或建议都将不胜感激
因此,在做进一步的研究后,我发现这是因为模型的配置文件正在查看大小为300 x 300的图像。因此,我将配置文件中的images维度更改为128,并且成功了
相关问题 更多 >
编程相关推荐