Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:edge2:npu:demos:densenet-ctc

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
Previous revision
products:sbc:edge2:npu:demos:densenet-ctc [2023/08/22 06:09]
louis
products:sbc:edge2:npu:demos:densenet-ctc [2024/07/25 23:05] (current)
ivan [Compile and run]
Line 1: Line 1:
-====== Demo3 densenet_ctc ======+~~tag> DenseNet NPU Edge2 RK3588~~ 
 + 
 +====== DenseNet CTC ONNX Keras Edge2 Demo - 3 ====== 
 + 
 +{{indexmenu_n>3}}
  
 ===== Get Source Code ===== ===== Get Source Code =====
  
-The codes we use.+We will use a DenseNet model based on [[gh>YCG09/chinese_ocr]].
  
 ```shell ```shell
Line 34: Line 38:
 ==== Get convert tool ==== ==== Get convert tool ====
  
-Download Tool from [[https://github.com/rockchip-linux/rknn-toolkit2.git|Rockchip Github]].+Download Tool from [[gh>rockchip-linux/rknn-toolkit2]].
  
 ```shell ```shell
Line 41: Line 45:
 ``` ```
  
-Install dependences and RKNN toolkit2 packages,+Install dependences and RKNN toolkit2 packages.
  
 ```shell ```shell
Line 51: Line 55:
 ``` ```
  
-==== convert ====+==== Convert ====
  
 After training model, run the codes as follows to modify net input and output and convert model to onnx. After training model, run the codes as follows to modify net input and output and convert model to onnx.
  
 <WRAP tip > <WRAP tip >
-Keras model(.h5) can convert rknn model directly. If you want to convert keras model, please use ‘’model.save’’ to save model with weight and network structure.+Keras model(.h5) can convert rknn model directly. If you want to convert keras model, please use ''model.save'' to save model with weight and network structure.
 </WRAP> </WRAP>
  
  
-```shell+```python export.py
 import onnx import onnx
 from keras.models import * from keras.models import *
Line 81: Line 85:
 ``` ```
  
-Enter rknn-toolkit2/examples/onnx/yolov5 and modify test.py as follows.+Enter ''rknn-toolkit2/examples/onnx/yolov5'' and modify ''test.py'' as follows.
  
-```shell+```python test.py
 # Create RKNN object # Create RKNN object
 rknn = RKNN(verbose=True) rknn = RKNN(verbose=True)
Line 94: Line 98:
 # Load ONNX model # Load ONNX model
 print('--> Loading model') print('--> Loading model')
-ret = rknn.load_onnx(model=./densenet_ctc.onnx)+ret = rknn.load_onnx(model='./densenet_ctc.onnx')
 if ret != 0: if ret != 0:
     print('Load model failed!')     print('Load model failed!')
Line 102: Line 106:
 # 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 110: Line 114:
 # Export RKNN model # Export RKNN model
 print('--> Export rknn model') print('--> Export rknn model')
-ret = rknn.export_rknn(./densenet_ctc.rknn)+ret = rknn.export_rknn('./densenet_ctc.rknn')
 if ret != 0: if ret != 0:
     print('Export rknn model failed!')     print('Export rknn model failed!')
Line 117: Line 121:
 ``` ```
  
-Run test.py to generate rknn model.+Run ''test.py'' to generate rknn model.
  
 ```shell ```shell
Line 127: Line 131:
 ==== Get source code ==== ==== Get source code ====
  
-Clone the source code form our [[https://github.com/khadas/edge2-npu|Github]].+Clone the source code from our [[gh>khadas/edge2-npu]].
  
 ```shell ```shell
Line 144: Line 148:
 === Picture input demo === === Picture input demo ===
  
-Put densenet_ctc.rknn in edge2-npu/C++/densenet_ctc/data/model.+Put ''densenet_ctc.rknn'' in ''edge2-npu/C++/densenet_ctc/data/model''.
  
 ```shell ```shell
-// compile+# Compile 
 +$ cd edge2-npu/C++/densenet_ctc
 $ bash build.sh $ bash build.sh
  
-// run+# Run
 $ cd install/densenet_ctc $ cd install/densenet_ctc
 $ ./densenet_ctc data/model/densenet_ctc.rknn data/img/KhadasTeam.png $ ./densenet_ctc data/model/densenet_ctc.rknn data/img/KhadasTeam.png
Line 156: Line 161:
  
 <WRAP tip > <WRAP tip >
-If your densenet_ctc model classes is not the same as coco, please change ‘’data/class_str.txt’’ and the ‘’OBJ_CLASS_NUM’’ in ‘’include/postprocess.h’’.+If your **DenseNet CTC** model classes is not the same as mine, please change ''data/class_str.txt'' and the ''OBJ_CLASS_NUM'' in ''include/postprocess.h''.
 </WRAP> </WRAP>
  
Last modified: 2023/08/22 06:09 by louis