- Install the cross-compilation system on the host side, refer to Installation.
- Download the model that you want to use, such as
resnet50
, and copy it to the board using scp. - Install the model on the target
side.
By default, we put the models under /usr/share/vitis_ai_library/models directory on the target side.tar -xzvf <model>.tar.gz cp -r <model> /usr/share/vitis_ai_library/models
Note: You do not need to install the Xilinx model packet if you want to use your own model. - Git clone the corresponding Vitis AI Library from https://github.com/Xilinx/Vitis-AI.
- Create a folder under your workspace, using classification as an
example.
mkdir classification
- Create the demo_classification.cpp
source file. The main flow is shown in the following figure. See Vitis-AI/demo/Vitis-AI-Library/samples/dpu_task/classification/demo_classification.cpp
for a complete code example.Figure 1. Main Program Flow Chart
- Create a build.sh file as
shown below, or copy one from the Vitis AI
Library's demo and modify
it.
#/bin/sh CXX=${CXX:-g++} $CXX -std=c++11 -O3 -I. -o demo_classification demo_classification.cpp -lopencv_core -lopencv_video -lopencv_videoio -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lglog -lvitis_ai_library-dpu_task -lvitis_ai_library-model_config -lvart-runner
- Cross compile the
program.
sh -x build.sh
- Copy the executable program to the target board using scp.
scp demo_classification root@IP_OF_BOARD:~/
- Execute the program on the target board. Before running the
program, make sure the target board has the Vitis AI Library installed, and prepare the images you want to
test.
./demo_classification /usr/share/vitis_ai_library/models/resnet50/resnet50.xmodel resnet50_0 demo_classification.jpg
Note:
- demo_classification.cpp uses user-defined pre-processing parameter as input.
- demo_classification.cpp uses user post-processing code. If you want to use the Vitis AI Library's post-processing library, please check Using the AI Library's Post-Processing Library.