# A Multi-Scale Rebar Detection Network with an Embedded Attention Mechanism
## 1 Introduction
[17] introduced a feature pyramid and complete cross-joint intersection over union (IoU) in YOLOv3 loss and focal loss to propose a YOLOv3-based rebar counting method in real time. One essential task in the intelligent application is the detection of the number of rebars, which requires high detection accuracy because a rebar is expensive and there are many of them in actual use, and both misdetection and omission need to be identified manually in a large number of marked points; therefore, current rebars are still manually inventoried. It is proposed in the literature [12; 15] that traditional image processing techniques can be used to preprocess the input image and combine the area and morphology for matching counts, but they do not perform well in dense or occluded situations. To further improve the efficiency and accuracy of rebar counting, a study on rebar identification using a neural network was proposed in the literature [18], which significantly improved the detection efficiency but was slightly inferior in accuracy. [PERSON] et al. [16] proposed a data enhancement method of SWDA (strong-weak distribution alignment), in which each rebar is first positioned for cropping, then a fully convolutional network (FCN) model is input to obtain the semantic mask, and, finally, three FCN models are used to perform high-quality semantic segmentation and combination of the rebar cross-section. Although better accuracy was achieved, this multi-stage network design model is larger and requires higher clarity of the input images. Therefore, how to improve the detection speed without reducing the detection accuracy becomes an urgent problem. In the literature [19], it is pointed out that the use of a residual network (ResNet) can effectively solve the problems of gradient dispersion, explosion, and network degradation of neural networks, which enables the input information to propagate further in the network and also improves the performance of the network. The use of pyramid pooling allows the fusion of high- and low-layer features, resulting in a network with better final semantic information features and spatial information features [20]. The literature [21] proposes an automatic detection and localization method using deep learning and migration. The literature [22] proposes a new and accurate counting model based on YOLOv3 to automatically and efficiently count dense steel pipes by using images. Although the rebar detection counting technique is progressively mature, there is still a possible big boost. In this paper, we propose an improved YOLOv5-based rebar cross-section detection algorithm with the following contributions:  
1. In response to the current problem of scarce rebar datasets and complex practical application scenarios, a new rebar cross-section dataset is created. In order to improve the data labeling efficiency, we propose a new semi-automatic data labeling method. 2. In order to make the anchor box parameters fit the rebar dataset better, the anchor boxes are re-clustered using the K-means++ algorithm, thus suppressing the redundancy of the anchor box caused by too many small targets and close rebar target sizes. 3. The channel attention (CA) module was integrated into the backbone network and the attention weight of the feature map was adjusted to make the network more focused on the \"interested\" targets so as to enhance the feature extraction capability of the network. 4. The new SD_IoU Loss is designed as the loss function of the bounding box, and the angular deviation and distance between the predicted box and the true box are considered to improve the accuracy of the box detection. 5. To address the problem that small targets with scales smaller than 8\(\times\)8 in the network cannot be detected, the detection loss rate of the network for small targets is reduced by fusing high-level semantic information with low-level features and redesigning a new detection layer.