A welding seam surface defect detection method based on a DAB-YOLO algorithm
By improving the DAB-YOLO algorithm, the feature extraction and fusion capabilities for weld surface defect detection are enhanced, solving the problems of low efficiency and poor accuracy of traditional methods. This achieves efficient and accurate weld detection, which is suitable for industrial sites.
Patent Information
- Application Number
- CN202511304092.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-12
- Publication Date
- 2026-03-03
- Estimated Expiration
- 2045-09-12
AI Technical Summary
Existing methods for detecting surface defects in welds are inefficient and inaccurate, especially in their inability to adapt to minute defects and complex welding scenarios, making it difficult to meet the diverse needs of industrial production.
A weld surface defect detection method based on the DAB-YOLO algorithm is adopted. By improving the backbone network, designing the ConBEC module and the knowledge distillation method, the feature extraction and feature fusion capabilities are enhanced, a teacher-student model architecture is constructed, and the model performance is optimized.
It improves the accuracy of identifying various defects on the weld surface, reduces missed and false detections, increases detection speed and adaptability, is suitable for real-time industrial monitoring, reduces labor costs, and ensures product safety.
Smart Images

Figure CN120953260B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of weld surface defect detection technology, and in particular to a weld surface defect detection method based on the DAB-YOLO algorithm. Background Technology
[0002] In industrial production, the quality of welding directly affects the safety and reliability of products. Defects on the weld surface, such as cracks, holes, and lack of fusion, if not detected and addressed promptly and accurately, will severely impact the normal operation and lifespan of equipment, and may even lead to safety accidents, causing significant economic losses and personal injury. Therefore, weld surface defect detection technology occupies a crucial position in modern industrial manufacturing, playing an irreplaceable role in ensuring product quality, improving production efficiency, and reducing production costs.
[0003] Traditional methods for detecting surface defects in welds mainly include visual inspection, penetrant testing, and magnetic particle testing; however, these methods have many limitations.
[0004] Manual visual inspection is not only inefficient, but also greatly affected by the subjective factors, experience level and fatigue of the inspectors, which can easily lead to missed or false detections, and the consistency and repeatability of the test results are difficult to guarantee.
[0005] While penetrant testing and magnetic particle testing can improve the accuracy of defect detection to some extent, the testing process is relatively cumbersome, requiring pre- and post-processing of the workpiece. The testing efficiency is not high, and it can only detect defects with surface openings, making it difficult to effectively identify some small and hidden defects.
[0006] With the continuous development of computer technology, machine learning-based detection technology has been gradually applied to the field of weld surface defect detection. Its advantage lies in its ability to achieve automated feature extraction and classification, reducing manual intervention and improving detection efficiency. However, these traditional machine learning methods often rely on manually designed feature extraction algorithms, which are poorly adaptable to the complex and varied defect features of weld surfaces. When faced with defects of different types and sizes, as well as workpieces under different lighting conditions and welding processes, the detection performance will significantly decline, and the model's generalization ability is weak, making it difficult to meet the diverse needs of actual industrial production.
[0007] In recent years, deep learning technology has achieved significant breakthroughs in image recognition and detection. Convolutional Neural Networks (CNNs), with their powerful automatic feature learning capabilities, can extract deep-level feature information from massive amounts of image data, demonstrating outstanding performance in numerous image detection tasks. The application of deep learning technology has brought new opportunities for weld surface defect detection, potentially overcoming many shortcomings of traditional methods and achieving efficient, accurate, and reliable automated detection. Among numerous deep learning-based detection algorithms, the YOLO series has received widespread attention for its fast and accurate detection capabilities. However, in practical applications of weld surface defect detection, some limitations still exist, such as the need to improve the detection accuracy for minute defects, further optimize the balance between detection speed and accuracy, and enhance adaptability to complex welding scenarios. Summary of the Invention
[0008] The purpose of this invention is to propose a weld surface defect detection method based on the DAB-YOLO algorithm. By proposing an improved backbone network, designing a ConBEC module, and adopting a knowledge distillation method, the problem of insufficient ability to identify small target defects and difficulty in identifying all defect targets in weld surface defect images is solved.
[0009] To achieve the above objectives, this invention proposes a method for detecting surface defects in welds based on the DAB-YOLO algorithm, the specific steps of which are as follows:
[0010] Step S1: Use a camera to collect surface defect images of welds under different conditions, create a defect dataset based on the defect images, and perform defect annotation and expansion on the defect dataset, dividing the defect dataset into a training set and a validation set.
[0011] Step S2: Establish a weld surface defect detection model based on the enhanced cascaded YOLO detection network DAB-YOLO. The weld surface defect detection model includes:
[0012] The attention-enhanced fast spatial pyramid pooling module AESPPF introduces the improved Hybrid Local Channel Attention (MLCA) module into the fast spatial pyramid pooling module SPPF, and incorporates the efficient channel attention module ECA and residual module for optimization; the improved MLCA module adds a deformable convolution to the spatial attention mechanism.
[0013] The convolutional module Conv in the backbone network of the YOLOv10n model is converted into a dilated convolutional module Dilconv, activation functions and regularization operations are added, and a non-zero padding strategy is adopted.
[0014] The enhanced cascaded module ConBEC, which integrates bidirectional feature pyramids, constructs an improved bidirectional feature pyramid network module BiFPN based on the number of input and output channels during initialization. It ensures that the number of channels of all input features is consistent through a feature adjustment layer, processes the features through the BiFPN module, and finally concatenates the processed features along a specified dimension. Residual connections are added after the BiFPN module.
[0015] Using the YOLOv10s model as the teacher model and the improved YOLOv10n model as the student model, a model architecture based on the teacher and student models is constructed and knowledge distillation is performed. The knowledge distillation loss function is defined.
[0016] Step S3: Train the weld surface defect detection model based on the training set, and evaluate the average detection accuracy and detection speed of the weld surface defect detection model based on the validation set.
[0017] Step S4: Use the weld surface defect detection model to detect defects on the weld surface.
[0018] Preferably, in step S1, defect annotation is performed on the defect dataset, specifically as follows:
[0019] Based on the defect category of the weld surface, the defect area and defect category information are marked for all images.
[0020] Preferably, in step S1, the defect dataset is expanded by performing flipping and mirroring operations on the defect images in the defect dataset to obtain defect images from different angles, thereby expanding the dataset.
[0021] Preferably, in step S2, the backbone network of the weld surface defect detection model consists of two DilConv modules connected in series, a cross-stage dual feature fusion module C2f, a Conv module, a C2f module, a spatial-channel decoupled downsampling module SCDown, a C2f module, an AESPPF module, and a position-sensitive attention module PSA. The DilConv module includes a standard two-dimensional convolutional layer, a batch normalization layer (BatchNormalization), and activation functions ReLU and regularized Dropout operations, with a non-zero padding strategy. The AESPPF module includes an improved MLCA module, and is connected in series with the SPPF module, ECA module, and residual module, while simultaneously applying a scaling factor for batch normalization.
[0022] Preferably, in step S2, the neck network of the weld surface defect detection model consists of the following modules connected in series: Upsample, ConBEC, C2f, Upsample, ConBEC, C2f, Conv, ConBEC, C2f, SCDown, and the cross-stage inverted bottleneck fusion module C2fCIB; wherein, the ConBEC module includes the cascaded module Concat and the improved BiFPN module.
[0023] Preferably, the improved BiFPN module consists of a weighted feature fusion module with dynamic weight allocation, constructing a multi-layer BiFPN structure, and adding feature channel adaptive adjustment units at the input and output ends of each BiFPN layer.
[0024] Preferably, in step S2, the total loss calculation formula for the knowledge distillation loss function is as follows:
[0025] Loss=(1-α)·CE(S,Y)+α·KD(S,Z);
[0026] Where Loss is the total loss of the knowledge distillation loss function, CE(S,Y) is the cross-entropy loss, KD(S,Z) is the knowledge distillation loss, S is the output of the student model, Z is the output of the teacher model, Y is the true label, and α is the hyperparameter.
[0027] The formula for calculating the knowledge distillation loss KD(S,Z) is as follows:
[0028]
[0029] Among them, D KL Let be the KL divergence, T be the temperature parameter, || be the soft objective output by the teacher model, and σ be the softmax function.
[0030] Therefore, this invention proposes a method for detecting surface defects in welds based on the DAB-YOLO algorithm, which has the following advantages:
[0031] (1) This invention enhances the feature extraction capability through the AESPPF module and optimizes feature fusion by combining the ConBEC module, effectively improving the recognition accuracy of various defects on the weld surface (especially small target defects) and reducing missed detections and false detections.
[0032] (2) The improved backbone network of this invention adopts lightweight design such as dilated convolution, which reduces the number of parameters and computation while ensuring detection accuracy. Combined with knowledge distillation, it further optimizes the model performance, improves the detection speed, and meets the needs of industrial real-time monitoring.
[0033] (3) This invention enhances the model’s adaptability to different welding scenarios and different types of defects through a feature fusion mechanism with dynamic weight allocation and a channel adaptive adjustment unit, and can still maintain stable detection performance under complex working conditions.
[0034] (4) The teacher-student model architecture constructed in this invention achieves model lightweighting through knowledge distillation, which facilitates deployment on edge devices in industrial sites, provides practical and reliable technical support for welding quality inspection, and helps reduce labor costs and ensure product safety.
[0035] 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
[0036] Figure 1 This is a flowchart of a weld surface defect detection method based on the DAB-YOLO algorithm according to the present invention;
[0037] Figure 2 This is a network structure diagram of the YOLOv10n lightweight model in this invention;
[0038] Figure 3 This is a network structure diagram of the DilConv module in this invention;
[0039] Figure 4 This is a network structure diagram of the AESPPF module in this invention;
[0040] Figure 5 This is a network structure diagram of the ConBEC module in this invention;
[0041] Figure 6 This is a diagram of the teacher-student model architecture in this invention. Detailed Implementation
[0042] To make the technical solutions, advantages, and objectives of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below. The described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the described embodiments of the present invention without creative effort are within the protection scope of the present invention.
[0043] Unless otherwise defined, the technical or scientific terms used in this invention shall have the ordinary meaning as understood by one of ordinary skill in the art to which this invention pertains.
[0044] Example
[0045] like Figure 1 As shown, this invention provides a method for detecting surface defects in welds based on the DAB-YOLO algorithm, with the following specific steps:
[0046] S1. Collect images of weld surface defects under different conditions to create a weld surface defect dataset. Use annotation software to annotate the dataset and use data augmentation algorithms to expand the dataset.
[0047] A weld surface defect dataset was created by collecting images of weld surface defects under different conditions using a camera. The dataset contains 7,500 images, including Porosity, Slag Inclusio, Undercut, Spatter, Weld Bead, Burn-through, and Good Weld. All images are labeled with defect areas and defect category information using labelimg software. The dataset was expanded by adding images from different angles through flipping and mirroring.
[0048] A training set and a validation set for weld surface defect detection were established using a weld surface defect dataset. The defect dataset was divided into two parts according to an 8:2 ratio, that is, 80% of the images were randomly selected as the training set and 20% of the images were randomly selected as the validation set.
[0049] S2. Establish a weld surface defect detection model based on the enhanced cascaded YOLO detection network DAB-YOLO;
[0050] Based on the real-time monitoring algorithm YOLOv10 target detection algorithm, which demonstrates good stability and outstanding detection accuracy in practice, this example optimizes the existing YOLOv10n network structure in conjunction with a real industrial scenario. It constructs a lightweight YOLOv10n model to identify defects, reduces the number of parameters and computation, enhances feature extraction capabilities, and improves the detection accuracy and speed.
[0051] The lightweight YOLOv10n model's backbone network employs an enhanced version of CSPDarkNet-53, fusing dynamic sparse convolutions and a multi-path structure for efficient image feature extraction. After the input image passes through the backbone network, it outputs multi-scale feature maps. An Attention-Enhanced Fast Spatial Pyramid Pooling (AESPPF) module extracts multi-scale spatial information, while a Position-Sensitive Attention (PSA) module captures long-range dependencies. In the neck network, an enhanced cascaded module, ConBEC, fuses bidirectional feature pyramids, integrating multi-scale features to form a feature pyramid rich in semantic information. The head network, based on the feature fusion module's output, inputs the multi-scale fused features into YOLOhead for classification and object detection.
[0052] like Figures 2-3As shown, the backbone network of the YOLOv10n lightweight model consists of two dilated convolutional modules, DilConv, a cross-stage dual feature fusion module, C2f, a convolutional module Conv, a C2f module, a spatial-channel decoupled downsampling module SCDown, a C2f module, an AESPPF module, and a position-sensitive attention module PSA, all connected in series. The DilConv module includes a standard two-dimensional convolutional layer, a batch normalization layer BatchNorm2d, and the ReLU activation function with regularized Dropout operation, and adopts a non-zero padding strategy. The AESPPF module contains an improved hybrid local channel attention module MLCA, and is connected in series with a fast spatial pyramid pooling module SPPF, an efficient channel attention module ECA, and a residual module, while simultaneously applying a scaling factor for batch normalization.
[0053] The neck network of the YOLOv10n lightweight model consists of the following modules in series: Upsample, ConBEC, C2f, Upsample, ConBEC, C2f, Conv, ConBEC, C2f, SCDown, and the cross-stage inverted bottleneck fusion module C2fCIB. The ConBEC module includes the cascaded module Concat and the improved BiFPN module.
[0054] In this embodiment, the input is a 640×640 image. This invention improves the YOLOv10n model and proposes the DAB-YOLO network model, the specific structure of which is as follows:
[0055] The convolutional module Conv in the backbone network of YOLOv10n is transformed into a dilated convolutional module DilConv. Compared with ordinary convolution, it can obtain a larger receptive field without increasing the amount of computation, and can capture richer contextual information. New activation functions and regularization operations are added to prevent overfitting and other problems, and a non-zero padding strategy is adopted.
[0056] like Figure 4 As shown, the AESPPF module is constructed by introducing the improved MLCA module into the SPPF module and integrating it with the ECA module and residual module for optimization. The improved MLCA module inherits the modeling of channel and spatial attention mechanisms from the original MLCA module, and adds a deformable convolution to the spatial attention mechanism to capture feature information more accurately and improve feature extraction capabilities and effects.
[0057] like Figure 5As shown, the ConBEC module, which integrates an improved feature fusion module, is constructed. During initialization, this module builds an improved bidirectional feature pyramid network (BiFPN) based on the number of input and output channels. A feature adjustment layer ensures that the number of channels for all input features is consistent. The BiFPN module then processes the features, and the processed features are concatenated along a specified dimension, significantly improving the accuracy and performance of weld mark defect detection. Adding residual connections after the BiFPN module can alleviate the gradient vanishing problem, further enhancing the model's detection performance.
[0058] like Figure 6 As shown, YOLOv10s is used as the teacher model and the improved YOLOv10n as the student model. A model architecture based on the teacher and student models is constructed and knowledge distillation is performed. The knowledge distillation loss function is defined. This model architecture combines cross-entropy loss and KL divergence loss to guide the learning process of the student model. The specific calculation is as follows:
[0059] Loss=(1-α)·CE(S,Y)+α·KD(S,Z);
[0060] Where Loss is the total loss of the knowledge distillation loss function, CE(S,Y) is the cross-entropy loss, KD(S,Z) is the knowledge distillation loss, S is the output of the student model, Z is the output of the teacher model, Y is the true label, and α is the hyperparameter.
[0061] The knowledge distillation loss KD(S,Z) is used to measure the difference between the student model output S and the teacher model output Z. The calculation formula is as follows:
[0062]
[0063] Among them, D KL Let be the KL divergence, T be the temperature parameter, || be the soft objective output by the teacher model, and σ be the softmax function.
[0064] S3. Model Training: Set training parameters, perform 300 training iterations, with the last 75 iterations using knowledge distillation. The learning rate is 0.001. The training and validation sets from the collected weld defect images are fed into the constructed DAB-YOLO-based weld surface defect detection model for training and validation. Specifically:
[0065] The adaptive scaling of training and validation images for weld surface defect detection is achieved based on the input size set by the network.
[0066] Input the training set and train the weld surface defect detection model based on the DAB-YOLO algorithm according to the set training parameters;
[0067] The performance of the trained weld surface defect detection model was evaluated, and a well-converged network model was obtained.
[0068] The validation set is input into the trained weld surface defect detection model for validation, and the model performance is tested.
[0069] S4. Model Evaluation; Based on the trained weld surface defect detection model, the model is evaluated using metrics such as average detection accuracy and detection speed. Specifically:
[0070] By setting training parameters and inputting sample images from the training set into the DAB-YOLO algorithm, and setting the number of iterations, the optimal weight file for weld defect detection is obtained. The direction of network training is continuously adjusted using the CIoU bounding box loss function. The map value of the validation set is calculated to verify whether the training has achieved the expected results. Finally, the optimal weight file is selected by filtering the trained weight files and loaded into the weld surface defect detection model of the DAB-YOLO algorithm.
[0071] S5. Compare the evaluation metrics trained by the weld surface defect detection model based on YOLOv10n with those trained by the weld surface defect detection model based on the DAB-YOLO algorithm.
[0072] The evaluation metrics for weld surface defect detection models constructed using the YOLOv10n algorithm and the DAB-YOLO algorithm were calculated respectively, and the results are as follows:
[0073] YOLOv10n algorithm:
[0074] Accuracy P = 0.863, recall R = 0.896, mean precision (mAP) mAP50 = 0.899 when the IoU threshold is 0.5, and mean precision (mAP) mAP50-95 = 0.611 when the IoU threshold ranges from 0.5 to 0.95 (step size 0.05).
[0075] DAB-YOLO algorithm:
[0076] Accuracy P = 0.942, recall R = 0.921, mean precision (mAP) mAP50 = 0.918 when the IoU threshold is 0.5, and mean precision (mAP) mAP50-95 = 0.636 when the IoU threshold ranges from 0.5 to 0.95 (step size 0.05).
[0077] The comparison revealed that the evaluation metrics trained by the weld surface defect detection model based on the DAB-YOLO algorithm were superior to those trained by the weld surface defect detection model based on YOLOv10n.
[0078] It is worth noting that all contents not described in detail in this invention are existing technologies and are well known to those skilled in the art.
[0079] Therefore, this invention provides a weld surface defect detection method based on the DAB-YOLO algorithm, which not only improves detection efficiency and accuracy and reduces missed and false detections, but also provides practical and reliable technical support for welding quality assessment and defect classification. It helps to reduce labor costs and ensure product safety, and has strong industrial practical value.
[0080] 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 welding seam surface defect detection method based on a DAB-YOLO algorithm, characterized in that, The steps are as follows: Step S1, collecting weld surface defect images under different conditions by using a camera, making a defect data set based on the defect images, and labeling and expanding the defect data set, and dividing the defect data set into a training set and a validation set; Step S2, establishing a weld surface defect detection model based on the enhanced cascade YOLO detection network DAB-YOLO, the weld surface defect detection model comprising: An attention-enhanced fast spatial pyramid pooling module AESPPF, an improved mixed local channel attention module MLCA is introduced into a fast spatial pyramid pooling module SPPF, and an efficient channel attention module ECA and a residual module are fused for optimization; the improved MLCA module adds a deformable convolution to the spatial attention mechanism on the basis of modeling the channel and spatial attention mechanisms of the original MLCA module; The convolution module Conv in the backbone network of the YOLOv10n model is converted into a dilated convolution module Dilconv, an activation function and a regularization operation are added, and a non-zero padding strategy is adopted; An enhanced cascade module ConBEC that fuses a bidirectional feature pyramid is constructed, an improved bidirectional feature pyramid network module BiFPN is constructed according to the input and output channel numbers during initialization, the channel numbers of all input features are ensured to be consistent through a feature adjustment layer, and the features are processed through the BiFPN module, and finally the processed features are spliced along the specified dimension, and a residual connection is added after the BiFPN module; YOLOv10s model is used as a teacher model, and the improved YOLOv10n model is used as a student model, a model architecture based on the teacher model and the student model is constructed, and knowledge distillation is performed, and a knowledge distillation loss function is defined; Step S3, training the weld surface defect detection model based on the training set, and evaluating the average detection accuracy and detection speed of the weld surface defect detection model based on the validation set; Step S4, detecting the defects on the weld surface by using the weld surface defect detection model; In step S2, the backbone network of the weld surface defect detection model is composed of two DilConv modules, a cross-stage double feature fusion module C2f, a Conv module, a C2f module, a spatial-channel decoupling down-sampling module SCDown, a C2f module, an AESPPF module, and a position-sensitive attention module PSA connected in sequence; wherein the DilConv module comprises a standard two-dimensional convolution layer, a batch normalization layer BatchNormalization, and an activation function ReLU and a regularization Dropout operation connected in sequence, and adopts a non-zero padding strategy; the AESPPF module includes an improved MLCA module, and the SPPF module, the ECA module, and the residual module are connected in series, and the scaling factor of batch normalization is performed at the same time; The neck network of the weld surface defect detection model is composed of an up-sampling module Upsample, a ConBEC module, a C2f module, an up-sampling module, a ConBEC module, a C2f module, a Conv module, a ConBEC module, a C2f module, an SCDown module and a cross-stage inverted bottleneck fusion module C2fCIB connected in sequence; wherein the ConBEC module contains a concatenation module Concat and an improved BiFPN module; The improved BiFPN module is composed of a weighted feature fusion module with dynamic weight distribution, a BiFPN structure containing multiple layers is constructed, and a feature channel adaptive adjustment unit is added at the input and output ends of each BiFPN layer.
2. The weld seam surface defect detection method based on the DAB-YOLO algorithm according to claim 1, characterized in that, In step S1, the defect data set is labeled, specifically: According to the defect category of the weld surface, the defect area and defect category information in all images are labeled.
3. The weld seam surface defect detection method based on the DAB-YOLO algorithm according to claim 1, characterized in that, In step S1, the defect data set is expanded, specifically: the defect images in the defect data set are flipped and mirrored to obtain defect images at different angles, and the data set is expanded.
4. The weld seam surface defect detection method based on the DAB-YOLO algorithm according to claim 1, characterized in that, In step S2, the total loss calculation formula of the knowledge distillation loss function is as follows: ; wherein, Loss Ltotal is the total loss for the knowledge distillation loss function, Lcross-entropy is the cross-entropy loss, Lknowledge distillation is the knowledge distillation loss, S is the output of the student model, Z is the output of the teacher model, and Y is the true label, is a hyperparameter; Knowledge distillation loss The formula for calculating the knowledge distillation loss is as follows: ; where, is the KL divergence, T is the temperature parameter, is the soft target output by the teacher model, is the softmax function.
Citation Information
Patent Citations
Weld defect detection method based on improved YOLOv8 custom pruning and mixed distillation
CN118212225A
Ship industry steel surface defect detection algorithm based on improved YOLOv8
CN120387990A