A method for detecting a road surface crack and a storage medium
By using the MSF-Transformer model for multi-scale feature extraction and location encoding, combined with the prediction layer FFN, the problem of local texture feature loss in the DETR model during pavement crack detection is solved, achieving efficient and accurate pavement crack detection.
Patent Information
- Application Number
- CN202310441866.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-23
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2043-04-23
AI Technical Summary
Existing DETR models tend to lose local texture features in pavement crack detection, resulting in poor detection performance, especially under the influence of lighting and noise.
We employ the deep learning-based MSF algorithm and Transformer model for target detection. Through multi-scale feature extraction, position encoding and decoding, and combined with the prediction layer FFN, we achieve end-to-end crack detection, discarding the anchor prior knowledge and non-maximum suppression steps.
It improves the accuracy and robustness of pavement crack detection, adapts to detection under different sizes and lighting conditions, and simplifies the detection algorithm process.
Smart Images

Figure CN116309536B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of target detection technology, and in particular to a method for detecting road surface cracks and a storage medium. Background Technology
[0002] Detection of cracks in highway pavements has always been a crucial research area for road traffic safety. In recent years, research in deep learning and object detection has propelled the intelligent development of crack detection methods. As the foundation for road health assessment and pavement maintenance measures, crack detection has become a key research focus in fields such as roads, bridges, and tunnels, possessing significant research value and broad application prospects.
[0003] Crack detection not only involves marking cracks on the road surface with appropriate bounding boxes, but also displaying the crack's confidence level and corresponding category. Cracks are categorized into three types: transverse cracks, longitudinal cracks, and repaired cracks. A basic crack includes six dimensions: X and Y coordinates, the width and height of the bounding box, confidence level, and detection category. With the emergence of large-scale datasets, the reduction in computer hardware costs, and the improvement of GPU parallel computing capabilities, deep learning has gradually gained absolute dominance in object detection and crack detection. Object detection based on the DETR network has been studied and used by many scholars. This model eliminates prior knowledge and constraints such as anchors and abandons the post-processing step of non-maximum suppression. The entire network model achieves end-to-end object detection, greatly simplifying the object detection algorithm.
[0004] The classic DETR model mainly consists of four parts: the CNN backbone, the Transformer encoder and decoder, and the final prediction layer FFN. Generally speaking, the network used in the DETR backbone is more suitable for feature extraction and processing of large-sized targets. However, in actual engineering, road cracks are affected by factors such as the acquisition equipment, acquisition distance, crack size, and noise such as lighting and shadows. If the DETR model is used to extract features from road cracks, it is easy to lose the local texture features of the cracks, which will have a certain impact on the training of subsequent network models and the crack detection effect. Summary of the Invention
[0005] This invention proposes a method and storage medium for detecting road surface cracks. It utilizes the MSF algorithm and Transformer model based on deep learning for target detection training and then performs detection on the image to be detected, which greatly simplifies the target detection algorithm.
[0006] This invention provides a method for detecting road surface cracks, comprising the following steps:
[0007] Acquire the image to be detected;
[0008] The image to be detected is input into the MSF-Transformer model, which outputs the optimal prediction box, class label, and confidence score.
[0009] Cracks in the image to be detected are determined based on the optimal prediction bounding box, category label, and confidence score.
[0010] The image to be detected is input into the MSF-Transformer model, which outputs predicted bounding boxes, class labels, and confidence scores, including:
[0011] Multi-scale feature extraction is performed on the image to be detected based on the MSF model to obtain a fused feature map.
[0012] Construct positional codes of the same dimension based on the fused feature maps;
[0013] The fused feature map and positional encoding are encoded and decoded based on the Transformer model to obtain the decoding result.
[0014] The decoding results are predicted based on the prediction layer FFN to obtain the prediction box, class label and confidence score.
[0015] Preferably, the image to be detected needs to be preprocessed before multi-scale feature extraction using the MSF model.
[0016] Preferably, the preprocessing process includes the following steps:
[0017] The size of the image to be detected is reduced to 200×200 DPI;
[0018] The image to be detected after size processing is converted to grayscale and Gaussian noise is added, followed by median filtering;
[0019] The image annotation tool was used to annotate the median-filtered image to be inspected into three categories: transverse cracks, longitudinal cracks, and repaired cracks.
[0020] Preferably, the multi-scale feature extraction of the image to be detected based on the MSF model to obtain the fused feature map includes the following steps:
[0021] The preprocessed image to be detected is input into the CBL module, which consists of convolution, normalization, and activation functions;
[0022] The image to be detected through the CBL module is sequentially input into multiple convolutional layers and residual structures to obtain multiple feature maps of different sizes;
[0023] Upsample multiple feature maps of different sizes into multiple feature maps of the same size;
[0024] Multiple feature maps of the same size are stacked, fused, and convolved to obtain a fused feature map.
[0025] Preferably, the position code is constructed using the following formula:
[0026]
[0027]
[0028] In the formula, PE represents position encoding, pos represents the position of the current pixel in the input feature map, and d model The dimension of the pixel is represented by , and i represents the fused feature map at different locations, where even-numbered locations use sin and odd-numbered locations use cos.
[0029] Preferably, the Transformer model includes a multi-layer encoder and a multi-layer decoder. Each encoder layer includes a multi-head attention layer and a feedforward connection layer, and each decoder layer includes an occlusion multi-head attention layer, a multi-head attention layer, and a feedforward connection layer.
[0030] Preferably, the optimal prediction box is obtained by predicting the decoding result based on the prediction layer FFN, including the following steps:
[0031] The multi-layer decoding results are input to the prediction layer FFN after parameter sharing, resulting in multiple prediction boxes.
[0032] Construct a set of prediction boxes based on multiple prediction boxes, and construct a set of true values;
[0033] The Hungarian algorithm is used for bipartite graph matching. The set of predicted boxes is matched with the set of true values, and the optimal predicted box is selected from multiple predicted boxes.
[0034] Preferably, the Hungarian algorithm is as follows:
[0035]
[0036]
[0037] In the formula, It is the set of optimal allocation results, where σ(i) represents the exponent. The true value element y of road surface cracks i The pairwise matching cost with the exponent σ(i), where c(i) is the target class label and b(i) is a vector. It is the probability of c(i). It is a prediction box, y i This represents the i-th truth element. L represents the set of predicted bounding boxes. boxThis represents the bounding box loss, where N represents the number of prediction sets. Represents a set element.
[0038] Preferably, the Transformer model is trained using a loss function, as shown below:
[0039]
[0040]
[0041] In the formula, y represents the set of truth values of the detected object. This represents the set of prediction boxes. It is C i The logarithmic probability, It was a loss for Hungary, L iou It is the generalized IoU loss, λ iou , λ L1 It's a hyperparameter.
[0042] A computer-readable storage medium storing computer instructions for causing a computer to perform the road surface crack detection method.
[0043] Compared with the prior art, the beneficial effects of the present invention are:
[0044] This invention inputs the acquired two-dimensional image into the MSF algorithm model to obtain feature maps fused from different sizes. This effectively alleviates the difficulty in accurately grasping local texture characteristics and global texture relationships when detecting slender and small feature targets in the field of object detection. At the same time, it adopts a Transformer multi-layer encoder-decoder structure, combined with positional encoding, and abandons prior knowledge constraints such as anchors and post-processing steps such as non-maximum suppression, to achieve end-to-end object detection, which greatly simplifies the object detection algorithm. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a flowchart of a method for detecting road surface cracks according to the present invention;
[0047] Figure 2 This is a model training effect diagram of a road surface crack detection method according to the present invention. Detailed Implementation
[0048] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0049] Reference Figure 1 This invention provides a method for detecting road surface cracks, comprising the following steps:
[0050] Step 1: Use a data acquisition vehicle to collect road surface images to obtain multiple images to be detected.
[0051] Preprocessing of multiple images to be detected includes the following steps:
[0052] (1) The size of multiple images to be detected is processed to 200×200DPI.
[0053] (2) Convert the multiple images to be detected after size processing to grayscale and add Gaussian noise, and then perform median filtering;
[0054] (3) Using the LabelImg image annotation tool, multiple images to be detected after median filtering were labeled according to three categories: transverse cracks, longitudinal cracks, and repaired cracks. The labels were randomly generated according to a training set and a validation set ratio of 0.85:0.15. The MSF-Transformer model was trained using the training set and validated using the validation set.
[0055] Step 2: Input multiple images to be detected into the trained MSF-Transformer model, and output the optimal predicted bounding box, class label, and confidence score. This includes:
[0056] The MSF (Multi-scale fusion) model is used to extract multi-scale features from the image to be detected, resulting in a fused feature map.
[0057] (1) Input the preprocessed image to be detected into the CBL module, which consists of convolution, normalization and activation functions (Conv, BatchNormalization and LeakyReLU), and then prepare to start feature extraction.
[0058] (2) Input the image to be detected through the CBL module into multiple convolutional layers and residual structures to obtain feature maps of 1 / 8, 1 / 16 and 1 / 32 size of the original image. The feature maps of the three sizes are now extracted.
[0059] (3) Multiple feature maps of different sizes are unified into multiple feature maps of the same size by an upsampling method similar to Feature Pyramid (FPN).
[0060] (4) Stack, fuse, and convolve multiple feature maps of the same size to obtain a fused feature map.
[0061] Construct positional codes of the same dimension based on the fused feature maps.
[0062] The positional encoding is constructed using the following formula:
[0063]
[0064]
[0065] In the formula, PE represents position encoding, pos represents the position of the current pixel in the input feature map, and d model The dimension of the pixel is represented by , and i represents the fused feature map at different locations, where even-numbered locations use sin and odd-numbered locations use cos.
[0066] The fused feature map and location encoding are encoded and decoded based on the Transformer model to obtain the decoding result.
[0067] (1) Input multiple fused feature maps and multiple location codes into a multi-layer encoder to obtain the encoding result. Each encoder layer consists of a multi-head attention layer and a feedforward connection layer.
[0068] (2) The encoded result is input into the multi-layer decoder to obtain the decoded result. Each layer decoder consists of a masking multi-head attention layer, a multi-head attention layer, and a feedforward connection layer. Except for the first layer decoder, the other decoders use the output of the previous layer decoder and the output of the multi-layer encoder as input.
[0069] The optimal prediction box, category label, and confidence score are obtained by predicting the decoding results based on the prediction layer FFN.
[0070] (1) The output of each decoder layer is shared and input to the prediction layer FFN for prediction, and the loss function is calculated to achieve deep supervision. The FFN of this invention is calculated by three linear layers with ReLU activation function and hidden layers, so that the normalized center coordinates, height and width of the predicted box can be obtained by using the softmax function to activate and obtain the predicted class label.
[0071] (2) The above operations yield a set of prediction boxes of a fixed size, but this clearly exceeds the actual required number of prediction boxes. Therefore, considering the need for optimal selection of a considerable number of prediction boxes, this invention constructs a set of prediction boxes and a set of ground truth values based on multiple prediction boxes. The number of ground truth values is expanded to be the same as the number of prediction boxes, and an additional special class label is used to represent the background category, so that the predicted values and ground truth values become a set with the same number of elements. At this time, the Hungarian algorithm is used for bipartite graph matching, and the elements of the prediction set and the ground truth set are matched one-to-one to minimize the matching loss.
[0072] The Hungarian algorithm is shown below:
[0073]
[0074]
[0075] In the formula, It is the set of optimal allocation results, where σ(i) represents the exponent. The true value element y of road surface cracks i The pairwise matching cost with the exponent σ(i), where c(i) is the target class label and b(i) is a vector. It is the probability of c(i). It is a prediction box, y i This represents the i-th truth element. L represents the set of predicted bounding boxes. box This represents the bounding box loss, where N represents the number of prediction sets. Represents a set element.
[0076] (3) Calculate the loss function based on the correspondence between the obtained Ground Truth (true value) and the predicted target box;
[0077]
[0078]
[0079] In the formula, y represents the set of truth values of the detected object. This represents the set of prediction boxes. It is C i The logarithmic probability, It was a loss for Hungary, L iou It is the generalized IoU loss, λ iou and λ L1 This is a hyperparameter, normalized by the number of objects in the batch.
[0080] Step 3: Determine the cracks in the image to be detected based on the optimal prediction bounding box, category labels, and confidence scores. The cracks in the image are selected using the prediction bounding box, classified by category labels, and the confidence score of each crack is displayed.
[0081] Reference Figure 2 After 500 epochs of training, it is evident that the loss of the training set and the validation set shows a good trend of oscillation and decline, and the difference between the two is not particularly large. This fully demonstrates that the model has good applicability and sufficient support for the task of detecting cracks in highway pavement.
[0082] This invention also provides a computer-readable storage medium storing computer-executable instructions that can execute the above-described pavement crack detection method.
[0083] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0084] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.
Claims
1. A method for detecting road surface cracks, characterized in that, Includes the following steps: Acquire the image to be detected; The image to be detected is input into the MSF-Transformer model, which outputs the optimal prediction box, class label, and confidence score. The cracks in the image to be detected are determined based on the optimal prediction box, category label, and confidence score. The image to be detected is input into the MSF-Transformer model, which outputs predicted bounding boxes, class labels, and confidence scores, including: Multi-scale feature extraction is performed on the image to be detected based on the MSF model to obtain a fused feature map. Construct positional codes of the same dimension based on the fused feature maps; The fused feature map and positional encoding are encoded and decoded based on the Transformer model to obtain the decoding result. The decoding results are predicted based on the prediction layer FFN to obtain the prediction box, class label and confidence score; The process of extracting multi-scale features from the image to be detected based on the MSF model to obtain a fused feature map includes the following steps: The preprocessed image to be detected is input into the CBL module, which consists of convolution, normalization, and activation functions; The image to be detected through the CBL module is sequentially input into multiple convolutional layers and residual structures to obtain multiple feature maps of different sizes; Upsample multiple feature maps of different sizes into multiple feature maps of the same size; Multiple feature maps of the same size are stacked, fused, and convolved accordingly to obtain a fused feature map. The optimal prediction box is obtained by predicting the decoding results based on the prediction layer FFN, including the following steps: The multi-layer decoding results are input to the prediction layer FFN after parameter sharing, resulting in multiple prediction boxes. Construct a set of prediction boxes based on multiple prediction boxes, and construct a set of true values; The Hungarian algorithm is used for bipartite graph matching. The set of predicted boxes is matched with the set of true values, and the optimal predicted box is selected from multiple predicted boxes.
2. The method for detecting road surface cracks as described in claim 1, characterized in that, Before performing multi-scale feature extraction on the image to be detected using the MSF model, the image needs to be preprocessed.
3. The method for detecting road surface cracks as described in claim 2, characterized in that, The preprocessing process includes the following steps: The size of the image to be detected is reduced to 200×200 DPI; The image to be detected after size processing is converted to grayscale and Gaussian noise is added, followed by median filtering; The image annotation tool was used to annotate the median-filtered image to be inspected into three categories: transverse cracks, longitudinal cracks, and repaired cracks.
4. The method for detecting road surface cracks as described in claim 1, characterized in that, The positional encoding is constructed using the following formula: In the formula, PE Represents position code, pos This indicates the position of the current pixel in the input feature map. d model This indicates the dimension of the pixel. i This represents the fused feature map at different locations, where even-numbered locations use... sin Odd positions use cos .
5. The method for detecting road surface cracks as described in claim 1, characterized in that, The Transformer model includes a multi-layer encoder and a multi-layer decoder. Each encoder layer includes a multi-head attention layer and a feedforward connection layer, and each decoder layer includes an occlusion multi-head attention layer, a multi-head attention layer, and a feedforward connection layer.
6. The method for detecting road surface cracks as described in claim 1, characterized in that, The Hungarian algorithm is as follows: In the formula, It is the set of optimal allocation results. Indicates an index. True value element of road surface cracks With index The pairwise matching cost, where It is the target category label. It is a vector. yes The probability, It is a prediction box. Indicates the first i One true element, This represents the set of prediction boxes. Represents the bounding box loss. N Indicates the number of prediction sets. Represents a set element.
7. A method for detecting road surface cracks as described in claim 6, characterized in that, The Transformer model is trained using a loss function, as shown below: In the formula, y Represents the set of truth values for the object being detected. This represents the set of prediction boxes. yes The logarithmic probability, It was a loss for Hungary. It is a generalized IoU loss. , It's a hyperparameter.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the pavement crack detection method according to any one of claims 1-7.
Citation Information
Patent Citations
Video group behavior recognition method based on cascade Transformer
CN113673489A
Ballastless track slab crack measurement method based on multi-scale cooperative deep learning
CN114494240A
