Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
c3d964cb
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
337
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
c3d964cb
编写于
9月 12, 2019
作者:
C
Chunwei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
up
上级
3e5ce873
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
13 addition
and
12 deletion
+13
-12
cpp_demo.md
cpp_demo.md
+13
-12
未找到文件。
cpp_demo.md
浏览文件 @
c3d964cb
...
...
@@ -21,7 +21,7 @@
进入 Paddle-Lite 目录,运行以下命令编译代码(
**需加编译选项`--build_extra=ON`确保完整编译**
):
```
shell
{% highlight shell %}
./lite/tools/build.sh
\
--arm_os=android
\
--arm_abi=armv8
\
...
...
@@ -29,17 +29,17 @@
--android_stl=c++_static
\
--build_extra=ON
\
full_publish
```
{% highlight %}
编译完成后
`./build.lite.android.armv8.gcc/inference_lite_lib.android.armv8/`
文件夹下包含:
```
bash
{% highlight shell %}
cxx/include/
cxx/lib/libpaddle_api_full_bundled.a
cxx/lib/libpaddle_api_light_bundled.a
demo/cxx/ #其中包括{include Makefile.def mobile_light}
third_party/gflags/
```
{% highlight %}
## 准备执行环境
...
...
@@ -120,20 +120,20 @@ Output[900]: 0.000586
-
加入头文件引用
```
cpp
{% highlight cpp %}
#include
<iostream>
#include
<vector>
#include "paddle_api.h"
#include "paddle_use_kernels.h"
#include "paddle_use_ops.h"
#include "paddle_use_passes.h"
```
{% highlight %}
-
通过MobileConfig设置:模型文件位置(model_dir)、线程数(thread)和能耗模式( power mode )。输入数据(input),从 MobileConfig 创建 PaddlePredictor 并执行预测。 (注:Lite还支持从memory直接加载模型,可以通过MobileConfig::set_model_buffer方法实现)
代码示例:
```
cpp
{% highlight cpp %}
// 1. Create MobileConfig
MobileConfig config;
...
...
@@ -176,7 +176,7 @@ predictor->Run();
// 7. Get output
std::unique_ptr
<const
Tensor
>
output_tensor(std::move(predictor->GetOutput(0)));
```
{% highlight %}
## CxxConfig案例: OCR_model的运行
...
...
@@ -185,7 +185,8 @@ std::unique_ptr<const Tensor> output_tensor(std::move(predictor->GetOutput(0)));
-
也可以从
[
Paddle/model项目
](
https://github.com/PaddlePaddle/models/tree/develop/PaddleCV/ocr_recognition
)
中训练出模型
2.
示例代码:
```
c++
{% highlight cpp %}
#include "paddle_api.h" // NOLINT
#include "paddle_use_kernels.h" // NOLINT
#include "paddle_use_ops.h" // NOLINT
...
...
@@ -264,18 +265,18 @@ int main(int argc, char **argv) {
RunModel();
return 0;
}
```
{% highlight %}
3.
运行方法:
参考以上代码编译出可执行文件
`OCR_DEMO`
,模型文件夹为
`ocr_attention`
。手机以USB调试、文件传输模式连接电脑
在终端中输入以下命令执行OCR model测试:
```
{% highlight shell %}
#OCR_DEMO为编译出的可执行文件名称,ocr_attention为ocr_attention模型的文件夹名称
adb push OCR_DEMO data/local/tmp
adb push ocr_attention data/local/tmp
adb shell 'cd data/local/tmp && ./OCR_DEMO --model_dir=./OCR_DEMO'
```
{% highlight %}
4.
运行结果
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录