Tunnel lining apparent disease identification method based on query matching attention
Through the tunnel lining apparent disease identification method based on query matching attention, using self-attention mechanism and deep supervision strategy, the accuracy and efficiency of disease detection under complex lighting and background conditions are solved, and the apparent disease in tunnel lining is realized Medium-high-precision and efficient disease segmentation.
Patent Information
- Application Number
- CN202411041014.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-31
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2044-07-31
AI Technical Summary
Existing tunnel lining apparent disease detection methods are difficult to accurately identify diseases under complex lighting and background conditions, and the disease accounts for a small proportion of images, resulting in low detection efficiency and low accuracy, especially when dealing with subtle disease characteristics. and noise interference problem.
Using the tunnel lining apparent disease recognition method based on query matching attention, the feature extraction model and disease positioning attention feature decoding model is constructed, and the self-attention mechanism and deep supervision strategy are used to match the high-correlation bond vectors and value vectors. Reduce the computational burden, focus on disease characteristics with small proportions, and improve the detection ability of diseases at different scales through adaptive feature fusion and linear layer processing.
Effectively suppress background noise when the disease and background scale is unbalanced, improve the accuracy and segmentation accuracy of disease detection, maintain good performance in different environments, achieve more refined disease boundary definition and higher detection efficiency.
Smart Images

Figure CN118887544A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of semantic segmentation in computer vision, and in particular to a method for identifying apparent defects of tunnel linings based on query matching attention. Background Art
[0002] The traditional method of tunnel lining surface disease detection mainly relies on manual inspection, supplemented by some simple measurement tools. This method has problems such as low efficiency, strong subjectivity and difficulty in accurate quantification. In recent years, with the rapid development of image processing technology and deep learning, the automatic detection of tunnel lining surface diseases based on computer vision models has made good progress. These methods usually construct training data sets through the collected tunnel lining surface images, and use algorithms to realize automatic disease identification and pixel-level segmentation, which greatly improves the detection speed and accuracy, and also facilitates the quantitative evaluation of subsequent professionals. However, the existing technology still faces challenges, such as how to accurately identify diseases under complex lighting and background conditions, how to overcome the small proportion of diseases in the image, and how to achieve fine segmentation of diseases. Therefore, studying a high-precision and high-efficiency disease segmentation technology solution has become an important direction of current research.
[0003] In recent years, researchers in the field of tunnel defect detection have paid more and more attention to improving the accuracy and efficiency of defect recognition by improving the model's attention mechanism. The introduction of the attention mechanism aims to enable the model to focus on the defect features more efficiently during the training process, avoid the interference of irrelevant background, and thus achieve more accurate defect location and segmentation. Convolutional neural networks are widely used in defect detection due to their excellent performance in image processing. However, CNN tends to capture local information, which is conducive to the accurate extraction of local features, but when dealing with the task of defect segmentation, it may lead to discontinuity in the defect area due to the lack of a global view. For example, in tunnel crack recognition, cracks are often distributed in an elongated shape, and the local receptive field of CNN limits its performance in this regard. In order to overcome the limitations of CNN, researchers began to explore and apply different attention mechanisms to enhance the model's sensitivity to key defect features. Channel and spatial attention assist the model in strengthening important feature channels and pixels. The channel attention mechanism can help the model screen out features that are closely related to the defect; while spatial attention focuses on the specific location of the defect in the image to ensure the coherence and integrity of the defect segmentation. The multi-scale dilated pyramid expands the receptive field of the model by introducing dilated convolutions of different scales, enabling it to capture local details and global context information at the same time, effectively improving the accuracy of disease detection. The self-attention mechanism originated from the field of natural language processing and was later transplanted to the field of computer vision. It enables the model to automatically identify areas in the image that are highly correlated with disease features by constructing a triple of query vector, key vector, and value vector, thereby highlighting disease signals in the complex tunnel background. The core of this mechanism is that it allows the model to form a self-referential attention distribution when processing image features, effectively enhancing the model's ability to capture long-distance dependencies. Although the attention mechanism significantly improves the performance of disease detection, when the proportion of diseases in the image is extremely small, the full-image attention calculation can extract long-distance associations in parallel, but it may also introduce unnecessary computational burden and may introduce too much noise into model training.
[0004] In addition, the decoders of the disease segmentation model also show a trend of diversification. Each decoder architecture is designed to optimize specific feature extraction methods and segmentation tasks to improve the ability of disease detection. The SegNet model adopts a direct upsampling strategy and uses the pooling index obtained in the encoder stage for pixel-level prediction. This mechanism simplifies the calculation process to a certain extent, but may sacrifice some details, especially when dealing with subtle disease features. The DeepLaV3+ model introduces intermediate layer features to provide information for decoding, which can reduce the complexity of the decoding stage while maintaining a high resolution. The UNet model can effectively compensate for the information loss caused by the increase in model depth. The jump connection allows deep features to interact directly with shallow features, thereby achieving more refined boundary definition in the disease segmentation task. This structure consumes a lot of memory and may perform poorly when the target scale difference is large. As a representative of lightweight decoders, SegFormer processes the features extracted by the self-attention mechanism through linear layers, and then achieves disease segmentation through feature splicing. This design not only reduces the demand for computing resources, but also improves the flexibility of the model. However, directly splicing multi-scale features may cause some details to be obscured, especially for diseases with complex shapes and varying scales. This limitation is particularly obvious. Summary of the invention
[0005] In order to overcome the shortcomings of the above-mentioned prior art, the present invention proposes a method for identifying apparent defects in tunnel linings based on query matching attention. By constructing a feature extraction model and a defect location attention feature decoding model, the query vector is matched with a key vector and a value vector with high correlation, the computational burden of the model is reduced, and the model's attention is focused on defects with a relatively small proportion. A deep segmentation strategy and an adaptive feature fusion algorithm are adopted to enhance the model's ability to extract defects of different scales and extremely small scales. When the scale of the defect is extremely unbalanced with the background, the influence of background noise can be effectively suppressed, thereby improving the accuracy of defect detection.
[0006] A method for identifying apparent defects of tunnel lining based on query matching attention comprises the following steps:
[0007] S1. Collect tunnel lining surface images, annotate the defects in the tunnel lining surface images, and construct a defect image dataset;
[0008] S2, preprocessing the tunnel lining surface disease image and the corresponding disease mask image, extracting non-overlapping sub-image blocks containing the disease, and constructing a disease image training data set and a test data set;
[0009] S3. Construct a feature extraction model to extract the detail feature map of the tunnel lining surface disease image, and calculate the multi-stage disease location attention feature map of the tunnel lining surface disease image based on the detail feature map combined with the self-attention mechanism;
[0010] S4. Construct a disease localization attention feature decoding model, use an adaptive feature fusion method to fuse shallow and deep features, and calculate the segmentation results of the segmentation feature map at each stage through a deep supervision strategy;
[0011] S5. Binarization and optimization are performed on the segmentation results to obtain an optimized binarization result of the tunnel crack disease, and the crack disease direction is identified according to the optimized binarization result of the tunnel crack disease.
[0012] Specifically, the step S1 includes:
[0013] The inspection vehicle is equipped with a linear array camera to collect tunnel lining surface images twice to obtain two half-tunnel images, and the two half-tunnel images are aligned and spliced to obtain a complete tunnel lining surface image.
[0014] The complete tunnel lining surface image is cut without overlap according to a preset resolution, and the cut tunnel lining surface image is classified to obtain a tunnel lining surface disease image and a background; the tunnel lining surface disease image is divided into a crack disease image and a tile peeling disease image;
[0015] The tunnel lining surface defect image is annotated by the category number mapping method to obtain the annotated defect mask image.
[0016] A damage image dataset is constructed, which includes tunnel lining surface damage images and annotated damage mask images.
[0017] Specifically, the step S2 includes:
[0018] The brightness difference of the tunnel lining surface defect image is corrected by the illumination unevenness correction algorithm to obtain the grayscale image after uniform illumination.
[0019] The uniformly illuminated grayscale image is converted into an RGB color image to obtain a corrected tunnel lining apparent disease image. The corrected tunnel lining apparent disease image and the corresponding disease mask image are cut into multiple sub-image blocks, and the disease-free sub-image blocks are eliminated. The remaining image blocks are divided into a tunnel image training data set and a tunnel image test data set according to several proportions.
[0020] Specifically, step S3 includes:
[0021] S31. Construct a feature extraction model based on a self-attention mechanism neural network. The feature extraction model includes a query matching disease attention extraction branch and a multi-scale content feature extraction branch.
[0022] S32. Extract the key low-level visual features of the tunnel lining surface disease image through a convolutional neural network to generate a detail feature map FD ;
[0023] S33, detail feature map F D Input the query matching-based disease attention extraction branch and calculate the query vector V Q and the key vector V that matches the query QK ;
[0024] S34, detail feature map F D Input the multi-scale content feature extraction branch and calculate the value vector V V and the query matching value vector V QV ;
[0025] S35. Query vector V Q , query matching key vector V Q K and the query matching value vector V QV They are used as the query, key and value inputs of the self-attention mechanism respectively to calculate the first-stage disease location attention feature map F1;
[0026] S36. Based on the first-stage disease localization attention feature map F1, the second-stage disease localization attention feature map F2, the third-stage disease localization attention feature map F3, and the fourth-stage disease localization attention feature map F4 are calculated respectively.
[0027] Specifically, the step S33 includes: extracting the detail feature map F by querying the matched disease attention branch D The network is divided into S×S blocks in width and height directions, and the embedded features E are extracted for each block through a convolutional neural network. The query vector V is calculated from the embedded features E using a linear layer. Q and the key vector V K ;
[0028] Compute query vector V by channel Q The mean value M Q , and then calculate the key vector V by channel K The mean value M K , calculate the mean M Q and mean M K The cosine similarity of is the correlation between the query vector and the key vector of each block;
[0029] Take the query vector V Q Calculate the dimension for the target and select the same vector as the query vector V Q The top K key vectors with the highest relevance constitute the key vector set V that matches the query. QK .
[0030] Specifically, the step S34 includes extracting the detail feature map FD It is divided into three groups of features in the channel dimension, and the three groups of features are represented as F D1 、F D2 and F D3 ;
[0031] For three sets of features F D1 、F D2 、F D3 Use different sizes of depth-separable convolution kernels to extract multi-scale features and extract feature maps F D1 、F D2 and F D3 The multi-scale features F s 、F m and F l ;
[0032] Concatenate feature maps F by channel D1 、F D2 and F D3 The multi-scale features F s 、F m and F l , multi-scale features are fused through 1×1 convolution to obtain the value vector V V ;
[0033] According to the value vector V V Extract query matching value vector V according to relevance QV .
[0034] Specifically, step S4 includes:
[0035] Construct a disease localization attention feature decoding model, which includes an adaptive feature fusion module and a linear layer;
[0036] Extract the segmentation feature map of the disease localization attention feature map through a linear layer, extract the segmentation feature map S4 from the four-stage disease localization attention feature map F4 through a linear layer, input the segmentation feature map S4 and the three-stage feature map F3 into the adaptive feature fusion module, and extract the three-stage segmentation feature map S3;
[0037] The three-stage segmentation feature map S3 and the two-stage feature map F2 are input into the adaptive feature fusion module to extract the two-stage segmentation feature map S2; the two-stage segmentation feature map S2 and the one-stage feature map F1 are input into the adaptive feature fusion module to extract the one-stage segmentation feature map S1;
[0038] The sub-image blocks of the disease mask image are bilinearly downsampled in stages to obtain the sampled annotations. The resolution and segmentation features of each stage of downsampling are Figure 1 One by one, the sampled annotations are input into the 1×1 convolution layer to calculate the segmentation results of the segmentation feature map at each stage;
[0039] Calculate the segmentation result T according to the loss function x With L x The edge guided loss is used to extract the segmentation result T through the FFT algorithm. x and marked L x High frequency information H y and H l ;
[0040] Specifically, step S5 includes:
[0041] Binarize the segmentation results according to the disease category and convert them into disease areas and backgrounds;
[0042] The segmentation results are optimized through the opening and closing operations in morphology, and the segmentation edges are refined, the holes in the segmentation area are filled, and the defects with too small areas are removed.
[0043] The skeleton of the binary results of tunnel crack disease is extracted through the morphology algorithm, the crack propagation trend is visualized, and the direction of crack disease is identified.
[0044] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0045] The present invention proposes a method for identifying apparent defects in tunnel linings based on query matching attention. By constructing a feature extraction model, a key vector and a value vector with high correlation are matched to the query vector, the computational burden of the model is reduced, and the model's attention is focused on defects with a relatively small proportion. By increasing the capture of local defect features, when the defect and background scales are greatly unbalanced, the influence of background noise can be effectively suppressed, thereby improving the accuracy of defect detection. Query matching attention can help the model learn the common features of defects, so that it can maintain good performance when facing defects in different environments.
[0046] By building a disease localization attention feature decoding model, deep supervision allows the model to consider features at different levels simultaneously, which helps capture the manifestation of diseases at various scales. Since there are supervisory signals at multiple levels, the boundaries of the disease can be more finely controlled, resulting in more accurate segmentation results. The introduction of adaptive feature fusion methods and linear layers in the encoder structure ensures a lower computational complexity when incorporating shallow features. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0048] Figure 1 is a flow chart of a method for identifying apparent defects of tunnel linings based on query matching attention in an embodiment of the present invention;
[0049] Figure 2 is a schematic diagram of a feature extraction method based on query matching attention in an embodiment of the present invention;
[0050] Figure 3 Schematic diagram of deep supervised disease segmentation integrating multi-scale features in an embodiment of the present invention. DETAILED DESCRIPTION
[0051] The technical solution of the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is obvious that the described embodiments are part of the embodiments of the present invention, not all of the embodiments, and the implementation of the present invention is not limited to this. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0052] Embodiment 1:
[0053] The tunnel lining apparent disease recognition method based on query matching attention of the present invention comprises five parts: data acquisition, data processing, feature extraction, disease segmentation and post-processing of segmentation results. The segmentation results are optimized by image algorithm, the skeleton of the binary result of tunnel crack disease is extracted, the crack propagation trend is visualized, and the crack disease direction is identified. In this embodiment, the improved self-attention mechanism and deep supervision strategy are used to help improve the disease segmentation capability.
[0054] like Figure 1 As shown, a flow chart of a method for identifying apparent defects of tunnel lining based on query matching attention is provided. The method for identifying apparent defects of tunnel lining based on query matching attention of the present invention comprises:
[0055] S1. Data acquisition: Collect tunnel lining surface images, annotate the defects in tunnel lining surface images, and construct a defect image dataset.
[0056] S11, using an inspection vehicle with a linear array camera to collect tunnel lining surface images twice to obtain two half-width tunnel images, and using existing image acquisition software to align and splice the two half-width tunnel images to obtain a complete tunnel lining surface image;
[0057] The line array camera carried by the inspection vehicle is used to collect the apparent image of the tunnel lining, ensuring that the image has comprehensive coverage and high acquisition quality. The image acquisition software is used to accurately align and splice the two half-images collected to form a complete apparent image of the tunnel lining.
[0058] S12, cutting the complete tunnel lining surface image without overlap according to a preset resolution, classifying the cut tunnel lining surface image, and obtaining the tunnel lining surface disease image and background.
[0059] The complete image is cut at high resolution to ensure clear details at a resolution of 8192*4000. Through manual screening, the cut images are classified by disease type to obtain tunnel lining surface disease images and backgrounds. Tunnel lining surface disease images are further divided into crack disease images and tile peeling disease images.
[0060] S13. Annotate the tunnel lining surface defect image by using a category number mapping method to obtain an annotated defect mask image.
[0061] Specifically, different category numbers are assigned to the categories of background, crack disease image, and tile peeling disease image, which are 0, 1, and 2 respectively. The mask image is filled pixel by pixel according to the category number to generate a disease mask image and obtain a detailed disease annotation map. The resolution of the annotated disease mask image is consistent with the resolution of the tunnel lining apparent image before segmentation, ensuring that the annotation information completely corresponds to the original image. This implementation uses LabelMe software to perform pixel-level annotation on the tunnel lining apparent disease image. Through manual judgment, the software is used to draw a polygonal area on the image to select the disease, and the built-in algorithm is used to fill the selected area to obtain the annotation, which can ensure the annotation accuracy. The annotation results are stored as JSON files for easy data management and post-processing.
[0062] S14. Construct a disease image dataset, where the disease image dataset includes tunnel lining surface disease images and labeled disease mask images.
[0063] S2. Data processing: preprocess the tunnel lining surface disease images and the corresponding disease mask images, extract non-overlapping sub-image blocks containing diseases, and construct disease image training data sets and test data sets.
[0064] S21. Correct the brightness difference of the tunnel lining apparent disease image through the illumination unevenness correction algorithm, obtain the grayscale image after uniform illumination, and balance the brightness difference of the tunnel lining apparent disease image caused by light supplementation.
[0065] Specifically, the illumination unevenness correction algorithm is used to correct the brightness difference of the tunnel lining surface defect image, including:
[0066] The tunnel lining surface disease image is converted from RGB image to grayscale image G, and the average value of all pixels in grayscale image G is calculated as the average brightness g of grayscale image G. m .
[0067]
[0068] Among them, M and N represent the width and height of the grayscale image G, respectively. i,j Represents a pixel in the grayscale image, i and j represent the coordinates of the pixel in width and height, respectively, and the coordinate intervals are i∈[0,M-1] and j∈[0,N-1] respectively.
[0069] Set the local grayscale correction window size w l The horizontal and vertical steps and the number of windows required to traverse the image are calculated, and a local window brightness map is created according to the number of windows, and the local window brightness B is calculated. A matrix with the same size as the grayscale image is created according to the number of windows as the local window brightness map B, and each correction window is traversed to calculate the average value of the pixels in the window as the window average brightness, and it is recorded in the corresponding position of the local window brightness map B.
[0070]
[0071] Among them, a and b represent the pixel coordinates of the local window brightness map B.
[0072] Calculate the local window brightness B and the average brightness g m The ratio E is used to reflect the degree of local brightness abnormality:
[0073]
[0074] The local window brightness image is upsampled to the same size as the original image, and a Gaussian blur transition window is superimposed to smooth the brightness change. The ratio of the original grayscale image G to the ratio E is calculated, the pixel values that cross the boundary are cut, and the integer part of the pixel value is retained to obtain the grayscale image G′ after uniform illumination:
[0075]
[0076] The uniformly lighted grayscale image G′ is converted back into an RGB color image, which helps to enhance the contrast and color saturation of the image, thereby improving the expression of image details.
[0077] S22, converting the uniformly illuminated grayscale image into an RGB color image to obtain a corrected tunnel lining apparent disease image, cutting the corrected tunnel lining apparent disease image and the corresponding disease mask image into multiple sub-image blocks, removing the disease-free sub-image blocks, and dividing the remaining image blocks into a tunnel image training data set and a tunnel image test data set according to a certain ratio.
[0078] In this embodiment, the grayscale image after uniform illumination is converted into an RGB color image to increase the contrast and color saturation of the image, further improve the image details, and make the disease features more prominent. The corrected tunnel lining apparent disease image and the corresponding disease mask image are cut into multiple sub-image blocks, with a crack type disease segmentation resolution of 512×512 and a tile peeling disease segmentation resolution of 1024×1024. Image blocks containing disease features are screened out, and sub-image blocks without diseases are removed to reduce invalid data and improve model training efficiency. The image blocks are divided into a tunnel image training data set and a tunnel image test data set in a ratio of 8:2 to ensure the representativeness of the data set and provide sufficient data support for model training and verification.
[0079] S3. Feature extraction: construct a feature extraction model to extract the detail feature map of the tunnel lining apparent disease image. Based on the detail feature map and the self-attention mechanism, calculate the multi-stage disease location attention feature map of the tunnel lining apparent disease image.
[0080] S31. Construct a feature extraction model based on a neural network with a self-attention mechanism. The feature extraction model includes a query matching disease attention extraction branch and a multi-scale content feature extraction branch. The query matching disease attention extraction branch extracts features based on a convolutional neural network and calculates matching vectors using cosine similarity. The multi-scale content feature extraction branch is based on a deep separable convolutional network with multiple branches, and a convolutional layer is added at the end to fuse the calculation results of multiple branches. Finally, after completing a matching operation, the output results of the two branches calculate the attention features through matrix multiplication to obtain the enhanced features of the diseased area. The model uses deep separable convolution and attention mechanisms to extract and fuse content features of different scales, thereby achieving more accurate feature representation. Secondly, when calculating the self-attention features, the model eliminates the interference of irrelevant areas and reduces the amount of matrix multiplication calculations.
[0081] S32. Extract the key low-level visual features of the tunnel lining surface disease images in the training dataset through a convolutional neural network (CNN) to generate a detail feature map F D .
[0082] The key low-level visual features of tunnel lining surface defect images include edges, textures, etc. of tunnel lining surface defect images.
[0083] S33, detail feature map F D Input the query matching-based disease attention extraction branch and calculate the query vector V Q and the key vector V that matches the query QK .
[0084] like Figure 2 FIG. 1 is a schematic diagram of a feature extraction method based on query matching attention in an embodiment of the present invention; D Input the query matching-based disease attention extraction branch, and use the query matching-based disease attention extraction branch to extract the detail feature map F with a width of W, a height of H, and a number of channels of C. D , divided into S×S blocks in width and height directions, the embedded feature E is extracted for each block through a convolutional neural network, and the query vector V is calculated from the embedded feature E using a linear layer Q and the key vector V K .
[0085] Calculate and query vector V Q The matching key vector V K , specifically including: Calculate the query vector V by channel Q The mean value M Q , and then calculate the key vector V by channel K The mean value M K , then calculate the mean M Q and mean M K The cosine similarity of is used as the correlation index between the query vector and the key vector between blocks. Q Calculate the dimension for the target and select the same vector as the query vector V Q The top K key vectors with the highest relevance constitute the key vector set V that matches the query. QK .
[0086] S34, detail feature map F D Input the multi-scale content feature extraction branch and calculate the value vector V V and the query matching value vector V QV ;
[0087] The detail feature map F D Input the multi-scale content feature extraction branch, and use the multi-scale content feature extraction branch to extract the detail feature map F D In the channel dimension, it is divided into three groups of features, denoted as F D1 、F D2 and F D3 , the number of channels are c1, c2 and c3 respectively.
[0088] For three sets of features F D1 、F D2、F D3 The multi-scale features are extracted using depthwise separable convolution kernels of different sizes, 3×3, 5×5, and 7×7, respectively. The multi-scale features F of three groups of features are extracted. s 、F m and F l .
[0089] The multi-scale features are concatenated by channel and fused through 1×1 convolution to obtain the fused features as the value vector V V , according to the value vector V V Extract query matching value vector V according to relevance QV . According to the value vector V V Extract query matching value vector V according to relevance QV Specifically include: Calculate the query vector V by channel Q The mean value M Q , and then calculate the value vector V by channel V The mean value M V , then calculate the mean M Q and mean M V The cosine similarity of is used as the correlation index between the query vector and the value vector between blocks. Q Calculate the dimension for the target and select the same vector as the query vector V Q The top K value vectors with the highest relevance constitute the value vector set V that matches the query. QV .
[0090] S35. Query vector V Q , query matching key vector V Q K and the query matching value vector V QV They are used as the query, key and value inputs of the self-attention mechanism respectively to calculate the first-stage disease localization attention feature map F1. The disease localization attention feature map F1 is calculated by the following formula:
[0091]
[0092] Where C is the key vector V QK The dimension of . Formula (5) is Figure 2 It is represented as two matrix multiplication calculations.
[0093] S36. Based on the first-stage disease location attention feature map F1, repeat the above process to construct a multi-stage deep feature extraction model, and obtain the disease location attention feature maps of each stage, represented as F1, F2, F3 and F4.
[0094] The step S35 comprises:
[0095] Input the first-stage disease location attention feature map F1 into the query matching-based disease attention extraction branch to calculate the query vector and the key vector matching the query; Input the first-stage disease location attention feature map F1 into the multi-scale content feature extraction branch to calculate the value vector and the value vector matching the query; Use the query vector, query matching key vector and query matching value vector as the query, key and value input of the self-attention mechanism respectively to calculate the second-stage disease location attention feature map F2;
[0096] The two-stage disease location attention feature map F2 is input into the query matching-based disease attention extraction branch to calculate the query vector and the key vector matching the query; the two-stage disease location attention feature map F2 is input into the multi-scale content feature extraction branch to calculate the value vector and the value vector matching the query; the query vector, the query matching key vector and the query matching value vector are used as the query, key and value input of the self-attention mechanism respectively to calculate the three-stage disease location attention feature map F3;
[0097] The three-stage disease localization attention feature map F3 is input into the query matching-based disease attention extraction branch to calculate the query vector and the key vector matching the query; the three-stage disease localization attention feature map F3 is input into the multi-scale content feature extraction branch to calculate the value vector and the value vector matching the query; the query vector, query matching key vector and query matching value vector are used as the Query, Key and Value inputs of the self-attention mechanism respectively to calculate the four-stage disease localization attention feature map F4.
[0098] S4. Disease segmentation: construct a disease localization attention feature decoding model, use an adaptive feature fusion method to fuse shallow and deep features, and calculate the segmentation results of the segmentation feature map at each stage through a deep supervision strategy.
[0099] like Figure 3 , which is a schematic diagram of deep supervised disease segmentation integrating multi-scale features in an embodiment of the present invention. Specifically, step S4 includes:
[0100] S41. Construct a disease localization attention feature decoding model, which includes an adaptive feature fusion module and a linear layer.
[0101] Specifically, the disease localization attention feature decoding model includes an adaptive feature fusion module and a linear layer. The adaptive feature fusion module is used to fuse the disease localization attention feature maps generated at each stage, and the fused features are input into the segmentation layer based on the convolutional neural network to predict the disease segmentation results. The adaptive feature fusion module introduces a linear layer to adjust the dimension of the feature map, and fuses the features with the features of the previous layer through the upsampling layer, the pooling layer and the linear layer, so as to restore the detail information lost due to downsampling. For each layer of restored features, the model introduces a segmentation layer to obtain disease segmentation results of different scales, and calculates the segmentation loss of the segmentation results and the segmentation annotations to guide model training.
[0102] S42, extracting a segmentation feature map of the disease localization attention feature map through a linear layer, extracting a segmentation feature map S4 from the four-stage disease localization attention feature map F4 through a linear layer, inputting the segmentation feature map S4 and the three-stage feature map F3 into an adaptive feature fusion module, and extracting a three-stage segmentation feature map S3;
[0103] The adaptive feature fusion module will gradually fuse the feature maps of different stages. The upsampled segmentation feature map S4 has the same resolution as the feature map F3 of the previous stage. Then the two are input into the adaptive feature fusion module to extract the segmentation feature map S3 of this stage.
[0104] The adaptive feature fusion module is used to splice the disease location attention feature map F at the current stage by channel. x Compared with the segmentation feature map S of the previous stage x-1 , get the channel attention feature map C x , calculate the channel attention feature map C x The average value of each channel in is input into the linear layer, and the fusion ratio A of the feature is obtained through the Softmax activation function x , using the fusion ratio A x Calculate the fused segmentation feature map S x .
[0105] S x =A x ·S x-1 +(1-A x )·F x (6)
[0106] S42, input the three-stage segmentation feature map S3 and the two-stage feature map F2 into the adaptive feature fusion module to extract the two-stage segmentation feature map S2; input the two-stage segmentation feature map S2 and the one-stage feature map F1 into the adaptive feature fusion module to extract the one-stage segmentation feature map S1, and obtain the segmentation feature maps S2 and S1.
[0107] S43, using the deep supervision strategy, bilinear downsampling the sub-image blocks of the disease mask image in stages, obtaining the sampling annotations, and the resolution and segmentation features of each stage of downsampling Figure 1 Correspondingly, the sampled annotations are input into the 1×1 convolution layer to calculate the segmentation results of the segmentation feature map at each stage.
[0108] The use of deep supervision strategies can further improve the generalization ability and stability of the model, such as Figure 3 The dotted double arrow part. For the annotation, bilinear interpolation downsampling is a commonly used image resizing algorithm, which estimates the value of the new position by weighted average of the four nearest known points. The implementation details are seldom described. The sub-image blocks of the disease mask image generated in step S2 are bilinearly downsampled to ensure that the annotation resolution of each stage matches the segmentation feature map, obtain the annotations L1, L2, L3 and L4, and input the 1×1 convolution layer to calculate the segmentation feature map S at each stage. x The segmentation result Y x .
[0109] S44, calculate segmentation result Y x With L x The edge-guided loss guides the continuity of the disease segmentation
[0110] Extract the segmentation result T through FFT algorithm x and marked L x High frequency information H y and H l , calculate the edge guidance loss according to the loss function. High frequency information H y and H l Used for edge detail alignment to improve the continuity and accuracy of disease segmentation.
[0111] The segmentation result T is extracted by Fourier transform (FFT) algorithm x and marked L x High frequency information H y and H l , follow these steps:
[0112] Convert the image to the frequency domain, and then segment the result Y x and marked L x For each pixel value in , a two-dimensional discrete Fourier transform (DFT) is performed. The two-dimensional discrete Fourier transform formula is as follows:
[0113]
[0114] Among them, f(x, y) is the pixel value of the original image, F(u, v) is the corresponding frequency domain value, M and N are the height and width of the image respectively, and j is the imaginary unit.
[0115] Extract high-frequency information. The low-frequency information in the frequency domain is located near the center, while the high-frequency information is located at the edge. Therefore, we can only focus on the edge of the spectrum to extract high-frequency information. x and L x The spectrum F x and F l , we can take the elements in the non-central area as high-frequency information H y and H l The edge-guided loss can be calculated from the obtained high-frequency information. High-frequency information usually contains edge and texture details in the image. By comparing the predicted results with the annotated high-frequency information, the model can focus on capturing edge and texture changes, while more accurately locating edges and contours, thereby improving the accuracy of disease recognition.
[0116] The edge-guided loss function is defined as follows:
[0117]
[0118] Among them, H yr , H yi Represents high frequency information H y The imaginary and real parts, H lr , H li Represents high frequency information H l The imaginary and real parts of , α and β are the balancing coefficients, which are used to adjust the relative importance of the two loss parts.
[0119] S5. Post-processing the segmentation results: binarizing and optimizing the segmentation results to obtain optimized binarization results of tunnel crack diseases, and identifying the direction of crack diseases according to the optimized binarization results of tunnel crack diseases.
[0120] Specifically, step S5 includes:
[0121] S51, performing binarization processing on the segmentation results according to the disease category, and converting the segmentation results into the disease area and the background;
[0122] First, according to different disease categories, the segmentation results output by the model are binarized. This process converts the segmentation results into clear foreground (disease area) and background, which is convenient for subsequent morphological operations and analysis.
[0123] S52, optimizing the segmentation results through the opening and closing operations in morphology, performing operations such as segmentation edge refinement, segmentation area hole filling, and small area disease removal, so as to further improve the accuracy and completeness of disease identification;
[0124] The segmentation results are post-processed through the opening and closing operations in morphology to remove the burrs and noise in the diseased area and make the edges smoother. Small holes inside the diseased area are filled to ensure the integrity of the diseased area. Segmentation results with too small areas are removed, which may be noise or non-disease areas, thereby improving the accuracy of disease recognition.
[0125] S53. The skeleton of the binary result of tunnel crack disease is extracted through the morphology algorithm, the crack propagation trend is visualized, and the direction of crack disease is identified.
[0126] Specifically, the steps of extracting the skeleton of tunnel crack disease by morphology algorithm include: binarization of crack image, binarization of crack segmentation result, that is, converting the image into black and white, black represents the background, and white represents the crack. Thinning the object in the binary image to its skeleton, retaining the main trunk part of the crack in the middle, while eliminating the filling part of the crack to make it look like a thin line. Dilation and corrosion are performed on the skeleton. By alternating dilation and corrosion operations, the pixels around the crack can be gradually removed until only a single-pixel wide line remains, which is the skeleton of the crack. Remove the branch points of the skeleton. The result of thinning may contain branch points, which cannot represent the real path of the crack. Therefore, further processing is required to delete these points and leave only a continuous skeleton. Connect the broken skeleton. During the thinning process, some cracks may be cut off. In order to fully represent the crack, these broken parts need to be reconnected.
[0127] Using the Morphology algorithm, we pay special attention to the binary results of crack damage and extract the skeleton of the binary results of crack damage, which is the main extension path of the crack. This step can intuitively display the propagation trend of the crack, help analysts quickly understand the development of the crack, and provide a basis for subsequent repair plans.
[0128] In summary, the present invention proposes a method for identifying apparent defects in tunnel linings based on query matching attention. By introducing a defect attention extraction mechanism based on query matching, the model can focus on the key local features of the defect. Even when there is a significant scale difference between the defect and the background, it can effectively suppress background noise interference and significantly improve the accuracy and robustness of defect detection. The use of deep supervision strategy enables the model to simultaneously consider and fuse multi-scale features at different levels, which not only helps to fully capture the manifestations of defects at the micro and macro levels, but also, by introducing supervision signals at multiple levels, it can more finely control the depiction of defect boundaries, thereby producing more accurate segmentation results. The adaptive feature fusion method and linear layer introduced in the encoder structure realize the effective fusion of shallow features while ensuring low computational complexity. This design not only ensures the full utilization of shallow information by the model, but also avoids the possibility of affecting real-time or large-scale deployment due to excessive consumption of computing resources. This method comprehensively uses the query matching attention mechanism, deep supervision strategy and adaptive feature fusion technology, effectively overcomes the limitations of traditional disease recognition methods in complex environments, significantly improves the accuracy and efficiency of disease recognition, and provides a more reliable technical means for tunnel lining health monitoring and maintenance.
[0129] The above embodiments are preferred implementation modes of the present invention, but the implementation modes of the present invention are not limited to the above embodiments. Any other changes, modifications, substitutions, combinations, and simplifications that do not deviate from the spirit and principles of the present invention should be equivalent replacement methods and are included in the protection scope of the present invention.
Claims
1. A tunnel lining surface defect recognition method based on query matching attention, It is characterized in that The following steps are involved: S1. Collect tunnel lining surface images, annotate the defects in the tunnel lining surface images, and construct a defect image dataset; S2, preprocessing the tunnel lining surface disease image and the corresponding disease mask image, extracting non-overlapping sub-image blocks containing the disease, and constructing a disease image dataset; S3. Construct a feature extraction model to extract the detail feature map of the tunnel lining surface disease image, and calculate the multi-stage disease location attention feature map of the tunnel lining surface disease image based on the detail feature map combined with the self-attention mechanism; S4. Construct a disease localization attention feature decoding model, use an adaptive feature fusion method to fuse shallow and deep features, and calculate the segmentation results of the segmentation feature map at each stage through a deep supervision strategy; S5. Binarization and optimization are performed on the segmentation results to obtain an optimized binarization result of the tunnel crack disease, and the crack disease direction is identified according to the optimized binarization result of the tunnel crack disease.
2. According to the query matching attention based tunnel lining apparent disease identification method of claim 1, It is characterized in that The step S1 comprises: The inspection vehicle is equipped with a linear array camera to collect tunnel lining surface images twice to obtain two half-tunnel images, and the two half-tunnel images are aligned and spliced to obtain a complete tunnel lining surface image. The complete tunnel lining surface image is cut without overlap according to a preset resolution, and the cut tunnel lining surface image is classified to obtain a tunnel lining surface disease image and a background; the tunnel lining surface disease image is divided into a crack disease image and a tile peeling disease image; The tunnel lining surface defect image is annotated by the category number mapping method to obtain the annotated defect mask image. A damage image dataset is constructed, which includes tunnel lining surface damage images and annotated damage mask images.
3. According to the query matching attention based tunnel lining apparent disease identification method of claim 2, It is characterized in that The step S2 comprises: The brightness difference of the tunnel lining surface defect image is corrected by the illumination unevenness correction algorithm to obtain the grayscale image after uniform illumination. The uniformly illuminated grayscale image is converted into an RGB color image to obtain a corrected tunnel lining apparent disease image. The corrected tunnel lining apparent disease image and the corresponding disease mask image are cut into multiple sub-image blocks, and the disease-free sub-image blocks are eliminated. The remaining image blocks are divided into a tunnel image training data set and a tunnel image test data set according to several proportions.
4. According to the query matching attention based tunnel lining apparent disease identification method of claim 1, It is characterized in that The step S3 comprises: S31. Construct a feature extraction model based on a self-attention mechanism neural network. The feature extraction model includes a query matching disease attention extraction branch and a multi-scale content feature extraction branch. S32. Extract the key low-level visual features of the tunnel lining surface disease image through a convolutional neural network to generate a detail feature map F D ; S33, detail feature map F D Input the query matching-based disease attention extraction branch and calculate the query vector V Q and the key vector V that matches the query QK ; S34, detail feature map F D Input the multi-scale content feature extraction branch and calculate the value vector V V and the query matching value vector V QV ; S35. Query vector V Q , query matching key vector V QK and query matching value vector V QV As the query, key and value input of the self-attention mechanism, the first-stage disease location attention feature map F is calculated. 1 ; S36, attention feature map based on one-stage disease positioning F 1 , respectively calculate the two-stage disease location attention feature map F 2 , get the three-stage disease location attention feature map F 3 , Four-stage disease location attention feature map F 4 .
5. According to the query matching attention based tunnel lining apparent disease identification method of claim 4, It is characterized in that The step S33 comprises: extracting the detail feature map F by querying the matched disease attention branch D The network is divided into S×S blocks in width and height directions, and the embedded features E are extracted for each block through a convolutional neural network. The query vector V is calculated from the embedded features E using a linear layer. Q and the key vector V K ; Compute query vector V by channel Q The mean value M Q , and then calculate the key vector V by channel K The mean value M K , calculate the mean M Q and mean M K The cosine similarity of is the correlation between the query vector and the key vector of each block; Take the query vector V Q Calculate the dimension for the target and select the same vector as the query vector V Q The top K key vectors with the highest relevance constitute the key vector set V that matches the query. QK .
6. According to claim 4, a method for identifying apparent defects of tunnel lining based on query matching attention, It is characterized in that The step S34 includes extracting the detail feature map F through a multi-scale content feature extraction branch. D It is divided into three groups of features in the channel dimension, and the three groups of features are represented as F D1 、F D2 and F D3 ; For three sets of features F D1 、F d2 、F D3 Use different sizes of depth-separable convolution kernels to extract multi-scale features and extract feature maps F D1 、F D2 and F D3 The multi-scale features F s 、F m and F l ; Concatenate feature maps F by channel D1 、F D2 and F D3 The multi-scale features F s 、F m and F l , multi-scale features are fused through 1×1 convolution to obtain the value vector V V ; According to the value vector V V Extract query matching value vector V according to relevance QV .
7. According to claim 4, a method for identifying apparent defects of tunnel lining based on query matching attention, It is characterized in that The step S35 includes: Position the first-stage disease in the attention feature map F 1 Input the query matching-based disease attention extraction branch, calculate the query vector and the key vector matching the query; localize the first-stage disease attention feature map F 1 Input the multi-scale content feature extraction branch, calculate the value vector and the query matching value vector; use the query vector, query matching key vector and query matching value vector as the query, key and value input of the self-attention mechanism respectively, and calculate the second-stage disease location attention feature map F 2 ; Position the second-stage disease in the attention feature map F 2 Input the query matching-based disease attention extraction branch, calculate the query vector and the key vector matching the query; localize the second-stage disease attention feature map F 2 Input the multi-scale content feature extraction branch, calculate the value vector and the query matching value vector; use the query vector, query matching key vector and query matching value vector as the query, key and value input of the self-attention mechanism respectively, and calculate the three-stage disease location attention feature map F 3 ; Position the three-stage disease attention feature map F 3 Input the query matching-based disease attention extraction branch, calculate the query vector and the key vector matching the query; localize the three-stage disease attention feature map F 3 Input the multi-scale content feature extraction branch, calculate the value vector and the query matching value vector; use the query vector, query matching key vector and query matching value vector as the query, key and value input of the self-attention mechanism respectively, and calculate the four-stage disease location attention feature map F 4 .
8. A method for identifying apparent defects in tunnel linings based on query matching attention according to claim 4, It is characterized in that The step S4 comprises: Construct a disease localization attention feature decoding model, which includes an adaptive feature fusion module and a linear layer; The segmentation feature map of the disease localization attention feature map is extracted through the linear layer, and the linear layer is used to extract the segmentation feature map of the disease localization attention feature map F from the four-stage disease localization attention feature map 4 Extract the segmentation feature map S 4 , segment the feature map S 4 With the three-stage feature map F 3 Input the adaptive feature fusion module to extract the three-stage segmentation feature map S 3 ; The three-stage segmentation feature map S 3 And the second stage feature map F 2 Input the adaptive feature fusion module to extract the two-stage segmentation feature map S 2 ; The second stage segmentation feature map S 2 With the one-stage feature map F 1 Input the adaptive feature fusion module to extract the first-stage segmentation feature map S 1 ; The sub-image blocks of the disease mask image are bilinearly downsampled in stages to obtain the sampled annotations. The resolution of the downsampling at each stage corresponds to the segmentation feature map one by one. The sampled annotations are input into the 1×1 convolution layer to calculate the segmentation result of the segmentation feature map at each stage. Calculate the segmentation result Y according to the loss function x With L x The edge-guided loss is used to extract the segmentation result Y through the FFT algorithm. x and marked L x High frequency information H y and… l .
9. According to claim 8, a method for identifying apparent defects of tunnel lining based on query matching attention, It is characterized in that The adaptive feature fusion module is used to splice the disease location attention feature map of the current stage and the segmentation feature map of the previous stage by channel to obtain a channel attention feature map; calculate the average value of each channel in the channel attention feature map and input it into the linear layer, obtain the feature fusion ratio through the Softmax activation function, and use the fusion ratio to calculate the fused segmentation feature map.
10. A method for identifying apparent defects in tunnel linings based on query matching attention according to claim 8, It is characterized in that The step S5 comprises: Binarize the segmentation results according to the disease category and convert them into disease areas and backgrounds; The segmentation results are optimized through the opening and closing operations in morphology, and the segmentation edges are refined, the holes in the segmentation area are filled, and the defects with too small areas are removed. The skeleton of the binary results of tunnel crack disease is extracted through the morphology algorithm, the crack propagation trend is visualized, and the direction of crack disease is identified.
Citation Information
Patent Citations
Low-precision image semantic segmentation method based on improved attention mechanism
CN112508960A
Method and device for identifying typical disease image of tunnel lining
CN116563608A
Few-shot radar target recognition method based on hierarchical meta transfer
WO2024082374A1
Cited By
Method and system for acquiring information of surrounding rock and lining structure of operating tunnel
CN119579922A
Tunnel disease target intelligent identification and extraction method based on machine vision
CN120374607A
Tunnel disease detection model construction method based on few samples
CN120807452A
