PaddlePaddle provides several inference libraries to deploy models on different devices as the following image. Please refer to the document for more detail information about PaddlePaddle.
In this tutorial, we introduce the usage of Paddle Lite by the demo of deploying the human segmentation model on Android mobile phone.
git clone https://github.com/PaddlePaddle/PaddleSeg.git
.Based on the Android App, we can easily update the inference library and use other models.
The inference libray of Paddle Lite contains three files:
There are two ways to obtain the inference libray of Paddle Lite as follows.
Firstly, download the release library from github. For instance, the Android App use the v2.8.0 inference library in default. Besides, the dirname of PaddlePredictor.jar is jave/
, the dirname of arm64-v8a and armeabi-v7a is jave/libs
.
Secondly, prepare the compiling environment and compile the inference libray of Paddle Lite. Please refer to the preparement document and compiling document. There are several demos about the usege of Paddle Lite.
We use the HRNet_w18_small_v1 as the backbone of humanseg model. We have exported the inference model and you can download it from link. If you need to export other models, please refer to the document.
After preparing the inference model, we use the opt tool in Paddle Lite to convert it.
Download the opt tool from github. The version of opt tool unsed in the Android App is v2.8.
The usage of opt tool is as follows and the full usage can be found in PaddleLite.
./opt \
--model_dir=<model_param_dir> \
--model_file=<model_path> \
--param_file=<param_path> \
--optimize_out_type=(protobuf|naive_buffer) \
--optimize_out=<output_optimize_model_dir> \
--valid_targets=(arm|opencl|x86|x86_opencl|npu) \
--record_tailoring_info =(true|false) \
--quant_model=(true|false) \
--quant_type=(QUANT_INT8|QUANT_INT16)
Use the converted model to replace the old model in app/src/main/assets/image_segmentation/models/hrnet_small_for_cpu
.
Q: No permission to build Android project, /Users/xxx/human_segmentation_demo/app/cache/71j4bd3k08cpahbhs9f81a9gj9/cxx/libs/arm64-v8a/libhiai_ir_build.so (Permission denied)
.
A: Run chmod -R 777 /Users/xxx/human_segmentation_demo/app/cache/
.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。