本文是基于 https://blog.csdn.net/zhqh100/article/details/102954409 进行的后续操作,
先下载 https://github.com/tensorflow/models.git,
然后执行下面三段命令:
mkdir models
cd models
wget -c http://download.tensorflow.org/models/object_detection/ssd_mobilenet_v2_quantized_300x300_coco_2019_01_03.tar.gz
tar xvf ssd_mobilenet_v2_quantized_300x300_coco_2019_01_03.tar.gz
cd ..
mkdir output
INPUT_TYPE=image_tensor
PIPELINE_CONFIG_PATH=object_detection/samples/configs/ssd_mobilenet_v2_quantized_300x300_coco.config
TRAINED_CKPT_PREFIX=models/ssd_mobilenet_v2_quantized_300x300_coco_2019_01_03/model.ckpt
EXPORT_DIR=output
python object_detection/export_inference_graph.py \
--input_type=${INPUT_TYPE} \
--pipeline_config_path=${PIPELINE_CONFIG_PATH} \
--trained_checkpoint_prefix=${TRAINED_CKPT_PREFIX} \
--output_directory=${EXPORT_DIR}
export CONFIG_FILE=output/pipeline.config
export CHECKPOINT_PATH=output/model.ckpt
export OUTPUT_DIR=output
python object_detection/export_tflite_ssd_graph.py \
--pipeline_config_path=$CONFIG_FILE \
--trained_checkpoint_prefix=$CHECKPOINT_PATH \
--output_directory=$OUTPUT_DIR \
--add_postprocessing_op=true
cd output
tflite_convert --output_file=detect.tflite \
--graph_def_file=tflite_graph.pb \
--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=128 \