Component crack detection method and device, electronic equipment, storage medium and product
By using the SwinUNet backbone network and dynamic residual connection structure, the problem of noise interference in electronic nondestructive testing is solved, enabling accurate identification and highly reliable detection of micro-cracks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHINA INSTITUTE OF ATOMIC ENERGY
- Filing Date
- 2026-01-21
- Publication Date
- 2026-04-21
AI Technical Summary
Traditional electronic nondestructive testing accelerators are subject to interference from scattering effects, Compton effect, equipment vibration, and noise from composite component materials during the testing process, resulting in insufficient accuracy and reliability in identifying microcracks.
The SwinUNet backbone network is used for hierarchical feature extraction. Combined with window self-attention and shift window mechanism, and through dynamic residual connection structure and cascaded regularization transformer module, background interference is suppressed, crack features are enhanced, and accurate pixel-level segmentation is achieved.
It improves the accuracy and reliability of crack detection, ensures that critical details of narrow cracks are not overlooked, and enhances detection accuracy and robustness in complex environments.
Smart Images

Figure CN121904022A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of nondestructive testing technology, and in particular to a method, apparatus, electronic device, storage medium and product for detecting cracks in components. Background Technology
[0002] Currently, electron nondestructive testing accelerators are widely used in industrial components, particularly for the nondestructive testing and evaluation of internal defects in critical fields such as aerospace, bridges, and railways. However, during the testing process, the inherent scattering effect of the electron beam, the Compton effect, equipment vibration, and the materials of composite components introduce a large amount of noise, severely interfering with the identification of minute defects such as microcracks. Traditional image processing and detection algorithms often exhibit insufficient robustness and limited feature extraction capabilities when facing such noise interference and multi-scale crack features, resulting in insufficient accuracy and reliability in crack detection. Summary of the Invention
[0003] In view of this, embodiments of this application provide a method, apparatus, electronic device, storage medium, and product for detecting component cracks, aiming to improve the accuracy and reliability of crack detection in images acquired by an electronic nondestructive testing accelerator.
[0004] The technical solution provided in this application is implemented as follows: In a first aspect, embodiments of this application provide a method for detecting cracks in a component, the method comprising: Acquire component images obtained by scanning with an electronic nondestructive testing accelerator; A crack segmentation image is obtained based on the component image and the crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder, and the skip connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the encoder is used to perform hierarchical feature extraction on the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder.
[0005] In some embodiments, the SwinUNet backbone network further includes a bottleneck layer located between the end node of the encoder and the beginning node of the decoder. The bottleneck layer includes a cascaded regularized transformer module consisting of three cascaded Transformer modules.
[0006] In some embodiments, the dynamic residual connection structure includes an identity transformation module, a first SwingTransformer module, a second Swing Transformer module, and a first residual connection module; wherein... The input terminal of the dynamic residual connection structure is the input terminal of the identity transformation module. The output terminal of the identity transformation module is connected to the input terminal of the first Swing Transformer module and the first input terminal of the first residual connection module. The output terminal of the first Swing Transformer module is connected to the input terminal of the second Swing Transformer module. The output terminal of the second Swing Transformer module is connected to the second input terminal of the first residual connection module. The output terminal of the first residual connection module is the output terminal of the dynamic residual connection structure.
[0007] In some embodiments, each of the Swin Transformer modules includes: a first linear normalization layer, a window multi-head attention layer, a first residual connection layer, a second linear normalization layer, a first multilayer perceptron, and a second residual connection layer; wherein, The input of the Swin Transformer module is connected to the input of the first linear normalization layer and the first input of the first residual connection layer. The output of the first linear normalization layer is connected to the input of the window multi-head attention layer. The output of the window multi-head attention layer is connected to the second input of the first residual connection layer. The output of the first residual connection layer is connected to the input of the second linear normalization layer and the first input of the second residual connection layer. The output of the second linear normalization layer is connected to the first multilayer perceptron. The first multilayer perceptron is connected to the second input of the second residual connection layer. The output of the second residual connection layer is the output of the Swin Transformer module.
[0008] In some embodiments, the cascaded regularized transformer module includes: a first Transformer module, a second Transformer module, a third Transformer module, and a second residual connection module; wherein, the input terminal of the cascaded regularized transformer module is the input terminal of the first Transformer module, the output terminal of the first Transformer module is connected to the input terminal of the second Transformer module and the first input terminal of the second residual connection module, the output terminal of the second Transformer module is connected to the second input terminal of the second residual connection module, the output terminal of the second residual connection module is connected to the third Transformer module, and the output terminal of the third Transformer module is the output terminal of the cascaded regularized transformer module.
[0009] In some embodiments, the method further includes: during the training process of the crack detection model, optimizing the parameters of the crack detection model based on a hybrid loss function composed of a first loss function for measuring the similarity between the predicted region and the real region and a second loss function for measuring the difference in probability distribution, and the AdamW optimizer.
[0010] In some embodiments, the method further includes: during the training process of the crack detection model, uniformly adding at least two intensity ranges of noise to the dataset of the same material and the same processing mode; Images corresponding to noise within the same intensity range are randomly assigned to the training and test sets at a preset ratio.
[0011] Secondly, embodiments of this application provide a component crack detection device, the device comprising: The acquisition module is used to acquire component images obtained by scanning with an electronic nondestructive testing accelerator; A detection module is used to obtain a crack segmentation image based on the component image and the crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder, and the skip connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the encoder is used to perform hierarchical feature extraction on the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder.
[0012] Thirdly, embodiments of this application provide an electronic device, the electronic device including a processor and a memory for storing a computer program capable of running on the processor, wherein the processor, when running the computer program, performs the steps of the method described in the first aspect.
[0013] Fourthly, embodiments of this application provide a storage medium storing a computer program, which, when executed by a control device, implements the steps of the method described in the first aspect.
[0014] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a controlled device, implements the steps of the method described in the first aspect.
[0015] The technical solution provided in this application embodiment acquires a component image obtained by scanning with an electronic nondestructive testing accelerator; a crack segmentation image is obtained based on the component image and a crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder; the encoder is used to extract hierarchical features from the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the jump connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder. In this application, a SwinUNet backbone network is used to extract hierarchical features from the input component image. A progressive feature capture mechanism of "local detail-global correlation" is achieved through window self-attention and shift windowing to obtain multi-scale feature maps, facilitating the identification of cracks of varying shapes and sizes. Global features are upsampled to the input resolution for accurate pixel-level segmentation prediction, enabling precise crack location. The decoder also fuses high-resolution features from the encoder through skip connections to mitigate spatial information loss caused by downsampling. At the skip connections, a dynamic residual connection structure composed of two SwinTransformer modules analyzes the correlation between high-resolution shallow details (such as crack edges) and deep global semantics, dynamically calculating fusion weights to prioritize and enhance crack-related features. Furthermore, based on the attention, regularization, and residual filtering characteristics of SwinTransformer, background interference such as component surface textures and stains can be suppressed. This solves the feature interference problem in traditional skip connections, ensuring that key details of narrow cracks are not obscured, further improving the accuracy and reliability of crack detection. Attached Figure Description
[0016] Figure 1This is a schematic flowchart of the component crack detection method provided in the embodiments of this application; Figure 2 This is a schematic diagram of the structure of the SwinUNet backbone network provided in the embodiments of this application; Figure 3 This is a schematic diagram of the dynamic residual connection structure provided in the embodiments of this application; Figure 4 This is a schematic diagram of the structure of the cascaded regularized transformer module provided in the embodiments of this application; Figure 5 This is a schematic diagram of the component crack detection device provided in the embodiments of this application; Figure 6 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0017] The present application will now be described in further detail with reference to the accompanying drawings and embodiments.
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0019] Currently, electron nondestructive testing accelerators are widely used in industrial components, particularly for the nondestructive testing and evaluation of internal defects in critical fields such as aerospace, bridges, and railways. They utilize high-energy electron beams to penetrate the object under test and reconstruct its three-dimensional information based on sufficient projection data. However, during the testing process, inherent scattering effects of the electron beam, the Compton effect, equipment vibration, and the materials of composite components introduce significant noise, severely interfering with the identification of minute defects such as microcracks. Traditional image processing and detection algorithms often exhibit insufficient robustness and limited feature extraction capabilities when facing such noise interference and multi-scale crack features, resulting in insufficient accuracy and reliability in crack detection. Therefore, a novel detection method that can effectively suppress noise and accurately enhance and identify crack features is urgently needed.
[0020] In various embodiments of this application, a SwinUNet backbone network is used to extract hierarchical features from the input component images. A progressive feature capture of "local detail-global correlation" is achieved through window self-attention and shift window mechanisms to obtain multi-scale feature maps, facilitating the identification of cracks of varying shapes and sizes. Global features are upsampled to the input resolution to achieve accurate pixel-level segmentation prediction, enabling precise crack location. The decoder also fuses high-resolution features from the encoder through skip connections to mitigate spatial information loss caused by downsampling. At the skip connections, a dynamic residual connection structure composed of two SwinTransformer modules analyzes the correlation between high-resolution shallow details (such as crack edges) and deep global semantics, dynamically calculates fusion weights, prioritizes and strengthens crack-related features, and, based on the attention, regularization, and residual filtering characteristics of SwinTransformer, suppresses background interference such as component surface textures and stains. This solves the problem of feature interference in traditional skip connections, ensuring that key details of narrow cracks are not obscured, further improving the accuracy and reliability of crack detection.
[0021] This application provides a method for detecting cracks in components, such as... Figure 1 As shown, the method includes: Step 101: Obtain the component image obtained by scanning with an electronic nondestructive testing accelerator; Step 102: Obtain a crack segmentation image based on the component image and the crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder, and the skip connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the encoder is used to perform hierarchical feature extraction on the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder.
[0022] Here, the electron nondestructive testing accelerator can be a high-energy (>5MeV) electron linear accelerator. The high-energy electron linear accelerator is used to perform computed tomography (CT) scans on the component to obtain an image. The image of the component to be inspected is input into a trained crack detection model. The crack detection model generates a crack segmentation image, which can be represented by black areas outside the crack to highlight the crack region, thereby achieving automatic and accurate crack detection in an electron beam environment. In this embodiment, the high-energy electron linear accelerator can be divided into traveling-wave electron linear accelerators and standing-wave electron linear accelerators. They have high electron energies (generally >5MeV) and output power between several kilowatts and tens of kilowatts. This embodiment does not limit the specific type, specific electron energy, or specific output power of the high-energy electron linear accelerator.
[0023] A schematic diagram of the SwinUNet backbone network is shown below. Figure 2 As shown, the SwinUNet backbone network is built on the Unet architecture, specifically by replacing the convolutional modules of Unet with Swin Transformer blocks (Swin TransformerBlock in the diagram). The encoder is... Figure 2 The Encoder module contains the decoder module. Figure 2 The modules contained in the Decoder are skip connections. Figure 2 The bottleneck layer in the Skip Connection module is... Figure 2 The Bottleneck Block module in the code. It can be understood that the component image is input from the Input section, and the crack segmentation image is output from the Output section.
[0024] In some embodiments, such as Figure 3 As shown, the dynamic residual connection structure includes an identity transformation module, a first Swing Transformer module, a second Swing Transformer module, and a first residual connection module; wherein, The input terminal of the dynamic residual connection structure is the input terminal of the identity transformation module. The output terminal of the identity transformation module is connected to the input terminal of the first Swing Transformer module and the first input terminal of the first residual connection module. The output terminal of the first Swing Transformer module is connected to the input terminal of the second Swing Transformer module. The output terminal of the second Swing Transformer module is connected to the second input terminal of the first residual connection module. The output terminal of the first residual connection module is the output terminal of the dynamic residual connection structure.
[0025] here, Figure 3 The Identity module is the identity transformation module, Swin Transformer-1 is the first Swin Transformer module, and Swin Transformer-2 is the second Swin Transformer module. The output of the Identity module and the output of Swin Transformer-2 are added through the first residual connection module to obtain the output of the skip connection. The SwinUnet decoder fuses high-resolution features from the encoder based on the output of the skip connection to mitigate the spatial information loss caused by downsampling. Specifically, the output of the Identity module is split into two paths: one path goes into Swin Transformer-1 for feature enhancement, and the other path goes directly into the first residual connection module. The output of Swin Transformer-1 is then fed into Swin Transformer-2 to further refine the feature representation. Finally, the output of Swin Transformer-2 and the output of the Identity module are fused in the first residual connection module to generate the final output feature map.
[0026] In some embodiments, such as Figure 3 As shown, each of the Swin Transformer modules includes: a first linear normalization layer, a window multi-head attention layer, a first residual connection layer, a second linear normalization layer, a first multilayer perceptron, and a second residual connection layer; wherein, The input of the Swin Transformer module is connected to the input of the first linear normalization layer and the first input of the first residual connection layer. The output of the first linear normalization layer is connected to the input of the window multi-head attention layer. The output of the window multi-head attention layer is connected to the second input of the first residual connection layer. The output of the first residual connection layer is connected to the input of the second linear normalization layer and the first input of the second residual connection layer. The output of the second linear normalization layer is connected to the first multilayer perceptron. The first multilayer perceptron is connected to the second input of the second residual connection layer. The output of the second residual connection layer is the output of the Swin Transformer module.
[0027] here, Figure 3In the Swin Transformer-1, the LN-1 module is the first linear normalization layer, the W-MSA module is the window multi-head attention layer, the LN-2 module is the second linear normalization layer, and the MLP-1 module is the first multilayer perceptron. The LN-1 module normalizes the input features, followed by the W-MSA module extracting local features. Then, the original input and attention output are fused through the first residual connection layer. The LN-2 module further stabilizes the feature distribution, and finally, the MLP-1 module performs non-linear enhancement, integrating the final output through the second residual connection layer. These modules progressively optimize and strengthen crack features through layer-by-layer propagation and fusion.
[0028] Understandably, the encoder of the SwinUNet backbone network performs hierarchical feature extraction on the input component image, and achieves progressive feature capture of "local details-global correlation" through window self-attention and shift window mechanism to obtain multi-scale feature maps, which facilitates the judgment of cracks of different shapes and sizes. The decoder upsamples the global features to the input resolution to achieve accurate pixel-level segmentation prediction, which can accurately locate the crack position. The decoder also fuses high-resolution features from the encoder through skip connections to reduce the spatial information loss caused by downsampling.
[0029] By combining two Swing Transformer modules into a dynamic residual connection structure, forming the skip connections of the SwingUNet backbone network, the hierarchical window attention feature and adaptive window mechanism of Swing Transformer are utilized. This is well-suited to the UNet encoding and decoding structure, enabling the dynamic residual connection structure to analyze the correlation between high-resolution shallow details (such as crack edges) and deep global semantics, dynamically calculate fusion weights, prioritize the preservation and enhancement of crack-related features, and, based on the attention, regularization, and residual filtering characteristics of Swing Transformer, suppress background interference such as surface textures and stains. This solves the feature interference problem in traditional skip connections, ensuring that critical details of narrow cracks are not obscured, further improving the accuracy and reliability of crack detection.
[0030] In some embodiments, the SwinUNet backbone network further includes a bottleneck layer located between the end node of the encoder and the beginning node of the decoder. The bottleneck layer includes a cascaded regularized transformer module consisting of three cascaded Transformer modules.
[0031] Here, the bottleneck layer refers to the intermediate processing module located between the encoder and the decoder (i.e., Figure 2The Bottleneck Block is used to suppress noise, enhance target features (such as cracks) and provide a more accurate and robust feature representation for subsequent decoders by introducing more complex structures or mechanisms after the encoder has extracted multi-scale features.
[0032] In some embodiments, the cascaded regularized transformer module includes: a first Transformer module, a second Transformer module, a third Transformer module, and a second residual connection module; wherein, the input terminal of the cascaded regularized transformer module is the input terminal of the first Transformer module, the output terminal of the first Transformer module is connected to the input terminal of the second Transformer module and the first input terminal of the second residual connection module, the output terminal of the second Transformer module is connected to the second input terminal of the second residual connection module, the output terminal of the second residual connection module is connected to the third Transformer module, and the output terminal of the third Transformer module is the output terminal of the cascaded regularized transformer module.
[0033] Here, as Figure 4 As shown, the bottleneck layer consists of three cascaded Transformer modules, specifically Transformer layer-1, Transformer layer-2, and Transformer layer-3, while maintaining the feature size and resolution, achieving a balance between noise suppression and detail preservation. Due to the multi-head attention mechanism, residual connections, and DropPath regularization of the Transformer modules, constructing the bottleneck layer using Transformer modules can capture long-range dependencies based on the multi-head attention mechanism, and alleviate gradient vanishing and overfitting problems based on residual connections and DropPath regularization. The Multi-Layer Perceptron (MLP) in the Transformer module further enhances the nonlinear expressive power. Specifically, Transformer layer-1 is mainly responsible for preliminary feature extraction and noise suppression, using a self-attention mechanism to capture local and global dependencies and remove irrelevant background information; Transformer layer-2 further refines the features, enhances the expressive power of crack edges, and prevents overfitting through DropPath technology; Transformer layer-3 fuses the outputs of the first two Transformer modules and uses skip connections to preserve shallow geometric details and deep semantic information, which can gradually suppress noise and enhance crack feature expression.
[0034] like Figure 4 As shown, each Transformer module includes a first normalization layer (Norm-1 module), an MHA (Multi-head Attention Module), a second normalization layer (Norm-2 module), and a second multilayer perceptron module (MLP-2 module). The input first passes through the normalization layer, then enters the MHA layer for processing, and is added to the original input through residual connections. It then passes through another normalization layer, enters the multilayer perceptron for processing, and finally outputs the result through residual connections. The specific structure of the Transformer module can be found in relevant technologies and will not be elaborated here.
[0035] The aforementioned SwinUNet encoder-decoder backbone network, dynamic residual connections, and cascaded regularization transformer modules in the bottleneck layer collaboratively construct a multi-node key processing procedure on the basis of the original network, achieving a breakthrough in detection performance that cannot be achieved by traditional single network architectures or simple module stacking. In the harsh industrial environment of high noise and strong electromagnetic interference under the electronic nondestructive testing accelerator beam, this collaborative architecture exhibits significant advantages: the multi-scale features provided by the SwinUNet backbone network lay the foundation for crack detection; the dynamic residual connections accurately filter background interference and enhance the correlation of crack features through adaptive weight allocation; and the cascaded regularization transformer modules further suppress noise diffusion and deeply mine the long-range dependencies of crack features. The synergistic effect formed by the complementarity of the three improves the model's generalization ability under different component materials and multiple working conditions, fully meeting the industrial-grade requirements for accuracy and robustness in crack detection under the electronic nondestructive testing accelerator beam.
[0036] In some embodiments, the method further includes: during the training process of the crack detection model, optimizing the parameters of the crack detection model based on a hybrid loss function composed of a first loss function for measuring the similarity between the predicted region and the real region and a second loss function for measuring the difference in probability distribution, and the AdamW optimizer.
[0037] Here, the cracked area in a component image typically only occupies 1%-3% of the image. Therefore, crack detection requires precise identification of the crack. The first loss function reflects the spatial overlap between the predicted area and the actual cracked area, ensuring that the model pays attention to smaller cracked areas and improves boundary accuracy. The second loss function measures the difference between the model's predicted probability (e.g., the probability that a pixel is a crack) and the actual sample labeling, making the model's output predicted probability as close as possible to the distribution of the actual labels. This ensures that the model does not ignore cracked areas due to their small size, improving the model's reliability and robustness against noise interference (e.g., complex backgrounds, blurred crack edges). Since industrial CT images often have high noise and low contrast, the hybrid loss function design allows the crack detection model to focus on both region overlap and pixel-level classification accuracy during training, thereby achieving a more comprehensive detection capability.
[0038] In practical applications, the first loss function can be the Dice Loss function, the second loss function can be the Cross-Entropy Loss function, and the hybrid loss function can be specifically expressed as LOSS=α×DiceLoss+β×Cross-Entropy Loss, where the weight coefficients α of Dice Loss and β of Cross-Entropy Loss can be determined according to the actual situation. This application embodiment does not limit this, and this application embodiment does not limit the specific formulas of the first loss function, the second loss function, and the hybrid loss function.
[0039] The AdamW optimizer is an improved adaptive learning rate optimization algorithm that optimizes the weight decay strategy, avoiding the risk of overfitting during weight updates, and exhibiting stronger generalization ability, especially when dealing with high-dimensional data. In crack detection tasks, using the AdamW optimizer helps stabilize the crack detection model training process, accelerates convergence, and maintains the robustness and generalization ability of the crack detection model when facing complex industrial CT images.
[0040] In some embodiments, the method further includes: during the training process of the crack detection model, uniformly adding at least two intensity ranges of noise to the dataset of the same material and the same processing mode; Images corresponding to noise within the same intensity range are randomly assigned to the training and test sets at a preset ratio.
[0041] Here, in the training process of the crack detection model, in order to enable the model to handle CT data with high noise and micro-defects, a dataset of concrete crack images with multiple composite structures and multiple noise types can be constructed. The material types of concrete can include: ordinary concrete (NC), high performance concrete (HPC), ultra-high performance concrete (UHPC), and unreinforced and reinforced concrete (fibers made of straight steel fibers, crimped steel fibers, hooked steel fibers, polypropylene fibers, and glass fiber reinforced polymers). Furthermore, each type of concrete is obtained based on four typical point processing modes, such as "hc": hard core point processing, with a bulk density of 60% and a strength of 0.000025, obtained using force-biased spherical filler; "matclust": matcassn clustering process, with a parent density of 0.0002 / 50, a progeny strength of 50, and a cluster radius of 20; "PPP": Poisson point process with a strength of 0.0002; and "ppp scaling": Poisson point process with a strength of 0.0002 (within a 200×150×200 window), where the resulting Voronoi diagram (the space occupied by concrete aggregate corresponding to each region of the Voronoi diagram) is stretched by a factor of 2 in the x and z directions. This application does not limit the specific point processing mode in its embodiments.
[0042] It is understandable that after obtaining the sample images used to construct the dataset, the sample images undergo preprocessing such as standardization, size normalization, and annotation. Furthermore, for each image in the dataset, noise within the intensity range of [-σ, σ], [-2σ, 2σ], and [-4σ, 4σ] is added. Defective pixels account for a relatively small proportion of the overall images, mainly concentrated between 1% and 3%.
[0043] In some embodiments, to address the problem of uneven numbers of different types of cracks (e.g., more fatigue crack samples and fewer welding crack samples) and differences in the number of crack samples from different components, methods such as rotation, flipping, and local cropping can be used to increase the number of sample images.
[0044] Images are segmented using a stratified random sampling strategy. In practical applications, concrete images of 7 material types and 4 point processing modes can be selected to construct a dataset, thus dividing the dataset into 28 categories. Each category (which may include 48 images) serves as a layer. Images in each layer are evenly divided into 12 groups based on the type of noise added (e.g., noise in 4 intensity ranges). These 12 groups of images are randomly assigned to the training and test sets according to a preset ratio (e.g., 8:2) to ensure that concrete component images of all categories are stratified and distributed in equal proportions, maintaining a balanced data distribution and the integrity of noise coverage. Here, the 4 intensity ranges of noise may include noise type a (no noise added), noise type b (noise in [-σ, σ]), noise type c (noise in [-2σ, 2σ]), and noise type d (noise in [-4σ, 4σ]). This embodiment does not limit the number or preset ratio of the noise types. This effectively improves the robustness of the crack detection model in complex noise environments, thereby achieving higher accuracy in crack detection and enabling its widespread application in non-destructive testing tasks in high-noise industrial scenarios.
[0045] The technical solution provided in this application embodiment acquires a component image obtained by scanning with an electronic nondestructive testing accelerator; a crack segmentation image is obtained based on the component image and a crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder; the encoder is used to extract hierarchical features from the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the jump connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder. In this application, a SwinUNet backbone network is used to extract hierarchical features from the input component image. A progressive feature capture mechanism of "local detail-global correlation" is achieved through window self-attention and shift windowing to obtain multi-scale feature maps, facilitating the identification of cracks of varying shapes and sizes. Global features are upsampled to the input resolution for accurate pixel-level segmentation prediction, enabling precise crack location. The decoder also fuses high-resolution features from the encoder through skip connections to mitigate spatial information loss caused by downsampling. At the skip connections, a dynamic residual connection structure composed of two SwinTransformer modules analyzes the correlation between high-resolution shallow details (such as crack edges) and deep global semantics, dynamically calculating fusion weights to prioritize and enhance crack-related features. Furthermore, based on the attention, regularization, and residual filtering characteristics of SwinTransformer, background interference such as component surface textures and stains can be suppressed. This solves the feature interference problem in traditional skip connections, ensuring that key details of narrow cracks are not obscured, further improving the accuracy and reliability of crack detection.
[0046] Ablation experiments verify the segmentation effect of the proposed solution under multiple nodes. Specifically, removing the bottleneck structure provided in the embodiments of this application significantly reduces the model's performance, demonstrating that the bottleneck module plays a crucial role in enhancing feature extraction capabilities and cross-layer information aggregation. Removing the skip connections provided in the embodiments of this application also increases the boundary error, indicating that the skip connections provided in the embodiments of this application are equally indispensable in maintaining the continuity of spatial information and multi-scale semantic fusion.
[0047] In summary, this application employs the SwinUNet architecture as the backbone and combines it with targeted module optimizations, enabling accurate segmentation of crack regions from noisy backgrounds and significantly improving detection accuracy and robustness in complex electron beam environments. The dynamic residual connection mechanism embedded in the skip connections dynamically fuses multi-scale features through adaptive windows, solving the interference problem inherent in traditional skip connections when fusing complex background and crack features, thus improving the detection rate of micro-cracks and the smoothness of segmentation boundaries. At bottleneck nodes, multi-stage features are refined to suppress noise at different stages. This method achieves end-to-end automated crack detection, greatly reducing manual intervention, improving detection efficiency, and providing core technical support for the intelligent upgrade of electronic nondestructive testing accelerators.
[0048] In order to implement the method of the embodiments of this application, the embodiments of this application also provide a component crack detection device, which corresponds to the above-described component crack detection method. Each step in the above-described component crack detection method embodiments is also fully applicable to the component crack detection device embodiments.
[0049] like Figure 5 As shown, the component crack detection device includes an acquisition module 501 and a detection module 502; The acquisition module 501 is used to acquire component images obtained by scanning with an electronic nondestructive testing accelerator; The detection module 502 is used to obtain a crack segmentation image based on the component image and the crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder, and the skip connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the encoder is used to perform hierarchical feature extraction on the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder.
[0050] In some embodiments, the component crack detection device includes a training module 503; The training module 503 is used to optimize the parameters of the crack detection model during the training process of the crack detection model based on a hybrid loss function composed of a first loss function used to measure the similarity between the predicted region and the real region and a second loss function used to measure the difference in probability distribution, and the AdamW optimizer.
[0051] In some embodiments, the training module 503 is further configured to uniformly add at least two intensity ranges of noise to the dataset of the same material and the same processing mode during the training process of the crack detection model. Images corresponding to noise within the same intensity range are randomly assigned to the training and test sets at a preset ratio.
[0052] It should be noted that the component crack detection device provided in the above embodiments is only illustrated by the division of the above-described program modules when performing component crack detection. In practical applications, the above processing can be assigned to different program modules as needed, that is, the internal structure of the device can be divided into different program modules to complete all or part of the processing described above. In addition, the component crack detection device and the component crack detection method embodiments provided in the above embodiments belong to the same concept, and their specific implementation process can be found in the method embodiments, which will not be repeated here.
[0053] Based on the hardware implementation of the above program modules, and in order to implement the method of the embodiments of this application, the embodiments of this application also provide an electronic device. Figure 6 The diagram shows only an exemplary structure of the electronic device, not the entire structure; implementation is possible as needed. Figure 6 The structure shown may be part or all of the structure.
[0054] like Figure 6 As shown, the electronic device 600 provided in this application embodiment includes at least one processor 601, a memory 602, and a user interface 603. The various components in the electronic device 600 are coupled together via a bus system 604. It can be understood that the bus system 604 is used to implement communication between these components. In addition to a data bus, the bus system 604 also includes a power bus, a control bus, and a status signal bus. However, for clarity, in... Figure 6 The general designated all buses as Bus System 604.
[0055] The user interface 603 may include a monitor, keyboard, mouse, trackball, click wheel, buttons, touchpad, or touch screen.
[0056] The memory 602 in this embodiment is used to store various types of data to support the operation of the electronic device 600. Examples of such data include any computer program used to operate on the electronic device 600.
[0057] The control method for an electronic device disclosed in this application can be applied to or implemented by a processor 601. The processor 601 may be an integrated circuit chip with signal processing capabilities. During implementation, each step of the control method for the electronic device can be completed by integrated logic circuits in the hardware of the processor 601 or by instructions in software form. The processor 601 can be a general-purpose processor, a digital signal processor (DSP), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The processor 601 can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this application. A general-purpose processor can be a microprocessor or any conventional processor, etc. The steps of the method disclosed in the embodiments of this application can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software modules can be located in a storage medium, specifically memory 602. The processor 601 reads information from memory 602 and, in conjunction with its hardware, completes the steps of the control method for the electronic device provided in the embodiments of this application.
[0058] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), DSPs, programmable logic devices (PLDs), complex programmable logic devices (CPLDs), field-programmable gate arrays (FPGAs), general-purpose processors, controllers, microcontrollers (MCUs), microprocessors, or other electronic components to perform the aforementioned method.
[0059] It is understood that memory 602 can be volatile memory or non-volatile memory, or both. Non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), ferromagnetic random access memory (FRAM), flash memory, magnetic surface memory, optical disc, or compact disc read-only memory (CD-ROM); magnetic surface memory can be disk storage or magnetic tape storage. Volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of RAM are available, such as Static Random Access Memory (SRAM), Synchronous Static Random Access Memory (SSRAM), Dynamic Random Access Memory (DRAM), Synchronous Dynamic Random Access Memory (SDRAM), Double Data Rate Synchronous Dynamic Random Access Memory (DDRSDRAM), Enhanced Synchronous Dynamic Random Access Memory (ESDRAM), Sync Link Dynamic Random Access Memory (SLDRAM), and Direct Rambus Random Access Memory (DRRAM).The memories described in the embodiments of this application are intended to include, but are not limited to, these and any other suitable types of memories.
[0060] In an exemplary embodiment, this application also provides a storage medium, namely a computer storage medium, specifically a computer-readable storage medium, such as a memory 602 storing a computer program. This computer program can be executed by the processor 601 of the electronic device 600 to complete the steps described in the method of this application embodiment. The computer-readable storage medium can be a ROM, PROM, EPROM, EEPROM, Flash Memory, magnetic surface memory, optical disc, or CD-ROM, etc.
[0061] In an exemplary embodiment, this application also provides a computer program product, including a computer program that can be executed by a processor 601 of an electronic device 600 to perform the steps described in the method of this application embodiment.
[0062] It should be noted that terms such as "first" and "second" are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. In this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0063] It should be understood that the phrase "some embodiments" throughout the specification means that a particular feature, structure, or characteristic related to an embodiment is included in at least one embodiment of this application. Therefore, "some embodiments" appearing throughout the specification does not necessarily refer to the same embodiment.
[0064] In this article, the term "and / or" is merely a description of the relationship between related objects, indicating that there can be three relationships. For example, A and / or B can represent three situations: A exists alone, A and B exist simultaneously, and B exists alone.
[0065] In the description of the embodiments of this application, it should be noted that, unless otherwise explicitly specified and limited, the terms "connected" or "linked" should be interpreted broadly. For example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection, an electrical connection, or a connection that allows communication between the components; it can be a direct connection or an indirect connection through an intermediate medium; it can be the internal communication between two components or the interaction between two components. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.
[0066] Furthermore, the technical solutions described in the embodiments of this application can be combined arbitrarily without conflict.
[0067] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for detecting cracks in a component, characterized in that, The method includes: Acquire component images obtained by scanning with an electronic nondestructive testing accelerator; A crack segmentation image is obtained based on the component image and the crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder, and the skip connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the encoder is used to perform hierarchical feature extraction on the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder.
2. The method according to claim 1, characterized in that, The SwinUNet backbone network also includes a bottleneck layer, which is located between the end node of the encoder and the beginning node of the decoder. The bottleneck layer includes a cascaded regularization transformer module consisting of three cascaded Transformer modules.
3. The method according to claim 1, characterized in that, The dynamic residual connection structure includes an identity transformation module, a first Swing Transformer module, a second Swing Transformer module, and a first residual connection module; wherein... The input terminal of the dynamic residual connection structure is the input terminal of the identity transformation module. The output terminal of the identity transformation module is connected to the input terminal of the first Swing Transformer module and the first input terminal of the first residual connection module. The output terminal of the first Swing Transformer module is connected to the input terminal of the second Swing Transformer module. The output terminal of the second Swing Transformer module is connected to the second input terminal of the first residual connection module. The output terminal of the first residual connection module is the output terminal of the dynamic residual connection structure.
4. The method according to claim 1, characterized in that, Each of the aforementioned Swin Transformer modules includes: a first linear normalization layer, a window multi-head attention layer, a first residual connection layer, a second linear normalization layer, a first multilayer perceptron, and a second residual connection layer; wherein... The input of the Swin Transformer module is connected to the input of the first linear normalization layer and the first input of the first residual connection layer. The output of the first linear normalization layer is connected to the input of the window multi-head attention layer. The output of the window multi-head attention layer is connected to the second input of the first residual connection layer. The output of the first residual connection layer is connected to the input of the second linear normalization layer and the first input of the second residual connection layer. The output of the second linear normalization layer is connected to the first multilayer perceptron. The first multilayer perceptron is connected to the second input of the second residual connection layer. The output of the second residual connection layer is the output of the Swin Transformer module.
5. The method according to claim 2, characterized in that, The cascaded regularized transformer module includes: a first Transformer module, a second Transformer module, a third Transformer module, and a second residual connection module; wherein, the input terminal of the cascaded regularized transformer module is the input terminal of the first Transformer module, the output terminal of the first Transformer module is connected to the input terminal of the second Transformer module and the first input terminal of the second residual connection module, the output terminal of the second Transformer module is connected to the second input terminal of the second residual connection module, the output terminal of the second residual connection module is connected to the third Transformer module, and the output terminal of the third Transformer module is the output terminal of the cascaded regularized transformer module.
6. The method according to claim 1, characterized in that, The method further includes: during the training process of the crack detection model, optimizing the parameters of the crack detection model based on a hybrid loss function composed of a first loss function used to measure the similarity between the predicted region and the real region and a second loss function used to measure the difference in probability distribution, and using the AdamW optimizer.
7. The method according to claim 1, characterized in that, The method further includes: during the training process of the crack detection model, uniformly adding at least two intensity ranges of noise to the dataset of the same material and the same processing mode; Images corresponding to noise within the same intensity range are randomly assigned to the training and test sets at a preset ratio.
8. A component crack detection device, characterized in that, The device includes: The acquisition module is used to acquire component images obtained by scanning with an electronic nondestructive testing accelerator; A detection module is used to obtain a crack segmentation image based on the component image and the crack detection model; wherein, the crack detection model includes a SwinUNet backbone network; the SwinUNet backbone network includes an encoder and a decoder, and the skip connection between the encoder and the decoder includes a dynamic residual connection structure composed of two Swin Transformer modules; the encoder is used to perform hierarchical feature extraction on the component image to obtain multi-scale feature maps; the decoder is used to gradually restore the spatial resolution of the feature maps through upsampling operations; the dynamic residual connection structure is used to assign fusion weights to the feature maps and add and fuse the weighted feature maps with the upsampled features of the decoder.
9. An electronic device, characterized in that, The electronic device includes a processor and a memory for storing a computer program capable of running on the processor, wherein the processor, when running the computer program, performs the steps of the method according to any one of claims 1 to 7.
10. A storage medium storing a computer program, characterized in that, When the computer program is executed by the control device, it implements the steps of the method as described in any one of claims 1 to 7.
11. A computer program product, comprising a computer program, characterized in that, When executed by the controlled device, the computer program implements the steps of the method as described in any one of claims 1 to 7.