Member-only story
How to Prune and Sparse YOLOv5?
Yolov5 is a modern object detection algorithm, that has been written in a PyTorch, Besides this, it has, fast speed, high accuracy, easy to install and use.
The importance of yolov5 is raised, due to its different export and deployment modules. We can convert the trained model (.pt) in many extensions i.e.,
- torch(.pt) → tensorflow-lite(.tflite) {for android development etc)
- torch → open-neural-network-exchange (.onnx) {for cross platforms}
- torch → Tensorrt-engine (.trt/.engine) {for Tensorrt integration)
Pruning?
Pruning is the process of “Modification of weights by reducing the weights parameters, that does not impact on the classification of classes”. Yolov5 uses the technique of pruning in a way that “randomly in some percentage of weights parameters, nn.conv2d layers whose weights are nearly zero, it will convert them to zeros”.
YOLOV5 Pruning Procedure?
You will first need to train yolov5 on your custom data, Once training is completed, you need to validate your trained model on Validation data, at that time you can call the prune function for the trained model to prune.
you can use your custom-trained weights best.pt file for pruning with the below code, if you just want to prune…