Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


products:sbc:vim3:npu:ksnn:ksnn-usage

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
Next revision Both sides next revision
products:sbc:vim3:npu:ksnn:ksnn-usage [2023/09/10 04:50]
hyphop [KSNN Usage]
products:sbc:vim3:npu:ksnn:ksnn-usage [2023/12/21 01:29]
louis
Line 1: Line 1:
-~~tag> VIM3 VIM3L NPU Python API KSNN ~~+~~tag> VIM3 VIM3L NPU Python API KSNN  ~~
  
  
 ====== KSNN Usage ====== ====== KSNN Usage ======
  
-===== Introduction =====+This article shows VIM3 NPU usage examples through **KSNN** - Python API.
  
-This article mainly introduces how to call NPU through Python API in VIM3/VIM3L.+<WRAP help > 
 +**KSNN** is [[https://github.com/khadas/ksnn#readme|Khadas Software Neural Network]] 
 +</WRAP>
  
 ===== Install KSNN ===== ===== Install KSNN =====
  
-1. Clone code to local.+Get the library and example code: [[gh>khadas/ksnn]]
  
 ```shell ```shell
Line 16: Line 18:
 ``` ```
  
-2. Installation dependencies.+Install the dependencies:
  
 ```shell ```shell
Line 22: Line 24:
 ``` ```
  
-3. Install KSNN library.+Install KSNN library:
  
 ```shell ```shell
Line 29: Line 31:
 ``` ```
  
-===== Example of use =====+===== Usage example =====
  
-Demos are all concentrated in the examlpes directory,+All Demo examples in the ''examples'' directory are sorted by folders.
  
 ```shell ```shell
Line 38: Line 40:
 ``` ```
  
-Take Inception V3 as an example, other demos are similar.+Choose ''tensorflow'' and ''inceptionv3.py'' for example, other demos are similar.
  
 ```shell ```shell
-$ cd tensorflow && ls +$ cd tensorflow && ls -1 
-README.md  box_priors.txt  data  inceptionv3.py  libs  mobilenet_ssd_picture.py  models+data   
 +libs 
 +models 
 +README.md   
 +box_priors.txt 
 +inceptionv3.py 
 +mobilenet_ssd_picture.py
 ``` ```
  
-The running commands and conversion parameters are in the ''README'' file in the corresponding directory.+The running commands and conversion parameters are in the ''README.md'' file in the same directory.
  
 ```shell ```shell
Line 64: Line 72:
 --inputs input \ --inputs input \
 --outputs InceptionV3/Predictions/Reshape_1 \ --outputs InceptionV3/Predictions/Reshape_1 \
---mean-values '128,128,128,128' \+--mean-values '128 128 128 0.0078125' \
 --quantized-dtype asymmetric_affine \ --quantized-dtype asymmetric_affine \
 --kboard VIM3 --print-level 1 --kboard VIM3 --print-level 1
Line 75: Line 83:
 --inputs FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1 \ --inputs FeatureExtractor/MobilenetV1/MobilenetV1/Conv2d_0/BatchNorm/batchnorm/mul_1 \
 --outputs "'concat concat_1'" \ --outputs "'concat concat_1'" \
---mean-values '127.5,127.5,127.5,127.5' \+--mean-values '127.5 127.5 127.5 0.0078431' \
 --quantized-dtype asymmetric_affine \ --quantized-dtype asymmetric_affine \
 --kboard VIM3 --print-level 1 --kboard VIM3 --print-level 1
Line 83: Line 91:
 ``` ```
  
-Run Inception V3:+Run ''inceptionv3.py'':
  
 ```shell ```shell
Line 159: Line 167:
 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/examples/darknet +cd ksnn/examples/darknet 
-python3 hand-cap.py --model ./models/VIM3/hand.nb --library ./libs/libnn_hand.so --device X+ 
 +python3 hand-cap.py --model ./models/VIM3/hand.nb 
 +  --library ./libs/libnn_hand.so --device X
 ``` ```
  
 2. Currently, the only demo that supports RTSP is the yolo series. Take Yolov3 as an example, 2. Currently, the only demo that supports RTSP is the yolo series. Take Yolov3 as an example,
  
-```shell +```sh 
-cd ksnn/examples/darknet +cd ksnn/examples/darknet 
-python3 flask-yolov3.py --model ./models/VIM3/yolov3.nb --library ./libs/libnn_yolov3.so --device X+ 
 +python3 flask-yolov3.py --model ./models/VIM3/yolov3.nb 
 +  --library ./libs/libnn_yolov3.so --device X
 ``` ```
  
Last modified: 2024/05/27 22:15 by louis