Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:edge2:npu:npu-convert

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision Both sides next revision
products:sbc:edge2:npu:npu-convert [2023/08/22 05:56]
louis
products:sbc:edge2:npu:npu-convert [2023/08/25 05:01]
louis
Line 24: Line 24:
 ===== Get Convert Tool ===== ===== Get Convert Tool =====
  
-Download Tool from [[https://github.com/rockchip-linux/rknn-toolkit2.git|Rockchip Github]].+Download Tool from [[https://github.com/rockchip-linux/rknn-toolkit2.git|rockchip-linux/rknn-toolkit2]].
  
 ```shell ```shell
Line 43: Line 43:
 ===== Convert Model ===== ===== Convert Model =====
  
-Converting model has five main steps. Create RKNN object, pre-process config, load model, build model and export RKNN model. Here, take ''yolov5'' ‘’onnx’’ as an example.+Converting model has five main steps. Create RKNN object, pre-process config, load model, build model and export RKNN model. Here, take ''yolov5'' ''onnx'' as an example.
  
 Create RKNN object.  Create RKNN object. 
  
-```shell+```python
 # Create RKNN object # Create RKNN object
 rknn = RKNN(verbose=True)  rknn = RKNN(verbose=True) 
Line 54: Line 54:
 Pre-process config. Pre-process config.
  
-```shell+```python
 # pre-process config # pre-process config
 print('--> Config model') print('--> Config model')
Line 64: Line 64:
   * **std_values** - The variance of normalization parameter.   * **std_values** - The variance of normalization parameter.
 model input = (image – mean_values) / std_values model input = (image – mean_values) / std_values
-  * **target_platform** - Chooses ‘’rk3588’’.+  * **target_platform** - Chooses ''rk3588''.
  
 Load model. Load model.
  
-```shell+```python
 # Load ONNX model # Load ONNX model
 print('--> Loading model') print('--> Loading model')
-ret = rknn.load_onnx(model=./yolov5.onnx)+ret = rknn.load_onnx(model='./yolov5.onnx')
 if ret != 0: if ret != 0:
     print('Load model failed!')     print('Load model failed!')
Line 82: Line 82:
 Load other platform model. Load other platform model.
  
-```shell+```python
 # Load pytorch model # Load pytorch model
 print('--> Loading model') print('--> Loading model')
Line 129: Line 129:
 ``` ```
  
-  * **inputs/outputs** - Only use in ‘’tensorflow’’ model. It is the name of inputs/outputs.+  * **inputs/outputs** - Only use in tensorflow model. It is the name of inputs/outputs.
   * **input_size_list** - The size and channels of input.   * **input_size_list** - The size and channels of input.
  
 Build model Build model
  
-```shell+```python
 # Build model # Build model
 print('--> Building model') print('--> Building model')
-ret = rknn.build(do_quantization=True, dataset=./dataset.txt)+ret = rknn.build(do_quantization=True, dataset='./dataset.txt')
 if ret != 0: if ret != 0:
     print('Build model failed!')     print('Build model failed!')
Line 149: Line 149:
 Export RKNN model Export RKNN model
  
-```shell+```python
 # Export RKNN model # Export RKNN model
 print('--> Export rknn model') print('--> Export rknn model')
-ret = rknn.export_rknn(export_path=./yolov5_int8.rknn)+ret = rknn.export_rknn(export_path='./yolov5_int8.rknn')
 if ret != 0: if ret != 0:
     print('Export rknn model failed!')     print('Export rknn model failed!')
Line 161: Line 161:
   * **export_path** - The path of rknn model.   * **export_path** - The path of rknn model.
  
-All the above codes can be found in ‘’rknn-toolkit2/examples’’. There are all platforms we support now. Choose ‘’rk3588’’ in rknn-toolkit2/examples/onnx/yolov5/test.py and run the file to convert model.+All the above codes can be found in ''rknn-toolkit2/examples''. There are all platforms we support now. Choose ''rk3588'' in ''rknn-toolkit2/examples/onnx/yolov5/test.py'' and run the file to convert model.
  
 ```diff patch ```diff patch
Line 177: Line 177:
 ``` ```
  
-Run test.py to generate rknn model.+Run ''test.py'' to generate rknn model.
  
 ```shell ```shell
Line 189: Line 189:
 ===== See Also ===== ===== See Also =====
  
-For more usage, please refer to the related documents under ‘’doc’’.+For more usage, please refer to the related documents under ''doc''.
  
  
Last modified: 2024/04/25 03:47 by louis