VIM4 NPU KSNN Python test version

KSNN supports on VIM4. Now release the test version and a demo of YOLOv8n. Welcome to try.

What is KSNN ?

KSNN is the abbreviation of Khadas Software Neural Network. It is a Python api which can call NPU to infer AI model. Help those who are not familiar with C/C++.

Instruction

Dependence

  1. For some special reasons, the current python api still relies on the adla files and case codes converted from the original SDK.
  2. The dependent python packages, in addition to the core packages, mainly include opencv and numpy.

Limit

  1. The current version only supports single input.
  2. Currently does not support hybrid quantization.
  3. Like the original SDK, only the tensor and layer supported by the SDK can be used.

How To Use

SDK

Get SDK

$ git lfs install
$ git lfs clone https://gitlab.com/khadas/vim4_npu_sdk.git

Build convert environment

Follow Docker official docs to install Docker:Install Docker Engine on Ubuntu | Docker Docs

Get Docker image

docker pull numbqq/npu-vim4

Use SDK to convert

Modify the parameters in ksnn_args.txt you need and then run convert-in-docker.sh.

bash ./convert-in-docker.sh ksnn

Convert model and dynamic library will generate the path you set parameter –outdir.

Inference on VIM4

Get KSNN Demo

$ git clone https://github.com/khadas/ksnn-vim4

Install KSNN

$ cd ksnn/ksnn
$ sudo apt update
$ sudo apt install python3-pip
$ pip3 install ksnn_vim4-1.4-py3-none-any.whl

Run KSNN YOLOv8n Demo

$ cd ksnn/examples/yolov8n
$ python3 yolov8n-picture.py --model ./models/VIM4/yolov8n_int8.adla --library ./libs/libnn_yolov8n.so --picture ./data/horses.jpg --level 0

The docs of VIM4 KSNN.
KSNN Python [Khadas Docs]

2 Likes