mirror of
https://github.com/PaddlePaddle/FastDeploy.git
synced 2025-10-06 09:07:10 +08:00

* Create README_CN.md * Update README.md * Update README_CN.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Create README_CN.md * Update README.md * Update README.md * Update README_CN.md * Create README_CN.md * Update README.md * Update README.md * Update and rename README_en.md to README_CN.md * Update WebDemo.md * Update and rename WebDemo_en.md to WebDemo_CN.md * Update and rename DEVELOPMENT_cn.md to DEVELOPMENT_CN.md * Update DEVELOPMENT_CN.md * Update DEVELOPMENT.md * Update RNN.md * Update and rename RNN_EN.md to RNN_CN.md * Update README.md * Update and rename README_en.md to README_CN.md * Update README.md * Update and rename README_en.md to README_CN.md * Update README.md * Update README_cn.md * Rename README_cn.md to README_CN.md * Update README.md * Update README_cn.md * Rename README_cn.md to README_CN.md * Update export.md * Update and rename export_EN.md to export_CN.md * Update README.md * Update README.md * Create README_CN.md * Update README.md * Update README.md * Update kunlunxin.md * Update classification_result.md * Update classification_result_EN.md * Rename classification_result_EN.md to classification_result_CN.md * Update detection_result.md * Update and rename detection_result_EN.md to detection_result_CN.md * Update face_alignment_result.md * Update and rename face_alignment_result_EN.md to face_alignment_result_CN.md * Update face_detection_result.md * Update and rename face_detection_result_EN.md to face_detection_result_CN.md * Update face_recognition_result.md * Update and rename face_recognition_result_EN.md to face_recognition_result_CN.md * Update headpose_result.md * Update and rename headpose_result_EN.md to headpose_result_CN.md * Update keypointdetection_result.md * Update and rename keypointdetection_result_EN.md to keypointdetection_result_CN.md * Update matting_result.md * Update and rename matting_result_EN.md to matting_result_CN.md * Update mot_result.md * Update and rename mot_result_EN.md to mot_result_CN.md * Update ocr_result.md * Update and rename ocr_result_EN.md to ocr_result_CN.md * Update segmentation_result.md * Update and rename segmentation_result_EN.md to segmentation_result_CN.md * Update README.md * Update README.md * Update quantize.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md
77 lines
4.0 KiB
Markdown
Executable File
77 lines
4.0 KiB
Markdown
Executable File
English | [简体中文](README_CN.md)
|
|
# YOLOv5 Quantification Model C++ Deployment Example
|
|
|
|
This directory provides examples that `infer.cc` fast finishes the deployment of YOLOv5 on RV1126.
|
|
|
|
## Prepare the deployment
|
|
### Prepare FastDeploy cross-compilation environment
|
|
1. For the environment of software, hardware and cross-compilation, refer to [FastDeploy cross-compilation environment preparation](../../../../../../docs/cn/build_and_install/rv1126.md#交叉编译环境搭建)
|
|
|
|
### Prepare the quantification model
|
|
Users can directly deploy quantized models provided by FastDeploy or prepare quantification models as the following steps:
|
|
1. Refer to [YOLOv5](https://github.com/ultralytics/yolov5/releases/tag/v6.1) to officially convert the ONNX model or use the following command to download it.
|
|
```bash
|
|
wget https://paddle-slim-models.bj.bcebos.com/act/yolov5s.onnx
|
|
```
|
|
2. Prepare 300 or so images for quantization.And we can also download the prepared data using the following command:
|
|
```bash
|
|
wget https://bj.bcebos.com/fastdeploy/models/COCO_val_320.tar.gz
|
|
tar -xf COCO_val_320.tar.gz
|
|
```
|
|
3. Users can use the [ One-click auto-compression tool](../../../../../../tools/common_tools/auto_compression/) provided by FastDeploy to automatically conduct quantification model for deployment.
|
|
```bash
|
|
fastdeploy compress --config_path=./configs/detection/yolov5s_quant.yaml --method='PTQ' --save_dir='./yolov5s_ptq_model_new/'
|
|
```
|
|
4. The YOLOv5 model requires heterogeneous computing. Refer to [Heterogeneous Computing](./../../../../../../docs/cn/faq/heterogeneous_computing_on_timvx_npu.md). Since FastDeploy already provides the YOLOv5 model, we can first test the heterogeneous files to verify whether the accuracy meets the requirements.
|
|
```bash
|
|
# Download the model, unzip it, and copy the subgraph.txt file to your newly quantized model directory
|
|
wget https://bj.bcebos.com/fastdeploy/models/yolov5s_ptq_model.tar.gz
|
|
tar -xvf yolov5s_ptq_model.tar.gz
|
|
```
|
|
|
|
Refer to [model quantification](../../quantize/README.md) for more information
|
|
|
|
## Deploy quantized YOLOv5 detection model on RV1126
|
|
Refer to the following steps:
|
|
1. For cross compiling FastDeploy repo, refer to [cross compiling FastDeploy](../../../../../../docs/cn/build_and_install/rv1126.md#基于-paddlelite-的-fastdeploy-交叉编译库编译)
|
|
|
|
2. Copy the compiled repo to your current directory through the following command:
|
|
```bash
|
|
cp -r FastDeploy/build/fastdeploy-timvx/ FastDeploy/examples/vision/detection/yolov5/rv1126/cpp
|
|
```
|
|
|
|
3. Download models and images for deployment in the current location:
|
|
```bash
|
|
cd FastDeploy/examples/vision/detection/yolov5/rv1126/cpp
|
|
mkdir models && mkdir images
|
|
wget https://bj.bcebos.com/fastdeploy/models/yolov5s_ptq_model.tar.gz
|
|
tar -xvf yolov5s_ptq_model.tar.gz
|
|
cp -r yolov5s_ptq_model models
|
|
wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg
|
|
cp -r 000000014439.jpg images
|
|
```
|
|
|
|
4. Compile the deployment example through the following command:
|
|
```bash
|
|
cd FastDeploy/examples/vision/detection/yolov5/rv1126/cpp
|
|
mkdir build && cd build
|
|
cmake -DCMAKE_TOOLCHAIN_FILE=${PWD}/../fastdeploy-timvx/toolchain.cmake -DFASTDEPLOY_INSTALL_DIR=${PWD}/../fastdeploy-timvx -DTARGET_ABI=armhf ..
|
|
make -j8
|
|
make install
|
|
# Successful compilation generates the install folder, containing a running demo and repo required for deployment
|
|
```
|
|
|
|
5. Deploy YOLOv5 detection model to Rockchip RV1126 based on adb. Refer to the following command:
|
|
```bash
|
|
# Enter the install directory
|
|
cd FastDeploy/examples/vision/detection/yolov5/rv1126/cpp/build/install/
|
|
# The following commands represent: bash run_with_adb.sh running demo model path image path DEVICE_ID
|
|
bash run_with_adb.sh infer_demo yolov5s_ptq_model 000000014439.jpg $DEVICE_ID
|
|
```
|
|
|
|
vis_result.jpg after successful deployment:
|
|
|
|
<img width="640" src="https://user-images.githubusercontent.com/30516196/203706969-dd58493c-6635-4ee7-9421-41c2e0c9524b.png">
|
|
|
|
Note that the deployment model on RV1126 is the quantized model. Refer to [Model Quantification](../../../../../../docs/cn/quantize.md)
|