English | 简体中文
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/
.
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》