## 2 Materials and Methods
### Proposed Methodology
#### 2.2.2 Improvement Methods  
In order to be more suitable for cracks in our dataset, YOLOv5 has been enhanced in four aspects, and they are illustrated separately in the following sections. 1. 160 \(\times\) 160 Detection Layer for Small Targets  
There are three (20 \(\times\) 20, 40 \(\times\) 40, and 80 \(\times\) 80) detection branches in the head of YOLOv5. In multi-scale detection, the larger the size of the feature map, the more conducive it is to extracting small target features. In this study, a small-target detection layer with size 160 \(\times\) 160 was added into the original YOLOv5 framework in order to enhance the detection of small-sized cracks which are abundant in our dataset. In YOLOv5, the original three branches are connected to the 3 rd, 4 th, and 5 th feature layer, respectively. After improving, the new detection branch integrated the 2 nd feature layer where shallow features generated into the feature fusion network. 2. Anchor Box Update  
The anchor box is the prior knowledge from the dataset. During the model training process, anchor boxes that are more closely matched to the dataset will assist the network with converging better and faster. The original anchor box of previous-generation networks such as YOLOv3 was set up for the COCO dataset and was not applicable to self-built datasets, the problem of which has been settled in YOLOv5 by introducing the K-means clustering algorithm to generate an adaptive anchor box automatically. Considering that K-means convergence depends heavily on the cluster center's initialization status, the K-means++ clustering algorithm was used to cluster the label boxes of crack dataset in this study. As much as possible, K-means++ could lead the randomly selected center point to a global optimal solution rather than a local optimal solution. The updated 12 anchor boxes are as follows: [15 39], [65 12], [44 49], [23 108], [169 19], [52 127], [84 82], [248 38], [103 146], [156 99], [179 189], [322 176]. 3. Improved Neck Structure Based on Bi-FPN  
Figure 4: The network architecture of YOLOv5. The neck structure of YOLOv5 consists of a feature pyramid network (FPN) and path aggregation network (PANet). This combination makes cross-layer connection and information aggregation possible. And while fusing the input feature maps that derived from different scales, YOLOv5 uses an equivalent weight strategy. In this study, a bi-directional weighted feature pyramid network (Bi-FPN) was adopted. Bi-FPN was proposed by the Google team based on PANet, an extra path is added to fuse features in the feature extraction network and bottom-up path to realize cross-scale connections [52]. In addition, weighted feature fusion and a fast normalization method are introduced to distinguish the contribution of different feature maps, the employment of which achieves an adaptive balance for the process of network fusion. Figure 5 shows the neck structure design in this study. 4 Improved Cross-Layer Connections  
In this study, the feature maps of the YOLOv5 network were visualized and the hsv colormap was selected to scalar the grayscale data of feature maps to colors. Figure 6 displays the visualized feature maps generated by the feature extraction network of an example image, ranging from shallow to deep layers, and the red boxes in example image represent the crack area. It is obvious that shallow features contain more detailed crack information such as location, contour, color, etc. ; on the contrary, deep features are more abstract and complex and mainly contribute to target classification. It is also clear that pavement cracks do not have strong semantic information, and shallow features are strong indicators in crack detection. In the original YOLOv5 network, there is a connection between the 3 rd feature layer and the 80 \(\times\) 80 detection branch, and also between the 4 th feature layer and the 40 \(\times\) 40 detection branch, the 5 th feature layer and the 20 \(\times\) 20 detection branches.