A Deep Learning-Based Method and System for Detecting Surface Defects in Welds
By constructing a neural network based on a dual-branch feature extraction and feature separation module using deep learning, the problem of feature homogenization caused by spatter interference in weld inspection is solved, enabling accurate identification of surface defects in welds and improving the accuracy and reliability of inspection. This method is applicable to weld quality inspection of bogies in rail vehicles.
Patent Information
- Application Number
- CN202511836715.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2045-12-08
AI Technical Summary
Existing two-dimensional visible light-based weld defect detection methods cannot effectively distinguish the homogeneous interference caused by welding spatter, resulting in detection accuracy and reliability falling far short of the stringent requirements of industrial applications, especially in scenarios with high spatter coverage where false detections and missed detections occur frequently.
We employ a deep learning-based approach to construct a neural network that includes a dual-branch feature extraction structure and a feature separation module. We build a labeled dataset using a semi-supervised annotation strategy, increase the distance between splash features and defect features in the feature space using a feature comparison mechanism, and enhance the defect feature response through a self-attention mechanism and an edge-enhanced attention window. Finally, we perform post-processing optimization.
This effectively decouples splashes from defect characteristics, significantly improving the reliability and stability of detection results, meeting stringent industrial standards, reducing the risk of false positives and missed negatives, and ensuring the safe operation of rail vehicles.
Smart Images

Figure CN121259006B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect detection technology, and specifically to a method and system for detecting surface defects in welds based on deep learning. Background Technology
[0002] As rail vehicles continue to evolve towards higher speeds and heavier loads, increasingly stringent requirements are being placed on the welding quality and reliability of critical load-bearing structural components such as bogies. This trend has brought significant advantages in improving vehicle performance and operational efficiency. However, this development is accompanied by increasingly complex and severe technical challenges in the automated quality inspection of bogie welds.
[0003] In the welding and manufacturing process of bogies, low-alloy steel welding rods are commonly used, which inevitably generates a large amount of welding spatter. This spatter adheres extensively and densely to the weld surface and its heat-affected zone, and its physical properties highly overlap with those of actual minute defects. This poses a serious problem of defect-false defect feature confusion for vision-based automated inspection systems, leading to frequent false positives and false negatives. This can result in inaccurate inspection results, misjudgment of qualified parts, or the slip-through of defective parts, creating a series of serious consequences and posing potential hazards to driving safety.
[0004] In the bogie weld quality inspection system, the accurate identification of minute defects such as microcracks and porosity plays a crucial role. The key to achieving accurate identification lies in the effective extraction and analysis of the image features of the weld surface. Currently, most existing weld defect detection methods based on two-dimensional visible light focus on visual features such as geometric shape and grayscale contrast in the image. Undeniably, these methods can accurately identify defects in scenarios with minimal spatter interference or obvious defect features, providing some support for quality assessment. However, they have a significant limitation…
[0005] In other words, it is impossible to effectively distinguish the homogeneous interference caused by welding spatter. Specifically, spatter particles are highly consistent with key defects such as microcracks and pores in terms of size, material, and optical properties; at the same time, their irregular angular or spherical shapes have a visual similarity of 85% to 90% to defects. In addition, the spatter coverage area often exceeds 90% and is densely distributed, which easily forms a complex superposition state where false defects cover real defects. In the face of such highly homogeneous interference, existing models lack the feature decoupling ability to fundamentally distinguish between true and false features, ultimately resulting in the detection accuracy and reliability in highly interference scenarios such as bogies falling far short of the stringent requirements of industrial applications. Summary of the Invention
[0006] The purpose of this invention is to provide a method and system for detecting surface defects in welds based on deep learning, so as to overcome the shortcomings of the prior art.
[0007] To achieve the above objectives, the present invention provides the following technical solution: a method for detecting surface defects in welds based on deep learning, comprising:
[0008] Original images of the bogie weld surface were acquired, and a labeled dataset containing spatter areas, defect areas, and spatter-defect coexistence areas was established. The labeled dataset adopted a semi-supervised labeling strategy.
[0009] A deep neural network is constructed that includes a dual-branch feature extraction structure and a feature separation module, wherein the first branch is configured to extract the optical reflection characteristics of the material, and the second branch is configured to extract the geometric topological features of the defects.
[0010] The deep neural network is trained using the labeled dataset. During the training process, a joint loss function including a feature comparison mechanism is used to increase the distance between splash features and defect features in the feature space.
[0011] The image of the weld to be detected is input into the trained deep neural network. The feature separation module obtains the preliminary detection results, and the preliminary detection results are post-processed and optimized to output the final defect detection results.
[0012] In a preferred embodiment, the step of establishing the labeled dataset includes:
[0013] Acquire raw images of the bogie weld surface, covering the main weld area, heat-affected zone, and surrounding base material area;
[0014] The true defect state of the samples is confirmed by non-destructive testing methods, forming a basic labeled sample set;
[0015] A complete labeled dataset is constructed using a semi-supervised annotation strategy, where:
[0016] Areas where splash particles accumulate and are confirmed to be free of defects are labeled as splash interference.
[0017] Defect areas without splash coverage are labeled with the corresponding defect category tags;
[0018] For areas covered by splashes that are confirmed to have defects, both splash interference labels and defect category labels should be marked.
[0019] In a preferred embodiment, the step of constructing a complete labeled dataset using a semi-supervised annotation strategy includes:
[0020] A basic segmentation model was trained using a basic labeled sample set confirmed by nondestructive testing.
[0021] The basic segmentation model is used to generate pseudo-labels for unlabeled regions;
[0022] Manually review and correct fuzzy areas in pseudo-labels whose confidence levels fall within the preset review interval;
[0023] The quality of the reviewed annotation results is checked to form the final annotated dataset.
[0024] In a preferred embodiment, the step of constructing a deep neural network including a dual-branch feature extraction structure includes:
[0025] In the first branch, a deep convolutional neural network structure is constructed to extract the optical reflection characteristics of the material through multi-layer convolution operations. The deep convolutional neural network includes convolutional layers, pooling layers, and normalization layers to capture the differences in reflectivity and surface roughness between spatter and defects.
[0026] In the second branch, a multi-scale dilated convolutional structure is constructed. The geometric topological features of defects are extracted through parallel convolutional layers with different dilation rates. The multi-scale dilated convolutional structure contains multiple parallel dilated convolutional branches, which capture morphological features such as the linear continuity of microcracks and the circular closure of pores at different scales.
[0027] The optical reflection characteristics of the first branch and the geometric topology characteristics of the second branch are spliced together along the channel dimension to form a dual-branch fusion feature.
[0028] In a preferred embodiment, the step of outputting the defect detection result through the feature separation module includes:
[0029] Spatial attention weight map is generated by calculating the spatial correlation of dual-branch fusion features through a self-attention mechanism.
[0030] By incorporating prior information about the weld contour, spatial attention weights are constrained to suppress invalid computations in the background region;
[0031] The edge-enhanced attention window is used to strengthen the response of defect features whose feature size is smaller than a preset threshold. The edge-enhanced attention window adopts a method of fusing local structural feature extraction and global attention weight.
[0032] The input features are reweighted spatially based on the optimized attention weights to highlight the feature representation of the real defect area;
[0033] The classification head performs pixel-level classification on the weighted feature map and outputs the defect detection results.
[0034] In a preferred embodiment, the step of enhancing the defect feature response using an edge-enhanced attention window includes:
[0035] For microcrack regions with feature sizes smaller than a preset threshold, an attention enhancement method based on local structural features is adopted;
[0036] The continuity features of linear defects are enhanced by edge-guided feature extraction operations, and learnable edge detection convolutional kernels are used to extract local gradient information.
[0037] Local structural features are fused with global attention weights to generate an attention weight map for edge enhancement.
[0038] Attention weight maps based on edge enhancement selectively enhance the features of minute defects, thereby improving the detection rate of minute defects.
[0039] In a preferred embodiment, the step of post-processing and optimizing the preliminary detection results includes:
[0040] The training state is evaluated based on the classification performance of multi-class samples on the validation set, wherein the multi-class samples include splash-only regions, overt defect regions, and splash-defect coexistence regions.
[0041] The weights of each term in the joint loss function are dynamically adjusted based on the feature separation performance index.
[0042] Calculate the distribution difference between splash samples and defect samples in the feature space, and quantify the feature separation degree based on the distribution difference;
[0043] Adjust the weight ratio of classification loss and feature contrast loss according to the degree of feature separation. When the degree of feature separation is insufficient, increase the weight ratio of feature contrast loss.
[0044] In a preferred embodiment, after the step of inputting the image of the weld to be detected into the trained deep neural network, the method further includes:
[0045] Post-processing optimization is performed on the defect candidate regions output by the feature separation module;
[0046] Multi-neighbor connectivity analysis is used to aggregate spatially correlated defect pixels to form a complete defect candidate region.
[0047] Calculate the average classification confidence within each connected component, and filter out the true defect regions based on the adaptive confidence threshold;
[0048] The screened defect areas are subjected to morphological analysis and classification, and the final defect detection results and confidence scores are output.
[0049] This invention also provides a deep learning-based weld surface defect detection system, comprising:
[0050] An image acquisition module is used to acquire the original image of the bogie weld surface and perform distortion correction. The image acquisition module includes an industrial camera, a uniform illumination device, and an image preprocessing unit.
[0051] The processing module is configured to perform training of the deep neural network, preprocessing of the image to be detected, model inference, and post-processing of the defect candidate region. The processing module includes a dual-branch feature extraction unit, a feature separation unit, and an adaptive post-processing unit.
[0052] The output module is used to visualize the defect detection results and the attention weight heatmap of the feature separation process. The output module includes a defect visualization interface and a feature analysis interface.
[0053] The technical effects and advantages provided by the present invention in the above technical solution are as follows:
[0054] By employing a dual-branch feature extraction method based on reflection characteristics and geometric morphology, the true and false defect features are decoupled from their physical essence, breaking the limitation that a single feature dimension cannot distinguish homogeneous interference. Combined with self-attention feature separation, it effectively suppresses splash interference, solves the complex superposition problem of false defects covering true defects, and accurately identifies tiny defects hidden under splashes.
[0055] By strengthening classification and feature separation capabilities through a joint loss function, balancing training objectives with a dynamic weight adjustment strategy, and quantitatively verifying the feature separation effect, this approach addresses the implicit problem of undecoupled features in existing models, significantly improving the reliability and stability of detection results and meeting stringent industrial standards.
[0056] The entire process of technology optimization enhances industrial applicability: the specially designed labeling system provides high-quality training samples that fit reality, improving the model's generalization ability; the post-processing stage effectively removes false defects caused by splashing, reduces the risk of false detection and missed detection, avoids misjudging qualified parts and missing defective parts, and ensures the safety of rail vehicle operation. Attached Figure Description
[0057] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this invention. For those skilled in the art, other drawings can be obtained based on these drawings.
[0058] Figure 1 This is a flowchart of the method of the present invention.
[0059] Figure 2 This is a system block diagram of the present invention. Detailed Implementation
[0060] 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, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0061] Example 1, please refer to Figure 1 As shown in this embodiment, a deep learning-based method for detecting surface defects in welds includes:
[0062] S1. Acquire the original image of the bogie weld surface and establish a labeled dataset containing spatter area, defect area and spatter-defect coexistence area. The labeled dataset adopts a semi-supervised labeling strategy.
[0063] S2. Construct a deep neural network that includes a dual-branch feature extraction structure and a feature separation module, wherein the first branch is configured to extract the optical reflection characteristics of the material, and the second branch is configured to extract the geometric topological features of the defects.
[0064] S3. Train the deep neural network using the labeled dataset. During the training process, a joint loss function including a feature comparison mechanism is used. The feature comparison mechanism is used to increase the distance between the splash feature and the defect feature in the feature space.
[0065] S4. Input the image of the weld to be detected into the trained deep neural network, obtain the preliminary detection result through the feature separation module, perform post-processing optimization on the preliminary detection result, and output the final defect detection result.
[0066] As described in S1-S4 above, weld surface defect detection is a core aspect of quality control in the manufacturing of rail vehicle bogies, directly impacting the safety and reliability of high-speed train operation. Traditional weld defect detection methods either rely on manual visual inspection, which is highly subjective, has a high rate of missed detections, and cannot identify minute defects; or they employ automated solutions based on single feature extraction, which struggle to distinguish the homogeneous features of welding spatter from actual defects, especially when spatter coverage exceeds 90%, leading to a sharp drop in detection accuracy. Existing deep learning models often focus on single-dimensional feature learning, lacking an understanding of the physical nature of weld defects, resulting in poor model generalization ability and an inability to adapt to the detection needs of different welding processes and materials. This method, through a full-link design including semi-supervised precise annotation, decoupling of essential features in two branches, feature comparison-enhanced training, and self-attention feature separation, deeply integrates material physical properties with deep learning technology. This not only solves the problem of weak anti-interference capability of traditional methods but also provides clear technical logic support for the detection process, achieving an industrial-grade closed loop from data acquisition to defect identification, providing a precise and efficient quality inspection tool for rail transit equipment manufacturing.
[0067] In one embodiment, step S1 of establishing the labeled dataset includes:
[0068] S11. Acquire the original image of the bogie weld surface, covering the main weld area, heat-affected zone and surrounding base material area;
[0069] S12. Confirm the true defect state of the sample through non-destructive testing methods to form a basic labeled sample set;
[0070] S13. Construct a complete labeled dataset using a semi-supervised annotation strategy, where:
[0071] S131. Areas where spatter particles accumulate and are confirmed to be free of defects are labeled as spatter interference areas.
[0072] S132. Mark the defective areas without splash coverage with the corresponding defect category label;
[0073] S133. If a defect is confirmed to exist in the area covered by splashing, both a splashing interference label and a defect category label shall be marked.
[0074] As described in S11-S13 above, a high-quality labeled dataset is fundamental to ensuring the accuracy of the defect detection model. Its coverage and labeling accuracy directly determine the model's generalization ability. For raw image acquisition, a Baslerac A2040-180km industrial CMOS camera with a 25mm fixed-focus lens can be used, with a scanning resolution ≥1920×1200 pixels and a frame rate of 10-15fps, ensuring clear capture of minute defect details such as microcracks (0.1-0.3mm wide) and pores (0.2-0.6mm in diameter). Non-destructive testing methods can employ ultrasonic testing equipment (such as the Olympus EPOCH650, with a detection frequency of 5MHz) or X-ray testing equipment to confirm the true defect state of the samples, forming a basic labeled sample set and avoiding labeling deviations due to human error. A dual-label association mechanism is used during the labeling process. For the challenging situation of sputtering-defect coexistence, two types of labels are labeled simultaneously, solving the technical problem that traditional single-label methods cannot distinguish between false defects covering true defects. This step, through full-area coverage data collection, non-destructive testing verification, and precise multi-label annotation, constructs a high-quality dataset that closely matches industrial realities. This completely solves the problems of incomplete annotation information and an inadequate labeling system in traditional methods, laying a solid data foundation for subsequent model training. In real-world industrial scenarios, the grain structure of the weld heat-affected zone differs from the base material, easily leading to hidden defects. Furthermore, impurities or scratches in the surrounding base material may be misjudged as defects. By covering the entire area and accurately annotating it, the model can learn the characteristic differences between different regions, improving detection accuracy.
[0075] In one embodiment, step S1, which involves constructing a complete labeled dataset using a semi-supervised annotation strategy, includes:
[0076] S14. Train the basic segmentation model using the basic labeled sample set confirmed by non-destructive testing;
[0077] S15. Use the aforementioned basic segmentation model to generate pseudo-labels for the unlabeled regions;
[0078] S16. Manually review and correct the fuzzy areas in the pseudo-labels whose confidence levels are within the preset review interval;
[0079] S17. Perform quality checks on the reviewed annotation results to form the final annotation dataset.
[0080] As described in S14-S17 above, the core value of the semi-supervised annotation strategy lies in addressing the pain points of high annotation costs and limited sample size in industrial scenarios, balancing annotation efficiency and quality. The lightweight U-Net network can be used as the base segmentation model. This model has the advantages of fewer parameters and faster inference in image segmentation tasks, making it suitable for quickly generating pseudo-labels. The preset verification interval is typically set to a confidence level of 0.5-0.9. Annotation results within this interval have high uncertainty, and manual verification can accurately correct model misjudgments. Regions with a confidence level <0.5 are labeled as background by default, while regions with a confidence level >0.9 are directly considered valid annotations, significantly reducing manual workload. The quality inspection stage employs a two-person cross-review mechanism, randomly selecting 20% of the labeled samples for verification to ensure an annotation accuracy rate ≥99.8% and a label omission rate ≤0.2%. Compared to traditional fully manual annotation, this strategy can improve annotation efficiency by more than 60%, while the combination of basic sample training and precise manual verification ensures that the dataset quality is not compromised. In bogie weld inspection, the number of image samples for a single weld can reach thousands. Manual annotation would require a lot of manpower. Semi-supervised strategies reduce repetitive work by automatically annotating through models and only focus on fuzzy areas for manual intervention. This not only improves annotation efficiency but also avoids the high error rate of fully automated annotation, making it one of the best solutions for industrial big data annotation.
[0081] In one embodiment, step S2 of constructing a deep neural network including a dual-branch feature extraction structure includes:
[0082] S21. Construct a deep convolutional neural network structure in the first branch, and extract the optical reflection characteristics of the material through multi-layer convolution operations. The deep convolutional neural network includes convolutional layers, pooling layers and normalization layers, which are used to capture the differences between spatter and defects in terms of reflectivity and surface roughness.
[0083] S22. Construct a multi-scale dilated convolutional structure in the second branch, and extract the geometric topological features of the defects through parallel convolutional layers with different dilation rates. The multi-scale dilated convolutional structure contains multiple parallel dilated convolutional branches, which respectively capture the morphological features such as the linear continuity of microcracks and the circular closure of pores at different scales.
[0084] S23. The optical reflection characteristics of the first branch and the geometric topology characteristics of the second branch are spliced together by channel dimension to form a dual-branch fusion feature.
[0085] As described in S21-S23 above, the dual-branch feature extraction structure is a core innovation that breaks through the bottleneck of traditional single-feature detection. Its essence is to decouple the feature differences between splashes and defects from two orthogonal dimensions: physical essence and spatial morphology. The deep convolutional neural network of the first branch can be set with 5-10 convolutional layers. The first 3 layers use 3×3 small convolutional kernels to extract local reflection features. Subsequent layers deepen the feature expression by increasing the number of channels (gradually increasing from 64 to 1024). Combined with max pooling layers (2×2 pooling kernels) and BatchNorm normalization layers, it effectively captures the optical differences between splashes (high reflectivity, uniform surface) and defects (low reflectivity, rough surface). The multi-scale dilated convolutional structure of the second branch sets up parallel convolutional layers with dilation rates of 1, 3, and 5. For areas where the splash coverage area is ≥95%, an additional branch with a dilation rate of 7 is added. The outputs of each branch are concatenated by channels and then reduced to 512 dimensions by 1×1 convolution to accurately capture the geometric features of defects at different scales. Finally, the dual-branch features (1024 dimensions + 512 dimensions) are concatenated into a 1536-dimensional fused feature, achieving a comprehensive feature representation of both physical essence and spatial morphology. Traditional single-branch models only focus on geometric morphology and cannot distinguish between splashes and defects that are similar in appearance but different in physical essence. The dual-branch architecture of this application solves the problem of feature homogenization interference at its root, giving the model stronger anti-interference ability and generalization ability.
[0086] In one embodiment, step S4, which outputs the defect detection result through the feature separation module, includes:
[0087] S41. Calculate the spatial correlation of the dual-branch fusion features through a self-attention mechanism to generate a spatial attention weight map;
[0088] S42. Constrain the spatial attention weights by combining prior information on weld contours to suppress invalid calculations in the background region;
[0089] S43. Enhance the response of defect features whose feature size is smaller than a preset threshold by using an edge-enhanced attention window. The edge-enhanced attention window adopts a method of fusing local structural feature extraction with global attention weight.
[0090] S44. Based on the optimized attention weights, the input features are re-weighted in terms of spatial dimensions to highlight the feature representation of the real defect area;
[0091] S45. Perform pixel-level classification on the weighted feature map using the classification head, and output the defect detection results;
[0092] As described in S41-S45 above, the core function of the feature separation module is to purify and fuse features, suppress spatter interference, strengthen defect features, and solve the industry problem of pseudo-defects covering true defects. The self-attention mechanism maps the fused features to a query vector Q, a key vector K, and a value vector V. It calculates the product of the transposes of Q and K to obtain a spatial correlation matrix, which is then normalized using softmax to generate an attention weight map, automatically focusing on regions with strong feature responses. Prior information about the weld contour is obtained through Canny edge detection, assigning a weight of 0 to background pixels outside the weld area to reduce invalid computation and improve inference efficiency. The preset threshold is typically set to 0.1mm. For microcracks with a width <0.1mm, the edge enhancement attention window strengthens the linear feature response through a 3×3 local window. The classification head uses two convolutional layers plus a softmax activation function to achieve pixel-level classification, outputting three categories: spatter-only, explicit defects, and spatter-defect coexistence. This module employs a five-level processing approach—spatial correlation calculation, prior constraints, edge enhancement, feature weighting, and precise classification—to improve the interference suppression rate of spatter features to over 80% and increase the feature response intensity of minor defects by 50%. This completely resolves the problem of frequent missed and false detections in traditional models under high spatter interference scenarios. In practical applications, spatter distribution in bogie welds is dense and irregular, often covering minor defects. The feature separation module, through dynamic adjustment of attention weights, can accurately identify defects completely covered by spatter, providing a reliable basis for quality control.
[0093] In one embodiment, step S43, which utilizes an edge-enhanced attention window to strengthen the response to defect features, includes:
[0094] S431. For microcrack regions with feature sizes smaller than a preset threshold, an attention enhancement method based on local structural features is adopted.
[0095] S432. Enhance the continuity features of linear defects through edge-guided feature extraction operations, and use learnable edge detection convolution kernels to extract local gradient information;
[0096] S433. The local structural features and global attention weights are fused and calculated to generate an attention weight map for edge enhancement.
[0097] S434. Attention weight map based on edge enhancement selectively enhances the features of small defects, thereby improving the detection rate of small defects.
[0098] As described in S431-S434 above, the detection of minute defects (microcracks with a width < 0.1 mm and porosity with a diameter < 0.2 mm) is a challenge in weld inspection. Traditional models, due to their weak feature response, are prone to missing these defects. A preset threshold of 0.1 mm is set, referencing the definition of minute defects in "Ultrasonic Testing of Welds Part 1: Techniques, Inspection Grades and Evaluation". A 3×3 size learnable edge detection convolution kernel is used, and the kernel parameters are adaptively adjusted through model training to accurately extract the local gradient information of microcracks, strengthening their linear continuity features and preventing them from being obscured by irregular edges caused by spatter. The fusion of local structural features and global attention weights uses a weighted summation method, setting a local feature weight of 0.6 and a global weight of 0.4. This ensures that the local features of minute defects are fully captured without deviating from the overall weld feature context. Through this step, the detection rate of microcracks is increased from 30% in traditional methods to over 70%, completely overcoming the technical blind spot in minute defect detection. In the manufacturing of railway vehicle bogies, if micro-cracks are not detected in time, they may expand into macro-cracks after long-term operation, causing serious safety accidents. This step provides key protection for equipment safety through targeted feature enhancement.
[0099] In one embodiment, step S3 of training a deep neural network using a labeled dataset further includes:
[0100] S31. Evaluate the training state based on the classification performance of multi-class samples on the validation set, wherein the multi-class samples include splash-only regions, overt defect regions, and splash-defect coexisting regions.
[0101] S32. Dynamically adjust the weight allocation of each item in the joint loss function based on the feature separation performance index;
[0102] S33. Calculate the distribution difference between the splash samples and the defect samples in the feature space, and measure the degree of feature separation based on the distribution difference;
[0103] S34. Adjust the weight ratio of classification loss and feature comparison loss according to the degree of feature separation. When the degree of feature separation is insufficient, increase the weight ratio of feature comparison loss.
[0104] As described in S31-S34 above, the dynamic weight adjustment strategy is key to ensuring that the model balances classification accuracy and feature separation performance, avoiding model bias caused by traditional fixed-weight training. The validation set is divided into training set:validation set:test set ratios of 7:2:1, ensuring balanced distribution of the three classes. Classification performance is quantified and evaluated using accuracy (Acc). The feature separation performance is quantified using the cosine similarity of the feature vectors of splash samples and defective samples; a similarity < 0.3 indicates satisfactory separation. The joint loss function consists of classification loss (cross-entropy loss) and feature contrast loss (triple loss), with an initial weight ratio of 1:1. The adjustment rules are clear: when the validation set accuracy is < 85%, the classification loss weight is increased to 1.2:0.8; when the accuracy is ≥ 92% but feature separation is not satisfactory, the feature contrast loss weight is increased to 0.8:1.2. This strategy allows model training to dynamically adapt to real-time performance, improving convergence speed by 50% and reducing the training cycle from 100 rounds to 60-70 rounds. Traditional fixed-weight training often results in accurate classification but feature confusion or good feature separation but large classification error. However, the dynamic adjustment mechanism of this application achieves synergistic optimization of the two training objectives, ensuring that the model has both accurate classification ability and can fundamentally distinguish the feature differences between splashes and defects.
[0105] In one embodiment, step S4, which involves post-processing and optimizing the preliminary detection results, includes:
[0106] S46. Perform post-processing optimization on the defect candidate regions output by the feature separation module;
[0107] S47. Multi-neighborhood connectivity analysis is used to aggregate spatially related defect pixels to form a complete defect candidate region.
[0108] S48. Calculate the average classification confidence within each connected component, and filter out the real defect areas based on the adaptive confidence threshold.
[0109] S49. Perform morphological analysis and classification on the screened defect areas, and output the final defect detection results and confidence scores.
[0110] As described in S46-S49 above, post-processing optimization improves the reliability of detection results by eliminating false defects, aggregating scattered defect pixels, and forming an accurate description of the defect region. Multi-neighbor connectivity analysis uses an 8-neighbor rule to aggregate spatially adjacent (vertical, horizontal, and diagonal) defect pixels into a complete region, avoiding the fragmentation of continuous defects into multiple pieces. The adaptive confidence threshold is dynamically adjusted based on the overall confidence distribution of the sample, typically set to 0.7; regions below this threshold are identified as false defects and eliminated. Morphological analysis further distinguishes between microcracks (linear, low circularity) and pores (circular, high circularity) by calculating parameters such as the area, perimeter, and roundness of the defect region. This step controls the false detection rate of the final detection to below 5%, significantly improving the industrial applicability of the results. In production line applications, the post-processing optimized results can be directly integrated into the MES system, providing accurate defect information for quality traceability, including location, type, size, and confidence score, avoiding unnecessary rework due to false defects and reducing production costs.
[0111] Example 2, please refer to Figure 2 As shown in this embodiment, a deep learning-based weld surface defect detection system includes:
[0112] An image acquisition module is used to acquire the original image of the bogie weld surface and perform distortion correction. The image acquisition module includes an industrial camera, a uniform illumination device, and an image preprocessing unit.
[0113] The processing module is configured to perform training of the deep neural network, preprocessing of the image to be detected, model inference, and post-processing of the defect candidate region. The processing module includes a dual-branch feature extraction unit, a feature separation unit, and an adaptive post-processing unit.
[0114] The output module is used to visualize the defect detection results and the attention weight heatmap of the feature separation process. The output module includes a defect visualization interface and a feature analysis interface.
[0115] This system adopts a modular architecture of acquisition, processing, and output, with each module working collaboratively to achieve full automation of weld defect detection, making it suitable for industrial production line scenarios in rail vehicle manufacturing. The image acquisition module uses a highly uniform annular diffuse light source (color temperature 5500K±200K, illuminance 6000-12000 lux) to eliminate interference from metal reflections on the weld surface. The image preprocessing unit uses a combination of Gaussian filtering and median filtering for noise reduction, and a 12×9 checkerboard calibration board is used for distortion correction to ensure that the distortion coefficient is ≤0.008. The processing module is equipped with an NVIDIA Jetson Xavier NX edge computing box, supporting TensorRT acceleration, with a single-frame inference time of ≤50ms, meeting the real-time detection requirements of the production line. The output module's defect visualization interface uses different colors to mark defect types (red for microcracks, blue for porosity), and the feature analysis interface displays an attention weight heatmap, intuitively presenting the model's decision-making basis. This system completely eliminates the reliance on manual labor in traditional inspections, increasing inspection efficiency by more than three times and maintaining a stable accuracy rate of over 92%. It also boasts excellent scalability, adapting to the weld inspection needs of other large-scale engineering equipment such as tower cranes and construction hoists. Compared to traditional inspection systems, this system not only possesses precise inspection capabilities but also achieves traceability of the inspection process through a visual interface and structured data output, providing a comprehensive solution for industrial quality control.
[0116] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for detecting a surface defect of a weld based on deep learning, characterized by, The application relates to a defect detection method based on a deep neural network, and belongs to the technical field of welding defect detection. The method comprises the following steps: Collecting original images of a bogie weld surface, establishing a labeled data set containing a splash area, a defect area and a splash-defect coexisting area, and adopting a semi-supervised labeling strategy for the labeled data set; A deep neural network containing a double-branch feature extraction structure and a feature separation module is constructed, wherein a first branch is configured to extract optical reflection characteristic features of materials, and a second branch is configured to extract geometric topological morphological features of defects; The deep neural network is trained using the labeled data set, and a joint loss function containing a feature comparison mechanism is adopted in the training process, wherein the feature comparison mechanism is used to increase the distance between splash features and defect features in a feature space; A weld image to be detected is input into the trained deep neural network, a preliminary detection result is obtained through the feature separation module, the preliminary detection result is post-processed and optimized, and a final defect detection result is output; The step of inputting the weld image to be detected into the trained deep neural network and obtaining the preliminary detection result through the feature separation module comprises the following steps: The spatial correlation of double-branch fusion features is calculated through a self-attention mechanism to generate a spatial attention weight map; The spatial attention weight is constrained in combination with weld contour prior information to suppress invalid calculation of a background area; An edge-enhanced attention window is used to strengthen the defect feature response with a feature size smaller than a preset threshold value, and the edge-enhanced attention window adopts a local structure feature extraction and global attention weight fusion mode; The input features are reweighted in the spatial dimension based on the optimized attention weight to highlight the feature expression of a real defect area; The weighted feature map is classified in a pixel level through a classification head to output a defect detection result; The step of using the edge-enhanced attention window to strengthen the defect feature response with a feature size smaller than a preset threshold value comprises the following steps: For a microcrack area with a feature size smaller than a preset threshold value, an attention enhancement mode based on a local structure feature is adopted; An edge-oriented feature extraction operation is used to strengthen the continuity feature of a linear defect, and a learnable edge detection convolution kernel is used to extract local gradient information; Local structure features and global attention weights are fused and calculated to generate an edge-enhanced attention weight map; 2. The method of claim 1, wherein the method is based on deep learning. Based on the edge-enhanced attention weight map, the micro defect features are selectively strengthened to improve the detection rate of the micro defects. The step of collecting original images of a bogie weld surface and establishing a labeled data set containing a splash area, a defect area and a splash-defect coexisting area comprises the following steps: Original images of a bogie weld surface are collected to cover a weld main body area, a heat affected zone and a surrounding base material area; A real defect state of a sample is confirmed through a nondestructive testing method to form a basic labeled sample set; A complete labeled data set is constructed by adopting a semi-supervised labeling strategy, wherein: A splash interference label is labeled for an area where splash particles gather and no defects are confirmed; A corresponding defect category label is labeled for a defect area without splash coverage; 3. The method of claim 2, wherein the method is based on deep learning. A splash interference label and a defect category label are labeled for a splash coverage area where defects exist. The step of constructing the complete labeled data set by adopting the semi-supervised labeling strategy comprises the following steps: Training a basic segmentation model using a basic labeled sample set confirmed by non-destructive testing; Generating pseudo-labels for unlabeled regions using the basic segmentation model; Manually reviewing and correcting ambiguous regions in the pseudo-labels with confidence levels within a preset review interval; Quality inspection of the reviewed labeled results to form a final labeled data set.
4. The method of claim 1, wherein the method is based on deep learning. The steps of constructing the deep neural network comprising a double-branch feature extraction structure and a feature separation module include: In the first branch, a deep convolutional neural network structure is constructed to extract the optical reflection characteristic features of the material through multi-layer convolution operations, and the deep convolutional neural network comprises a convolution layer, a pooling layer and a normalization layer for capturing the difference features of the splash and the defect in reflectivity and surface roughness; In the second branch, a multi-scale hollow convolution structure is constructed to extract the geometric topological morphological features of the defect through parallel convolution layers with different hollow rates, and the multi-scale hollow convolution structure comprises a plurality of parallel hollow convolution branches that capture the linear continuity of micro-cracks and the circular closed morphological features of pores at different scales; The optical reflection characteristic features of the first branch and the geometric topological morphological features of the second branch are spliced in the channel dimension to form double-branch fusion features.
5. The method of claim 1, wherein: The steps of training the deep neural network using the labeled data set and adopting a joint loss function comprising a feature comparison mechanism during the training process further include: Evaluating the training status based on the classification performance of multi-class samples on the validation set, wherein the multi-class samples include only splash regions, explicit defect regions and splash-defect coexisting regions; Dynamically adjusting the weight distribution of each term in the joint loss function according to the feature separation effect index; Calculating the distribution difference of splash samples and defect samples in the feature space, and quantifying the feature separation degree based on the distribution difference; Adjusting the weight proportion of the classification loss and the feature comparison loss according to the feature separation degree, and increasing the weight proportion of the feature comparison loss when the feature separation degree is insufficient.
6. The method of claim 1, wherein the method is based on deep learning. The steps of post-processing and optimizing the preliminary detection results include: Post-processing and optimizing the defect candidate regions output by the feature separation module; Aggregating spatially related defect pixels by multi-neighbor connectivity analysis to form complete defect candidate regions; Calculating the average classification confidence in each connected domain and filtering real defect regions based on an adaptive confidence threshold; Performing morphological analysis and classification on the filtered defect regions to output the final defect detection results and confidence scores.
7. A deep learning-based weld seam surface defect detection system for implementing the deep learning-based weld seam surface defect detection method of any one of claims 1-6, characterized in that, It includes: An image acquisition module for acquiring original images of the surface of the weld of the bogie and correcting distortion, the image acquisition module comprising an industrial camera, a uniform illumination device and an image preprocessing unit; A processing module configured to perform training of the deep neural network, homologous preprocessing of the image to be detected, model inference and post-processing of the defect candidate region, the processing module comprising a double-branch feature extraction unit, a feature separation unit and an adaptive post-processing unit; An output module for visualizing and displaying the defect detection results and the attention weight heat map of the feature separation process, the output module comprising a defect visualization interface and a feature analysis interface.
Citation Information
Patent Citations
Weld joint detection method, system and device based on deep learning and storage medium
CN116385336A
Microchip appearance defect detection method based on convolutional neural network
CN119693363A