Transform and cascade operation-based bridge crack detection model construction method and system
Through the cascade coordination attention enhancement model Cascade CATransUNet, combined with global and local cascade operations, the GPU memory limitation problem of the Transformer model in high-resolution image processing is solved, and fine-grained segmentation and security of high-resolution bridge crack detection are achieved. Evaluate.
Patent Information
- Application Number
- CN202410770985.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-14
- Publication Date
- 2024-09-06
AI Technical Summary
Existing Transformer-based high-resolution bridge crack detection models have limitations in GPU memory consumption, resulting in the inability to effectively process high-resolution images, which in turn affects segmentation precision and safety assessment.
The cascade coordinated attention enhancement model Cascade CATransUNet is used. By introducing a coordinated attention mechanism and a multi-scale feature extraction architecture, combined with global and local cascade operations, a customized loss function is designed to optimize the model, reduce GPU memory requirements and improve segmentation accuracy.
It achieves fine-grained crack detection on high-resolution images, keeps the computational memory requirements unchanged, improves the accuracy and security of segmentation results, and is suitable for bridge detection with 4K image resolution.
Smart Images

Figure CN118608968A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer technology, and in particular to a method and system for constructing a bridge crack detection model based on transformer and cascade operation. Background Art
[0002] Long-term health monitoring and regular inspections are essential to ensure the normal operation of bridges throughout their service life, especially older concrete bridges, which are prone to crack formation due to changes in loading conditions, environmental corrosion and other factors, which may lead to more serious damage. Therefore, cracks are often regarded as a basic intuitive indicator for the initial assessment of structural safety. Therefore, how to achieve accurate and effective crack detection has always been a major concern of structural management and maintenance departments, especially in the case of existing bridge structures.
[0003] Inspired by the outstanding performance of computer vision techniques based on deep learning (DL) in various fields, civil engineering researchers have begun to explore and enhance the potential of this advanced technology for crack detection. DL-based crack detection can be roughly divided into three main methods: classification of crack images, target detection of cracks, and segmentation of crack images. Among these methods, crack segmentation stands out because it can extract the topological structure and morphology of cracks, which is convenient for further analysis and extraction of quantitative information. Therefore, crack segmentation has received great attention in recent years.
[0004] Many researchers have studied crack segmentation and contributed to the development of this field. It is worth noting that convolutional neural networks (CNNs) have become one of the most classic algorithms in the field of DL. Convolutional neural networks are able to simulate the complex hierarchical cognitive patterns in the visual cortex of the human brain, enabling them to effectively capture and restore the grid-like topological structure of target pixels. Therefore, most crack segmentation algorithms use CNN as their basis, but they inevitably encounter common challenges inherent in the CNN architecture. Specifically, the discrete downsampling of features leads to the gradual loss of fine-grained information, which hinders the generation of accurate segmentation results. As the downsampling process becomes more substantial, this shortcoming becomes more obvious in images with higher resolutions. Therefore, existing methods mainly focus on low-resolution (LR) crack images to mitigate the excessive loss of key crack details. However, with the advancement of imaging technology and display devices, it has become increasingly common to use 4K and 6K resolution imaging devices for bridge inspection. Compared with their LR counterparts, these high-resolution (HR) crack images provide more comprehensive structural information. This enhanced image enables inspectors to make more accurate predictions about the structural condition, effectively plan maintenance or repair interventions, and wisely allocate maintenance resources. In addition, higher resolution imaging devices usually provide a larger field of view, which helps to acquire crack images faster. This greatly reduces the time that inspectors or unmanned equipment are exposed to dangerous operating environments and greatly improves inspection safety. Therefore, the development of HR crack segmentation algorithms has become an urgent concern of researchers in this field, which is consistent with the trajectory of using HR images for crack detection. However, previous CNN-based crack segmentation algorithms have faced significant difficulties in effectively solving this problem.
[0005] To extract the complex topological properties of cracks with finer details, the Visual Transformer (ViT) model has attracted great attention from researchers. Recent studies have shown that the ViT model has a remarkable ability to extract topological properties due to its superior long-range dependency modeling, parallel computational capabilities, multi-scale feature representation, and efficient position encoding. These unique properties of Transformers enhance the representation of discrete crack pixels and can achieve more accurate segmentation results compared to CNNs. Liu et al. addressed the challenges associated with uneven crack pixel intensities, complex topological structures, and low contrast with noisy background pixels by introducing a fine-grained crack detection architecture called “CrackFormer”. This architecture surpasses the state-of-the-art CNN-based segmentation methods; then Shamsabadi et al. proposed an enhanced ViT-based crack segmentation architecture, which improved the mIoU of small-scale crack images with a resolution of 448×448 by 6.1% and 3.8%, respectively, compared with CNN-based models such as DeepLabv3+ and U-Net. Building on this work, Fang et al. integrated Transformers into the U-shaped encoder-decoder framework and proposed TransUNet, which uses an external attention mechanism to perform road crack segmentation at a resolution of 480×320. In the presence of complex background interference, this architecture effectively alleviates the limited robustness of the original CNN model. Although Transformers surpass CNN in terms of crack recognition robustness and accuracy, they require more computing resources to support high-performance training and inference. In the Transformer model, the self-attention mechanism plays a key role in capturing the dependencies between different positions in the input sequence. Each position must calculate its association with other positions, resulting in a quadratic increase in the time and space complexity of model training and inference relative to the length of the sequence. As the image resolution increases, the number of pixels in the image increases, which lengthens the input sequence and significantly increases the graphics processing unit (GPU) memory usage required for the self-attention mechanism calculation. The surge in GPU memory requirements often exceeds the capacity of commercial GPUs, resulting in interruptions in the inference process. These interruptions may cause the training process to stop abruptly, making it challenging to obtain a fully trained model.
[0006] The advantages of Transformers in HR image processing are limited by computational resources, which forces researchers to make commitments: a common approach is to reduce the image resolution by downsampling or compression to reduce memory requirements; another approach is to split the image into smaller blocks for separate processing and then concatenate the predictions sequentially. While these methods address memory limitations and maintain normal program operation, they may cause the loss of fine crack features and boundary pixels, resulting in incomplete and rough segmentation results, which can seriously affect structural safety assessment. Therefore, it is necessary to enhance the current Transformer-based methods to address the trade-off between segmentation fineness and GPU memory consumption. This is crucial to overcome the limitations of current Transformer-based crack segmentation models, which are limited to predicting low-resolution (LR) crack images no larger than 800×600 to prevent program termination due to GPU memory overflow. However, in previous studies, addressing this specific challenge in high-quality crack segmentation of HR images based on Transformers has not received significant attention. Summary of the invention
[0007] The purpose of the present invention is to provide a method and system for constructing a bridge crack detection model based on transformer and cascade operation, aiming to solve the above-mentioned problems in the prior art.
[0008] The embodiment of the present invention provides a method for constructing a bridge crack detection model based on transformer and cascade operation, comprising:
[0009] Acquire a bridge crack image, and pre-process the crack image to obtain input data;
[0010] The input data is input into the cascade coordinated attention enhancement model Cascade CATransUNet for training, and the model is optimized through a customized loss function to obtain the final bridge crack detection model.
[0011] The embodiment of the present invention provides a bridge crack detection model construction system based on transformer and cascade operation, including:
[0012] A data preprocessing module, used for acquiring a bridge crack image, and preprocessing the crack image to obtain input data;
[0013] A building module is used to input the input data into the cascade coordinated attention enhancement model CascadeCATransUNet for training, and optimize the model through a customized loss function to obtain the final bridge crack detection model.
[0014] An embodiment of the present invention also provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the above-mentioned method for constructing a bridge crack detection model based on transformer and cascade operation are implemented.
[0015] An embodiment of the present invention also provides a computer-readable storage medium, on which a program for implementing information transmission is stored. When the program is executed by a processor, the steps of the above-mentioned method for constructing a bridge crack detection model based on transformer and cascade operation are implemented.
[0016] The use of the embodiments of the present invention may include the following beneficial effects: The embodiments of the present invention propose a fine segmentation method called Cascade CATransUNet, which combines a cascade structure and a coordinated attention mechanism to enhance the Transformer. In order to improve the capture of fine crack features, this method introduces a CA mechanism at all jump connections of TransUNet, and designs two cascade refinement operations based on CATransUNet to restore the missing boundary fine-grained pixels of the enhanced coarse-grained crack features. This approach not only takes into account both global and local aspects, but also keeps the computational memory requirements unchanged. A loss function that considers the boundary area is also added during the model training process to reduce the jagged effect often observed in the crack boundary prediction results, effectively achieving fine-grained segmentation of HR crack images while saving GPU memory. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate one or more embodiments of this specification 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 recorded in this specification. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0018] Figure 1 is a flow chart of a method for constructing a bridge crack detection model based on transformer and cascade operation according to an embodiment of the present invention;
[0019] Figure 2 1 is a structural diagram of a transformer-based multi-scale crack feature extraction architecture and its key components according to an embodiment of the present invention (where a is CATransUNet, b is Swin Transformer Block, and c is a coordinated attention mechanism module);
[0020] Figure 3: is a schematic diagram of a global cascade operation in an embodiment of the present invention (wherein a three-level cascade operation is constructed on the basis of CATransUNet, using three scales of output, and the output step sizes OS are 8, 2 and 1 respectively, for global refinement processing);
[0021] Figure 4 is a schematic diagram of the global cascade optimization algorithm code of an embodiment of the present invention;
[0022] Figure 5 is a schematic diagram of local cascade operation in an embodiment of the present invention;
[0023] Figure 6 It is a schematic diagram of the local cascade optimization algorithm code of an embodiment of the present invention;
[0024] Figure 7 It is a schematic diagram of a bridge crack detection model construction system based on transformer and cascade operation according to an embodiment of the present invention. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the following will be combined with the drawings in one or more embodiments of this specification to clearly and completely describe the technical solutions in one or more embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this document.
[0026] Method Embodiment
[0027] According to an embodiment of the present invention, a method for constructing a bridge crack detection model based on transformer and cascade operation is provided. Figure 1 is a flow chart of a method for constructing a bridge crack detection model based on transformer and cascade operation according to an embodiment of the present invention, such as Figure 1 As shown, the bridge crack detection model construction method based on transformer and cascade operation according to an embodiment of the present invention specifically includes:
[0028] Step S101, obtaining a bridge crack image, preprocessing the crack image to obtain input data, specifically includes:
[0029] Downsampling the long axis of the crack image to a preset length, and adjusting the short axis of the crack image according to the ratio of the long axis to the short axis of the original image;
[0030] The preset length is a length obtained according to the GPU memory limitation and the capabilities of the two cascade operations;
[0031] Step S102, inputting the input data into a cascade coordinated attention enhancement model Cascade CATransUNet for training, and optimizing the model through a customized loss function to obtain a final bridge crack detection model;
[0032] The cascade coordinated attention enhancement model is a coordinated attention and transformer enhancement model CATransUNet that introduces two cascade operations;
[0033] The coordinated attention and transformer enhancement model CATransUNet is based on the UNet architecture, which is a U-shaped encoder and decoder. The Swin Transformer is used to replace the original convolutional layer on the encoder side, and a coordinated attention CA mechanism is introduced at each jump connection between the encoder and the decoder. The two cascade operations include global cascade operations and local cascade operations.
[0034] The input data is input into the Cascade Coordinated Attention Enhancement Model Cascade CATransUNet for training, and the model is optimized through a customized loss function to obtain the final bridge crack detection model, which specifically includes:
[0035] Input the input data into CATransUNet for the first refinement operation to generate a first refined mask image, merge the input data with the first refined mask image and feed them back to CATransUNet for the second refinement operation to generate a second refined mask image, merge the first refined mask image with the second refined mask image and feed them back to CATransUNet for the third refinement operation to generate a third refined mask image; upsample the third refined mask image, crop the upsampled image and remove the edge through a sliding window, perform a local refinement operation on the cropped image, stitch each cropped image after local refinement to obtain the entire segmentation mask image; and optimize the model through a customized loss function as shown in Formula 1 to obtain a final bridge crack detection model; wherein the customized loss function is a loss function designed according to features at different scales;
[0036]
[0037] Among them, Loss represents the total loss function, represents the cross entropy loss function with step size 8, represents the cross entropy loss function with step size 2, represents the L1+L2 loss function with a step size of 2, represents the L1+L2 loss function with step size 1, represents the boundary loss function with step size 1;
[0038] The method further comprises:
[0039] The bridge crack image is detected by using the bridge crack detection model.
[0040] The above technical solution of the embodiment of the present invention is described in detail below in combination with the specific situation of the bridge crack detection model construction method based on transformer and cascade operation in the embodiment of the present invention.
[0041] To solve the problems existing in the prior art, a cascade architecture provides a potential solution, which combines downsampling and patch cropping in a staged manner for prediction and refinement. This cascade structure effectively reduces error accumulation and enhances segmentation results without increasing computing resource consumption by downsampling the global image and iteratively processing local patches. It shows advantages that traditional methods lack in various HR natural scene segmentation tasks. Considering the powerful performance of the cascade structure in representing HR details, the embodiment of the present invention adopts this promising method to achieve fine-grained segmentation of Transformers on HR crack images. However, the original cascade architecture has only been verified on natural scene datasets, and cracks and their elongated and randomly distributed patterns belong to challenging sample categories. It is difficult to capture their random features and edge details using DL models that rely on regular grid sampling. Therefore, it is necessary to customize the cascade operation logic and Transformer-based feature extraction architecture specifically for HR crack images.
[0042] In order to effectively achieve fine-grained segmentation of HR crack images while saving GPU memory, an embodiment of the present invention introduces a fine segmentation method called Cascade CATransUNet, which combines a cascade structure and coordinated attention (CA) to enhance the Transformer. The method first adopts a crack feature extraction module based on TransUNet to extract coarse-grained crack features of three different scales from the downsampled LR crack image. In order to improve the capture of fine crack features, the CA mechanism is introduced at all jump connections of TransUNet; then, two cascade refinement operations are designed based on CATransUNet to restore the missing boundary fine-grained pixels of the enhanced coarse-grained crack features. These operations keep the computational memory requirements unchanged while considering both global and local aspects; in addition, a loss function considering the boundary area is added during the model training process to alleviate the jagged effect often observed in the crack boundary prediction results. The outstanding innovation of this study is the customized cascade operation of the transformer-based crack detector, which helps the transformer architecture to achieve fine-grained prediction of high-resolution crack images in a coarse-to-fine manner. The embodiment of the present invention effectively utilizes the advantages of Transformer in fine-grained segmentation of HR crack images while maintaining acceptable GPU memory usage.
[0043] 1. Cascaded Coordinated Attention Enhancement Model TransUNet (Cascaded CATransUNet)
[0044] Cascade CATransUNet is designed for fine-grained pixel-level crack detection in HR images, and it performs segmentation at three scales with increasing levels of detail. The architecture of Cascade CATransUNet consists of two main components: (1) a segmentation framework that utilizes a U-shaped encoder-decoder with coordinate attention mechanism and SwinTransformer to capture coarse-grained features at three scales; and (2) a series of fine-grained operations that process the predictions generated by CATransUNet. It is worth noting that in the custom design of Cascade CATransUNet, special attention is paid to the accurate depiction of crack edge details. To achieve this, the loss function used in the training process amplifies the weights related to crack boundaries. The following is a comprehensive explanation of the working principles of each component integrated in Cascade CATransUNet.
[0045] 1.1 Coordinated Attention and Transformer Enhanced UNet (CATransUNet)
[0046] The UNet architecture follows a U-shaped encoder-decoder structure, where the encoder is responsible for extracting semantic features from the image and the decoder maps these features back to pixel-level predictions of the original image. UNet has become the basic architecture of many crack segmentation models due to its excellent ability to transmit contextual information. It achieves accurate semantic segmentation by effectively utilizing local image information. Therefore, in the embodiment of the present invention, a U-shaped encoder-decoder architecture is used for pixel-level crack extraction. However, when processing cracks in HR images, the simplicity of the U-shaped design brings significant limitations: first, the regular convolution and pooling operations in the encoder reduce the image resolution and separate the global semantic crack information, which may hinder the recovery of fine-grained crack details distributed on the image in the decoder; second, the UNet architecture encounters challenges when processing large-scale images because it needs to feed the entire image into the network, resulting in increased memory consumption and computing resource requirements. In order to address the above challenges, the Swin Transformer used in the embodiment of the present invention is equipped with a learnable long-range attention mechanism, which shows excellent ability in capturing dependencies between discrete small-scale cracks across considerable distances. By adopting separable parameterized kernel functions and approximate calculations, the Swin Transformer significantly reduces the complexity of attention calculations. Compared with traditional Transformer and CNN models, this leads to reduced computational and storage requirements when processing large-scale data. Therefore, in order to ensure the performance of the U-shaped encoder-decoder architecture on HR crack segmentation, the Swin Transformer replaces the original convolutional layers on the encoder side. In addition, in order to alleviate the loss of crack pixels during downsampling, a coordinate attention mechanism is introduced in the skip connection of each stage.
[0047] Finally, the U-shaped split architecture that combines the Transformer and coordinate attention mechanism is shown in Figure 2 As shown in Figure 2, the segmentation architecture is designed with multi-scale input and output, considering that larger-scale features can provide more global context information, while smaller-scale features are more suitable for capturing details and local information.
[0048] During prediction, the network receives the HR image and three corresponding coarse segmentation masks obtained from any scale of the coarse segmentation architecture, which are resized to a consistent size and then input to the network. After passing through three ResNet50 blocks, the resulting high-dimensional features are converted into multiple 2D image patches. To match the one-dimensional linear encoding of the subsequent Transformer, the size of each image patch is P×P, with a total of patches, each with C channels. A linear projection is then applied to each x using the following formula i :
[0049] Z 0 =[x 1 E;x 2 E;...x N E;]+E pos (1)
[0050] in, represents the linear projection matrix, E pos ∈R N×D Represents position encoding, Z 0 is the vector obtained after linear projection and is used as the input for the computation within the cascaded twelve Swin Transformer blocks.
[0051] 1.2. Rotary Transformer
[0052] Swin transformer blocks, such as Figure 2 As shown in (b), it includes several components W-MSA (window multi-head self-attention) and SW-MSA (shift window multi-head self-attention) which are the self-attention mechanisms used in ViT. W-MSA is window-based, while SW-MSA introduces self-attention based on moving windows to solve the limited interaction between window features. LN (layer normalization) is used for layer-by-layer normalization. In each stage, W-MSA and SW-MSA are applied alternately. The self-attention calculation process in the whole process is mathematically defined by equations (2) to (5):
[0053]
[0054] a l =MLP[LN(a l )]+a l (3)
[0055]
[0056] in, a l and a l+1 They correspond to the features generated by W-MSA (SW-MSA) and MLP in modules l and (l+1), respectively, while a l-1 Represents the features generated by module l-1. Different from the commonly used pooling operation in CNN, Swin-Transformer uses a patch merging mechanism as a self-learning mechanism for mapping window features. This method helps to extract multi-scale features, thereby improving the information representation in the model.
[0057] In the decoder part, the hidden features Z generated by Swin Transformer 0are reshaped into Hp×Wp; these features are then restored to the original input resolution through a series of upsampling operators, 3×3 convolutions, and ReLU layers, and the resulting outputs obtained with strides of 1, 2, and 8 are used as the input to the next stage.
[0058] 1.3 Coordinated Attention Mechanism
[0059] In the field of segmentation tasks, combining multi-scale feature information enriches the contextual understanding of the network and improves the accuracy of boundary prediction. These factors are crucial to achieving high-quality segmentation of high-resolution crack images. Specifically, shallow features provide higher spatial resolution and fine-grained local data, which are essential for accurately locating object boundaries and capturing tiny crack details; intermediate-level features usually include partial abstract and semantic information, which helps capture the shape, contour, and intermediate visual features of wider cracks; in contrast, deep features have a larger receptive field, contain more abstract, semantic, and global visual information, help represent semantic categories and the context of cracks, and are usually regarded as high-level features.
[0060] In order to enhance the fusion and utilization of feature information at different scales, skip connections are introduced between the encoder and decoder. However, traditional skip connections with long cross-level feature propagation paths may encounter challenges in effectively transmitting high-frequency fine detail information (e.g., fine cracks) to the decoder. Therefore, such traditional skip connections may significantly affect the overall integrity of high-resolution crack image segmentation.
[0061] To solve this problem, the embodiment of the present invention adds a coordinate attention mechanism to each jump connection layer. By considering the spatial position information in each feature map of each layer, the representation of high-frequency fine detail features is enhanced. The collaborative attention mechanism uses the spatial coordinate information to learn the relative position relationship between target pixels and adjust the weight distribution of high-frequency features, thereby enhancing the attention to each position of fine crack features. Specifically, this coordinate-based attention mechanism incorporates position information into channel attention, which allows global information to be integrated in one spatial direction while retaining precise position information in another spatial direction, such as Figure 2 As shown in (c), the attention mechanism promotes feature enhancement through two different branches: one is dedicated to enhancing features along the length dimension, and the other is dedicated to enhancing features along the width dimension. This attention mechanism has been shown to perform well in segmentation, and the output of the module can be written as Equation (6):
[0062]
[0063] Among them, i and j represent the row and column positions in the image respectively, and x c is the input associated with the cth channel, and Represent the attention weights in the length and width directions respectively.
[0064] 2. Global and local cascade refinement steps
[0065] In order to achieve accurate segmentation of HR crack images, the embodiments of the present invention draw inspiration from the ability of the human eye to roughly identify the main subject in the global field of view and then distinguish fine details in the local field of view. Therefore, two refinement processes are developed that combine the global and local perspectives and utilize the multi-scale prediction results obtained by CATransUNet.
[0066] 2.1. Global cascade operation
[0067] In the embodiment of the present invention, a global three-level cascade operation is designed and then applied to the entire image to simulate the initial stage of fine recognition by the human eye, such as Figure 3 As shown. It is worth noting that due to the limitation of GPU memory, it is not feasible to directly input HR images into CATransUNet for training or testing. In order to alleviate this hardware limitation, the long axis of the original HR image is downsampled to length L (set to 900 in the embodiment of the present invention). It should be noted that the choice of downsampling size needs to strike a balance between the GPU memory limitation and the ability of the subsequent two cascade operations to effectively recover the details lost during downsampling. The short axis is adjusted according to the original long-short axis ratio. As shown Figure 2 (a) and Figure 3 As shown in the figure, three coarse masks of the same size are fused with the RGB image and input into CATransUNet at the same time. After the first refinement operation, a refined mask with a step size of 8 is generated; the second refinement stage merges the first input coarse segmentation image with the two masks with a step size of 8 generated by the first refinement stage, and then these fused images are fed back into CATransUNet to produce outputs with a step size of 8 and 2; a similar input replacement method is adopted in subsequent levels to finally obtain a global refined segmentation image with a step size of 2 and 1. This three-level cascade structure allows CATransUNet to gradually correct the segmentation error while retaining information from the coarse segmentation map. Importantly, the multi-scale global cascade operation effectively combines deep semantic information with fine texture details, thereby enhancing the recovery of crack boundary details. In addition, as shown in Figure 4 Algorithm 1 shown provides a pseudo-code process representation of the steps involved in the global cascade refinement operation.
[0068] 2.2. Local cascade operation
[0069] After completing the global refinement, the next step is to perform local refinement, focusing on refining the local details of the HR crack segmentation image, such as Figure 5As shown in Figure 1, the local patches cropped from the HR image and their corresponding segmentation patches undergo a sequential refinement process. This sequential cropping of the HR image solves the limitation of GPU memory while retaining the global context information to a large extent. A two-level cascade operation is constructed based on CATransUNet, and the two scale outputs of the local patch (output step size OS is 2 and 1) are used for local refinement, that is, the local cascade operation is performed on each crack patch in turn, and then they are stitched into the final output of the entire image.
[0070] Specifically, the stride 2 and stride 1 outputs obtained from the last stage of the global cascade operation are upsampled to match the resolution of the original image size (W×H); these images are then cropped using a sliding window of size L×L and stride 4 / 5×L. In order to eliminate the influence of boundary artifacts, 24 pixels of edges are removed from each side of the cropped patches, and then local refinement operations are performed on the cropped patch set in a sequential manner, as follows: Figure 5 As shown in , the structure of the local cascade operation is similar to the global cascade operation; finally, the refinement results of each cropped block are stitched together to create the entire HR segmentation mask. Given the overlapping areas between adjacent patches, the segmentation results of these areas may not be consistent within each patch. To resolve this difference, the average prediction value is applied to these overlapping areas. Through the above local refinement process, segmented images of different scales can be used to accurately refine the boundary details of the crack. In addition, as Figure 6 Algorithm 2 shown provides a pseudo-code procedural representation of the steps involved in the local cascade refinement operation.
[0071] 2.3 Boundary optimization enhances joint cascade losses
[0072] In the segmentation task, the contribution of decoded features is different at different scales. Due to multiple decoding and upsampling stages, features from shallower layers show enhanced resolution, making them better at capturing fine-grained edge details; on the contrary, features from deeper layers, characterized by wider receptive fields, contain rich semantic context information, which has been shown to be helpful in identifying the main structural elements in the global image. By formulating different loss functions for features at each scale, the method proposed in the embodiment of the present invention can more effectively utilize the inherent advantages of features at different scales, thereby enhancing the refinement of the decomposition results from a global and local perspective.
[0073] According to the above explanation on designing loss functions, the embodiments of the present invention improve the existing loss functions to better identify fine cracks. For different scales, the following four loss functions are used:
[0074] 1) The average of the cross entropy loss and the dice loss of the output with a stride of 8. This loss function aims to make full use of the advantages of the cross entropy loss in capturing deep semantic information, while using the Dice loss to alleviate the negative impact of the imbalance of deep semantic feature categories on model training.
[0075] 2) The average of the L1+L2 losses of the outputs with a stride of 2. The goal of this loss function is to ensure that the residual semantic information in the intermediate layers is fully utilized by the cross entropy loss, while using the L1+L2 loss to provide an initial representation of the edge and contour details in the feature map.
[0076] 3) L1+L2 loss of the output with a stride of 1. The purpose of this loss function is to make full use of the advantages of L1+L2 loss in refining low-level topological features and achieve fine-grained recovery of edge and contour details in shallow feature maps.
[0077] 4) For the output with a stride of 1, a boundary loss function LBD is introduced to effectively capture the details of the boundary area, making full use of the network architecture. This is because the shallowest stride-1 feature shows higher resolution and clearer detailed information, thus providing a richer source of boundary guidance for network training. The boundary loss function can be written as formula (7):
[0078]
[0079] Among them, φ G is the ground truth distance map, S θ is the softmax probability output, and P represents the pixel to be predicted.
[0080] By adding the boundary loss, the total loss function can be written as (8):
[0081]
[0082] Among them, Loss represents the total loss function, represents the cross entropy loss function with step size 8, represents the cross entropy loss function with step size 2, represents the L1+L2 loss function with a step size of 2, represents the L1+L2 loss function with step size 1, represents the boundary loss function with step size 1.
[0083] System Example
[0084] According to an embodiment of the present invention, a bridge crack detection model construction system based on transformer and cascade operation is provided. Figure 7is a schematic diagram of a bridge crack detection model construction system based on transformer and cascade operation according to an embodiment of the present invention, such as Figure 7 As shown, the bridge crack detection model construction system based on transformer and cascade operation according to an embodiment of the present invention specifically includes:
[0085] The data preprocessing module 70 is used to obtain a bridge crack image and preprocess the crack image to obtain input data, specifically for:
[0086] Downsampling the long axis of the crack image to a preset length, and adjusting the short axis of the crack image according to the ratio of the long axis to the short axis of the original image;
[0087] The preset length is a length obtained according to the GPU memory limitation and the capabilities of the two cascade operations;
[0088] The construction module 72 is used to input the input data into the cascade coordinated attention enhancement model CascadeCATransUNet for training, and optimize the model through a customized loss function to obtain the final bridge crack detection model, which is specifically used for:
[0089] Input the input data into CATransUNet for the first refinement operation to generate a first refined mask image, merge the input data with the first refined mask image and feed them back to CATransUNet for the second refinement operation to generate a second refined mask image, merge the first refined mask image with the second refined mask image and feed them back to CATransUNet for the third refinement operation to generate a third refined mask image; upsample the third refined mask image, crop the upsampled image and remove the edge through a sliding window, perform a local refinement operation on the cropped image, stitch each cropped image after local refinement to obtain the entire segmentation mask image; and optimize the model through a customized loss function as shown in Formula 1 to obtain a final bridge crack detection model; wherein the customized loss function is a loss function designed according to features at different scales;
[0090]
[0091] Among them, Loss represents the total loss function, represents the cross entropy loss function with step size 8, represents the cross entropy loss function with step size 2, represents the L1+L2 loss function with a step size of 2, represents the L1+L2 loss function with step size 1, represents the boundary loss function with step size 1;
[0092] The system further comprises:
[0093] The detection module is used to detect the bridge crack image by using the bridge crack detection model.
[0094] The embodiment of the present invention is a system embodiment corresponding to the above-mentioned method embodiment. The specific operations of each module can be understood by referring to the description of the method embodiment, which will not be repeated here.
[0095] In summary, high-resolution (HR) crack image segmentation is the key to accurately diagnose bridge safety. However, accurate segmentation of cracks with slender topological structures and random distribution in HR images poses a significant challenge. In addition, the limited storage capacity of graphics cards imposes significant restrictions on HR image segmentation. To address this arduous task, an embodiment of the present invention proposes a method called cascaded CATransUNet, which consists of a coordinated attention-enhanced transformer architecture with a self-cascade design. First, a transformer-based multi-scale feature extraction architecture CATransUNet is customized, and a coordinate attention mechanism is embedded to enhance the horizontal and vertical extraction of the main contour of the crack. Then, a self-cascade refinement operation is introduced on the basis of CATransUNet to sequentially reconstruct the details of the extracted crack features from both the global and local levels. In addition, an optimized boundary loss based on a joint cascade loss function is introduced to improve the segmentation quality of the boundary area. The necessity and effectiveness of all improvements are demonstrated through ablation studies on open source crack datasets and HR crack images collected in the field, and the advanced nature of the method is confirmed in a parallel comparative experiment. The self-cascaded transformer architecture achieved impressive performance, with mIoU, mBIoU and DICE scores exceeding 89.83%, 85.78% and 96.97% on HR (4K) images, respectively. Finally, the proposed method was tested on a UAV-based bridge crack detection task. The use of Cascade CATransUNet enabled the UAV to accurately detect cracks even at a considerable distance. This improvement improved the safety and efficiency of UAV detection and ensured the flexibility of flight path selection, thus providing technical support for the promotion and application of UAV bridge crack detection technology.
[0096] Device Example 1
[0097] An embodiment of the present invention provides an electronic device, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps described in the method embodiment when executed by the processor.
[0098] Device Example 2
[0099] An embodiment of the present invention provides a computer-readable storage medium, on which a program for implementing information transmission is stored. When the program is executed by a processor, the steps described in the method embodiment are implemented.
[0100] The computer-readable storage medium in this embodiment includes, but is not limited to, ROM, RAM, magnetic disk or optical disk, etc.
[0101] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A bridge crack detection model construction method based on transformer and cascade operation, It is characterized in that include: Acquire a bridge crack image, and pre-process the crack image to obtain input data; The input data is input into the cascade coordinated attention enhancement model Cascade CATransUNet for training, and the model is optimized through a customized loss function to obtain the final bridge crack detection model.
2. The method according to claim 1, It is characterized in that The method further comprises: The bridge crack image is detected by using the bridge crack detection model.
3. The method according to claim 1, It is characterized in that Preprocessing the crack image specifically includes: Downsampling the long axis of the crack image to a preset length, and adjusting the short axis of the crack image according to the ratio of the long axis to the short axis of the original image; The preset length is a length obtained according to the GPU memory limitation and the capabilities of the two cascade operations.
4. The method according to claim 3, It is characterized in that The cascade coordinated attention enhancement model is a coordinated attention and transformer enhancement model CATransUNet that introduces two cascade operations; The coordinated attention and transformer enhancement model CATransUNet is based on the UNet architecture, which is a U-shaped encoder and decoder. The Swin Transformer is used to replace the original convolutional layer on the encoder side, and a coordinated attention CA mechanism is introduced at each jump connection between the encoder and the decoder. The two types of cascade operations include global cascade operations and local cascade operations.
5. The method according to claim 4, It is characterized in that The input data is input into the Cascade Coordinated Attention Enhancement Model Cascade CATransUNet for training, and the model is optimized through a customized loss function to obtain the final bridge crack detection model, which specifically includes: Input the input data into CATransUNet for the first refinement operation to generate a first refined mask image, merge the input data with the first refined mask image and feed them back to CATransUNet for the second refinement operation to generate a second refined mask image, merge the first refined mask image with the second refined mask image and feed them back to CATransUNet for the third refinement operation to generate a third refined mask image; upsample the third refined mask image, crop the upsampled image and remove the edge through a sliding window, perform a local refinement operation on the cropped image, stitch each cropped image after local refinement to obtain the entire segmentation mask image; and optimize the model through a customized loss function as shown in Formula 1 to obtain a final bridge crack detection model; wherein the customized loss function is a loss function designed according to features at different scales; Among them, Loss represents the total loss function, represents the cross entropy loss function with step size 8, represents the cross entropy loss function with step size 2, represents the L1+L2 loss function with a step size of 2, represents the L1+L2 loss function with step size 1, represents the boundary loss function with step size 1.
6. A bridge crack detection model construction system based on transformer and cascade operation, It is characterized in that include: A data preprocessing module, used for acquiring a bridge crack image, and preprocessing the crack image to obtain input data; A building module is used to input the input data into the cascade coordinated attention enhancement model Cascade CATransUNet for training, and optimize the model through a customized loss function to obtain a final bridge crack detection model.
7. The system according to claim 6, It is characterized in that The system further comprises: The detection module is used to detect the bridge crack image by using the bridge crack detection model.
8. The system according to claim 6, It is characterized in that The data preprocessing module is specifically used for: Downsampling the long axis of the crack image to a preset length, and adjusting the short axis of the crack image according to the ratio of the long axis to the short axis of the original image; The preset length is a length obtained according to the GPU memory limitation and the capabilities of the two cascade operations; The building blocks are specifically used for: Input the input data into CATransUNet for the first refinement operation to generate a first refined mask image, merge the input data with the first refined mask image and feed them back to CATransUNet for the second refinement operation to generate a second refined mask image, merge the first refined mask image with the second refined mask image and feed them back to CATransUNet for the third refinement operation to generate a third refined mask image; upsample the third refined mask image, crop the upsampled image and remove the edge through a sliding window, perform a local refinement operation on the cropped image, stitch each cropped image after local refinement to obtain the entire segmentation mask image; and optimize the model through a customized loss function as shown in Formula 1 to obtain a final bridge crack detection model; wherein the customized loss function is a loss function designed according to features at different scales; Among them, Loss represents the total loss function, represents the cross entropy loss function with step size 8, represents the cross entropy loss function with step size 2, represents the L1+L2 loss function with a step size of 2, represents the L1+L2 loss function with step size 1, represents the boundary loss function with step size 1.
9. An electronic device, It is characterized in that include: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, the steps of the method for constructing a bridge crack detection model based on transformer and cascade operation as described in any one of claims 1 to 5 are implemented.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores an implementation program for information transmission, and when the program is executed by a processor, the steps of the method for constructing a bridge crack detection model based on transformer and cascade operation as described in any one of claims 1 to 5 are implemented.
Citation Information
Patent Citations
Bridge concrete crack detection method under complex background based on deep learning
CN116823800A
Cited By
Method and system for detecting cracks of flow passage component of hydroelectric generating set
CN120214076A
Bridge crack intelligent identification method based on efficient sampling and multi-scale fusion
CN120236198A
