This shows you the differences between two versions of the page.
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: | ||
- | ====== | + | ~~tag> DenseNet NPU Edge2 RK3588~~ |
+ | |||
+ | ====== | ||
+ | |||
+ | {{indexmenu_n> | ||
===== Get Source Code ===== | ===== Get Source Code ===== | ||
- | The codes we use. | + | We will use a DenseNet model based on [[gh> |
```shell | ```shell | ||
Line 34: | Line 38: | ||
==== Get convert tool ==== | ==== Get convert tool ==== | ||
- | Download Tool from [[https:// | + | Download Tool from [[gh>rockchip-linux/ |
```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’’ | + | 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 85: | ||
``` | ``` | ||
- | 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 98: | ||
# 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 106: | ||
# 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 114: | ||
# 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 121: | ||
``` | ``` | ||
- | Run test.py to generate rknn model. | + | Run '' |
```shell | ```shell | ||
Line 127: | Line 131: | ||
==== 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 148: | ||
=== 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 161: | ||
<WRAP tip > | <WRAP tip > | ||
- | If your densenet_ctc | + | If your **DenseNet CTC** model classes is not the same as mine, please change |
</ | </ | ||