Khadas Docs

Amazing Khadas, always amazes you!

User Tools

Site Tools


Sidebar

products:sbc:vim3:npu:npu-prebuilt-demo-usage

This is an old revision of the document!


NPU Prebuilt Demo Usage

  1. Please follow this docs to upgrade the system to latest version before run any NPU demos.
  2. Just support Opencv4

install OpenCV4

Install-OpenCV4.sh
sudo apt install libopencv-dev python3-opencv

Get NPU Demo

NPU Demo is not installed on the board by default. You need to download it from github first

1) Clone to the board through the git command.

get-npu-demo-from-demo.sh
 cd {workspace}
 git clone --recursive https://github.com/khadas/aml_npu_demo_binaries

2) Or download the compressed package directly, and then unzip it to the board.

  There are three directories in NPU Demo:

detect_demo

  1. detect_demo: A collection of yolo series models for camera dynamic recognition.

detect_demo_picture

  1. detect_demo_picture: A collection of yolo series models that identify pictures.

inceptionv3

  1. inceptionv3: Identify the inception model of the picture

Inception Model

  1. The inception model does not need to install any libraries into the system. Enter the inceptionv3 directory.
  2. imagenet_slim_labels.txt is a label file. After the result is identified, the label corresponding to the result can be queried in this file.
 $ cd {workspace}/aml_npu_demo_binaries/inceptionv3
 $ ls
 dog_299x299.jpg  goldfish_299x299.jpg  imagenet_slim_labels.txt  VIM3  VIM3L

If your board is VIM3, enter the VIM3 directory, if it is VIM3L, then enter the VIM3L directory. Here is VIM3 as an example.

1  $ cd {workspace}/aml_npu_demo_binaries/inceptionv3/VIM3
2  $ inceptionv3  inception_v3.nb  run.sh

1  $ cd {workspace}/aml_npu_demo_binaries/inceptionv3/VIM3
2  $ ./run.sh
3  Create Neural Network: 59ms or 59022us
4  Verify...
5  Verify Graph: 0ms or 739us
6  Start run graph [1] times...
7  Run the 1 time: 20.00ms or 20497.00us
8  vxProcessGraph execution time:
9  Total   20.00ms or 20540.00us
10 Average 20.54ms or 20540.00us
11 --- Top5 ---
12 2: 0.833984
13 795: 0.009102
14 974: 0.003592
15 408: 0.002207
16 393: 0.002111

By querying imagenet_slim_labels.txt, the result is a goldfish, which is also correctly identified.You can use the method above to identify other images.

Yolo Series Model

Preparation

The application of the yolo series model is divided into two parts: camera dynamic recognition and image recognition.

Install and uninstall libraries

The yolo series models need to install the library into the system. Whether it is using the camera to dynamically recognize or recognize pictures, they share the same library.

1) Install

install-libraries.sh
cd {workspace}/aml_npu_demo_binaries/detect_demo_picture
sudo ./INSTALL

2) Uninstall

uninstall-libraries.sh
cd {workspace}/aml_npu_demo_binaries/detect_demo_picture
sudo ./UNINSTALL

type Parameter Description

The type parameter is an input parameter that must be selected whether it is to use camera dynamic recognition or to recognize pictures. This parameter is mainly used to specify the running yolo series model.

1  0 : yoloface model
2  1 : yolov2 model
3  2 : yolov3 model
4  3 : yolov3_tiny model
5  4 : yolov4 model

Operating Environment Description

NPU Demo can run in X11 or framebuffer mode, just select the corresponding demo to run.

X11 / Framebuffer

  1. The demo with fb is running in framebuffer mode.
  1. The demo with x11 is running in X11 mode.

Illustrative Example

Here is an example of detect_demo_picture,

detect-demo-picture-example.sh
$ cd {workspace}/aml_npu_demo_binaries/detect_demo_picture
$ ls 
1080p.bmp  detect_demo_x11  detect_demo_xfb  INSTALL  lib  nn_data  README.md  UNINSTALL
  1. detect_demo_fb It is a demo that uses opencv4 recognition pictures running under framebuffer
  2. detect_demo_x11 It is a demo that uses opencv4 recognition pictures running under X11

Run

Identify the command format of the picture.

$ cd {workspace}/aml_npu_demo_binaries/detect_demo_picture
$ ./detect_demo_xx -m <type> -p <picture_path>

Here is an example of using Opencv4 to call the yolov3 model to recognize pictures under x11.

$ cd {workspace}/aml_npu_demo_binaries/detect_demo_picture
$ ./detect_demo_fb 2 1080p.bmp

The results of the operation are as follows.

https://docs.khadas.com/linux/images/vim3/detect_demo_picture_x11_cv4.png

Last modified: 2022/09/16 03:11 by ivan