A welding defect detection method and system based on visual hybrid attention mechanism

Through the welding defect detection method of visual hybrid attention mechanism, a multi-head self-attention and position attention module is used to build a hybrid attention feature pyramid network, solving the problems of low accuracy and high cost in welding defect detection, and achieving efficient and accurate welding defect recognition.

CN120259280BActive Publication Date: 2025-08-15NINGDE SKEQI INTELLIGENT EQUIP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510716942.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-30
Publication Date
2025-08-15
Estimated Expiration
2045-05-30

AI Technical Summary

Technical Problem

Existing computer vision and deep learning solutions have problems such as poor generalization, low detection accuracy, real-time crossover and high computing costs in welding defect detection, especially for small defects and low-resolution images.

Method used

Welding defect detection method based on visual hybrid attention mechanism is adopted, and by designing multi-head self-attention and position attention modules, the scope of feature utilization is enhanced, and a hybrid attention feature pyramid network architecture is constructed, and a self-attention and coordinate attention mechanism is combined to optimize feature extraction and detection.

Benefits of technology

It improves the identification accuracy and generalization ability of welding defect detection, solves the problems of feature loss and location information loss in traditional DNN solutions, and reduces the inconsistency of manual standards and calculation costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120259280B_ABST
    Figure CN120259280B_ABST
Patent Text Reader

Abstract

The present invention relates to the field of computer vision technology and discloses a welding defect detection method and system based on a visual hybrid attention mechanism. First, an industrial camera captures an image of the weld point of the object to be inspected, which is input at a fixed resolution. The input image is then passed to a feature extraction layer for feature extraction. The input image is set to x, and the feature map output by the feature extraction layer is optimized. The optimized feature map is then passed to the output layer for target detection. This invention enhances the model's ability to perceive context, increases the scope of feature utilization, and makes the model more robust, effectively targeting different types of welding defects. With the help of the attention mechanism, the problems of feature loss and position information transmission loss in traditional DNN solutions are resolved, as well as the low detection rate of subtle defects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision technology, and in particular to a welding defect detection method and system based on a visual hybrid attention mechanism. Background Art

[0002] Traditional manual welding defect detection is no longer suitable for modern high-efficiency smart factories due to low efficiency, inconsistent assessments, high costs, and lack of real-time data. It is gradually being replaced by automated detection based on computer vision.

[0003] Computer vision-based detection solutions have advantages such as real-time, continuous, and non-contact performance, making them the mainstream in industrial scenarios such as solder joint defect detection. However, existing computer vision and deep learning-based defect detection solutions have the following problems:

[0004] First, some solutions rely on manually extracted rules, which do not generalize well to different industrial parts and require expert prior knowledge;

[0005] Second, some solutions based on deep neural networks (DNNs) have good real-time performance and fast detection speed, but they are not effective for parts with small defect areas and low-resolution images.

[0006] 3. Some solutions based on YOLO (You Only Look Once) and multi-layer DNN models have improved accuracy, but they suffer from real-time interference and lose some features, making it difficult to cover high-precision scenarios.

[0007] To meet the needs of more efficient manufacturing, a smarter new solution is needed to address the low accuracy, high error detection rate, and computational cost of solder joint defect detection in surface mount technology in industrial scenarios.

[0008] Therefore, to address the above problems, a welding defect detection method and system based on visual hybrid attention mechanism is needed. Summary of the Invention

[0009] The present invention aims to provide a welding defect detection method and system based on a visual hybrid attention mechanism. This method enhances the model's ability to perceive context, increases the range of feature utilization, and makes the model more robust, effectively targeting different types of welding defects. The attention mechanism overcomes the issues of feature loss and position information loss in traditional DNN solutions, addressing the low detection rate of subtle defects.

[0010] The present invention is achieved in that:

[0011] The present invention provides a welding defect detection method based on a visual hybrid attention mechanism, which is specifically performed in the following steps:

[0012] S1: For the object to be inspected, an industrial camera captures an image of the solder joint and inputs it at a fixed resolution; the fixed resolution is 1280x1280 pixels or 1920x1280 pixels;

[0013] S2: The input image is passed to the feature extraction layer for feature extraction. Suppose the input image is , as shown in formula (1);

[0014] Formula (1);

[0015] Among them, the size is H×W×C ,in H is the height, W is the width, C is the number of channels;

[0016] Follow these steps:

[0017] S2.1: The input image is first subjected to a series of convolution and normalization operations to extract primary features of the image, including edges and textures, and then pyramid pooling is performed to integrate the features.

[0018] S2.2: The input image passes through a convolutional layer, which consists of multiple learnable filter convolution kernels. The filter is slid across the image, and the dot product between the filter and the local area of the image is calculated to output a feature map, as shown in Equation (2).

[0019] Formula (2);

[0020] in Represents the input image, the original image or the output of the previous layer, with a size of H×W×C. k represents the convolution kernel matrix, obtained by model training. The model is the HAFPN feature pyramid extraction module, with a size of k×k×C. b represents the bias term, which is a constant value added to the result of the convolution operation, with a size of 1×1×m. * represents the convolution calculation.

[0021] Model training is performed in the following steps:

[0022] S2.2.1: First, perform positioning: align the upper left corner of the convolution kernel with the upper left corner of the input image;

[0023] S2.2.2: Then calculate the dot product between the convolution kernel and the local area of the input image;

[0024] S2.2.3: Then slide the convolution kernel one pixel to the right and repeat the dot product calculation until it reaches the end of the current row;

[0025] S2.2.4: Move the convolution kernel to the beginning of the next row and repeat steps S2.2.2 and S2.2.3 until the entire input image is covered;

[0026] S2.2.5: Get the result of the last dot product and finally output a new feature map through the convolution operation.

[0027] S2.3: Perform normalization processing, and follow the convolution layer with a batch normalization layer to stabilize training and accelerate convergence, as shown in formula (3);

[0028] Formula (3);

[0029] in x’ represents the output of the current layer, represents the mean value of the current layer output, σ represents the variance of the current layer output, , to prevent division by zero;

[0030] S2.4: The normalized feature map is activated by SiLu function to introduce nonlinearity, as shown in Equation (4).

[0031] Formula (4);

[0032] in, represents the input image;

[0033] S2.5: Use the C3 convolutional layer of the CSP structure to further extract features, as shown in formula (5);

[0034] Formula (5);

[0035] in, Represents the input image, CSP(x) is the feature map after Cross Stage Partial structure processing;

[0036] S2.6: Perform pyramid pooling to integrate feature information of different scales, reduce the size of the feature map, and reduce the amount of subsequent calculations, as shown in Equation (6);

[0037] Formula (6);

[0038] in, Represents the input image, pool(x, k) represents the use of pooling kernels of different sizes k right Perform pooling operation. Continue to perform pooling operation, in the input image A fixed-size window is slided up and the maximum value in each window is selected as the output.

[0039] S3: Optimize the feature map output by the feature extraction layer; specifically, perform the following steps:

[0040] S3.1: The feature map is processed by depthwise separable convolution DWConv and layer normalization LN, and then further optimized by enhanced multi-head self-attention EMSA and coordinate attention CA mechanisms;

[0041] Through multi-head self-attention, the global context information is captured through multi-scale and multi-head self-attention mechanisms, and the expressive power of features is enhanced, as shown in Equation (7);

[0042] Formula (7);

[0043] Among them, X input represents the input features, X output represents the output feature, X m and X n represents the intermediate features, Q, K, and V represent the query matrix, key matrix, and value matrix, respectively. Linear is the linear transformation operation, SiLU is the Linaer activation function, FC represents full connection, and d is the scalar factor.

[0044] S3.2: Perform feature fusion. The feature map processed by the hybrid attention mechanism is fused through the multi-layer perceptron layer MLP to obtain the optimized feature map.

[0045] The feature maps processed by the hybrid attention mechanism are fused through the multi-layer perceptron layer MLP to obtain the optimized feature maps; first, the input features are parameter shared through the depth-wise separable convolution residual block and the learning ability of local features is enhanced, and then processed using the normalization layer. The output is processed by the multi-head attention mechanism and the coordinate attention mechanism respectively, normalized by LN, and finally obtained through the multi-layer perceptron layer.

[0046] S4: Import the optimized feature map into the output layer and output the result, as shown in formula (8);

[0047] Formula (8);

[0048] Among them, X input represents the input features, X output represents the output features, X m 、 Xn and X q is the intermediate feature, DWconv represents depthwise separable convolution, LN represents normalization, CA represents coordinate attention mechanism, EMSA represents enhanced multi-head self-attention mechanism, and MLP represents multi-layer perceptron.

[0049] For target detection, firstly after feature optimization, the feature map is obtained F : H x W x D, where H and W is the height and width of the feature map, C is the number of channels, based on which the defect bounding box can be obtained; where:

[0050] Center point x: ;

[0051] Center point y: ;

[0052] Width w: ;

[0053] Height h: ;

[0054] Where σ is the sigmoid function, W and H are the width and height of the feature map respectively, e x and e y is the coordinate offset, the offset of the predicted feature map coordinates compared to the original input size, P w and P h are the predefined width and height, which can be defined as the mean value of the defect size in the scenario described in the present invention. and is the offset used to convert the predicted value to the actual size;

[0055] Then calculate the defect probability; the output feature map of the fully connected layer is defined as f, and the defect probability can be obtained through the sofxtmax layer, as shown in formula (9);

[0056] Formula (9);

[0057] Where K is the total number of defect categories, which is 2 when only detecting presence or absence. P is the probability distribution of each category, and the category with the largest corresponding value is taken as the result.

[0058] Furthermore, the present invention provides a welding defect detection system based on a visual hybrid attention mechanism, comprising a data input module for receiving a welding spot image captured by an industrial camera;

[0059] Feature extraction module, used to extract features from input images through convolution and normalization;

[0060] The feature optimization module is used to import the feature map output by the feature extraction module into the feature optimization module:

[0061] The output module is used to import the optimized feature map into the output module, perform target detection, and output defect probability results.

[0062] Furthermore, the present invention provides a computer-storable medium, which includes an embedded processing system and a stored program, and when the embedded system control program is running, controls the flow disturbance generation method based on packet feature inversion to execute any one of the above-mentioned welding defect detection methods based on visual hybrid attention mechanism.

[0063] Compared with the prior art, the present invention has the following beneficial effects:

[0064] 1. By designing a multi-head self-attention module and a position-attention module, the network's feature utilization range is enhanced and the model's computational speed is accelerated. Building on these modules, a hybrid attention mechanism (HAM) module is designed to improve the learning of local features. Furthermore, a hybrid attention feature pyramid network (HAFPN) module is constructed to enhance the FPN's ability to perceive contextual information and address the accuracy degradation caused by positional information loss. Finally, based on the HAFPN module, a feature detection system based on the visual hybrid attention mechanism is implemented. This system improves the recognition accuracy of welding defect detection in industrial applications while maintaining detection speed. Furthermore, this system's solution based on the visual hybrid attention mechanism reduces the problem of inconsistent manual standards and high labor costs.

[0065] 2. The proposed solution, based on a hybrid attention mechanism, enhances the model's contextual awareness and widens the range of feature utilization, making the model more robust and effective at detecting different types of welding defects. This attention mechanism overcomes the issues of feature loss and position information loss in traditional DNN solutions, addressing the low detection rate of subtle defects.

[0066] 3. By combining the self-attention mechanism with the coordinate attention mechanism, we designed a hybrid attention network, which addresses the feature loss problem encountered by traditional deep neural networks in industrial defect detection. Applying the hybrid attention mechanism to the YOLO detection model solves the problem of low accuracy in detecting subtle defects and improves the model's generalization capabilities.

[0067] 4. The hybrid attention mechanism designed in this invention enhances the network's ability to perceive long-distance position information and learn local features, thereby improving recognition generalization and accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0068] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following is a brief introduction to the drawings required for use in the embodiments. It is understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without creative work.

[0069] Figure 1 is a flow chart of the method of the present invention;

[0070] Figure 2 It is a system structure diagram of the present invention;

[0071] Figure 3 It is a system structure flow chart of the present invention. DETAILED DESCRIPTION

[0072] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the invention for which protection is sought, but is merely for selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.

[0073] See also Figure 1-Figure 3 The present invention provides a welding defect detection method based on a visual hybrid attention mechanism, which is specifically performed in the following steps:

[0074] S1: For the object to be inspected, an industrial camera captures an image of the solder joint and inputs it at a fixed resolution; the fixed resolution is 1280x1280 pixels or 1920x1280 pixels;

[0075] S2: The input image is passed to the feature extraction layer for feature extraction. Suppose the input image is , as shown in formula (1);

[0076] Formula (1);

[0077] Among them, the size is H×W×C ,in H is the height, Wis the width, C is the number of channels;

[0078] Follow these steps:

[0079] S2.1: The input image is first subjected to a series of convolution and normalization operations to extract primary features of the image, including edges and textures, and then pyramid pooling is performed to integrate the features.

[0080] S2.2: The input image passes through a convolutional layer, which consists of multiple learnable filter convolution kernels. The filter is slid across the image, and the dot product between the filter and the local area of the image is calculated to output a feature map, as shown in Equation (2).

[0081] Formula (2);

[0082] in Represents the input image matrix, the original image or the output of the previous layer, with a size of H×W×C. k represents the convolution kernel matrix, obtained by model training. The model is the HAFPN feature pyramid extraction module, with a size of k×k×C. b represents the bias term, which is a constant value added to the result of the convolution operation, with a size of 1×1×m. * represents the convolution calculation.

[0083] Model training is performed in the following steps:

[0084] S2.2.1: First, perform positioning: align the upper left corner of the convolution kernel with the upper left corner of the input image;

[0085] S2.2.2: Then calculate the dot product between the convolution kernel and the local area of the input image;

[0086] S2.2.3: Then slide the convolution kernel one pixel to the right and repeat the dot product calculation until it reaches the end of the current row;

[0087] S2.2.4: Move the convolution kernel to the beginning of the next row and repeat steps S2.2.2 and S2.2.3 until the entire input image is covered;

[0088] S2.2.5: Get the result of the last dot product and finally output a new feature map through the convolution operation.

[0089] S2.3: Perform normalization processing, and follow the convolution layer with a batch normalization layer to stabilize training and accelerate convergence, as shown in formula (3);

[0090] Formula (3);

[0091] in x’ represents the output of the current layer, represents the mean value of the current layer output, σ represents the variance of the current layer output, , to prevent division by zero;

[0092] S2.4: The normalized feature map is activated by SiLu function to introduce nonlinearity, as shown in Equation (4).

[0093] Formula (4);

[0094] in, represents the input image;

[0095] S2.5: Use the C3 convolutional layer of the CSP structure to further extract features, as shown in formula (5);

[0096] Formula (5);

[0097] in, Represents the input image, CSP(x) is the feature map after Cross Stage Partial structure processing;

[0098] S2.6: Perform pyramid pooling to integrate feature information of different scales, reduce the size of the feature map, and reduce the amount of subsequent calculations, as shown in Equation (6);

[0099] Formula (6);

[0100] in, Represents the input image, pool(x, k) represents the use of pooling kernels of different sizes k right Perform pooling operation. Continue to perform pooling operation, in the input image A fixed-size window is slided up and the maximum value in each window is selected as the output.

[0101] S3: Optimize the feature map output by the feature extraction layer; specifically, perform the following steps:

[0102] S3.1: The feature map is processed by depthwise separable convolution DWConv and layer normalization LN, and then further optimized by enhanced multi-head self-attention EMSA and coordinate attention CA mechanisms;

[0103] Through multi-head self-attention, the global context information is captured through multi-scale and multi-head self-attention mechanisms, and the expressive power of features is enhanced, as shown in Equation (7);

[0104] Formula (7);

[0105] in, Xinput represents the input features, X output represents the output features, X m and X n represents the intermediate features, Q, K, and V represent the query matrix, key matrix, and value matrix, respectively. Linear is the linear transformation operation, SiLU is the Linaer activation function, FC represents full connection, and d is the scalar factor.

[0106] First, the original features are linearly transformed through the Q, K, and V components of the fully connected layer. The Q and K matrices are multiplied and then a series of nonlinear transformations are performed. After passing through the fully connected layer, the Silu activation function is input. After passing through the fully connected layer, Tanh is used for processing. The output result is the matrix multiplied by the linearly transformed V component matrix. Finally, the fully connected layer is used to fuse with the original input features to obtain the final output result.

[0107] Compared with the original MSA, EMSA has more nonlinear transformations, which can make the context perception stronger, expand the range of feature utilization of the model network, and make the network more expressive.

[0108] And through coordinate attention, the model's perception of position information is enhanced; first, the image height and width are pooled to obtain the dimension and 1×W×C feature maps, and then the feature maps are connected and reduced in dimension through shared convolution to obtain a dimension of The feature map is then transformed nonlinearly to improve its expressiveness, and then convolution is used to restore the original dimension. Finally, HardSigmoid is used. Compared with SigMoid, HardSigmoid does not require exponentiation, so its calculation speed is faster.

[0109] S3.2: Perform feature fusion. The feature map processed by the hybrid attention mechanism is fused through the multi-layer perceptron layer MLP to obtain the optimized feature map.

[0110] The feature maps processed by the hybrid attention mechanism are fused through the multi-layer perceptron layer MLP to obtain the optimized feature maps. First, the input features are shared through the depthwise separable convolution residual block to enhance the learning ability of local features. Then, the normalization layer is used for processing. The output is processed by the multi-head attention mechanism and the coordinate attention mechanism respectively, and then normalized by LN. Finally, the output result is obtained through the multi-layer perceptron layer, as shown in formula (8).

[0111] Formula (8);

[0112] Among them, X input represents the input features, X output represents the output features, X m 、 X n and X q is the intermediate feature, DWconv represents depthwise separable convolution, LN represents normalization, CA represents coordinate attention mechanism, EMSA represents enhanced multi-head self-attention mechanism, and MLP represents multi-layer perceptron.

[0113] S4: Import the optimized feature map into the output layer for target detection. First, after feature optimization, the feature map is obtained. F : H x W x D, where H and W is the height and width of the feature map, C is the number of channels, based on which the defect bounding box can be obtained; where:

[0114] Center point x: ;

[0115] Center point y: ;

[0116] Width w: ;

[0117] Height h: ;

[0118] Among them, σ is the sigmoid function, W and H are the width and height of the feature map respectively, e x and e y is the coordinate offset, the offset of the predicted feature map coordinates compared to the original input size, p w and p h are the predefined width and height, which can be defined as the mean value of the defect size in the scenario described in the present invention. and is the offset used to convert the predicted value to the actual size;

[0119] Then calculate the defect probability; for the output image of the fully connected layer Defined as f, the defect probability can be obtained through the sofxtmax layer, as shown in formula (9);

[0120] Formula (9);

[0121] Where K is the total number of defect categories, which is 2 when only detecting presence or absence. P is the probability distribution of each category, and the category with the largest corresponding value is taken as the result.

[0122] In this embodiment, the present invention provides a welding defect detection system based on a visual hybrid attention mechanism, comprising a data input module for receiving a welding spot image captured by an industrial camera;

[0123] Feature extraction module, used to extract features from input images through convolution and normalization;

[0124] The feature optimization module is used to import the feature map output by the feature extraction module into the feature optimization module:

[0125] The output module is used to import the optimized feature map into the output module, perform target detection, and output defect probability results.

[0126] The second embodiment provided in this embodiment, the present invention provides a computer-storable medium, the computer-readable storage medium includes an embedded processing system and a stored program, when the embedded system control program is running, the flow disturbance generation method based on packet feature inversion is controlled to execute any one of the above-mentioned welding defect detection methods based on visual hybrid attention mechanism.

[0127] The foregoing description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention are intended to be within the scope of protection of the present invention.

Claims

1. A welding defect detection method based on a visual hybrid attention mechanism, characterized by: Follow these steps: S1: For the object to be inspected, the industrial camera captures the solder joint image with a fixed resolution input; S2: The input image is passed to the feature extraction layer for feature extraction. Suppose the input image is , as shown in formula (1): Formula (1); Among them, the size is H×W×C ,in H is the height, W is the width, C is the number of channels; S3: Perform feature optimization on the feature map output by the feature extraction layer; Follow these steps: S3.1: The feature map is processed by depthwise separable convolution DWConv and layer normalization LN, and then the feature map is optimized by enhanced multi-head self-attention EMSA and coordinate attention CA mechanism; Through multi-head self-attention, the global context information is captured through multi-scale and multi-head self-attention mechanisms, and the expressive power of features is enhanced, as shown in formula (7): Formula (7); in, X input represents the input features, X output represents the output features, X m and X n represents the intermediate features, Q, K and V represent the query matrix, key matrix and value matrix respectively, Linear is the linear transformation operation, SiLU is the activation function of Linaer, FC represents full connection, and d is the scalar factor; S3.2: Perform feature fusion. The feature maps processed by the hybrid attention mechanism are fused through the multi-layer perceptron layer MLP to obtain the optimized feature maps. The feature maps processed by the hybrid attention mechanism are fused through the multi-layer perceptron layer MLP to obtain the optimized feature maps. First, the input features are shared through the depthwise separable convolution residual block to enhance the learning ability of local features. Then, the normalization layer is used for processing. The output is processed by the multi-head attention mechanism and the coordinate attention mechanism respectively, and then normalized by LN. Finally, the output result is obtained through the multi-layer perceptron layer, as shown in formula (8): Formula (8); in, X q is the intermediate feature, DWconv represents depthwise separable convolution, LN represents normalization, CA represents coordinate attention mechanism, EMSA represents enhanced multi-head self-attention mechanism, and MLP represents multi-layer perceptron; S4: Import the optimized feature map into the output layer for target detection.

2. The welding defect detection method based on visual hybrid attention mechanism according to claim 1 is characterized in that: In step S2, the following steps are specifically performed: S2.1: The input image is first subjected to a series of convolution and normalization operations to extract primary features of the image, including edges and textures, and then pyramid pooling is performed to integrate the features. S2.2: The input image passes through the convolution layer, which consists of multiple learnable filter convolution kernels. The filter is slid on the image, and the dot product between the filter and the local area of the image is calculated to output a feature map, as shown in formula (2): Formula (2); in Represents the input image, the original image or the output of the previous layer, with a size of H×W×C. k represents the convolution kernel matrix, obtained by model training. The model is the HAFPN feature pyramid extraction module, with a size of k×k×C. b represents the bias term, which is a constant value added to the result of the convolution operation, with a size of 1×1×m. * represents the convolution calculation. S2.3: Perform normalization processing and follow the convolution layer with a batch normalization layer to stabilize training and accelerate convergence, as shown in formula (3): Formula (3); in x’ represents the output of the current layer, represents the mean value of the current layer output, σ Represents the variance of the current layer output, ϵ=0.001, to prevent division by zero; S2.4: The normalized feature map is activated by the SiLu function to introduce nonlinearity, as shown in formula (4): Formula (4); in, represents the input image; S2.5: Use the C3 convolutional layer of the CSP structure to extract features, as shown in formula (5): Formula (5); Among them, CSP(x) is the feature map after Cross Stage Partial structure processing; S2.6: Perform pyramid pooling to integrate feature information of different scales, reduce the size of the feature map, and reduce the amount of subsequent calculations, as shown in formula (6): Formula (6); in, Represents the input image, pool(x,k) represents the use of pooling kernels of different sizes k right Perform pooling operation.

3. The welding defect detection method based on visual hybrid attention mechanism according to claim 1 is characterized in that: In step S2.2, model training is performed as follows: S2.2.1: First, perform positioning: align the upper left corner of the convolution kernel with the upper left corner of the input image; S2.2.2: Then calculate the dot product between the convolution kernel and the local area of the input image; S2.2.3: Then slide the convolution kernel one pixel to the right and repeat the dot product calculation until it reaches the end of the current row; S2.2.4: Move the convolution kernel to the beginning of the next row and repeat steps S2.2.2 and S2.2.3 until the entire input image is covered; S2.2.5: Get the result of the last dot product and finally output a new feature map through the convolution operation.

4. The welding defect detection method based on visual hybrid attention mechanism according to claim 2 is characterized in that: In step S2.6, the pooling operation is continued. A fixed-size window is slided up and the maximum value in each window is selected as the output.

5. The welding defect detection method based on visual hybrid attention mechanism according to claim 1 is characterized in that: In step S4, after feature optimization, the feature map is obtained. F : H x W x C, where H and W is the height and width of the feature map, C is the number of channels, based on which the defect bounding box is obtained; where: Center point x: ; Center point y: ; Width w: ; Height h: ; Among them, σ is the sigmoid function, W and H are the width and height of the feature map respectively, e x and e y is the coordinate offset, the offset of the predicted feature map coordinates compared to the original input size, p w and p h are predefined width and height, and is the offset used to convert the predicted value to the actual size; Then calculate the defect probability; for the output image of the fully connected layer Defined as , the defect probability is obtained through the sofxtmax layer, as shown in formula (9): Formula (9); in, is the total number of defect categories, which is 2 when only detecting whether there is any defect. is the probability distribution of each category, and the category with the largest corresponding value is taken as the result.

6. A welding defect detection system based on a visual hybrid attention mechanism, configured to execute a welding defect detection method based on a visual hybrid attention mechanism according to any one of claims 1 to 5, characterized in that: A data input module is included for receiving a welding spot image captured by an industrial camera; Feature extraction module, used to extract features from input images through convolution and normalization; The feature optimization module is used to import the feature map output by the feature extraction module into the feature optimization module: The output module is used to input the optimized feature map into the output module, perform target detection, and output defect probability results.

Citation Information

Patent Citations

  • Semantic segmentation method based on feature pyramid attention and mixed attention cascading

    CN112651973A

  • Intelligent machine vision detection method and system based on image processing and storage medium

    CN119205719A