通过冻图生成tflite文件:
tensorflow-master$> bazel build tensorflow/contrib/lite/toco:toco
tensorflow-master$> bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_file=/home/tclxa/TCL/tmp/frozen_model.pb \
--input_format=TENSORFLOW_GRAPHDEF \
--output_format=TFLITE \
--output_file=/home/tclxa/TCL/tmp/mobilenet_quant_v1_224.tflite \
--inference_type=FLOAT \
--input_type=FLOAT \
--input_arrays=input \
--output_arrays=MobilenetV1/Predictions/Reshape_1 \
--input_shapes=1,224,224,3
–output_file、–inference_type、–input_type、–input_arrays、–output_arrays、–input_shapes需要根据自己模型说明作相应的修改
通过ckpt和结构pb生成冻图:.ckpt和结构.pb文件
tensorflow-master$> bazel build tensorflow/python/tools:freeze_graph
tensorflow-master$> bazel-bin/tensorflow/python/tools/freeze_graph \
--input_graph=/home/tclxa/TCL/tmp/mobilenet_v1_224.pb \
--input_checkpoint=/home/tclxa/TCL/tmp/mobilenet-10202.ckpt \
--input_binary=true \
--output_graph=/home/tclxa/TCL/tmp/frozen_model.pb \
--output_node_names=MobileNet/Predictions/Reshape_1
–input_graph、–input_checkpoint、–output_graph、–output_node_names需要根据自己模型说明作相应的修改
adb调试:
将手机文件拷贝到电脑上:adb pull /mnt/sdcard/DCIM/Imgtest/test-dep.jpg /home/tclxa/TCL/tmp
进入手机命令:adb shell
错误:
Bug1:
2018-08-17 13:14:04.041593: F tensorflow/contrib/lite/toco/model_cmdline_flags.cc:331] Check failed:
absl::SimpleAtoi(dim_str, &size) Failed to parse input_shape: 1,
Solve:
命令中有空格