# Transmission Lines Small-Target Detection Algorithm Research Based on YOLOv5
## 3 Introduction to the P2E-YOLOv5 Network
### ECA Attention Mechanism  
In the case of small target images of transmission lines with complex environmental backgrounds, such as insulators and bolts, there are challenges like inconspicuous features and high susceptibility to environmental interference. These factors make it difficult for the detection model to accurately identify them. To address these issues, this paper introduces the ECA attention mechanism, as depicted in Figure 5, to effectively mitigate the impact of environmental factors and improve the network's ability to focus on small target areas, thus enhancing the accuracy of detection.  
By incorporating the ECA attention module after the BN layer of the CBS module, the interference of environmental factors on small targets can be significantly reduced. This allows the model to effectively identify obstructed small targets and strengthen its focus on the small target area. Furthermore, the CBES module composed of the ECA attention module can be added to both the backbone network and neck network. This enhancement strengthens the network model's feature extraction capability for small targets, ultimately leading to improved detection performance.  
Figure 4: By leveraging the three detection heads derived from the initial P3, P4, and P5 layer feature maps, a novel detection head with an elevated resolution of 160 \(\times\) 160 pixels is extracted from the P2 layer feature map.  
The ECA attention module is a lightweight module that can be seamlessly integrated into the CNN architecture. It employs a local cross-channel interaction strategy without dimension reduction, effectively preventing any negative impact on channel attention learning caused by dimension reduction. This proper cross-channel interaction allows for a significant reduction in model complexity while preserving performance. The structure of the ECA module is illustrated in Figure 6:  
Figure 5: The ECA attention mechanism is added after the BN layer of the CBS module.  
Figure 6: Specific composition of ECA attention module.  
The ECA attention module is described in detail as follows:  
1. The first input is an H \(\times\) W \(\times\) C dimensional feature graph;
2. The input feature map undergoes spatial feature compression: in the spatial dimension, a feature map of 1 \(\times\) 1 \(\times\) C is obtained by using global average pooling;
3. Channel features are learned for the compressed feature graph: the importance of different channels is learned through 1 \(\times\) 1 convolution, and the output dimension remains 1 \(\times\) 1 \(\times\) C. Among them, \[\text{k}=\psi(C)=\left|\frac{\log 2C}{\gamma}+\frac{b}{\gamma}\right|_{odd}.\] (1) Formula: the size of k can be obtained adaptive, where C represents the channel dimension, \(\left|\text{t}\right|_{odd}\) represents the odd number closest to t, where \(\gamma=\) 2, b = 1.
4. Finally, the channel attention is combined, and the feature map of channel attention 1 \(\times\) 1 \(\times\) C is multiplied channel by channel with the original input feature map H \(\times\) W \(\times\) C to generate a feature map with channel attention.