From 41ee93c75e48183d096828d252e65e4d46a1bc35 Mon Sep 17 00:00:00 2001 From: Zheng-Bicheng <58363586+Zheng-Bicheng@users.noreply.github.com> Date: Tue, 14 Mar 2023 17:49:12 +0800 Subject: [PATCH] [Doc] Update RKNPU2 Docs (#1608) * update rknpu2 docs * update rknpu2 docs --- .../vision/detection/rkyolo/cpp/README.md | 51 +++---------------- .../vision/detection/rkyolo/cpp/README_CN.md | 7 +++ .../vision/detection/rkyolo/python/README.md | 10 +++- .../detection/rkyolo/python/README_CN.md | 10 +++- 4 files changed, 30 insertions(+), 48 deletions(-) diff --git a/examples/vision/detection/rkyolo/cpp/README.md b/examples/vision/detection/rkyolo/cpp/README.md index 1984ae7a4..da54395b2 100644 --- a/examples/vision/detection/rkyolo/cpp/README.md +++ b/examples/vision/detection/rkyolo/cpp/README.md @@ -10,57 +10,20 @@ Two steps before deployment Refer to [RK2 generation NPU deployment repository compilation](../../../../../docs/cn/build_and_install/rknpu2.md) -## Generate the base directory file - -The routine consists of the following parts -```text -. -├── CMakeLists.txt -├── build # Compile folder -├── image # Folder to save images -├── infer_rkyolo.cc -├── model # Folder to save model files -└── thirdpartys # Folder to save sdk -``` - -Generate a directory first -```bash -mkdir build -mkdir images -mkdir model -mkdir thirdpartys -``` - -## Compile - -### Compile and copy SDK to the thirdpartys folder - -Refer to [RK2 generation NPU deployment repository compilation](../../../../../docs/cn/build_and_install/rknpu2.md). It will generate fastdeploy-0.0.3 directory in the build directory after compilation. Move it to the thirdpartys directory. - -### Copy model files and configuration files to the model folder -In the process of Paddle dynamic graph model -> Paddle static graph model -> ONNX model, the ONNX file and the corresponding yaml configuration file will be generated. Please save the configuration file in the model folder. -Copy onverted RKNN model files to model。 - -### Prepare test images and image folder ```bash wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/000000014439.jpg -cp 000000014439.jpg ./images -``` - -### Compilation example - -```bash cd build -cmake .. +cmake .. -DFASTDEPLOY_INSTALL_DIR=${PWD}/fastdeploy-linux-x64-x.x.x make -j8 -make install +./infer_rkyolo /path/to/model 000000014439.jpg ``` -## Running routine +## common problem -```bash -cd ./build/install -./infer_picodet model/ images/000000014439.jpg +If you use the YOLOv5 model you have trained, you may encounter the problem of 'segmentation fault' after running the demo of FastDeploy. It is likely that the number of labels is inconsistent. You can use the following solution: + +```c++ +model.GetPostprocessor().SetClassNum(3); ``` diff --git a/examples/vision/detection/rkyolo/cpp/README_CN.md b/examples/vision/detection/rkyolo/cpp/README_CN.md index 7d2827173..9b3c077b6 100644 --- a/examples/vision/detection/rkyolo/cpp/README_CN.md +++ b/examples/vision/detection/rkyolo/cpp/README_CN.md @@ -18,6 +18,13 @@ make -j8 ./infer_rkyolo /path/to/model 000000014439.jpg ``` +## 常见问题 + +如果你使用自己训练的YOLOv5模型,你可能会碰到运行FastDeploy的demo后出现`segmentation fault`的问题,很大概率是label数目不一致,你可以使用以下方案来解决: + +```c++ +model.GetPostprocessor().SetClassNum(3); +``` - [模型介绍](../../) - [Python部署](../python) diff --git a/examples/vision/detection/rkyolo/python/README.md b/examples/vision/detection/rkyolo/python/README.md index 4cb2a444d..c79a1262b 100644 --- a/examples/vision/detection/rkyolo/python/README.md +++ b/examples/vision/detection/rkyolo/python/README.md @@ -19,10 +19,16 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000 cp -r ./model /path/to/FastDeploy/examples/vision/detection/rkyolo/python # Inference -python3 infer.py --model_file ./model/ \ - --image 000000014439.jpg +python3 infer.py --model_file /path/to/model --image /path/to/000000014439.jpg ``` +## common problem + +If you use the YOLOv5 model you have trained, you may encounter the problem of 'segmentation fault' after running the demo of FastDeploy. It is likely that the number of labels is inconsistent. You can use the following solution: + +```python +model.postprocessor.class_num = 3 +``` ## Note The model needs to be in NHWC format on RKNPU. The normalized image will be embedded in the RKNN model. Therefore, when we deploy with FastDeploy, call DisablePermute(C++) or `disable_permute(Python)` to disable normalization and data format conversion during preprocessing. diff --git a/examples/vision/detection/rkyolo/python/README_CN.md b/examples/vision/detection/rkyolo/python/README_CN.md index 09a0e14aa..006dcf8ca 100644 --- a/examples/vision/detection/rkyolo/python/README_CN.md +++ b/examples/vision/detection/rkyolo/python/README_CN.md @@ -19,10 +19,16 @@ wget https://gitee.com/paddlepaddle/PaddleDetection/raw/release/2.4/demo/0000000 cp -r ./model /path/to/FastDeploy/examples/vision/detection/rkyolo/python # 推理 -python3 infer.py --model_file ./model/ \ - --image 000000014439.jpg +python3 infer.py --model_file /path/to/model --image /path/to/000000014439.jpg ``` +## 常见问题 + +如果你使用自己训练的YOLOv5模型,你可能会碰到运行FastDeploy的demo后出现`segmentation fault`的问题,很大概率是label数目不一致,你可以使用以下方案来解决: + +```python +model.postprocessor.class_num = 3 +``` ## 注意事项 RKNPU上对模型的输入要求是使用NHWC格式,且图片归一化操作会在转RKNN模型时,内嵌到模型中,因此我们在使用FastDeploy部署时,需要先调用DisablePermute(C++) `disable_permute(Python)`,在预处理阶段禁用归一化以及数据格式的转换。