Sample program

Sample program of Neon-RB5 - Capture and Inference - Model converter

Capture and Inference

  • The example program uses the built-in camera of the Neon-RB5 for image capture and employs the YOLOv6 model for object detection. The SNPE version used is
  • Download link
  • ### Installation guild
  • Install compile environment

    sudo apt-get update
    sudo apt install --fix-broken 
    sudo apt-get install cmake
    - #### Untar the file

    tar -zxvf Neon-RB5_sample.tar.gz -C /home/adlink/Desktop cd /home/adlink/Desktop/Neon-RB5_sample cp /home/adlink/Desktop/Neon-RB5_sample/yolov6n_base_quantized.dlc /home/adlink tar -zxvf snpe- -C /home/adlink

  • modidy .bashrc and add content below

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/adlink/snpe-
    export ADSP_LIBRARY_PATH="/home/adlink/snpe-;/usr/lib/rfsa/adsp/;/vendor/lib/rfsa/dsp/testsig;/system/lib/rfsa/adsp;/system/vendor/lib/rfsa/adsp;/dsp"
    export PATH=$PATH:/home/adlink/snpe-
    - #### Reload the .bashrc setting

    source ~/.bashrc

  • Compile the sample

    cd /home/adlink/Desktop/Neon-RB5_sample/samples
    mkdir build && cd build
    cmake .. && make
    - #### Execute the inference sample

    cd /home/adlink/Desktop/Neon-RB5_sample/samples/build ./yolov6_snpe

Procedure of Model Conversion

Required hardware

- x86 Host PC with [ubuntu18.04](
- Neon-RB5

The AI model used in the example is Meituan YOLOv6-N Below, we will describe how to convert the downloaded file into a dlc file for use with Neon-RB5.

The model conversion process primarily consists of four steps and requires a host PC with Ubuntu 18.04. Steps 1~5 are executed on the host.

Step 1: Environment Setup

sudo apt-get update && sudo apt-get upgrade 
sudo apt install python3-pip -y
pip3 install --upgrade pip
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
update-alternatives --list python

Step 2: Download conversion tools

wget -O ~/
wget ~/YOLOv6.tar.gz

Step 3: Setup conversion environment

cd ~
unzip -X -d ~
export SNPE_ROOT=/home/adlink/snpe-
source $SNPE_ROOT/bin/
source $SNPE_ROOT/bin/ 
pip3 install numpy==1.16.5 sphinx==2.2.1 scipy==1.3.1 matplotlib==3.0.3 scikit-image==0.15.0 protobuf==3.6.0 pyyaml==5.1 
source snpe- 
pip3 install onnx
pip3 install torch 
pip3 install onnxsim

Step 4: Convert *.pt to ONNX

cd ~
tar -zxvf YOLOv6.tar.gzcd ~/YOLOv6/
python3 ./deploy/ONNX/ \
    --weights ./deploy/ONNX/ \
    --img 288 \
    --batch 1 

Step 5: Convert *.ONNX to *.dlc

cd ~/snpe-
./snpe-onnx-to-dlc --input_network ~/YOLOv6/deploy/ONNX/yolov6n.onnx  --output_path yolov6n_base_quantized.dlc

Step 6: Replace model in Neon-RB5

Replace *.dlc in /home/adlink/Desktop/Neon-RB5_sample/samples/build

	cd /home/adlink/Desktop/Neon-RB5_sample/samples/build