Construction waste detection method based on improved YOLOv5 model
By improving the YOLOv5 model, combining the Focus, Conv, C3, SPP and Transformer Encoder structures, designing asymmetric weighted feature fusion Neck network and CIoU non-linear non-maximum suppression algorithm, the problem of insufficient detection performance of small objects in construction waste detection is solved. Efficient and accurate construction waste detection is achieved.
Patent Information
- Application Number
- CN202410693242.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-31
- Publication Date
- 2024-09-24
AI Technical Summary
The performance of existing deep learning algorithms in the detection of small and medium-sized objects in construction waste detection needs to be improved, leading to problems of false detection, missed detection and repeated detection, which is inefficient and error-prone.
Adopting a construction waste detection method based on the improved YOLOv5 model, building a backbone network through Focus, Conv, C3, SPP and Transformer Encoder structures, designing an asymmetric weighted feature fusion Neck network, and using CIoU-based non-linear non-maximum in the post-processing stage value suppression algorithm (C-NMS) to improve detection performance.
The recognition accuracy and efficiency of construction waste detection are significantly improved, especially in small object detection. The average accuracy is increased by 1.1%. At the same time, the amount of model parameters and inference time are reduced, making the model more suitable for deployment on mobile devices.
Smart Images

Figure CN118691789A
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of computer vision and deep learning, and in particular to a construction waste detection algorithm based on improved YOLOv5. Background Art
[0002] With the rapid development of urban construction, a large amount of construction waste has caused serious impact on the environment. In order to achieve effective management and resource utilization of construction waste, it is necessary to accurately detect and classify construction waste. At present, traditional construction waste detection and classification methods mainly rely on manual operation, which is inefficient and prone to errors. Therefore, it is particularly important to develop an automated construction waste detection and classification algorithm.
[0003] At present, the research on construction waste sorting technology is relatively limited. In practical applications, before the construction waste is identified by the visual system, it needs to be pre-processed by the crushing system to reduce the volume of construction waste and reduce the processing cost. Therefore, in the process of construction waste detection, the proportion of small targets is relatively high. The performance of existing deep learning algorithms in small object detection needs to be improved, which may lead to problems such as false detection, missed detection and repeated detection in the process of construction waste detection. In view of this challenge, it has become crucial to seek effective solutions. Summary of the invention
[0004] The purpose of the present invention is to propose a detection method for automatically identifying and locating construction waste, which has high recognition accuracy for various types of construction waste. In particular, the recognition ability is significantly improved in small object detection. With this invention, the classification and processing of construction waste will become more efficient and accurate.
[0005] To achieve the above object, the present invention proposes a construction waste detection method based on an improved YOLOv5 model, comprising the following steps:
[0006] Step 1: Use a 2D camera to shoot the moving construction waste to obtain a construction waste dataset;
[0007] Step 2: Label the collected construction waste images, and use the labeled construction waste dataset as model training sample data;
[0008] Step 3: Design an improved YOLOv5 model and optimize it specifically for the construction waste detection scenario to improve the detection performance;
[0009] S31: Build an improved YOLOv5 model backbone network by using Focus, Conv, C3, SPP and Transformer Encoder structures;
[0010] S32: Design an asymmetric weighted feature fusion Neck network to enhance the model's learning ability on feature maps of different resolutions;
[0011] In the feature fusion stage, the Fusion-Concat module is used to train the weights of each feature map information stream with different resolutions. The weight calculation of each information stream is expressed as follows:
[0012]
[0013] Among them, the symbol j represents the number of input nodes, and the ∈ value is set to 0.0001;
[0014] The output after feature fusion is expressed as:
[0015] Output=Concat(X[0]W[0],X[1],W[1],…,X[i]W[i])
[0016] Among them, each W[i]) ranges from 0 to 1, and the sum of the normalized weights of all inputs is 1;
[0017] S33: Design a CIoU-based nonlinear non-maximum suppression algorithm (C-NMS) to enhance the model's ability to filter detection boxes in the post-processing stage; the expression is as follows:
[0018]
[0019] Among them, s i Represents the detection box b i The classification confidence score, M represents the detection box with the highest score, N t Represents the threshold of the non-maximum suppression algorithm.
[0020] Step 4: Use the labeled construction waste detection dataset to train the optimized YOLOv5 model so that the model can learn and identify various types of construction waste;
[0021] Step 5: Apply the trained YOLOv5 model to construction waste detection in actual working scenarios to achieve automatic identification and positioning of construction waste.
[0022] Furthermore, in step 1, obtaining the garbage dataset includes the following methods:
[0023] Install the camera: Install a fixed 2D camera with high resolution and fast shooting capability above the construction waste conveyor belt to capture clear images of the construction waste;
[0024] Light source setting: Set up a suitable LED light source in the shooting area to ensure that the light is evenly distributed in the shooting area to ensure image quality;
[0025] Real-time shooting: During the shooting process, the construction waste moves on the conveyor belt at a certain speed, and the camera quickly focuses and captures clear images to complete the shooting;
[0026] Image storage: The processed images of the captured construction waste are usually stored in a cloud server.
[0027] Furthermore, in step 2, the following steps are included:
[0028] S21: labeling the collected construction waste images, using the labeling tool to draw the smallest rectangular frame around the construction waste target in the image, and assigning the corresponding category to it; during the labeling process, ensure that the rectangular frame fits the target object tightly and the category labeling is accurate; after the labeling is completed, generate the labeling information into an XML format data file for use in subsequent model training;
[0029] S22: Generate a TXT format file suitable for the YOLO model using the XML file; the TXT file contains target category information and normalized target rectangular frame coordinate data; through conversion, ensure that the YOLO model can correctly parse these data and accurately learn the target category and its corresponding bounding box position information during training.
[0030] Furthermore, the step 4 includes the following steps:
[0031] Application of pre-trained models: First, use the model trained based on the COCO dataset as the pre-trained model; then, on this basis, add the construction waste detection dataset for training, and adjust the model parameters to optimize the performance;
[0032] Image preprocessing:
[0033] Read image: read image data from the file and convert it into a digital matrix;
[0034] Scaling and padding: In order to adapt to the model input size, the input image needs to be scaled to the specified size; at the same time, in order to maintain the aspect ratio of the image, black or other colored pixels are filled around the scaled image;
[0035] Data augmentation: Increase the diversity of training samples by applying a variety of data augmentation techniques;
[0036] Normalization: Normalize the image data to a fixed range to control the numerical range of the model parameters;
[0037] Convert data format: convert the preprocessed image data into the data format required by the model to facilitate model calculation;
[0038] Batch processing: Combine multiple preprocessed images into a batch as input for model training or inference; improve model computational efficiency.
[0039] Model training.
[0040] Furthermore, in step 5, the construction waste image is predicted by the model trained in step 4; in the prediction process, the input image is first scaled, padded, and normalized to meet the input size and format requirements of the model; then, the trained model is used to predict the target in the image; in the prediction stage, a nonlinear non-maximum suppression algorithm based on CIoU is used to suppress redundant prediction boxes, and the final detection result is screened out according to the confidence and the set threshold; finally, the model outputs the predicted result to complete the detection task of the construction waste image.
[0041] Compared with the prior art, the advantages of the present invention are:
[0042] 1. The present invention is based on a backbone network of a multi-head self-attention mechanism of the Transformer Encoder structure and an asymmetric weighted feature fusion Neck network; these designs help to deeply explore the characteristics of the construction waste dataset.
[0043] 2. The present invention designs a nonlinear non-maximum suppression algorithm C-NMS based on CIoU to suppress redundant detection boxes.
[0044] 3. The present invention can effectively identify targets in construction waste images, significantly improves the ability to identify small targets, and increases the average detection accuracy by 1.1%. At the same time, the number of model parameters and reasoning time are also effectively reduced, making the model more suitable for deployment on mobile devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] Figure 1 It is the yaml file configuration of the improved YOLOv5 algorithm in the embodiment of the present invention.
[0046] Figure 2 This is a structural diagram of the improved YOLOv5 backbone network in an embodiment of the present invention.
[0047] Figure 3 This is a diagram of the improved YOLOv5 Neck network structure in an embodiment of the present invention.
[0048] Figure 4 : This is a diagram of the detection head network structure of the YOLO-V5 model in an embodiment of the present invention.
[0049] Figure 5This is the result of using the image enhancement technology on the construction waste image using the improved YOLO-V5 model in an embodiment of the present invention.
[0050] Figure 6 This is the improved YOLOv5 model architecture in the embodiment of the present invention.
[0051] Figure 7 This is the detection result of using the improved YOLOv5 model in the embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be further described below.
[0053] The present invention provides a construction waste detection method based on improved YOLOv5, aiming to improve the accuracy of construction waste detection, especially the detection ability of small objects; the specific implementation scheme is as follows:
[0054] Step 1: Use a 2D camera to shoot the moving construction waste and obtain a construction waste dataset, which includes the following sub-steps:
[0055] S11: Install a camera, that is, install a fixed 2D camera with high resolution and fast shooting capability above the construction waste conveyor belt to capture clear and detailed images of the construction waste.
[0056] S12: Setting the light source, that is, configuring a suitable LED light source in the shooting area to ensure that the light is evenly distributed in the shooting area and that the image quality is not affected by the light conditions.
[0057] S13: Real-time shooting, that is, during the shooting process, the construction waste moves on the conveyor belt at a certain speed, and the camera quickly focuses and captures clear images to achieve efficient and accurate shooting.
[0058] S14: Image storage, that is, after the construction waste images are initially processed, they are usually stored on a cloud server for subsequent use, such as model training, analysis, and optimization. This storage method helps improve data availability and ease of management.
[0059] Step 2: annotate the collected construction waste images and use the annotated construction waste dataset as model training sample data, including the following steps:
[0060] S21: Label the collected construction waste images, use professional labeling tools to draw the smallest rectangular box around the construction waste targets in the image, and assign corresponding categories to them. During the labeling process, ensure that the rectangular box fits the target object tightly and the category labeling is accurate. After completing the labeling, click the Save button to generate the labeling information into an XML format data file for use in subsequent model training.
[0061] S22: Generate a TXT file suitable for the YOLO model using the XML file. The TXT file contains target category information and normalized target rectangle coordinate data. Through conversion, the YOLO model is ensured to correctly parse the data and accurately learn the target category and its corresponding bounding box position information during training.
[0062] S23: Divide the dataset. The construction waste dataset obtained above contains a total of 4,873 images, including 6 common construction waste materials, namely concrete blocks, bricks, plastics, wood blocks, woven bags and paint blocks. They are divided into training set, validation set and test set in a ratio of 6:2:2.
[0063] Step 3: Figure 2 As shown in the figure, an improved YOLOv5 model is designed to perform specific optimization for the construction waste detection scenario to improve the detection performance. The following steps are included:
[0064] YOLOv5 (You Only Look Once version 5) is a real-time target detection algorithm that has achieved good performance in many target detection tasks. However, in the specific task of detecting construction waste, YOLOv5's small object detection performance is not ideal, which may lead to false detection, missed detection and repeated detection problems in construction waste detection. Therefore, this design proposes a targeted improvement strategy, as follows.
[0065] S31: In the YOLOv5 model, a convolutional neural network (CNN) is usually used to extract feature maps, which includes multiple convolutional layers and pooling layers. They gradually reduce the spatial resolution of the feature map to adapt to target detection tasks at lower resolutions. However, as the depth of the network increases, the resolution of the feature map decreases. Since the receptive field of the low-resolution feature map is relatively large, it may lead to loss of detail information and poor performance in detecting small targets, and missed detections are prone to occur. In addition, false detection and repeated detection problems also exist. In order to solve these problems, the present invention uses Focus, Conv, C3, SPP and TransformerEncoder structures to construct the backbone network of the YOLOv5 model, thereby enhancing the model's ability to perceive detail information and detect small targets in target detection tasks.
[0066] Further, the Focus module of the present invention is intended to extract low-level features of the input image. The main function of this module is to reduce the size of the input image by half and retain the important features of the input image in the process. Specifically, for a three-channel image, the Focus module slices the image and takes values every other pixel to construct 12 feature maps, and the size of these 12 feature maps becomes half of the original. Through this processing method, the Focus module can not only retain all the feature information of the input image, but also expand the number of channels by 4 times, so that the backbone network is more lightweight, while reducing the amount of calculation and memory usage. The module consists of two convolutional layers, namely a 3x3 convolutional layer and a 1x1 convolutional layer. Between the two convolutional layers, a convolutional layer with a step size of 2 is used to reduce the size of the input image by half. After the convolutional layer, a batch normalization layer and a SiLU activation function are also added. During the training process, the Focus module reduces the input image by half and outputs a feature map of 64 channels. The structure of this module is very simple, but it can effectively improve the performance and generalization ability of the model in practical applications.
[0067] Furthermore, the Conv module uses three key functions: convolution, batch normalization, and activation function to extract low-level and mid-level features of the image. At the same time, in order to avoid the loss of image edge information, the autopad(k,p) function is used to achieve the padding effect, thereby improving the robustness and generalization ability of the model. The advantage of the Conv module is that it can not only effectively extract low-level and mid-level features of the image, but also maintain image integrity and improve model performance. In the convolution layer of the Conv module, different kernel sizes and strides are used to adapt to target detection tasks of different sizes and complexities. At the same time, in order to further improve the performance and accuracy of the model, the Conv module also uses batch normalization and activation function technology, which makes the model converge faster and more stable.
[0068] Furthermore, the C3 module is a residual block consisting of three convolutional layers, which aims to increase the depth and complexity of the model to improve the expressiveness and performance of the model. The C3 module consists of the third convolutional layer, n* Bottlenecks and a residual block. First, the input feature map passes through the first convolutional layer, and the number of channels is reduced to the number of hidden channels. Then the input feature map and the output feature map of the first convolutional layer are concatenated together and sent to a residual block. Finally, the output feature map of the residual block and the input feature map are concatenated again and sent to the third convolutional layer to obtain the final output. In the C3 module, the number of Bottlenecks is determined by n*, which represents the result of multiplying the number value of the C3 layer in the yaml configuration file and the depth_multiple parameter.
[0069] Figure 1 The depth_multiple setting in the yaml configuration file is shown, and its value is set to 0.33. The value of n is determined by the number parameter of the C3 layer in the yaml configuration file, and the number values of each C3 network layer are different.
[0070] Furthermore, the SPP module pools features of different scales in order to better handle objects of different sizes. The SPP module is implemented by connecting a pyramid structure composed of different pooling layers after the convolution layer. This pyramid structure includes three pooling layers of different sizes, namely 5×5, 9×9 and 13×13. The output results of these pooling layers will be connected in series and reduced in dimension through a 1x1 convolution layer to obtain a fixed-size feature vector. Compared with the traditional maximum pooling layer, the advantage of the SPP module is that it can handle objects of different scales, reduce the number of model parameters, and improve the computational efficiency of the model.
[0071] Furthermore, the Transformer Encode structure can simultaneously capture different semantic information in the input sequence through the multi-head self-attention mechanism. Each head can learn different focuses in the input sequence, thereby improving the generalization ability and performance of the model. The parallel calculation of multi-head attention can also improve the computational efficiency of the model.
[0072] The Transformer Encoder structure consists of a series of Encoder layers, each of which contains two main parts: a multi-head self-attention mechanism and a position-wise feed-forward network.
[0073] The multi-head self-attention mechanism allows the model to simultaneously learn different contextual information of the input sequence in different representation subspaces. Specifically, the multi-head self-attention maps the input sequence to multiple query (Q), key (K), and value (V) vectors, and then captures the dependencies in the sequence by calculating the dot product attention scores between Q and K. These attention scores are then multiplied with the V vector to obtain the output sequence. The output of the multi-head self-attention mechanism is combined through a linear layer to obtain a new representation. Its expression is:
[0074]
[0075] The calculation method of each Attention is:
[0076]
[0077] In the formula, considering the stability of the gradient, the similarity score between Q and K after calculation is normalized, that is, divided by
[0078] Position-wise Feed-Forward Network: It consists of two linear layers and an activation function to learn nonlinear representations of the input sequence in a local scope.
[0079] Transformer Encoder is a structure from Vision Transformer (ViT). ViT is a Transformer-based method that applies Transformer to the image field and uses a neural network model with multi-head self-attention for image classification. For the YOLOv5 model, this structure can enhance the model's visual expression ability for construction waste, while considering both global information and focusing on important information, thereby improving the problem of small target detection.
[0080] By designing the backbone network using the above method, the improvement of the present invention improves the performance of building waste detection, while also reducing the number of parameters and the amount of calculation of the model. The improved backbone network of the present invention is compared with the original YOLOv5, and the detailed comparison results can be seen in Table 1.
[0081] Table 1: Backbone network improvement effect
[0082]
[0083] In the above table, YOLOv5 represents the original network, and T-YOLOv5 represents the model after using the improved backbone network. The improved model reduces the model parameters by 0.44% and the GFLOPs calculation by 14.29%, while improving the model's detection accuracy by 0.8% mAP, and enhancing the model's detection effect for small objects.
[0084] S32: In the original YOLOv5 network, feature maps of different resolutions are first adjusted to the same resolution by upsampling or downsampling, and then Concat is used for feature fusion. This method assumes that input features of different resolutions have the same importance. However, in general, high-resolution feature maps pay more attention to local features and details, while low-resolution feature maps pay more attention to global information because of more pooling operations. Therefore, in the task of construction waste detection, in order for the network to automatically learn the importance of each feature map, the present invention proposes an asymmetric weighted feature fusion Neck network to achieve the fusion of shallow graphic features and deep semantic features. Specifically, in the feature fusion stage, the weights of each feature map information flow of different resolutions are trained through the Fusion-Concat module to enhance the model's ability to learn feature maps of different resolutions, because the contributions of input feature maps of different resolutions in the output are usually unequal. The improved Neck network is shown in the figure. Figure 3 shown.
[0085] Furthermore, in Fusion-Concat, the present invention trains a weight for each fused branch, and the weight calculation method is shown in Formula 3. This improved method enables the model to better utilize the information of each feature map, thereby improving the accuracy and stability of construction waste detection. Through weight training, the model can adaptively select appropriate feature maps and pay more attention to features that are helpful for detecting construction waste.
[0086]
[0087] In Formula 3, the symbol j represents the number of input nodes, and the value of ∈ is set to 0.0001.
[0088] The output of the Fusion-Concat module is represented as:
[0089] Output=Concat(X[0]W[0],X[1],W[1],…,X[i]W[i]) (Formula 4)
[0090] In Formula 4, each W[i]) ranges from 0 to 1, and the sum of the normalized weights of all inputs is 1.
[0091] S33: The detection head network is used to perform multi-scale target detection on the feature map extracted by the Neck network, such as Figure 4 shown.
[0092] Furthermore, the detection head module consists of three detection layers, each of which corresponds to feature maps of different sizes obtained in Neck, so as to detect objects of different sizes. On each feature map, different grid sizes and three preset anchor boxes with different aspect ratios are used to predict and regress the position and size of the object. This design enables the YOLOv5 network structure to effectively detect objects of multiple scales and shapes, thereby improving the performance and robustness of the model. In addition, the detection head module also includes two branches, confidence prediction and category prediction, which are used to determine whether the object exists and classify the object. During the training process, YOLOv5 uses the cross entropy loss function to optimize the parameters of the model to minimize the gap between the predicted results and the true labels. At the same time, the CIoU screening and C-NMS algorithms are used to filter and merge the detection results to obtain the final detection results. These optimization strategies are helpful to improve the detection accuracy and efficiency of YOLOv5, so that it has better application prospects in practical scenarios.
[0093] S34: Use CIoU as the loss metric for target box coordinate regression. Its calculation method is shown in the following formula (5-7), where ρ 2 (b,b gt ) represent the Euclidean distance between the center point of the predicted bounding box and the center point of the actual bounding box. 2 It represents the diagonal length of the minimum enclosed area that can contain both the predicted bounding box and the actual bounding box, and w and h represent the width and height of the bounding box.
[0094]
[0095] in,
[0096]
[0097] in,
[0098]
[0099] Furthermore, the CIoU_Loss calculation is as follows:
[0100] Loss CIoU =1-CIoU
[0101] Figure 6 The improved YOLOv5 model architecture is presented.
[0102] Step 4: Use the labeled construction waste detection dataset to train the model, which specifically includes the following steps:
[0103] S41: Application of pre-trained models.
[0104] Furthermore, the pre-trained model is used for fine-tuning to make the model better suited to detection tasks in different scenarios. First, the model trained based on the COCO dataset is used as the pre-trained model. Then, on this basis, the self-made construction waste detection dataset is added for training, and the model parameters are adjusted to optimize the performance.
[0105] S42: Image preprocessing.
[0106] Furthermore, the image is read, that is, the image data is read from the file and converted into a digital matrix.
[0107] Furthermore, scaling and padding means that in order to adapt to the model input size, the input image needs to be scaled to a specified size. At the same time, in order to maintain the aspect ratio of the image, black or other colored pixels are filled around the scaled image.
[0108] Furthermore, data enhancement is to increase the diversity of training samples by applying various data enhancement techniques (such as flipping, rotation, cropping, brightness and contrast adjustment, etc.). Figure 5 Demonstrates the effect of using data augmentation technology on the construction waste image model.
[0109] Furthermore, image normalization, that is, normalizing the image data to a fixed range (between 0 and 1), controls the numerical range of the model parameters.
[0110] Furthermore, the data format is converted, that is, the preprocessed image data is converted into the data format required by the model (such as tensor or array, etc.) to facilitate the model to perform calculations.
[0111] Furthermore, batch processing, that is, combining multiple pre-processed images into a batch as input for model training or inference, is used to improve model computational efficiency.
[0112] S43: Model training
[0113] The present invention selects YOLOv5s as the detection model according to the real-time and easy deployment requirements and computing resources of construction waste sorting, and improves the model in step 3 on this basis.
[0114] Furthermore, the stochastic gradient descent algorithm is selected as the optimization algorithm to minimize the loss function and thus optimize the parameters of the model.
[0115] Furthermore, the model training parameters are set, the learning rate is set to 0.002, the momentum term coefficient is set to 0.937, the weight decay coefficient is set to 0.0005, the batch size is set to 8, and the training rounds are set to 150.
[0116] Furthermore, we used GPU for model training. We accelerated the model training process by specifying the --device parameter at the beginning of training. The training took a total of 18 hours and 30 minutes.
[0117] Step 5: Use the trained YOLO model to detect construction waste in actual working conditions, including the following steps:
[0118] S51: Select the best model for prediction among the models trained in step 4. After the YOLOv5 model is trained, two model weight files, best.pt and last.pt, are generated.
[0119] During the training process, the best.pt weight file stores the model parameters with the best performance on the validation set. That is, when the highest mAP (average precision) is obtained on the validation set, the current model weights are saved as best.pt.
[0120] The last.pt weight file stores the model parameters of the last iteration in the training process, which represents the latest model status, but may not be the optimal model.
[0121] In this design, we choose best.pt as the weight file for model detection because it has the best performance on the validation set.
[0122] S52: Preprocess the input image to meet the input size and format requirements of the YOLOv5 model. Preprocessing includes scaling, padding, and normalization. The preprocessed input image has a size of 640x640, 3 channels, and a pixel value range between 0 and 1.
[0123] S53: Model prediction output results Further, the preprocessed image is input into the YOLOv5 model. The model consists of a series of convolutional layers, batch normalization layers, activation function layers, etc. These layers gradually extract image features from shallow to deep layers and generate multiple feature maps.
[0124] Furthermore, the YOLOv5 model uses feature pyramid technology to fuse feature maps of different scales, which helps to detect objects of different sizes simultaneously.
[0125] Furthermore, the YOLOv5 model generates predictions, including target categories, confidence levels, and bounding box coordinates. The model predicts each preset anchor box and maps the predictions back to the original image space.
[0126] Furthermore, in the prediction results, there may be multiple overlapping bounding boxes pointing to the same target. The C-NMS algorithm designed by the present invention can screen out the most representative bounding boxes and eliminate redundant detection results.
[0127] In the object detection task, the same object is usually detected by multiple bounding boxes, and these bounding boxes often have overlapping parts. The goal of C-NMS is to select an optimal bounding box from these overlapping bounding boxes, which has the highest confidence and the smallest overlap with other bounding boxes.
[0128] The specific operation process of the C-NMS algorithm is as follows:
[0129] Based on the model prediction results, each detection box is assigned a confidence score (probability value of the target category).
[0130] Sort the candidate bounding boxes from high to low according to the confidence scores and generate a candidate bounding box list bbox_list.
[0131] Initialize an empty list of final bounding boxes (final_boxes).
[0132] When the candidate bounding box list is not empty, repeat the following steps:
[0133] a: Select the bounding box with the highest confidence from the candidate bounding box list, add it to the final_boxes list, and remove the candidate bounding box from the bbox_list list.
[0134] b: Calculate the CIoU value between the current highest confidence candidate bounding box and all other candidate bounding boxes.
[0135] The calculation method of CIoU is shown in Equation 5. IoU is used to measure the overlap between the predicted bounding box and the true bounding box. Given two bounding boxes B1 and B2, their IoU is defined as their intersection area divided by their union area:
[0136]
[0137] c: Update the confidence score of the candidate detection box based on the calculated CIoU value. The calculation method is:
[0138]
[0139] Among them, s i Represents the detection box b i The classification confidence score, M represents the detection box with the highest score, N t Represents the CIoU threshold, which is equal to 0.5.
[0140] When the candidate detection box list is empty, the algorithm ends and the detection boxes in the final_boxes list are used as the final output.
[0141] In this way, C-NMS suppresses overlapping bounding boxes while retaining high-confidence bounding boxes, effectively reducing the number of duplicate detections and thus improving the accuracy of construction waste detection.
[0142] Furthermore, the detection results are filtered by setting a confidence threshold to reduce false detections. The detection results are filtered by applying a preset confidence threshold to the detection results, and only the detection results with a confidence higher than the threshold are retained.
[0143] Furthermore, the output results, that is, the model outputs the detection results after C-NMS and confidence filtering. These results include target category, bounding box coordinates, and confidence.
[0144] In view of the problem that the proportion of small targets in construction waste is high and the model detection effect needs to be improved, we optimized the YOLOv5 network. Specifically, the present invention designs a multi-head self-attention mechanism backbone network based on the Transformer Encoder structure, which is composed of Focus, Conv, C3, SPP and Transformer Encoder structures, so as to improve the model's ability to capture the characteristics of construction waste. In addition, the present invention also designs an asymmetric weighted feature fusion Neck network to enhance the model's ability to learn feature maps of different resolutions. By adopting the Fusion-Concat module, training weights are assigned to each node, so that the model can learn the importance of feature maps of different resolutions, thereby further improving the model performance. At the same time, the present invention also designs a nonlinear non-maximum suppression algorithm C-NMS based on CIoU to enhance the model's ability to screen detection frames in the post-processing stage. In order to evaluate the detection performance of the model, we also created a construction waste detection data set and annotated it in detail. After experimental comparison of the network before and after optimization, the results show that the detection performance of the optimized network reached 98.4% mAP, which is 1.1 percentage points higher than that of the network before optimization.
[0145] This paper describes the core concept and innovation of the present invention. By adopting the algorithm proposed in the present invention, we have reduced the number of network parameters and the amount of calculation, and improved the detection ability of the model. This effectively enhances the model's recognition performance for small objects and ensures that the improved model has a high accuracy rate when identifying construction waste of different sizes.
[0146] Figure 7 The detection results of the improved YOLOv5 model are shown. The left side is the original image and annotation information, while the right side is the prediction result of the optimized model. It can be observed that the model performs well in identifying construction waste of different shapes and sizes. Even in complex environments, the optimized model can still accurately detect construction waste in the image.
[0147] In the task of sorting construction waste, by using the improved algorithm of the present invention, construction waste on the conveyor belt in motion can be quickly and accurately identified. This is of great significance for improving resource recovery rate, reducing environmental pollution and promoting sustainable development. The algorithm designed by the present invention has the following advantages:
[0148] High accuracy: By improving the convolutional neural network structure of YOLOv5, the present invention can more accurately detect and identify various types of construction waste, especially the detection ability of small objects is effectively improved.
[0149] Real-time: Compared with traditional target detection algorithms, the YOLOv5 algorithm has higher real-time performance and can meet the real-time needs of construction waste detection.
[0150] Adaptability: By using the feature pyramid network to fuse multi-scale features, the detection algorithm of the present invention can adapt to construction waste objects of different sizes and has strong adaptability.
[0151] Automation: The present invention provides an automated method for detecting and classifying construction waste, which has higher efficiency and accuracy compared to traditional manual operations, and is conducive to the effective management and resource utilization of construction waste.
[0152] In summary, the present invention provides a construction waste detection algorithm based on improved YOLOv5, which can effectively detect and classify various types of construction waste with high real-time and accuracy. It has important application value in construction waste management and resource utilization.
[0153] Through the practical application of the present invention, the following assistance can be provided to construction waste treatment plants:
[0154] Improve the efficiency of construction waste classification: The construction waste detection algorithm based on the improved YOLOv5 can realize automatic construction waste detection and classification. Compared with the traditional manual classification method, it can greatly improve the efficiency of construction waste classification and reduce labor costs.
[0155] Reducing misclassification and missed detection: The detection algorithm of the present invention has higher accuracy. Compared with the YOLOv5 network, it can effectively reduce misclassification and missed detection, thereby improving the accuracy of construction waste classification and providing better quality raw materials for subsequent resource utilization.
[0156] Assisting environmental supervision: Through real-time detection of construction waste, it can provide data support for environmental supervision departments, help to promptly discover and deal with illegal construction waste dumping and protect the environment.
[0157] Promote the resource utilization of construction waste: Accurate detection and classification of construction waste can help improve the effect of resource utilization of construction waste, reduce the demand for new construction materials, and reduce environmental pollution.
[0158] In order to make the construction waste detection algorithm of the present invention play a greater role in practical applications, it is recommended to take the following measures:
[0159] The detection algorithms are updated and optimized regularly to adapt to the ever-changing types and characteristics of construction waste and ensure detection accuracy.
[0160] Combine existing cameras and sensor equipment to build a complete construction waste detection system to achieve comprehensive monitoring and real-time analysis.
[0161] Cooperate with other intelligent equipment in the construction waste treatment plant to achieve end-to-end automated construction waste classification, treatment and resource utilization.
[0162] Cooperate with governments, enterprises and research institutions to jointly promote the development of construction waste detection technology and provide technical support for achieving green building and environmental protection development goals.
[0163] In summary, the present invention provides a construction waste detection algorithm based on improved YOLOv5, which has high accuracy and real-time performance, and can provide strong technical support for construction waste treatment plants. Through the promotion and application of the present invention, it is expected to promote the improvement of construction waste management and resource utilization, and contribute to environmental protection and sustainable development.
[0164] Improve public environmental awareness: Through the publicity and promotion of the present invention, the public's attention to construction waste treatment and environmental protection can be increased, and the importance of construction waste management and resource utilization in all sectors of society can be further enhanced.
[0165] Future-oriented research: The construction waste detection algorithm of the present invention can provide a data basis for future research and lay the foundation for the research and development of new construction waste treatment technologies.
[0166] Intelligent construction waste treatment platform: The present invention is combined with cloud computing, big data and other technologies to build an intelligent construction waste treatment platform to realize functions such as remote monitoring, intelligent early warning, and automatic scheduling, thereby improving the efficiency and level of construction waste treatment.
[0167] Policy support and standard setting: strive for government policy support to promote the widespread application of this invention in the construction waste treatment industry; participate in the formulation of relevant standards to promote the standardization and standardization of construction waste detection technology.
[0168] Through the implementation of the above measures, the construction waste detection algorithm of the present invention will play a greater role in practical applications, promote technological innovation and green development in the construction waste treatment industry, and provide strong support for building a beautiful home and achieving sustainable development goals.
[0169] The above is only a preferred embodiment of the present invention and does not limit the present invention in any way. Any technician in the relevant technical field, without departing from the scope of the technical solution of the present invention, makes any form of equivalent replacement or modification to the technical solution and technical content disclosed in the present invention, which does not depart from the content of the technical solution of the present invention and still falls within the protection scope of the present invention.
Claims
1. A construction waste detection method based on an improved YOLOv5 model, characterized in that: The following steps are involved: Step 1: Use a 2D camera to shoot the moving construction waste to obtain a construction waste dataset; Step 2: Label the collected construction waste images, and use the labeled construction waste dataset as model training sample data; Step 3: Design an improved YOLOv5 model and optimize it specifically for the construction waste detection scenario to improve the detection performance; S31: Build an improved YOLOv5 model backbone network by using Focus, Conv, C3, SPP and Transformer Encoder structures; S32: Design an asymmetric weighted feature fusion Neck network to enhance the model's learning ability on feature maps of different resolutions; In the feature fusion stage, the Fusion-Concat module is used to train the weights of each feature map information stream with different resolutions. The weight calculation of each information stream is expressed as follows: Among them, the symbol j represents the number of input nodes, and the ∈ value is set to 0.0001; The output after feature fusion is expressed as: Output=Concat(X[0]W[0],X[1],W[1],...,X[i]W[i]) Among them, each W[i]) ranges from 0 to 1, and the sum of the normalized weights of all inputs is 1; S33: Design a CIoU-based nonlinear non-maximum suppression algorithm (C-NMS) to enhance the model's ability to filter detection boxes in the post-processing stage; the expression is as follows: Among them, s i Represents the detection box b i The classification confidence score, M represents the detection box with the highest score, N t Represents the threshold of the non-maximum suppression algorithm. Step 4: Use the labeled construction waste detection dataset to train the optimized YOLOv5 model so that the model can learn and identify various types of construction waste; Step 5: Apply the trained YOLOv5 model to construction waste detection in actual working scenarios to achieve automatic identification and positioning of construction waste.
2. The construction waste detection method based on the improved YOLOv5 model according to claim 1 is characterized in that: In step 1, obtaining the garbage dataset includes the following methods: Install the camera: Install a fixed 2D camera with high resolution and fast shooting capability above the construction waste conveyor belt to capture clear images of the construction waste; Light source setting: Set up a suitable LED light source in the shooting area to ensure that the light is evenly distributed in the shooting area to ensure image quality; Real-time shooting: During the shooting process, the construction waste moves on the conveyor belt at a certain speed, and the camera quickly focuses and captures clear images to complete the shooting; Image storage: The processed images of the captured construction waste are usually stored in a cloud server.
3. The construction waste detection method based on the improved YOLOv5 model according to claim 1 is characterized in that: In step 2, the following steps are included: S21: labeling the collected construction waste images, using the labeling tool to draw the smallest rectangular frame around the construction waste target in the image, and assigning the corresponding category to it; during the labeling process, ensure that the rectangular frame fits the target object tightly and the category labeling is accurate; after the labeling is completed, generate the labeling information into an XML format data file for use in subsequent model training; S22: Generate a TXT format file suitable for the YOLO model using the XML file; the TXT file contains target category information and normalized target rectangular frame coordinate data; through conversion, ensure that the YOLO model can correctly parse these data and accurately learn the target category and its corresponding bounding box position information during training.
4. The construction waste detection method based on the improved YOLOv5 model according to claim 1 is characterized in that: The step 4 includes the following steps: Application of pre-trained models: First, use the model trained based on the COCO dataset as the pre-trained model; then, on this basis, add the construction waste detection dataset for training, and adjust the model parameters to optimize the performance; Image preprocessing: Read image: read image data from the file and convert it into a digital matrix; Scaling and padding: In order to adapt to the model input size, the input image needs to be scaled to the specified size; at the same time, in order to maintain the aspect ratio of the image, black or other colored pixels are filled around the scaled image; Data augmentation: Increase the diversity of training samples by applying a variety of data augmentation techniques; Normalization: Normalize the image data to a fixed range to control the numerical range of the model parameters; Convert data format: convert the preprocessed image data into the data format required by the model to facilitate model calculation; Batch processing: Combine multiple preprocessed images into a batch as input for model training or inference; improve model computational efficiency. Model training.
5. The construction waste detection method based on the improved YOLOv5 model according to claim 1 is characterized in that: In step 5, the construction waste image is predicted by the model trained in step 4; in the prediction process, the input image is first scaled, padded, and normalized to meet the input size and format requirements of the model; then, the trained model is used to predict the target in the image; In the prediction stage, a nonlinear non-maximum suppression algorithm based on CIoU is used to suppress redundant prediction boxes, and the final detection results are screened out according to the confidence and the set threshold; finally, the model outputs the predicted results to complete the detection task of construction waste images.
Citation Information
Patent Citations
Household garbage real-time detection method and device, electronic equipment and medium
CN114492658A
Garbage detection method in complex scene based on improved YOLOv8 model
CN117710771A
Cited By
Garbage classification putting behavior identification method and system based on AI algorithm
CN119049133A
Method for intelligent sorting, detection, and recognition of construction waste
US12810592B2
Method for intelligent sorting, detection, and recognition of construction waste
US20250363780A1
