Published On: November, 17, 2023 By: Eshtaartha Basu
This tutorial will walk you through the steps required to integrate Xilinx’s DPU-TRD Acceleration PL Kernel to your Acceleration Ready Vitis Platform. The tutorial will also show you how to build and run AI demos like Face Detection and ADAS Detection directly from the Xilinx AI Model Zoo on the OSDZU3-REF platform.
This tutorial can be used standalone or as Part 4 of a 4-part Acceleration tutorial series that will help you run Vitis-AI DPU-TRD based Face Detection demo, ADAS Detection demo (and other AI demos) on the OSDZU3-REF board. An overview of the flow is shown below:
This tutorial assumes the user has already gone through:
This tutorial will require the following software setup.
Note: All the steps in this tutorial have been validated using Petalinux 2021.2 running on Ubuntu 20.04.LTS. However, the overall design flow should be similar for other Petalinux and host OS versions as well.
This section will describe the steps required to Integrate DPU-TRD PL Acceleration Kernel to our Acceleration Ready Vitis Platform.
Open Vitis 2021.2 IDE
Set the directory created as part of Tutorial 3, osdzu3-ref-accl-vitis-pkg, as your workspace directory. The workspace should already have osdzu3-ref-accl-vitis-platform created as part of Tutorial 3 under Explorer.
Under Window > Preferences > Library Repositories tab > Click Add button
Configure the settings of the Vitis AI 2.0 library as shown below. Ensure the Branch is 2.0 and not “master”.
./host_cross_compiler_setup.sh
Default installation location is ~/petalinux_sdk_2021.2.
If you need sysroot installed some other place, open the script and add the full path to below line:
install_path=~/petalinux_sdk_2021.2
This section describes how to configure DPU-TRD project for OSDZU3-REF platform.
`define B4096 to `define B2304`define CHANNEL_AUGMENTATION_ENABLE to `define CHANNEL_AUGMENTATION_DISABLE`define DWCV_ENABLE to `define DWCV_DISABLE`define POOL_AVG_ENABLE to `define POOL_AVG_DISABLE`define DSP48_USAGE_HIGH to `define DSP48_USAGE_LOW
[clock]
id=0:DPUCZDX8G_1.aclk
id=1:DPUCZDX8G_1.ap_clk_2
[connectivity]
sp=DPUCZDX8G_1.M_AXI_GP0:HPC0
sp=DPUCZDX8G_1.M_AXI_HP0:HP0
sp=DPUCZDX8G_1.M_AXI_HP2:HP2
nano /etc/vart.conf
Make sure the contents are:
firmware: /media/sd-mmcblk1p1/dpu.xclbin
xdputil query
The Vitis AI Model Zoo is a free repository that includes optimized, pre-trained, deep learning models to speed up the deployment of deep learning inference on Xilinx™ platforms. These models cover different applications, including but not limited to ADAS/AD, medical, video surveillance, robotics, data center, etc.
As examples, this section will show you how to manually compile the following two Café framework models from Vitis AI Model Zoo:
git clone -b v2.0 https://github.com/Xilinx/Vitis-AI
cd Vitis-AI
export VITIS_AI_HOME=$PWD
2. The Vitis AI Model Zoo provides several versions of the Face Detect (Densebox_640_360) and ADAS (yolov3_cityscapes) models for different boards as listed in the model.yaml files of the respective models. The versions of the models we’re interested in are highlighted in the pictures below.
cd $VITIS_AI_HOME/models/AI-Model-Zoo/model-list
cat cf_densebox_wider_360_640_1.11G_2.0/model.yaml
cat dk_yolov3_cityscapes_256_512_0.9_5.46G_2.0/model.yaml
wget https://www.xilinx.com/bin/public/openDownload?filename=cf_densebox_wider_360_640_1.11G_2.0.zip -O cf_densebox_wider_360_640_1.11G_2.0.zip
wget https://www.xilinx.com/bin/public/openDownload?filename=dk_yolov3_cityscapes_256_512_0.9_5.46G_2.0.zip -O dk_yolov3_cityscapes_256_512_0.9_5.46G_2.0.zip
unzip dk_yolov3_cityscapes_256_512_0.9_5.46G_2.0.zip
cp {path_to_arch_json}/arch.json .
sudo docker pull xilinx/vitis-ai:2.0.0.1103
cd $VITIS_AI_HOME
sudo sh -x docker_run.sh xilinx/vitis-ai:2.0.0.1103
6. Read all the license notification messages, when prompted press ENTER to go through the terms and press “y” on the keyboard to accept the terms. Next, you should see Vitis-AI Docker command line.
cd models/AI-Model-Zoo
mkdir compiled_output
8. Let’s create a generic script for compiling Caffe model named “compile_cafe_model.sh” with the following content:
model_name=$1
modelzoo_name=$2
vai_c_caffe \
--prototxt ./${modelzoo_name}/quantized/deploy.prototxt \
--caffemodel ./${modelzoo_name}/quantized/deploy.caffemodel \
--arch ./arch.json \
--output_dir ./compiled_output/${model_name} \
--net_name ${model_name}
9. Activate conda environment
conda activate vitis-ai-caffe
10. Compile the Densebox_640_360 model to work with our newly created DPU based Hardware Platform using the command:
source ./compile_cafe_model.sh densebox_640_360 cf_densebox_wider_360_640_1.11G_2.0
11. Similarly, compile the ADAS model to work with our newly created DPU based Hardware Platform using the command:
source ./compile_cafe_model.sh yolov3_cityscapes dk_yolov3_cityscapes_256_512_0.9_5.46G_2.0/
12. Under “compiled_output” directory, you should be able to see “densebox_640_360.xmodel” and “yolov3_cityscapes.xmodel”
13. Exit docker with the following command:
Exit
14. Copy “densebox_640_360.xmodel” and “yolov3_cityscapes.xmodel” files to the BOOT partition of the µSD card.
cd $VITIS_AI_HOME/demo/VART/adas_detection
source ~/petalinux_sdk_2021.2/environment-setup-cortexa72-cortexa53-xilinx-linux
chmod +x build.sh
./build.sh
4. The newly built ADAS application is highlighted below
cd $VITIS_AI_HOME/demo/Vitis-AI-Library/samples/facedetect
chmod +x build.sh
./build.sh
lsusb
export DISPLAY=:0.0
xrandr --output DP-1 --mode 640x480
cd ~
cp –r /mnt/sd-mmcblk1p1/test_video_facedetect ~
cp –r /mnt/sd-mmcblk1p1/densebox_640_360.xmodel ~
cp –r /mnt/sd-mmcblk1p1/densebox_640_360.prototxt ~
cp –r /mnt/sd-mmcblk1p1/adas_detection ~
cp –r /mnt/sd-mmcblk1p1/yolov3_cityscapes.xmodel ~
mkdir /usr/share/vitis_ai_library/models
cp ~/densebox_640_360.xmodel /usr/share/vitis-ai-library/models
./test_video_facedetect densebox_640_360.xmodel 0
You can watch this demo in action here –https://www.youtube.com/watch?v=QxXFs8B_scU
./adas_detection /dev/video0 yolov3_cityscapes.xmodel
Point the webcam towards live traffic on the street. You can also play dashcam traffic videos on your laptop and point the webcam towards it to observe the ADAS traffic detection in action as shown below.
The PL resource utilization by DPU-TRD PL Kernel on OSDZU3-REF is shown by the below figure.
The average input power consumption for the demos is as follows.
| OSDZU3-REF State | OSDZU3-REF Input Power |
|---|---|
| Petalinux Idle | 9.75W |
| Running Face Detect Demo (from Vitis AI Model Zoo) | 12.15W |
| Running ADAS Detect Demo (from Vitis AI Model Zoo) | 13.2W |
This has completed the Vitis AI Tutorial series. Please visit any of the previous versions of this tutorial series for further information.
Get notified of updates to this Application Note and all of our Technical Documentation.
“*” indicates required fields
| Revision Number | Revision Date | Changes | Author |
|---|---|---|---|
| 1 | 11/27/2023 | Initial Version | Erik Welsh |
There has been multiple revisions to the OSDZU3-REF and some of the documentation is for specific revisions.
The revision of your OSDZU3-REF is printed under the fan next to the Octavo Systems logo. See the image below.
If there are multiple versions of a document make sure you select the one that matches your revision.