Weld defect detection method and system based on improved YOLO network
By improving the YOLO network, combining lightweight convolution, deformable convolution and attention mechanisms, weld defect detection is optimized, which solves the problem of insufficient detection accuracy of the YOLO network in small targets, and achieves efficient and accurate weld defect detection.
Patent Information
- Application Number
- CN202510476478.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-16
- Publication Date
- 2025-08-15
AI Technical Summary
The existing weld defect detection method based on YOLO network is insufficient in detecting small target defects, and traditional manual inspection is time-consuming and labor-intensive and dependent on experience, making it difficult to ensure accuracy.
By improving the YOLO network, lightweight convolution, deformable convolution, ELAN-PCS network structure and coordinate attention mechanism are introduced to optimize the feature extraction and detection process, and combined with the attention mechanism network, the accuracy and efficiency of small object detection are improved.
Maintain high-precision detection in a low computing resource environment, reduce missed detection and missed detection, and improve the detection accuracy of small defect targets, which is suitable for industrial automation detection needs.
Smart Images

Figure CN120495176A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of weld detection, and in particular to a weld defect detection method and system based on an improved YOLO network. Background Art
[0002] Welding, as the main method of metal connection, is particularly common in various industrial applications. However, defects such as cracks and pores are likely to appear during the welding process due to improper operation or material properties. Traditional manual detection methods are not only time-consuming and labor-intensive, but also greatly affected by the experience of the inspectors, making it difficult to ensure the accuracy of the detection. With the development of deep learning technology, target detection algorithms based on the YOLO series have gradually been applied to weld defect detection. However, they still have the problem of insufficient accuracy when detecting small target defects. Therefore, the present invention aims to improve the applicability and detection efficiency of the YOLO model in weld defect detection by optimizing it. Summary of the Invention
[0003] The purpose of the present invention is to overcome one or more of the above-mentioned existing technical problems and provide a weld defect detection method and system based on an improved YOLO network.
[0004] To achieve the above objectives, the present invention provides a weld defect detection method based on an improved YOLO network, comprising:
[0005] Obtain original welding images;
[0006] Based on the original welding image, it is input into the backbone feature extraction network to obtain the first feature information map, the second feature information map and the third feature information map;
[0007] Based on the first feature information map, the second feature information map and the third feature information map, inputting them into the fusion enhanced feature extraction network to obtain the first enhanced feature information map, the second enhanced feature information map and the third enhanced feature information map;
[0008] Based on the first enhanced feature information map, the second enhanced feature information map and the third enhanced feature information map, inputting them into the attention mechanism network to obtain a welding inspection image;
[0009] The weld defect detection results are obtained based on the welding inspection image.
[0010] According to one aspect of the present invention, the backbone feature extraction network includes two convolutional neural network modules connected in sequence, three layer-aggregated partial convolution and attention mechanism modules connected to the two convolutional neural network modules, three maximum pooling layers and one layer-aggregated deformable convolution;
[0011] The original welding image is input into the first convolutional neural network module to obtain the first convolutional neural network feature, where the formula is:
[0012] F1 = SiLU(BN(conv(X)));
[0013] Among them, X represents the original welding image;
[0014] conv represents the convolutional layer;
[0015] BN represents batch normalization layer;
[0016] SiLU represents the activation function;
[0017] F1 represents the first convolutional neural network feature;
[0018] The first convolutional neural network feature is input into the second convolutional neural network module to obtain the second convolutional neural network feature, where the formula is,
[0019] F2 = SiLU(BN(conv(F1)));
[0020] F2 represents the second convolutional neural network feature.
[0021] According to one aspect of the present invention, obtaining the first characteristic information map, the second characteristic information map, and the third characteristic information map includes:
[0022] The second convolutional neural network features are sequentially input into the first layer of aggregate partial convolution and attention mechanism module, the first maximum pooling layer, and the second layer of aggregate partial convolution and attention mechanism module to obtain the first feature information graph, where the formula is,
[0023] F3=ELAN-PCS(MP(ELAN-PCS(F2)));
[0024] Among them, ELAN-PCS represents the layer aggregation partial convolution and attention mechanism module;
[0025] MP represents the maximum pooling layer;
[0026] F3 represents the first feature information graph;
[0027] The first feature information map is sequentially input into the second maximum pooling layer and the third layer aggregation partial convolution and attention mechanism module to obtain the second feature information map, where the formula is,
[0028] F4 = ELAN-PCS (MP (F3));
[0029] Wherein, F4 represents the second feature information graph;
[0030] The second feature information map is sequentially input into the third maximum pooling layer and layer aggregation deformable convolution to obtain the third feature information map, where the formula is,
[0031] F5 = ELAN-DCNV2 (MP (F4));
[0032] Among them, ELAN-DCNV2 represents layer-aggregated deformable convolution;
[0033] F5 represents the third characteristic information graph.
[0034] According to one aspect of the present invention, the method for obtaining the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map includes:
[0035] The fusion-enhanced feature extraction network consists of a spatial pyramid pooling layer, four feature fusion modules, six convolutional neural network modules, four layer-aggregated partial convolution and attention mechanism modules, two channel attention mechanism layers, and two upsampling layers;
[0036] The first feature information graph is sequentially input into the third convolutional neural network module and the first channel attention mechanism layer to obtain the first attention feature, where the formula is,
[0037] F 11 =Attention(SiLU(BN(conv(F3))));
[0038] Among them, Attention represents the channel attention mechanism layer;
[0039] F 11 Indicates the first feature of interest;
[0040] The second feature information graph is sequentially input into the fourth convolutional neural network module and the second channel attention mechanism layer to obtain the second attention feature, where the formula is,
[0041] F 12 =Attention(SiLU(BN(conv(F4))));
[0042] Among them, F 12 Indicates the second feature of interest;
[0043] The third feature information map is input into the spatial pyramid pooling layer to obtain the multi-scale pooling feature, where the formula is:
[0044] F6=SPPCSPC(F5);
[0045] Among them, SPPCSPC represents the spatial pyramid pooling layer;
[0046] F6 represents multi-scale pooling features;
[0047] The multi-scale pooling features are sequentially input into the fifth convolutional neural network module and the first upsampling layer to obtain the third focus feature, where the formula is,
[0048] F 13 =Upsample(SiLU(BN(conv(F6))));
[0049] Among them, Upsample represents the upsampling layer;
[0050] F 13 Indicates the third feature of interest.
[0051] According to one aspect of the present invention, the method for obtaining the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map includes:
[0052] The third attention feature is fused with the second attention feature and then input into the fourth layer aggregation partial convolution and attention mechanism module to obtain the first fusion feature, where the formula is,
[0053] F 21 =ELAN-PCS(Concat(F 12 ,F 13 ));
[0054] Among them, Concat means channel stacking fusion;
[0055] F 21 represents the first fusion feature;
[0056] The first fusion feature is sequentially input into the sixth convolutional neural network module and the second upsampling layer and then fused with the first feature information graph to obtain the second fusion feature, where the formula is:
[0057] F 22 =Concat(F 21 ,Upsample(SiLU(BN(conv(F3)))));
[0058] Among them, F 22 represents the second fusion feature;
[0059] The second fusion feature is sequentially input into the fifth-layer aggregate partial convolution and attention mechanism module and the seventh convolutional neural network module, and then fused with the first fusion feature to obtain the third fusion feature, where the formula is:
[0060] F 23 =Concat(F 21 ,SiLU(BN(conv(ELAN-PCS(F 22 )))));
[0061] Among them, F 23 represents the third fusion feature;
[0062] The third fusion feature is sequentially input into the sixth layer of aggregate partial convolution and attention mechanism module and the eighth convolutional neural network module, and then fused with the multi-scale pooling feature to obtain the fourth fusion feature, where the formula is:
[0063] F 24 =Concat(F6,SiLU(BN(conv(ELAN-PCS(F 23 )))));
[0064] Among them, F 24 Represents the fourth fusion feature.
[0065] According to one aspect of the present invention, the method for obtaining a welding detection image includes:
[0066] The attention mechanism network consists of three lightweight convolutions, three attention modules and a feature output module:
[0067] The second fusion feature is input into the fifth layer of aggregated partial convolution and attention mechanism module to obtain the first enhanced feature information map. The first enhanced feature information map is input into the first lightweight convolution and the first attention module in sequence to obtain the first output feature, where the formula is,
[0068] F 31 =ELAN-PCS(F 22 );
[0069] S1=SimAM(PConv(F 31 ));
[0070] Among them, F 31 represents a first enhanced feature information graph;
[0071] S1 represents the first output feature;
[0072] SimAM represents the attention module;
[0073] PConv stands for lightweight convolution;
[0074] The third fusion feature is input into the sixth layer of aggregated partial convolution and attention mechanism module to obtain the second enhanced feature information map. The second enhanced feature information map is input into the second lightweight convolution and second attention modules in sequence to obtain the second output feature, where the formula is,
[0075] F 32 =ELAN-PCS(F 23 );
[0076] S2=SimAM(PConv(F 32 ));
[0077] Among them, F 32 represents a second enhanced feature information graph;
[0078] S2 represents the second output feature;
[0079] The fourth fusion feature is input into the seventh layer of aggregated partial convolution and attention mechanism module to obtain the third enhanced feature information map. The third enhanced feature information map is input into the third lightweight convolution and third attention modules in sequence to obtain the third output feature, where the formula is,
[0080] F 33 =ELAN-PCS(F 24 );
[0081] S3=SimAM(PConv(F 33 ));
[0082] Among them, F 33 represents a third enhanced feature information graph;
[0083] S3 represents the third output feature.
[0084] According to one aspect of the present invention, the method for obtaining a welding detection image includes:
[0085] After the first output feature, the second output feature, and the third output feature are input into the feature output module, the welding detection image is obtained, where the formula is:
[0086]
[0087] Where Y represents the welding inspection image;
[0088] Represents the feature output module.
[0089] To achieve the above objectives, the present invention provides a weld defect detection system based on an improved YOLO network, comprising:
[0090] Welding original image acquisition unit: acquires welding original image;
[0091] Feature information map acquisition unit: Based on the original welding image, it is input into the backbone feature extraction network to obtain the first feature information map, the second feature information map and the third feature information map;
[0092] An enhanced feature information map acquisition unit: based on the first feature information map, the second feature information map and the third feature information map, inputs them into a fusion enhanced feature extraction network to obtain a first enhanced feature information map, a second enhanced feature information map and a third enhanced feature information map;
[0093] Welding inspection image extraction unit: Based on the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map, the first enhanced feature information map is input into the attention mechanism network to obtain a welding inspection image;
[0094] Defect monitoring result acquisition unit: obtains weld defect detection results based on welding detection images.
[0095] To achieve the above-mentioned objectives, the present invention provides an electronic device, comprising a processor, a memory, and a computer program stored in the memory and runnable on the processor. When the computer program is executed by the processor, the above-mentioned weld defect detection method based on the improved YOLO network is implemented.
[0096] To achieve the above-mentioned objectives, the present invention provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned weld defect detection method based on an improved YOLO network is implemented.
[0097] Based on this, the beneficial effects of the present invention are: the present application combines lightweight convolution, deformable convolution, ELAN-PCS network structure and coordinate attention mechanism, and improves the feature channel selection capability through SimAM (parameter-free attention mechanism), so that the model can maintain high-precision detection in a low-computing resource environment and is suitable for a variety of industrial automation detection needs;
[0098] A lightweight convolution module is integrated into the model to reduce the computational burden and optimize the model structure, significantly reducing the number of model parameters and improving computational efficiency. Deformable convolution is introduced in the feature extraction stage, allowing the convolution kernel to adaptively adjust its shape and position, thereby accurately capturing the detailed features of irregular weld defects. The dynamic offset mechanism of the deformable convolution enhances the adaptability and accuracy of the model in complex weld detection, effectively reducing missed detections and false detections, and improving the detection accuracy of weld defects. A feature aggregation mechanism combines shallow and deep feature information, enhancing the model's detection capability for small targets. Important feature channels are adaptively selected without the need for additional parameters, allowing the model to focus more on features relevant to weld defect detection, effectively reducing interference from irrelevant information and further improving the detection accuracy of small defect targets. This ensures that the model maintains high efficiency while also having higher feature selection capabilities. A coordinate attention mechanism is introduced in the detection head. By generating weights for spatial coordinate information, the model can adaptively assign different weights to different pixels in the width and height directions of the feature map, enabling the model to reliably detect subtle weld defects even in noisy environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0099] Figure 1 is a flow chart of a weld defect detection method based on an improved YOLO network according to an exemplary embodiment;
[0100] Figure 2 1 is a network structure diagram of a weld defect detection method based on an improved YOLO network according to an exemplary embodiment;
[0101] Figure 3 The figure is a flow chart of a weld defect detection system based on an improved YOLO network according to an exemplary embodiment. DETAILED DESCRIPTION
[0102] The present invention will now be discussed with reference to exemplary embodiments. It should be understood that the embodiments discussed are only for enabling those skilled in the art to better understand and thereby implement the present invention, rather than implying any limitation on the scope of the present invention.
[0103] As used herein, the term “including” and variations thereof are to be interpreted as open-ended terms meaning “including, but not limited to.” The term “based on” is to be interpreted as “based, at least in part, on,” and the terms “one embodiment” and “an embodiment” are to be interpreted as “at least one embodiment.”
[0104] According to one embodiment of the present invention, Figure 1 FIG. 1 is a flow chart of a weld defect detection method based on an improved YOLO network according to an exemplary embodiment. Figure 1As shown, to achieve the above purpose, the present invention provides a weld defect detection method based on an improved YOLO network, comprising:
[0105] Obtain original welding images;
[0106] Figure 2 is a network structure diagram of a weld defect detection method based on an improved YOLO network according to an exemplary embodiment. Figure 2 As shown, based on the original welding image, it is input into the backbone feature extraction network to obtain the first feature information map, the second feature information map and the third feature information map;
[0107] Based on the first feature information map, the second feature information map and the third feature information map, inputting them into the fusion enhanced feature extraction network to obtain the first enhanced feature information map, the second enhanced feature information map and the third enhanced feature information map;
[0108] Based on the first enhanced feature information map, the second enhanced feature information map and the third enhanced feature information map, inputting them into the attention mechanism network to obtain a welding inspection image;
[0109] The weld defect detection results are obtained based on the welding inspection image.
[0110] According to one embodiment of the present invention, the backbone feature extraction network includes two convolutional neural network modules connected in sequence, three layer-aggregated partial convolution and attention mechanism modules connected to the two convolutional neural network modules, three maximum pooling layers and one layer-aggregated deformable convolution;
[0111] The original welding image is input into the first convolutional neural network module to obtain the first convolutional neural network feature, where the formula is:
[0112] F1 = SiLU(BN(conv(X)));
[0113] Among them, X represents the original welding image;
[0114] conv represents the convolutional layer;
[0115] BN represents batch normalization layer;
[0116] SiLU represents the activation function;
[0117] F1 represents the first convolutional neural network feature;
[0118] The first convolutional neural network feature is input into the second convolutional neural network module to obtain the second convolutional neural network feature, where the formula is,
[0119] F2 = SiLU(BN(conv(F1)));
[0120] F2 represents the second convolutional neural network feature.
[0121] According to one embodiment of the present invention, obtaining the first characteristic information map, the second characteristic information map, and the third characteristic information map includes:
[0122] The second convolutional neural network features are sequentially input into the first layer of aggregate partial convolution and attention mechanism module, the first maximum pooling layer, and the second layer of aggregate partial convolution and attention mechanism module to obtain the first feature information graph, where the formula is,
[0123] F3=ELAN-PCS(MP(ELAN-PCS(F2)));
[0124] Among them, ELAN-PCS represents the layer aggregation partial convolution and attention mechanism module;
[0125] MP represents the maximum pooling layer;
[0126] F3 represents the first feature information graph;
[0127] The first feature information map is sequentially input into the second maximum pooling layer and the third layer aggregation partial convolution and attention mechanism module to obtain the second feature information map, where the formula is,
[0128] F4 = ELAN-PCS (MP (F3));
[0129] Wherein, F4 represents the second feature information graph;
[0130] The second feature information map is sequentially input into the third maximum pooling layer and layer aggregation deformable convolution to obtain the third feature information map, where the formula is,
[0131] F5 = ELAN-DCNV2 (MP (F4));
[0132] Among them, ELAN-DCNV2 represents layer-aggregated deformable convolution;
[0133] F5 represents the third characteristic information graph.
[0134] According to one embodiment of the present invention, a method for obtaining a first enhanced feature information map, a second enhanced feature information map, and a third enhanced feature information map includes:
[0135] The fusion-enhanced feature extraction network consists of a spatial pyramid pooling layer, four feature fusion modules, six convolutional neural network modules, four layer-aggregated partial convolution and attention mechanism modules, two channel attention mechanism layers, and two upsampling layers;
[0136] The first feature information graph is sequentially input into the third convolutional neural network module and the first channel attention mechanism layer to obtain the first attention feature, where the formula is,
[0137] F 11 =Attention(SiLU(BN(conv(F3))));
[0138] Among them, Attention represents the channel attention mechanism layer;
[0139] F 11 Indicates the first feature of interest;
[0140] The second feature information graph is sequentially input into the fourth convolutional neural network module and the second channel attention mechanism layer to obtain the second attention feature, where the formula is,
[0141] F 12 =Attention(SiLU(BN(conv(F4))));
[0142] Among them, F 12 Indicates the second feature of interest;
[0143] The third feature information map is input into the spatial pyramid pooling layer to obtain the multi-scale pooling feature, where the formula is:
[0144] F6=SPPCSPC(F5);
[0145] Among them, SPPCSPC represents the spatial pyramid pooling layer;
[0146] F6 represents multi-scale pooling features;
[0147] The multi-scale pooling features are sequentially input into the fifth convolutional neural network module and the first upsampling layer to obtain the third focus feature, where the formula is,
[0148] F 13 =Upsample(SiLU(BN(conv(F6))));
[0149] Among them, Upsample represents the upsampling layer;
[0150] F 13 Indicates the third feature of interest.
[0151] According to one embodiment of the present invention, a method for obtaining a first enhanced feature information map, a second enhanced feature information map, and a third enhanced feature information map includes:
[0152] The third attention feature is fused with the second attention feature and then input into the fourth layer aggregation partial convolution and attention mechanism module to obtain the first fusion feature, where the formula is,
[0153] F 21 =ELAN-PCS(Concat(F 12 ,F 13 ));
[0154] Among them, Concat means channel stacking fusion;
[0155] F 21 represents the first fusion feature;
[0156] The first fusion feature is sequentially input into the sixth convolutional neural network module and the second upsampling layer and then fused with the first feature information graph to obtain the second fusion feature, where the formula is:
[0157] F 22 =Concat(F 21 ,Upsample(SiLU(BN(conv(F3)))));
[0158] Among them, F 22 represents the second fusion feature;
[0159] The second fusion feature is sequentially input into the fifth-layer aggregate partial convolution and attention mechanism module and the seventh convolutional neural network module, and then fused with the first fusion feature to obtain the third fusion feature, where the formula is:
[0160] F 23 =Concat(F 21 ,SiLU(BN(conv(ELAN-PCS(F 22 )))));
[0161] Among them, F 23 represents the third fusion feature;
[0162] The third fusion feature is sequentially input into the sixth layer of aggregate partial convolution and attention mechanism module and the eighth convolutional neural network module, and then fused with the multi-scale pooling feature to obtain the fourth fusion feature, where the formula is:
[0163] F 24 =Concat(F6,SiLU(BN(conv(ELAN-PCS(F 23 )))));
[0164] Among them, F 24 Represents the fourth fusion feature.
[0165] According to one embodiment of the present invention, a method for obtaining a welding detection image includes:
[0166] The attention mechanism network consists of three lightweight convolutions, three attention modules and a feature output module:
[0167] The second fusion feature is input into the fifth layer of aggregated partial convolution and attention mechanism module to obtain the first enhanced feature information map. The first enhanced feature information map is input into the first lightweight convolution and the first attention module in sequence to obtain the first output feature, where the formula is,
[0168] F 31 =EALN-PCS(F 22 );
[0169] S1=SimAM(PConv(F 31 ));
[0170] Among them, F 31 represents a first enhanced feature information graph;
[0171] S1 represents the first output feature;
[0172] SimAM represents the attention module;
[0173] PConv stands for lightweight convolution;
[0174] The third fusion feature is input into the sixth layer of aggregated partial convolution and attention mechanism module to obtain the second enhanced feature information map. The second enhanced feature information map is input into the second lightweight convolution and second attention modules in sequence to obtain the second output feature, where the formula is,
[0175] F 32 =ELAN-PCS(F 23 );
[0176] S2=SimAM(PConv(F 32 ));
[0177] Among them, F 32 represents a second enhanced feature information graph;
[0178] S2 represents the second output feature;
[0179] The fourth fusion feature is input into the seventh layer of aggregated partial convolution and attention mechanism module to obtain the third enhanced feature information map. The third enhanced feature information map is input into the third lightweight convolution and third attention modules in sequence to obtain the third output feature, where the formula is,
[0180] F 33 =ELAN-PCS(F 24 );
[0181] S3=SimAM(PConv(F33 ));
[0182] Among them, F 33 represents a third enhanced feature information graph;
[0183] S3 represents the third output feature.
[0184] According to one embodiment of the present invention, a method for obtaining a welding detection image includes:
[0185] After the first output feature, the second output feature, and the third output feature are input into the feature output module, the welding detection image is obtained, where the formula is:
[0186]
[0187] Where Y represents the welding inspection image;
[0188] Represents the feature output module.
[0189] According to one embodiment of the present invention, lightweight convolution is added to the convolution structure of the model, and the computational complexity and the number of model parameters are reduced through depth-separable convolution or lightweight operations based on group convolution, so that the model can improve the running speed while ensuring detection accuracy. The application of lightweight convolution ensures that the detection can run smoothly on devices with limited resources (such as mobile terminals or embedded systems).
[0190] According to one embodiment of the present invention, a deformable convolution is added to the model so that the convolution kernel can adaptively adjust its shape to adapt to the irregular shape characteristics of weld defects. By introducing deformable convolution, the model can more flexibly capture the detailed information of weld defects and improve the recognition accuracy of small defects or irregular defects. The parameters of the deformable convolution are adaptively optimized through the model to enhance the adaptability to complex weld textures.
[0191] According to one embodiment of the present invention, an ELAN-PCS module is added to the model to enhance the ability to detect small targets by aggregating features between layers. ELAN-PCS can not only effectively aggregate shallow and deep feature information, but also adopts a parameter-free attention mechanism to automatically focus on subtle defects in welds, making detection more robust. PC stands for partial convolution, and S stands for SiMAM, a three-dimensional attention mechanism that does not require additional parameters. It dynamically adjusts feature weights through an energy function to enhance the focus on key information.
[0192] According to one embodiment of the present invention, in combination with the feature requirements of the weld defect detection task, a coordinate attention mechanism is adopted to embed spatial coordinate information into the feature extraction process of the model. The model assigns weights corresponding to different pixel points through the coordinate attention mechanism, thereby enhancing the recognition and positioning accuracy of small defects. The coordinate attention mechanism generates weights in the width and height directions of the feature map, so that the model pays more attention to the specific position of the target object, especially the edge area of the weld and small target defects in complex backgrounds.
[0193] According to one embodiment of the present invention, a model was trained on a weld defect dataset containing various defect types (such as pores and cracks). Data augmentation techniques were used to simulate different industrial scenarios. During training, the Adam optimizer and cross-entropy loss function were used to adjust model parameters to ensure good generalization in complex environments. Furthermore, ablation and comparative experiments were conducted to analyze the performance contributions of each module. Ultimately, the model structure was optimized to achieve accurate and rapid weld defect detection. The optimized model outperformed existing weld defect detection technologies in both accuracy and speed, meeting the requirements of real-time industrial field detection.
[0194] According to one embodiment of the present invention, the lightweight convolution module reduces redundant parameters and computational complexity by decomposing the convolution layer into depthwise separable convolution or group convolution-based convolution. This module reduces model complexity while maintaining high-precision feature extraction capabilities, enabling the model to run in real time on embedded devices and low-computing environments, meeting the high-efficiency requirements of industrial automated weld defect detection.
[0195] According to one embodiment of the present invention, the deformable convolution layer introduces a dynamic offset parameter to adaptively adjust the position of the convolution kernel, so that the convolution process can better adapt to the irregular shape of the weld defect. This convolution method enhances the model's feature extraction capability for irregular weld defects, and is particularly suitable for the detection of variable and subtle weld defects such as cracks and pores, significantly improving the robustness of the model in complex weld defect detection.
[0196] According to one embodiment of the present invention, the ELAN-PCS structure integrates SimAM (parameter-free attention mechanism), which improves the attention to the defect area by automatically identifying and focusing on important feature channels related to defects. SimAM does not require additional parameter adjustment. It simulates the human attention mechanism to improve the focusing accuracy of small-size defects and reduce the computational overhead of the model, thereby achieving optimized extraction of important features. The principle of SimAM is to obtain the 3-D weight of each neuron in the weld surface defect feature map through an energy function, and obtain the final output feature by performing a dot multiplication of the obtained 3-D weight and the input feature map.
[0197] According to one embodiment of the present invention, the coordinate attention mechanism generates spatial weights in the width and height directions of the feature map to enhance the focus on the target location of weld defects, so that the model can accurately detect small-sized defects in welds even under complex backgrounds and noise interference. This mechanism ensures the positioning accuracy of the model, especially in scenes with large changes in weld edges and lighting, and improves the ability to distinguish subtle weld defects.
[0198] According to one embodiment of the present invention, data preparation and preprocessing are performed. To ensure that the model can adapt to complex industrial inspection environments, the data collection process should cover a variety of weld defect types (such as cracks, pores, weld nodules, etc.), and the data should be collected through multiple shooting angles and lighting conditions to enhance data diversity. In order to improve the robustness and generalization ability of the model, the data set is enhanced, including random rotation, scaling, brightness adjustment, cropping and other data enhancement operations to simulate different welding conditions. The enhanced data set can help the model adapt to complex inspection scenarios. In addition, annotation tools are used to accurately annotate the weld defect data, and the defect type and location coordinates are added to each sample to ensure that the model training phase can accurately identify and locate defects.
[0199] In the model architecture design stage, the present invention integrates lightweight convolution, deformable convolution, ELAN-PCS network structure and coordinate attention mechanism on the basis of the model. First, the lightweight convolution module replaces some conventional convolution layers. Through the depth-separable convolution and group convolution strategies, the traditional convolution operation is decomposed into independent channel convolution and point-by-point convolution, which significantly reduces the number of model parameters and improves computational efficiency. The integration of this module ensures that the model is suitable for low-power devices such as embedded devices while maintaining high accuracy, thereby meeting the real-time detection needs of industrial sites.
[0200] Subsequently, the model introduced deformable convolution in the feature extraction stage. By dynamically adjusting the offset position of the convolution kernel, the convolution kernel was made to fit the edge and shape characteristics of the weld defect more closely. The adaptive offset mechanism of the deformable convolution can automatically adjust the position and receptive field of the convolution window according to the characteristics of the defects in the input image, significantly improving the model's feature capture ability in processing irregular morphological defects (such as cracks), thereby improving the accuracy and robustness of detection and reducing the missed detection and false detection rates.
[0201] To further enhance the model's performance in small object detection, the present invention incorporates the ELAN-PCS module into the backbone network. This module effectively combines shallow edge information with deep semantic information through multi-layer feature fusion, giving the model enhanced small object detection capabilities. Furthermore, the SimAM (parameter-free attention mechanism) integrated into ELAN-PCS automatically selects important feature channels relevant to defect detection without requiring additional parameter adjustments, reducing interference from irrelevant information and further improving the detection accuracy of small defect targets. This design not only effectively reduces computational overhead but also makes the model more efficient in detecting small defects.
[0202] The model's detection head incorporates a coordinate attention mechanism to further improve the spatial localization accuracy of weld defects. This mechanism generates spatial weights for feature maps, fusing width and height information with channel features. This helps the model focus on weld areas, maintaining high detection accuracy for small defects (such as edge cracks and pores) even in complex backgrounds or with unstable lighting conditions. The coordinate attention mechanism improves the model's recognition and localization accuracy, effectively reducing false detection rates, particularly for small defects at weld edges and in complex backgrounds.
[0203] During model training and optimization, the data-augmented weld defect dataset was divided into training, validation, and test sets, with training performed in a 7:1:2 ratio. The Adam optimizer and cross-entropy loss function were used to adjust model parameters to ensure generalization across multiple scenarios and working conditions. To increase the model's adaptability, data augmentation strategies were further employed to simulate defect morphologies in different welding environments. During multiple rounds of iterative optimization, ablation and comparative experiments were conducted to evaluate the effectiveness of each module, including lightweight convolution, deformable convolution, ELAN-PCS, and coordinate attention mechanisms, to ensure the contribution of improvements in each model component to performance. Model performance was evaluated using metrics such as mean average precision (mAP) and detection speed (FPS), ensuring that the model met the speed requirements for real-time detection while maintaining high detection accuracy. During the model testing and deployment phase, the improved model's actual performance was verified on the test set, ensuring its accurate identification, location, and classification of weld defects. Test results show that the model achieves a defect detection speed of 172.4 FPS with an average accuracy of 95.6%. It performs particularly well in detecting small defects such as pores, with a detection accuracy of 90.2%. After the model was tested, it was deployed in embedded devices or industrial inspection systems to verify its real-time and efficiency in low-computing environments. Experimental results show that the optimization of lightweight convolution and the ELAN-PCS module ensures that the model can achieve efficient detection on embedded systems, making it suitable for the automated weld quality inspection needs of industrial sites.
[0204] In summary, the present invention demonstrates excellent detection accuracy and real-time performance in complex construction environments, and is suitable for embedded devices and automated detection scenarios. Experimental verification shows that the improved model of the present invention is superior to traditional methods in detection speed, accuracy, and small target recognition. It can effectively improve the quality control level of the welding process and has broad application prospects.
[0205] In addition, in order to achieve the above-mentioned purpose, the present invention also provides a weld defect detection system based on an improved YOLO network. Figure 3 FIG. 1 is a flow chart of a weld defect detection system based on an improved YOLO network according to an exemplary embodiment. Figure 3 As shown, a weld defect detection system based on an improved YOLO network in the present invention includes:
[0206] Welding original image acquisition unit: acquires welding original image;
[0207] Feature information map acquisition unit: Based on the original welding image, it is input into the backbone feature extraction network to obtain the first feature information map, the second feature information map and the third feature information map;
[0208] An enhanced feature information map acquisition unit: based on the first feature information map, the second feature information map and the third feature information map, inputs them into a fusion enhanced feature extraction network to obtain a first enhanced feature information map, a second enhanced feature information map and a third enhanced feature information map;
[0209] Welding inspection image extraction unit: Based on the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map, the first enhanced feature information map is input into the attention mechanism network to obtain a welding inspection image;
[0210] Defect monitoring result acquisition unit: obtains weld defect detection results based on welding detection images.
[0211] To achieve the above-mentioned purpose of the invention, the present invention also provides an electronic device, which includes: a processor, a memory, and a computer program stored in the memory and capable of running on the processor. When the computer program is executed by the processor, the above-mentioned weld defect detection method based on the improved YOLO network is implemented.
[0212] To achieve the above-mentioned purpose of the invention, the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned weld defect detection method based on the improved YOLO network is implemented.
[0213] Those skilled in the art will appreciate that the modules and algorithm steps described in conjunction with the embodiments disclosed herein can be implemented using electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0214] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and equipment can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0215] In the embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules is merely a logical function division. In actual implementation, there may be other division methods, such as multiple modules or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or modules, which can be electrical, mechanical or other forms.
[0216] The modules described as separate components may or may not be physically separate, and the components shown as modules may or may not be physical modules, that is, they may be located in one place or distributed across multiple network modules. Some or all of these modules may be selected according to actual needs to achieve the objectives of the embodiments of the present invention.
[0217] In addition, each functional module in the embodiment of the present invention may be integrated into one processing module, or each module may exist physically separately, or two or more modules may be integrated into one module.
[0218] If the functions are implemented as software modules and sold or used as standalone products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or the portion of the technical solution itself, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the energy-saving signal transmission / reception method according to various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a mobile hard drive, ROM, RAM, a magnetic disk, or an optical disk.
[0219] The above description is merely a preferred embodiment of the present application and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of the invention herein is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also encompasses other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the inventive concept. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features having similar functions disclosed in this application.
[0220] It should be understood that the size of the serial numbers of each step in the content of the invention and the embodiments of the present invention does not absolutely mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
Claims
1. A weld defect detection method based on an improved YOLO network, characterized in that: include: Obtain original welding images; Based on the original welding image, it is input into the backbone feature extraction network to obtain the first feature information map, the second feature information map and the third feature information map; Based on the first feature information map, the second feature information map and the third feature information map, inputting them into the fusion enhanced feature extraction network to obtain the first enhanced feature information map, the second enhanced feature information map and the third enhanced feature information map; Based on the first enhanced feature information map, the second enhanced feature information map and the third enhanced feature information map, inputting them into the attention mechanism network to obtain a welding inspection image; The weld defect detection results are obtained based on the welding inspection image.
2. A weld defect detection method based on an improved YOLO network according to claim 1, characterized in that: The backbone feature extraction network consists of two sequentially connected convolutional neural network modules, three layer-aggregated partial convolution and attention mechanism modules connected to the two convolutional neural network modules, three maximum pooling layers, and one layer-aggregated deformable convolution; The original welding image is input into the first convolutional neural network module to obtain the first convolutional neural network feature, where the formula is: F1 = SiLU(BN(conv(X))); Among them, X represents the original welding image; conv represents the convolutional layer; BN represents batch normalization layer; SiLU represents the activation function; F1 represents the first convolutional neural network feature; The first convolutional neural network feature is input into the second convolutional neural network module to obtain the second convolutional neural network feature, where the formula is, F2 = SiLU(BN(conv(F1))); F2 represents the second convolutional neural network feature.
3. A weld defect detection method based on an improved YOLO network as claimed in claim 2, characterized in that: The obtaining of the first characteristic information graph, the second characteristic information graph, and the third characteristic information graph includes: The second convolutional neural network features are sequentially input into the first layer of aggregate partial convolution and attention mechanism module, the first maximum pooling layer, and the second layer of aggregate partial convolution and attention mechanism module to obtain the first feature information graph, where the formula is, F3=ELAN-PCS(MP(ELAN-PCS(F2))); Among them, ELAN-PCS represents the layer aggregation partial convolution and attention mechanism module; MP represents the maximum pooling layer; F3 represents the first feature information graph; The first feature information map is sequentially input into the second maximum pooling layer and the third layer aggregation partial convolution and attention mechanism module to obtain the second feature information map, where the formula is, F4 = ELAN-PCS (MP (F3)); Wherein, F4 represents the second feature information graph; The second feature information map is sequentially input into the third maximum pooling layer and layer aggregation deformable convolution to obtain the third feature information map, where the formula is, F5 = ELAN-DCNV2 (MP (F4)); Among them, ELAN-DCNV2 represents layer-aggregated deformable convolution; F5 represents the third characteristic information graph.
4. A weld defect detection method based on an improved YOLO network as claimed in claim 3, characterized in that: The method for obtaining the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map includes: The fusion-enhanced feature extraction network consists of a spatial pyramid pooling layer, four feature fusion modules, six convolutional neural network modules, four layer-aggregated partial convolution and attention mechanism modules, two channel attention mechanism layers, and two upsampling layers; The first feature information graph is sequentially input into the third convolutional neural network module and the first channel attention mechanism layer to obtain the first attention feature, where the formula is, F 11 =Attention(SiLU(BN(conv(F3)))); Among them, Attention represents the channel attention mechanism layer; F 11 Indicates the first feature of interest; The second feature information graph is sequentially input into the fourth convolutional neural network module and the second channel attention mechanism layer to obtain the second attention feature, where the formula is, F 12 =Attention(SiLU(BN(conv(F4)))); Among them, F 12 Indicates the second feature of interest; The third feature information map is input into the spatial pyramid pooling layer to obtain the multi-scale pooling feature, where the formula is: f6=SPPCSPC(f5); Among them, sppcspc represents the spatial pyramid pooling layer; F6 represents multi-scale pooling features; The multi-scale pooling features are sequentially input into the fifth convolutional neural network module and the first upsampling layer to obtain the third focus feature, where the formula is, F 13 =Upsample(SiLU(BN(conv(F6)))); Among them, Upsample represents the upsampling layer; f 13 Indicates the third feature of interest.
5. A weld defect detection method based on an improved YOLO network as claimed in claim 4, characterized in that: The method for obtaining the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map includes: The third attention feature is fused with the second attention feature and then input into the fourth layer aggregation partial convolution and attention mechanism module to obtain the first fusion feature, where the formula is, F 21 =ELAN-PCS(Concat(F 12 ,F 13 )); Among them, Concat means channel stacking fusion; F 21 represents the first fusion feature; The first fusion feature is sequentially input into the sixth convolutional neural network module and the second upsampling layer and then fused with the first feature information graph to obtain the second fusion feature, where the formula is: F 22 =Concat(F 21 ,Upsample(SiLU(BN(conv(F3))))); Among them, F 22 represents the second fusion feature; The second fusion feature is sequentially input into the fifth-layer aggregate partial convolution and attention mechanism module and the seventh convolutional neural network module, and then fused with the first fusion feature to obtain the third fusion feature, where the formula is: F 23 =Concat(F 21 ,SiLU(BN(conv(ELAN-PCS(F 22 ))))); Among them, F 23 represents the third fusion feature; The third fusion feature is sequentially input into the sixth layer of aggregate partial convolution and attention mechanism module and the eighth convolutional neural network module, and then fused with the multi-scale pooling feature to obtain the fourth fusion feature, where the formula is: F 24 =Concat(F6,SiLU(BN(conv(ELAN-PCS(F 23 ))))); Among them, F 24 Represents the fourth fusion feature.
6. A weld defect detection method based on an improved YOLO network as claimed in claim 5, characterized in that: The method for obtaining a welding detection image comprises: The attention mechanism network consists of three lightweight convolutions, three attention modules and a feature output module: The second fusion feature is input into the fifth layer of aggregated partial convolution and attention mechanism module to obtain the first enhanced feature information map. The first enhanced feature information map is input into the first lightweight convolution and the first attention module in sequence to obtain the first output feature, where the formula is, F 31 =ELAN-PCS(F 22 ); S1=SimAM(PConv(F 31 )); Among them, F 31 represents a first enhanced feature information graph; S1 represents the first output feature; SimAM represents the attention module; PConv stands for lightweight convolution; The third fusion feature is input into the sixth layer of aggregated partial convolution and attention mechanism module to obtain the second enhanced feature information map. The second enhanced feature information map is input into the second lightweight convolution and second attention modules in sequence to obtain the second output feature, where the formula is, F 32 =ELAN-PCS(F 23 ); S2=SimAM(PConv(F 32 )); Among them, F 32 represents a second enhanced feature information graph; S2 represents the second output feature; The fourth fusion feature is input into the seventh layer of aggregated partial convolution and attention mechanism module to obtain the third enhanced feature information map. The third enhanced feature information map is input into the third lightweight convolution and third attention modules in sequence to obtain the third output feature, where the formula is, F 33 =ELAN-PCS(F 24 ); S3=SimAM(PConv(F 33 )); Among them, F 33 represents a third enhanced feature information graph; S3 represents the third output feature.
7. A weld defect detection method based on an improved YOLO network as claimed in claim 6, characterized in that: The method for obtaining a welding detection image comprises: After the first output feature, the second output feature, and the third output feature are input into the feature output module, the welding detection image is obtained, where the formula is: Where Y represents the welding inspection image; Represents the feature output module.
8. A weld defect detection system based on an improved YOLO network, characterized in that: include: Welding original image acquisition unit: acquires welding original image; Feature information map acquisition unit: Based on the original welding image, it is input into the backbone feature extraction network to obtain the first feature information map, the second feature information map and the third feature information map; An enhanced feature information map acquisition unit: based on the first feature information map, the second feature information map and the third feature information map, inputs them into a fusion enhanced feature extraction network to obtain a first enhanced feature information map, a second enhanced feature information map and a third enhanced feature information map; Welding inspection image extraction unit: Based on the first enhanced feature information map, the second enhanced feature information map, and the third enhanced feature information map, the first enhanced feature information map is input into the attention mechanism network to obtain a welding inspection image; Defect monitoring result acquisition unit: obtains weld defect detection results based on welding detection images.
9. An electronic device, characterized in that: The invention comprises a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the computer program is executed by the processor, a weld defect detection method based on an improved YOLO network as claimed in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by the processor, it implements a weld defect detection method based on an improved YOLO network according to any one of claims 1 to 7.
Citation Information
Cited By
Anti-shielding, multi-scale and self-adaptive deformation welding spot defect detection method
CN121329930A