Skip to main content

ResNet50 V2

This document describes how to run ResNet50 V2 on NPU.

info

Refer to Model Zoo Download for the example.

ResNet50 V2 Example Directory Structure:

$ tree ./
./
├── class_post.cpp
├── class_pre.cpp
├── CMakeLists.txt
├── convert_model
│ ├── config_yml.py
│ └── convert_model_env.sh
├── label.h
├── main.cpp
├── model
│ └── 1.jpg
└── README.md

Model Conversion

Download Model

Click to download resnet50v2.onnx.

Then move the model to the convert_model/ directory.

X86 Linux PC
cd convert_model/
./convert_model_env.sh

Model Import/Quantization/Conversion

You need to enter the container development environment first. Refer to the Create Container section in Model Zoo Download.

info

Different platforms use corresponding Docker images:

  • A733: ubuntu-npu:v2.0.10.1
  • T527: ubuntu-npu:v1.8.11
X86 Linux PC
docker exec -it model-zoo /bin/bash

After entering the container, navigate to the corresponding directory and run the script.

X86 Linux PC
cd /workspace/examples/resnet50v2/convert_model/
X86 Linux PC
./pegasus_import.sh resnet50v2
./pegasus_quantize.sh resnet50v2 uint8 10
X86 Linux PC
./pegasus_export_ovx_nbg.sh resnet50v2 uint8 a733

The exported model files are stored in the ../model directory.

Compile Example

Now you can compile the example. First exit the container, then execute the following command to compile the example.

First, you need to configure third-party libraries and cross-compilation toolchain.

info

You can skip this step if you have already configured third-party libraries and cross-compilation toolchain in other examples.

X86 Linux PC
cd ../../../3rdparty/opencv/
unzip opencv-4.9.0-aarch64-linux-sunxi-glibc.zip
cd ../../0-toolchains/

You need to manually download via this link first, then place it in 0-toolchains/ before executing the following command:

X86 Linux PC
tar -xvf gcc-arm-10.2-2020.11-x86_64-aarch64-none-linux-gnu.tar.xz
X86 Linux PC
cd ../examples/resnet50v2/
X86 Linux PC
../build_linux.sh -t a733 -s debian11

Model Deployment

After compilation, the example will be installed in the install directory. You can use scp to transfer it to the board.

Configure NPU Driver

info

You can skip this step if you have already configured NPU driver in other examples.

Transfer the driver library to the board's lib directory via scp.

  • A733 corresponds to the common/lib_linux_aarch64/A733 directory
  • T527 corresponds to the common/lib_linux_aarch64/T527 directory

Then execute the following command to export to environment variables.

Radxa SBC
echo 'export LD_LIBRARY_PATH=$HOME/lib:$LD_LIBRARY_PATH' >> ~/.bashrc

Run Example

After configuring the driver, you can run the example.

tip

For T527 platform, you need to first enable NPU by referring to the A5E's "Enable NPU on Board" documentation, then use the following command to grant the current user permission to use /dev/vipcore.

Radxa SBC
sudo chmod 777 /dev/vipcore
Radxa SBC
cd resnet50v2_demo_linux_a733/
Radxa SBC
chmod +x ./resnet50v2_demo_a733
./resnet50v2_demo_a733 -nb model/resnet50v2_uint8_a733.nb -i model/1.jpg

The running result is as follows:

$ ./resnet50v2_demo_a733 -nb model/resnet50v2_uint8_a733.nb -i model/1.jpg
model_file=model/resnet50v2_uint8_a733.nb, input=model/1.jpg, loop_count=1, malloc_mbyte=10
VIPLite driver software version 2.0.3.2-AW-2024-08-30
input 0 dim 3 224 224 1, data_format=2, quant_format=0, name=input/output[0], none-quant
output 0 dim 1000 1 0 0, data_format=0, name=uid_20000_sub_uid_1_out_0, none-quant
nbg name=model/resnet50v2_uint8_a733.nb, size: 17593328.
create network 0: 15664 us.
prepare network: 1734 us.
network: 0, loop count: 1
run time for this network 0: 8900 us.
class_postprocess.cpp run.
========== top5 ==========
class id: 281, prob: 11.682373, label: tabby, tabby cat
class id: 285, prob: 11.270020, label: Egyptian cat
class id: 282, prob: 10.033203, label: tiger cat
class id: 287, prob: 6.047363, label: lynx, catamount
class id: 292, prob: 5.085327, label: tiger, Panthera tigris
destroy npu finished.
~NpuUint.

This performance data only calculates the time consumption of model inference. Unless otherwise specified, it does not include the time consumption of pre-processing and post-processing.

SoCNPUModelInput ResolutionNetwork Creation TimeNetwork Preparation TimeSingle Frame Inference TimePost-processing TimeTotal TimeFrame Rate
Allwinner A733Vivante VIP9000resnet50v2224×22415.7 ms1.7 ms8.9 ms26.3 ms112.4 FPS

    You need to be logged into GitHub to post a comment. If you are already logged in, please ignore this message.

    Radxa-docs © 2026 by Radxa Computer (Shenzhen) Co.,Ltd. is licensed under CC BY 4.0