# Transmission Lines Small-Target Detection Algorithm Research Based on YOLOv5
## 3 Introduction to the P2E-YOLOv5 Network
### Optimize the Loss Function  
In order to address the challenges posed by the indistinct and aggregated characteristics of small targets on transmission lines, this paper proposes the use of EIOU_Loss as the loss function for network regression. This approach aims to improve the regression accuracy of bounding boxes, enhancing the network's ability to accurately identify and localize small targets. Small-target images of transmission lines captured using UAV, such as insulators and bolts, constitute a very small proportion of the entire image, and their low resolution result in limited visual information, making it challenging to extract clear and distinct features. These characteristics pose difficulties for detection models in accurately locating and identifying these small targets. Additionally, when small targets are densely clustered, they may merge into a single point in the deep feature map after multiple down-sampling, causing the detection model to fail to distinguish them. Furthermore, when small targets are too close to each other, the non-maximum suppression operation in post-processing may filter out a significant number of correct predictional bounding boxes, resulting in missed detections. The original YOLOv5 network used CIOU_Loss [24] as the loss function for network regression. Although CIOU_Loss considered the overlap area, center point distance, and aspect ratio of bounding box regression, it only accounted for the aspect ratio difference in bounding boxes and did not consider the actual differences between width and height and their confidence. Additionally, when the aspect ratio of the predicted box changes proportionally, the aspect ratio penalty in CIOU_Loss loses its effectiveness, making it challenging to accurately locate and recognize small targets. To address these issues, this paper adopts the EIOU_Loss function as the regression loss function for the P2E-YOLOv5 model. EIOU_Loss resolves the ambiguity in the definition of aspect ratio and the proportional change of aspect ratio that affects the penalty in CIOU_Loss. By doing so, the EIOU_Loss effectively improves the detection model's precise positioning of small targets such as insulators and bolts. This enhancement leads to improved convergence and significantly reduces the model's omission rate for these small targets. The EIOU_Loss function used in this paper consists of three components: overlap loss LIOU, center distance loss Ldis, and width and height loss Lasp. The first two parts retain the benefits of the CIOU method, while the width and height loss divides the aspect ratio loss term into the difference between the predicted width and height and the minimum width and height of the enclosing box. This modification is applied to the penalty term of CIOU to expedite model convergence and enhance regression accuracy. The calculation formula for EIOU Loss is as follows:\[\mathrm{L}_{\mathrm{EIOU}}=\mathrm{L}_{\mathrm{IOU}}+\mathrm{L}_{\mathrm{dis}}+ \mathrm{L}_{\mathrm{asp}}=1-\mathrm{IOU}+\frac{\rho^{2}\left(\,\mathrm{b},\, \mathrm{b}^{\mathrm{gt}}\right)}{\mathrm{C}^{2}}+\frac{\rho^{2}(\omega,\omega ^{\mathrm{gt}})}{\mathrm{C}^{2}_{\omega}}+\frac{\rho^{2}\left(\,\mathrm{h},\, \mathrm{h}^{\mathrm{gt}}\right)}{\mathrm{C}^{2}_{\mathrm{h}}} \tag{2}\]  
where: IOU represents the intersection over union ratio between the prediction box and the ground truth box, b and \(\mathrm{b}^{\mathrm{gt}}\) represent the center points of the prediction box and ground truth box, \(\rho\)(b,\(\mathrm{b}^{\mathrm{gt}}\)) represents the Euclidean distance between the center point of the prediction box and the ground truth box, C represents the diagonal distance of the smallest enclosing rectangle of prediction box and ground truth box, and \(\omega^{\mathrm{gt}}\) and \(\mathrm{h}^{\mathrm{gt}}\) are respectively the width and height of the ground truth box.