Welding defect detection method based on double-context adaptive fusion module
By introducing a dual-context adaptive fusion module and an improved loss function, the welding defect detection method solves the problems of stability and accuracy in complex environments, improves the ability to identify minute defects and the adaptability of the system, and achieves efficient detection and data management.
Patent Information
- Application Number
- CN202511717192.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-21
- Publication Date
- 2026-02-13
AI Technical Summary
Existing welding defect detection methods suffer from insufficient stability and reliability when facing complex and ever-changing industrial environments. They are particularly unstable in identifying novel defects and under complex background interference, and their computational complexity is high, making it difficult to effectively identify minute defects.
A welding defect detection method based on a dual-context adaptive fusion module is adopted. By data preprocessing, improving the convolutional network and loss function, and combining the DCAR module and FL-CE function, the accuracy and stability of weld defect rating are improved.
It significantly improves the detection rate and classification accuracy of minute defects, enhances the adaptability and robustness of the model, has strong system flexibility, supports industry standards and enterprise-defined requirements, and realizes traceability and data accumulation throughout the entire detection process.
Smart Images

Figure CN121527063A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of nondestructive testing technology, and in particular to a welding defect detection method based on a dual-context adaptive fusion module. Background Technology
[0002] Welding is a crucial joining process in modern industry, and its quality directly affects the structural safety and service life of critical equipment in aerospace, energy, and chemical industries. However, due to factors such as materials, processes, and environment, the welding process is highly susceptible to microscopic defects such as porosity, slag inclusions, lack of fusion, and cracks. These defects can significantly reduce structural strength and pose serious safety hazards. Therefore, accurate non-destructive testing of welds is a key step in ensuring project quality.
[0003] X-ray imaging, as a core non-destructive testing method, can effectively reveal the internal structure of workpieces. However, traditional inspection processes heavily rely on expert interpretation of film or digital images. This method is not only inefficient and costly, but its results are also heavily influenced by individual experience and condition, exhibiting strong subjectivity and consistency issues, making it difficult to meet the dual demands of modern industry for efficiency and objectivity.
[0004] For example, patent CN120726029A, entitled "A Defect Monitoring Method Based on a Visual Large Model," proposes a defect monitoring method based on a visual large model. Its monitoring process mainly consists of five core technologies: image enhancement and brightness correction, multi-level convolutional feature extraction, lightweight feature extraction module design, cross-scale feature fusion mechanism, and cosine similarity-based defect matching. First, the original image is enhanced by combining linear brightness correction and logarithmic image transformation, effectively improving uneven illumination and noise interference, providing high-quality input for subsequent processing. Second, basic features are extracted using continuous convolutional layers and pooling operations, and multi-scale features are gradually abstracted through a lightweight feature extraction module (containing multiple convolutional layers and feature weighting layers), reducing the number of parameters while maintaining feature expressive power. Then, a feature fusion module is introduced, integrating features of different scales through upsampling, reparameterized convolution, and feature enhancement modules, achieving complementarity between detailed and semantic information. Finally, by calculating the cosine similarity between the target fused features and historical features in a preset database, rapid defect matching and classification are achieved. While this method offers advantages in improving the automation and efficiency of defect detection, there is still room for improvement. First, it relies on historical features from a pre-set database for matching. In real-world industrial scenarios, defect types are diverse and dynamically changing, and the database's coverage and update frequency may be insufficient, resulting in limited ability to identify novel defects or defects with small sample sizes, thus challenging its generalization ability. Second, the feature extraction and fusion process involves multiple convolutions, sampling, and attention calculations, leading to high computational complexity. This complexity is easily affected by changes in training parameter weights, making it difficult to effectively train and accurately identify minute defects. Finally, the parameters in the image enhancement stage (such as α, β, and η) need to be manually set, lacking an adaptive adjustment mechanism. This can lead to instability under different lighting conditions or workpiece materials, and the lack of consideration for complex background interference may result in inconsistent enhancement effects or increased false detection rates.
[0005] Therefore, this monitoring method still faces significant challenges in dealing with complex and ever-changing industrial environments. In particular, its fixed-database-based matching mechanism exhibits limitations when facing novel defects or complex background interference. The parameters in the image enhancement stage rely on manual experience for setting, lacking adaptability to varying operating conditions, which to some extent affects the stability and reliability of the detection system. It is necessary to improve the ability to identify complex areas and enhance the accuracy of identifying a few types of defects to improve the applicability and robustness of this method in industrial practice. Summary of the Invention
[0006] The technical problem to be solved by the present invention is to provide a welding defect detection method based on a dual-context adaptive fusion module, which can comprehensively improve the accuracy, stability and long-term adaptability of weld defect rating by preprocessing the image, improving the convolutional network and loss function and developing a configurable rule system.
[0007] To solve the above-mentioned technical problems, the technical solution of the present invention is: a welding defect detection method based on a dual-context adaptive fusion module, the innovation of which is as follows: the specific detection method is as follows: S1: Data Acquisition and Data Construction S1.1: High-resolution weld images are acquired using industrial-grade digital X-ray imaging equipment, covering a variety of welding processes and material conditions; S1.2: Use professional annotation tools to manually annotate the acquired images. The annotation content includes the outline of the weld area and several typical defect categories. S1.3: Perform illumination and contrast preprocessing on the original image to eliminate uneven exposure, enhance the contrast of dark areas and details, make minor defects more visually prominent, and facilitate the subsequent extraction of distinctive features by the network. S1.4: Construct training, validation, and testing datasets based on labeled and enhanced images to serve as high-quality inputs for subsequent model training; S2: Improved Detection Network Construction and Optimization: S2.1: A dual-context adaptive sensing module—DCAR—is introduced into the YOLOv11 backbone network. The dual-context adaptive sensing module extracts local detail information and broader context information in parallel, and adaptively weights and fuses the two types of information. The dual-context adaptive sensing module is used to achieve both detail capture of minute defects and contextual understanding of the overall weld structure, thereby improving the detection rate of small cracks and pores and reducing false detections. S2.2. To improve the model's learning ability for difficult-to-classify samples, an improved focus loss and cross-entropy function are adopted to give higher training weights to low-confidence or easily confused samples, thereby enhancing the model's ability to distinguish between closely related categories that are not fused or not fully bonded. S3: Model Training, Validation, and Performance Evaluation A dual-model, two-stage training strategy is adopted to train separately for weld area detection and weld defect detection, in order to improve detection accuracy and efficiency. S4: Test Report and System Output S4.1: Integrate the detected defect locations, categories, quantification parameters, and self-configured rule rating results to generate a standardized assessment report; S4.2. The report also provides visual comparison charts, numerical tables, and confidence indicators to facilitate manual review and archiving; S4.3 supports exporting test reports as PDF or structured data and uploading them to the inspection management system, enabling process traceability and data accumulation.
[0008] Furthermore, in S1.3, to improve the visual visibility of minute defects, the original image is first illuminated using multi-scale Retinex (retinal cortex theory), and then local adaptive Gamma correction is used to enhance details in dark areas; the specific formula is as follows: (1) in It is the original pixel grayscale value (normalized to [0,1]). The variance is The Gaussian kernel, * represents the convolution operation. The enhanced pixel values are obtained by removing local mean brightness in equation (1) to highlight details, and then performing multi-scale combination on equation (1): (2) For different scales, this system uses a scale of 3. The corresponding weights are set to {0.33, 0.33, 0.34}; right Linear normalization yields Then, the local average brightness is defined as... Mean within the window ( (Take the maximum value of the length and width of the input image). (3) Seeking again Local average brightness corresponding to the coordinates: (4) in, , The minimum / maximum gamma is configurable (0.5 and 1.8 in this method). , This represents the statistical limit of the local mean. To prevent zero constant values, pixel transformation is performed last. (5) Local adaptive gamma correction is mainly applied to the normalization value of dark areas. To enhance the detail representation of defects, apply to bright areas. Prevent overexposure.
[0009] Furthermore, in step S2.1, 5*5 and 7*7 large receptive fields are used to extract overall structural information, which is then processed using Adaptive Fusion through channel weights. and To achieve dynamic equilibrium, the formula is as follows: (6) in Given the input feature map, Large receptive field convolutions (5x5 and 7x7) are used to extract contextual features. Average pooling is used to obtain channel statistics. Max pooling highlights salient regions. The sigmoid activation function is used to normalize the weights. Element-wise multiplication between channels. , To adaptively control the proportions of local and global features, the weight coefficients are used separately. Dual-context fusion feature output.
[0010] Furthermore, in S2.2, the focal loss and cross-entropy function are combined into the FL-CE (Focal Loss CrossEntropy) composite loss function. The focusing mechanism of Focal Loss and the stable gradient properties of standard Cross Entropy are explained in the following formulas: (7) This represents the total number of samples in a batch; that is, the number of samples calculated during each backpropagation of the network. The index of the i-th sample; The true label for sample i; It is the probability predicted by the model that the sample belongs to each category; (8) in This represents the total number of categories, specifically the number of weld defect types. This indicates that the i-th sample is predicted to be its true class. The probability, The focusing parameter is used to adjust the degree of suppression for easily classified samples. When = 0, it degenerates into standard cross-entropy. hour, Growth causes the model to reduce the weight of high-confidence samples; This is the category balance coefficient. (9), For category The number of samples, As a smoothing constant, it is generally taken as e or 1. A class balance coefficient is introduced to balance the uneven number of samples between different classes and prevent the majority of samples, such as the strip defect class, from dominating the training. It is a constant used to balance the proportion of the Focal portion and the standard CE.
[0011] Furthermore, in S3, a dual-model, two-stage training strategy is used to train for weld area detection and weld defect detection respectively, in order to improve detection accuracy and efficiency; specifically: 1) Weld area inspection training The goal of this stage is to train the YOLOv11 model to accurately locate the weld area, eliminate background interference, and increase the proportion of small defects, thereby optimizing subsequent defect detection. The specific steps are as follows: The weld defect dataset was divided into training, validation, and test sets in a 70:15:15 ratio. During the training phase, geometric transformation, noise injection, and random contrast perturbation were introduced. The batch size was set to 16, the learning rate was 0.001, the AdamW optimizer was used, and the StepLR learning rate scheduling strategy was adopted to set the learning rate to 0.001, the batch size to 16, and the training was conducted for 300 rounds. 2) Model Validation and Performance Evaluation Comparative experiment: A comparative experiment was conducted with the original YOLOv11 to verify the effectiveness of DCAR in improving the Conv and FL-CE composite loss function; Evaluation metrics: Precision and Recall are used to evaluate model performance; Accuracy refers to the proportion of correctly classified samples out of the total number of samples in the prediction, reflecting the overall predictive performance of the model; the higher the value, the more accurate the overall prediction of the model. The calculation formula is as follows: (10) Recall refers to the proportion of samples that are predicted to be positive out of all true positive samples, reflecting the model's ability to identify positive samples; the higher the value, the stronger the model's ability to identify positive samples. The calculation formula is as follows: (11) Among them, TP (True Positive) represents the number of objects predicted as positive when the object is a positive class; TN (True Negative) represents the number of objects predicted as negative when the object is a negative class; FP (False Positive) represents the number of objects predicted as positive when the object is a negative class; and FN (False Negative) represents the number of objects predicted as negative when the object is a positive class.
[0012] The advantages of this invention are: 1) In this invention, by implementing illumination and contrast preprocessing (Retinex (retinal cortex theory) to improve the visual visibility of minute defects and local adaptive Gamma correction to enhance details in dark areas) and introducing the DCAR module and FL-CE (Focal Loss Cross-Entropy) function, the model's detection rate of fine cracks is increased from 81% to 89%, and the classification accuracy of easily confused defects such as incomplete fusion and incomplete penetration is improved by 5.2%, reaching 96.5%.
[0013] 2) The system of the present invention is highly flexible and easy to deploy and integrate; it supports the industry standard "NB / T47013-2023 Non-destructive Testing of Pressure Equipment" while the rating rules are configurable, and can flexibly adapt to standard updates or enterprise-defined requirements; the system outputs structured reports and seamlessly connects to the upper-level management system, realizing traceability and data accumulation of the entire testing process. Attached Figure Description
[0014] The present invention will now be described in further detail with reference to the accompanying drawings and specific embodiments.
[0015] Figure 1 This is a flowchart of a welding defect detection method based on a dual-context adaptive fusion module according to the present invention.
[0016] Figure 2 This is a comparison image of a preprocessed image and the original image of a welding defect detection method based on a dual-context adaptive fusion module according to the present invention.
[0017] Figure 3 The welding defect detection method based on the dual context adaptive fusion module of the present invention uses YOLOv11 as the basic framework diagram.
[0018] Figure 4 The detection effect diagram of a welding defect detection method based on a dual-context adaptive fusion module according to the present invention. Detailed Implementation
[0019] 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.
[0020] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0021] Example: The specific technical implementation of the welding radiographic film defect detection and rating system based on multi-dimensional feature fusion proposed in this invention is as follows: Figure 1 As shown, the process mainly includes four steps: Step 1, collection, construction and preprocessing of weld defect data dataset; Step 2, improvement of weld defect detection network structure; Step 3, model training, verification and performance evaluation; Step 4, adaptive evaluation and system output.
[0022] Step 1: Collection, Construction, and Preprocessing of Weld Defect Dataset High-resolution X-ray image data was acquired using a DR digital imaging system. The data came from DR images of pressure pipeline circumferential welds provided by the Kunshan Branch of the Jiangsu Special Equipment Inspection Institute. Metadata for each image was recorded (from DICONDE or DICOM file fields). Manual annotation was performed using Labelimg software, including annotations of the weld area and seven weld defect types (cracks, lack of fusion, incomplete penetration, strip defects, circular defects, root concavity, and root bite). From 4200 weld images, the following weld defects were identified: 290 cracks, 364 lack of fusion, 466 incomplete penetration, 1480 strip defects, 1354 circular defects, 236 root concavity, and 210 root bite. To improve the visual visibility of minute defects, multi-scale Retinex (retinal cortex theory) deillumination was first applied to the original images, followed by local adaptive Gamma correction to enhance details in dark areas. The specific formula is as follows: (1) in It is the original pixel grayscale value (normalized to [0,1]). The variance is The Gaussian kernel, * represents the convolution operation. The enhanced pixel values are obtained by removing local mean brightness in equation (1) to highlight details, and then performing multi-scale combination on equation (1): (2) For different scales, this system uses a scale of 3. The corresponding weights are set to {0.33, 0.33, 0.34}; right Linear normalization yields Then, the local average brightness is defined as... Mean within the window ( (Take the maximum value of the length and width of the input image). (3) Seeking again Local average brightness corresponding to the coordinates: (4) in, , The minimum / maximum gamma is configurable (0.5 and 1.8 in this method). , This represents the statistical limit of the local mean. To prevent zero constant values, pixel transformation is performed last. (5) Local adaptive gamma correction is mainly applied to the normalization value of dark areas. To enhance the detail representation of defects, apply to bright areas. To prevent overexposure, the pre-processed image is compared with the original image. Figure 2 As shown.
[0023] Step 2: Improve the structure of the weld defect detection network The improved weld defect detection network uses YOLOv11 as its basic framework, such as... Figure 3 As shown, the improvements to the network mainly include two aspects: replacing the Conv module in the Bottleneck area of the C3K2 module in the Backbone with the DCAR (Dual Context Adaptive Receptive field) module, and introducing the FL-CE (Focal Loss Cross-Entropy) function in the Head to improve feature representation ability and small target detection accuracy.
[0024] 1) The main idea of the DCAR (Dual Context Adaptive Receptive field) module is to simultaneously capture local details and global contextual information, and dynamically adjust the ratio of the two through an adaptive weight mechanism, enabling the convolutional network to perceive both minute defects and macroscopic structures in weld images. The dual-branch structure of DCAR includes: LocalPath (local branch): Uses 3x3 convolution to extract local texture and detail features of weld defects. GlobalPath (global branch): Uses 5x5 and 7x7 large receptive fields to extract overall structural information, and then uses Adaptive Fusion to apply channel weights. and To achieve dynamic equilibrium, the formula is as follows: (6) in Given the input feature map, Large receptive field convolutions (5x5 and 7x7) are used to extract contextual features. Average pooling is used to obtain channel statistics. Max pooling highlights salient regions. The sigmoid activation function is used to normalize the weights. Element-wise multiplication between channels. , To adaptively control the proportions of local and global features, the weight coefficients are used separately. Dual-context fusion feature output.
[0025] The main advantages of the DCAR module are: 1. Traditional convolutional kernels have a fixed size, causing the network to only perceive features at a fixed scale. The DCAR module, however, automatically balances through a dual-path structure, automatically adjusting its response domain when facing defects of different scales (porosity, cracks, incomplete penetration, etc.), resulting in more stable recognition. 2. Through... The two types of features are dynamically fused, enabling the model to still identify dark cracks in high grayscale areas and improving the recognition ability of complex areas such as edges and roots. 3. Average pooling (AvgPool) captures smooth background features, while max pooling (MaxPool) focuses on significant defects. The combination of the two forms a more stable weighting mechanism, and the attention is adaptively adjusted by the grayscale changes in the weld area, enhancing the robustness of feature representation.
[0026] 2) Design the FL-CE (Focal Loss Cross-Entropy) function to improve classification loss. In weld radiographic inspection, the number of samples varies greatly among different defect types (such as porosity, lack of fusion, incomplete penetration, and cracks). Minor defects, in particular, have a very small sample size and subtle appearance differences, easily leading to sample imbalance and class confusion. Traditional cross-entropy (CE) loss functions are prone to being dominated by the majority class in such cases, resulting in low accuracy in identifying minority class defects. Therefore, this invention proposes an improved FL-CE (Focal Loss Cross Entropy) composite loss function. The focusing mechanism of Focal Loss and the stable gradient properties of standard Cross Entropy are explained in the following formulas: (7) This represents the total number of samples in a batch; that is, the number of samples calculated during each backpropagation of the network. The index of the i-th sample; The true label for sample i; It is the probability predicted by the model that the sample belongs to each category; (8) in This represents the total number of categories, specifically the number of weld defect types. This indicates that the i-th sample is predicted to be its true class. The probability, The focusing parameter is used to adjust the degree of suppression for easily classified samples. When = 0, it degenerates into standard cross-entropy. hour, Growth causes the model to reduce the weight of high-confidence samples; This is the category balance coefficient. (9), For category The number of samples, As a smoothing constant, it is generally taken as e or 1. A class balance coefficient is introduced to balance the uneven number of samples between different classes and prevent the majority of samples, such as the strip defect class, from dominating the training. It is a constant used to balance the proportion of the Focal portion and the standard CE.
[0027] Step 3: Model Training, Validation, and Performance Evaluation This invention employs a dual-model, two-stage training strategy, training separately for weld area detection and weld defect detection, in order to improve detection accuracy and efficiency.
[0028] 1. First stage: Weld seam inspection model training and dataset reconstruction 1) Weld area inspection training The goal of this stage is to train the YOLOv11 model to accurately locate the weld area, eliminate background interference, and increase the proportion of small defects, thereby optimizing subsequent defect detection. The specific steps are as follows: The weld defect dataset was divided into training, validation, and test sets in a 70:15:15 ratio. During the training phase, geometric transformations (small-angle rotation, scale transformation, random cropping), local occlusion simulation (simulating film blemishes), noise injection (Gaussian / Poisson), and random contrast perturbation were introduced. The batch size was set to 16, the learning rate to 0.001, and the AdamW optimizer was used with a StepLR learning rate scheduling strategy. The training run lasted for 300 epochs.
[0029] 2) Model Validation and Performance Evaluation Comparative experiment: A comparative experiment was conducted with the original YOLOv11 to verify the effectiveness of DCAR in improving the Conv and FL-CE composite loss function.
[0030] Evaluation metrics: Precision and Recall were used to evaluate model performance.
[0031] Accuracy refers to the proportion of correctly classified samples out of the total number of samples in a prediction, reflecting the overall predictive performance of the model. A higher value indicates a more accurate overall prediction. The calculation formula is as follows: (10) Recall refers to the proportion of samples that are predicted to be positive out of all true positive samples, reflecting the model's ability to identify positive samples; the higher the value, the stronger the model's ability to identify positive samples. The calculation formula is as follows: (11) Among them, TP (True Positive) represents the number of objects predicted as positive when the object is a positive class; TN (True Negative) represents the number of objects predicted as negative when the object is a negative class; FP (False Positive) represents the number of objects predicted as positive when the object is a negative class; and FN (False Negative) represents the number of objects predicted as negative when the object is a positive class.
[0032] Experimental Results: Ablation experiments were conducted using the unmodified YOLOv11 model, the model with only DCAR-modified Conv, the model with only FL-CE composite loss function, and the model with both DCAR and FL-CE composite loss function. The results are shown in Table 1. Table 1 Comparison of ablation experiments
[0033] The average detection accuracy of the YOLOv11 model using the DCAR method and the FL-CE composite loss function reached 96.50%. Compared with the original YOLOv11 model, it showed significant improvements in the weld area and various weld defects (cracks, lack of fusion, incomplete penetration, strip defects, circular defects, root concavity, and root seizure), effectively reducing false positives and false negatives. Figure 4 The improved YOLOv11 model is demonstrated in its ability to detect weld defects.
[0034] Step 4: Adaptive Evaluation and System Output This invention is based on the Pyside6 open-source framework to build an intelligent visualization system. It implements a complete workflow system from batch image import, weld defect area identification, image reconstruction and preprocessing, defect detection, rule configuration, and substrate rating. The system preprocesses the original images using multi-scale Retinex illumination and then enhances dark area details through local adaptive Gamma correction, improving the visual visibility of minute defects. The DCAR (Dual Context Adaptive Receptive field) module replaces the Conv module of the Bottleneck in the C3K2 module of the Backbone layer, and the FL-CE (Focal Loss Cross-Entropy) function improves feature representation ability and small target detection accuracy. The optimized defect detection model can accurately extract defect information of seven types of defects, including cracks, lack of fusion, incomplete penetration, strip defects, circular defects, root concavity, and root bite. The parameters extracted from the DICONDE file are then substituted into the rating algorithm designed in the "NB / T47013-2023 Non-destructive Testing of Pressure Equipment" standard to evaluate the quality of the film. Finally, the user-defined configuration file performs adaptive evaluation under different rules, providing a visual analysis interface and automatic inspection report. The inspection report can be exported as PDF or structured data (JSON / CSV) and uploaded to the inspection management system to achieve process traceability and data accumulation.
[0035] Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely illustrative of the principles of the present invention. Various changes and modifications can be made to the present invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the present invention as claimed.
Claims
1. A welding defect detection method based on a dual-context adaptive fusion module, characterized in that: The specific testing methods are as follows: S1: Data Acquisition and Data Construction S1.1: High-resolution weld images are acquired using industrial-grade digital X-ray imaging equipment, covering a variety of welding processes and material conditions; S1.2: Use professional annotation tools to manually annotate the acquired images. The annotation content includes the outline of the weld area and several typical defect categories. S1.3: Perform illumination and contrast preprocessing on the original image to eliminate uneven exposure, enhance the contrast of dark areas and details, make minor defects more visually prominent, and facilitate the subsequent extraction of distinctive features by the network. S1.4: Construct training, validation, and testing datasets based on labeled and enhanced images to serve as high-quality inputs for subsequent model training; S2: Improved Detection Network Construction and Optimization: S2.1: A dual-context adaptive sensing module—DCAR—is introduced into the YOLOv11 backbone network. The dual-context adaptive sensing module extracts local detail information and broader context information in parallel, and adaptively weights and fuses the two types of information. The dual-context adaptive sensing module is used to achieve both detail capture of minute defects and contextual understanding of the overall weld structure, thereby improving the detection rate of small cracks and pores and reducing false detections. S2.
2. To improve the model's learning ability for difficult-to-classify samples, an improved focus loss and cross-entropy function are adopted to give higher training weights to low-confidence or easily confused samples, thereby enhancing the model's ability to distinguish between closely related categories that are not fused or not fully bonded. S3: Model Training, Validation, and Performance Evaluation A dual-model, two-stage training strategy is adopted to train separately for weld area detection and weld defect detection, in order to improve detection accuracy and efficiency. S4: Test Report and System Output S4.1: Integrate the detected defect locations, categories, quantification parameters, and self-configured rule rating results to generate a standardized assessment report; S4.
2. The report also provides visual comparison charts, numerical tables, and confidence indicators to facilitate manual review and archiving; S4.3 supports exporting test reports as PDF or structured data and uploading them to the inspection management system, enabling process traceability and data accumulation.
2. The welding defect detection method based on a dual-context adaptive fusion module according to claim 1, characterized in that: In step S1.3, to improve the visual visibility of minute defects, the original image is first illuminated using multi-scale Retinex (retinal cortex theory), and then local adaptive Gamma correction is used to enhance details in dark areas; the specific formula is as follows: (1) in It is the original pixel grayscale value (normalized to [0,1]). The variance is The Gaussian kernel, * represents the convolution operation. The enhanced pixel values are obtained by removing local mean brightness in equation (1) to highlight details, and then performing multi-scale combination on equation (1): (2) For different scales, this system uses a scale of 3. The corresponding weights are set to {0.33, 0.33, 0.34}; right Linear normalization yields Then, the local average brightness is defined as... Mean within the window ( (Take the maximum value of the length and width of the input image). (3) Seeking again Local average brightness corresponding to the coordinates: (4) in, , The minimum / maximum gamma is configurable (0.5 and 1.8 in this method). , This represents the statistical limit of the local mean. To prevent zero constant values, pixel transformation is performed last. (5) Local adaptive gamma correction is mainly applied to the normalization value of dark areas. To enhance the detail representation of defects, apply to bright areas. Prevent overexposure.
3. The welding defect detection method based on a dual-context adaptive fusion module according to claim 1, characterized in that: In step S2.1, 5*5 and 7*7 large receptive fields are used to extract overall structural information, and then Adaptive Fusion is used to extract information through channel weights. and To achieve dynamic equilibrium, the formula is as follows: (6) in Given the input feature map, Large receptive field convolutions (5x5 and 7x7) are used to extract contextual features. Average pooling is used to obtain channel statistics. Max pooling highlights salient regions. The sigmoid activation function is used to normalize the weights. Element-wise multiplication between channels. , To adaptively control the proportions of local and global features, the weight coefficients are used separately. Dual-context fusion feature output.
4. The welding defect detection method based on a dual-context adaptive fusion module according to claim 1, characterized in that: The focal loss and cross-entropy function in S2.2, and the FL-CE (Focal Loss Cross Entropy) composite loss function. The focusing mechanism of Focal Loss and the stable gradient properties of standard Cross Entropy are explained in the following formulas: (7) This represents the total number of samples in a batch; that is, the number of samples calculated during each backpropagation of the network. The index of the i-th sample; The true label for sample i; It is the probability predicted by the model that the sample belongs to each category; (8) in This represents the total number of categories, specifically the number of weld defect types. This indicates that the i-th sample is predicted to be its true class. The probability, The focusing parameter is used to adjust the degree of suppression for easily classified samples. When = 0, it degenerates into standard cross-entropy. hour, Growth causes the model to reduce the weight of high-confidence samples; This is the category balance coefficient. (9), For category The number of samples, As a smoothing constant, it is generally taken as e or 1. A class balance coefficient is introduced to balance the uneven number of samples between different classes and prevent the majority of samples, such as the strip defect class, from dominating the training. It is a constant used to balance the proportion of the Focal portion and the standard CE.
5. The welding defect detection method based on a dual-context adaptive fusion module according to claim 1, characterized in that: The S3 employs a dual-model, two-stage training strategy, training separately for weld area detection and weld defect detection to improve detection accuracy and efficiency; specifically: 1) Weld area inspection training The goal of this stage is to train the YOLOv11 model to accurately locate the weld area, eliminate background interference, and increase the proportion of small defects, thereby optimizing subsequent defect detection. The specific steps are as follows: The weld defect dataset was divided into training, validation, and test sets in a 70:15:15 ratio. During the training phase, geometric transformation, noise injection, and random contrast perturbation were introduced. The batch size was set to 16, the learning rate was 0.001, the AdamW optimizer was used, and the StepLR learning rate scheduling strategy was adopted to set the learning rate to 0.001, the batch size to 16, and the training was conducted for 300 rounds. 2) Model Validation and Performance Evaluation Comparative experiment: A comparative experiment was conducted with the original YOLOv11 to verify the effectiveness of DCAR in improving the Conv and FL-CE composite loss function; Evaluation metrics: Precision and Recall are used to evaluate model performance; Accuracy refers to the proportion of correctly classified samples out of the total number of samples in the prediction, reflecting the overall predictive performance of the model; the higher the value, the more accurate the overall prediction of the model. The calculation formula is as follows: (10) Recall refers to the proportion of samples that are predicted to be positive out of all true positive samples, reflecting the model's ability to identify positive samples; the higher the value, the stronger the model's ability to identify positive samples. The calculation formula is as follows: (11) Among them, TP (True Positive) represents the number of objects predicted as positive when the object is a positive class; TN (True Negative) represents the number of objects predicted as negative when the object is a negative class; FP (False Positive) represents the number of objects predicted as positive when the object is a negative class; and FN (False Negative) represents the number of objects predicted as negative when the object is a positive class.
Citation Information
Patent Citations
Defect monitoring method based on visual large model
CN120726029A