# Transmission Tower Re-Identification Algorithm Based on Machine Vision
## 2 The Proposed Method
### The Transmission Tower Detection Based on the Improved YOLO
#### 2.2.1 Improvement of YOLOv5n  
YOLOv5 [15], a detection model introduced by Ultralytics in 2020, has evolved from its initial release of version 1.0 to version 7.0. In the YOLOv5 architecture, CBS consists of Convolution (Conv), BatchNormlization (BN), Sigmoid Linear Unit (SiLU). The CSP Bottleneck with three convolutions (C3) module is utilized in the backbone and the head networks. Within the backbone network, this module is denoted as C3_n, where 'n' represents the number of Bottleneck1 units. In contrast, in the head network, it is denoted as C3_n_F, with 'n' indicating the number of Bottleneck2 units. This differentiation underscores the adaptive use of the CSP Bottleneck structure in various segments of the YOLOv5 model to optimize performance. The backbone feature extraction network of YOLOv5 consists of CBS, C3_n, Spatial Pyramid Pooling--Fast (SPPF). The head network of YOLOv5 consists of CBS, upsampling, C3_n_F and Conv, constructing three sub-detection modules of varying dimensions. The loss function of YOLOv5 combines categorical probability cross-entropy loss, binary cross-entropy loss for confidence, and bounding box regression loss, aiming for a comprehensive optimization of the target detection model. The categorical probability loss adjusts the target category of the classification prediction box, the confidence loss determines whether the prediction box genuinely contains the target object, and the bounding box regression loss finetunes the exact position of the prediction box. The total loss is determined by the cumulative weighted sum of these three losses, as illustrated in Equation (1):  
\[Loss=\lambda_{1}L_{cls}+\lambda_{2}L_{obj}+\lambda_{3}L_{box} \tag{1}\]  
where \(L_{cls}\) represents classification loss, \(L_{obj}\) represents confidence loss, \(L_{box}\) represents bounding box regression loss, \(\lambda_{1}\) is the weight of the classification loss, \(\lambda_{2}\) is the weight of the confidence loss, \(\lambda_{3}\) is the weight of the bounding box regression loss.  
This study introduces two derivative models based on the YOLOv5n architecture: YOLOv5n-c2f head and YOLOv5n-conv head. [PERSON] et al. [17] suggested that the CSP Bottleneck with two convolutions (C2f) can introduce gradient flow to enhance the feature extraction capability of the head network. In the YOLOv8 architecture, the structure of the C2f module differs between the backbone and head networks. Within the backbone network, this module is denoted as C2f_n, where 'n' represents the number of Bottleneck1 units. Conversely, in the head network, it is identified as C2f_n_F. Here, 'n' indicates the number of Bottleneck2 units. In our research, the YOLOv5n underwent a structural modification where the original C3_n_F module was replaced with the C2f_n_F module. This alteration resulted in the creation of a new variant, designated as the YOLOv5n-c2f head. Furthermore, we replaced the C3_n_F module in YOLOv5n with a two-layer CBS network, resulting in the formation of the YOLOv5n-conv head. All the previously discussed modules, as well as the refined YOLOv5n-conv head network, are depicted in Figure 4. This substitution aims to streamline the network, decrease the inference time for the transmission tower detection, and facilitate real-time monitoring on mobile devices. The overall network structure of YOLOv5n-conv head is illustrated in Figure 4. Since our alterations were limited to specific layers within the head network of YOLOv5n, the loss calculation for both YOLOv5n-c2f head and YOLOv5n-conv head remains as outlined in Equation (1).