object detection模型转换成TensorFlow Lite,在Android应用
环境
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.tflite和coco_labels_list.txt会重新下载,又被覆盖掉了
object detection模型转换成TensorFlow Lite,在Android应用的更多相关文章
- TensorFlow Lite for Android示例
一.TensorFlow Lite TensorFlow Lite 是用于移动设备和嵌入式设备的轻量级解决方案.TensorFlow Lite 支持 Android.iOS 甚至树莓派等多种平台. ...
- 【tensorflow-v2.0】如何将模型转换成tflite模型
前言 TensorFlow Lite 提供了转换 TensorFlow 模型,并在移动端(mobile).嵌入式(embeded)和物联网(IoT)设备上运行 TensorFlow 模型所需的所有工具 ...
- Linux下ffmpeg添加Facebook/transform代码块实现将全景视频的球模型转换成立方体模型
Facebook事实上已开始在平台中支持360度全景视频的流播,但公司对此并不满足.其工程师更是基于锥体几何学设计出了一套全新的视频编码,号称最高能将全景视频的文件大小减少80%.(VR最新突破:全景 ...
- java中object数据怎么转换成json数据
可以通过这个(json-lib-2.3-jdk15.jar)jar里的方法转换 JSONObject json = JSONObject.fromObject(Object); 如果对象数组 JSON ...
- 评价目标检测(object detection)模型的参数:IOU,AP,mAP
首先我们为什么要使用这些呢? 举个简单的例子,假设我们图像里面只有1个目标,但是定位出来10个框,1个正确的,9个错误的,那么你要按(识别出来的正确的目标/总的正确目标)来算,正确率100%,但是其实 ...
- Tensorflow Lite从入门到精通
TensorFlow Lite 是 TensorFlow 在移动和 IoT 等边缘设备端的解决方案,提供了 Java.Python 和 C++ API 库,可以运行在 Android.iOS 和 Ra ...
- TensorFlow Object Detection API(Windows下训练)
本文为作者原创,转载请注明出处(http://www.cnblogs.com/mar-q/)by 负赑屃 最近事情比较多,前面坑挖的有点久,今天终于有时间总结一下,顺便把Windows下训练跑通.Li ...
- 移动端目标识别(3)——使用TensorFlow Lite将tensorflow模型部署到移动端(ssd)之Running on mobile with TensorFlow Lite (写的很乱,回头更新一个简洁的版本)
承接移动端目标识别(2) 使用TensorFlow Lite在移动设备上运行 在本节中,我们将向您展示如何使用TensorFlow Lite获得更小的模型,并允许您利用针对移动设备优化 ...
- 基于ssd的手势识别模型(object detection api方式)
[Tensorflow]Object Detection API-训练自己的手势识别模型 1. 安装tensorflow以及下载object detection api 1.安装tensorflow: ...
随机推荐
- JavaScript获取当前日期前后7天的日期
function fun_date(aa){ var date1 = new Date(), time1=date1.getFullYear()+"-"+(date1.getMon ...
- 电脑使用热键时是否需按住Fn键相关说明
ThinkPad E系列机型 方法一: 在开机出现ThinkPad标志时,连续点F1(若无反应,请尝试Fn+F1)进入BIOS设置. 在BIOS中,依次选择Config---Keyboard/Mous ...
- POJ 1004:Financial Management
Financial Management Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 165062 Accepted: ...
- tensorflow--保存加载模型
s=mnist.train.next_batch(batch_size)print(xs.shape)print(ys.shape) # #从集合中取全部变量# tf.get_collection() ...
- 抗干扰性极强非接触式读卡13.56mhz芯片:SI522
由于智能门锁产品不断地火爆,市场上的不断出现破解的方法.对此中科微联合深圳市动能世纪科技有限公司不断满足市场需求,推出一款抗干扰性极强的13.56mhz芯片. 该芯片出了抗干扰性强以外还直接PIN2P ...
- PHP上传图片,路径保存在数据库中,根据图片路径显示图片
1.创建数据表 CREATE TABLE image( id int(4) unsigned NOT NULL AUTO_INCREMENT, name varchar(100) default ...
- 一本通1166 求f(x,n)
[题目描述] 已知 计算x=4.2,n=1以及x=2.5,n=15时f的值. [输入] 输入x和n. [输出] 函数值,保留两位小数. [输入样例] 4.2 10 [输出样例] 3.68 1.看见这种 ...
- 实验吧web-中-忘记密码了
打开网页,查看源代码,好像发现了管理员邮箱而且还是用vim编辑的. 我们提交一下这个邮箱,虽然提交成功了,但好像并没什么用. 我们随便提交一个,会弹出 看来好像还有个step2呢,我们查看源代码(在这 ...
- css代码实现列表等宽
实现上面的手机页面,我们会遇到一个自适应的问题,但是手机页面的屏幕大小不一致,自适应的问题不是百分比可以好好解决的,我采用下面的布局:display:flex; <!DOCTYPE html&g ...
- C++优先队列详解
转自csdn的文章,仅作为学习笔记.原文链接:https://blog.csdn.net/weixin_36888577/article/details/79937886 普通的队列是一种先进先出的数 ...