Skip to content

Commit

Permalink
[Doc] Update readme files in English version (PaddlePaddle#1592)
Browse files Browse the repository at this point in the history
* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md
  • Loading branch information
huchuqi12 authored Mar 13, 2023
1 parent 0464b4e commit 4ae772c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 64 deletions.
106 changes: 46 additions & 60 deletions examples/vision/detection/paddledetection/rknpu2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ English | [简体中文](README_CN.md)
## List of Supported Models

Now FastDeploy supports the deployment of the following models
- [PicoDet models](https://github.com/PaddlePaddle/PaddleDetection/tree/release/2.4/configs/picodet)
The PaddleDetection models that have been tested on RKNPU2 are as follows:

- Picodet
- PPYOLOE(int8)
- YOLOV8

If detailed speed information is required, you can check out the [RKNPU2 Model Speed Table](../../../../../docs/cn/faq/rknpu2/rknpu2.md)

## Prepare PaddleDetection deployment models and convert models
Before RKNPU deployment, you need to transform Paddle model to RKNN model:
Expand All @@ -13,9 +19,19 @@ Before RKNPU deployment, you need to transform Paddle model to RKNN model:


## Model Transformation Example
The following steps are conducted on Ubuntu computers, refer to the configuration document to prepare the environment. Taking Picodet-s as an example, this document demonstrates how to transform PaddleDetection model to RKNN model.
### Export the ONNX model
### Notes

When deploying PPDetection models on RKNPU2, you may pay attention to the following points:

* Include Decode for model export
* Since RKNPU2 does not support NMS, the output nodes must be clipped before NMS
* Limited by the RKNPU2 Div operator, the output nodes need to be clipped before the Div operator

### From Paddle model to ONNX model

Because the rknN-toolkit2 provided by Rockchip does not support the direct support from Paddle models to RKNN models, you need to export the Paddle model to the ONNX model first, and then convert the ONNX model to the RKNN model.
```bash
# Taking Picodet as an example
# Download Paddle static map model and unzip it
wget https://paddledet.bj.bcebos.com/deploy/Inference/picodet_s_416_coco_lcnet.tar
tar xvf picodet_s_416_coco_lcnet.tar
Expand All @@ -30,88 +46,58 @@ paddle2onnx --model_dir picodet_s_416_coco_lcnet \
# Fix shape
python -m paddle2onnx.optimize --input_model picodet_s_416_coco_lcnet/picodet_s_416_coco_lcnet.onnx \
--output_model picodet_s_416_coco_lcnet/picodet_s_416_coco_lcnet.onnx \
--input_shape_dict "{'image':[1,3,416,416]}"
--input_shape_dict "{'image':[1,3,416,416], 'scale_factor':[1,2]}"
```

### Write the model export configuration file
Taking the example of RKNN model from RK3588, we need to edit tools/rknpu2/config/RK3568/picodet_s_416_coco_lcnet.yaml to convert ONNX model to RKNN model.
### Write the yaml file

**Modify normalize parameter**

If you need to perform the normalize operation on NPU, configure the normalize parameters based on your model. For example:
```yaml
model_path: ./picodet_s_416_coco_lcnet/picodet_s_416_coco_lcnet.onnx
output_folder: ./picodet_s_416_coco_lcnet
target_platform: RK3568
normalize:
mean: [[0.485,0.456,0.406]]
std: [[0.229,0.224,0.225]]
outputs: ['tmp_17','p2o.Concat.9']
mean:
-
- 123.675
- 116.28
- 103.53
std:
-
- 58.395
- 57.12
- 57.375
```
**Modify outputs parameter**
The output node names of the transformation model are various based on different versions of Paddle2ONNX. Please use [Netron](https://netron.app) and find the NonMaxSuppression node marked by the blue box below, and the node name in the red box is the target name.
For example, we can obtain the following image after visualization with Netron:
![](https://user-images.githubusercontent.com/58363586/202728663-4af0b843-d012-4aeb-8a66-626b7b87ca69.png)
![](https://ai-studio-static-online.cdn.bcebos.com/8bce6b904a6b479e8b30da9f7c719fad57517ffb2f234aeca3b8ace0761754d5)
Find the NonMaxSuppression node marked by the blue box,and we can see the names of the two nodes marked by the red box: tmp_17 and p2o.Concat.9. So we need to modify the outputs parameter:
```yaml
model_path: ./picodet_s_416_coco_lcnet/picodet_s_416_coco_lcnet.onnx
output_folder: ./picodet_s_416_coco_lcnet
target_platform: RK3568
normalize: None
outputs: ['tmp_17','p2o.Concat.9']
outputs_nodes:
- 'p2o.Mul.179'
- 'p2o.Concat.9'
```
### From ONNX model to RKNN model
For your convenience, we provide python scripts that will enable you to quickly convert ONNX models to RKNN models through our pre-configured config file
### model transformation
```bash

# Transform ONNX modle to RKNN model
# The transformed model is in the picodet_s_320_coco_lcnet_non_postprocess directory
python tools/rknpu2/export.py --config_path tools/rknpu2/config/picodet_s_416_coco_lcnet.yaml \
python tools/rknpu2/export.py --config_path
tools/rknpu2/config/picodet_s_416_coco_lcnet_unquantized.yaml \
--target_platform rk3588
```

### Modify the configuration file during runtime
## List of RKNN models

n the config file, we need to modify **Normalize** and **Permute** under **Preprocess**.
For people’s testing, we provide two models, picodet and ppyoloe, which can be used after unzipping:

**Remove Permute**

The Permute operation needs removing considering that RKNPU only supports the input format of NHWC. After removal, the Precess is as follows:
```yaml
Preprocess:
- interp: 2
keep_ratio: false
target_size:
- 416
- 416
type: Resize
- is_scale: true
mean:
- 0.485
- 0.456
- 0.406
std:
- 0.229
- 0.224
- 0.225
type: NormalizeImage
```
**Decide whether to remove Normalize based on model transformation file**
RKNPU supports Normalize on NPU. Remove **Normalize** if you configured the Normalize parameter when exporting the model. After removal, the Precess is as follows:
```yaml
Preprocess:
- interp: 2
keep_ratio: false
target_size:
- 416
- 416
type: Resize
```
| Model Name | Download Address |
| --------------------------- | ------------------------------------------------------------ |
| picodet_s_416_coco_lcnet | https://bj.bcebos.com/paddlehub/fastdeploy/rknpu2/picodet_s_416_coco_lcnet.zip |
| ppyoloe_plus_crn_s_80e_coco | https://bj.bcebos.com/paddlehub/fastdeploy/rknpu2/ppyoloe_plus_crn_s_80e_coco.zip |

## Other Links
- [Cpp Deployment](./cpp)
Expand Down
16 changes: 12 additions & 4 deletions examples/vision/detection/rkyolo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,22 @@ RKYOLO models are encapsulated with reference to the code of [rknn_model_zoo](ht

## List of Supported Models

* RKYOLOV5
FastDeploy currently supports the deployment of the following three models:

## Model Transformation Example
- RKYOLOV5
- RKYOLOX
- RKYOLOv7

Please refer to [RKNN_model_convert](https://github.com/airockchip/rknn_model_zoo/tree/main/models/CV/object_detection/yolo/RKNN_model_convert)
For people’s testing, we provide three converted models that allow downloading and use. If you need to convert models, refer to [RKNN_model_convert](https://github.com/airockchip/rknn_model_zoo/tree/main/models/CV/object_detection/yolo/RKNN_model_convert).

| Model Name | Download Address |
| ------------------ | ------------------------------------------------------------ |
| yolov5-s-relu-int8 | https://bj.bcebos.com/paddlehub/fastdeploy/rknpu2/yolov5-s-relu.zip |
| yolov7-tiny-int8 | https://bj.bcebos.com/paddlehub/fastdeploy/rknpu2/yolov7-tiny.zip |
| yolox-s-int8 | https://bj.bcebos.com/paddlehub/fastdeploy/rknpu2/yolox-s.zip |


## Other Links
- [Cpp deployment](./cpp)
- [Python deployment](./python)
- [Visual model predicting results](../../../../docs/api/vision_results/)
- [Vision model predicting results](../../../../docs/api/vision_results/)

0 comments on commit 4ae772c

Please sign in to comment.