Note
- Please follow this docs to upgrade the system to latest version before run any NPU demos.
- Just support Opencv4
Install OpenCV4
1 | 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
The address of the repository on github is:https://github.com/khadas/aml_npu_demo_binaries
Clone to the board through the git
command.
1 | cd {workspace} |
Or download the compressed package directly, and then unzip it to the board
There are three directories in NPU Demo:
1 | detect_demo: A collection of yolo series models for camera dynamic recognition |
Inception Model
- The inception model does not need to install any libraries into the system. Enter the inceptionv3 directory
1 | cd {workspace}/aml_npu_demo_binaries/inceptionv3 |
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.
- If your board is VIM3, enter the
VIM3
directory, if it is VIM3L, then enter theVIM3L
directory. Here is VIM3 as an example
1 | cd {workspace}/aml_npu_demo_binaries/inceptionv3/VIM3 |
- run
run.sh
1 | cd {workspace}/aml_npu_demo_binaries/inceptionv3/VIM3 |
By querying imagenet_slim_labels.txt
, the result is a goldfish, which is also correctly identified
- Identify other pictures
1 | cd {workspace}/aml_npu_demo_binaries/inceptionv3/VIM3 |
NoteThe size of the picture must correspond to the size of the model, so here, the input of the inceptionv3 model is 299x299x3, and the incoming recognized picture must also be 299x299
Yolo Series Model
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.
enter detect_demo_picture
1 | cd {workspace}/aml_npu_demo_binaries/detect_demo_picture |
Install
1 | sudo ./INSTALL |
Uninstall
1 | 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 |
Operating Environment Description
NPU Demo can run in X11 or framebuffer mode, just select the corresponding demo to run.
X11 / Framebuffer
The demo with fb
is running in framebuffer mode.
The demo with x11
is running in X11 mode.
Illustrative Example
Here is an example of detect_demo_picture
,
1 | cd {workspace}/aml_npu_demo_binaries/detect_demo_picture |
- detect_demo_fb It is a demo that uses opencv4 recognition pictures running under framebuffer
- detect_demo_x11 It is a demo that uses opencv4 recognition pictures running under X11
Run
Picture Recognition
Identify the command format of the picture
1 | cd {workspace}/aml_npu_demo_binaries/detect_demo_picture |
Here is an example of using Opencv4 to call the yolov3 model to recognize pictures under x11.
1 | cd {workspace}/aml_npu_demo_binaries/detect_demo_picture |
The results of the operation are as follows,
Dynamic Camera Recognition
Camera description
You should use the demo of usb
to use the USB camera, and the demo of mipi
to use the mipi camera.
Command format for camera dynamic recognition
1 | cd {workspace}/aml_npu_demo_binaries/detect_demo |
Here is an example of using opencv4 to call yolov3 in the x11 environment.
1 | cd {workspace}/aml_npu_demo_binaries/detect_demo |
After turning on the camera, the recognition result will be displayed on the screen