Yolov3 Tiny Tutorial Darknet To Caffe Conversion and Implementation On Xilinx DNNDK - August12 - 2019
Yolov3 Tiny Tutorial Darknet To Caffe Conversion and Implementation On Xilinx DNNDK - August12 - 2019
Put the downloaded cfg and weights file for yolov3-tiny inside the 0_model_darnet folder.
Replace this:
[maxpool]
size = 2
With this:
[maxpool]
size = 1
Then run the 0_convert.sh file. Before that modify the script file as shown below:
$ python ../yolo_convert.py \
0_model_darknet/yolov3-tiny.cfg #path to Darknet cfg file \
0_model_darknet/yolov3-tiny.weights #path to Darknet weights file \
1_model_caffe/v3-tiny.prototxt #path to Caffe prototxt file \
1_model_caffe/v3-tiny.caffemodel #path to Caffe caffemodel file
This script will convert the Darknet model into two caffe files, v3-tiny.prototxt and v3-tiny.caffemodel
and store inside 1_model_caffe folder.
You can test the caffe prototxt using the 1_test_caffe.sh script inside example_yolov3 folder.
To quantize the Caffe model, copy v3-tiny.prototxt and v3-tiny.caffemodel from 1_model_caffe to the
2_model_for_qunatize. Then modify the v3-tiny.protxt file as shown below:
Also make sure to change the source and root folder path accordingly to where you have extracted
the 5_file_for_test folder. This contains calibration data.
If you are doing in CPU only mode like inside a virtual machine your script will be the following:
#Assuming "decent" tool is already in the PATH
$ decent-cpu quantize -model 2_model_for_quantize/v3-tiny.prototxt \
-weights 2_model_for_quantize/v3-tiny.caffemodel \
-sigmoided_layers layer15-conv,layer22-conv \
-output_dir 3_model_after_quantize \
-method 1
Layer15-conv and layer22-conv are the output layers in the Yolov3-tiny as opposed to Yolov3 where
layer81-conv, layer93-conv and layer105-conv are the output layers.
$ dnnc-dpu1.3.0 --prototxt=3_model_after_quantize/deploy.prototxt \
--caffemodel=3_model_after_quantize/deploy.caffemodel \
--dpu=4096FA \
--cpu_arch=arm64 \
--output_dir=4_model_elf \
--net_name=yolo_tiny \
--mode=normal \
--save_kernel
If you are using DDNDK version 3 which contains dpu 1.4 change the dnnc-dpu1.3.0 to dnnc which will
use whatever dpu version you have installed. For Ultra95 change the dpu architecture to 2304FA.
For Ultra96
$ dnnc --prototxt=3_model_after_quantize/deploy.prototxt \
--caffemodel=3_model_after_quantize/deploy.caffemodel \
--dpu=2304FA \
--cpu_arch=arm64 \
--output_dir=4_model_elf \
--net_name=yolo_tiny \
--mode=normal \
--save_kernel
This will generate dpu_yolo_tiny.elf file inside the 4_model_elf file. Copy the dpu_yolo_tiny.elf file to
the model folder in the yolov3_deploy folder.
Then setup the board and transfer this yolov3_deploy folder to your target board. Ultra96 in our case.
Edit the main.cc file which inside yolov3_deploy/src folder. And Make changes as follows:
To
To
Then Save the file. Change the directory to yolov3_deploy and run the make command as follows:
make -j
6. Output of YoloV3-Tiny-Caffe
Figure 2 On video
***
End of Tutorial!
***