Enviroment Setup
For boards without network connectivity, configure the network connection first.
apt update
apt install build-essential libopencv-dev cmake
apt install wget git vim
apt install python3-pip
cd /root
python3 -m venv ort
source /root/ort/bin/activate
After enstalling these packages, the board will have the necessary build environment.
Building the Source Code
git clone https://github.com/AXERA-TECH/ax-samples.git
cd ax-samples
mkdir build && cd build
cmake -DBSP_MSP_DIR=/soc/ -DAXERA_TARGET_CHIP=ax650 ..
make -j6
make install
Note: Even with a proxy configured on the host PC, the board won't inherit the proxy settings. The recommended appproach is to download packages on the host machine and transfer them to the board. Alternatively, use a mirror service:
git clone https://ghproxy.com/https://github.com/AXERA-TECH/ax-samples.git
cd ax-samples
mkdir build && cd build
cmake -DBSP_MSP_DIR=/soc/ -DAXERA_TARGET_CHIP=ax650 ..
make -j6
make install
Upon successful compilation, the executables are located in ax-samples/build/install/ax650/.
Downloading the Official Converted Model
Obtain the pre-converted yolov5s.axmodel from the official Google Drive repository (pulsar2-modelzoo). Place the model file in the same directory as the compiled executables. Also prepare a test image for inference.
Running Inference
Terminal output when running the YOLOv5s inference:
(ort) root@maixbox:/home/ax-samples/build/install/ax650# ls
ax_classification ax_hrnet ax_pp_humanseg ax_pp_vehicle_attribute ax_rtdetr ax_simcc_pose ax_yolov5s_seg ax_yolov8 yolov5s.axmodel
ax_detr ax_imgproc ax_pp_liteseg_stdc2_cityscapes ax_ppyoloe ax_rtmdet ax_yolo_nas ax_yolov6 ax_yolov8_pose
ax_dinov2 ax_model_info ax_pp_ocr_rec ax_ppyoloe_obj365 ax_scrfd ax_yolov5_face ax_yolov7 ax_yolox
ax_glpdepth ax_pfld ax_pp_person_attribute ax_realesrgan ax_segformer ax_yolov5s ax_yolov7_tiny_face dog.jpg
(ort) root@maixbox:/home/ax-samples/build/install/ax650# ./ax_yolov5s -m yolov5s.axmodel -i dog.jpg
-------------------------------------
model file : yolov5s.axmodel
image file : dog.jpg
img_h, img_w : 640 640
-------------------------------------
WARN,Func(__is_valid_file),NOT find file = '/etc/ax_syslog.conf'
ERROR,Func(__syslog_parma_cfg_get), NOT find = '/etc/ax_syslog.conf'
Engine creating handle is done.
Engine creating context is done.
Engine get io info is done.
Engine alloc io is done.
Engine push input is done.
-------------------------------------
post process cost time:1.87 ms
-------------------------------------
Repeat 1 times, avg time 7.77 ms, max_time 7.77 ms, min_time 7.77 ms
-------------------------------------
detection num: 3
16: 91%, [ 138, 218, 310, 541], dog
2: 69%, [ 470, 76, 690, 173], car
1: 56%, [ 158, 120, 569, 420], bicycle
-------------------------------------
(ort) root@maixbox:/home/ax-samples/build/install/ax650#
The model successfully detected three objects: a dog with 91% confidence, a car with 69% confidence, and a bicycle with 56% confidence.
Next Steps
Deploying custom-trained YOLOv5 models to the M4N-DOCK board for further experimentation.