YOLOv8/YOLOv7/YOLOv5/YOLOv4/Faster-rcnn series algorithm improvements [NO.79] The improved loss function is VariFocal Loss

 Foreword
As the current advanced deep learning target detection algorithm YOLOv8, it has gathered a large number of tricks, but there is still room for improvement and improvement, aiming at the detection difficulties in specific application scenarios. , can be improved in different ways. The following series of articles will focus on a detailed introduction to how to improve YOLOv8. The purpose is to provide meager help and reference for those students who are engaged in scientific research and need to innovate or those who are engaged in engineering projects who need to achieve better results. Due to the emergence of YOLOv8, YOLOv7, and YOLOv5 algorithms, a large number of improvement papers have emerged since 2020. Whether for students engaged in scientific research or friends who are already working, the value and novelty of the research are not enough. In order to keep up with the times, In the future, the improved algorithm will be based on YOLOv7. The previous YOLOv5 improvement method is also applicable to YOLOv7, so the serial number of the YOLOv5 series of improvements will continue. In addition, the improvement method can also be applied and improved in other target detection algorithms such as YOLOv5. Hope it helps everyone.

1. Solve problems

It is mainly aimed at improving the detection effect of data sets with small targets, dense targets, and occluded targets. Focal loss mainly solves the problem of imbalance of positive and negative samples. The above situations involve situations where there are fewer positive samples and more negative samples. By introducing VariFocal Loss, an improved version of focal loss, similar problems can be effectively solved and the target detection effect can be improved.

2. Basic principles

Abstract: Accurately ranking large numbers of candidate detections is critical for achieving high performance in dense object detectors. Previous work uses classification scores or a combination of classification and predicted localization scores to rank candidates. However, neither option leads to reliable rankings, thus reducing detection performance. In this paper, we propose to learn the Iou-aware classification score (IACS) as a joint representation of object presence confidence and localization accuracy. We show that, based on IACS, dense object detectors can achieve more accurate ranking of candidate detections. We design a new loss function, called zoom loss, to train dense object detectors to predict IACS, and propose a new star-shaped bounding box feature representation for IACS prediction and bounding box refinement. Combining these two new components and the bounding box refinement branch, we build an IoU-aware dense object detector based on the FCOS+ATS architecture, referred to as VarifocalNet or VFNet.        

3. Add method

The specific improvement code can be obtained by private message me.

Example of improvement using yolov5-6.0 project

Step 1: Replace the focal loss function call in the code in loss.py

Step 2: Add VariFocal Loss code in loss.py (modify and integrate according to the original text of the paper)

Step 3: Change the focal parameter to 1.5 in hyp.scratch.yaml

Step 4: Run train.py.

4. Summary

Preview: The next article will continue to share improvements related to deep learning algorithms. Friends who are interested can follow me. If you have any questions, you can leave a message or message me privately.

PS: This method is not only suitable for improving YOLOv5, but can also improve other YOLO networks and target detection networks, such as YOLOv7, v6, v4, v3, Faster rcnn, ssd, etc.

Finally, if you need it, please send me a private message. Pay attention to receive free deep learning algorithm learning materials!

Guess you like

Origin blog.csdn.net/m0_70388905/article/details/134487622