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 05:40] hyphop [Camera Demo] |
products:sbc:vim3:npu:ksnn:ksnn-usage [2025/01/09 21:08] (current) louis |
||
|---|---|---|---|
| Line 4: | Line 4: | ||
| ====== KSNN Usage ====== | ====== KSNN Usage ====== | ||
| - | This article shows VIM3 NPU usage examples through **KSSN** - Python API. | + | This article shows VIM3 NPU usage examples through **KSNN** - Python API. |
| <WRAP help > | <WRAP help > | ||
| - | **KSSN** is [[https:// | + | **KSNN** is [[https:// |
| </ | </ | ||
| ===== Install KSNN ===== | ===== Install KSNN ===== | ||
| - | Get code: [[gh> | + | Get the library and example |
| ```shell | ```shell | ||
| - | $ git clone --recursive | + | $ git lfs install |
| - | ``` | + | $ git lfs clone https:// |
| - | + | ||
| - | Installation dependencies: | + | |
| - | + | ||
| - | ```shell | + | |
| - | $ pip3 install matplotlib | + | |
| ``` | ``` | ||
| Line 28: | Line 23: | ||
| ```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 |
| ``` | ``` | ||
| Line 40: | Line 35: | ||
| ``` | ``` | ||
| - | Choose '' | + | Choose '' |
| ```shell | ```shell | ||
| - | $ cd tensorflow | + | $ cd keras && ls -1 |
| - | data | + | data |
| libs | libs | ||
| models | models | ||
| - | README.md | + | README.md |
| - | box_priors.txt | + | xception.py |
| - | inceptionv3.py | + | |
| - | mobilenet_ssd_picture.py | + | |
| ``` | ``` | ||
| Line 56: | Line 49: | ||
| ```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 91: | 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 113: | 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 126: | 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 170: | Line 155: | ||
| cd ksnn/ | cd ksnn/ | ||
| - | python3 | + | python3 |
| - | --library ./ | + | |
| - | ``` | + | |
| - | + | ||
| - | 2. Currently, the only demo that supports RTSP is the yolo series. Take Yolov3 as an example, | + | |
| - | + | ||
| - | ```sh | + | |
| - | cd ksnn/ | + | |
| - | + | ||
| - | python3 flask-yolov3.py --model ./ | + | |
| - | | + | |
| ``` | ``` | ||