【发布时间】:2019-10-25 15:40:26
【问题描述】:
我看到的任何 zoo .tflite 模型的大小都不超过 3MB。在 edgetpu 上,它们运行良好。但是,当我训练自己的对象检测模型时,.pb 文件为 60MB,而 .tflite 文件也很大,为 20MB!它也被量化如下。最终结果是 edgetpu object_detection 模型上的分段错误。是什么导致这个文件这么大?将未调整大小的图像输入模型是否会导致模型变大(某些照片为 4096×2160 且未调整大小)?
来自 object_detection
训练模型
python train.py \
--logtostderr \
--train_dir=training \
--pipeline_config_path=training/ssd_mobilenet_v1_coco.config
冻结图形 - 创建 60MB .pb 文件
python export_tflite_ssd_graph.py \
--pipeline_config_path=training/ssd_mobilenet_v2_coco.config \
--trained_checkpoint_prefix=training/model.ckpt-2020 \
--output_directory=inference_graph \
--add_postprocessing_op=true
转换为 .tflite - 创建 20MB 的 .tflite 文件
tflite_convert
--graph_def_file=inference_graph/tflite_graph.pb \
--output_file=inference_graph/detect.tflite \
--inference_type=QUANTIZED_UINT8 \
--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 \
--mean_values=128 \
--std_dev_values=127 \
--allow_custom_ops \
--default_ranges_min=0 \
--default_ranges_max=6
在这个阶段,.tflite 文件被推送到谷歌珊瑚 edgetpu,模型在连接到 TPU 的 USB 摄像头上进行试验。
export DISPLAY=:0 && edgetpu_detect \
--source /dev/video1:YUY2:1280x720:20/1 \
--model ${DEMO_FILES}/detect.tflite
最终结果是分段错误。
INFO: Initialized TensorFlow Lite runtime.
glvideomixer name=mixer background=black ! glimagesink sync=False name=glsink qos=False
v4l2src device=/dev/video1 ! video/x-raw,height=720,framerate=20/1,format=YUY2,width=1280 ! glupload ! tee name=t
t. ! glupload ! queue ! mixer.
overlaysrc name=overlay ! video/x-raw,height=720,width=1280,format=BGRA ! glupload ! queue max-size-buffers=1 ! mixer.
t. ! queue max-size-buffers=1 leaky=downstream ! glfilterbin filter=glcolorscale ! video/x-raw,height=168,width=300,format=RGBA ! videoconvert ! video/x-raw,height=168,width=300,format=RGB ! videobox autocrop=True ! video/x-raw,height=300,width=300 ! appsink max-buffers=1 sync=False emit-signals=True drop=True name=appsink
Segmentation fault
【问题讨论】:
标签: python tensorflow tensorflow-lite google-coral