The Darknet pruner is used to prune YOLO models. In Vitis AI 1.4, vai_p_darknet supports YOLOv2, YOLOv3, and YOLOv4. In this section, a YOLOv3 example is used to demonstrate how to use vai_p_darknet.
A typical main cfg file for YOLOv3 pruning is as follows. In this example, you will prune a YOLOv3 model trained on a VOC dataset and prepare the VOC data in the standard Darknet way. Refer to the YOLO website for details.
Because of the YOLOv3 network structure, the convolution layer before the
YOLO layer cannot be pruned, which means that if you use standard YOLOv3 cfg file, layer
81, 93, and 105 should be added to “ignore_layer.” A full list of main cfg options can
be found in the vai_p_darknet Usage section.
Recommended: Do not prune
the convolution layer before 81, 93, and 105. The ana step will be very slow if
layers 80, 92,104 are not ignored.
Note: For YOLOv4,
use
"yolo_v3v4=1"
instead of "yolov3=1"
.# a cfg example to prune YoloV3
[pruning]
workspace=pruning
datacfg=pruning/voc.data
modelcfg=pruning/yolov3-voc.cfg
prunedcfg=pruning/yolov3-voc-prune.cfg
ana_out_file=pruning/ana.out
prune_out_weights=pruning/weights.prune
criteria=0
kernel_batch=2
ignore_layer=80,81,92,93,104,105
yolov3=1
threshold=0.005