A crack segmentation method based on a pre-training segmentation base model and topology-aware supervision

CN122966664APending Publication Date: 2026-10-23HARBIN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611180199.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-05
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

上述方法在训练场景与测试场景接近时能够获得一定分割效果,但在表面材质、裂缝形态、光照条件或成像尺度发生变化时,容易出现泛化性能下降;另一方面,传统区域级损失主要衡量预测掩膜与真值掩膜的像素重叠,少量像素造成的局部骨架断裂对区域指标影响较小,因而难以直接约束细裂缝中心线、分支和连通关系

Benefits of technology

[0045]1)本发明能够利用预训练分割基础模型图像编码器提供可迁移视觉表征,并从末端多个Transformer模块提取多层特征,可增强模型对不同裂缝形态、表面纹理和成像条件的适应能力;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122966664A_ABST
    Figure CN122966664A_ABST
Patent Text Reader

Abstract

The application discloses a crack segmentation method based on a pre-training segmentation base model and topological perception supervision and belongs to the technical field of structure surface crack detection and processing. The method solves the problems of the traditional crack segmentation method in the prior art, such as strong dependence on training data distribution, more false positive responses under complex backgrounds, and easy missed detection, fracture and structure fragmentation of small and branch cracks; the application enhances training image data to obtain enhanced training images; a crack segmentation model is constructed to extract different level features, complete channel alignment and crack task adaptation, and obtain adapted multi-layer features; fusion features are formed to obtain crack enhancement features; a crack probability map is generated by a segmentation head to obtain a crack ground truth mask; joint training is performed through a topological perception composite loss function to obtain a trained crack segmentation model; and a crack segmentation mask is obtained by inputting a to-be-trained image. The application effectively improves crack segmentation precision and can be applied to crack segmentation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of structural surface crack detection and treatment technology, specifically a crack segmentation method based on a pre-trained segmentation model and topology-aware supervision. Background Technology

[0002] Cracks typically take the form of being long and thin, curved, branching, and with significant scale variations. They account for a small percentage of pixels and are easily confused with background information such as wall textures, road seams, shadows, stains, and material particles. Crack segmentation not only requires accurately distinguishing crack pixels from background pixels, but also requires maintaining the crack's central path, branching relationships, and overall connectivity.

[0003] Existing crack segmentation models typically extract local texture features through convolutional encoders and decoders, and are trained using binary cross-entropy loss or region overlap loss. While these methods achieve some segmentation performance when the training and testing scenarios are similar, their generalization performance tends to decline when surface material, crack morphology, lighting conditions, or imaging scale change. Furthermore, traditional region-level losses primarily measure pixel overlap between the predicted and ground truth masks; local skeleton breaks caused by a small number of pixels have little impact on region metrics, making it difficult to directly constrain the centerline, branches, and connectivity of fine cracks.

[0004] Pre-trained segmentation base models can provide visual representations with transferability, but when directly used for crack segmentation, they still suffer from problems such as insufficient utilization of multi-layer features, insufficient refinement of local crack structures, false detection in complex backgrounds, and output crack breakage.

[0005] Therefore, there is a need for a crack segmentation method based on a pre-trained segmentation base model and topologically aware supervision that can utilize pre-trained visual features while taking into account pixel-level region accuracy and crack topological connectivity, in order to improve segmentation stability in complex scenes and under unseen data conditions. Summary of the Invention

[0006] A brief overview of the invention is given below to provide a basic understanding of certain aspects of it. It should be understood that this overview is not an exhaustive summary of the invention. It is not intended to identify key or essential parts of the invention, nor is it intended to limit the scope of the invention. Its purpose is merely to present certain concepts in a simplified form as a prelude to the more detailed description that follows.

[0007] In view of this, in order to solve the problems of traditional crack segmentation methods in the prior art being highly dependent on the distribution of training data, having many false positive responses in complex backgrounds, and being prone to missed detection, breakage and structural fragmentation of small and branch cracks, this invention provides a crack segmentation method based on a pre-trained segmentation base model and topology-aware supervision.

[0008] The technical solution is as follows: A crack segmentation method based on a pre-trained segmentation base model and topology-aware supervision, comprising the following steps:

[0009] S1. Obtain training images with pixel-level crack ground truth masks, and perform synchronous size unification and data augmentation on the training images and their ground truth masks to form training samples;

[0010] S2. Construct a crack segmentation model, input the training image into the pre-trained image encoder, extract multi-layer features from the last four Transformer modules of the pre-trained image encoder, and complete channel alignment and crack task adaptation through the 1×1 adapter in the multi-layer feature adaptation module to obtain the adapted multi-layer features.

[0011] S3. Input the adapted multi-layer features into the attention fusion module, and adaptively weight the response of each layer to the crack region to obtain the fused features. Then input the fused features into the channel attention and feature refinement module to enhance the crack sensitive channel, and use 3×3 and 5×5 depth convolution branches to refine the local structure of the crack to obtain the crack enhancement features.

[0012] S4. Input the crack enhancement features into the lightweight decoder, restore the spatial resolution through four-stage progressive upsampling, generate a crack probability map from the segmentation head, and then obtain the crack prediction mask through thresholding.

[0013] S5. Generate a single-pixel-width crack centerline from the crack ground truth mask and expand it into a tubular skeleton map. Use the crack ground truth mask and the tubular skeleton map as supervision information. Utilize the region-level loss, skeleton recall loss and background false detection suppression term to construct a topology-aware composite loss function to jointly train the crack segmentation model and obtain the trained crack segmentation model.

[0014] S6. Input the image to be segmented into the trained crack segmentation model, and perform thresholding or probability determination based on the output crack probability map to obtain the crack segmentation mask.

[0015] Furthermore, in S2, the crack segmentation model includes a pre-trained image encoder, a multi-layer feature adaptation module, an attention fusion module, a channel attention and feature refinement module, a lightweight decoder, a segmentation head, and a topology-aware composite supervision module for the training phase, which are connected in sequence.

[0016] The input training image is divided into image blocks and mapped into feature sequences by a pre-trained image encoder. Multi-layer visual features are extracted through multiple Transformer modules. The features extracted from the last four Transformer modules are respectively adapted to the corresponding 1×1 adapters to complete channel alignment and crack task adaptation without changing the spatial position relationship, resulting in adapted multi-layer features.

[0017] Furthermore, in S3, the attention fusion module generates fusion weights based on the responses of different hierarchical features to the crack region, crack edge, and background region, and adaptively weights the adapted multi-layer features to obtain fused features.

[0018] The fused features are input into the channel attention and feature refinement module. Global statistics and channel weights are used to enhance the crack-sensitive channel and suppress the background response. Then, the channel enhancement features are input into the 3×3 depth convolution branch and the 5×5 depth convolution branch respectively to refine the crack direction, width variation, curvature and branch structure under different receptive fields. The outputs of the two branches are integrated by the fusion convolution and added to the fused feature residual to obtain the crack enhancement features.

[0019] Furthermore, in S4, the lightweight decoder includes four consecutive progressive upsampling stages, each stage performing convolutional transformation, normalization, nonlinear activation, and spatial scaling to progressively restore the output resolution.

[0020] The segmentation head maps the decoded features into single-channel crack responses, and then uses a sigmoid function to obtain a crack probability map of size H×W. Its pixel values ​​are located in [0,1]; where H and W represent the image height and width, respectively; for the crack probability map A crack prediction mask is obtained by binarizing the data using a preset threshold.

[0021] Further, in S5, both the crack truth mask Y and the tubular skeleton image T generated by the crack truth mask Y are binary images of size H×W. The crack truth mask Y is iteratively refined and skeletonized, and its deletion condition is determined based on the 3×3 neighborhood of the boundary pixel of the crack region to be processed. The deletion condition includes: the number of crack pixels in the 8-neighborhood of the boundary pixel is not less than 2 and not more than 6; when the 8 neighboring pixels are arranged clockwise, the number of times the adjacent pixel value changes from background value 0 to crack value 1 is equal to 1; in the first sub-iteration, pixels in the top, right, and bottom directions cannot simultaneously be crack pixels, and pixels in the right, bottom, and left directions cannot simultaneously be crack pixels; in the second sub-iteration, pixels in the top, right, and left directions cannot simultaneously be crack pixels, and pixels in the top, bottom, and left directions cannot simultaneously be crack pixels. In each sub-iteration, boundary pixels that meet the corresponding deletion conditions are first uniformly marked, and then the marked boundary pixels are simultaneously deleted. The two sub-iterations are then executed alternately until there are no boundary pixels that meet the deletion conditions, resulting in a single-pixel-width crack centerline that maintains the crack branches, endpoints, and connectivity. Subsequently, the crack centerline is morphologically dilated or distance-extended by a preset radius to obtain a tubular skeleton map T.

[0022] Binary cross-entropy loss Represented as:

[0023]

[0024] Where N = H × W, This represents the predicted crack probability for pixel i. This represents the truth label of the crack corresponding to pixel i;

[0025] Dice loss Represented as:

[0026]

[0027] Where ε is a small constant that ensures numerical stability;

[0028] Tversky loss Represented as:

[0029]

[0030]

[0031]

[0032]

[0033] Where α and β control the relative penalty for false positives and false negatives, respectively; TP, FP, and FN represent soft true positives, soft false positives, and soft false negatives, respectively; TP represents the part correctly predicted as a crack, FP represents the part that incorrectly predicts the background as a crack, and FN represents the crack part that is not correctly identified.

[0034] Frame recall losses Represented as:

[0035]

[0036] in, This indicates that the tubular skeleton image in a small batch contains at least one valid sample set with a positive pixel. Indicates the number of valid samples. This represents the total number of pixels in each sample. Indicates pixel index, Indicates the sample index. Indicates the first Pixels in each sample The predicted crack probability, Indicates the first Pixels in each sample The corresponding tubular skeleton label, when pixel Located in the When the sample is located within the actual fracture tubular skeleton region... ;otherwise, ;

[0037] Background false detection suppression items Represented as:

[0038]

[0039] in, This represents the non-crack region in the crack truth mask;

[0040] Topology-aware composite loss function Represented as:

[0041]

[0042] Where λ1, λ2, λ3, λ4 and λ5 are the weights of the binary cross-entropy loss, Dice loss, Tversky loss, skeleton recall loss and background false detection suppression term, respectively.

[0043] Furthermore, in step S6, the ground truth mask Y and the tubular skeleton map T are not used in the inference stage. Instead, the image to be segmented is input into the trained crack segmentation model, and the crack probability map is obtained through forward computation. The crack segmentation mask is obtained through thresholding or probability determination.

[0044] The beneficial effects of this invention are as follows:

[0045] 1) This invention can provide transferable visual representations by utilizing a pre-trained segmentation base model image encoder and extract multi-layer features from multiple Transformer modules at the end, which can enhance the model's adaptability to different crack morphologies, surface textures and imaging conditions.

[0046] 2) This invention combines high-level semantics with fine-grained local structures through a 1×1 adapter, attention fusion, and channel attention and feature refinement modules, and enhances the expression of fine, curved and branched cracks by using deep convolution with different receptive fields.

[0047] 3) This invention improves the crack center path and component-level connectivity while ensuring pixel-level region overlap accuracy and reducing false detections in complex backgrounds through joint optimization of region-level loss, skeleton recall loss and background false detection suppression loss.

[0048] 4) This invention uses a lightweight four-stage progressive decoder to restore the output resolution, which reduces the computational complexity of the decoding process while preserving the crack details.

[0049] 5) The model trained by this invention can be directly applied to unseen target scenarios, maintaining relatively stable crack segmentation performance without the need for additional fine-tuning or domain adaptation. Attached Figure Description

[0050] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:

[0051] Figure 1 This is a flowchart illustrating a crack segmentation method based on a pre-trained segmentation baseline model and topology-aware supervision.

[0052] Figure 2 This is a schematic diagram of the network structure of a crack segmentation model based on a pre-trained segmentation baseline model and topology-aware supervision.

[0053] Figure 3 The diagram shows the qualitative comparison of crack segmentation results, zero-sample generalization, and ablation visualization results. Among them, (a) is DeepCrack. D (a) is a diagram illustrating intra-domain qualitative comparisons on the dataset; (b) is a diagram illustrating zero-shot generalization comparisons on the CFD dataset; (c) is a diagram illustrating zero-shot generalization comparisons on the CCSD dataset; and (d) is a diagram illustrating DeepCrack. D A schematic diagram of the skeleton recall loss ablation visualization results on the dataset. Detailed Implementation

[0054] To make the technical solutions and advantages of the embodiments of the present invention clearer, the exemplary embodiments of the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not an exhaustive list of all embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present invention can be combined with each other.

[0055] Example 1: Reference Figures 1-3 This embodiment describes a crack segmentation method based on a pre-trained segmentation model and topology-aware supervision, specifically including the following steps:

[0056] S1. Obtain training images with pixel-level crack ground truth masks, and perform synchronous size unification and optional data augmentation on the training images and their ground truth masks to form training samples;

[0057] S2. Construct a crack segmentation model, input the training image into the pre-trained image encoder, extract multi-layer features from its last four Transformer modules, and complete channel alignment and crack task adaptation through a 1×1 adapter.

[0058] S3. Input the adapted multi-layer features into the attention fusion module to obtain fused features, and then input them into the channel attention and feature refinement module. Use channel attention to enhance the crack sensitive channel and suppress background interference. Extract local crack structures under different receptive fields through fixed 3×3 and 5×5 depth convolution branches. Obtain crack enhancement features through fusion convolution and residual connection.

[0059] S4. Input the crack enhancement features into the lightweight decoder, restore the spatial resolution through four-stage progressive upsampling, generate a crack probability map from the segmentation head, and obtain the crack prediction mask through thresholding;

[0060] S5. Generate a single-pixel-width centerline and a tubular skeleton map from the corresponding crack ground truth mask. Use the crack ground truth mask and the tubular skeleton map as supervision information and jointly train the model through the topology-aware composite loss function.

[0061] S6. Input the image to be segmented into the trained crack segmentation model, and obtain the crack segmentation mask based on the output crack probability map.

[0062] Specifically, the network input during the training phase is the training image, and the supervision information is the corresponding ground truth mask of the crack. and by Generated tubular skeleton diagram The model output is a predicted crack probability map. The inference stage only inputs the image to be segmented and does not use... and .

[0063] Furthermore, in S2, a pre-trained Segment Anything Model image encoder is used as the feature extraction backbone. The input image is divided into image patches and mapped to feature sequences, which are then linked to establish a global context through multiple Transformer modules. N represents the last Transformer module, and Tap 31, Tap 30, Tap 29, and Tap 28 represent the feature extraction positions in the last four Transformer modules. The corresponding features are uniformly denoted as... and .

[0064] Features extracted earlier retain more local details, crack edges, and fine crack structures, while features extracted later provide stronger crack semantics and long-range structural information. The four feature layers are adapted for channel alignment and crack task fitting via 1×1 adapters, converting general visual representations into crack task features without altering spatial relationships. During model training, all or part of the parameters of the pre-trained encoder can be frozen, and the adapter and subsequent modules can be trained; alternatively, the encoder's end modules can be jointly fine-tuned based on the training data scale.

[0065] Furthermore, in S3, the attention fusion module generates fusion weights based on the responses of the four-layer adaptive features to the crack region, crack edge, and background region. These fusion weights are adaptively learned by the network during training, rather than being pre-set. The four-layer features are then weighted and fused to obtain F. AF , where AF represents attention fusion.

[0066] F AF Input channel attention and feature refinement module. Channel attention to F AF Global statistics and channel weights are calculated to enhance crack-sensitive channels and reduce the response of background interference channels. Subsequently, the channel enhancement features are input into two fixed-depth convolutional branches with kernel sizes of 3×3 and 5×5, respectively, to extract local crack orientation, width variation, curvature, and branching structures under different receptive fields. The outputs of the two branches are concatenated or summed and then fused using a 1×1 convolution, before being combined with F... AF Perform residual summation to obtain crack enhancement characteristics.

[0067] Furthermore, in S4, the lightweight decoder is fixed to include four consecutive upsampling stages. Each stage sequentially performs convolutional transformation, normalization, nonlinear activation, and spatial scaling to restore spatial resolution step by step, thereby reducing the loss of detail caused by a single large-scale upsampling. Finally, the segmentation head maps the decoded features to a single-channel gap response and obtains the result through the Sigmoid function. , where H and W represent the image height and width, respectively. A crack prediction mask is obtained by binarizing the data using a preset threshold.

[0068] Furthermore, in S5, the crack truth mask is denoted as... The tubular skeleton diagram is denoted as During skeletonization, boundary pixels of the crack region are iteratively detected based on the 3×3 neighborhood of each pixel. Boundary pixels that satisfy the local connectivity preservation condition but are not crack endpoints are deleted. This process is repeated until no boundary pixels can be deleted, resulting in a single-pixel-width centerline that preserves the crack branches, endpoints, and connectivity. Subsequently, the centerline is morphologically dilated or extended by a preset radius to obtain a tubular skeleton image T with spatial tolerance.

[0069] Topology-aware composite training objectives consist of region-level supervision and skeleton-level supervision:

[0070]

[0071] Skeleton-level loss is defined as:

[0072]

[0073] Among them, L srec Losses due to skeleton recall:

[0074]

[0075] in, This indicates that the tubular skeleton image in a small batch contains at least one valid sample set with a positive pixel. This represents the number of valid samples; N = H × W is the total number of pixels. For pixel index, For sample index; and They represent the first Pixels in each sample Predicted crack probability and tubular skeleton label, ε is a numerically stable term, and pixel i is located at the th When the true tubular skeleton region of a sample is within When located outside this area .

[0076] The numerator of the skeleton recall loss accumulates the predicted probabilities on the true tubular skeleton regions, while the denominator is normalized based on the number of positive pixels in the tubular skeleton for each valid sample. Low predicted responses at interrupted segments, fine branches, or crack endpoints increase the loss and generate gradients that contribute to their recovery; the tubular skeleton allows for small positional deviations near the centerline, and sample-level normalization avoids long cracks disproportionately affecting the training target. Because L... srec It only applies to the real skeleton region, mainly reducing false positives and structural interruptions, without directly penalizing false positives in the background region.

[0077] Region-level loss is used to maintain pixel-level segmentation accuracy:

[0078]

[0079] Binary cross-entropy loss L bce Provides pixel-level supervision for crack and background classification:

[0080]

[0081] in, Let i be the predicted crack probability. This is the corresponding crack truth label. (Dice loss) Used to improve the overlap between the predicted crack region and the true crack region:

[0082]

[0083] Tversky lost L tversky Used to balance false positives and false negatives:

[0084]

[0085] Among them, TP, FP, and FN are soft statistics, calculated as follows:

[0086]

[0087]

[0088]

[0089] TP represents the portion correctly predicted as a crack, FP represents the portion of the background incorrectly predicted as a crack, and FN represents the portion of the crack that was not correctly identified; α and β control the relative penalty for false positives and false negatives, respectively. Since the above three terms are calculated from the prediction probability, they are soft statistics rather than the number of discrete pixels.

[0090] To mitigate background false positives that may result from skeleton recall loss, a background false positive suppression term is introduced:

[0091]

[0092] in, This represents the background region in the ground truth mask, and this term penalizes high crack responses on background pixels; the loss weights are set to... , , , ,and .

[0093] Specifically, L bce L dice and L tversky Constitutes a regional-level optimization term, L srec Acting on the support area of ​​the tubular skeleton, L fp Used to suppress false positives. Compared to single-pixel skeletons, tubular skeletons provide positional tolerance for prediction results and cover effective pixels near the central structure; this supervision does not force connections between crack regions that are separate from each other in the ground truth, but rather improves the prediction response near the center path of each real crack, thereby reducing local breaks and omissions of small branches while avoiding unreasonable cross-regional connections.

[0094] During training, random cropping, scaling, flipping, or color perturbation are performed simultaneously on the training image and the corresponding ground truth mask. The processed ground truth mask generates T in real time or in advance. After the model calculates Ŷ, the region-level loss and skeleton-level loss are calculated to form the overall loss L. The trainable parameters are updated through backpropagation. The final model can be selected based on the validation set loss or metrics such as Dice and IoU.

[0095] During inference, Y and T are no longer needed; only the image to be segmented is input into the trained model. After the model outputs Ŷ, a binary crack mask is obtained using a fixed threshold or a threshold set according to application requirements, and post-processing such as small connected component removal can be performed. For target datasets not present during the training phase, inference can be performed directly without additional fine-tuning, retraining, or domain adaptation, enabling zero-shot segmentation across datasets.

[0096] Specifically, to verify the intra-domain segmentation performance, cross-dataset zero-shot generalization ability, and the effect of skeleton recall loss on crack connectivity of the method of the present invention, this embodiment uses DeepCrack... D Experiments were conducted on four public crack datasets: Crack500, CFD, and CCSD, as detailed below:

[0097] DeepCrack D The dataset contains 537 crack images with a resolution of 544×384 pixels, divided into training, test, and validation sets in a 7:2:1 ratio, with the training set augmented to 3000 samples. Crack500 contains 500 original images of approximately 2000×1500 pixels, cropped and expanded to 3368 images of 640×360 pixels, also divided in a 7:2:1 ratio. CFD contains 118 road crack images of 480×320 pixels. CCSD contains 458 high-resolution building crack images of 3024×4032 pixels, divided into 5187 sub-images of 360×360 pixels. Crack500 and DeepCrack... D Used for in-domain training and testing, where the Crack500 results are compared with those reported by SCSegMamba, and DeepCrack... D The results were compared with those reported by TopoSAM; the zero-sample experiment was conducted only in DeepCrack. D The dataset is trained on unseen CFD and CCSD models and tested directly without fine-tuning, retraining, or domain adaptation.

[0098] In the evaluation metrics, TP, FP, TN, and FN represent the predicted probabilities, respectively. Figure 2 The value-based values ​​represent the number of true positives, false positives, true negatives, and false negatives pixels. Here, TP, FP, and FN are discrete pixel counts, distinct from the soft statistics calculated based on prediction probabilities in the loss function. Precision (Pre) and Recall (Re) are defined as follows:

[0099]

[0100] Where Precision represents the proportion of correctly predicted crack pixels out of all predicted crack pixels, and Recall represents the proportion of correctly detected ground truth crack pixels. The F1-score is the harmonic mean of Precision and Recall.

[0101]

[0102] The crossover ratio (IoU) of crack categories is defined as follows:

[0103]

[0104] IoU measures the proportion of overlap between the predicted crack region and the ground truth crack region. The mean crossover ratio mIoU is the average of the IoU across all categories.

[0105]

[0106] Where C represents the number of categories, TP c FP c and FN c These represent the number of true positives, false positives, and false negatives in category c, respectively; in binary crack segmentation, C=2, corresponding to the crack class and the background class. The Dice coefficient is defined as:

[0107]

[0108] Dice is used to evaluate the similarity between the predicted crack mask and the ground truth crack annotation. To evaluate the overall performance under different binarization thresholds, ODS and OIS are used:

[0109]

[0110]

[0111] Where t represents the binarization threshold, N represents the total number of test images, and P t and R t P represents Precision and Recall calculated for the entire test set at threshold t, respectively. (i,t) and R (i,t) Let represent the Precision and Recall of the i-th test image at threshold t, respectively. ODS represents the highest F1-score achievable when using a single uniform threshold across the entire test set; OIS represents the average of the highest F1-scores obtained after selecting the optimal threshold for each image.

[0112] The intra-domain comparative experiment is as follows:

[0113] The model was trained on the Crack500 dataset using its training set, and evaluated on the corresponding test set. The quantitative results for each method are shown in Table 1.

[0114] Table 1. Comparison of crack segmentation results of the method of the present invention and existing methods on the Crack500 dataset.

[0115]

[0116] As shown in Table 1, the method of this invention achieves the highest values ​​for ODS, OIS, Precision, F1-score, and mIoU on Crack500, at 79.00%, 76.98%, 77.39%, 78.99%, and 81.19%, respectively, with a Recall of 80.67%. Compared with SCSegMamba, ODS, F1-score, and mIoU are improved by 6.56, 3.46, and 3.41 percentage points, respectively. The Recall is not the highest, mainly because the model implements stronger suppression of uncertain responses in non-crack regions and blurred boundaries through background false detection suppression terms, reducing false positives while potentially excluding a small number of low-confidence edge pixels. For relatively wide and visually distinctive cracks in Crack500, this strategy can achieve a better balance between precision and overall segmentation accuracy while maintaining the integrity of the main crack regions.

[0117] On the DeepCrackD dataset, the same dataset was used for training and testing, and the results were compared with the general segmentation model and the crack-specific model. The results are shown in Table 2.

[0118] Table 2 Comparison of crack segmentation results of the method of the present invention and existing methods on the DeepCrackD dataset.

[0119]

[0120] As shown in Table 2, the method of the present invention is effective in DeepCrack. DThe Dice, IoU, and Recall values ​​were 88.14%, 78.80%, and 87.46%, respectively, all the highest values ​​in the table. Precision was 88.85%, only 0.98 percentage points lower than the highest value of 89.83%. Compared to TopoSAM, Dice, IoU, and Recall improved by 4.32, 6.21, and 7.26 percentage points, respectively. The slight decrease in Precision is mainly due to the high proportion of small, low-contrast, and visually blurred cracks in this dataset. To preserve these weak crack structures and reduce breakage, the model retains more candidate responses near the crack centerline and boundaries, thereby increasing the detection rate of true cracks, while potentially introducing a small amount of crack-like background responses. The higher Dice and IoU indicate that the crack integrity gain outweighs the slight increase in false positives. Figure 3 The qualitative comparison in (a) further demonstrates that the method of the present invention has fewer missing pixels and local breaks at fine crack and branch locations.

[0121] Zero-shot cross-dataset generalization experiments are detailed below:

[0122] To evaluate the generalization ability of the proposed method across datasets in unseen scenarios, all methods were trained only on DeepCrackD and then tested directly on CFD and CCSD without any additional fine-tuning or domain adaptation. The comparison methods used the same zero-sample setting reported by TopoSAM, and the quantitative results are shown in Table 3.

[0123] Table 3. Comparison of segmentation results of different methods on the CFD and CCSD datasets under zero-shot settings.

[0124]

[0125] As shown in Table 3, on CFD, the proposed method achieves Dice, IoU, and Recall of 62.11%, 45.04%, and 58.69%, respectively, all higher than other methods, with a Precision of 65.95%. This decrease in Precision is mainly due to cross-dataset domain shift: to reduce the missed detection of weak, fine, and low-contrast cracks, the model identifies more candidate crack pixels, while potentially misclassifying some crack-like textures and background areas as cracks; however, the highest Dice and IoU indicate that its overall consistency with the ground truth remains optimal. On CCSD, Dice, IoU, Precision, and Recall reach 68.63%, 52.24%, 96.28%, and 53.32%, respectively, all the highest values ​​in the table. Compared to TopoSAM, the method of this invention improves Dice, IoU and Recall by 5.49, 4.37 and 10.20 percentage points in CFD, and by 9.30, 5.43, 2.96 and 5.34 percentage points in CCSD. Figure 3 (b) and Figure 3 (c) shows that the method of the present invention can preserve more fine cracks and branch structures in unseen scenarios and reduce the prediction of local discontinuities.

[0126] The ablation experiment for the scaffold recall loss is as follows:

[0127] To evaluate topology-aware connectivity, the ConnRatio, SkelConnRecall, and clDice metrics are further employed. Let Y and Ŷ represent the ground truth crack mask and the predicted crack mask, respectively, and S(·) represent the skeletonization operation; K gt and K pred These represent the number of connected components in Y and Ŷ, respectively. ConnRatio is used to measure the consistency in the number of connected components between the two:

[0128]

[0129] A higher ConnRatio indicates that the connectivity components of the predicted crack mask are closer to the ground truth. SkelConnRecall measures the proportion of the ground truth skeleton connectivity components covered by the predicted skeleton:

[0130]

[0131] in, This represents the skeleton of the predicted crack mask. Truth skeleton The number of connected components in For connected component indexes, Represents the set of skeleton pixels contained in the k-th connected component of the truth skeleton; indicator function exist The value is set to 1 if it intersects with the connected component of the corresponding truth skeleton, and 0 otherwise.

[0132] clDice achieves topological accuracy T prec and topological sensitivity T sens A comprehensive evaluation of the topological consistency between the predicted crack structure and the true crack structure is conducted.

[0133]

[0134]

[0135] Among them, T prec T represents the proportion of the predicted skeleton located within the true crack region. sens This indicates the proportion of the true skeleton that is covered by the predicted crack region.

[0136] Table 4. Experimental results of skeleton recall loss ablation on the DeepCrackD dataset.

[0137]

[0138] Table 4 shows the recall loss L after adding the skeleton. srec Afterwards, the ConnRatio of the complete model improved from 0.539 to 0.624, a relative increase of 15.77%; Dice, IoU, Recall, and clDice improved by 0.23%, 0.38%, 0.81%, and 0.44%, respectively, while Precision and SkelConnRecall changed slightly by -0.34% and -0.31%, respectively. The skeleton recall loss mainly recovers a small number of pixels at the breakpoints of the cracks that play a key connecting role. Therefore, it has a limited improvement on the region overlap index, but it can reconnect the originally separated crack segments and significantly improve ConnRatio. Figure 3 (d) further shows the ablation visualization, removing L srec After that, fine cracks and branching areas are more prone to local interruptions; the complete model has a more continuous central path and a more complete branching structure.

[0139] Comprehensive Analysis of Experimental Results: The above experiments verified the effectiveness of the proposed method in three aspects: intra-domain segmentation accuracy, zero-shot cross-dataset generalization ability, and topological connectivity. (Crack500 and DeepCrack) DThe comparative results show that the method of the present invention can improve the accuracy of crack region detection and segmentation; zero-shot results on CFD and CCSD show that pre-trained visual representation, multi-layer task adaptation, and feature refinement structure can enhance robustness in unseen scenes; ablation results show that tubular skeleton supervision can significantly improve the consistency of crack connectivity components while maintaining stable pixel-level performance. Therefore, the method of the present invention can output a more accurate, continuous crack mask with better cross-scene adaptability.

[0140] Example 2: A crack segmentation method based on a pre-trained segmentation model and topology-aware supervision, further comprising a crack segmentation system, which includes, in sequence, an image acquisition and preprocessing module, a multi-layer feature extraction and adaptation module, an attention fusion module, a channel attention and feature refinement module, a lightweight decoding module, a skeleton supervision construction module, a joint optimization module, and a crack inference output module; each module can be implemented by software, hardware, or a combination of software and hardware, and is configured to execute the crack segmentation method based on a pre-trained segmentation model and topology-aware supervision described in Example 1.

[0141] Example 3: The computer device of the present invention may include a processor and a memory, such as a microcontroller containing a central processing unit. Furthermore, the processor executes the computer program stored in the memory to implement the steps of the above-described crack segmentation method based on a pre-trained segmentation model and topology-aware supervision.

[0142] The processor referred to can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor can be a microprocessor or any conventional processor.

[0143] The memory may primarily include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as sound playback, image playback, etc.); the data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). Furthermore, the memory may include high-speed random access memory, and may also include non-volatile memory, such as hard disks, RAM, plug-in hard disks, smart media cards (SMC), secure digital cards (SD cards), flash cards, at least one disk storage device, flash memory device, or other volatile solid-state storage devices.

[0144] Example 4: The computer-readable storage medium of the present invention can be any form of storage medium that can be read by the processor of a computer device, including but not limited to non-volatile memory, volatile memory, ferroelectric memory, etc. The computer-readable storage medium stores a computer program. When the processor of the computer device reads and executes the computer program stored in the memory, the steps of the above-mentioned crack segmentation method based on a pre-trained segmentation basic model and topology-aware supervision can be implemented.

[0145] The computer program includes computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added to or subtracted according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.

[0146] Although the invention has been described with reference to a limited number of embodiments, those skilled in the art will understand from the foregoing description that other embodiments are conceivable within the scope of the invention described herein. Furthermore, it should be noted that the language used in this specification has been chosen primarily for readability and edibility purposes, and not for the purpose of interpreting or limiting the subject matter of the invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the invention is illustrative and not restrictive, and the scope of the invention is defined by the appended claims.

Claims

1. A crack segmentation method based on a pre-trained segmentation baseline model and topology-aware supervision, characterized in that, Includes the following steps: S1. Obtain training images with pixel-level crack ground truth masks, and perform synchronous size unification and data augmentation on the training images and their ground truth masks to form training samples; S2. Construct a crack segmentation model, input the training image into the pre-trained image encoder, extract multi-layer features from the last four Transformer modules of the pre-trained image encoder, and complete channel alignment and crack task adaptation through the 1×1 adapter in the multi-layer feature adaptation module to obtain the adapted multi-layer features. S3. Input the adapted multi-layer features into the attention fusion module, and adaptively weight the response of each layer to the crack region to obtain the fused features. Then input the fused features into the channel attention and feature refinement module to enhance the crack sensitive channel, and use 3×3 and 5×5 depth convolution branches to refine the local structure of the crack to obtain the crack enhancement features. S4. Input the crack enhancement features into the lightweight decoder, restore the spatial resolution through four-stage progressive upsampling, generate a crack probability map from the segmentation head, and then obtain the crack prediction mask through thresholding. S5. Generate a single-pixel-width crack centerline from the crack ground truth mask and expand it into a tubular skeleton map. Use the crack ground truth mask and the tubular skeleton map as supervision information. Utilize the region-level loss, skeleton recall loss and background false detection suppression term to construct a topology-aware composite loss function to jointly train the crack segmentation model and obtain the trained crack segmentation model. S6. Input the image to be segmented into the trained crack segmentation model, and perform thresholding or probability determination based on the output crack probability map to obtain the crack segmentation mask.

2. The crack segmentation method based on a pre-trained segmentation model and topology-aware supervision as described in claim 1, characterized in that, In S2, the crack segmentation model includes a pre-trained image encoder, a multi-layer feature adaptation module, an attention fusion module, a channel attention and feature refinement module, a lightweight decoder, a segmentation head, and a topology-aware composite supervision module for the training phase, which are connected in sequence. The input training image is divided into image patches and mapped to feature sequences by a pre-trained image encoder, and multiple layers of visual features are extracted through multiple Transformer modules. The features extracted from the last four Transformer modules are respectively processed by the corresponding 1×1 adapters to complete channel alignment and crack task adaptation without changing the spatial position relationship, resulting in adapted multi-layer features.

3. The crack segmentation method based on a pre-trained segmentation model and topology-aware supervision as described in claim 2, characterized in that, In S3, the attention fusion module generates fusion weights based on the responses of different hierarchical features to the crack region, crack edge, and background region, and adaptively weights the adapted multi-layer features to obtain fused features. The feature input channel attention and feature refinement module are integrated, and the crack-sensitive channel is enhanced and the background response is suppressed through global statistics and channel weight calculation. Subsequently, the channel enhancement features are input into the 3×3 depth convolution branch and the 5×5 depth convolution branch respectively, and the crack direction, width variation, curvature and branch structure are refined under different receptive fields. The outputs of the two branches are integrated by fusion convolution and added to the fusion feature residual to obtain the crack enhancement features.

4. The crack segmentation method based on a pre-trained segmentation model and topology-aware supervision as described in claim 3, characterized in that, In S4, the lightweight decoder includes four consecutive progressive upsampling stages, each of which performs convolutional transformation, normalization, nonlinear activation, and spatial scaling to progressively restore the output resolution. The segmentation head maps the decoded features into a single-channel crack response, and obtains a crack probability map Ŷ of size H×W through the Sigmoid function, with its pixel values ​​located in [0,1]; where H and W represent the image height and width, respectively; the crack probability map Ŷ is binarized using a preset threshold to obtain a crack prediction mask.

5. The crack segmentation method based on a pre-trained segmentation model and topology-aware supervision as described in claim 4, characterized in that, Further, in S5, both the crack truth mask Y and the tubular skeleton image T generated by the crack truth mask Y are binary images with a size of H×W; the crack truth mask Y is iteratively refined and skeletonized based on the 3×3 boundary pixels of the crack region to be processed. The neighborhood is used to determine whether it meets the deletion conditions. The deletion conditions include: the number of crack pixels in the 8-neighborhood of the boundary pixel is not less than 2 and not more than 6; when the 8 neighboring pixels are arranged in a clockwise direction, the number of times the value of the adjacent pixel changes from the background value 0 to the crack value 1 is equal to 1; in the first sub-iteration, pixels in the top, right, and bottom directions cannot be crack pixels at the same time, and pixels in the right, bottom, and left directions cannot be crack pixels at the same time; in the second sub-iteration, pixels in the top, right, and left directions cannot be crack pixels at the same time, and pixels in the top, bottom, and left directions cannot be crack pixels at the same time; in each sub-iteration, the boundary pixels that meet the corresponding deletion conditions are first uniformly marked, and then the marked boundary pixels are deleted at the same time, and the two sub-iterations are alternately repeated until there are no boundary pixels that meet the deletion conditions, and a single-pixel width crack centerline that maintains the crack branches, endpoints, and connectivity is obtained; then, the crack centerline is morphologically dilated or distance extended with a preset radius to obtain a tubular skeleton map T; Binary cross-entropy loss Represented as: Where N = H × W, This represents the predicted crack probability for pixel i. This represents the truth label of the crack corresponding to pixel i; Dice loss Represented as: Where ε is a small constant that ensures numerical stability; Tversky loss Represented as: Where α and β control the relative penalty for false positives and false negatives, respectively; TP, FP, and FN represent soft true positives, soft false positives, and soft false negatives, respectively; TP represents the part correctly predicted as a crack, FP represents the part that incorrectly predicts the background as a crack, and FN represents the crack part that is not correctly identified. Frame recall losses Represented as: in, This indicates that the tubular skeleton image in a small batch contains at least one valid sample set with a positive pixel. Indicates the number of valid samples. This represents the total number of pixels in each sample. Indicates pixel index, Indicates the sample index. Indicates the first Pixels in each sample The predicted crack probability, Indicates the first Pixels in each sample The corresponding tubular skeleton label, when pixel Located in the When the sample is located within the actual cracked tubular skeleton region ;otherwise, ; Background false detection suppression items Represented as: in, This represents the non-crack region in the crack truth mask; Topology-aware composite loss function Represented as: Where λ1, λ2, λ3, λ4 and λ5 are the weights of the binary cross-entropy loss, Dice loss, Tversky loss, skeleton recall loss and background false detection suppression term, respectively.

6. The crack segmentation method based on a pre-trained segmentation model and topology-aware supervision as described in claim 5, characterized in that, In step S6, the ground truth mask Y and tubular skeleton map T are not used in the inference stage. Instead, the image to be segmented is input into the trained crack segmentation model, and the crack probability map is obtained through forward computation. The crack segmentation mask is obtained through thresholding or probability determination.