Author: Pedro Vinícius A. B. Venâncio1,2
1 Graduate Program in Electrical Engineering (PPGEE/UFMG)
2 Gaia, solutions on demand (GAIA)
This repository contains the source codes of some techniques for filter pruning in convolutional neural networks implemented in the Darknet framework. Pruning a trained network with an appropriate technique can slightly decrease its performance (or even improve it in some cases), in addition to making the network lighter and faster to run on mobile devices and machines without a Graphics Processing Unit (GPU). The pruning techniques implemented can be classified into three categories:
- Criteria-based pruning techniques: L0-Norm, L1-Norm, L2-Norm, L-Inf Norm and Random.
- Projection-based pruning techniques: PLS(Single)+VIP, PLS(Multi)+VIP, CCA(Multi)+CV and PLS(Multi)+LC.
- Cluster-based pruning techniques: HAC+PCC.
Note: If you do not want to reuse the filters that remained in the pruned architecture for fine-tuning, just use the From-Scratch mode.
After compiling Darknet on your machine, creating your .cfg and .data files and training your network, follow these steps:
- Download this repository within your
darknet/
folder:
git clone https://github.com/pedbrgs/Pruning-Darknet/ darknet/pruning/
-
After that, move all files and folders from
pruning/
to root directorydarknet/
. You can remove thepruning/
folder, which is empty now. -
Move the
.cfg
,.data
,.names
,.weights
,train.txt
andvalid.txt
files into the darknet repository. Make sure that you have already trained the network for the desired task and that the paths in.data
are correct.
Note: If you arrived here in this repository without ever training a network in the Darknet framework, I recommend that you learn how to use it first. You need to compile Darknet, define your deep network, define your dataset and train your model to proceed.
- Run pruning with fine-tuning:
- Example for a criterion-based method:
python prune.py --cfg yolo.cfg --data yolo.data --names yolo.names --weights yolo.weights --network YOLOv4 --img-size 416 --technique L1 --pruning-rate 0.60 --pruning-iter 2 --lr 0.005 --tuning --tuning-iter 30000
- Example for a projection-based method:
python prune.py --cfg yolo.cfg --data yolo.data --names yolo.names --weights yolo.weights --network YOLOv4 --img-size 416 --technique PLS-VIP-Multi --pruning-rate 0.60 --pruning-iter 2 --lr 0.005 --pool-type max --n-components 2 --num-classes 3 --perc-samples 0.1 --tuning --tuning-iter 30000
- Example for a cluster-based method:
python prune.py --cfg yolo.cfg --data yolo.data --names yolo.names --weights yolo.weights --network YOLOv4 --img-size 416 --technique HAC --pruning-rate 0.60 --pruning-iter 2 --lr 0.005 --measure Pearson --tuning --tuning-iter 30000`
Please cite my paper in your publications if you use this source code.
-
Pedro Vinícius Almeida Borges de Venâncio, Adriano Chaves Lisboa, Adriano Vilela Barbosa: An automatic fire detection system based on deep convolutional neural networks for low-power, resource-constrained devices. In: Neural Computing and Applications, 2022.
- Darknet Manual
- Compile on Windows
- Compile on Linux/macOS
- Requirements (and how to install dependecies)
Please send any bug reports, questions or suggestions directly in the repository.