Bridge crack disease detection method and device based on crack self-segmentation model

By using a bridge crack detection method based on a crack self-segmentation model, and by automatically generating a mask using a cue generator and an image encoder-decoder, the problems of low efficiency and low accuracy in bridge crack detection are solved, and rapid and accurate bridge crack detection is achieved.

CN117809082BActive Publication Date: 2026-11-20HUNAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311706889.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-13
Publication Date
2026-11-20
Estimated Expiration
2043-12-13

AI Technical Summary

Technical Problem

Existing technologies for bridge crack detection suffer from low detection efficiency, low accuracy, and poor anti-interference capabilities, making it difficult to quickly and accurately identify crack defects against complex bridge image backgrounds.

Method used

A detection method based on a crack self-segmentation model is adopted. The bridge surface image is segmented by a pre-trained crack self-segmentation model. A prompt generator is used to automatically generate prompt words to clarify the segmentation task target. A mask is generated to predict the crack location. The crack identification and segmentation are performed by combining an image encoder and a mask decoder.

Benefits of technology

It enables rapid and accurate detection of bridge cracks, improves detection efficiency and accuracy, and can be applied in various scenarios, making it suitable for crack detection of various bridge configurations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117809082B_ABST
    Figure CN117809082B_ABST
Patent Text Reader

Abstract

The application discloses a bridge crack disease detection method and device based on a crack self-segmentation model, and the method steps include: collecting the surface image of the measured bridge, inputting into the crack self-segmentation model trained in advance, and identifying and segmenting the target image containing cracks; extracting the information of the cracks from the target image containing the cracks; the crack self-segmentation model identifying and segmenting the target image containing the cracks includes: segmenting and encoding the input surface image through an image encoder, extracting attention features embedded with relative position features and multiple intermediate features, and generating image embedding; processing each intermediate feature by a prompt generator, obtaining multiple groups of prompt words and corresponding semantic categories, determining the crack target category, and generating prompt embedding; and generating a mask-containing image according to the image embedding and the prompt embedding by a mask decoder. The application has the advantages of simple implementation method, high detection efficiency and precision, strong anti-interference performance and the like.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of bridge inspection technology, and in particular to a method and apparatus for detecting bridge crack defects based on a crack self-segmentation model. Background Technology

[0002] Bridges are susceptible to damage from natural environments and external forces, including cracking, spalling, and steel reinforcement corrosion. Cracks are narrow, elongated gaps that form after a structure breaks down; in digital images, cracks typically appear as long, narrow openings. Crack width plays a crucial role in assessing the severity of the crack and its impact on the structure, and is one of the most important parameters in quantitative crack detection results.

[0003] For object detection, existing technologies typically employ edge-detection-based image processing methods and deep learning algorithms such as the two-stage R-CNN algorithm and the one-stage YOLO algorithm based on instance segmentation. However, these algorithms are often time-consuming, requiring extensive model training for specific target scenarios. It's difficult to balance training efficiency and accuracy, and they are limited by dataset size. Furthermore, detection models from different domains are difficult to directly transfer to other domains. In engineering practice, bridge images present complex backgrounds and diverse scenes. For example, a concrete bridge may simultaneously exhibit defects such as exposed rebar, cracks, and spalling. Different bridge sections may also be affected by noise interference from strong light and shadows. Traditional object detection and recognition algorithms require building separate detection models for each type of defect, which is not only complex and time-consuming for image processing and model training, but also results in low detection efficiency, low actual detection accuracy, and poor anti-interference capabilities. In short, traditional object detection and recognition algorithms struggle to achieve fast and accurate detection and recognition of bridge cracks. Summary of the Invention

[0004] The technical problem to be solved by the present invention is to provide a method and device for detecting bridge crack defects based on a crack self-segmentation model, which is simple to implement, has high detection efficiency and accuracy, and strong anti-interference ability, in response to the technical problems existing in the prior art.

[0005] To solve the above-mentioned technical problems, the technical solution proposed by this invention is as follows: A method for detecting bridge crack defects based on a crack self-segmentation model, comprising the following steps: Acquire surface images of the bridge under test; The acquired surface image is input into a pre-trained crack self-segmentation model, which then identifies and segments the target image containing cracks from the current surface image. Extract crack information from the segmented target image containing cracks; The training data for the crack self-segmentation model includes mask markers to cover the target region through a mask; The steps of the crack self-segmentation model in identifying and segmenting a target image containing cracks from a current surface image include: The input surface image is segmented and encoded by an image encoder, and attention features and multiple intermediate features embedded with relative position features are extracted to generate image embeddings. The prompt generator processes each intermediate feature to learn the semantic features represented in each intermediate feature, obtains multiple sets of prompt words and corresponding crack semantic categories, determines the crack target category with crack semantic features based on each set of prompt words and crack semantic categories, and generates prompt embeddings. The mask decoder performs mask decoding based on the image embedding and the cue embedding, and segments the foreground module to generate an image containing the mask, which is the target image containing the crack. During the decoding process, the cue embedding is used to predict the mask position to generate a mask for the image background area.

[0006] Furthermore, the step of segmenting and encoding the input surface image using an image encoder, extracting attention features embedded with relative position features and multiple intermediate features, and generating an image embedding includes: Initialize and configure the image encoder; After the current surface image is input into the image encoder, the input image is cut into multiple image sequence blocks; Each image sequence block is flattened into a one-dimensional vector after dimensional mapping to convert spatial geometric information into semantic information. The mapped vector is then embedded with a positional code to preserve positional information. The positional encoding and the mapped vector are input together into the encoder layer to generate an image embedding. The Transformer decoder is used for decoding. During the decoding process, a multi-head attention module is used for feature extraction. The features extracted from all heads are merged according to the corresponding configured weights to obtain attention features embedded with relative position features and multiple intermediate features.

[0007] Furthermore, the Transformer decoder includes multiple Encoder Block layers and a Neck layer. The Encoder Block layer includes a normalization layer, a multi-head attention layer, and an MLP layer arranged sequentially. The MLP layer contains two linear layers and an activation layer to solve for the connection weights and biases between different layers. The Neck layer includes two convolutional layers and two normalization layers to achieve the transition between input and output information and output the final image information.

[0008] Furthermore, the step of processing each intermediate feature by the prompt generator to learn the semantic features represented in each intermediate feature layer includes: A feature aggregation module is set up to process the acquired intermediate features. The feature aggregation module samples the input features through a downsampling layer and then provides them to a two-dimensional convolutional layer for convolution operation. Starting from the second two-dimensional convolutional layer, the sampling result of the current layer is accumulated with the convolution result of the previous two-dimensional convolutional layer as the input of the current two-dimensional convolutional layer. The final convolution operation result is fused by a fusion convolutional layer and outputs a fused feature value. Based on the fused feature values, an anchor-based region proposal network is used to generate candidate bounding boxes; The candidate bounding boxes are obtained by RoI pooling to obtain the visual feature representation of a single object from the location-encoded feature map; A semantic awareness head, a location awareness head, and a cue awareness head are derived from the visual feature representation. The semantic awareness head determines the target category, the location awareness head establishes a location matching criterion between the generated cue and the target instance mask, and the cue awareness head generates a cue embedding.

[0009] Furthermore, the system also includes a prompt encoder module in the prompt generator for marking preprocessing. The marks include point marks, box marks, and mask marks. The point marks are used to outline the target contour, the box marks are used to mark the target position with a box, and the mask marks are used to cover the target area with a mask. The prompt encoder module performs prompt encoding preprocessing on the coordinates of the marked points and the marked boxes, and transforms the specific position of the marked point coordinates into a proportional position to achieve position embedding.

[0010] Furthermore, the step of generating a masked image by performing mask decoding based on the image embedding and the cue embedding by the mask decoder includes: Image embedding and cue embedding are input into the Transformer module of the mask decoder to fuse cue information features with image features to obtain the initial mask src; The initial mask src is upsampled to obtain a prediction mask with position encoding; The predicted mask is input into a multilayer perceptron for forward propagation. During forward propagation, weights and biases are used for weighting, and the gradient is calculated using the propagation results and then backpropagated. After multiple iterations and optimizations, the error between the real mask and the predicted mask is minimized, resulting in the final mask.

[0011] Furthermore, the training process for the crack segmentation model also includes: The inverse time decay learning strategy is determined based on the weight decay rate, and the initial learning rate function is set: In the formula, represents the learning rate at the t-th training round, WDR is the weight decay rate, and t represents the number of training rounds; After multiple training sessions, a learning rate interval is obtained. The logarithmic uniformity of the learning rate is used to calculate the logarithmic value of the learning rate interval and the learning rate is randomly assigned and tested to determine the optimal learning rate. During training, if the model accuracy is still less than the preset accuracy after a specified number of consecutive epochs, the current learning rate will be adjusted using a dynamic adjustment factor.

[0012] Furthermore, the step of extracting crack information from the identified and segmented target image containing cracks includes: The image is segmented into foreground and background, and the boundary threshold that maximizes the variance between the foreground and background classes is found according to the preset threshold conditions to highlight the specific outline of the target crack, thus obtaining the segmented image. The original shape of the crack is reconstructed using the median transformation method on the segmented image. The crack skeleton is then pruned using the discrete evolution method to remove false branches caused by the serrated shape of the crack and remove intersections, thus obtaining the final crack skeleton. Establish a local coordinate system in the orthogonal direction of the crack skeleton to obtain the crack propagation direction. Find the relative point group on both sides of the skeleton point and the orthogonal point group that is closest to the orthogonal vector and opposite to each other. Measure the crack width based on the shortest Euclidean distance between the candidate points. The actual geometric width of the crack is obtained based on the measured crack pixel width and the ground sampling interval, where the ground sampling interval is the ground size corresponding to a single pixel in the digital image.

[0013] Furthermore, a mobile carrier equipped with an image acquisition device is used to inspect the bridge under test. The image acquisition device acquires surface images of the bridge using oblique photography, and the ground sampling interval of the image acquisition device is calculated under both oblique and orthogonal conditions. The ground sampling interval under orthogonal conditions is... The following formula is used to calculate: Ground sampling interval under inclined conditions The following formula is used to calculate: in, H Indicates the drone's flight altitude. sIndicates the pixel size of the image acquisition device. f This refers to the focal length of the image acquisition device.

[0014] A bridge crack defect detection device based on a crack self-segmentation model includes a processor and a memory. The memory is used to store a computer program, and the processor is used to execute the computer program to perform the method described above.

[0015] Compared with the prior art, the advantages of the present invention are as follows: 1. This invention pre-constructs and trains a prompt-driven crack self-segmentation model, which is then used to detect and segment bridge surface images. The model extracts different crack defect features, and the prompt generator in the model automatically generates prompts based on the image content to clarify the specific task target to be segmented. Then, it returns an effective segmentation mask to predict the mask (crack) location. This can quickly and accurately segment images containing masks (cracks), effectively improving the segmentation ability of crack defects and ensuring the segmentation effect and detection capability of crack defects in bridge facilities.

[0016] 2. Based on prompt words, this invention can achieve zero-shot learning for new datasets and task requirements. Therefore, it can quickly complete training on a large scale of data and generalize to downstream tasks, improving the model's generalization ability. Under different scenario requirements, even if the crack category is not clear or multiple crack types may be involved, it can accurately detect objects containing at least one reasonable mask (crack). It can be applied to detect crack defects in bridges with different configurations and spans without having to build multiple complex detection models separately. Attached Figure Description

[0017] Figure 1 This is a schematic diagram illustrating the implementation process of the bridge crack defect detection method based on the crack self-segmentation model in this embodiment.

[0018] Figure 2 This is a schematic diagram illustrating the principle of ground sampling interval calculation in this embodiment.

[0019] Figure 3 This is a schematic diagram of the structural principle of the feature aggregation module in this embodiment.

[0020] Figure 4 These are schematic diagrams of two types of crack masks identified in specific application embodiments of the present invention.

[0021] Figure 5 This refers to the crack width information detected in a specific application embodiment of the present invention. Detailed Implementation

[0022] The present invention will be further described below with reference to the accompanying drawings and specific preferred embodiments, but this does not limit the scope of protection of the present invention.

[0023] This invention pre-constructs and trains a prompt-driven crack self-segmentation model, CrackSAM, to detect and segment bridge surface images. The model extracts different crack features, and a prompt generator within the model automatically generates prompts based on the image content, clarifying the specific segmentation target. This returns an effective segmentation mask to predict the mask (crack) location, enabling rapid and accurate segmentation of images containing the mask, i.e., image regions containing bridge cracks. This effectively improves the segmentation capability of cracks and ensures the segmentation effect and detection capability of cracks in bridge facilities.

[0024] like Figure 1 As shown, the steps of the bridge crack defect detection method based on the crack self-segmentation model in this embodiment include: Step 1: Acquire surface images of the bridge under test.

[0025] In this embodiment, a mobile platform such as a drone or robot is used to carry an image acquisition device (high-definition camera, etc.) to inspect the bridge under test. For example, the drone hovers at a safe distance from the bridge structure, and the image acquisition device acquires surface images of the bridge under test using oblique photography. The ground sampling interval (GSD) is calculated according to the crack width requirements to obtain a clear bridge surface image of appropriate size.

[0026] Ground sampling interval represents the ground size corresponding to a single pixel in a digital image, allowing calculation of the actual size represented by each pixel in the real world. Taking drone inspection as an example, such as... Figure 2 As shown, based on the actual flight altitude H and the camera tilt angle... In addition to the zoom factor X, the ground sampling interval GSD of the images captured by the camera on the drone or other flying equipment can be calculated. The specific steps are as follows: Step 1.1. Calculate the camera pixel size.

[0027] A pixel is the smallest photosensitive unit on a camera chip. Each pixel corresponds to one pixel in an image. The actual distance represented by one pixel in the captured image can be calculated based on the pixel size. The formula for calculating the pixel size 's' is as follows: (1) Here, CMOS represents the sensor size, and dpi represents the effective pixel size. For the sensor height dimension, This represents the image height.

[0028] Step 1.2. Calculate the focal length of the camera lens.

[0029] When photographing cracks in a bridge, the airborne camera needs to maintain a certain distance from the bridge structure and use the zoom function to capture an image of appropriate size and sufficient clarity.

[0030] Camera zoom focal length The specific calculation formula is as follows: (2) In the formula, f is the focal length of the zoom camera. This is the minimum focal length for a zoom camera. For zoom cameras, the equivalent focal length is... This is the minimum equivalent focal length for a zoom camera. This is the equivalent focal length for a wide-angle camera. This is the zoom ratio of a zoom camera, based on the equivalent focal length of a wide-angle camera.

[0031] Step 1.3. Calculate the ground sampling interval under tilted or orthophoto conditions.

[0032] Orthophotos are remote sensing images with orthogonal projection properties. When taking aerial photos, the camera is perpendicular to the ground, and the captured images can be projected onto the ground using orthogonal projection.

[0033] Ground sampling interval corresponding to an orthophoto image with sensor size as the standard for: (3) In the formula, H is the actual flight altitude of the aircraft.

[0034] To ensure a sufficiently wide field of view and safety during bridge inspections, oblique photography is used. The ground sampling interval for the oblique images is... The ground sampling interval of the orthophoto image can be used to determine the orthophoto. The calculation yields the following result: (4) (5) In the formula, The camera tilt angle represents the angle between the tilted plane and the vertical plane. The tilt angle of the gimbal.

[0035] Calculate the ground sampling interval according to the steps described above. GSD Then, the ground sampling interval can be used subsequently. GSD The actual crack width in the image is calculated.

[0036] In a specific application embodiment, during the inspection of a bridge by a drone equipped with a high-definition camera, in order to ensure the safe flight of the drone, it is necessary to maintain a certain safe distance from the bridge structure surface being photographed. The flight height limit for identifying the crack width under different accuracy requirements is calculated based on the ground sampling interval of the camera, that is, the minimum crack identification width row height corresponding to different spatial resolution lenses, as shown in Table 1.

[0037] Furthermore, when drones are used for bridge inspection, by generating a strip-shaped loop along the centerline within a designated area, the number of tilted photos can be significantly reduced compared to traditional loop loops, thus improving the quality of bridge surface image acquisition.

[0038] Step 2: Input the acquired surface image into the pre-trained crack self-segmentation model, and the crack self-segmentation model will identify and segment the target image containing cracks from the current surface image.

[0039] In this embodiment, the core architecture of the crack self-segmentation model CrackSAM includes a prompt generator, an image encoder, and a mask decoder. The prompt generator, by introducing a lightweight feature aggregation module, uses a crack disease dataset as training material to generate prompt words for the model, thus obtaining the basic model CrackSAM, which can automatically acquire semantic instance-level masks. The working principle of the CrackSAM model is specifically represented by the following expression: (6) In the formula, This represents the original image, which is a color image with a certain height and width, and 3 channels. The height is H, the width is W, and the number of channels is 3. This represents the image features initially obtained by the first-layer image encoder, which have the same information dimension as image I. Representing the intermediate feature map, in It now includes semantic information on top of the existing features. By the second-layer feature aggregator and prompt generator After processing, multiple sets of prompts are generated. and corresponding semantic categories M corresponds to the predicted mask.

[0040] In this embodiment, the specific steps for crack image segmentation using the CrackSAM model described above include: Step 2.1. Segment and encode the input surface image using an image encoder, extract attention features embedded with relative position features and multiple intermediate features, and generate an image embedding; Step 2.2. The prompt generator processes each intermediate feature to learn the semantic features represented in each intermediate feature, obtains multiple sets of prompt words and corresponding crack semantic categories, determines the target category with crack semantic features based on each set of prompt words and crack semantic categories, and generates a prompt embedding. The prompt may specifically include spatial or textual information of the identified object, etc. Step 2.3. The mask decoder performs mask decoding based on image embedding and cue embedding, segments the foreground module to generate an image containing the mask, which is the target image containing the crack. During the decoding process, cue embedding is used to predict the mask position to generate a mask for the background area of ​​the image.

[0041] In this embodiment, the specific steps of segmenting and encoding the input surface image using an image encoder to obtain attention features embedded with relative position features and multiple intermediate features include: Step 2.1.1. Initialize the image encoder configuration; Step 2.1.2. After inputting the current surface image into the image encoder, the input image is cut into multiple image sequence blocks; Step 2.1.3. After dimensional mapping of each image sequence block, flatten it into a one-dimensional vector to convert spatial geometric information into semantic information, and embed the mapped vector into a positional code to preserve positional information; Step 2.1.4. Input the position encoding and the mapped vector together into the encoder layer to generate the image embedding; Step 2.1.5. Use the Transformer decoder for decoding. During the decoding process, feature extraction is performed through a multi-head attention module. The features extracted from all heads are merged according to the corresponding configured weights to obtain attention features embedded with relative position features and multiple intermediate features.

[0042] In a specific application embodiment, the basic network of the image encoder is composed of a Vision Transformer (ViT) network. The structural composition of the ViT network and its processing in feature extraction are as follows: ① Module initialization: This involves initial configuration of the image encoder module, including parameters such as the number of topic encoders, the number of image encoding channels, the standard size of the input image, the channel scaling ratio in the multilayer perceptron (MLP) module, the number of normalization layers, the number of multi-head attention heads, the patch size, the bias weights of the qkv fully connected layers, the window size, and the output channels.

[0043] ② Patch Embedding Layer: This corresponds to a convolutional layer with a kernel size of 16×16 and a kernel channel of 3×768. It performs convolution operations to transform the input image attributes (batch_size, channel, Height, wide) into (batch_size, n, embed_dim). The specific formula can be expressed as: (7) (8) The above formula represents dividing an image with width W, height H, and number of channels C into n blocks, each block having a size of embed_dim. The encoding of each semantic element is mapped to a feature vector of dimension embed_dim. The value of n changes with the input image size, and the value of embed_dim can be changed according to the set patch size and image channels. This allows the spatial geometric information of the image to be converted into semantic information for use by the Transform module. In this embodiment, embed_dim is specifically set to 1, meaning that the encoding of each semantic element is mapped to a one-dimensional feature vector.

[0044] ③ Position Embedding layer: This corresponds to a map with the same number of rows as the input sequence. Each row represents a vector with the same dimension as the input sequence tokens. The vector is summed with the position encoding as the output, while the dimension remains unchanged.

[0045] ④ Transformer Decoder Decoding: This includes multiple repeating Encoder Block layers, which are ultimately processed by a Neck layer before outputting the image information. The Encoder Block layers consist of a normalization layer, a multi-head attention layer, and an MLP, from low to high. After normalization, the information input to the patch embedding layer is adjusted from its original size H*W to S*S by the partition block to embed the relative positions in subsequent processes. Finally, the unpartition block restores the original size.

[0046] For the features F(N×E) input to the multi-head attention module, the nn.Linear function is used to further extract features to obtain the output feature v(value). To consider the influence of the proximity and positional relationships among the N features on the output feature v, an additional weight w is set to weight the output feature v, so that any value of v takes into account the mutual influence between the N token features. The weight w and feature v together produce the output. Combining the outputs of all heads yields the final output, which is the attention feature embedded with relative positional features.

[0047] The MLP layer contains two linear layers and one activation layer, which solves for the connection weights and biases between different layers. The Neck layer contains two convolutional layers and two normalization layers, which act as a transition layer between the input and output information.

[0048] In this embodiment, the specific steps by which the prompt generator processes each intermediate feature to learn the semantic features represented in each intermediate feature layer include: Step 2.2.1. Set up a feature aggregation module to process the acquired intermediate features. The feature aggregation module samples the input features through a downsampling layer and then provides them to a two-dimensional convolutional layer for convolution operation. Starting from the second two-dimensional convolutional layer, the sampling result of the current layer is accumulated with the convolution result of the previous two-dimensional convolutional layer and used as the input of the current two-dimensional convolutional layer. The final convolution operation result is fused by a fusion convolutional layer and outputs the fused feature value. Step 2.2.2. Generate candidate bounding boxes using an anchor-based Region Proposal Network (RPN) based on the fused feature values; Step 2.2.3. Obtain the visual feature representation of a single object from the location-encoded feature map by using RoI pooling on the candidate bounding boxes; Step 2.2.4. Derive the semantic perception head, the location perception head, and the cue perception head from the visual feature representation. The semantic perception head determines the target category, the location perception head establishes a location matching criterion between the generated cue and the target instance mask, and the cue perception head generates the cue embedding P.

[0049] In a specific application embodiment, the basic ProGen network of the prompt generator module is implemented in the following manner: Set up a lightweight feature aggregation module in the prompt generator, such as Figure 3 As shown, the input is received by the feature aggregation module. The image input features F are sampled by the downsampling layer, then accumulated after convolution operation by the two-dimensional convolutional layer, and finally the fused feature value is output by the fusion convolutional layer. .

[0050] The working process of the prompt generator module can be represented by the following formula: (9) In the formula, This represents the feature values ​​after sampling. The intermediate feature values ​​are represented by a and b, respectively, after processing by the RPN network and the ROI pool. Indicates the sampling layer. Indicates a convolutional layer. This represents the anchor-based Region Proposal Network (RPN) layer. This indicates the derivation of the sensory head layer. This represents the pooling layer.

[0051] Accordingly, the model's loss includes the binary classification and localization losses of the RPN network, the classification loss of the semantic header, the regression loss of the localization header, and the segmentation loss of the SAM mask decoder. The total loss can be expressed as: In this embodiment, a cue encoder is also included in the cue generator for preprocessing the markers. The markers in the pre-trained data include three types: points, boxes, and masks. Points delineate the target outline by connecting points that are closed at both ends; boxes indicate the approximate location of the target; and masks cover the target area with a mask. The coordinates of the marker points and boxes are preprocessed using cue encoding, converting specific coordinates into relative proportional coordinates to obtain data indicating the marker location for output.

[0052] In a specific application embodiment, the ProEnco network, the basic network of the cue encoder in the model, mainly processes three types of cues—point markers, bounding box markers, and mask markers—during feature extraction. The steps include: ① Module initialization: This involves initial configuration, including parameters such as the number of encoding channels (consistent with the previously acquired image encoding channels), the standard size of the input image, the number of training samples, the training step size, and the device model.

[0053] ② Marker preprocessing: The number of channels in the input image is changed from 2 to the number of channels in the cue encoding, and then position encoding weights are assigned to convert the specific coordinates into proportional coordinates between [0~1], thus completing the image segmentation calibration.

[0054] ③ Preprocessing of bounding boxes: Change the number of channels in the image to reduce its dimensionality to the number of channels for cue encoding, and then assign positional encoding weights to transform the specific coordinates into proportional coordinates between [0~1], thus completing the image segmentation calibration.

[0055] ④ Mask Preprocessing: The output size of the mask is four times the size of the image encoding output by the image encoder module. Therefore, to maintain consistency, a 4x downsampling is required. If there is no mask input, the no_mask_embed encoding is expanded to the same size as the image encoding to replace the mask.

[0056] In this embodiment, the step of generating a masked image by performing mask decoding based on image embedding and cue embedding by a mask decoder includes: Step 2.3.1. Input the image embedding and the cue embedding into the Transformer module of the mask decoder to fuse the cue information features with the image features and obtain the initial mask src; Step 2.3.2. Upsample the initial mask src to obtain a prediction mask with position encoding; Step 2.3.3. By calculating the weighted weights, the mask probability for each location in the image is calculated to obtain the final mask.

[0057] In specific application embodiments, the basic network MaskDeco of the mask decoder mainly includes the following steps in feature extraction: ① Module initialization: This involves initial configuration, including parameters such as the number of masks required for mask ambiguity prediction, the mask prediction transformer network configuration, the natural language processing depth, and the natural language processing hidden channels.

[0058] ② Transformer Decoding: This consists of multiple stacked bidirectional attention blocks and multi-head attention blocks. The bidirectional attention block comprises a normalization layer, a multi-head attention layer, and a multilayer perceptron (MLP), used to fuse the cue information features from the cue encoder with the image information features from the image encoder. In the ViT network, the attention block involves a fully connected layer receiving one input and splitting the result into q, k, and v. In the mask decoder's Transformer decoding, the attention block receives three inputs from three fully connected layers to obtain q, k, and v.

[0059] ③ Upsampling layer sampling: This corresponds to a transposed convolutional layer with 2x upsampling, followed by a standard layer activation unit and a linear layer activation unit, used to add positional encoding to the prediction mask predict_masks.

[0060] ④ Mask Generation and Evaluation: Mask prediction and generation are accomplished through a multilayer perceptron. The multilayer perceptron receives the predicted mask as input and performs forward propagation using matrix multiplication, ReLU activation function, and sigmoid activation function. During forward propagation, specific initial weights are set based on the narrow and delicate characteristics of the crack target. These weights are then weighted with the bias values ​​for calculation. The final propagation result is used to calculate the gradient and backpropagation is performed. After multiple iterations and optimizations, the error between the real mask and the predicted mask is minimized. After processing by the multilayer perceptron, the initial coarse mask (src) is transformed into a mask.

[0061] ⑤ Mask Evaluation: The generated mask is passed through a multilayer perceptron containing hidden linear layers, and the mask IoU score is calculated. IoU is the best indicator for evaluating the overlap between the predicted result and the real result, and can intuitively reflect the recognition accuracy of the trained model for the target.

[0062] In this embodiment, during the training of the crack segmentation model, the confidence scores (IoU) of different masks are calculated, the model parameters or model configuration are adjusted, and a linear combination of focus loss and dice loss is used for supervised prediction. This results in the prediction target that is closest to the true label result of the target, i.e., the minimum loss, and the most effective and accurate mask result is output to complete the model training.

[0063] In this embodiment, after training the crack segmentation model, the model parameters are also adjusted. The parameters include: number of key prompts KP, number of learnable tokens NT, learning rate, batch size, training epoch, weight decay rate, etc.

[0064] Overfitting can easily occur during model training for crack segmentation. Specifically, the accuracy on the training set decreases instead of increasing, while the accuracy on the validation set remains unchanged. This embodiment addresses this by introducing a weight decay normalization coefficient as compensation for the weight decay rate. The specific steps include: The inverse time decay learning strategy is determined based on the weight decay rate, and the initial learning rate function is set: (10) In the formula, represents the learning rate at the t-th training round, WDR is the weight decay rate, and t represents the number of training rounds; After multiple training sessions, a learning rate interval was obtained. The logarithmic uniformity of the learning rate was used to calculate the logarithm of the learning rate interval and the learning rate was randomly assigned and tested to determine the optimal learning rate. During training, if the model accuracy is still less than the preset accuracy after a specified number of consecutive epochs, the current learning rate will be adjusted using a dynamic adjustment factor.

[0065] Considering the imbalance between foreground and background in cracked images, the loss functions for foreground and background need to have increased weighting coefficients to prevent foreground elements from being overwhelmed by the background. Preferably, the relevant hyperparameters are set as follows: =0, =0.25, which can maximize the preservation of crack element characteristics to a certain extent.

[0066] After establishing the CrackSAM model, a dataset of crack images with masks needs to be prepared, stored in COCO annotation format, and divided into training and test sets. Preliminary segmentation training is performed using the training set, and the segmentation effect is evaluated based on the test set evaluation metrics. Finally, the segmentation accuracy is determined on the validation set. Traditional methods typically assign equal weights to the feature values ​​obtained from different parts of the crack target. However, the information contained in the crack image itself is not equally important. For example, the crack width at the end of the crack is thinner, the middle of the crack may extend into weak branch cracks, and the geometric shapes of transverse cracks, vertical cracks, diagonal cracks, and block cracks have different patterns. Therefore, the feature information of different types of cracks and different parts of the crack in an image is not equally important. This embodiment further optimizes the model through a process of training, loss, and iteration, so that the most reasonable weight values ​​can be configured. That is, for a certain type of crack, the semantic features of a specific part of the crack can be more discriminative, thereby improving the recognition accuracy of different cracks.

[0067] Based on structural monitoring knowledge, this example sets initial crack weights that conform to engineering experience and mechanical theory. By training the weight files using a large set of masks (image datasets with cracks), the model can segment crack objects in any image without additional training. This improves the model's generalization ability to handle various possible crack defect segmentation and detection. Only minor adjustments to the model parameters are needed to achieve segmentation and detection of various types of crack defects.

[0068] In a specific application embodiment, the trained CrackSAM model is used to detect and segment cracks in the collected images of bridge facilities. The specific implementation process is as follows: ① Input the image to be tested: The image is uniformly processed into an RGB three-channel image, and the image size and channel order are adjusted. The padding method is used to fill the scaled image to meet the input requirements of the neural network and then batch input is performed.

[0069] ② Image Embedding Generation: The image encoder segments the input image into blocks, then flattens them into one-dimensional vectors after dimensionality mapping. The spatial geometric information is converted into semantic information. Positional codes are embedded to preserve positional information. These positional codes, along with the one-dimensional vectors, are input into the encoder layer to generate the image embeddings, which are then output. The mapped vector is summed with the corresponding dimensional positional codes to obtain coarse-grained attention features, including relative positional characteristics. and multiple intermediate features Image feature data, etc.

[0070] ③ Image cues generation: The cues generator processes the acquired intermediate features by introducing a lightweight feature aggregation module. Without increasing computational complexity, it learns the semantic features represented in various intermediate feature layers of the Vision Transformer backbone network, obtains multiple sets of cues and their corresponding semantic categories, outputs the cues embedded to determine the crack target category, and intelligently generates the cues embedding required by the mask decoder.

[0071] ④ Generating Possible Masks: Image embedding and cue embedding are input into the transformer module of the mask decoder, where cue information features are fused with image features to obtain a coarse mask (src). Then, through upsampling, weighted calculation, multilayer perceptron mapping, and linear dynamic classification, the probability of a possible mask at each location in the image is calculated. Using the cue embedding from the cue generator, a mask is automatically generated for the image background region in the mask decoder, segmenting the foreground module (cracks) to complete the crack identification and segmentation of the image under test. Extracting the spatial coordinates of the segmentation bounding box yields a foreground image containing only the crack outline region. In a specific application embodiment, the two crack mask images obtained are shown below. Figure 4 As shown in the figure, (a) and (b) correspond to two different types of cracks detected.

[0072] Step 3: Extract crack information from the identified and segmented target image containing cracks.

[0073] Step 3.1. Perform foreground and background segmentation on the image, and find the boundary threshold that maximizes the variance between the foreground and background classes according to the preset threshold conditions to perform segmentation, so as to highlight the specific outline of the target crack and obtain the segmented image. Step 3.2. Reconstruct the original shape of the crack using the median transformation method on the segmented image, and prune the crack skeleton using the discrete evolution method to remove false branches caused by the serrated shape of the crack and remove intersections to obtain the final crack skeleton. Step 3.3. Establish a local coordinate system in the orthogonal direction of the crack skeleton to obtain the crack propagation direction. Find the relative point group on both sides of the skeleton point and the orthogonal point group that is closest to the orthogonal vector and opposite to each other. Measure the crack width based on the shortest Euclidean distance between the candidate points. Step 3.4. Obtain the actual geometric width of the crack based on the measured crack pixel width and the ground sampling interval.

[0074] Step 3.5. After the disease image is input into the model, the model will understand each possible instance in the image at the semantic level, providing basic information about the location, category, and morphology of the disease. Combining the ground sampling interval of images captured by cameras mounted on drones or other mechanical equipment, high-precision crack geometric widths are obtained. For the acquired crack objects, a distance calculation method based on the crack skeleton is used to accurately measure the crack width. This achieves an integrated intelligent detection process for cracks, from automatic detection and recognition, edge contour extraction, to quantitative width measurement.

[0075] In a specific application embodiment, after the CrackSAM model identifies and segments the cracks in the image to be detected, and then locates them, digital image processing methods are used to post-process the crack image to extract crack morphology and width information. This includes thresholding of the background, crack skeleton extraction and preprocessing, skeleton preprocessing, and crack width vectorization extraction and measurement. The specific steps include: ① The image is divided into two parts, background and foreground, according to grayscale characteristics. The threshold that maximizes the variance between the two classes is found based on threshold conditions to minimize the probability of misclassification, reduce noise interference and information data in the image, and highlight the specific outline of the target crack.

[0076] An image can be viewed as a fixed-size matrix, where each value is a pixel value in the image, ranging from (0, 255). The segmentation thresholds for foreground and background can be determined based on their respective proportions in the entire image and their average gray levels. The overall average gray level can be calculated by finding the maximum inter-class difference, which can effectively segment and define the background and foreground, highlighting the specific outline of the crack in the target.

[0077] ② The original shape of the crack is reconstructed using the median transformation method in the image obtained in step ①. ① Using the skeleton nodes as the maximum center circle helps to measure each end branch and locate local edges. Due to its jagged appearance, the crack is prone to generating false branches. The discrete evolution method is used to prune the crack skeleton, removing false branches caused by the jagged shape of the crack. The intersections of multiple cracks or crack branches may interfere with the secondary beam of crack width. The node redefinition method is used to remove intersections. Furthermore, weights are assigned by identifying the contribution of each end branch to the reconstructed shape, and compared with a set threshold. Branch nodes below the threshold are removed, and finally, new fitting points are generated, and all crack ends are pruned.

[0078] ③ The intersections of multiple cracks or crack branches may interfere with the crack width measurement. This invention uses a node redefinition method to average the intersections in the image obtained in step ①. At the intersections, a midpoint circle with a perimeter intersecting the crack boundary at more than a certain value is used for fitting, improving the measurement accuracy at crack intersections. Specifically, a local coordinate system is established in the orthogonal direction of the crack skeleton to obtain the crack propagation direction within a small area, and the shortest achievable distance point is found. To minimize errors, a group of relative points close to both sides of the skeleton point and a group of orthogonal points closest to the orthogonal vector but opposite to each other are divided. The crack width is determined based on the shortest Euclidean distance between the candidate points. To reduce the image of repeated skewed measurements during crack propagation, a balance coefficient is introduced to balance the crack widths measured by the two groups of points. An empirical value of the balance coefficient that is closest to the actual result is determined experimentally.

[0079] ④ Multiply the crack pixel width obtained in step ③ by the ground sampling interval obtained in step (1) to obtain the actual geometric width of the crack, as shown in the following formula: (11) In the formula, W is the actual width of the crack, and Pix is ​​the width of the crack pixels in the image.

[0080] By following the steps described above, an integrated intelligent detection system can be achieved, encompassing automatic detection and identification of cracks, edge contour extraction, and quantitative width measurement. The calculated crack information can then be used to assist in determining appropriate crack repair strategies.

[0081] In a specific application embodiment, the crack width information detected using the method described above in this embodiment is as follows: Figure 5 As shown.

[0082] To verify the effectiveness of the model described above, this embodiment specifically adopts the following evaluation metrics: ① F1 score: Recall and precision are commonly used when analyzing the correct and incorrect predictions of a sample. They can be used to initially measure the performance of a model. To balance recall and precision simultaneously, the F1 score is introduced as a reference. Its calculation formula is as follows: (12) (13) (14) Where TP represents the number of correctly predicted positive samples, FP represents the number of incorrectly predicted positive samples, and FN represents the number of incorrectly predicted negative samples.

[0083] ②IoU: IoU stands for Intersection over Union, which represents the accuracy of the predicted region compared to the actual region. Assuming the predicted crack region is A and the actual region labeled for the crack is B, A∩B represents the union of the predicted crack region and the labeled actual region. This represents the intersection of the predicted crack area and the calibrated actual area. The IoU calculation formula is as follows: (15) ③ mAP: mAP stands for Mean Precision, which is commonly used to objectively evaluate the effectiveness of object detection or instance segmentation methods. The higher the value, the better the performance of the detection model. It solves the problem of the singularity of recall and precision, and the evaluation is more representative. With recall as the x-axis and precision as the y-axis, a PR curve of the model can be obtained, and the area formed by the curve and the coordinate axes is the AP value.

[0084] Since calculating the integral is relatively difficult, the specific calculation of AP introduces an interpolation method, as shown in the following formula: (16) The average AP value for each category in the detection and segmentation is the mAP value. It represents the average precision value corresponding to the threshold T when the IoU between the predicted bounding box or mask of an instance and the actual value is greater than a certain threshold. The larger the value, the closer the predicted instance mask is to the true value. The evaluation metric used in this invention is... and That is, the mAP values ​​of the model are calculated when the IoU is 0.5 and 0.75 respectively.

[0085] Furthermore, this embodiment adopts As a reference value, with a step size of 0.05, the mAP is calculated for IoU thresholds ranging from 0.50 to 0.95, and the average value is taken.

[0086] This invention utilizes a prompt-driven crack self-segmentation model, CrackSAM, to detect and segment bridge surface images. It can quickly and accurately segment image regions containing bridge cracks, effectively improving the segmentation capability of crack defects and ensuring the segmentation and detection performance of bridge facility crack defects. Furthermore, based on prompt words, it can achieve zero-shot learning for new datasets and task requirements, thus enabling rapid training on large-scale, extensive data and generalization to downstream tasks, improving the model's generalization ability. Even in scenarios where the crack category is unclear or multiple crack types may be involved, it can accurately detect objects containing at least one reasonable mask (crack). It can be applied to detect crack defects in bridges of various configurations and spans without the need to construct multiple complex detection models separately.

[0087] This embodiment further provides a bridge crack defect detection device based on a crack self-segmentation model, including a processor and a memory. The memory is used to store a computer program, and the processor is used to execute the computer program to perform the method described above.

[0088] It is understood that the method described in this embodiment can be executed by a single device, such as a computer or server, or it can be applied to a distributed scenario where multiple devices cooperate to complete the task. In a distributed scenario, one of the multiple devices may execute only one or more steps of the method described in this embodiment, and the multiple devices interact to complete the method. The processor can be implemented using a general-purpose CPU, microprocessor, application-specific integrated circuit, or one or more integrated circuits, and is used to execute relevant programs to implement the method described in this embodiment. The memory can be implemented using read-only memory (ROM), random access memory (RAM), static storage devices, and dynamic storage devices. The memory can store the operating system and other applications. When the method described in this embodiment is implemented through software or firmware, the relevant program code is stored in the memory and called and executed by the processor.

[0089] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Therefore, any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention should fall within the protection scope of the present invention.

Claims

1. A method for detecting bridge crack defects based on a crack self-segmentation model, characterized by the following steps: include: Acquire surface images of the bridge under test; The acquired surface image is input into a pre-trained crack self-segmentation model, which then identifies and segments the target image containing cracks from the current surface image. Extract crack information from the segmented target image containing cracks; Among them, the training data of the crack self-segmentation model includes mask markers to cover the target area through the mask; The steps of the crack self-segmentation model in identifying and segmenting a target image containing cracks from a current surface image include: The input surface image is segmented and encoded by an image encoder, and attention features and multiple intermediate features embedded with relative position features are extracted to generate image embeddings. The prompt generator processes each intermediate feature to learn the semantic features represented in each intermediate feature, obtains multiple sets of prompt words and corresponding crack semantic categories, determines the crack target category with crack semantic features based on each set of prompt words and crack semantic categories, and generates prompt embeddings. The mask decoder performs mask decoding based on the image embedding and the cue embedding, and segments the foreground module to generate an image containing the mask, which is the target image containing cracks. During the decoding process, the cue embedding is used to predict the mask position to generate a mask for the image background area. The steps for extracting crack information from the segmented target image containing cracks include: The image is segmented into foreground and background, and the boundary threshold that maximizes the variance between the foreground and background classes is found according to the preset threshold conditions to highlight the specific outline of the target crack, thus obtaining the segmented image. The original shape of the crack is reconstructed using the median transformation method on the segmented image. The crack skeleton is then pruned using the discrete evolution method to remove false branches caused by the serrated shape of the crack and remove intersections, thus obtaining the final crack skeleton. A local coordinate system is established in the orthogonal direction of the crack skeleton to obtain the crack propagation direction. The relative point group close to both sides of the skeleton point and the orthogonal point group that is closest to the orthogonal vector and opposite to each other are found. The crack width is measured based on the shortest Euclidean distance between the candidate points. A balance coefficient is introduced to balance the crack width measured by the relative point group and the orthogonal point group. The balance coefficient adopts the empirical value of the balance coefficient that is closest to the actual result determined by experiments. The actual geometric width of the crack is obtained by multiplying the measured crack pixel width by the ground sampling interval.

2. The bridge crack defect detection method based on a crack self-segmentation model according to claim 1, characterized in that, The steps of segmenting and encoding the input surface image using an image encoder, extracting attention features embedded with relative position features and multiple intermediate features, and generating an image embedding include: Initialize and configure the image encoder; After the current surface image is input into the image encoder, the input image is cut into multiple image sequence blocks; Each image sequence block is flattened into a one-dimensional vector after dimensional mapping to convert spatial geometric information into semantic information. The mapped vector is then embedded with a positional code to preserve positional information. The positional encoding and the mapped vector are input together into the encoder layer to generate an image embedding. The Transformer decoder is used for decoding. During the decoding process, a multi-head attention module is used for feature extraction. The features extracted from all heads are merged according to the corresponding configured weights to obtain attention features embedded with relative position features and multiple intermediate features.

3. The bridge crack defect detection method based on a crack self-segmentation model according to claim 2, characterized in that, The Transformer decoder includes multiple Encoder Block layers and a Neck layer. The Encoder Block layer includes a normalization layer, a multi-head attention layer, and an MLP layer arranged sequentially. The MLP layer contains two linear layers and an activation layer to solve for the connection weights and biases between different layers. The Neck layer includes two convolutional layers and two normalization layers to achieve the transition between input and output information and output the final image information.

4. The bridge crack defect detection method based on a crack self-segmentation model according to claim 1, characterized in that, The process of the prompt generator processing each intermediate feature to learn the semantic features represented in each intermediate feature layer includes: A feature aggregation module is set up to process the acquired intermediate features. The feature aggregation module samples the input features through a downsampling layer and then provides them to a two-dimensional convolutional layer for convolution operation. Starting from the second two-dimensional convolutional layer, the sampling result of the current layer is accumulated with the convolution result of the previous two-dimensional convolutional layer as the input of the current two-dimensional convolutional layer. The final convolution operation result is fused by a fusion convolutional layer and outputs a fused feature value. Based on the fused feature values, an anchor-based region proposal network is used to generate candidate bounding boxes; The candidate bounding boxes are obtained by RoI pooling to obtain the visual feature representation of a single object from the location-encoded feature map; A semantic awareness head, a location awareness head, and a cue awareness head are derived from the visual feature representation. The semantic awareness head determines the target category, the location awareness head establishes a location matching criterion between the generated cue and the target instance mask, and the cue awareness head generates a cue embedding.

5. The bridge crack defect detection method based on a crack self-segmentation model according to claim 1, characterized in that, The system also includes a prompt encoder module in the prompt generator for marking preprocessing. The marks include point marks, box marks, and mask marks. The point marks are used to outline the target contour with points, the box marks are used to mark the position of the target with boxes, and the mask marks are used to cover the target area with masks. The prompt encoder module performs prompt encoding preprocessing on the coordinates of the marked points and the marked boxes, and transforms the specific position of the coordinates of the marked points into a proportional position to achieve position embedding.

6. The bridge crack defect detection method based on a crack self-segmentation model according to any one of claims 1 to 5, characterized in that, The step of generating a masked image by segmenting the foreground module using a mask decoder based on the image embedding and the cue embedding includes: Image embedding and cue embedding are input into the Transformer module of the mask decoder to fuse cue information features with image features to obtain the initial mask src; The initial mask src is upsampled to obtain a prediction mask with position encoding; The predicted mask is input into a multilayer perceptron for forward propagation. During forward propagation, weights and biases are used for weighting, and the gradient is calculated using the propagation results and then backpropagated. After multiple iterations and optimizations, the error between the real mask and the predicted mask is minimized, resulting in the final mask.

7. The bridge crack defect detection method based on a crack self-segmentation model according to any one of claims 1 to 5, characterized in that, The training process for the crack segmentation model also includes: The inverse time decay learning strategy is determined based on the weight decay rate, and the initial learning rate function is set: In the formula, represents the learning rate at the t-th training round, WDR is the weight decay rate, and t represents the number of training rounds; After multiple training sessions, a learning rate interval is obtained. The logarithmic uniformity of the learning rate is used to calculate the logarithmic value of the learning rate interval and the learning rate is randomly assigned and tested to determine the optimal learning rate. During training, if the model accuracy is still less than the preset accuracy after a specified number of consecutive epochs, the current learning rate will be adjusted using a dynamic adjustment factor.

8. The bridge crack defect detection method based on a crack self-segmentation model according to any one of claims 1 to 5, characterized in that, A mobile platform carrying an image acquisition device was used to inspect the bridge under test. The image acquisition device acquired surface images of the bridge using either oblique or orthophoto methods, and the ground sampling interval of the image acquisition device was calculated for both oblique and orthophoto conditions. The ground sampling interval under orthophoto conditions was further specified. The following formula is used to calculate: Ground sampling interval under inclined conditions The following formula is used to calculate: in, H Indicates the drone's flight altitude. s Indicates the pixel size of the image acquisition device. f The focal length of the image acquisition device. The camera tilt angle, The tilt angle of the gimbal.

9. A bridge crack defect detection device based on a crack self-segmentation model, comprising a processor and a memory, wherein the memory is used to store computer programs, characterized in that, The processor is used to execute the computer program to perform the method as described in any one of claims 1 to 8.