891 views|1 replies

278

Posts

0

Resources
The OP
 

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.

YOLOV3

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.

Error message when reporting an error:

Solution: Modify the rootfs.fex node 45360 ==> 95744 of sys_partition.fex under the board directory.

Testing YOLOV3

First we prepare a picture and convert it to a 416*416 resolution picture.

Use ADB to download the image to the root directory

On the development board, switch to the root folder and use ls to list the image file 2.jpg.

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

You can see that car and motorbike are recognized. At this time, you can see the marked picture yolo_v3_output.bmp by running ls

You can use adb to upload images to the host for viewing.

Open the image to view the annotations

If an error occurs during operation, please confirm whether the image format is jpg and the image resolution is 416x416

Lenet

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.

Use ls to list uploaded data

Run the test model using the lenet command

You can see that the tensor output0_10_1.dat file is output here

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.

In the development board, you can run vpm_run to view supported operations.

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:

``` [network] ./network_binary.nb [input] ./iter_0_images_262_out0_1_3_640_640.tensor ./input_0.dat


多网络sample.txt文件配置,当需要一次运行多个nb模型时,不同nb以标签为界限:

 ```
[network]
 ./network_binary.nb
 [input]
 ./iter_0_images_262_out0_1_3_640_640.tensor

 [network]
 ./network_binary.nb
 [input]
 ./input_0.dat

common problem

① 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

Write the sample.txt file:

``` [network] ./network_binary.nb [input] ./iter_0_images_262_out0_1_3_640_640.tensor


将模型、输入文件、vpm_run例程传入板端

运行vpm_run例程:

./vpm_run -s sample.txt

unsupported input file type=tenso. error input file type segmentation fault ```

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.

This post is from Domestic Chip Exchange

Latest reply

There are so many floor boards!   Details Published on 2024-1-8 11:27
 
 

6069

Posts

4

Resources
2
 

There are so many floor boards!

This post is from Domestic Chip Exchange
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list