A T-shaped weld defect detection method based on improved YOLO11s
By improving the YOLO11s model, embedding the CA module, replacing it with SIoU loss, and adding a P2 small target detection layer, the problems of easy omission of small targets and blurred local boundaries in T-type weld defect detection are solved, the detection accuracy and recall are improved, and the adaptability and robustness of the model under complex working conditions are enhanced.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- INNER MONGOLIA UNIV OF SCI & TECH
- Filing Date
- 2026-04-30
- Publication Date
- 2026-07-31
AI Technical Summary
Existing technologies for detecting defects in T-type welds suffer from problems such as easy omission of small targets, sensitivity of weld area location, blurred local boundaries, and difficulty in identifying weak class samples, resulting in low detection accuracy and recall, and insufficient adaptability and robustness of the model under complex working conditions.
An improved YOLO11s model is adopted. By embedding the Coordinate Attention (CA) module in the backbone network, replacing the bounding box regression loss with SIoU loss, and adding a P2 small object detection layer in the detection head, a higher resolution shallow feature map is introduced to optimize feature representation and bounding box regression.
It significantly improves the accuracy, recall, and localization precision of T-weld defect detection, enhances the model's adaptability and robustness in complex scenarios, and enables more accurate identification of multi-scale defects.
Smart Images

Figure CN122492593A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the technical field of weld defect detection, and in particular to a method for detecting T-type weld defects based on an improved YOLO11s. Background Technology
[0002] Weld defect detection is a crucial step in welding quality control, and its results directly impact the service safety and engineering reliability of welded structures. T-welds, a common connection type in steel structures, machinery manufacturing, pressure vessels, and engineering equipment, are prone to defects such as incomplete fusion, incomplete penetration, porosity, undercut, spatter, and abnormal weld reinforcement during the forming process. Due to the significant differences in defect size, concentrated distribution areas, and complex local textures, traditional methods relying on manual experience or feature extraction often suffer from low efficiency, poor stability, and high subjectivity in complex scenarios.
[0003] From the development of research on weld visual perception and feature extraction, methods such as structured light stripe center extraction, weld contour recognition, and weld feature point localization based on the improved Steger algorithm have laid the foundation for automatic weld recognition and tracking. However, these methods are usually sensitive to illumination, noise, surface reflection, and manually set features. When faced with complex scenes with multiple types of defects, weak local textures, and blurred boundaries, their generalization ability remains limited.
[0004] In recent years, deep learning-based object detection methods have rapidly developed in the field of industrial defect detection. The YOLO series of models has continuously evolved due to its end-to-end structure and real-time detection advantages, while multi-scale feature fusion and path aggregation have also continuously improved the performance of small object detection. In weld defect detection scenarios, existing research has used models such as YOLOv5, LF-YOLO, TA-YOLOv8, and WELD-DETR for detecting surface anomalies in steel pipe welds, spot welds, and complex industrial welding defects, validating the effectiveness of deep learning in weld detection tasks. However, specialized research on scenarios involving small samples, location sensitivity, and the coexistence of weak targets in T-shaped welds remains relatively insufficient. Summary of the Invention
[0005] The purpose of this invention is to provide a T-type weld defect detection method based on improved YOLO11s, which solves the problems of easy missed detection of small targets, sensitivity of weld area location, blurred local boundaries and difficulty in weak class sample identification in T-type weld defect detection, significantly improves the accuracy, recall and localization accuracy of defect detection, and enhances the adaptability and robustness of the model under complex working conditions.
[0006] To achieve the above objectives, the present invention provides a method for detecting T-type weld defects based on improved YOLO11s, comprising the following steps: S1. Obtain the original image of the T-type weld defect and divide it into training set, validation set and test set; S2. Perform offline data augmentation on the training set to build an expanded training set; S3. Construct an initial detection network based on YOLO11s, and embed a CA module in the main feature extraction line of the backbone network to enable the network to retain the position information in the horizontal and vertical directions on the basis of channel attention. S4. Replace the original bounding box regression loss in the initial detection network with SIoU loss to jointly optimize the predicted box and the ground box in the dimensions of angle, distance and shape. S5. Add a P2 small target detection layer to the detection head to introduce a higher resolution shallow feature map into the multi-scale detection branch, resulting in an improved detection network. S6. Use the extended training set to train the improved detection network in step S5 to obtain the T-type weld defect detection model. S7. Input the image of the T-weld to be detected into the T-weld defect detection model, and output the defect category, confidence level and bounding box position.
[0007] Preferably, in step S2, offline data enhancement includes horizontal flipping, brightness adjustment, contrast adjustment, Gamma transformation, grayscale conversion, Gaussian noise perturbation, and Gaussian blurring.
[0008] Preferably, in step S3, the calculation process of the CA module includes the following steps: S31. Input feature map X Perform one-dimensional global average pooling along the horizontal and vertical directions to obtain height-aggregated features and width-aggregated features, as shown in the formula: ; ; The feature map has dimensions C×H×W, where C, H, and W represent the number of channels, height, and width of the feature map, respectively. and These represent the input feature maps, i.e., the i-th and j-th. Each channel is in coordinates and The response value at that location, Indicates the first Each channel in the vertical direction Aggregation features at the location, Indicates the first Each channel in the width direction Aggregation features at the location; S32. Concatenate the features in the height and width directions, and generate intermediate features through 1×1 convolution, batch normalization (BN), and non-linear activation. The formula is as follows: ; ; in, Indicates feature concatenation operation; This represents a 1×1 convolution transformation; BN Indicates batch normalization; Represents a non-linear activation function; r Indicates the channel compression ratio; d The number of channels representing intermediate features; S33. Split the intermediate features into height and width branches, and generate attention weights in the height and width directions respectively through 1×1 convolution and sigmoid activation, as shown in the formula: ; ; ; in, This indicates that the merged intermediate features are re-decomposed into height and width branches; and These represent 1×1 convolution transformations applied to the height and width branches, respectively. This represents the Sigmoid activation function; and These represent the attention weights generated along the height and width directions, respectively. S34. Apply attention weights to the original features and output the recalibrated features, using the following formula: ; in, Indicates the output feature map of the th Each channel is in coordinates The response value at that location.
[0009] Preferably, in step S4, the calculation of SIoU loss includes the following steps: S41. Construct the prediction box as follows The real frame is The center coordinates of the prediction box are The center coordinates of the true bounding box are The predicted bounding box width and height are respectively and The actual frame width and height are respectively and The width and height of the minimum bounding rectangle are respectively and The Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box is defined as: ; S42. Angle cost is introduced to describe the degree of deviation of the center line of the prediction box relative to the coordinate axis direction. The calculation formula is as follows: ; ; in, For the sake of perspective, This represents the normalized component of the line connecting the center of the predicted bounding box and the center of the ground truth bounding box along the nearest coordinate axis. S43. The distance cost describes the degree of offset between the center of the predicted bounding box and the center of the ground truth bounding box in both the horizontal and vertical directions. The calculation formula is as follows: ; ; ; ; in, Indicates distance cost. and These represent the normalized distances between the center of the predicted bounding box and the center of the ground truth bounding box, respectively, in the horizontal and vertical directions. A modulation factor related to angle cost; S44. Introducing shape cost, the calculation formula is as follows: ; ; ; in, For the cost of shape, and These represent the relative differences in width and height between the predicted bounding box and the ground truth bounding box, respectively. Hyperparameters for adjusting the intensity of shape penalty; S45. The cross-ratio is retained to measure the degree of overlap between the predicted bounding box and the ground truth bounding box. The calculation formula is as follows: ; in, This represents the area of the intersection between the predicted bounding box and the ground truth bounding box. This represents the area of the union of the two sets; S46. Combining the angle cost, distance cost, shape cost, and IoU term, the final SIoU loss is expressed as: .
[0010] Preferably, in step S5, a P2 small target detection layer is added on the basis of the original detection head, introducing a higher resolution shallow feature map to participate in the prediction. While preserving local edge and texture information, it complements the deep semantic features, improves the model's ability to perceive small and weak targets, and forms a four-scale prediction structure with the P3, P4 and P5 detection heads to jointly complete multi-scale defect detection.
[0011] Therefore, the present invention employs the above-described method for detecting T-type weld defects based on improved YOLO11s, which has the following advantages: (1) In this invention, by embedding the Coordinate Attention (CA) module into the YOLO11s backbone network, the model’s ability to characterize key areas and location-sensitive defects of T-welds is significantly enhanced by using coordinate direction encoding and spatial position perception, thereby suppressing background interference and improving the accuracy of defect identification.
[0012] (2) In this invention, the bounding box regression loss is replaced by SIoU loss. By introducing angle cost, distance cost and shape cost to coordinate constraints, the regression path and convergence efficiency of the predicted box are optimized, which greatly improves the positioning accuracy of blurred boundaries and small-scale defects and improves the fitting effect of the detection box.
[0013] (3) In this invention, a new P2 small target detection layer is added to the detection head, and high-resolution shallow features are introduced to participate in multi-scale prediction, which effectively solves the problems of easy to miss small defects in T-type welds and difficulty in identifying weak texture targets, and comprehensively improves the robustness of the model to multi-scale defect detection.
[0014] The technical solution of the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Attached Figure Description
[0015] Figure 1 This is a schematic flowchart of a T-type weld defect detection method based on improved YOLO11s according to the present invention. Figure 2 This is a schematic diagram of the improved YOLO11s algorithm model structure provided in an embodiment of the present invention; Figure 3 This is a visual comparison and analysis diagram of T-shaped weld images with obvious spatter, incomplete penetration, and undercut, provided in an embodiment of the present invention. Figure 3 (a) is an image of an original T-weld with obvious spatter, incomplete penetration, and undercut defects. Figure 3 (b) is the YOLO11s model pair Figure 3 (a) shows the detection results. Figure 3 (c) Improved model for this embodiment Figure 3 (a) shows the detection results; Figure 4 This is a visual comparison analysis diagram of T-shaped weld images with obvious spatter and two types of defects, namely, lack of fusion and spatter, provided in an embodiment of the present invention. Figure 4 (a) is an image of the original T-weld with both incomplete fusion and spatter defects, and the spatter is obvious. Figure 4 (b) is the YOLO11s model pair Figure 4 (a) shows the detection results. Figure 4 (c) Improved model for this embodiment Figure 4 (a) shows the detection results; Figure 5 This is a visual comparison and analysis chart of T-shaped weld images with four types of defects—incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement—provided in an embodiment of the present invention, where the excessive weld reinforcement is particularly noticeable. Figure 5 (a) An image of an original T-weld with four types of defects: incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement, with the excessive weld reinforcement being particularly obvious. Figure 5 (b) is the YOLO11s model pair Figure 5 (a) shows the detection results. Figure 5 (c) Improved model for this embodiment Figure 5 (a) shows the detection results; Figure 6 This is a visual comparison and analysis diagram of T-shaped weld images with obvious spatter and four types of defects: lack of fusion, incomplete penetration, spatter, and excessive weld reinforcement, provided in an embodiment of the present invention. Figure 6 (a) An image of an original T-weld with obvious spatter, exhibiting four types of defects: incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement. Figure 6 (b) is the YOLO11s model pair Figure 6 (a) shows the detection results. Figure 6 (c) Improved model for this embodiment Figure 6 (a) shows the detection results. Detailed Implementation
[0016] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Specific model specifications need to be selected and determined according to the actual specifications of the device, etc. The specific selection calculation method adopts the prior art, and therefore will not be described in detail.
[0017] Example like Figures 1-2 As shown, this invention provides a method for detecting T-type weld defects based on improved YOLO11s, comprising the following steps: S1. Obtain the original image of the T-type weld defect and divide it into training set, validation set and test set.
[0018] S2. Perform offline data augmentation on the training set to build an expanded training set; The original publicly available dataset contains 288 images, with each image potentially containing multiple defect targets. The images are categorized into seven classes: Lof (lack of fusion), Lop (lack of penetration), Gas (surface porosity), Undercut (undercut), Spatter (splash), Convex (excessive weld height), and Good (defect-free weld). The initial statistics show that the number of instances for Lof, Lop, Gas, Undercut, Spatter, Convex, and Good are 168, 231, 111, 30, 676, 187, and 109, respectively. Subsequent experiments focused on detecting six defect targets: lop, lof, spatter, convex, gas, and undercut, and the Good class was no longer included in the main experimental category.
[0019] Considering the small size and unbalanced class distribution of the original dataset, and the significant shortage of weak class samples such as gas, undercut, and some lof, directly using the original training set for training often results in unsatisfactory performance in terms of recall, weak class AP, and strict localization metrics. Therefore, this embodiment implements offline enhancement and expansion of the training set. The offline enhancement methods mainly include horizontal flipping, brightness adjustment, contrast adjustment, Gamma transformation, grayscale conversion, Gaussian noise perturbation, Gaussian blur, and combined enhancements such as "brightness + contrast" and "brightness + Gamma." These enhancements primarily address common factors in weld seam images, such as illumination fluctuations, grayscale changes, imaging noise, and local blurring. This improves the model's adaptability to complex imaging conditions without altering the semantic attributes of the defects. The dataset expansion uses a "total" mode to control the overall size, limiting the total number of images in the expanded dataset to 1800. The training set size is automatically generated by the script based on the target total.
[0020] S3. Construct an initial detection network based on YOLO11s, and embed a Coordinate Attention (CA) module into the main feature extraction line of the backbone network. This allows the network to retain both horizontal and vertical positional information on top of channel attention. The calculation process of the CA module includes the following steps: S31. Input feature map X Perform one-dimensional global average pooling along the horizontal and vertical directions to obtain height-aggregated features and width-aggregated features, as shown in the formula: ; ; The feature map has dimensions C×H×W, where C, H, and W represent the number of channels, height, and width of the feature map, respectively. and These represent the coordinates of the c-th channel of the input feature map. and The response value at that location, Indicates the first Each channel in the vertical direction Aggregation features at the location, Indicates the first Each channel in the width direction Aggregation features at the location; S32. Concatenate the features in the height and width directions, and generate intermediate features through 1×1 convolution, batch normalization (BN), and non-linear activation. The formula is as follows: ; ; in, Indicates feature concatenation operation; This represents a 1×1 convolution transformation; BN Indicates batch normalization; Represents a non-linear activation function; r Indicates the channel compression ratio; d The number of channels representing intermediate features; S33. Split the intermediate features into height and width branches, and generate attention weights in the height and width directions respectively through 1×1 convolution and sigmoid activation, as shown in the formula: ; ; ; in, This indicates that the merged intermediate features are re-decomposed into height and width branches; and These represent 1×1 convolution transformations applied to the height and width branches, respectively. This represents the Sigmoid activation function; and These represent the attention weights generated along the height and width directions, respectively. S34. Apply attention weights to the original features and output the recalibrated features, using the following formula: ; in, Indicates the output feature map of the th Each channel is in coordinates The response value at that location.
[0021] S4. Replace the original bounding box regression loss in the initial detection network with SIoU loss, so that the predicted box and the ground truth box are jointly optimized in the dimensions of angle, distance and shape. The calculation of SIoU loss includes the following steps: S41. Construct the prediction box as follows The real frame is The center coordinates of the prediction box are The center coordinates of the true bounding box are The predicted bounding box width and height are respectively and The actual frame width and height are respectively and The width and height of the minimum bounding rectangle are respectively and The Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box is defined as: ; S42. Angle cost is introduced to describe the degree of deviation of the center line of the prediction box relative to the coordinate axis direction. The calculation formula is as follows: ; ; in, For the sake of perspective, This represents the normalized component of the line connecting the center of the predicted bounding box and the center of the ground truth bounding box along the nearest coordinate axis. S43. The distance cost describes the degree of offset between the center of the predicted bounding box and the center of the ground truth bounding box in both the horizontal and vertical directions. The calculation formula is as follows: ; ; ; ; in, Indicates distance cost. and These represent the normalized distances between the center of the predicted bounding box and the center of the ground truth bounding box, respectively, in the horizontal and vertical directions. As a modulation factor related to the angle cost, it can be seen that the distance cost in SIoU is not calculated independently, but coupled with the angle cost, so that the model takes into account the orientation information when optimizing the center position offset, which helps to improve the stability of bounding box regression. S44. Introducing shape cost, the calculation formula is as follows: ; ; ; in, For the cost of shape, and These represent the relative differences in width and height between the predicted bounding box and the ground truth bounding box, respectively. To adjust the hyperparameters of shape penalty intensity, shape cost can constrain the shape difference between the predicted box and the ground truth box from the two dimensions of width and height, thus having better adaptability when dealing with slender, blurred or small-scale targets; S45. The cross-ratio is retained to measure the degree of overlap between the predicted bounding box and the ground truth bounding box. The calculation formula is as follows: ; in, This represents the area of the intersection between the predicted bounding box and the ground truth bounding box. This represents the area of the union of the two sets; S46. Combining the angle cost, distance cost, shape cost, and IoU term, the final SIoU loss is expressed as: ; Compared to traditional IoU-type losses, SIoU reduces the regression degrees of freedom of the predicted bounding box by introducing angle information, enabling the predicted bounding box to approach the true bounding box with a more reasonable path, thereby improving the model's localization accuracy and convergence efficiency.
[0022] S5. Add a P2 small target detection layer to the detection head to introduce a higher resolution shallow feature map into the multi-scale detection branch, resulting in an improved detection network. A P2 small target detection layer is added to the original detection head, introducing a higher resolution shallow feature map to participate in the prediction. While preserving local edge and texture information, it complements the deep semantic features, improving the model's ability to perceive small and weak targets. Together with the P3, P4, and P5 detection heads, it forms a four-scale prediction structure to complete multi-scale defect detection.
[0023] S6. Use the extended training set to train the improved detection network in step S5 to obtain the T-type weld defect detection model.
[0024] S7. Input the image of the T-weld to be detected into the T-weld defect detection model, and output the defect category, confidence level and bounding box position.
[0025] Table 1 Experimental Environment Configuration
[0026] To ensure fairness in the comparison between different experimental groups, the training parameters in this embodiment are uniformly set as follows: input image size is 960×960, training epochs are 200, batch size is set to 3, and the training device is a single GPU. Considering that Mosaic enhancement may affect the fine regression of bounding boxes in the later stage of training, this embodiment sets close_mosaic=10, that is, Mosaic enhancement is turned off at the end of training to further improve the model's convergence stability and localization accuracy. The experimental environment configuration is shown in Table 1.
[0027] To comprehensively evaluate the impact of different improvement measures on the detection performance of the YOLO11s model, this embodiment sequentially incorporates the CA module, SIoU loss, and P2 small target detection layer into the baseline model. Four combination schemes were designed for ablation experiments to quantify the specific contribution of each improved module to the model's detection accuracy. The results are shown in Table 2. In the table, "CA", "SIoU", and "P2" represent the three improvement points proposed in this embodiment, and the symbol "√" indicates that the improvement strategy is adopted.
[0028] As shown in Table 2, compared to the original YOLO11s baseline model, after introducing the CA module in Improvement 1, the model precision increased from 82.22% to 83.41%, recall increased from 69.82% to 74.01%, and mAP@0.5 increased from 82.61% to 82.74%, with only a 0.03M increase in parameters. The results indicate that the CA module enhances the model's ability to represent the spatial features of key weld areas, improves the model's ability to identify defect targets, and improves the overall detection performance with almost no increase in computational load.
[0029] Improvement 2, by further employing SIoU loss on top of the CA module, improved the model's precision, recall, and mAP@0.5 to 84.17%, 75.41%, and 84.44%, respectively, representing increases of 0.76, 1.40, and 1.70 percentage points compared to Improvement 1, while keeping the number of parameters unchanged. This demonstrates that SIoU loss effectively optimizes the bounding box regression process, improving the model's ability to locate boundary ambiguities and small-scale defects, thus further improving the detection results. Since SIoU only improves the loss function and does not change the model structure, the number of model parameters and computational cost remained largely unchanged.
[0030] This improved method, by adding a P2 small target detection layer to Improvement 2, achieves optimal detection results, with a precision of 87.82%, a recall of 78.04%, and an mAP@0.5 of 86.45%, representing improvements of 5.60, 8.22, and 3.84 percentage points respectively compared to the baseline model. Simultaneously, the number of model parameters increased from 9.43M to 9.60M. The results demonstrate that the P2 small target detection layer enhances the model's ability to perceive small defects and extract detailed features, thereby further improving detection accuracy. Although the computational cost increased, the parameter increase was relatively small, maintaining a good level of lightweight design overall.
[0031] In summary, the improved YOLO11s model demonstrates significantly enhanced performance in T-weld defect detection. Specifically, the CA module primarily enhances the model's ability to model spatial features of critical weld regions, the SIoU loss improves bounding box regression quality, and the P2 small target detection layer further enhances the model's ability to detect minute defects. The combined effect of these three components results in a final model that outperforms the baseline model in terms of detection accuracy, recall, and overall recognition performance, demonstrating the effectiveness of the proposed improvement strategy.
[0032] Table 2 Ablation Experiment Data
[0033] To verify the practical application effect of the improved model proposed in this embodiment in the T-weld defect detection task, seven detection models were selected for comparative experiments: commonly used YOLOv5s, YOLOv8s, YOLOv10s, YOLO11n, YOLO11s, YOLO11s+ECA, and the improved model of this embodiment. All models used the same dataset, the same training parameter settings, and the same experimental environment to ensure the fairness of the performance comparison and the comparability of the results. Using the expanded T-weld defect dataset as model input and defect category and location as output, the detection performance of each model was verified. Specific results are shown in Table 3.
[0034] Analysis of the detection results of different network models in Table 3 shows that the improved model proposed in this embodiment has the best overall performance, with precision, recall, and mAP50 reaching 87.80%, 78.00%, and 86.40%, respectively, and a parameter count of 9.60M. Compared with YOLOv5su, the improved model in this embodiment improves precision, recall, and mAP50 by 5.22, 6.64, and 6.34 percentage points, respectively; compared with YOLOv8s, it improves by 4.28, 5.97, and 5.34 percentage points, respectively. This indicates that the model in this embodiment, while maintaining high detection accuracy, can further improve the model's ability to identify defective targets and the overall detection effect.
[0035] Compared to YOLOv10s, the improved model in this embodiment improved recall by 3.39 percentage points, precision by 18.06 percentage points, and mAP50 by 4.72 percentage points. This indicates that although YOLOv10s has shown some improvement in recall, its detection precision and overall recognition capability are still lower than the method in this embodiment. Compared to YOLO11n, the improved model in this embodiment improved precision, recall, and mAP50 by 24.44, 5.26, and 9.37 percentage points, respectively. This demonstrates that while lightweight structures can effectively reduce the number of model parameters, they still fall short in terms of feature extraction and detection accuracy for weld defects in complex environments.
[0036] Further comparison of the method in this embodiment with the YOLO11 series models shows that, compared to the YOLO11s baseline model, the precision, recall, and mAP50 of the improved model in this embodiment are improved from 82.20%, 69.80%, and 82.60% to 87.80%, 78.00%, and 86.40%, respectively, representing increases of 5.60, 8.20, and 3.80 percentage points, while the number of parameters only increases from 9.43M to 9.60M. This demonstrates that the structural improvement proposed in this embodiment can significantly improve the overall detection performance of the model with a relatively small increase in parameters. Compared to the YOLO11s+ECA model, the improved model in this embodiment achieves a 10.46, 5.16, and 4.66 percentage point increase in precision, recall, and mAP50, respectively. This further demonstrates that enhancing model feature representation solely through a single attention mechanism still has certain limitations. In contrast, this embodiment comprehensively introduces CA, SIoU, and P2 small target detection layers, synergistically optimizing the model's feature extraction capability, bounding box regression capability, and small target defect detection capability, thus resulting in superior detection performance.
[0037] From the perspective of parameter quantity analysis, the improved model in this embodiment has 9.60M parameters, which is lower than YOLOv8s' 11.1379M, slightly higher than YOLOv5su, YOLOv10s, and YOLO11s, but much lower than some larger-scale models. This indicates that the method in this embodiment achieves further improvement in detection accuracy while maintaining a good level of lightweight design. In summary, the improved model proposed in this embodiment outperforms the comparative model in terms of precision, recall, and mAP50, effectively improving feature extraction and multi-scale defect identification capabilities in T-weld defect detection tasks, and has significant engineering application value.
[0038] Table 3 Comparison of experimental results
[0039] To further verify the actual detection effect of the improved model in this embodiment, four representative T-weld images from the test set were selected for visual comparative analysis, such as... Figures 3-6 As shown, the red box and the enlarged view are used to show the inspection details of the key areas of the weld. Figure 3 This is a visual comparison and analysis diagram of T-shaped weld images with obvious spatter, incomplete penetration, and undercut, provided in an embodiment of the present invention. Figure 3 (a) is an image of an original T-weld with obvious spatter, incomplete penetration, and undercut defects. Figure 3 (b) is the YOLO11s model pair Figure 3 (a) shows the detection results. Figure 3 (c) Improved model for this embodiment Figure 3 (a) shows the detection results. The YOLO11s model can only detect spatter, while the improved model in this embodiment can detect spatter, incomplete penetration, and undercut. Figure 4 This is a visual comparison analysis diagram of T-shaped weld images with obvious spatter and two types of defects, namely, lack of fusion and spatter, provided in an embodiment of the present invention. Figure 4 (a) is an image of the original T-weld with both incomplete fusion and spatter defects, and the spatter is obvious. Figure 4 (b) is the YOLO11s model pair Figure 4 (a) shows the detection results. Figure 4 (c) Improved model for this embodiment Figure 4 (a) shows the detection results. The YOLO11s model can only detect spatter, while the improved model in this embodiment can detect both non-fusion and spatter. Figure 5 This is a visual comparison and analysis chart of T-shaped weld images with four types of defects—incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement—provided in an embodiment of the present invention, where the excessive weld reinforcement is particularly noticeable. Figure 5 (a) An image of an original T-weld with four types of defects: incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement, with the excessive weld reinforcement being particularly obvious. Figure 5 (b) is the YOLO11s model pair Figure 5 (a) shows the detection results. Figure 5 (c) Improved model for this embodiment Figure 5 (a) shows the detection results. The YOLO11s model can only detect excessive weld reinforcement, while the improved model in this embodiment can detect incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement. Figure 6 This is a visual comparison and analysis diagram of T-shaped weld images with obvious spatter and four types of defects: lack of fusion, incomplete penetration, spatter, and excessive weld reinforcement, provided in an embodiment of the present invention. Figure 6 (a) An image of an original T-weld with obvious spatter, exhibiting four types of defects: incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement. Figure 6(b) is the YOLO11s model pair Figure 6 (a) shows the detection results. Figure 6 (c) Improved model for this embodiment Figure 6 (a) shows the detection results. The YOLO11s model can only detect spatter, while the improved model in this embodiment can detect incomplete fusion, incomplete penetration, spatter, and excessive weld reinforcement.
[0040] While the YOLO11s model can identify some obvious defects, it still suffers from issues such as missed detection of small defects in the lower region of the weld, incomplete local detection, and insufficient stability in complex backgrounds. In contrast, the improved model in this embodiment can more accurately detect small defects on both sides and in the central region of the weld, exhibiting better recognition capabilities for adjacent distributed defects and defects with blurred boundaries. Local magnification results also show that its positioning in key areas is more accurate and its detection more complete. This demonstrates that the improved method proposed in this embodiment can effectively enhance the model's feature extraction and multi-scale recognition capabilities for T-type weld defects, improving detection accuracy and robustness in complex scenarios.
[0041] Therefore, this invention adopts a T-type weld defect detection method based on improved YOLO11s, which effectively solves the problems of easy omission of small targets, sensitivity of weld area location, blurred local boundaries and difficulty in weak class sample identification in T-type weld defect detection, significantly improves the accuracy, recall and localization accuracy of defect detection, and enhances the adaptability and robustness of the model under complex working conditions.
[0042] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the technical solutions of the present invention, and these modifications or equivalent substitutions cannot cause the modified technical solutions to deviate from the spirit and scope of the technical solutions of the present invention.
Claims
1. A T-shaped weld defect detection method based on improved YOLO11s, characterized by: Includes the following steps: S1. Obtain the original image of the T-type weld defect and divide it into training set, validation set and test set; S2. Perform offline data augmentation on the training set to build an expanded training set; S3. Construct an initial detection network based on YOLO11s, and embed a CA module in the main feature extraction line of the backbone network to enable the network to retain the position information in the horizontal and vertical directions on the basis of channel attention. S4. Replace the original bounding box regression loss in the initial detection network with SIoU loss to jointly optimize the predicted box and the ground box in the dimensions of angle, distance and shape. S5. Add a P2 small target detection layer to the detection head to introduce a higher resolution shallow feature map into the multi-scale detection branch, resulting in an improved detection network. S6. Use the extended training set to train the improved detection network in step S5 to obtain the T-type weld defect detection model. S7. Input the image of the T-weld to be detected into the T-weld defect detection model, and output the defect category, confidence level and bounding box position.
2. The T-shaped weld defect detection method based on improved YOLO11s according to claim 1, characterized in that: In step S2, offline data augmentation includes horizontal flipping, brightness adjustment, contrast adjustment, Gamma transformation, grayscale conversion, Gaussian noise perturbation, and Gaussian blurring.
3. The T-shaped weld defect detection method based on improved YOLO11s according to claim 2, characterized in that: In step S3, the calculation process of the CA module includes the following steps: S31, input feature map X One-dimensional global average pooling is performed along the horizontal and vertical directions to obtain height aggregation features and width aggregation features, and the formula is: ; ; wherein the size of the feature map is CxHxW, C, H and W represent the channel number, height and width of the feature map respectively, and represent the response value of the input feature map at the coordinate and and respectively, represent the aggregated feature of the input feature map at the height direction of the th channel, represent the aggregated feature of the input feature map at the width direction of the th channel. S32. Concatenate the features in the height and width directions, and generate intermediate features through 1×1 convolution, batch normalization (BN), and non-linear activation. The formula is as follows: ; ; wherein, denotes a feature concatenation operation; denotes a 1 x 1 convolutional transformation; BN denotes batch normalization; denotes a nonlinear activation function; r denotes a channel compression rate; d denotes a number of channels of an intermediate feature; S33. Split the intermediate features into height and width branches, and generate attention weights in the height and width directions respectively through 1×1 convolution and sigmoid activation, as shown in the formula: ; ; ; wherein, denotes re-decomposing the fused intermediate feature into height branches and width branches; and denote 1x1 convolutional transformations acting on the height and width branches, respectively; denotes a Sigmoid activation function; and denote attention weights generated along the height and width directions, respectively; S34. Apply attention weights to the original features and output the recalibrated features, using the following formula: ; in, Indicates the output feature map of the th Each channel is in coordinates The response value at that location.
4. The method for detecting T-type weld defects based on improved YOLO11s according to claim 3, characterized in that: In step S4, the calculation of SIoU loss includes the following steps: S41. Construct the prediction box as follows The real frame is The center coordinates of the prediction box are The center coordinates of the true bounding box are The predicted bounding box width and height are respectively and The actual frame width and height are respectively and The width and height of the minimum bounding rectangle are respectively and The Euclidean distance between the center points of the predicted bounding box and the ground truth bounding box is defined as: ; S42. Angle cost is introduced to describe the degree of deviation of the center line of the prediction box relative to the coordinate axis direction. The calculation formula is as follows: ; ; in, For the sake of perspective, This represents the normalized component of the line connecting the center of the predicted bounding box and the center of the ground truth bounding box along the nearest coordinate axis. S43. The distance cost describes the degree of offset between the center of the predicted bounding box and the center of the ground truth bounding box in both the horizontal and vertical directions. The calculation formula is as follows: ; ; ; ; in, Indicates distance cost. and These represent the normalized distances between the center of the predicted bounding box and the center of the ground truth bounding box, respectively, in the horizontal and vertical directions. A modulation factor related to angle cost; S44. Introducing shape cost, the calculation formula is as follows: ; ; ; in, For the cost of shape, and These represent the relative differences in width and height between the predicted bounding box and the ground truth bounding box, respectively. Hyperparameters for adjusting the intensity of shape penalty; S45. The cross-ratio is retained to measure the degree of overlap between the predicted bounding box and the ground truth bounding box. The calculation formula is as follows: ; in, This represents the area of the intersection between the predicted bounding box and the ground truth bounding box. This represents the area of the union of the two sets; S46. Combining the angle cost, distance cost, shape cost, and IoU term, the final SIoU loss is expressed as: 。 5. The method for detecting T-type weld defects based on improved YOLO11s according to claim 4, characterized in that: In step S5, a P2 small target detection layer is added on the basis of the original detection head. A higher resolution shallow feature map is introduced to participate in the prediction. While preserving local edge and texture information, it complements the deep semantic features, improves the model's ability to perceive small and weak targets, and forms a four-scale prediction structure with the P3, P4 and P5 detection heads to complete multi-scale defect detection.