# A Multi-Scale Rebar Detection Network with an Embedded Attention Mechanism
## 2 Materials  
### Introduction of YOLO Series Algorithm  
The YOLO algorithm is a deep learning-based regression detection method and also the leading algorithm in one-stage object detection. The core idea of YOLOv1 is to use the whole picture as the input of the network to regress the position and category of the box directly in the output layer, and the loss function uses the sum-squared error loss (SEL). The problem with using a single loss is that the IoU error for large objects and the IoU error for small objects contribute close to the loss value in network training. Therefore, for small objects, a very small IoU error can have a significant impact on network optimization, reducing the localization accuracy of object detection. YOLOv2 has been improved in three aspects: more accurate prediction, faster speed, and more recognized objects, while maintaining the processing speed. A joint training algorithm is proposed, which mixes two datasets, uses the idea of a hierarchical classification of objects, and expands the detection dataset with the huge data from the classification dataset to train a better detection model. YOLOv3 uses multi-scale prediction and is designed in such a way that it still uses the clustering algorithm to obtain 9 clustering centers, which are divided into 3 detection layers according to their sizes. Also, the backbone of the network uses Darknet-53, and YOLOv3 has a significant improvement in detection accuracy compared to YOLOv2. YOLOv4 mainly replaces the Darknet-53 backbone with CSPDarknet-53 and adds the spatial pyramid module (SPP) and path aggregation network (PANNet). Adding a dropblock module prevents overfitting while using the Mish and Leaky Relu activation functions. In 2020, Ultralytics released the YOLOv5 algorithm, which improves the backbone of C3 Darknet, making the algorithm more sensitive to feature information and thus better able to extract feature information. YOLOv5 performs one-stage object detection with high detection accuracy and fast inference, and the fastest detection rate is 140 frames/sec. On the other hand, the model weight of the YOLOv5 network is smaller, reduced by nearly 90% compared to YOLOv4; therefore, the YOLOv5 model is suitable for deployment to embedded devices for real-time detection. Meanwhile, YOLOv5 contains four size architectures: s, m, l, and x. The main difference between them is the different number of feature extraction modules and convolutional kernels of the network. The size of the model and model parameters increase sequentially in the four architectures. In summary, the advantages of YOLOv5 are high detection accuracy and a fast detection rate. Meanwhile, a large number of experiments show that YOLOv5 works well on many open-source datasets, but the performance in the smart rebar detection task still needs to be improved. Since the accuracy and real-time performance of rebar detection are crucial to the accuracy and efficiency of rebar recognition, especially for densely arranged targets in the dataset whose target boundary features are not obvious, small targets, and those with a complex overall image background, this study intends to improve the rebar target recognition network based on YOLOv5 and verify the effectiveness of the improved algorithm on the test set. Figure 1 shows the structure of the YOLOv5 network. The Conv module includes convolution, batch norm, and activation function operations, where the swish activation function is used in the new version of YOLOv5. The Bottleneck module first uses the convolution operation with a convolution kernel size of 1 \(\times\) 1 to reduce the number of channels of the input feature map, then doubles the number of channels through 3 \(\times\) 3 convolution, and finally performs feature fusion through a shortcut connection, with the number of channels of the fused feature map remaining unchanged; Figure 2 shows the Bottleneck module. The C3 module contains multiple Bottleneck modules that can adjust the depth of the network by setting the size of n. Figure 3 shows the C3 module.