If the model is split into multiple
subgraphs, you can no longer automatically run it with API_0, API_1, and API_2. You have
to deploy the model subgraph by subgraph. Graph runner is the new API for deploying
models. It converts the model into a single graph and makes deployment easier for models
with multiple subgraphs.
- Git clone the corresponding Vitis AI Library from https://github.com/Xilinx/Vitis-AI.
- Install the cross-compilation system on the host side. Refer to Installation for instructions.
- Check the model to see if it has multiple subgraphs. If yes, you can check
whether the operations that are not supported by the DPU are within the scope of
supported models. You can find the operations supported by the Vitis AI Library in Vitis-AI/tools/Vitis-AI-Library/cpu_task/ops.Note: If the operation is not in the supported list in cpu_task, then you cannot use the graph_runner directly. You may encounter an error when you compile the model. You must first solve it, then add the operation under cpu_task.
- Create the model_test.cpp source file.
The main flow is shown in the following figure. See Vitis-AI/demo/Vitis-AI-Library/samples/graph_runner/platenum_graph_runner/platenum_graph_runner.cpp
for a complete code example.
- Create a build.sh file as
shown below, or copy one from the Vitis AI
library demo and modify
it.
result=0 && pkg-config --list-all | grep opencv4 && result=1 if [ $result -eq 1 ]; then OPENCV_FLAGS=$(pkg-config --cflags --libs-only-L opencv4) else OPENCV_FLAGS=$(pkg-config --cflags --libs-only-L opencv) fi CXX=${CXX:-g++} $CXX -std=c++17 -O2 -I. \ -o platenum_graph_runner \ platenum_graph_runner.cpp \ -lglog \ -lxir \ -lvart-runner \ -lvitis_ai_library-graph_runner \ ${OPENCV_FLAGS} \ -lopencv_core \ -lopencv_imgcodecs \ -lopencv_imgproc
- Cross compile the
program.
sh -x build.sh
- Copy the executable program to the target board using the
scp
command.scp test_model root@IP_OF_BOARD:~/
- Install the latest VART. For more information, refer to Step 3: Installing AI Library Package.
- Execute the program on the target board. Before running the program, ensure
that the target board has the Vitis AI
Library installed, and prepare the images you want to
test.
./model_test <model> <image>