This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
products:sbc:edge2:npu:demos:densenet-ctc [2023/08/22 06:05] louis created |
products:sbc:edge2:npu:demos:densenet-ctc [2025/04/09 23:25] (current) louis |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Demo3 densenet_ctc ====== | + | ~~tag> DenseNet NPU Edge2 RK3588~~ |
- | ===== Get Source Code ===== | + | ====== DenseNet CTC ONNX Keras Edge2 Demo - 3 ====== |
- | The codes we use. | + | {{indexmenu_n> |
+ | |||
+ | ===== Introduction ===== | ||
+ | |||
+ | Densenet_CTC is a text recognition model. It only can recognize single line text. Therefore usually, it needs to be used in conjunction with a text detection model. | ||
+ | |||
+ | Recognition image and inference results on Edge2. | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | ===== Train Model ===== | ||
+ | |||
+ | We will use a DenseNet model based on [[gh> | ||
```shell | ```shell | ||
Line 34: | Line 47: | ||
==== Get convert tool ==== | ==== Get convert tool ==== | ||
- | Download Tool from [[https:// | + | Download Tool from [[gh>rockchip-linux/ |
```shell | ```shell | ||
Line 41: | Line 54: | ||
``` | ``` | ||
- | Install dependences and RKNN toolkit2 packages, | + | Install dependences and RKNN toolkit2 packages. |
```shell | ```shell | ||
Line 51: | Line 64: | ||
``` | ``` | ||
- | ==== 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’’ | + | Keras model(.h5) can convert rknn model directly. If you want to convert keras model, please use '' |
</ | </ | ||
- | ```shell | + | ```python export.py |
import onnx | import onnx | ||
from keras.models import * | from keras.models import * | ||
Line 81: | Line 94: | ||
``` | ``` | ||
- | Enter rknn-toolkit2/ | + | Enter '' |
- | ```shell | + | ```python test.py |
# Create RKNN object | # Create RKNN object | ||
rknn = RKNN(verbose=True) | rknn = RKNN(verbose=True) | ||
Line 94: | Line 107: | ||
# Load ONNX model | # Load ONNX model | ||
print(' | print(' | ||
- | ret = rknn.load_onnx(model=”./ | + | ret = rknn.load_onnx(model='./ |
if ret != 0: | if ret != 0: | ||
print(' | print(' | ||
Line 102: | Line 115: | ||
# Build model | # Build model | ||
print(' | print(' | ||
- | ret = rknn.build(do_quantization=True, | + | ret = rknn.build(do_quantization=True, |
if ret != 0: | if ret != 0: | ||
print(' | print(' | ||
Line 110: | Line 123: | ||
# Export RKNN model | # Export RKNN model | ||
print(' | print(' | ||
- | ret = rknn.export_rknn(“./ | + | ret = rknn.export_rknn('./ |
if ret != 0: | if ret != 0: | ||
print(' | print(' | ||
Line 117: | Line 130: | ||
``` | ``` | ||
- | Run test.py to generate rknn model. | + | Run '' |
```shell | ```shell | ||
Line 127: | Line 140: | ||
==== Get source code ==== | ==== Get source code ==== | ||
- | Clone the source code form our [[https:// | + | Clone the source code from our [[gh>khadas/ |
```shell | ```shell | ||
Line 144: | Line 157: | ||
=== Picture input demo === | === Picture input demo === | ||
- | Put densenet_ctc.rknn in edge2-npu/ | + | Put '' |
```shell | ```shell | ||
- | // compile | + | # Compile |
+ | $ cd edge2-npu/C++/densenet_ctc | ||
$ bash build.sh | $ bash build.sh | ||
- | // run | + | # Run |
$ cd install/ | $ cd install/ | ||
$ ./ | $ ./ | ||
Line 156: | Line 170: | ||
<WRAP tip > | <WRAP tip > | ||
- | If your yolov8n | + | If your **DenseNet CTC** model classes is not the same as mine, please change |
</ | </ | ||