Intelligent Detection Method and System for Surface Defects in Building Curtain Walls Based on Swin Transformer

By using the Swin Transformer backbone network and an improved multi-scale attention module, combined with a composite loss function and multi-stage preprocessing, the problem of insufficient small target feature extraction in traditional convolutional neural networks in curtain wall detection is solved, achieving high-precision defect detection and localization, and supporting automated safety assessment report generation.

CN122492669APending Publication Date: 2026-07-31广东省有色工业建筑质量检测站有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
广东省有色工业建筑质量检测站有限公司
Filing Date
2026-05-26
Publication Date
2026-07-31

AI Technical Summary

Technical Problem

Traditional convolutional neural networks are insufficient in extracting features from small targets such as minute cracks and bubbles in building curtain wall inspection. Furthermore, images acquired by drones are often accompanied by tilted viewpoints and perspective distortion, making it difficult to meet engineering acceptance standards for defect localization and size assessment accuracy.

Method used

A smart defect detection method for building curtain wall surfaces based on Swin Transformer is adopted. An initial defect detection model is constructed, including a Swin Transformer backbone network, an improved multi-scale attention module, and a defect detection head. The model is trained using a composite loss function and combined with a multi-stage preprocessing mechanism to eliminate illumination interference and geometric distortion, thereby improving detection accuracy and positioning accuracy.

Benefits of technology

It significantly improves the detection accuracy and positioning accuracy of small-scale defects such as microcracks and bubbles in complex outdoor environments, and realizes the automated process from image acquisition to report output, which has good engineering application value.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122492669A_ABST
    Figure CN122492669A_ABST
Patent Text Reader

Abstract

This invention discloses an intelligent detection method and system for surface defects in building curtain walls based on the Swin Transformer. The method includes the following steps: constructing an enhanced defect dataset based on historical building curtain wall images; constructing an initial defect detection model, including a cascaded Swin Transformer backbone network, an improved multi-scale attention module, and a defect detection head; the improved multi-scale attention module fuses deep and shallow features, performing channel and spatial dimension weighting and residual connections sequentially; iteratively training the initial defect detection model using the enhanced defect dataset and a composite loss function to obtain a target defect detection model; after obtaining preliminary defect detection results from the input image, using a non-maximum suppression algorithm to remove duplicate prediction boxes to obtain the final defect detection result. This invention solves the problems of difficulty in detecting small target defects, strong interference from complex lighting, and insufficient detection accuracy in existing technologies.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of artificial intelligence and building structure safety inspection technology. Specifically, it relates to an intelligent detection method and system for surface defects of building curtain walls based on Swing Transformer. Background Technology

[0002] As modern urban architecture develops towards high-rise buildings and large-area glass curtain walls, the safety and appearance quality of the curtain wall structure are directly related to the safety and aesthetics of the building. However, traditional curtain wall inspection methods mainly rely on manual high-altitude visual inspection or suspended platform operations, which have problems such as low inspection efficiency, high risk of high-altitude operations, poor consistency of subjective judgment, and difficulty in identification under complex lighting conditions.

[0003] In recent years, computer vision-based automatic detection technology has been increasingly applied to the field of building safety. However, traditional convolutional neural networks (CNNs) are insufficient in their ability to extract features from small targets such as minute cracks and bubbles when faced with strong specular reflections and background texture interference from glass curtain walls. In addition, images acquired by drones are often accompanied by perspective tilt and distortion, and existing methods lack targeted geometric correction and illumination decoupling preprocessing mechanisms, making it difficult to meet engineering acceptance standards in terms of defect location and size assessment accuracy. Summary of the Invention

[0004] The purpose of this invention is to overcome the shortcomings and deficiencies of the existing technology and provide an intelligent detection method for surface defects of building curtain walls based on SwinTransformer. This method overcomes the problem of loss of small target details caused by downsampling of traditional convolutional neural networks and improves the detection accuracy and positioning accuracy of small-scale defects such as fine cracks and bubbles in complex outdoor environments.

[0005] The second objective of this invention is to provide an intelligent detection system for surface defects in building curtain walls based on Swin Transformer.

[0006] The objective of this invention is achieved through the following technical solution: an intelligent detection method for surface defects in building curtain walls based on Swing Transformer, comprising the following steps:

[0007] S1. Obtain images of the curtain walls of historical buildings, perform preprocessing, defect annotation, and data augmentation on the images, and construct an enhanced defect dataset;

[0008] S2. Construct an initial defect detection model, which includes a cascaded SwinTransformer backbone network, an improved multi-scale attention module, and a defect detection head. The improved multi-scale attention module fuses the deep and shallow features output by the SwinTransformer backbone network into a fused feature. This fused feature is then weighted sequentially by channel dimension and spatial dimension. Finally, the spatially weighted feature is added element-wise to the fused feature via residual connections and input into the defect detection head, which outputs a preliminary defect detection result. Using the enhanced defect dataset, the initial defect detection model is iteratively trained using a composite loss function to obtain the target defect detection model.

[0009] S3. Obtain the original image of the building curtain wall to be tested, and preprocess the image to obtain the image to be tested;

[0010] S4. Input the image to be tested into the target defect detection model to obtain preliminary defect detection results, and use the non-maximum suppression algorithm to remove duplicate prediction boxes from the preliminary defect detection results to obtain the final defect detection results.

[0011] Preferably, in step S1, the image preprocessing includes:

[0012] S11. Reflection suppression processing based on homomorphic filtering: The image is decomposed into the product of illumination component and reflection component. The low-frequency illumination component is weakened by a frequency domain high-pass filter, and the high-frequency edge texture information is enhanced.

[0013] S12. Brightness equalization processing based on contrast-limited adaptive histogram equalization: The image is divided into multiple local blocks, and histogram equalization is performed on each block separately, while the contrast amplitude is limited.

[0014] S13. Distortion correction processing based on perspective transformation: Extract the posture data of the image acquisition device, combine it with the building curtain wall outline feature lines detected by Hough transform, calculate the four-point perspective transformation matrix, and correct the tilted view image to a standard front view.

[0015] S14. Bilateral filtering denoising: Bilateral filters are used to perform edge-preserving denoising on the image.

[0016] Preferably, in step S2, the improved multi-scale attention module specifically includes:

[0017] The upsampling layer is used to perform bilinear interpolation upsampling on deep features so that the spatial size of deep features is consistent with the spatial size of shallow features.

[0018] The channel stitching layer is used to stitch together the upsampled deep features with the shallow features to generate stitched features.

[0019] A 1×1 convolutional layer is used to reduce the dimensionality of the spliced ​​features to obtain the fused features;

[0020] The channel attention branch is used to perform global max pooling and global average pooling on the fused features in parallel. The pooling results are input into a multilayer perceptron with shared weights. The two outputs of the multilayer perceptron are added element by element and then activated by Sigmoid to generate a channel weight vector. The channel weight vector is then multiplied with the fused features channel by channel to output the channel-enhanced features.

[0021] The spatial attention branch is used to perform max pooling and average pooling on the channel enhancement features in parallel along the channel dimension. The pooling results are concatenated and then activated by a 7×7 convolution and a sigmoid function to generate a spatial weight map. The spatial weight map is then multiplied element-wise with the channel enhancement features to output the spatial enhancement features.

[0022] The residual connection layer is used to add the spatial enhancement features to the fused features element by element, and output the final fused features.

[0023] Preferably, in step S2, the specific training steps of the target defect detection model include:

[0024] S21. Construct a composite loss function: use Focal Loss as the classification loss and CIoU Loss as the regression loss, and employ a label smoothing strategy to suppress overfitting; the expression for Focal Loss is:

[0025] ,

[0026] Where, p t α represents the predicted probability of the defect detection head for the true category. t Here, γ is the category weighting factor, and γ is the focusing parameter;

[0027] S22. Set training optimization strategy: Use AdamW optimizer to optimize the parameters of the initial defect detection model, and use cosine annealing with warm-up adaptive learning rate mechanism to adjust the learning rate;

[0028] S23. Iterative training: The initial defect detection model is iteratively trained using the enhanced defect dataset until the composite loss function converges, thus obtaining the target defect detection model.

[0029] Preferably, the preliminary defect detection results include defect category, defect confidence level, and bounding box coordinates.

[0030] Preferably, after step S4, the method further includes: superimposing the defect target in the final defect detection result onto the original image through coordinate mapping to generate a defect superimposed visualization image.

[0031] Preferably, after step S4, the method further includes: storing the final defect detection results in the form of structured data in the curtain wall inspection database, and generating a safety assessment report, wherein the safety assessment report includes a defect distribution chart.

[0032] Preferably, in step S1, the data augmentation includes random rotation, mirror flipping, and brightness perturbation operations; the defect annotation includes: performing precise polygon annotation on the defect area in the image to generate a label file containing defect contour coordinates and category information.

[0033] Preferably, the IoU threshold used to remove duplicate prediction boxes in the non-maximum suppression algorithm is preset according to the detection accuracy requirements.

[0034] A smart detection system for surface defects in building curtain walls based on Swin Transformer includes:

[0035] The dataset construction module is used to acquire images of the curtain walls of historical buildings, perform image preprocessing, defect annotation, and data augmentation to build an enhanced defect dataset;

[0036] The model training module is used to construct an initial defect detection model, which includes a cascaded Swin Transformer backbone network, an improved multi-scale attention module, and a defect detection head. The improved multi-scale attention module fuses the deep and shallow features output by the Swin Transformer backbone network into a fused feature. This fused feature is then weighted sequentially by channel dimension and spatial dimension. Finally, the spatially weighted feature is added element-wise to the fused feature via residual connections and input into the defect detection head, which outputs a preliminary defect detection result. Using the enhanced defect dataset, the initial defect detection model is iteratively trained using a composite loss function to obtain the target defect detection model.

[0037] The acquisition and preprocessing module is used to acquire the original image of the building curtain wall to be tested, and to preprocess the image to obtain the image to be tested;

[0038] The detection module is used to input the image to be tested into the target defect detection model to obtain preliminary defect detection results, and to use a non-maximum suppression algorithm to remove duplicate prediction boxes from the preliminary defect detection results to obtain the final defect detection results.

[0039] The present invention has the following advantages and effects compared with the prior art:

[0040] (1) This invention constructs an initial defect detection model by cascading an initial defect detection model consisting of a Swing Transformer backbone network, an improved multi-scale attention module, and a defect detection head, and trains it using a composite loss function to obtain a target defect detection model. The improved multi-scale attention module fuses deep features with shallow features and then performs channel dimension weighting, spatial dimension weighting, and residual connection in sequence, so that the model retains edge detail features while preserving global semantics. This overcomes the problem of loss of small target details caused by downsampling in traditional convolutional neural networks and improves the detection accuracy and localization accuracy of small-scale defects such as fine cracks and bubbles in complex outdoor environments.

[0041] (2) This invention proposes a multi-stage joint preprocessing mechanism for curtain wall images in complex environments: sequentially performing reflection suppression processing based on homomorphic filtering, brightness equalization processing based on contrast-limited adaptive histogram equalization, distortion correction processing based on perspective transformation, and bilateral filtering denoising processing. This joint preprocessing effectively eliminates illumination interference and geometric distortion, providing high-quality input for the Swin Transformer backbone network.

[0042] (3) In the improved multi-scale attention module of the present invention, the channel attention branch performs channel dimension weighting on the fusion features to filter key feature channels, the spatial attention branch performs spatial dimension weighting to accurately locate the defect area, and the residual connection layer adds the spatial enhancement features and the fusion features element by element to retain the original feature information, thereby enhancing the model's ability to capture features and spatially locate small defects in complex backgrounds.

[0043] (4) The present invention adopts a composite loss function consisting of classification loss Focal Loss and regression loss CIoU Loss. Among them, Focal Loss dynamically reduces the loss contribution of easily classified samples by focusing parameters and increases the weight of small target defects that are difficult to classify, effectively alleviating the problem of extreme imbalance between positive and negative samples; CIoU Loss simultaneously optimizes the overlap area, center point distance and aspect ratio of the predicted box and the ground truth box, improving the regression accuracy of the bounding box coordinates.

[0044] (5) This invention uses coordinate mapping to accurately overlay the defect target in the final defect detection result onto the original image, generate a defect overlay visualization image, and store the detection result in the form of structured data to generate a safety assessment report with a defect distribution chart. It realizes an automated process from image acquisition, defect identification to report output and has good engineering application value. Attached Figure Description

[0045] Figure 1 This is a flowchart illustrating the intelligent detection method for surface defects in building curtain walls based on Swin Transformer, as described in this invention.

[0046] Figure 2 This is a schematic diagram of the forward propagation process of the improved multi-scale attention module of the present invention. Detailed Implementation

[0047] The present invention will be further described in detail below with reference to the embodiments and accompanying drawings, but the embodiments of the present invention are not limited thereto.

[0048] Example 1

[0049] This embodiment describes the process of constructing an enhanced defect dataset, which is used to provide training and validation samples for model training.

[0050] Step 1-1: Acquire the original image

[0051] Image acquisition equipment includes drones or other devices (such as cameras with gimbals). In this embodiment, a drone equipped with a high-resolution camera is used to acquire raw images of building curtain wall units in different regions and under different lighting conditions. During acquisition, the attitude data of the drone's inertial measurement unit (IMU), including pitch and yaw angle data, are recorded. The raw images should cover various curtain wall materials (such as glass, stone, and metal panels) and various environmental conditions (such as bright sunlight, cloudy days, early morning and dusk), to ensure the diversity of the dataset.

[0052] Steps 1-2: Image Preprocessing

[0053] The following four preprocessing operations are performed sequentially on the acquired raw images to eliminate strong light reflection, uneven lighting, and viewing angle tilt in outdoor curtain wall inspection.

[0054] (1) Reflection suppression based on homomorphic filtering: The image is regarded as the product of illumination component and reflection component. The low-frequency strong illumination component is weakened by a frequency domain high-pass filter, while the high-frequency edge texture information is enhanced. This step can effectively weaken strong light spots and highlight the scratches and cracks that have been covered up.

[0055] (2) Adaptive brightness equalization processing based on the Contrast Limited Adaptive Histogram Equalization (CLAHE) algorithm: The image is divided into multiple local blocks, and histogram equalization is performed on each block, while limiting the contrast amplitude. Specifically, the degree of contrast enhancement is controlled by cropping the histogram amplitude. This processing can improve the visibility of defects in dark areas while preserving true colors.

[0056] (3) Distortion correction processing based on perspective transformation: Extract the attitude data of the image acquisition device, which in this embodiment is the pitch and yaw angle data of the UAV gimbal inertial measurement unit (IMU). Combine the building curtain wall outline feature lines (i.e., the main edge lines in the horizontal and vertical directions) detected by Hough transform, calculate the four-point perspective transformation matrix, and correct the tilted view image to a standard front view. This step solves the problem of defect size measurement deviation caused by the tilt of the view.

[0057] (4) Bilateral filtering denoising: Bilateral filters are used to denoise the image. While filtering out sensor noise, bilateral filters can retain high-frequency edge features such as cracks, avoiding edge blurring caused by traditional Gaussian filtering.

[0058] The four preprocessing steps are performed sequentially: first, suppress reflections; then, equalize brightness; next, correct perspective distortion; and finally, denoise. Homomorphic filtering and CLAHE address lighting issues in the frequency and spatial domains, respectively; perspective transformation restores the geometric structure; and bilateral filtering preserves edges while denoising.

[0059] Steps 1-3, Defect Marking

[0060] After preprocessing, the defective areas in the image are precisely annotated with polygons. Annotation categories include cracks, bubbles, delamination, stains, scratches, etc., generating a label file containing defect contour coordinates and category information. In this embodiment, annotation tools such as Labelme can be used for annotation, outputting a JSON format file. In practical applications, annotation information can also be stored in other structured formats such as XML and YAML.

[0061] Steps 1-4: Data Augmentation

[0062] To increase sample diversity, data augmentation operations are performed on the labeled images and their corresponding label files, including random rotation, mirror flipping, and brightness perturbation. The augmented images and the original images together constitute the augmentation defect dataset, which is then divided into a training set and a validation set at a predetermined ratio (e.g., 8:2) for model training and validation, respectively.

[0063] Example 2

[0064] This embodiment describes the construction and training process of the target defect detection model.

[0065] I. Constructing the Initial Defect Detection Model

[0066] The initial defect detection model includes a cascaded Swin Transformer backbone network, an improved Multi-Scale Attention Module (MSAM), and a defect detection head.

[0067] (1) Swin Transformer Backbone Network: The Swin Transformer is used as the backbone network for feature extraction (e.g., Swin-Tiny or Swin-Base versions can be used). The input image size can be set according to the actual detection accuracy and computational resource requirements (e.g., 640×640 or 512×512). This backbone network generates multi-resolution feature maps through a sliding window self-attention mechanism. Specifically, it gradually reduces the feature map resolution and expands the receptive field through multiple stages of Patch Merging, outputting feature maps of multiple scales. Among them, shallow features retain rich edge details, while deep features contain global semantic information.

[0068] (2) Improved Multi-Scale Attention Module (MSAM): The structure of the improved multi-scale attention module is specifically designed for the detection of minute defects in curtain walls. Compared with conventional attention modules (such as those using only average pooling and single-scale convolution), the improved multi-scale attention module has the following improvements:

[0069] Parallel dual-pooling strategy: The channel attention branch simultaneously employs global max pooling and global average pooling, which are executed in parallel to retain richer feature information and avoid the loss of details caused by single pooling.

[0070] Shared-weight MLP: In the channel attention branch, the two pooling results are input into a shared-weight multilayer perceptron (MLP). The two outputs of the MLP are summed element-wise and then activated by a sigmoid function to generate the channel weight vector. This design controls the number of parameters while ensuring feature richness.

[0071] Large receptive field convolution: The spatial attention branch uses 7×7 convolution, which has a larger receptive field than the conventional 3×3 convolution. It can capture a wider range of spatial context information, which is beneficial for accurately locating the distribution area of ​​small defects.

[0072] Channel and spatial attention are sequentially connected: channel attention is processed first, followed by spatial attention, forming a clear cascade structure.

[0073] Residual connection: The spatially weighted features are added element by element to the fused features, preserving the original information and alleviating the gradient vanishing problem in deep network training.

[0074] like Figure 2 As shown, the improved multi-scale attention module comprises the following structure: an upsampling layer, a channel splicing layer, a 1×1 convolutional layer, a channel attention branch, a spatial attention branch, and a residual connection layer. The specific forward propagation process is as follows:

[0075] Upsampling layer: Upsamples deep features through bilinear interpolation to make the spatial size of deep features consistent with that of shallow features.

[0076] Channel stitching layer: The upsampled deep features and shallow features are stitched together along the channel dimension to generate stitched features.

[0077] 1×1 convolutional layer: Reduces the dimensionality of the concatenated features to obtain the fused feature F. fuse .

[0078] Channel attention branch: for fused features F fuse Global max pooling and global average pooling are performed in parallel. The results of the two pooling operations are then input into a multilayer perceptron (MLP) with shared weights. The two outputs of the MLP are summed element-wise, followed by sigmoid activation to generate the channel weight vector W. c Then the channel weight vector W c With fusion feature F fuse Channel-by-channel multiplication to output channel-enhanced feature F c This is to suppress invalid background channels such as reflections.

[0079] Spatial attention branch: enhancing channel features F c Max pooling and average pooling are performed in parallel along the channel dimension. The pooling results are concatenated and then passed through a 7×7 convolutional layer with sigmoid activation to generate a spatial weight map W. s Then, the spatial weight map W s With channel enhancement feature F c Element-wise multiplication outputs spatially enhanced features F s To accurately locate minute defects.

[0080] Residual connection layer: spatially enhanced feature F s With fusion feature F fuse Add elements one by one to output the final fused feature F. out =F s +F fuse This residual connection ensures that the original fused feature information is not lost, while also mitigating the gradient vanishing problem in deep network training.

[0081] (3) Defect detection head: It consists of two parallel branches. The classification branch outputs the defect category and the corresponding confidence level (e.g., the probability of categories such as cracks, bubbles, delamination, stains, scratches, etc.), and the regression branch outputs the offset of the bounding box (center coordinates, width, height). Therefore, the output of the defect detection head includes the defect category, defect confidence level, and bounding box coordinates of the target area, which serve as the preliminary defect detection results.

[0082] II. Model Training

[0083] The initial defect detection model is iteratively trained using the enhanced defect dataset constructed in Example 1, with the goal of minimizing the composite loss function. Specific steps include:

[0084] Step 2-1: Construct a composite loss function

[0085] The classification loss uses Focal Loss, and its expression is:

[0086] ,

[0087] Where, p t α represents the predicted probability of the defect detection head for the true category. t γ is the class weighting factor, and γ is the focusing parameter. Focal Loss reduces the loss contribution of easily classified samples and increases the weight of small, hard-to-classify defects. CIoU Loss is used for regression loss, comprehensively considering overlap area, center point distance, and aspect ratio to improve the bounding box fit of fine cracks. Simultaneously, a label smoothing strategy (smoothing factor can be set to, for example, 0.1) is employed to replace hard labels with soft labels, suppressing model overfitting.

[0088] Step 2-2: Set up training optimization strategy

[0089] The AdamW optimizer is used to optimize the parameters of the initial defect detection model, and an adaptive learning rate mechanism of cosine annealing with warm-up is used to adjust the learning rate: during the warm-up, the learning rate gradually increases from 0 to the initial learning rate (e.g., linear growth can be used), and the number of warm-up rounds can be set as a certain proportion of the total number of training rounds (e.g., 5%~10%); after the warm-up, the learning rate decays according to a cosine function. The initial learning rate and weight decay coefficient can be set according to the specific training task.

[0090] Steps 2-3: Iterative Training

[0091] The initial defect detection model is iteratively trained using the training set. In each iteration, the composite loss function is calculated and the parameters of the initial defect detection model are updated. After each round, the model is evaluated on the validation set. This process is repeated until the composite loss function converges, and the model parameters are saved to obtain the target defect detection model.

[0092] Example 3

[0093] This embodiment describes the complete process of using the target defect detection model trained in Embodiment 2 to detect defects in an actual building curtain wall, such as... Figure 1 As shown.

[0094] Step 3-1: Acquire and preprocess images

[0095] Acquire the original image of the building curtain wall to be tested and the corresponding UAV attitude data. Perform the same preprocessing operations as in Example 1 on the original image: perform homomorphic filtering for reflection suppression, CLAHE brightness equalization, perspective transformation distortion correction, and bilateral filtering for noise reduction in sequence to obtain the image to be tested. This design ensures that the preprocessing of the training data and the detection data are consistent.

[0096] Step 3-2: Input the model and perform forward inference.

[0097] The image to be tested is input into the target defect detection model. Internally, the model first extracts multi-scale features via a Swing Transformer backbone network, where shallow and deep features are fed into an improved multi-scale attention module (MSAM). The improved MSAM outputs fused features according to the forward propagation process described in Example 2, and then inputs the fused features into the defect detection head to obtain preliminary defect detection results, including defect category, defect confidence, and bounding box coordinates.

[0098] Step 3-3, Post-processing

[0099] To eliminate redundant detections, this embodiment employs the Non-Maximum Suppression (NMS) algorithm and sets an IoU (Intersection over Union) threshold to remove duplicate predicted boxes. Specifically, all detected boxes are sorted in descending order of confidence level, the highest-confidence box is retained, the IoU between the highest-confidence box and the remaining boxes is calculated, and boxes with an IoU greater than the threshold are removed. This process is repeated until all boxes have been processed, yielding the final defect detection result. The IoU threshold is preset based on the required detection accuracy.

[0100] Steps 3-4, Result Output

[0101] By mapping coordinates, the coordinates of the defect bounding boxes in the final defect detection results are restored to the original image size. The defect targets are then rendered on the original image as color-coded overlays, generating a defect overlay visualization image. Simultaneously, the detection results are stored in the curtain wall inspection database as structured data, and a safety assessment report is generated based on the defect category and severity, including a defect distribution chart.

[0102] Example 4

[0103] A smart detection system for surface defects in building curtain walls based on Swin Transformer includes:

[0104] The dataset construction module is used to acquire images of the curtain walls of historical buildings, perform image preprocessing, defect annotation, and data augmentation to build an enhanced defect dataset;

[0105] The model training module is used to construct an initial defect detection model, which includes a cascaded Swin Transformer backbone network, an improved multi-scale attention module, and a defect detection head. The improved multi-scale attention module fuses the deep and shallow features output by the Swin Transformer backbone network into a fused feature. This fused feature is then weighted sequentially by channel dimension and spatial dimension. Finally, the spatially weighted feature is added element-wise to the fused feature via residual connections and input into the defect detection head, which outputs a preliminary defect detection result. Using the enhanced defect dataset, the initial defect detection model is iteratively trained using a composite loss function to obtain the target defect detection model.

[0106] The acquisition and preprocessing module is used to acquire the original image of the building curtain wall to be tested, and to preprocess the image to obtain the image to be tested;

[0107] The detection module is used to input the image to be tested into the target defect detection model to obtain preliminary defect detection results, and to use a non-maximum suppression algorithm to remove duplicate prediction boxes from the preliminary defect detection results to obtain the final defect detection results.

[0108] The specific values ​​of the parameters involved in the above embodiments (including but not limited to the focusing parameter γ of Focal Loss, class weight factor, label smoothing factor, initial learning rate, weight decay coefficient, etc.) can be configured by those skilled in the art through conventional experiments or experience based on the actual training task, dataset size, and model complexity. The values ​​given in this embodiment are merely examples and do not constitute a limitation on the scope of protection of this invention.

[0109] The above embodiments are preferred embodiments of the present invention and are not intended to limit the present invention. Any changes or other equivalent substitutions made without departing from the technical solution of the present invention are included within the protection scope of the present invention.

Claims

1. A method for intelligent detection of surface defects of building curtain walls based on a Swin Transformer, characterized in that, Includes the following steps: S1. Obtain images of the curtain walls of historical buildings, perform preprocessing, defect annotation, and data augmentation on the images, and construct an enhanced defect dataset; S2. Construct an initial defect detection model, which includes a cascaded SwinTransformer backbone network, an improved multi-scale attention module, and a defect detection head. The improved multi-scale attention module is used to fuse the deep and shallow features output by the SwinTransformer backbone network into a fused feature. The fused feature is then weighted by channel dimension and spatial dimension, and the spatial dimension weighted feature is added element-wise to the fused feature through residual connections. The fused feature is then input into the defect detection head, which outputs the preliminary defect detection result. Using the enhanced defect dataset, the initial defect detection model is iteratively trained using a composite loss function to obtain the target defect detection model; S3. Obtain the original image of the building curtain wall to be tested, and preprocess the image to obtain the image to be tested; S4. Input the image to be tested into the target defect detection model to obtain preliminary defect detection results, and use the non-maximum suppression algorithm to remove duplicate prediction boxes from the preliminary defect detection results to obtain the final defect detection results.

2. The Swin Transformer-based building curtain wall surface defect intelligent detection method according to claim 1, characterized in that, Step S1, image preprocessing includes: S11. Reflection suppression processing based on homomorphic filtering: The image is decomposed into the product of illumination component and reflection component. The low-frequency illumination component is weakened by a frequency domain high-pass filter, and the high-frequency edge texture information is enhanced. S12. Brightness equalization processing based on contrast-limited adaptive histogram equalization: The image is divided into multiple local blocks, and histogram equalization is performed on each block separately, while the contrast amplitude is limited. S13. Distortion correction processing based on perspective transformation: Extract the posture data of the image acquisition device, combine it with the building curtain wall outline feature lines detected by Hough transform, calculate the four-point perspective transformation matrix, and correct the tilted view image to a standard front view. S14. Bilateral filtering denoising: Bilateral filters are used to perform edge-preserving denoising on the image.

3. The Swin Transformer-based building curtain wall surface defect intelligent detection method according to claim 1, characterized in that, In step S2, the improved multi-scale attention module specifically includes: The upsampling layer is used to perform bilinear interpolation upsampling on deep features so that the spatial size of deep features is consistent with the spatial size of shallow features. The channel stitching layer is used to stitch together the upsampled deep features with the shallow features to generate stitched features. A 1×1 convolutional layer is used to reduce the dimensionality of the spliced ​​features to obtain the fused features; The channel attention branch is used to perform global max pooling and global average pooling on the fused features in parallel. The pooling results are input into a multilayer perceptron with shared weights. The two outputs of the multilayer perceptron are added element by element and then activated by Sigmoid to generate a channel weight vector. The channel weight vector is then multiplied with the fused features channel by channel to output the channel-enhanced features. The spatial attention branch is used to perform max pooling and average pooling on the channel enhancement features in parallel along the channel dimension. The pooling results are concatenated and then activated by a 7×7 convolution and a sigmoid function to generate a spatial weight map. The spatial weight map is then multiplied element-wise with the channel enhancement features to output the spatial enhancement features. The residual connection layer is used to add the spatial enhancement features to the fused features element by element, and output the final fused features.

4. The Swin Transformer-based building curtain wall surface defect intelligent detection method according to claim 1, characterized in that, In step S2, the specific training steps of the target defect detection model include: S21. Construct a composite loss function: use Focal Loss as the classification loss and CIoU Loss as the regression loss, and employ a label smoothing strategy to suppress overfitting; the expression for Focal Loss is: , where p t is the predicted probability of the defect detection head for the true class, a t is the class weight factor, and g is the focus parameter. S22. Set training optimization strategy: Use AdamW optimizer to optimize the parameters of the initial defect detection model, and use cosine annealing with warm-up adaptive learning rate mechanism to adjust the learning rate; S23. Iterative training: The initial defect detection model is iteratively trained using the enhanced defect dataset until the composite loss function converges, thus obtaining the target defect detection model.

5. The intelligent detection method for surface defects of building curtain walls based on Swing Transformer according to claim 1, characterized in that, The preliminary defect detection results include defect category, defect confidence level, and bounding box coordinates.

6. The intelligent detection method for surface defects of building curtain walls based on Swing Transformer according to claim 1, characterized in that, Step S4 is followed by: superimposing the defect target in the final defect detection result onto the original image through coordinate mapping to generate a defect superimposed visualization image.

7. The intelligent detection method for surface defects of building curtain walls based on Swing Transformer according to claim 1, characterized in that, Step S4 is followed by: storing the final defect detection results in the form of structured data in the curtain wall inspection database, and generating a safety assessment report, which includes a defect distribution chart.

8. The intelligent detection method for surface defects of building curtain walls based on Swing Transformer according to claim 1, characterized in that, In step S1, the data augmentation includes random rotation, mirror flipping, and brightness perturbation operations; the defect annotation includes: performing precise polygon annotation on the defect area in the image to generate a label file containing defect contour coordinates and category information.

9. The intelligent detection method for surface defects of building curtain walls based on Swing Transformer according to claim 1, characterized in that, The IoU threshold used to remove duplicate prediction boxes in the non-maximum suppression algorithm is preset according to the detection accuracy requirements.

10. A smart detection system for surface defects of building curtain walls based on Swin Transformer, characterized in that, include: The dataset construction module is used to acquire images of the curtain walls of historical buildings, perform image preprocessing, defect annotation, and data augmentation to build an enhanced defect dataset; The model training module is used to construct an initial defect detection model, which includes a cascaded Swin Transformer backbone network, an improved multi-scale attention module, and a defect detection head. The improved multi-scale attention module fuses the deep and shallow features output by the Swin Transformer backbone network into a fused feature. This fused feature is then weighted sequentially by channel dimension and spatial dimension. Finally, the spatially weighted feature is added element-wise to the fused feature via residual connections and input into the defect detection head, which outputs a preliminary defect detection result. Using the enhanced defect dataset, the initial defect detection model is iteratively trained using a composite loss function to obtain the target defect detection model. The acquisition and preprocessing module is used to acquire the original image of the building curtain wall to be tested, and to preprocess the image to obtain the image to be tested; The detection module is used to input the image to be tested into the target defect detection model to obtain preliminary defect detection results, and to use a non-maximum suppression algorithm to remove duplicate prediction boxes from the preliminary defect detection results to obtain the final defect detection results.