Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
ef7ebd08
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
ef7ebd08
编写于
11月 25, 2021
作者:
C
cuicheng01
提交者:
GitHub
11月 25, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update tipc lite docs (#5390)
* update tipc lite docs * update tipc lite docs
上级
f5c8dac5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
152 addition
and
53 deletion
+152
-53
docs/tipc_test/development_specification_docs/Lite_arm_cpu_cpp_infer.md
.../development_specification_docs/Lite_arm_cpu_cpp_infer.md
+75
-25
docs/tipc_test/development_specification_docs/Lite_arm_gpu_opencl_cpp_infer.md
...pment_specification_docs/Lite_arm_gpu_opencl_cpp_infer.md
+77
-28
未找到文件。
docs/tipc_test/development_specification_docs/Lite_arm_cpu_cpp_infer.md
浏览文件 @
ef7ebd08
...
...
@@ -56,14 +56,14 @@ Lite预测测试工具位于PaddleOCR dygraph分支下的test_tipc目录,与Li
test_tipc/
├── common_func.sh
├── configs # 配置文件目录
│ ├──
ppocr_det_mobile
│ ├──
ch_PP-OCRv2_det
│ │ ├── model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt
│ │ ├── ...
│ ├── ...
│ ├──
ppocr_system_mobile
│ ├──
ch_PP-OCRv2
│ │ ├── model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt
│ │ └── ...
├── prepare_lite_cpp.sh # 完成test_
cpu_cpp
.sh运行所需要的数据和模型下载
├── prepare_lite_cpp.sh # 完成test_
lite_**
.sh运行所需要的数据和模型下载
├── test_lite_arm_cpp.sh # lite测试主程序
```
...
...
@@ -89,9 +89,18 @@ Lite端ARM_CPU预测接入TIPC包含如下三个步骤,接下来将依次介
以PaddleOCR文本检测模型为例,使用方式:
下载Paddle-Lite预测库的方式:
```
bash test_tipc/prepare_lite_arm_cpp.sh test_tipc/configs/ch_PP-OCRv2_det/model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt download
```
编译Paddle-Lite预测库的方式:
```
bash test_tipc/prepare_lite_arm_cpp.sh test_tipc/configs/ppocr_det_mobile/model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt
```
bash test_tipc/prepare_lite_arm_cpp.sh test_tipc/configs/ch_PP-OCRv2_det/model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt compile
```
`prepare_lite_arm_cpp.sh`
具体内容:
1.
解析
`model_linux_gpu_normal_normal_lite_cpp_arm_cpu.txt`
部分用于预测的参数字段,方便后续预测。
...
...
@@ -104,6 +113,7 @@ dataline=$(cat ${FILENAME})
IFS=$'\n'
lines=(${dataline})
IFS=$'\n'
paddlelite_library_source=$2
inference_cmd=$(func_parser_value "${lines[1]}")
DEVICE=$(func_parser_value "${lines[2]}")
...
...
@@ -112,10 +122,29 @@ rec_lite_model_list=$(func_parser_value "${lines[4]}")
cls_lite_model_list=$(func_parser_value "${lines[5]}")
```
2.
转换
`infernce model`
到Lite预测的
`.nb`
模型
2.
填写不同硬件设备需要的信息
```
if [ ${DEVICE} = "ARM_CPU" ];then
valid_targets="arm"
paddlelite_library_url="https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.android.armv8.gcc.c++_shared.with_extra.with_cv.tar.gz"
end_index="66"
compile_with_opencl="OFF"
elif [ ${DEVICE} = "ARM_GPU_OPENCL" ];then
valid_targets="opencl"
paddlelite_library_url="https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.armv8.clang.with_exception.with_extra.with_cv.opencl.tar.gz"
end_index="71"
compile_with_opencl="ON"
else
echo "DEVICE only support ARM_CPU, ARM_GPU_OPENCL."
exit 2
fi
```
3.
转换
`infernce model`
到Lite预测的
`.nb`
模型
```
# prepare
lite .nb
model
# prepare
paddlelite
model
if [[ $inference_cmd =~ "det" ]];then
lite_model_list=${det_lite_model_list}
elif [[ $inference_cmd =~ "rec" ]];then
...
...
@@ -127,6 +156,11 @@ else
exit 1
fi
pip install paddlelite==2.10-rc
current_dir=${PWD}
IFS="|"
model_path=./inference_models
for model in ${lite_model_list[*]}; do
if [[ $model =~ "PP-OCRv2" ]];then
inference_model_url=https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/${model}.tar
...
...
@@ -146,37 +180,51 @@ for model in ${lite_model_list[*]}; do
done
```
3
.
准备测试数据
4
.
准备测试数据
```
data_url=https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
model_path=./inference_models
inference_model=${inference_model_url##*/}
data_file=${data_url##*/}
wget -nc -P ./inference_models ${inference_model_url}
wget -nc -P ./test_data ${data_url}
cd ./inference_models && tar -xf ${inference_model} && cd ../
cd ./test_data && tar -xf ${data_file} && rm ${data_file} && cd ../
```
4
.
准备Lite预测环境,此处需要下载或者编译Paddle-Lite预测库。
5
.
准备Lite预测环境,此处需要下载或者编译Paddle-Lite预测库。
```
# prepare lite env
paddlelite_zipfile=$(echo $paddlelite_url | awk -F "/" '{print $NF}')
paddlelite_file=${paddlelite_zipfile:0:${end_index}}
wget ${paddlelite_url} && tar -xf ${paddlelite_zipfile}
mkdir -p ${paddlelite_file}/demo/cxx/ocr/test_lite
cp -r ${model_path}/*_opt.nb test_data ${paddlelite_file}/demo/cxx/ocr/test_lite
cp ppocr/utils/ppocr_keys_v1.txt deploy/lite/config.txt ${paddlelite_file}/demo/cxx/ocr/test_lite
cp -r ./deploy/lite/* ${paddlelite_file}/demo/cxx/ocr/
cp ${paddlelite_file}/cxx/lib/libpaddle_light_api_shared.so ${paddlelite_file}/demo/cxx/ocr/test_lite
cp ${FILENAME} test_tipc/test_lite_arm_cpp.sh test_tipc/common_func.sh ${paddlelite_file}/demo/cxx/ocr/test_lite
cd ${paddlelite_file}/demo/cxx/ocr/
if [[ ${paddlelite_library_source} = "download" ]]; then
paddlelite_library_zipfile=$(echo $paddlelite_library_url | awk -F "/" '{print $NF}')
paddlelite_library_file=${paddlelite_library_zipfile:0:${end_index}}
wget ${paddlelite_library_url} && tar -xf ${paddlelite_library_zipfile}
cd ${paddlelite_library_zipfile}
elif [[ ${paddlelite_library_source} = "compile" ]]; then
git clone -b release/v2.10 https://github.com/PaddlePaddle/Paddle-Lite.git
cd Paddle-Lite
./lite/tools/build_android.sh --arch=armv8 --with_cv=ON --with_extra=ON --toolchain=clang --with_opencl=${compile_with_opencl}
cd ../
cp -r Paddle-Lite/build.lite.android.armv8.clang/inference_lite_lib.android.armv8/ .
paddlelite_library_file=inference_lite_lib.android.armv8
else
echo "paddlelite_library_source only support 'download' and 'compile'"
exit 3
fi
```
6.
准备编译以及后续在Lite设备上测试需要的文件
```
mkdir -p ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp -r ${model_path}/*_opt.nb test_data ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp ppocr/utils/ppocr_keys_v1.txt deploy/lite/config.txt ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp -r ./deploy/lite/* ${paddlelite_library_file}/demo/cxx/ocr/
cp ${paddlelite_library_file}/cxx/lib/libpaddle_light_api_shared.so ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp ${FILENAME} test_tipc/test_lite_arm_cpp.sh test_tipc/common_func.sh ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cd ${paddlelite_library_file}/demo/cxx/ocr/
git clone https://github.com/cuicheng01/AutoLog.git
```
5.
交叉编译获得在手机上的可以运行的可执行文件
7.
交叉编译获得在手机上的可以运行的可执行文件及删除当前目录下无用文件
```
make -j
...
...
@@ -184,9 +232,11 @@ sleep 1
make -j
cp ocr_db_crnn test_lite && cp test_lite/libpaddle_light_api_shared.so test_lite/libc++_shared.so
tar -cf test_lite.tar ./test_lite && cp test_lite.tar ${current_dir} && cd ${current_dir}
rm -rf ${paddlelite_file}* && rm -rf ${model_path}
rm -rf ${paddlelite_
library_
file}* && rm -rf ${model_path}
```
运行结果会在当前目录上生成test_lite.tar,里边的内容大致如下:
```
├── common_func.sh # 通用函数,如解析参数等
...
...
docs/tipc_test/development_specification_docs/Lite_arm_gpu_opencl_cpp_infer.md
浏览文件 @
ef7ebd08
...
...
@@ -56,14 +56,14 @@ Lite预测测试工具位于PaddleOCR dygraph分支下的test_tipc目录,与Li
test_tipc/
├── common_func.sh
├── configs # 配置文件目录
│ ├──
ppocr_det_mobile
│ ├──
ch_PP-OCRv2_det
│ │ ├── model_linux_gpu_normal_normal_lite_cpp_arm_gpu_opencl.txt
│ │ ├── ...
│ ├── ...
│ ├──
ppocr_system_mobile
│ ├──
ch_PP-OCRv2
│ │ ├── model_linux_gpu_normal_normal_lite_cpp_arm_gpu_opencl.txt
│ │ └── ...
├── prepare_lite_cpp.sh # 完成test_
arm_cpp
.sh运行所需要的数据和模型下载
├── prepare_lite_cpp.sh # 完成test_
lite_**
.sh运行所需要的数据和模型下载
├── test_lite_arm_cpp.sh # lite测试主程序
```
...
...
@@ -89,12 +89,22 @@ Lite端ARM_GPU_OPENCL预测接入TIPC包含如下三个步骤,接下来将依
以PaddleOCR文本检测模型为例,使用方式:
下载Paddle-Lite预测库的方式:
```
bash test_tipc/prepare_lite_arm_cpp.sh test_tipc/configs/ppocr_det_mobile/model_linux_gpu_normal_normal_lite_cpp_arm_gpu_opencl.txt
```
bash test_tipc/prepare_lite_arm_cpp.sh test_tipc/configs/ch_PP-OCRv2_det/model_linux_gpu_normal_normal_lite_cpp_arm_gpu_opencl.txt download
```
编译Paddle-Lite预测库的方式:
```
bash test_tipc/prepare_lite_arm_cpp.sh test_tipc/configs/ch_PP-OCRv2_det/model_linux_gpu_normal_normal_lite_cpp_arm_gpu_opencl.txt compile
```
`prepare_lite_arm_cpp.sh`
具体内容:
1.
解析
`model_linux_gpu_normal_normal_lite_cpp_arm_
gpu_opencl
.txt`
部分用于预测的参数字段,方便后续预测。
1.
解析
`model_linux_gpu_normal_normal_lite_cpp_arm_
cpu
.txt`
部分用于预测的参数字段,方便后续预测。
```
source ./test_tipc/common_func.sh
...
...
@@ -104,6 +114,7 @@ dataline=$(cat ${FILENAME})
IFS=$'\n'
lines=(${dataline})
IFS=$'\n'
paddlelite_library_source=$2
inference_cmd=$(func_parser_value "${lines[1]}")
DEVICE=$(func_parser_value "${lines[2]}")
...
...
@@ -112,10 +123,29 @@ rec_lite_model_list=$(func_parser_value "${lines[4]}")
cls_lite_model_list=$(func_parser_value "${lines[5]}")
```
2.
转换
`infernce model`
到Lite预测的
`.nb`
模型
2.
填写不同硬件设备需要的信息
```
if [ ${DEVICE} = "ARM_CPU" ];then
valid_targets="arm"
paddlelite_library_url="https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.android.armv8.gcc.c++_shared.with_extra.with_cv.tar.gz"
end_index="66"
compile_with_opencl="OFF"
elif [ ${DEVICE} = "ARM_GPU_OPENCL" ];then
valid_targets="opencl"
paddlelite_library_url="https://github.com/PaddlePaddle/Paddle-Lite/releases/download/v2.10-rc/inference_lite_lib.armv8.clang.with_exception.with_extra.with_cv.opencl.tar.gz"
end_index="71"
compile_with_opencl="ON"
else
echo "DEVICE only support ARM_CPU, ARM_GPU_OPENCL."
exit 2
fi
```
3.
转换
`infernce model`
到Lite预测的
`.nb`
模型
```
# prepare
lite .nb
model
# prepare
paddlelite
model
if [[ $inference_cmd =~ "det" ]];then
lite_model_list=${det_lite_model_list}
elif [[ $inference_cmd =~ "rec" ]];then
...
...
@@ -127,6 +157,11 @@ else
exit 1
fi
pip install paddlelite==2.10-rc
current_dir=${PWD}
IFS="|"
model_path=./inference_models
for model in ${lite_model_list[*]}; do
if [[ $model =~ "PP-OCRv2" ]];then
inference_model_url=https://paddleocr.bj.bcebos.com/PP-OCRv2/chinese/${model}.tar
...
...
@@ -146,48 +181,62 @@ for model in ${lite_model_list[*]}; do
done
```
3
.
准备测试数据
4
.
准备测试数据
```
data_url=https://paddleocr.bj.bcebos.com/dygraph_v2.0/test/icdar2015_lite.tar
model_path=./inference_models
inference_model=${inference_model_url##*/}
data_file=${data_url##*/}
wget -nc -P ./inference_models ${inference_model_url}
wget -nc -P ./test_data ${data_url}
cd ./inference_models && tar -xf ${inference_model} && cd ../
cd ./test_data && tar -xf ${data_file} && rm ${data_file} && cd ../
```
4
.
准备Lite预测环境,此处需要下载或者编译Paddle-Lite预测库。
5
.
准备Lite预测环境,此处需要下载或者编译Paddle-Lite预测库。
```
# prepare lite env
paddlelite_zipfile=$(echo $paddlelite_url | awk -F "/" '{print $NF}')
paddlelite_file=${paddlelite_zipfile:0:${end_index}}
wget ${paddlelite_url} && tar -xf ${paddlelite_zipfile}
mkdir -p ${paddlelite_file}/demo/cxx/ocr/test_lite
cp -r ${model_path}/*_opt.nb test_data ${paddlelite_file}/demo/cxx/ocr/test_lite
cp ppocr/utils/ppocr_keys_v1.txt deploy/lite/config.txt ${paddlelite_file}/demo/cxx/ocr/test_lite
cp -r ./deploy/lite/* ${paddlelite_file}/demo/cxx/ocr/
cp ${paddlelite_file}/cxx/lib/libpaddle_light_api_shared.so ${paddlelite_file}/demo/cxx/ocr/test_lite
cp ${FILENAME} test_tipc/test_lite_arm_cpp.sh test_tipc/common_func.sh ${paddlelite_file}/demo/cxx/ocr/test_lite
cd ${paddlelite_file}/demo/cxx/ocr/
git clone https://github.com/cuicheng01/AutoLog.git
if [[ ${paddlelite_library_source} = "download" ]]; then
paddlelite_library_zipfile=$(echo $paddlelite_library_url | awk -F "/" '{print $NF}')
paddlelite_library_file=${paddlelite_library_zipfile:0:${end_index}}
wget ${paddlelite_library_url} && tar -xf ${paddlelite_library_zipfile}
cd ${paddlelite_library_zipfile}
elif [[ ${paddlelite_library_source} = "compile" ]]; then
git clone -b release/v2.10 https://github.com/PaddlePaddle/Paddle-Lite.git
cd Paddle-Lite
./lite/tools/build_android.sh --arch=armv8 --with_cv=ON --with_extra=ON --toolchain=clang --with_opencl=${compile_with_opencl}
cd ../
cp -r Paddle-Lite/build.lite.android.armv8.clang/inference_lite_lib.android.armv8/ .
paddlelite_library_file=inference_lite_lib.android.armv8
else
echo "paddlelite_library_source only support 'download' and 'compile'"
exit 3
fi
```
5.
交叉编译获得在手机上的可以运行的可执行文件
6.
准备编译以及后续在Lite设备上测试需要的文件
```
mkdir -p ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp -r ${model_path}/*_opt.nb test_data ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp ppocr/utils/ppocr_keys_v1.txt deploy/lite/config.txt ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp -r ./deploy/lite/* ${paddlelite_library_file}/demo/cxx/ocr/
cp ${paddlelite_library_file}/cxx/lib/libpaddle_light_api_shared.so ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cp ${FILENAME} test_tipc/test_lite_arm_cpp.sh test_tipc/common_func.sh ${paddlelite_library_file}/demo/cxx/ocr/test_lite
cd ${paddlelite_library_file}/demo/cxx/ocr/
git clone https://github.com/cuicheng01/AutoLog.git
```
7.
交叉编译获得在手机上的可以运行的可执行文件及删除当前目录下无用文件
```
make -j
sleep 1
make -j
cp ocr_db_crnn test_lite && cp test_lite/libpaddle_light_api_shared.so test_lite/libc++_shared.so
tar -cf test_lite.tar ./test_lite && cp test_lite.tar ${current_dir} && cd ${current_dir}
rm -rf ${paddlelite_file}* && rm -rf ${model_path}
rm -rf ${paddlelite_
library_
file}* && rm -rf ${model_path}
```
运行结果会在当前目录上生成test_lite.tar,里边的内容大致如下:
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录