环境

tensorflow = 1.12.0
bazel = 0.18.1
ubuntu = 16.04
python = 3.6.2

安装 bazel (0.18.1)

如果tensorflow是1.12.0,那么必须安装指定版本0.18.1的bazel,不然会出现很多的错误无法解决。

wget https://github.com/bazelbuild/bazel/releases/download/0.18.1/bazel-0.18.1-installer-linux-x86_64.sh
chmod +x bazel-0.18.1-installer-linux-x86_64.sh
./bazel-0.18.1-installer-linux-x86_64.sh --user

下载tensorflow工程代码

git clone https://github.com/tensorflow/tensorflow.git

编译转换工具

cd tensorflow/
bazel build tensorflow/python/tools:freeze_graph
bazel build tensorflow/contrib/lite/toco:toco

生成tflite_graph.pb文件

cd models/research/object_detection
python export_tflite_ssd_graph.py \
--pipeline_config_path=data/ssd_mobilenet_v1_coco.config \
--trained_checkpoint_prefix=data/training/model.ckpt-28189 \
--output_directory=data/output \
--add_postprocessing_op=true

利用bazel生成tflite文件

bazel-bin/tensorflow/contrib/lite/toco/toco \
--input_file=tflite_graph.pb \
--output_file=detect.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_values=128 \
--change_concat_input_ranges=false \
--default_ranges_min=0 \
--default_ranges_max=6 \
--allow_custom_ops

在Android上测试

在下面的目录中有tensorflow lite的例子,可以替换原来的detect.tflite文件,修改对应的coco_labels_list.txt文件,建议改成不一样的名称,修改代码,不然运行的时候,detect.tflitecoco_labels_list.txt会重新下载,又被覆盖掉了

 

最新文章

  1. python2.7 报错(UnicodeDecodeError: 'ascii' codec can't decode byte 0xe6 in position 0: ordinal not in range(128))
  2. View动画和属性动画
  3. storm 集群配置
  4. python--基础学习(六)sqlite数据库基本操作
  5. webapi初学项目(增删改查)
  6. 构建web应用示例
  7. linux bash: sqlplus: command not found 错误处理
  8. orientationchange不管用啊
  9. 439. Segment Tree Build II
  10. 怎么样把UIImage保存到相册
  11. C# @字符用法
  12. Math.round(11.5)等于()Math.round(-11.5)等于()
  13. hdu_5776_sum(前缀和维护)
  14. C# Webform中读取Windows AD/LDAP域用户清单
  15. mongodb和python交互
  16. 将jar包安装到本地repository中
  17. git push -u 用法
  18. Linux配置防火墙,开启80端口、3306端口
  19. tomcat ----> 源码关联/编译/....
  20. shell 发送所有内容到会话

热门文章

  1. 吴裕雄--天生自然C++语言学习笔记:C++ 预处理器
  2. Python MongoDB 创建集合
  3. oracle函数创建与调用
  4. 【Android】家庭记账本手机版开发报告七
  5. 大二暑假第六周总结--开始学习Hadoop基础(五)
  6. Day 7:TreeSet
  7. XXE--XML外部实体注入漏洞
  8. java 实现每次从list中取5000条数据放入新list
  9. 一本通1402 Vigenère密码
  10. 移动端 之 触摸事件、Tap事件和swipe事件