将Mobilenet模型转换为tflite后的结果很奇怪

时间:2019-07-15 10:10:32

标签: android tensorflow mobilenet

我正在尝试完成以下教程: https://medium.com/tensorflow/training-and-serving-a-realtime-mobile-object-detector-in-30-minutes-with-cloud-tpus-b78971cf1193

现在,我被困在最后一步。 我在本地进行了培训,效果很好,因此我将模型转换为冻结图格式。

python object_detection/export_tflite_ssd_graph.py \
--pipeline_config_path ssd_mobilenet_v2_coco.config \
--trained_checkpoint_prefix logs/model.ckpt-947 \
--output_directory object_detection/ \
--add_postprocessing_op=true

这给了我tflite优化图。 为了转换为tflite格式,我使用了以下转换:

tflite_convert --graph_def_file tflite_graph.pb \
--output_file finderPattern.tflite\
--input_shapes=1,300,300,3 \
--input_arrays=normalized_input_image_tensor \
--output_arrays='TFLite_Detection_PostProcess','TFLite_Detection_PostProcess:1','TFLite_Detection_PostProcess:2','TFLite_Detection_PostProcess:3' \
--inference_type=QUANTIZED_UINT8 \
--mean_values=128 \
--std_dev_values=128 \
--change_concat_input_ranges=false \
--allow_custom_ops \
--default_ranges_min=0 \
--default_ranges_max=1

在这里,我必须添加default_ragnes_stats,否则转换将以以下错误结束:

2019-07-15 12:01:26.232294: F tensorflow/lite/toco/tooling_util.cc:1726] Array FeatureExtractor/MobilenetV2/Conv/Relu6, which is an input to the DepthwiseConv operator producing the output array FeatureExtractor/MobilenetV2/expanded_conv/depthwise/Relu6, is lacking min/max data, which is necessary for quantization. If accuracy matters, either target a non-quantized output format, or run quantized training with your model from a floating point checkpoint to change the input graph to contain min/max information. If you don't care about accuracy, you can pass --default_ranges_min= and --default_ranges_max= for easy experimentation.
Aborted

也许我使用的参数错误,因为我找不到关于最小和最大的任何明智的文档。 设置了参数后,转换效果很好。 (不能像错误按摩所暗示的那样留空) 在示例android应用中运行网络会给我一些奇怪的结果。 每个bbox都有50%的概率,并且不会在输入图像不移动的情况下移动太多。 我尝试了不同的最小和最大设置,但结果没有任何变化。 也许有人可以指出我的错误。

Strange bboxes

0 个答案:

没有答案
相关问题