A deep learning-based masonry structure crack segmentation method

By constructing a masonry crack damage image dataset and introducing an improved U-Net network model with a convolutional block attention module, and combining it with Bayesian optimization algorithm to optimize hyperparameters, the problem of insufficient feature extraction capability for complex crack shapes and poor generalization performance in complex backgrounds in masonry crack segmentation methods is solved, achieving efficient and accurate crack segmentation.

CN122391261APending Publication Date: 2026-07-14TONGJI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TONGJI UNIV
Filing Date
2026-04-16
Publication Date
2026-07-14

AI Technical Summary

Technical Problem

Existing masonry crack segmentation methods are insufficient in extracting features of cracks with complex shapes, have poor generalization performance under complex background conditions, and rely on human experience to optimize model hyperparameters, resulting in low efficiency and difficulty in guaranteeing global optimality.

Method used

A dataset of masonry crack damage images was constructed, and an improved U-Net network model with a convolutional block attention module was introduced. The hyperparameters were globally optimized by combining Bayesian optimization algorithm, and the network parameters were updated iteratively through backpropagation and optimizer to enhance the ability to extract key crack features and the model's generalization ability.

Benefits of technology

It improves the accuracy and generalization ability of crack segmentation, especially maintaining accurate segmentation in complex backgrounds and multi-scale cracks, reducing the cost of manual trial and error, and improving the model's adaptability and stability on different datasets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122391261A_ABST
    Figure CN122391261A_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on deep learning's masonry structure crack segmentation method, it is related to building detection technical field, the method includes: constructing masonry crack image dataset, forms standardization sample by data acquisition, cropping, labeling and enhancement;Improved U-Net network model is established by introducing convolution block attention module, embedding channel and spatial double attention mechanism in encoder and decoder, enhance crack feature extraction capability;Global optimization is carried out to hyperparameter using Bayesian optimization algorithm, to determine the optimal hyperparameter combination;Model is trained based on optimal configuration, and network parameter is iteratively updated by back propagation and optimizer;Finally, the precision, recall and F1-Score are used to evaluate the performance of the model.The application can effectively improve the precision and robustness of masonry crack segmentation, adapt to the detection needs of complex background and multi-morphology cracks, and is suitable for building structure safety detection and other scenes.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of building inspection technology, and in particular to a method for segmenting cracks in masonry structures based on deep learning. Background Technology

[0002] Masonry structures, a widely used structural form in the construction field, are severely affected by cracking, which significantly impacts the safety and stability of buildings. Traditional masonry crack detection primarily relies on manual methods, with inspectors judging crack conditions based on visual observation and simple tools. This method has several drawbacks. First, manual inspection is labor-intensive, requiring inspectors to concentrate for extended periods, leading to fatigue and low efficiency. Second, the inspection process is time-consuming; for large buildings or large-area masonry structures, manual inspection consumes a significant amount of time. Third, manual inspection is highly susceptible to human factors; differences in experience and judgment standards among inspectors make it difficult to guarantee the accuracy and reliability of the results.

[0003] With the advancement of technology, deep learning has made significant progress in image processing, bringing new opportunities for masonry crack detection. The U-Net model, a commonly used deep learning model, has demonstrated advantages in some image processing tasks. However, existing models still face many challenges in masonry crack segmentation. On the one hand, masonry cracks are complex and diverse in morphology, including irregular shapes, varying widths and lengths, and some cracks are minute, making it difficult for existing models to accurately capture these complex crack features. On the other hand, real-world masonry structures are often accompanied by complex backgrounds, such as wall textures, stains, and lighting variations. These interfering factors increase the difficulty of crack detection, and the generalization ability of existing models is insufficient to handle crack detection in complex backgrounds, easily leading to misjudgments and missed detections. Furthermore, current research on masonry crack detection is relatively limited, and existing detection methods are insufficient to meet the high accuracy and efficiency requirements of masonry crack detection in practical engineering. Summary of the Invention

[0004] The purpose of this invention is to provide a deep learning-based method for segmenting cracks in masonry structures, which solves the problems of insufficient ability to extract features of cracks with complex shapes, poor generalization performance under complex background conditions, low efficiency of model hyperparameter tuning based on human experience, and difficulty in guaranteeing global optimality in existing masonry crack segmentation methods.

[0005] To achieve the above objectives, this invention provides a deep learning-based method for crack segmentation in masonry structures, comprising the following steps: S1. Construct a dataset of masonry crack damage images. Through data collection, unified cropping, manual annotation, and data augmentation, standardized training samples are formed to lay the data foundation for model training. S2. Based on the dataset constructed in S1, an improved U-Net network model with convolutional block attention module is established. By embedding channel and spatial dual attention mechanism in the encoder and decoder, the ability to extract key crack features is enhanced, serving as a masonry crack damage segmentation model. S3. Based on the model established in S2, the Bayesian optimization algorithm is used to globally optimize the hyperparameters of the model. The combination of hyperparameters that optimizes the model performance is determined through iterative search, providing the optimal configuration for model training. S4. Based on the hyperparameter combination determined in S3, train the model established in S2 using the dataset constructed in S1. Iterate and update the network parameters through backpropagation and optimizer until the model converges, and obtain the trained crack segmentation model. S5. Evaluate the performance of the model trained in S4. Use preset evaluation indicators to quantify the segmentation accuracy and robustness of the model and verify its effectiveness in the masonry crack segmentation task.

[0006] Preferably, the masonry crack damage image dataset constructed in S1 is specifically as follows: S11. Collect masonry images from different scenes and select images containing cracks as the original dataset; S12. Use OpenCV to uniformly crop the images filtered in S11 to the same size. S13. Use LabelMe software to manually label the cracks and construct the initial dataset of masonry cracks; S14. Expand the dataset size through data augmentation to improve the model's generalization ability and make it more adaptable to different scenarios; among which, data augmentation includes height translation, width translation, horizontal flipping, scaling and rotation.

[0007] Preferably, the improved U-Net network architecture in S2 is as follows: a convolutional block attention module is introduced after each convolutional block of the encoder and decoder to enhance the expression of crack features in both the channel and spatial dimensions.

[0008] Preferably, the construction of the improved U-Net network architecture includes the following sub-steps: S21. Input the processed masonry crack image into the input layer of the improved U-Net neural network that accepts the original data; S22. In the encoder, the input image is subjected to two convolution operations through a 3×3 convolutional layer, followed by batch normalization and ReLU activation to enhance the feature representation capability through non-linear mapping; a convolutional block attention module is used to extract features of crack channels and spatial dimensions; max pooling is used to reduce the resolution while retaining significant features (such as edges and textures), and the receptive field is gradually expanded to capture the global context. S23. In the decoder, the low-resolution feature map is expanded to its original size by transposed convolution upsampling to restore spatial information; overfitting of the model is prevented by adding a Dropout operation before the convolution operation; and the convolutional block attention module is used to fuse the feature map in both channel and spatial dimensions. S24. By using skip connections, the features of the encoder and the decoder at the same level are concatenated to fuse low-level positional information and high-level semantic information. S25. The output layer uses 1×1 convolution and the Sigmoid activation function to output a processed binarized segmented image.

[0009] Preferably, the Bayesian optimization in S3 includes the following sub-steps: S31. Set the search range of hyperparameters, including batch size, initial learning rate, dropout rate, loss function, optimizer, and regularization coefficient; S32. By using the discrete parameter continuity method, the range of discrete hyperparameter values ​​is mapped to a continuous interval; S33. Based on the Bayesian optimization framework, iteratively calculate the model performance under different combinations of hyperparameters; S34. Select the globally optimal hyperparameter combination that maximizes the convergence of the model's loss function and minimizes the final loss value.

[0010] Preferably, in S31: The search range for batch size is 4, 8, 16, 32, and 64; The initial learning rate is searched within a range of 10. -5 Up to 10 -3 ; The search range for dropout rate is 0 to 1; Loss functions include WCE, Focal Loss, F1-Score Loss, and F1-Score Loss with Dilation; Optimizers include SGD, Adam, and RMSprop; The search range for the regularization coefficient is 10. -5 Up to 10 -1 .

[0011] Preferably, the expressions for each loss function are as follows: The formula for calculating WCE is: ; In the formula, Indicates the weight of positive samples; The labels represent the real background, with 0 indicating the background and 1 indicating the crack. This represents the predicted probability output by the model (the value after Sigmoid activation). This represents the weighted cross-entropy loss function; The formula for calculating Focal Loss is: ; In the formula, This indicates the focus parameter (default 2.0). This represents the category balance factor (default 0.25). Represents the focus loss function; The formula for calculating F1-Score Loss is: ; In the formula, Indicates the smoothing term. This represents the unthresholded probability of the model output. This represents the F1 loss function; The formula for calculating F1-Score Loss with Dilation is: ; In the formula, This represents the mask after morphological dilation of the actual label. This represents the F1 loss function after inflation.

[0012] Preferably, training in S4 includes the following sub-steps: S41. Call the globally optimal hyperparameter combination obtained by Bayesian optimization in S34; S42. The masonry crack damage image dataset after data augmentation in S1 is used as training samples and input into the improved U-Net network model constructed in S2. S43. Based on the loss function in the optimal hyperparameter combination, calculate the loss value between the model prediction value and the true label in real time. S44. With the loss value as the optimization objective, the loss value is fed back to each layer of the model through the backpropagation algorithm. Combined with the selected optimizer, the network weights and biases of the model are iteratively updated to continuously reduce the loss function value. S45. Repeat S43 and S44 until the loss function value tends to stabilize and the model reaches convergence, thus obtaining the trained crack segmentation model.

[0013] Preferably, the performance evaluation of the model trained in S4 in S5 is specifically as follows: The trained crack segmentation model is used to segment cracks in masonry images and output the location and shape information of the cracks. The crack segmentation model was evaluated using precision, recall, and F1-Score. Precision measures the model's ability to identify cracks, and is expressed as follows: ; Recall rate reflects the degree to which actual crack pixels are correctly classified, and is expressed as follows: ; The F1 score is the harmonic mean of precision and recall, expressed as follows: ; Wherein, TP represents true positive, indicating the number of positive samples correctly predicted by the model; FP represents false positive, indicating the number of positive samples incorrectly predicted by the model; and FN represents false negative, indicating the number of negative samples incorrectly predicted by the model.

[0014] Therefore, the present invention employs the above-mentioned deep learning-based method for crack segmentation in masonry structures, which has the following beneficial effects: (1) This invention introduces a convolutional block attention module (CBAM) on the basis of the U-Net network model to enhance the ability to express key features. At the same time, it combines the feature fusion strategy of encoder and decoder to effectively improve the accuracy of crack segmentation, especially in complex backgrounds and multi-scale cracks, it can still maintain accurate segmentation.

[0015] (2) The present invention uses Bayesian optimization algorithm to optimize key hyperparameters of the model such as batch size, learning rate, dropout rate, loss function, optimizer, and regularization coefficient, thereby reducing the cost of manual trial and error, improving the adaptability and generalization ability of the model on different datasets, and further improving the performance of the model.

[0016] (3) This invention automatically crops crack images to uniformly processed pixels using OpenCV and uses LabelMe for fine annotation to construct a high-quality masonry crack dataset. In addition, data augmentation techniques are combined to expand the dataset size, improve the stability of the model under different lighting, angle and noise interference conditions, and improve the reliability in practical applications.

[0017] (4) By introducing a skip connection and attention fusion mechanism between the encoder and the decoder, the present invention effectively preserves the detailed information of the crack and improves the ability to segment multi-scale cracks.

[0018] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description

[0019] Figure 1 This is an overall flowchart of a deep learning-based method for crack segmentation in masonry structures according to the present invention. Figure 2 This is a schematic diagram of the network architecture of the improved U-Net network model according to an embodiment of the present invention; Figure 3This is a schematic diagram illustrating the principle of embedding the convolutional block attention module into a U-Net convolutional block according to an embodiment of the present invention. Figure 4 This is a schematic diagram of the channel attention module according to an embodiment of the present invention; Figure 5 This is a schematic diagram of the spatial attention module according to an embodiment of the present invention; Figure 6 This is an example schematic diagram of data augmentation processing according to an embodiment of the present invention, wherein (a) is the original image, (b) is the height translation change, (c) is the width translation change, (d) is the horizontal flip change, (e) is the scaling change, and (f) is the rotation change; Figure 7 The following is an example of the segmentation effect of the improved U-Net network model in the masonry crack segmentation task according to the embodiment of the present invention. Among them, (a) is a narrow and long vertical through crack in the brick, (b) is a low-contrast vertical crack at the interface, (c) is a stepped oblique structural crack, (d) is an extremely fine point crack, (e) is a surface damage crack with missing bricks, and (f) is an extremely narrow micro crack at the interface. Detailed Implementation

[0020] The following detailed description of embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.

[0021] Please see Figures 1-5 A deep learning-based method for crack segmentation in masonry structures includes the following steps: S1. Construct a masonry crack damage image dataset. Through data collection, unified cropping, manual annotation, and data augmentation, standardized training samples are formed to lay the data foundation for model training. Specifically, constructing the masonry crack damage image dataset involves: S11. Collect masonry images from different scenes and select images containing cracks as the original dataset; S12. Use OpenCV to uniformly crop the images filtered in S11 to a uniform size (e.g., 224×224 pixels) to ensure data format uniformity; S13. Use LabelMe software to manually label the cracks and construct the initial dataset of masonry cracks; S14. Expand the dataset size through data augmentation to improve the model's generalization ability and make it more adaptable to different scenarios; among which, data augmentation includes height translation, width translation, horizontal flipping, scaling and rotation.

[0022] S2. Based on the dataset constructed in S1, an improved U-Net network model with convolutional block attention modules is established. By embedding dual channel and spatial attention mechanisms in the encoder and decoder, the extraction capability of key crack features is enhanced, serving as a masonry crack damage segmentation model. The improved U-Net network architecture involves introducing a convolutional block attention module after each convolutional block in both the encoder and decoder to enhance the expression of crack features in both channel and spatial dimensions. The construction of the improved U-Net network architecture includes the following sub-steps: S21. Input the 224×224×3 masonry crack image into the input layer of the improved U-Net neural network that accepts the original data; S22. In the encoder, the input image is subjected to two convolution operations through a 3×3 convolutional layer, followed by batch normalization and ReLU activation to enhance the feature representation capability through non-linear mapping; a convolutional block attention module is used to extract features of crack channels and spatial dimensions; max pooling is used to reduce the resolution while retaining significant features (such as edges and textures), and the receptive field is gradually expanded to capture the global context. S23. In the decoder, the low-resolution feature map is expanded to its original size by transposed convolution upsampling to restore spatial information; overfitting of the model is prevented by adding a Dropout operation before the convolution operation; and the convolutional block attention module is used to fuse the feature map in both channel and spatial dimensions. S24. By using skip connections, the features of the encoder and the decoder at the same level are concatenated to fuse low-level positional information and high-level semantic information, thus avoiding the loss of details. S25. The output layer uses 1×1 convolution and the Sigmoid activation function to output a 224×224×1 binarized segmented image.

[0023] S3. Based on the model established in S2, the Bayesian optimization algorithm is used to globally optimize the model's hyperparameters. Through iterative search, the optimal combination of hyperparameters that maximizes model performance is determined, providing the optimal configuration for model training. The Bayesian optimization includes the following sub-steps: S31. Set the search range for hyperparameters, including batch size, initial learning rate, dropout rate, loss function, optimizer, and regularization coefficient; specifically: The search range for batch size is 4, 8, 16, 32, and 64; The initial learning rate is searched within a range of 10. -5 Up to 10 -3 ; The search range for dropout rate is 0 to 1; The loss functions include WCE (weighted cross-entropy loss), Focal Loss, F1-Score Loss, and F1-Score Loss with Dilation. Optimizers include SGD (Stochastic Gradient Descent), Adam (Adaptive Moment Estimation Optimizer), and RMSprop (Root Mean Square Propagation Optimizer). The search range for the regularization coefficient is 10. -5 Up to 10 -1 .

[0024] The expressions for each loss function are as follows: The formula for calculating WCE is: ; In the formula, Indicates the weight of positive samples; The labels represent the real background, with 0 indicating the background and 1 indicating the crack. This represents the predicted probability output by the model (the value after Sigmoid activation). This represents the weighted cross-entropy loss function; The formula for calculating Focal Loss is: ; In the formula, This indicates the focus parameter (default 2.0). This represents the category balance factor (default 0.25). Represents the focus loss function; The formula for calculating F1-Score Loss is: ; In the formula, Indicates the smoothing term. This represents the unthresholded probability of the model output. This represents the F1 loss function; The formula for calculating F1-Score Loss with Dilation is: ; In the formula, This represents the mask after morphological dilation of the actual label. This represents the F1 loss function after inflation.

[0025] S32. By using the discrete parameter continuity method, the range of discrete hyperparameter values ​​is mapped to a continuous interval; S33. Based on the Bayesian optimization framework, iteratively calculate the model performance under different combinations of hyperparameters; S34. Select the globally optimal hyperparameter combination that maximizes the convergence of the model's loss function and minimizes the final loss value.

[0026] S4. Based on the hyperparameter combination determined in S3, train the model established in S2 using the dataset constructed in S1. Iterate and update the network parameters through backpropagation and the optimizer until the model converges, obtaining the trained crack segmentation model. The training process includes the following sub-steps: S41. Call the globally optimal hyperparameter combination obtained by Bayesian optimization in S34; S42. The masonry crack damage image dataset after data augmentation in S1 is used as training samples and input into the improved U-Net network model constructed in S2. S43. Based on the loss function in the optimal hyperparameter combination, call the selected loss function (WCE, Focal Loss, F1-Score Loss or F1-Score Loss with Dilation) in the optimal hyperparameter combination, and calculate the loss value between the model prediction value and the true label in real time according to the corresponding loss function calculation formula. S44. With the loss value as the optimization objective, the loss value is fed back to each layer of the model through the backpropagation algorithm. Combined with the selected optimizer, the network weights and biases of the model are iteratively updated to continuously reduce the loss function value. S45. Repeat S43 and S44 until the loss function value tends to stabilize and the model reaches convergence, thus obtaining the trained crack segmentation model.

[0027] S5. Evaluate the performance of the model trained in S4, using pre-defined evaluation metrics to quantify the model's segmentation accuracy and robustness, and verify its effectiveness in the masonry crack segmentation task; specifically, the performance evaluation of the model trained in S4 includes: The trained crack segmentation model is used to segment cracks in masonry images and output the location and shape information of the cracks. The crack segmentation model was evaluated using precision, recall, and F1-Score. Precision measures the model's ability to identify cracks, and is expressed as follows: ; Recall rate reflects the degree to which actual crack pixels are correctly classified, and is expressed as follows: ; The F1 score is the harmonic mean of precision and recall, expressed as follows: ; Wherein, TP represents true positive, indicating the number of positive samples correctly predicted by the model; FP represents false positive, indicating the number of positive samples incorrectly predicted by the model; and FN represents false negative, indicating the number of negative samples incorrectly predicted by the model.

[0028] Example The method was implemented using Python and the Tensorflow deep learning framework, running on a CPU. The effectiveness and reliability of the segmentation method were verified by combining images of masonry cracks in actual engineering structures. To ensure accuracy and consistency, the training, testing, and prediction of the detection model were all performed in the same hardware environment, with the following computer configuration: 12th Gen Intel(R) Core(TM) i7-12700 @ 2.10GHz processor and 16GB of RAM.

[0029] 1) Creation of the masonry crack dataset: Images of masonry cracks were collected using three methods: public datasets, web searches, and on-site photography. All RGB images required manual annotation. The LabelMe masking tool was used to create crack morphologies in the engineering structure images for training the segmentation model, resulting in the original dataset. This dataset contains 350 original photographs and 350 annotations, showcasing various types and sizes of masonry cracks against complex backgrounds. All photographs were segmented into 224×224 pixel image blocks. Data augmentation was performed on the original dataset, such as... Figure 6 As shown, the following operations are used: "height translation" moves the image vertically by a certain distance; "width translation" moves the image horizontally; "horizontal flip" flips the image along the horizontal central axis; "scaling" enlarges or reduces the image by a certain ratio; and "rotation" rotates the image around the center point. Through these operations, the amount of data is expanded to 6 times the original, enriching the diversity of the dataset.

[0030] 2) Improve the establishment of the U-Net network model: First, a CBAM module is defined, comprising a channel attention module and a spatial attention module. The channel attention module extracts channel features and calculates channel weights through global average pooling and global max pooling, and normalizes them using sigmoid to enable the model to focus on more important features. Next, the spatial attention module calculates spatial weights through average pooling and max pooling to enhance the model's feature representation capabilities. The overall model flow first receives the image through the input layer and extracts features using multi-level convolutional blocks in the encoding path. C1-C5 (where C1 represents the first convolutional block, and so on) undergo two convolutions, batch normalization, and ReLU activation before the CBAM module is introduced to enhance channel and spatial attention. Simultaneously, max pooling is used to gradually reduce spatial resolution, and Dropout is added between C3-C5 for regularization. The deepest bottleneck layer, C5, continues to apply the CBAM module to strengthen the expression of high-level semantic features. In the decoding path, the model performs upsampling through deconvolution and makes skip connections with the corresponding features of the encoding path. Then, c6-c9 are processed by two convolutions and an additional CBAM module is added to improve segmentation accuracy, restore spatial information, highlight the salient features of the target region, and reduce background interference. Finally, the output layer uses a combination of single-channel 1x1 convolution and the Sigmoid activation function to achieve an output of arbitrary size.

[0031] 3) Perform Bayesian optimization training on the model: Bayesian optimization was used to fine-tune the hyperparameters of the improved U-Net network model. These hyperparameters included batch size, initial learning rate, dropout rate, loss function, optimizer, and regularization coefficient. The search range for Bayesian optimization was: batch size of 4, 8, 16, 32, and 64; initial learning rate of 10. -5 Up to 10 -3 The dropout rate is between 0 and 1; the loss function includes WCE, Focal Loss, F1-Score Loss, and F1-Score Loss with Dilation; the optimizers used are SGD, Adam, and RMSprop; the regularization coefficient is within 10. -5 Up to 10 -1 Interval. The discrete hyperparameter value range is mapped to a continuous interval for optimization using the discrete parameter continuity method. For example, if the search range for batch size (BS) is {4, 8, 16, 32, 64}, then the hyperparameter value range is set to [0, 4], and mapped according to the Bayesian optimization output: 0–0.499 corresponds to 4, 0.5–1.499 corresponds to 8, and so on.

[0032] 4) Model training and evaluation: Based on the optimal hyperparameter combination configuration, we performed a deep training on the augmented dataset for 100 epochs. Accurately segmenting the width of cracks is a highly challenging task, and crack detection evaluation typically allows for a certain tolerance range. For example, when background pixels are predicted as cracks (FP), if these pixels are several pixels away from the labeled cracks, they can be considered true cracks (TP). Notably, the model's segmentation performance on the validation set is particularly outstanding, such as... Figure 7 As shown, Figure 7 (a) shows the original image as a narrow, long, vertically penetrating crack in the brick. The model achieves 100% recall, completely capturing long-distance micro-cracks with extremely high edge fit and accuracy. Figure 7 (b) shows that the original image has a low-contrast interface with vertical cracks and strong texture interference. The model maintains 100% accuracy, has no false positive annotations, and has outstanding anti-interference ability. Figure 7 (c) shows that the original image is a stepped, oblique structural crack with a tortuous and varied shape. The model achieves pixel-level matching and accurately restores the complex topological structure, with an F1-score of 99%. Figure 7 (d) shows that the original image is a very fine point crack. The model successfully captures early micro-damage that is easily ignored and maintains high sensitivity at 99% high accuracy. Figure 7 (e) shows the original image as a brick-like surface damage with missing bricks. The model has strong generalization and recognition capabilities and completely outlines the irregular gap contours without omission. Figure 7 (f) shows the original image as an extremely narrow micro-crack at the interface. The model accurately identifies the crack under low-contrast interference, maintaining 100% accuracy and demonstrating excellent robustness. Its output binarized prediction map not only completely preserves the spatial distribution features of the crack in the original image but also accurately captures subtle morphological changes in the crack. The model can clearly predict the spatial location and geometric shape of the crack, and its prediction results match the actual crack in key dimensions such as length and width, reaching professional-grade engineering application standards.

[0033] Therefore, this invention employs a deep learning-based method for masonry structure crack segmentation, which mainly includes the following steps: First, a masonry crack damage image dataset is constructed through image acquisition, unified cropping, manual annotation, and data augmentation. Second, an improved U-Net network model is constructed, embedding convolutional block attention modules in the encoder and decoder to enhance the expression of crack features in both channel and spatial dimensions. Next, a Bayesian optimization algorithm is used to globally optimize hyperparameters such as batch size, learning rate, dropout rate, loss function, optimizer, and regularization coefficient. Then, the model is trained using the optimal hyperparameter combination, and the network parameters are iteratively updated through backpropagation and the optimizer until convergence. Finally, precision, recall, and F1-Score are used to evaluate the segmentation accuracy and robustness of the model. This method effectively improves the accuracy and generalization ability of crack segmentation.

[0034] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.

Claims

1. A method for crack segmentation in masonry structures based on deep learning, characterized in that, Includes the following steps: S1. Construct a dataset of masonry crack damage images. Through data collection, unified cropping, manual annotation, and data augmentation, standardized training samples are formed to lay the data foundation for model training. S2. Based on the dataset constructed in S1, an improved U-Net network model with convolutional block attention module is established. By embedding channel and spatial dual attention mechanism in the encoder and decoder, the ability to extract key crack features is enhanced, serving as a masonry crack damage segmentation model. S3. Based on the model established in S2, the Bayesian optimization algorithm is used to globally optimize the hyperparameters of the model. The combination of hyperparameters that optimizes the model performance is determined through iterative search, providing the optimal configuration for model training. S4. Based on the hyperparameter combination determined in S3, train the model established in S2 using the dataset constructed in S1. Iterate and update the network parameters through backpropagation and optimizer until the model converges, and obtain the trained crack segmentation model. S5. Evaluate the performance of the model trained in S4. Use preset evaluation indicators to quantify the segmentation accuracy and robustness of the model and verify its effectiveness in the masonry crack segmentation task.

2. The method for crack segmentation in masonry structures based on deep learning according to claim 1, characterized in that, The specific details of constructing the masonry crack damage image dataset in S1 are as follows: S11. Collect masonry images from different scenes and select images containing cracks as the original dataset; S12. Use OpenCV to crop the images filtered in S11 to the same size. S13. Use LabelMe software to manually label the cracks and construct the initial dataset of masonry cracks; S14. Expand the dataset size through data augmentation; where data augmentation includes height translation, width translation, horizontal flipping, scaling, and rotation.

3. The method for crack segmentation in masonry structures based on deep learning according to claim 2, characterized in that, The improved U-Net network architecture in S2 introduces a convolutional block attention module after each convolutional block in both the encoder and decoder to enhance the expression of crack features in both the channel and spatial dimensions.

4. The method for crack segmentation in masonry structures based on deep learning according to claim 3, characterized in that, The construction of the improved U-Net network architecture includes the following sub-steps: S21. Input the processed crack image into the input layer of the improved U-Net neural network that accepts the original data; S22. In the encoder, the input image is subjected to two convolution operations through a 3×3 convolutional layer, followed by batch normalization and ReLU activation to enhance the feature representation capability through non-linear mapping; a convolutional block attention module is used to extract features of crack channels and spatial dimensions; max pooling is used to reduce the resolution while retaining salient features. S23. In the decoder, the low-resolution feature map is expanded to its original size by transposed convolution upsampling to restore spatial information; overfitting of the model is prevented by adding a Dropout operation before the convolution operation; and the convolutional block attention module is used to fuse the feature map in both channel and spatial dimensions. S24. By using skip connections, the features of the encoder and the decoder at the same level are concatenated to fuse low-level positional information and high-level semantic information. S25. The output layer uses 1×1 convolution and the Sigmoid activation function to output a processed binarized segmented image.

5. The method for crack segmentation in masonry structures based on deep learning according to claim 4, characterized in that, Bayesian optimization in S3 includes the following sub-steps: S31. Set the search range of hyperparameters, including batch size, initial learning rate, dropout rate, loss function, optimizer, and regularization coefficient; S32. By using the discrete parameter continuity method, the range of discrete hyperparameter values ​​is mapped to a continuous interval; S33. Based on the Bayesian optimization framework, iteratively calculate the model performance under different combinations of hyperparameters; S34. Select the globally optimal hyperparameter combination that maximizes the convergence of the model's loss function and minimizes the final loss value.

6. The method for crack segmentation in masonry structures based on deep learning according to claim 5, characterized in that, In S31: The search range for batch size is 4, 8, 16, 32, and 64; The initial learning rate is searched within a range of 10. -5 Up to 10 -3 ; The search range for dropout rate is 0 to 1; Loss functions include WCE, Focal Loss, F1-Score Loss, and F1-Score Loss with Dilation; Optimizers include SGD, Adam, and RMSprop; The search range for the regularization coefficient is 10. -5 Up to 10 -1 .

7. The method for crack segmentation in masonry structures based on deep learning according to claim 6, characterized in that, The expressions for each loss function are as follows: The formula for calculating WCE is: ; In the formula, Indicates the weight of positive samples; The labels represent the real background, with 0 indicating the background and 1 indicating the crack. This represents the predicted probability output by the model; This represents the weighted cross-entropy loss function; The formula for calculating Focal Loss is: ; In the formula, Indicates the focus parameter, Represents the category balance factor. Represents the focus loss function; The formula for calculating F1-Score Loss is: ; In the formula, Indicates the smoothing term. This represents the unthresholded probability of the model output. This represents the F1 loss function; The formula for calculating F1-Score Loss with Dilation is: ; In the formula, This represents the mask after morphological dilation of the actual label. This represents the F1 loss function after inflation.

8. The method for crack segmentation in masonry structures based on deep learning according to claim 7, characterized in that, Training in S4 includes the following sub-steps: S41. Call the globally optimal hyperparameter combination obtained by Bayesian optimization in S34; S42. The masonry crack damage image dataset after data augmentation in S1 is used as training samples and input into the improved U-Net network model constructed in S2. S43. Based on the loss function in the optimal hyperparameter combination, calculate the loss value between the model prediction value and the true label in real time. S44. With the loss value as the optimization objective, the loss value is fed back to each layer of the model through the backpropagation algorithm. Combined with the selected optimizer, the network weights and biases of the model are iteratively updated to continuously reduce the loss function value. S45. Repeat S43 and S44 until the loss function value tends to stabilize and the model reaches convergence, thus obtaining the trained crack segmentation model.

9. A method for crack segmentation in masonry structures based on deep learning according to claim 8, characterized in that, The performance evaluation of the model trained in S4 in S5 is as follows: The trained crack segmentation model is used to segment cracks in masonry images and output the location and shape information of the cracks. The crack segmentation model was evaluated using precision, recall, and F1-Score. Precision measures the model's ability to identify cracks, and is expressed as follows: ; Recall rate reflects the degree to which actual crack pixels are correctly classified, and is expressed as follows: ; The F1 score is the harmonic mean of precision and recall, expressed as follows: ; Wherein, TP represents true positive, indicating the number of positive samples correctly predicted by the model; FP represents false positive, indicating the number of positive samples incorrectly predicted by the model; and FN represents false negative, indicating the number of negative samples incorrectly predicted by the model.