This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
products:sbc:vim3:npu:ksnn:ksnn-usage [2023/09/10 04:56] hyphop [KSNN Usage] |
products:sbc:vim3:npu:ksnn:ksnn-usage [2025/01/09 21:08] (current) louis |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ~~tag> VIM3 VIM3L NPU Python API KSNN ~~ | + | ~~tag> VIM3 VIM3L NPU Python API KSNN ~~ |
====== KSNN Usage ====== | ====== KSNN Usage ====== | ||
- | This article shows VIM3 NPU usage examples through | + | This article shows VIM3 NPU usage examples through |
<WRAP help > | <WRAP help > | ||
- | **KSSN** is Khadas Software Neural Network | + | **KSNN** is [[https:// |
</ | </ | ||
===== Install KSNN ===== | ===== Install KSNN ===== | ||
- | 1. Clone code to local. | + | Get the library and example |
```shell | ```shell | ||
- | $ git clone --recursive | + | $ git lfs install |
+ | $ git lfs clone https:// | ||
``` | ``` | ||
- | 2. Installation dependencies. | + | Install KSNN library: |
- | + | ||
- | ```shell | + | |
- | $ pip3 install matplotlib | + | |
- | ``` | + | |
- | + | ||
- | 3. Install KSNN library. | + | |
```shell | ```shell | ||
$ cd ksnn/ksnn | $ cd ksnn/ksnn | ||
- | $ pip3 install ksnn-1.3-py3-none-any.whl | + | $ pip3 install ksnn-1.4-py3-none-any.whl |
``` | ``` | ||
- | ===== Example of use ===== | + | ===== Usage example |
- | Demos are all concentrated | + | All Demo examples |
```shell | ```shell | ||
Line 40: | Line 35: | ||
``` | ``` | ||
- | Take Inception V3 as an example, other demos are similar. | + | Choose '' |
```shell | ```shell | ||
- | $ cd tensorflow | + | $ cd keras && ls -1 |
- | README.md | + | data |
+ | libs | ||
+ | models | ||
+ | README.md | ||
+ | xception.py | ||
``` | ``` | ||
- | The running commands and conversion parameters are in the '' | + | The running commands and conversion parameters are in the '' |
```shell | ```shell | ||
- | $ ~/ | + | $ ~/ |
- | # run | + | # Run |
+ | |||
+ | $ python3 xception.py --model ./ | ||
- | $ python3 inceptionv3.py --model ./ | ||
- | $ python3 mobilenet_ssd_picture.py --model ./ | ||
# Convert | # Convert | ||
+ | # uint8 | ||
$ ./convert \ | $ ./convert \ | ||
- | --model-name | + | --model-name |
- | --platform | + | --platform |
- | --model | + | --model /home/yan/yan/Yan/models-zoo/keras/xception/xception.h5 |
- | --input-size-list ' | + | --mean-values '127.5 127.5 127.5 0.007843137' \ |
- | --inputs input \ | + | |
- | --outputs InceptionV3/Predictions/Reshape_1 \ | + | |
- | --mean-values ' | + | |
- | --quantized-dtype asymmetric_affine \ | + | |
- | --kboard VIM3 --print-level 1 | + | |
- | + | ||
- | $ ./convert \ | + | |
- | --model-name mobilenet_ssd \ | + | |
- | --platform tensorflow \ | + | |
- | --model ssd_mobilenet_v1_coco_2017_11_17.pb \ | + | |
- | --input-size-list ' | + | |
- | --inputs FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/ | + | |
- | --outputs "' | + | |
- | --mean-values '127.5,127.5,127.5,127.5' \ | + | |
--quantized-dtype asymmetric_affine \ | --quantized-dtype asymmetric_affine \ | ||
+ | --source-files ./ | ||
--kboard VIM3 --print-level 1 | --kboard VIM3 --print-level 1 | ||
Line 85: | Line 72: | ||
``` | ``` | ||
- | Run Inception V3: | + | Run '' |
```shell | ```shell | ||
- | $ python3 | + | $ python3 |
- | |--- KSNN Version: v1.3 +---| | + | |---+ KSNN Version: v1.4 +---| |
Start init neural network ... | Start init neural network ... | ||
Done. | Done. | ||
Get input data ... | Get input data ... | ||
- | Done. | + | Done |
Start inference ... | Start inference ... | ||
- | Done. inference : 0.042353153228759766 | + | Done. inference |
- | ----- Show Top5 +----- | + | ----Xception---- |
- | 2: 0.93457 | + | -----TOP 5----- |
- | 795: 0.00328 | + | [1]: 0.99609375 |
- | 408: 0.00158 | + | [0]: 0.0009250640869140625 |
- | 974: 0.00148 | + | [391]: 0.00019299983978271484 |
- | 393: 0.00093 | + | [29]: 0.00017976760864257812 |
+ | [124]: 0.00016736984252929688 | ||
``` | ``` | ||
Line 107: | Line 95: | ||
```shell | ```shell | ||
- | $ python3 | + | $ python3 |
- | |--- KSNN Version: v1.3 +---| | + | |---+ KSNN Version: v1.4 +---| |
Start init neural network ... | Start init neural network ... | ||
# | # | ||
- | Create Neural Network: | + | Create Neural Network: |
Done. | Done. | ||
Get input data ... | Get input data ... | ||
- | Done. | + | Done |
Start inference ... | Start inference ... | ||
Start run graph [1] times... | Start run graph [1] times... | ||
Line 120: | Line 108: | ||
current device id=0, AXI SRAM base address=0xff000000 | current device id=0, AXI SRAM base address=0xff000000 | ||
---------------------------Begin VerifyTiling ------------------------- | ---------------------------Begin VerifyTiling ------------------------- | ||
- | AXI-SRAM = 1048576 | + | AXI-SRAM = 1048320 |
0 NBG [( | 0 NBG [( | ||
- | id IN [ x y w h ] | + | id IN [ x y w h ] |
- | 0 NBG DD 0x(nil) [ | + | |
- | PreLoadWeightBiases = 1048576 | + | id | opid IN [ x y w h ] |
+ | 0 | 0 NBG DD 0x00000000 [ | ||
+ | |||
+ | PreLoadWeightBiases = 1048320 | ||
---------------------------End VerifyTiling ------------------------- | ---------------------------End VerifyTiling ------------------------- | ||
layer_id: 0 layer name: | layer_id: 0 layer name: | ||
uid: 0 | uid: 0 | ||
abs_op_id: 0 | abs_op_id: 0 | ||
- | execution time: 20552 us | + | execution time: 97432 us |
- | [ 1] TOTAL_READ_BANDWIDTH | + | [ 1] TOTAL_READ_BANDWIDTH |
- | [ 2] TOTAL_WRITE_BANDWIDTH (MByte): | + | [ 2] TOTAL_WRITE_BANDWIDTH (MByte): |
- | [ 3] AXI_READ_BANDWIDTH | + | [ 3] AXI_READ_BANDWIDTH |
- | [ 4] AXI_WRITE_BANDWIDTH (MByte): | + | [ 4] AXI_WRITE_BANDWIDTH (MByte): |
- | [ 5] DDR_READ_BANDWIDTH (MByte): | + | [ 5] DDR_READ_BANDWIDTH (MByte): |
- | [ 6] DDR_WRITE_BANDWIDTH (MByte): | + | [ 6] DDR_WRITE_BANDWIDTH (MByte): |
- | [ 7] GPUTOTALCYCLES: | + | [ 7] GPUTOTALCYCLES: |
- | [ 8] GPUIDLECYCLES: | + | [ 8] GPUIDLECYCLES: |
- | VPC_ELAPSETIME: | + | VPC_ELAPSETIME: |
********* | ********* | ||
- | Run the 1 time: 118.00ms or 118636.00us | + | Run the 1 time: 100.00ms or 100247.00us |
vxProcessGraph execution time: | vxProcessGraph execution time: | ||
- | Total 118.00ms or 118996.00us | + | Total 100.00ms or 100303.00us |
- | Average | + | Average |
- | Done. inference : 0.1422710418701172 | + | Done. inference |
- | ----- Show Top5 +----- | + | ----Xception---- |
- | 2: 0.93457 | + | -----TOP 5----- |
- | 795: 0.00328 | + | [1]: 0.99609375 |
- | 408: 0.00158 | + | [0]: 0.0009250640869140625 |
- | 974: 0.00148 | + | [391]: 0.00019299983978271484 |
- | 393: 0.00093 | + | [29]: 0.00017976760864257812 |
+ | [124]: 0.00016736984252929688 | ||
``` | ``` | ||
Line 161: | Line 152: | ||
1. The Demos that currently support cameras include the Yolo series and OpenPose. Take Yolov3 as an example, | 1. The Demos that currently support cameras include the Yolo series and OpenPose. Take Yolov3 as an example, | ||
- | ```shell | + | ```sh |
- | $ cd ksnn/ | + | cd ksnn/ |
- | $ python3 hand-cap.py --model ./ | + | |
- | ``` | + | |
- | 2. Currently, the only demo that supports RTSP is the yolo series. Take Yolov3 as an example, | + | python3 |
- | + | ||
- | ```shell | + | |
- | $ cd ksnn/ | + | |
- | $ python3 | + | |
``` | ``` | ||