With the rapid development of computer vision and machine vision, methods based on deep learning have achieved good results in the field of object detection, identification, and tracking. However, for the detection and identification of rebars in smart construction sites, it is very difficult to perform accurate real-time detection of rebars by using object detection technology on the equipment in the field because of the problems of the dense cross-section between bundled bars, the mutual adhesion of cross-section boundaries, and mutual occlusion between cross-sections. To address the above problems, we propose a multi-scale rebar detection network RebarNet with an embedded attention mechanism based on YOLOv5, combining the K-means++ algorithm, attention mechanism, a newly designed SD_IoU Loss, and multi-scale feature fusion, aiming to solve the problems of missed and false detection in dense small object detection. Due to the problems of scarce rebar cross-section datasets, no publicly available large datasets, and weak rebar cross-sectional features, we constructed a new rebar cross-sectional dataset, used a semi-automatic annotation method to annotate part of the dataset, and then used the data enhancement algorithm to expand the rebar dataset. The experimental results show that the average accuracy (mAP) of our proposed RebarNet network is 97.9%, which is comparable to mainstream target detection algorithms such as Faster R-CNN, SSD, RetinaNet, CenterNet, CornerNet, YOLOv3, YOLOv4, and YOLOv5s. mAP0.5 is improved by 8.1%, 13%, 26.4%, 25.8%, 26.2%, 11.7%, 7.6%, and 9%, respectively. In addition, the frames per second (FPS) transmission reaches 89 frames per second, the model weight is only 17.0 MB. In summary, the proposed RebarNet can effectively reduce missed and false detections in the rebar counting detection task based on real-time detection.