## 2 Materials and Methods
### Improvements in YOLOv5s Network Model
#### 2.2.2 Optimization of Network Structure and Loss Function  
Object detection algorithms are usually divided into two different tasks: classification and localization. The classification task focuses on identifying texture and appearance features to determine objects' categories, while the localization task aims to pinpoint the objects' exact locations by accurately capturing edge information. Previous methods utilized a single feature map for both tasks, which may result in suboptimal performance due to the differing feature requirements of each task. The classification result depends on feature similarity to a specific class, whereas the localization task requires precise spatial coordinate predictions for bounding box adjustments. The previous approach often led to spatial misalignment between tasks as the feature needs of the classification and localization tasks may be different. Figure 2: Network structure of efficient channel attention module. To address the above problems, we implemented a decoupled head structure which was initially introduced and validated in YOLOv5 [31]. As illustrated in Figure 3, this structure enables separate feature extraction pathways for classification and localization, and each pathway includes a custom-designed network layer. This design not only improves detection accuracy but also accelerates the convergence of network training and improves detection efficiency by focusing on the respective key features. Crack detection in complex pavement scenes especially benefits from this decoupled head structure. The classification pathway can focus on identifying the essential features of cracks, significantly reducing the interference of complex backgrounds. Although the decoupled head provides different feature maps for the two tasks, it is designed to remain lightweight, which is critical for pavement crack detection systems that require real-time responses. Compared to conventional coupled heads, decoupled heads exhibit more efficient processing capabilities in terms of characterization requirements for different tasks, enhancing the classification and localization of objects. Furthermore, this structure efficiently preserves channel information through depth and breadth optimization, lowering computational demands and boosting network speed. Consequently, the decoupled head structure offers a solution for object detection, particularly in dynamic and intricate pavement environments. In the original YOLOv5 model, the regression loss function of a bounding box is CIoU (Complete Intersection over Union) loss. The Unet++ network was chosen for further crack segmentation after object detection using YOLOv5s, and high recall is crucial. GIoU (Generalized Intersection over Union) shows superior performance with small-box annotations. Thus, the GIoU loss function is used in the improved YOLOv5s. These modifications enhance the model's compatibility with small-bounding-box annotations  
Figure 3: Decoupled head architecture. and boost precision and recall in crack identification. The loss function is defined as shown in Equations (3)-(6):  
\[Loss_{CIoU}=1-IoU+\frac{\rho^{2}\big{(}b,b^{gt}\big{)}}{c^{2}}+av \tag{3}\]  
\[v=\frac{4}{\pi^{2}}\bigg{(}tan^{-1}\frac{w^{gt}}{hs^{gt}}-tan^{-1}\frac{w}{h} \bigg{)}^{2} \tag{4}\]  
\[a=\frac{v}{(1-IoU)+v} \tag{5}\]  
\[L_{GIoU}=1-IoU+\frac{|C-(A\cup B)|}{|C|} \tag{6}\]  
where the variables are defined as follows:  
_IoU_ (Intersection over Union) calculates the ratio of intersection to union between the predicted and actual boxes;  
\(b\) represents the centroid of the predicted box, and \(b^{gt}\) is the centroid of the actual box;  
\(\rho\) denotes the Euclidean distance;  
\(c\) is the length of the diagonal of the encompassing rectangle formed by both boxes;  
\(\alpha\) is the weight coefficient; \(v\) measures the aspect ratio discrepancy between the predicted and actual boxes. The introduction of aspect ratio considerations in the CIoU loss function emphasizes the bounding box's shape.