Allwinner V853 NPU Development Demo Instructions[Copy link]
After configuring the NPU expansion package in the previous section, you can see two Demo test applications in menuconfig. Here we will introduce how to use these two Demos.
In the NPU Package, we provide a relatively complete YOLOV3 Demo for testing. The program source code is located at:
openwrt/package/npu/yolov3/src
Compared with Lenet's Demo, this demo adds image pre-processing, data processing, post-processing and image framing functions. You can frame objects in uploaded images and output framed images.
First, we select the YOLOV3 related options in menuconfig
You can see that when yolov3 is selected, the yolov3-model option will appear. This option provides a test model to the system. The file is large. If errors occur during compilation and packaging, please refer to [ FAQ - V853 ] or refer to the following solutions.
As you can see, the download has been successful. Next, run yolov3. The format is:
Previously, we selected the yolov3-model model package, and the model has been installed to /etc/models/yolov3_model.nb, so we can use this model directly here and execute
If there is a HelloWorld for deep learning, it must be Lenet.
A Lenet Demo program is provided in the NPU expansion package.
This demo is relatively basic and demonstrates how to integrate the template code generated by model conversion into Tina Linux. Since there is no pre-processing and post-processing, both the input data and the output data are binary tensor files. Because of this, the output tensor can be compared with the simulated output tensor to verify whether there are any errors.
If you want a more complete demo including pre-processing and post-processing, you can check out yolov3 Demo.
We first make menuconfig to find the Lenet option. Here we provide two packages: the lenet main program and the lenet-model model. You can only select the main program to use your own converted model for testing.
Here we use the model provided by the extension package for verification. First, find the test data lenet_input_0.dat in the extension package and upload it to the development board.
If you need to implement image input and output, you need to add image pre-processing and data post-processing code based on this template. Pre-processing converts images into tensor input, and post-processing parses tensor output data.
vpm_run
The vpm_run package is a tool for testing and running on the development board, and is generally used for testing reasoning on the development board. And by referring to the vpm_run process, users can develop their own AI applications, so it can be seen as a set of AI application development templates, but it has some of its own characteristics.
vpm_run can be used as a general model running environment. The program does not need to be modified and can run any correctly deployed NBG model file.
vpm_run is based on the viplite network layer API, and the program is short and powerful.
vpm_run comes with TOP5 default post-processors. If they do not meet your algorithm requirements, you can extend them yourself.
We first make menuconfig to find the vpm_run option, check it, and package and compile. Here we also check the lenet option, and then test the use of vpm_run and provide a model.
As you can see, he needs a sample.txt file, defined as follows
The golden label represents the standard input, which can be regarded as a perfect output. This output can be the output file generated in the pre-inference phase or the simulation output file. vpm_run will compare these two files to see if there are any errors.
Some models require a larger memory size. If you need to modify the memory size, you can open openwrt/package/npu/vpm_run/src/vpm_run.c to modify the allocated memory size (viip_init(memory size)).
EEWORLDLINKTK9
Multiple input/multiple network configuration
Multi-input sample.txt file configuration, when there is only one nb model but two inputs are required:
① Deploy the lenet model on V853 according to the tutorial on the official website. When using vpm_run sample.txt, a segmentation fault occurs, as shown in the following figure
EEWORLDLINKTK10
Failed to read sample.txt. Check the source code of vpm_run.c to see the line break type of the file name.
Try to remove the spaces in the sample.txt file, which is one of the reasons that cause the segmentation fault error.
The line breaks in Windows operating system are: CR/LF or \r\n, while the line breaks in Linux are LF or \n.
② Error reading sample.txt when running the NPU module vpm_run routine
The error message is that the sample.txt file cannot be read. Check the source code of vpm_run.c to see the line break type of the file name. This is usually caused by space characters.