Belt tearing detection method, system and equipment based on YOLOv5s and medium
By introducing adaptive image scaling, Focus module, CSP module, SPP and PAN structure, as well as CIoU_loss function and NMS algorithm into YOLOv5, the problem of low detection accuracy in the existing technology is solved, and efficient and accurate belt tearing is achieved detection.
Patent Information
- Application Number
- CN202410709094.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-03
- Publication Date
- 2024-09-06
AI Technical Summary
The existing belt tear detection method based on YOLOv5 cannot achieve adaptive image scaling, image segmentation, feature map compression and fusion, and cannot perform accurate bounding box similarity calculation when the bounding box is rotated or distorted, resulting in low detection accuracy. .
Use the adaptive image scaling technology (Letterbox) module and Focus module for image preprocessing, replace the ordinary convolution block in ResNet53 with the CSP module, add the spatial pyramid pooling layer (SPP) and the path aggregation network (PAN) structure, and use The CIoU_loss function is used as the loss function, and the non-maximum suppression (NMS) algorithm is added for post-processing.
It improves the adaptability and feature extraction capabilities of images, reduces the amount of calculation and memory consumption, enables accurate bounding box detection when the bounding box is rotated or distorted, and improves detection accuracy and generalization capabilities.
Smart Images

Figure CN118608767A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of conveyor belt detection, and in particular to a belt tear detection method, system, equipment and medium based on YOLOv5s. Background Art
[0002] With the improvement of specialization and mechanization of coal mining in my country, the efficiency of coal mining industry in mining and transportation has been improved to a certain extent. The use of belt conveyors can increase transportation speed and improve transportation efficiency. Belt conveyors play an important role in the coal transportation process of coal mining industry. Coal mine belt conveyors have the advantages of large conveying capacity, convenient and fast operation, continuous conveying, and safe conveying process. It can not only improve transportation efficiency, but also reduce the waste of resources caused by human transportation.
[0003] Although the belt conveyor has an outstanding ability to transport materials over long distances, foreign matter on the conveyor belt will restrict the normal operation of the belt conveyor. Foreign matter will cause the conveyor belt to tear, abnormal wear and other problems. If the belt tear is not handled in time, it will lead to the interruption of raw coal transportation or safety accidents. Therefore, it is extremely important to monitor the abnormalities in the belt conveyor in time during the coal transportation process.
[0004] The Chinese patent application with publication number CN116002319A provides a belt tear and service life detection method based on improved YOLOv5, including the following steps: collecting data of the entire belt at different time intervals through a camera device to collect belt pictures; marking the abnormal state and service life of the belt pictures, and saving each marked picture into a txt file to form a database; dividing the txt files in the database into a training set and a test set at a ratio of 7:3, training using the YOLOv5s network structure to obtain a belt detection model; performing real-time detection of the on-site belt based on the belt detection model, displaying the real-time picture of the belt operation on the display terminal, and performing abnormal alarms and abnormal position marking. However, since the invention requires the illumination of the tool light source, the tear is judged by reflection, and the network architecture of YOLOv5s is not modified, the image adaptive scaling capability and image segmentation cannot be completed, the feature map is lacking in compression and fusion, and the bounding box similarity calculation cannot be performed when the bounding box is rotated or distorted. Summary of the invention
[0005] In order to overcome the shortcomings of the above-mentioned prior art, the purpose of the present invention is to provide a belt tear detection method, system, device and medium based on YOLOv5s, adopt an adaptive image scaling technology (Letterbox) module and a Focus module to achieve image scaling and slicing processing, replace the ordinary convolution block in ResNet53 with a CSP module, add SPP and PAN structures, and use the CIoU_loss function as the main loss function, so as to extract image features, compress and fuse feature maps, and calculate the similarity between the bounding box and the real bounding box when the bounding box is rotated or distorted.
[0006] In order to achieve the above object, the technical solution adopted by the present invention is:
[0007] A belt tear detection method based on YOLOv5s, comprising the following steps:
[0008] Step 1, collecting the belt working video by means of a camera device, performing frame extraction processing, and obtaining a belt tearing image;
[0009] Step 2, annotate the torn belt image obtained in step 1, save the annotated information into a txt text file, form a data pair with the torn belt image, and put it into the database;
[0010] Step 3: Use the adaptive image scaling technology (Letterbox) module and the Focus module to preprocess the data pairs in the database of step 2, and use the YOLOv5s network structure to train the preprocessed data pairs to form a belt detection model.
[0011] The labeling of the torn belt image described in step 2 specifically includes using labelimg software to label the collected torn belt image, labeling the abnormal parts in the torn belt image with a target box, and saving the coordinates of the upper left vertex and the lower right vertex of the target box in a txt file.
[0012] The step 3 uses the adaptive image scaling technology (Letterbox) module to pre-process the data pair, specifically: applying the adaptive image scaling technology (Letterbox) module to the input processing part of the YOLOv5s network structure to scale the image;
[0013] The use of the Focus module to preprocess the data pair described in step 3 is specifically as follows: the Focus module is applied to the input processing part of the YOLOv5s network structure to slice the belt torn image.
[0014] The training process described in step 3 is:
[0015] Step 3.1: Use CSPResNet53 in the YOLOv5s network structure, which can efficiently extract features, as the Backbone part, and use the CSP module to replace the ordinary convolution block in ResNet53 to extract image features;
[0016] Step 3.2: Design the Neck part, connect the Backbone and Head parts of step 3.1, add the spatial pyramid pooling layer (SPP) and path aggregation network (PAN) structure to the last few convolutional layers of the Backbone part, realize feature map compression and fusion, and pass the processed feature map to the Head part to improve some performance;
[0017] Step 3.3: Design the Head part connected in step 3.2, including a classifier and a regressor, to classify and detect the feature maps received from the Neck part, use the non-maximum suppression (NMS) algorithm to eliminate redundant windows, find the best object detection position, and finally form a complete belt detection model.
[0018] The classification and detection described in step 3.3 are specifically as follows: the CIoU_loss function is used as the loss function instead of the IoU_loss function. When the bounding box is rotated or distorted, the similarity between the bounding box and the true bounding box is calculated. The mathematical expression of the CIoU_loss function is as follows:
[0019]
[0020] In the formula, IoU represents the intersection over union ratio of the target prediction box and the true bounding box; α is a parameter that controls the weight of the penalty term; V is a term used to penalize inconsistent aspect ratios; h gt and w gt is the height and width of the true bounding box, h and w are the height and width of the predicted bounding box; p is the distance between the center points of the two boxes; c is the diagonal distance between the two boxes.
[0021] After the CIoU_loss function replaces the IoU_loss function, the non-maximum suppression (NMS) algorithm is added to the post-processing stage in the YOLOv5s network structure.
[0022] The classification and detection described in step 3.3 is specifically to add the non-maximum suppression (NMS) algorithm to the post-processing stage in the YOLOv5s network structure.
[0023] A system for detecting a belt tearing state based on YOLOv5s technology, comprising:
[0024] Image acquisition module: collects belt working video through camera equipment, performs frame extraction processing, and obtains belt tearing image;
[0025] Tear Annotation Module: Annotate the torn belt image, save the annotated information into a txt text file, form a data pair with the torn belt image, and put it into the database;
[0026] Detection module: Use the adaptive image scaling technology (Letterbox) module and the Focus module to preprocess the data pairs in the database, and use the YOLOv5s network structure to train the preprocessed data pairs to form a belt detection model.
[0027] A belt tearing state detection device based on YOLOv5s technology, comprising:
[0028] Memory: used to store a computer program for implementing the belt tearing state detection method based on YOLOv5s technology;
[0029] Processor: used to implement the belt tearing state detection method based on YOLOv5s technology when executing the computer program.
[0030] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of a belt tear state detection method based on YOLOv5s technology are implemented.
[0031] Compared with the prior art, the beneficial effects of the present invention are:
[0032] 1. The present invention adopts an adaptive image scaling technology (Letterbox) module, which can scale the input image and effectively adapt to inputs of pixels of various sizes, making it more universal;
[0033] 2. The present invention adopts the Focus module, which can slice the belt tearing image and enhance the capture of image features;
[0034] 3. The present invention replaces the common convolution block in ResNet53 with the CSP module, which can extract the characteristics of image features and reduce the amount of parameter calculation;
[0035] 4. The present invention adds SPP and PAN structures, which can compress and fuse feature maps, reduce the dimension and size of feature maps, and reduce the amount of calculation and memory consumption;
[0036] 5. The present invention uses the CIoU_loss function as the main loss function, which can calculate the similarity between the bounding box and the true bounding box when the bounding box is rotated or distorted, and can more accurately measure the difference between the predicted bounding box and the true bounding box.
[0037] 6. The present invention adds the non-maximum suppression (NMS) algorithm to the post-processing stage in the YOLOv5s network structure, which can eliminate redundant windows and find the optimal object detection position, and has the characteristics of efficient post-processing.
[0038] In summary, the present invention has strong generalization ability, is adaptable to input images of any size, improves work efficiency, reduces computer computing power consumption, and has the characteristics of high accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0039] Figure 1 The figure is a flow chart of the belt tear detection method of the present invention.
[0040] Figure 2 This is a result diagram of target detection using an improved model in an embodiment of the present invention.
[0041] Figure 3 The Precision-Recall (PR) curve of the training model according to the embodiment of the present invention. DETAILED DESCRIPTION
[0042] The present invention will be described in detail below in conjunction with the accompanying drawings.
[0043] like Figure 1 As shown, a belt tearing detection method based on YOLOv5s includes the following steps:
[0044] Step 1, collecting the belt working video by means of a camera device, performing frame extraction processing, and obtaining the belt tearing image;
[0045] Step 2: Use labelimg software to annotate the torn belt image obtained in step 1 with tear features, and save the annotated information into a txt file. The txt file saves the coordinates of the upper left vertex and the lower right vertex of the target box. The txt file and the torn belt image together form a data pair and are put into the database;
[0046] Step 3: Use the adaptive image scaling technology (Letterbox) module and the Focus module to preprocess the data pairs in the database of step 2, and use the YOLOv5s network structure to train the preprocessed data pairs to form a belt detection model.
[0047] During training, the computer hardware configuration uses Intel Core i5-13600kf CPU and NVDIA GeForce RTX3060ti GPU. The training parameters are set to the default 300 epochs, the batch size is automatically adjusted, and the training time is 0.5 hours. After the training, the obtained training model file with the suffix .pt is placed in the detect.py detection file.
[0048] The labeling of the torn belt image described in step 2 specifically includes using labelimg software to label the collected torn belt image, labeling the abnormal parts in the torn belt image with a target box, and saving the coordinates of the upper left vertex and the lower right vertex of the target box in a txt file.
[0049] Step 3 uses the adaptive image scaling technology (Letterbox) module to preprocess the data pair as follows: Apply the adaptive image scaling technology (Letterbox) module to the input processing part of the YOLOv5s network structure, and apply it in the data preprocessing stage: adjust the input images of different sizes to the input size expected by the model to obtain the image size desired by the model. In the data loading and preprocessing stage, load the original image and obtain its original width and height, calculate the ratio of width to height, select the scaling factor and the horizontal and vertical padding to fill the four sides of the image.
[0050] The use of the Focus module to preprocess the data pair described in step 3 is as follows: Apply the Focus module to the input processing part of the YOLOv5s network structure, slice the belt tear image to improve the computational efficiency of the model: Apply the Focus module to the YOLOv5s network structure, apply it in the data preprocessing stage, divide the input feature map into four smaller sub-maps, and then stack these four sub-maps together. This helps capture local information in the image without having to perform convolution operations on the entire feature map. The specific process is: The size of the input feature map is: (C, H, W), where C represents the number of channels, H represents the height, and W represents the width. Divide the input feature map into four sub-maps, usually evenly divided in the horizontal and vertical directions. This will generate four sub-maps, each of which has a size of (C / 4, H / 2, W / 2). Apply a convolution operation to each sub-map. Typically, the Focus module uses lightweight convolutions, such as depth-separable convolutions, to process these sub-maps. The purpose of convolution is to extract feature information in the sub-maps. The outputs of the four sub-maps are stacked together to generate the final output feature map. This will generate a feature map with the same dimensions (C, H, W) as the original input feature map. The key advantage of the Focus module is that it can reduce the computational complexity while still retaining the important feature information of the image. This technique helps speed up the inference process of the model, especially when processing large-sized images.
[0051] The training process described in step 3 is:
[0052] Step 3.1: Use CSPResNet53 in the YOLOv5s network structure, which can efficiently extract features, as the Backbone part, and use the CSP module to replace the ordinary convolution block in ResNet53 to extract image features;
[0053] Step 3.2: Design the Neck part, connect the Backbone and Head parts of step 3.1, add the spatial pyramid pooling layer (SPP) and path aggregation network (PAN) structure to the last few convolutional layers of the Backbone part, realize feature map compression and fusion, and pass the processed feature map to the Head part to improve some performance;
[0054] Step 3.3: Design the Head part connected in step 3.2, including the classifier and regressor, to classify and detect the feature maps received from the Neck part, use the non-maximum suppression (NMS) algorithm to eliminate redundant windows, find the best object detection position, and finally form a complete belt detection model, such as Figure 2 shown.
[0055] The classification and detection described in step 3.3 are specifically as follows: the CIoU_loss function is used as the loss function instead of the IoU_loss function. When the bounding box is rotated or distorted, the similarity between the bounding box and the true bounding box is calculated. The mathematical expression of the CIoU_loss function is as follows:
[0056]
[0057] In the formula, IoU represents the intersection over union ratio of the target prediction box and the true bounding box; α is a parameter that controls the weight of the penalty term; V is a term used to penalize inconsistent aspect ratios; h gt and w gt is the height and width of the true bounding box, h and w are the height and width of the predicted bounding box; p is the distance between the center points of the two boxes; c is the diagonal distance between the two boxes.
[0058] After the CIoU_loss function replaces the IoU_loss function, the non-maximum suppression (NMS) algorithm is added to the post-processing stage in the YOLOv5s network structure.
[0059] The classification and detection described in step 3.3 is specifically to add the non-maximum suppression (NMS) algorithm to the post-processing stage in the YOLOv5s network structure.
[0060] The main purpose of the NMS algorithm is to eliminate redundant windows and find the best object detection position. Because the shapes and sizes of the targets in the image may be various, in order to better detect these targets in the image, a large number of candidate bounding boxes with different lengths and widths are usually designed to be generated. However, for an object detection task, the ideal situation is one, so the goal is to output only one most accurate bounding box. Before using non-maximum suppression (NMS), thousands of target boxes will be generated. These boxes have corresponding classification confidences. When the confidence meets the positive sample condition, it is sent to non-maximum suppression (NMS). After adding non-maximum suppression (NMS), several target boxes will be generated.
[0061] See also Figure 3 , the model is tested through the test set to obtain the Precision-Recall (PR) curve of the trained model. The PR curve is usually used to evaluate the performance of the model because the PR curve can more comprehensively reflect the performance of the model under different precision and recall rates. Among them, the horizontal axis is the recall rate (Recall) and the vertical axis is the precision rate (Precision). By drawing the PR curve and calculating the area under the PR curve (PR AUC), you can intuitively understand the performance of the model under different thresholds and compare and evaluate the model performance.
[0062] Depend on Figure 2 , Figure 3 It can be seen that by improving YOLOv5, the belt tear detection accuracy of the present invention is high, and the mean average precision (mAP) under the intersection over union (IoU) of 0.5 reaches 0.995, which has very high detection accuracy and can accurately detect the tearing in the belt, such as Figure 2 As shown, when a tear occurs, the present invention can accurately detect the tear location.
[0063] A system for detecting a belt tearing state based on YOLOv5s technology, comprising:
[0064] Image acquisition module: collects belt working video through camera equipment, performs frame extraction processing, and obtains belt tearing image, which is used to implement step 1 of a belt tearing state detection method based on YOLOv5s technology;
[0065] Tear Annotation Module: annotate the torn belt image, save the annotated information into a txt text file, form a data pair with the torn belt image, and put it into the database to implement step 2 of a torn belt state detection method based on YOLOv5s technology;
[0066] Detection module: Use the adaptive image scaling technology (Letterbox) module and the Focus module to preprocess the data pairs in the database, and use the YOLOv5s network structure to train the preprocessed data pairs to form a belt detection model, which is used to implement step 3 of a belt tear state detection method based on YOLOv5s technology.
[0067] A belt tearing state detection device based on YOLOv5s technology, comprising:
[0068] Memory: used to store a computer program for implementing the belt tearing state detection method based on YOLOv5s technology;
[0069] Processor: used to implement the belt tearing state detection method based on YOLOv5s technology when executing the computer program.
[0070] The present invention also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the steps of the belt tear state detection method based on YOLOv5s technology are implemented.
Claims
1. A belt tear detection method based on YOLOv5s, characterized in that: The following steps are involved: Step 1, collecting the belt working video by means of a camera device, performing frame extraction processing, and obtaining the belt tearing image; Step 2, annotate the torn belt image obtained in step 1, save the annotated information into a txt text file, form a data pair with the torn belt image, and put it into the database; Step 3: Use the adaptive image scaling technology (Letterbox) module and the Focus module to preprocess the data pairs in the database of step 2, and use the YOLOv5s network structure to train the preprocessed data pairs to form a belt detection model.
2. According to a method for detecting a belt tearing state based on YOLOv5s technology according to claim 1, it is characterized in that: The labeling of the torn belt image described in step 2 specifically includes using labelimg software to label the collected torn belt image, labeling the abnormal parts in the torn belt image with a target box, and saving the coordinates of the upper left vertex and the lower right vertex of the target box in a txt file.
3. The belt tearing state detection method based on YOLOv5s technology according to claim 1 is characterized in that: The step 3 uses the adaptive image scaling technology (Letterbox) module to pre-process the data pair, specifically: applying the adaptive image scaling technology (Letterbox) module to the input processing part of the YOLOv5s network structure to scale the image; The use of the Focus module to preprocess the data pair described in step 3 is specifically as follows: the Focus module is applied to the input processing part of the YOLOv5s network structure to slice the belt torn image.
4. A belt tearing state detection method based on YOLOv5s technology according to claim 1 or 3, characterized in that: The training process described in step 3 is: Step 3.1: Use CSPResNet53 in the YOLOv5s network structure, which can efficiently extract features, as the Backbone part, and use the CSP module to replace the ordinary convolution block in ResNet53 to extract image features; Step 3.2: Design the Neck part, connect the Backbone and Head parts of step 3.1, add the spatial pyramid pooling layer (SPP) and path aggregation network (PAN) structure to the last few convolutional layers of the Backbone part, realize feature map compression and fusion, and pass the processed feature map to the Head part to improve some performance; Step 3.3: Design the Head part connected in step 3.2, including a classifier and a regressor, to classify and detect the feature maps received from the Neck part, use the non-maximum suppression (NMS) algorithm to eliminate redundant windows, find the best object detection position, and finally form a complete belt detection model.
5. The belt tearing state detection method based on YOLOv5s technology according to claim 4 is characterized in that: The classification and detection described in step 3.3 are specifically as follows: the CIoU_loss function is used as the loss function instead of the IoU_loss function. When the bounding box is rotated or distorted, the similarity between the bounding box and the true bounding box is calculated. The mathematical expression of the CIoU_loss function is as follows: In the formula, IoU represents the intersection over union ratio of the target prediction box and the true bounding box; α is a parameter that controls the weight of the penalty term; V is a term used to penalize inconsistent aspect ratios; h gt and w gt is the height and width of the true bounding box, h and w are the height and width of the predicted bounding box; p is the distance between the center points of the two boxes; c is the diagonal distance between the two boxes.
6. The belt tearing state detection method based on YOLOv5s technology according to claim 5 is characterized in that: After the CIoU_loss function replaces the IoU_loss function, the non-maximum suppression (NMS) algorithm is added to the post-processing stage of the YOLOv5s network structure output.
7. The belt tearing state detection method based on YOLOv5s technology according to claim 4 is characterized in that: The classification and detection described in step 3.3 is specifically to add the non-maximum suppression (NMS) algorithm to the post-processing stage of the YOLOv5s network structure output.
8. A system for detecting a belt tearing state based on the YOLOv5s technology according to any one of claims 1 to 7, characterized in that: include: Image acquisition module: collects belt working video through camera equipment, performs frame extraction processing, and obtains belt tearing image; Tear Annotation Module: Annotate the torn belt image, save the annotated information into a txt text file, form a data pair with the torn belt image, and put it into the database; Detection module: Use the adaptive image scaling technology (Letterbox) module and the Focus module to preprocess the data pairs in the database, and use the YOLOv5s network structure to train the preprocessed data pairs to form a belt detection model.
9. A belt tearing state detection device based on YOLOv5s technology, characterized in that: include: Memory: used to store a computer program for implementing a belt tearing state detection method based on YOLOv5s technology as described in any one of claims 1 to 7; Processor: used to implement a belt tearing state detection method based on YOLOv5s technology as described in any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the belt tear state detection method based on YOLOv5s technology are implemented.
Citation Information
Patent Citations
Belt tearing and service life detection method based on improved YOLOv5
CN116002319A
