Developing with Vitis AI API_0 - 3.5 English

Vitis AI Library User Guide (UG1354)

Document ID
Release Date
3.5 English
  1. Install the cross-compilation system on the host side. Refer to Installation for more information.
  2. Download the model that you want to use, such as resnet50, and copy it to the board using the scp command.
  3. Install the model on the target side.
    tar -xzvf <model>.tar.gz
    cp -r <model> /usr/share/vitis_ai_library/models

    By default, the models are located in the /usr/share/vitis_ai_library/models directory on the target side.

    Note: You do not need to install the AMD model package if you want to use your own model.
  4. Git clone the corresponding Vitis AI Library from
  5. Create a folder under your workspace. The following example uses classification.
    mkdir classification
  6. Create the demo_classification.cpp source file. The main flow is shown in the following figure. See Vitis-AI/examples/vai_runtime/resnet50/src/ for a complete code example.

  7. Create a file as shown below, or copy one from the Vitis AI Library demo and modify it.
    $CXX -O2 -fno-inline -I. -o demo_classification demo_classification.cpp -lopencv_core -lopencv_video -lopencv_videoio -lopencv_imgproc -lopencv_imgcodecs -lopencv_highgui -lglog -lxir -lunilog -lpthread -lvart-runner
  8. Cross-compile the program.
    sh -x
  9. Copy the executable program to the target board using the scp command.
    scp demo_classification root@IP_OF_BOARD:~/
  10. 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