Welding quality detection method based on deep learning
By designing information elastic convolutional layer, cross-window attention mechanism and weighted feedback fusion mechanism, combined with welding quality detection module and cascade classifier, the problems of traditional welding quality detection methods are solved, with high cost, long detection cycle and low classification accuracy, and efficient and accurate welding quality detection and grading are achieved.
Patent Information
- Application Number
- CN202510305748.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-07-01
AI Technical Summary
Traditional welding quality detection methods are costly, have a long detection cycle and are susceptible to subjective factors. The existing deep learning-based methods are insufficient in feature extraction and low classification accuracy when processing complex welding images, and fail to fully consider the overall evaluation and grading of welding quality.
Design information elastic convolution layer, cross-window attention mechanism and weighted feedback fusion mechanism, improve local feature capture ability through dynamic receptive fields and adaptive convolution control blocks, improve global context information understanding ability through dynamic window division and information interaction between windows, improve feature fusion process through weighted feedback fusion mechanism, and build a welding quality detection module and cascade classifier for welding quality evaluation and grading.
It improves the ability to learn welding image features, enhances the ability to understand complex welding images, realizes efficient and accurate welding quality detection and grading, and reduces detection costs and cycles.
Smart Images

Figure CN120236166A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of image processing, and particularly relates to a welding quality detection method based on deep learning. Background Art
[0002] During the tunnel construction process, waterproof boards need to be laid. During the laying process of waterproof boards, the welding and fixing between the waterproof board and the hot-melt washer are the key to ensuring the waterproof effect. The welding quality directly affects the waterproof effect. Most traditional welding quality detection methods rely on manual inspection or use traditional non-destructive testing techniques. These methods often have high costs and long detection cycles. At the same time, manual inspection is easily affected by subjective factors and cannot guarantee consistency and efficiency.
[0003] With the rapid development of computer vision and deep learning technologies, welding quality detection methods based on image processing have gradually become a research hotspot. By using a high-resolution camera or other imaging devices to collect images of the welding part and combining deep learning algorithms, it is possible to achieve automatic detection and classification of defects during the welding process. Compared with traditional detection methods, these methods not only improve the detection efficiency but also can perform high-precision quality evaluation in a shorter time. However, these methods still face some challenges when dealing with complex welding images. First, welding images usually have large variability, and the shapes, sizes, and distributions of defects are diverse, which easily leads to insufficient feature extraction and low classification accuracy. Second, most existing methods focus on defect detection and do not fully consider the overall evaluation and grading of welding quality. To address the above problems, the present invention proposes a welding quality detection method based on deep learning, designs an information elastic convolution layer to improve the ability to capture local complex details through a dynamic receptive field and an adaptive convolution control block; designs a cross-window attention mechanism to calculate the attention between windows through dynamic window division and information interaction between windows to improve the ability to understand global context information; improves the flexibility and fusion degree of the feature fusion process through a weighted feedback fusion mechanism to enhance the welding image feature learning ability; constructs a welding quality detection module to adaptively locate the welding area through adaptive boundary positioning, and proposes a cascade classifier. First, it determines whether the welding is qualified through a welding quality scoring function, and then introduces a fine-grained classification branch to detail the welding quality division to improve the ability of welding quality detection. Summary of the Invention
[0004] The present invention provides a welding quality detection method based on deep learning, aiming to dynamically fuse local features extracted based on the information elastic convolution layer and global features extracted based on the cross-window attention mechanism through a weighted feedback fusion mechanism, adaptively locate the welding area through a welding quality detection module, and determine whether the welding quality is qualified and detail the welding quality through the detection of the welding area.
[0005] To achieve the above object, the present invention provides the following technical solutions: A welding quality detection method based on deep learning, comprising the following steps.
[0006] S1. Collect qualified and defective welding images to produce a welding quality detection image dataset.
[0007] S2. Design an information elastic convolution layer, improve the fixed receptive field of the traditional convolution layer with a dynamic receptive field, and optimize the ability of the convolution operation to capture local complex details through an adaptive convolution control block.
[0008] S3. Design a cross-window attention mechanism to calculate the attention between windows. First, dynamically adjust the size of the window through dynamic window partitioning, and then introduce information interaction between windows to improve the limitation that information cannot interact between windows in the traditional window self-attention mechanism.
[0009] S4. Design a weighted feedback fusion mechanism to improve the flexibility and fusion degree of the feature fusion process. The weighted feedback fusion mechanism measures the weight of global context information through the difference in information between blocks, determines the weight of local features through the texture change in the local area, and fuses the global context information and local features with weights.
[0010] S5. Construct a welding quality detection module, perform boundary prediction through adaptive boundary judgment to locate the welding area, design a cascade classifier, determine whether the welding is qualified through a welding quality scoring function, and then introduce a fine-grained classification branch to detail the welding quality, including the qualified sub-quality levels, and label the defect type and severity for unqualified ones.
[0011] S6. Construct a welding quality detection model. The model includes an information elastic convolution layer, a cross-window attention mechanism, a weighted feedback fusion mechanism, and a welding quality detection module. Input the welding image into the welding quality detection model to obtain the welding quality detection result. Preferably, in step S1, collect welding images at different angles, different distances, and different welding processes. The welding images include qualified welding images and defective welding images. The welding defect types include pores, cracks, incomplete penetration, spatter, and uneven weld seams. The qualified welding images are divided into three grades: excellent, good, and average. Annotate each image with a bounding box for the welding area. For unqualified welding images, annotate the defect type and severity, and for qualified welding images, annotate the welding quality grade.
[0012] Preferably, in step S2, the information elastic convolution layer includes a dynamic receptive field and an adaptive convolution control block. The specific steps of the information elastic convolution layer are as follows:
[0013] S21. Input the first welding image feature X ∈ R H×W×C, where H, W, and C are the height, width, and channels of the first welding image respectively, and the specific calculation formula for the elastic convolution operation is:
[0014]
[0015] In the formula, Y (h,w) is the elastic convolution at (h, w), h ∈ [0, W], w ∈ [0, W], S(h, w) is the dynamic receptive field at (h, w), X (h+k,w+l) is the feature of (h + k, w + l) in the first welding image feature, and W(h, w) is the adaptive convolution control block at (h, w);
[0016] S22. The dynamic receptive field measures the range of the receptive field through the gradient information of local changes. The specific calculation formula for the dynamic receptive field S(h, w) is:
[0017]
[0018] In the formula, r is the maximum radius of the receptive field, is the gradient value at (h + p, w + q) in the first welding image feature; S23. The adaptive convolution control block dynamically adjusts the operations of different convolutional layers through local gradient changes. The specific calculation formula for the adaptive convolution control block W(h, w) is:
[0019]
[0020] In the formula, μ W is the local mean within the dynamic receptive field, is the gradient value in the horizontal direction, is the gradient value in the vertical direction. Preferably, in step S2, the traditional convolutional layer processes a receptive field with a fixed size of a local window. By designing an information elastic convolutional layer, the receptive field of the convolutional layer can be adaptively adjusted in different regions; the elastic region of the convolutional kernel will dynamically expand according to the changes in the important regions in the image, thereby enhancing the network's ability to learn important local features in different regions; through the dynamic receptive field, the receptive region can be dynamically changed according to the complexity of the image content, and the adaptive convolution control block dynamically adjusts the operations of different convolutional layers according to the quality of different regions of the welding image. By assigning different convolution processing strategies to different regions, the pertinence of feature extraction is further enhanced.
[0021] Preferably, in step S3, the cross-window attention mechanism includes dynamic window partitioning and information interaction between windows. The specific steps are: S31. Dynamic window partitioning first divides the welding image into N windows, and then dynamically adjusts the size of each window through the fusion of weighted gradients and surrounding region information. The specific calculation formula for the window size is:
[0022]
[0023] In the formula, M m is the window size of region m, where m ∈ [1, N], is the gradient value of region m, X m is the feature vector of region m, is used to measure the feature difference between region m and its surrounding regions;
[0024] S32. The information interaction between windows measures the similarity between different windows through the window - to - window difference to update the query and key of the window. The specific calculation formulas for the update of the query and key are as follows:
[0025]
[0026] In the formula, Q m is the query vector of window M m , is the updated query vector of window M m , K m is the key vector of window M m , is the updated key vector of window M m , ΔQ mn is the difference value between window M m and window M n . Window M n is the adjacent window of window M m , is the accumulation of the window - to - window difference;
[0027] The specific calculation formula for the window difference value ΔQ mn is as follows:
[0028]
[0029] In the formula, Q n is the query vector of the adjacent window M n , is the difference between the query vector of window M m and the query vectors of its surrounding windows;
[0030] S33. Calculate the cross - window attention A mn between window M m and window M n through the updated query and key of window M m and the adjacent window M n . The specific calculation formula for the cross - window attention is as follows:
[0031]
[0032] In the formula, For window M n The updated query vector, For window M n The updated key vector, Is a weighted fusion operation, And Is a distance metric term.
[0033] Preferably, in step S3, the cross-window attention mechanism first divides the welding quality inspection image into small windows through dynamic window partitioning and dynamically adjusts the window size according to the regional complexity. Then, it introduces information interaction between windows to improve the limitation that information cannot interact between windows in the traditional window self-attention mechanism. The information interaction between windows is not just through simple offset of window positions, but by measuring the similarity between different windows through window differences to update the query and key of the window, promoting cross-window interaction. Calculating the attention between windows through the cross-window attention mechanism can more effectively improve the interaction of global information.
[0034] Preferably, in step S4, an information elastic convolution layer is used to extract the local feature I of the welding image local , and the cross-window attention mechanism is used to capture the global context information I of the welding image global . The weighted feedback fusion mechanism dynamically adjusts the local feature and the global context information through the feedback mechanism, and then performs weighted fusion to obtain the fusion feature I fin . The mathematical model of the weighted feedback fusion mechanism is:
[0035]
[0036] In the formula, θ local (I local ) is the weight of the local feature, θ global (I local ) is the weight of the global feature, θ local (I local ) + θ global (I global ) = 1, Is a weighted fusion operation, Var local Is the mean of the local feature, Var global Is the mean of the global feature;
[0037] The specific calculation formula of the weight θ local (I local ) of the local feature is:
[0038]
[0039] In the formula, Sig is the Sigmoid function, I global (p, q) is the feature I globalFeature at (p, q);
[0040] The weight θ of the global feature global (I global ) The specific calculation formula is:
[0041]
[0042] In the formula, is the global structure similarity.
[0043] Preferably, in step S4, by dynamically adjusting the weights of the global context information and local details of the welding image, the attention to local details and global information can be flexibly strengthened according to the requirements of different image contents; by adaptively adjusting the fusion ratio of local features and global features, the model's ability to understand complex images is significantly improved, the fusion degree of local details and global information is effectively enhanced, and the feature learning ability is improved; the flexibility and dynamic weighting characteristics of the weighted feedback fusion mechanism enable the model to better balance details and overall information when processing complex welding images and diverse tasks, enhancing the robustness and adaptability of the model.
[0044] Preferably, in step S5, the fused feature I fin output by the weighted feedback fusion mechanism is input to the welding quality detection module. The specific steps of the welding quality detection module are as follows:
[0045] S51. Adaptive boundary judgment to locate the welding area. The adaptive boundary judgment enhances and amplifies the edge part of the welding area through the boundary area, and ensures that the sensitivity of boundary prediction can adaptively change through the adaptive boundary threshold. The adaptive boundary B boundary The specific calculation formula is:
[0046]
[0047] In the formula, B en is the boundary area enhancement feature, B ad is the adaptive boundary threshold, and α B is the sensitivity parameter;
[0048] The boundary area enhancement feature B en The specific calculation formula is:
[0049]
[0050] In the formula, is the gradient value in the horizontal direction, is the gradient value in the vertical direction, tanh is the hyperbolic tangent function, and β B is the control gradient's influence degree on boundary enhancement;
[0051] The adaptive boundary threshold B ad The specific calculation formula is as follows:
[0052]
[0053] In the formula, 0.3 is the global reference threshold, ||I curr || 2 is the L2 norm of the current region feature, ||I fin || 2 is the L2 norm of the whole image feature, γ B is the parameter for adjusting the dynamic response of the threshold, exp is the exponential function; S52. Input the welding area feature I bound into the cascade classifier. The cascade classifier is divided into two stages: the welding quality grading stage and the fine-grained classification branch stage. The welding quality grading determines the welding quality through the welding quality scoring function S x The welding images for which the welding quality scoring function does not exceed the set threshold are qualified, and those that exceed the set threshold are unqualified. Then, the fine-grained classification branch is introduced to judge the size and shape of the weld and to make a detailed classification of the welding quality. Qualified welding images can be subdivided into three quality levels: excellent, good, and average. Unqualified ones are marked with the defect type and severity. The welding quality determination formula is as follows:
[0054]
[0055] In the formula, S x is the welding quality scoring function, δ s is the welding quality threshold, and the welding quality threshold is dynamically adjusted according to the welding scenario; The welding quality scoring function S x The specific calculation formula is as follows:
[0056]
[0057] In the formula, Z is the number of welding area features, μ x and ρ x are non-linear mapping functions, f z1 (I bound ) is the information on the defect area, weld flatness, and texture feature of the z1-th feature in the welding area, g z2 (I bound ) is the information on the geometric shape and color contrast of the z2-th feature in the welding area.
[0058] Preferably, in step S5, an adaptive boundary judgment is used to improve the traditional boundary positioning method. According to different defect areas and weld bead morphologies in the welding image, the boundary prediction is dynamically adjusted, which can accurately locate the welding area and avoid the positioning deviation caused by the irregularity of the welding area in the traditional method; the cascade classifier improves the recognition ability of complex welding quality images through layer-by-layer refined judgment. First, it judges whether the welding is qualified, and then further grades the quality according to the qualification, reducing the unnecessary calculation burden, improving the processing efficiency of the model while ensuring the accuracy. At the same time, the refined defect annotation and quality grading provide important data support for intelligent manufacturing and automatic control.
[0059] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0060] The technical solution provided by the present invention is to design an information elastic convolution layer to improve the ability to capture local complex details through a dynamic receptive field and an adaptive convolution control block; design a cross-window attention mechanism to calculate the attention between windows through dynamic window division and information interaction between windows to improve the ability to understand global context information; improve the flexibility and fusion degree of the feature fusion process through a weighted feedback fusion mechanism to improve the welding image feature learning ability; construct a welding quality detection module to locate the welding area through adaptive boundary positioning and propose a cascade classifier to improve the ability of welding quality detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] Figure 1 is a flowchart of a welding quality detection method based on deep learning provided by the present invention.
[0062] Figure 2 is a structural diagram of a welding quality detection module provided by the present invention.
[0063] Figure 3 is an architecture diagram of a welding quality detection model provided by the present invention.
[0064] Figure 4 is an effect diagram of welding quality detection provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0065] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the drawings of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.
[0066] Please refer to Figures 1 to 4, the present invention provides a welding quality detection method based on deep learning, which dynamically fuses local features extracted based on an information elastic convolution layer and global features extracted based on a cross-window attention mechanism through a weighted feedback fusion mechanism, adaptively locates the welding area through a welding quality detection module, and determines whether the welding quality is qualified by detecting the welding area and makes a detailed classification of the welding quality.
[0067] Please refer to Figure 1 as shown, a welding quality detection method based on deep learning in an embodiment of the present application.
[0068] S1. Collect qualified and defective welding images to make a welding quality detection image dataset.
[0069] Furthermore, collect welding images at different angles, different distances, and different welding processes. The welding images include 500 qualified welding images and 1500 defective welding images. The types of welding defects include pores, cracks, incomplete penetration, spatter, and uneven weld seams, with 300 images of each type of welding defect. The qualified welding images are divided into three grades: excellent, good, and average, with 100 excellent images, 200 good images, and 200 average images. Label each image, mark the bounding box of the welding area. For unqualified welding images, label the defect type and severity, and for qualified welding images, label the welding quality grade.
[0070] S2. Design an information elastic convolution layer, use a dynamic receptive field to improve the fixed receptive field of the traditional convolution layer, and optimize the convolution operation's ability to capture local complex details through an adaptive convolution control block.
[0071] Furthermore, the information elastic convolution layer includes a dynamic receptive field and an adaptive convolution control block. The specific steps of the information elastic convolution layer are as follows.
[0072] S21. Input the first welding image feature X ∈ R H×W×C , where H, W, and C are the height, width, and channels of the first welding image, which are 490, 340, and 3 respectively. The specific calculation formula for the elastic convolution operation is:
[0073]
[0074] In the formula, Y (h,w) is the elastic convolution at (h, w), h ∈ [0, 490], w ∈ [0, 340], S(h, w) is the dynamic receptive field at (h, w), X (h+k,w+l) is the feature at (h + k, w + l) in the first welding image feature, and W(h, w) is the adaptive convolution control block at (h, w).
[0075] S22. The dynamic receptive field measures the range of the receptive field through locally varying gradient information. The specific calculation formula for the dynamic receptive field S(h, w) is as follows:
[0076]
[0077] In the formula, r is the maximum radius of the receptive field, is the gradient value at (h + p, w + q) in the first welding image feature. S23. The adaptive convolution control block dynamically adjusts the operations of different convolutional layers through local gradient changes. The specific calculation formula for the adaptive convolution control block W(h, w) is as follows:
[0078]
[0079] In the formula, μ W is the local mean within the dynamic receptive field, is the gradient value in the horizontal direction, is the gradient value in the vertical direction. S3. Design a cross-window attention mechanism to calculate the attention between windows. First, dynamically adjust the size of the window through dynamic window partitioning, and then introduce information interaction between windows to improve the limitation that information cannot be interacted between windows in the traditional window self-attention mechanism. Further, the cross-window attention mechanism includes dynamic window partitioning and information interaction between windows. The specific steps are as follows.
[0080] S31. In dynamic window partitioning, first divide the welding image into 1666 windows, and then dynamically adjust the size of each window through the fusion of weighted gradients and surrounding region information. The specific calculation formula for the window size is as follows:
[0081]
[0082] In the formula, M m is the window size of region m, m ∈ [1, 1666], is the gradient value of region m, X m is the feature vector of region m, measures the feature difference between region m and its surrounding regions.
[0083] S32. Information interaction between windows updates the query and key of the window by measuring the similarity between different windows. The specific calculation formulas for updating the query and key are as follows:
[0084]
[0085] In the formula, Q m is the query vector of window M m , is the updated query vector of window M m , K mFor window M m is the key vector of For window M m The updated key vector, ΔQ mn For window M m and window M n The difference value of, window M n For window M m The adjacent window of Is the accumulation of the differences between windows;
[0086] The window difference value ΔQ mn The specific calculation formula is:
[0087]
[0088] In the formula, Q n Is the query vector of the adjacent window M n of For window M m The difference from the query vectors of the surrounding windows.
[0089] S33. Through window M m and the adjacent window M n The updated query and key are used to calculate the cross-window attention A m of window M n and window M mn The specific calculation formula of the cross-window attention is:
[0090]
[0091] In the formula, Is the updated query vector of window M n of For window M n The updated key vector of Is the weighted fusion operation, and Is the distance metric term.
[0092] S4. Design a weighted feedback fusion mechanism to improve the flexibility and fusion degree of the feature fusion process. The weighted feedback fusion mechanism measures the weight of the global context information through the inter-block information difference, determines the weight of the local features based on the texture changes in the local area, and fuses the global context information and the local features with weights.
[0093] Furthermore, use an information elastic convolution layer to extract the local features I local of the welding image, and use the cross-window attention mechanism to capture the global context information I global, the weighted feedback fusion mechanism dynamically adjusts local features and global context information through the feedback mechanism, and then performs weighted fusion to obtain the fusion feature I fin , the mathematical model of the weighted feedback fusion mechanism is as follows:
[0094] In the formula, θ local (I local ) is the weight of the local feature, and its value range is [0.2, 0.8]. θ global (I global ) is the weight of the global feature, and its value range is [0.2, 0.8]. θ local (I local ) + θ global (I global ) = 1, is the weighted fusion operation, Var local is the mean value of the local feature, and Var global is the mean value of the global feature;
[0095] The specific calculation formula of the weight θ local (I local ) of the local feature is as follows:
[0096]
[0097] In the formula, Sig is the Sigmoid function, and I global (p, q) is the feature of the feature I global at (p, q);
[0098] The specific calculation formula of the weight θ global (I global ) of the global feature is as follows:
[0099]
[0100] In the formula, is the global structural similarity.
[0101] S5. Construct a welding quality detection module, perform boundary prediction through adaptive boundary judgment, locate the welding area, design a cascade classifier, determine whether the welding is qualified through a welding quality scoring function, and then introduce a fine-grained classification branch to divide the welding quality in detail, the qualified sub-quality levels, and label the defect types and severity for the unqualified ones.
[0102] Furthermore, as Figure 2 shown, input the fusion feature I fin output by the weighted feedback fusion mechanism into the welding quality detection module, and the specific steps of the welding quality detection module are as follows.
[0103] S51. Adaptive boundary judgment to locate the welding area. The adaptive boundary judgment enhances and amplifies the edge part of the welding area through the boundary area, and ensures that the sensitivity of boundary prediction can adaptively change through the adaptive boundary threshold. The adaptive boundary B boundary The specific calculation formula is:
[0104]
[0105] In the formula, B en is the boundary area enhancement feature, B ad is the adaptive boundary threshold, α B is the sensitivity parameter, with the initial value set to 0.01 and the value range being [0.01, 1];
[0106] The boundary area enhancement feature B en The specific calculation formula is:
[0107]
[0108] In the formula, is the gradient value in the horizontal direction, is the gradient value in the vertical direction, tanh is the hyperbolic tangent function, and β B is the parameter controlling the influence of the gradient on boundary enhancement, with the initial value set to 1 and the value range being [1, 10];
[0109] The adaptive boundary threshold B ad The specific calculation formula is:
[0110]
[0111] In the formula, 0.3 is the global reference threshold, ||I curr || 2 is the L2 norm of the current region feature, ||I fin || 2 is the L2 norm of the full-image feature, and γ B is the parameter for adjusting the dynamic response of the threshold, with the initial value set to 0.1 and the value range being [0.1, 1], exp is the exponential function.
[0112] S52. Input the welding area feature I bound into the cascade classifier. The cascade classifier is divided into two stages: the welding quality grading and the fine-grained classification branch. The welding quality grading is through the welding quality scoring function S xDetermine the welding quality. The welding images for which the welding quality scoring function does not exceed the set threshold are qualified, and those that exceed the set threshold are unqualified. Then, a fine-grained classification branch is introduced to judge the size and shape of the welds, and the welding quality is detailedly classified. Qualified welding images can be subdivided into three quality levels: excellent, good, and average. For unqualified ones, the defect type and severity are marked. The welding quality determination formula is as follows:
[0113]
[0114] In the formula, S x is the welding quality scoring function, and δ s is the welding quality threshold, with an initial value set to 0.4 and a value range of [0.4, 0.6]. The welding quality threshold is dynamically adjusted according to the welding scenario;
[0115] The welding quality scoring function S x has the following specific calculation formula:
[0116]
[0117] In the formula, Z is the number of welding area features, μ x and ρ x are non-linear mapping functions, f z1 (I bound ) is the information on the defect area, weld flatness, and texture features of the z1-th feature in the welding area, and g z2 (I bound ) is the information on the geometric shape and color contrast of the z2-th feature in the welding area.
[0118] S6. Build a welding quality detection model. The model includes an information elastic convolution layer, a cross-window attention mechanism, a weighted feedback fusion mechanism, and a welding quality detection module. Input the welding image into the welding quality detection model to obtain the welding quality detection result. Further, as Figure 3 shown, input the welding quality detection image into the welding quality detection model. First, use the information elastic convolution layer and the cross-window attention mechanism to extract the local features and global information of the welding quality detection image respectively. Then, adaptively adjust the fusion ratio of the local features and the global features through the weighted feedback fusion mechanism and fuse the local features and the global features. Finally, obtain the welding quality detection result through the welding quality detection module; The welding quality detection model is developed using the Python language through the Pycharm application program and is implemented based on the Pytorch framework. Divide 2000 welding image datasets into a training dataset and a test dataset, with 1400 in the training dataset and 600 in the test dataset. Use 1400 training sets to train the welding quality detection model and test it with 600 test datasets.
[0119] Furthermore, as Figure 4 shown, the figure is an unqualified welding image with a weld unevenness defect type and a medium severity defect.
[0120] The above are only the preferred embodiments of the present invention. It should be noted that for those of ordinary skill in the art, without departing from the inventive concept of the present invention, several variations and improvements can be made, and these all belong to the protection scope of the present invention.
Claims
1. A welding quality detection method based on deep learning, characterized in that: The following steps are involved: S1. Collect qualified and defective welding images to create a welding quality inspection image dataset; S2. Design an information elastic convolution layer, use dynamic receptive field to improve the fixed receptive field of the traditional convolution layer, and optimize the convolution operation's ability to capture local complex details through adaptive convolution control blocks; S3. Design a cross-window attention mechanism to calculate the attention between windows. First, dynamically adjust the window size through dynamic window division, and then introduce information interaction between windows to improve the limitation of the traditional window self-attention mechanism that information between windows cannot interact. S4. Design a weighted feedback fusion mechanism to improve the flexibility and fusion degree of the feature fusion process. The weighted feedback fusion mechanism measures the weight of the global context information by the difference of information between blocks, determines the weight of the local feature by the texture change of the local area, and weightedly fuses the global context information and the local feature. S5. Construct a welding quality inspection module, perform boundary prediction through adaptive boundary judgment, locate the welding area, design a cascade classifier, and determine whether the welding is qualified through the welding quality scoring function. Then, introduce a fine-grained classification branch to divide the welding quality in detail, subdivide the quality level of qualified ones, and mark the defect type and severity of unqualified ones; S6. Construct a welding quality detection model, which includes an information elastic convolution layer, a cross-window attention mechanism, a weighted feedback fusion mechanism and a welding quality detection module. Input the welding image into the welding quality detection model to obtain the welding quality detection result.
2. The welding quality detection method based on deep learning according to claim 1 is characterized in that: In the step S1, welding images of different angles, distances and welding processes are collected. The welding images include qualified welding images and defective welding images. The types of welding defects include pores, cracks, incomplete penetration, spatter and uneven welds. Qualified welding images are divided into three levels: excellent, good and general. Each image is annotated with a boundary box of the welding area. For unqualified welding images, the defect type and severity are annotated. For qualified welding images, the welding quality grade is annotated.
3. The welding quality detection method based on deep learning according to claim 2 is characterized in that: In the step S2, the information elastic convolution layer includes a dynamic receptive field and an adaptive convolution control block. The specific steps of the information elastic convolution layer are: S21, input the first welding image feature X∈R H×W×C , H, W and C are the height, width and channel of the first welding image respectively, and the specific calculation formula of the elastic convolution operation is: Where Y (h,w) is the elastic convolution at (h, w), h∈[0,H], w∈[0,W], S(h,w) is the dynamic receptive field at (h,w), X (h+k,w+l) is the feature of (h+k, w+l) in the first welding image feature, W(h, w) is the adaptive convolution control block at (h, w); S22, dynamic receptive field measures the range of the receptive field by using the local gradient information. The specific calculation formula of the dynamic receptive field S(h, w) is: In the formula, r is the maximum radius of the receptive field, is the gradient value at (h+p, w+q) in the first welding image feature; S23, the adaptive convolution control block dynamically adjusts the operation of different convolution layers through local gradient changes. The specific calculation formula of the adaptive convolution control block W (h, w) is: In the formula, μ W is the local mean within the dynamic receptive field, is the gradient value in the horizontal direction, is the vertical gradient value.
4. The welding quality detection method based on deep learning according to claim 3 is characterized in that: In the S3 step, the cross-window attention mechanism includes dynamic window division and information interaction between windows. The specific steps are: S31, dynamic window division First, the welding image is divided into N windows, and then the size of each window is dynamically adjusted by fusing the weighted gradient and the surrounding area information. The specific calculation formula of the window size is: Where M m is the window size of region m, m∈[1,N], is the gradient value of region m, X m is the eigenvector of region m, To measure the feature difference between region m and the surrounding areas; S32, information interaction between windows: measure the similarity between different windows by the difference between windows, and update the query and key of the window. The specific calculation formula for the query and key update is: In the formula, Q m For window M m The query vector is For window M m The updated query vector, K m For window M m The key vector of For window M m Updated key vector, ΔQ mn For window M m and window M n The difference value of window M n For window M m The adjacent window of is the accumulation of differences between windows; The window difference value ΔQ mn The specific calculation formula is: In the formula, Q n is the adjacent window M n The query vector is For window M m The difference with the surrounding window query vector; S33, through window M m and adjacent window M n Updated query and key calculation window M m and window M n Cross-window attention A mn , the specific calculation formula of the cross-window attention is: In the formula, For window M n The updated query vector, For window M n The updated key vector, is a weighted fusion operation, and is a distance measure.
5. A welding quality detection method based on deep learning according to claim 4, characterized in that: In the step S4, the information elastic convolution layer is used to extract the local features I of the welding image. local , using a cross-window attention mechanism to capture the global context information of welding images global The weighted feedback fusion mechanism dynamically adjusts the local features and global context information through the feedback mechanism, and then weightedly fuses them to obtain the fusion feature I fin , the mathematical model of the weighted feedback fusion mechanism is: In the formula, θ local (I local ) is the weight of the local feature, θ global (I global ) is the weight of the global feature, θ local (l local )+θ global (I global )=1, For weighted fusion operation, Var local is the mean of the local features, Var global is the mean of the global features; The weight θ of the local feature local (I local ) is calculated as follows: Where Sig is the Sigmoid function, I global (p, q) is feature I global Features at (p, q); The weight θ of the global feature global (I global ) is calculated as follows: In the formula, is the global structural similarity.
6. A welding quality detection method based on deep learning according to claim 5, characterized in that: In the step S5, the fusion feature I output by the weighted feedback fusion mechanism is input fin To the welding quality detection module, the specific steps of the welding quality detection module are: S51, adaptive boundary judgment locates the welding area, the adaptive boundary judgment amplifies the edge of the welding area by enhancing the boundary area, ensures that the sensitivity of the boundary prediction can be adaptively changed by an adaptive boundary threshold, and the adaptive boundary B boundary The specific calculation formula is: In the formula, B en To enhance the features of the boundary area, B ad is the adaptive boundary threshold, α B is the sensitivity parameter; The boundary region enhancement feature B en The specific calculation formula is: In the formula, is the gradient value in the horizontal direction, is the vertical gradient value, tanh is the hyperbolic tangent function, β B To control the influence of gradient on boundary enhancement; The adaptive boundary threshold B ad The specific calculation formula is: In the formula, 0.3 is the global benchmark threshold, ||I curr || 2 is the L2 norm of the current region feature, ||I fin || 2 is the L2 norm of the full image feature, γ B To adjust the parameters of the threshold dynamic response, exp is an exponential function; S52, input welding area characteristics I bound To the cascade classifier, the cascade classifier is divided into two stages: welding quality classification and fine-grained classification branch. The welding quality classification is based on the welding quality scoring function S x To determine the welding quality, the welding image whose welding quality scoring function does not exceed the set threshold is qualified, and the welding image whose welding quality exceeds the set threshold is unqualified. Then, a fine-grained classification branch is introduced to determine the size and shape of the welding, and the welding quality is divided in detail. The qualified welding image can be subdivided into three quality levels: excellent, good, and general. The unqualified ones are marked with the defect type and severity. The welding quality determination formula is: In the formula, S x is the welding quality scoring function, δ s is the welding quality threshold, which is dynamically adjusted according to the welding scenario; The welding quality scoring function S x The specific calculation formula is: Where Z is the number of weld area features, μ x and ρ x is a nonlinear mapping function, f z1 (I bound ) is the information of defect area, weld flatness and texture characteristics of the z1th feature in the welding area, g z2 (I bound ) is the information of the geometric shape and color contrast of the z2th feature in the welding area.