A deep learning-based welding defect classification method and system
By building a feature-fused CNN model using deep learning technology, the problems of low precision and poor real-time performance in traditional welding defect detection methods are solved, and efficient and accurate welding defect identification and classification are achieved.
Patent Information
- Application Number
- CN202510430613.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-08
- Publication Date
- 2025-10-17
- Estimated Expiration
- 2045-04-08
AI Technical Summary
Existing welding defect detection methods rely on manually designed features and traditional machine learning algorithms, which are difficult to adapt to complex and changeable welding defects, resulting in low detection accuracy and inability to meet real-time requirements.
Using deep learning technology, a feature-fused CNN image recognition and classification model is constructed. Through multi-layer feature fusion and adaptive feature weighting mechanism, combined with cross-entropy loss function and regularization technology, the model training process is optimized to achieve automated welding defect recognition.
It significantly improves the accuracy and efficiency of welding defect classification, enhances the robustness and applicability of the model, meets the real-time detection needs of industrial sites, simplifies the operating process and reduces costs.
Smart Images

Figure CN120236142B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of image processing, in particular to a welding defect classification method and system based on deep learning. BACKGROUND
[0002] Welding defect detection and classification is an important quality control task in industrial manufacturing, especially in the field of automation and intelligent manufacturing. Its accuracy and real-time performance directly affect the production efficiency and product quality. Traditional welding defect detection methods mainly rely on image processing techniques and manual feature extraction, such as edge detection, morphological operations, and gray-level co-occurrence matrix. These methods rely on manually designed features and have strong limitations. When dealing with complex and variable welding defects, they often cannot accurately extract effective features, resulting in low detection accuracy. At the same time, traditional machine learning algorithms, such as support vector machines and K-nearest neighbor algorithms, also have difficulties in processing high-dimensional data, and cannot fully exploit deep feature information in images, thus having obvious shortcomings in defect recognition and classification accuracy.
[0003] In recent years, deep learning technology, especially convolutional neural networks (CNN), has made significant progress in the field of computer vision, especially in image classification and object detection tasks. Convolutional neural networks can automatically learn features extracted from raw data, greatly reducing the dependence on manual feature engineering. Ario et al. developed an artificial neural network (ANN) to extract molten pool geometric features for welding quality control, but it still has shortcomings in detecting welding defects with high precision; Kovacevic et al. based on a classic neural network, established a model of molten pool size information and back weld width, but due to the limited feature extraction capability of the algorithm, the accuracy of detecting welding defects is not high; Liu Xinfei et al. used extracted molten pool length, width, area, and trailing angle as input to a neural network, and the proposed neural network model accurately predicted the change in back weld width of the molten pool, but it could not accurately detect welding defects; He Deqiang proposed an intelligent model for welding quality detection based on attention balance context Mask R-CNN, which accurately predicted welding defects, but due to its reliance on ultrasonic detection images, it could not be used for real-time detection; Zhang Zefa used CNN and welding images to study online defect detection of robot arc welding aluminum alloy based on deep learning, although the model accurately predicted welding defects, it lacked analysis of the welding mechanism of defect prediction; Guo proposed a welding defect classification method based on lightweight CNN, which visualized the feature data of each convolutional layer to verify the feasibility of the model and improve the interpretability of the model, but it lacked robustness in various welding scenarios. These models have achieved high-precision defect prediction in specific scenarios based on CNN and its improved algorithms, but still have certain shortcomings.
[0004] In existing research, Li et al. in Defects detection of GMAW process based on convolutional neural network algorithm developed a welding defect prediction model based on convolutional neural network (CNN) for welding defect detection in the gas metal arc welding (GMAW) process, combined with feature extraction and processing of molten pool images, significantly improving the accuracy and robustness of defect detection. The scheme first develops a visual perception system, which successfully solves the problem of arc light interference in the welding process through the arrangement of optical filters and specific angle cameras, and obtains clear molten pool images. Using image processing algorithms, the system pre-processes the original image, including defining the region of interest (ROI), morphological filtering and affine transformation, to eliminate the influence of arc light interference and welding spatter on the image, and extract high-quality molten pool boundary images. The image preprocessing steps are as shown in Figure 1 .
[0005] In model design, the research uses CNN to automatically extract high-dimensional visual features from a large number of molten pool images, analyzes key features in the molten pool (such as black holes in the middle of the molten pool, pores at the tail of the molten pool and slag inclusion at the edge of the molten pool) combined with welder experience, and the model training process architecture is as shown in Figure 2 . These features are used to predict welding defects such as burn-through, porosity and slag inclusion. By optimizing network parameters (convolution kernel size, batch size, learning rate, etc.), the model achieves more than 97% prediction accuracy and exhibits strong robustness in various welding scenarios. This research has made significant progress in accuracy and robustness, but there are still some shortcomings in cross-scene generality and adaptability to different welding parameter changes. On the other hand, the image processing steps of this method are complex, which will increase the calculation time and affect the application of the system under extreme real-time requirements. SUMMARY
[0006] In view of this, the present application provides a welding defect classification method and system based on deep learning, which realizes efficient and accurate welding defect identification through deep learning technology, and significantly improves the efficiency and reliability of industrial quality monitoring.
[0007] The present application discloses a welding defect classification method based on deep learning, which comprises:
[0008] Step 1: Collect welding images and use them as training samples in the training set, and pre-process the welding images in the training set;
[0009] Step 2: Construct a CNN image recognition and classification model with feature fusion;
[0010] Step 3: Train the CNN image recognition and classification model in step 2 using the training samples in step 1 to obtain a trained CNN image recognition and classification model;
[0011] Step 4: Input the welding image to be classified and recognized into the trained CNN image recognition and classification model, and obtain the defect category to which the welding image belongs through model inference.
[0012] Further, the step 2 comprises:
[0013] The feature-fused CNN image recognition and classification model comprises, in sequence, a data feature fusion layer, a first pooling layer, a deep feature fusion layer, a second pooling layer, a feature abstract representation layer, a third pooling layer, a feature high-level representation layer, a fourth pooling layer, a first full connection layer, a second full connection layer, a third full connection layer, and a Softmax layer.
[0014] Data feature fusion layer:
[0015] After inputting the original welding image, different scale features are extracted through multiple parallel convolution operations, the expression ability of the model for the defect area is enhanced through integrating features of different channels, the network not only extracts deep convolution features but also strengthens the main features of the welding defects, so that the subsequent layers can more accurately identify and classify different types of welding defects; the different scale features include edges and textures.
[0016] First pooling layer:
[0017] The feature map generated by the data feature fusion layer is subjected to maximum pooling to reduce the spatial dimension of the feature map.
[0018] Deep feature fusion layer:
[0019] The pooled feature map is further fused to integrate information of different channels, and the feature expression ability is enhanced by using cross-layer connection or channel attention mechanism, so that the model can capture the morphology and structure of the welding defects.
[0020] Second pooling layer:
[0021] The output of the deep feature fusion layer is subjected to a pooling operation while retaining the main features.
[0022] Feature abstract representation layer:
[0023] The pooled deep feature map is subjected to global average pooling or other dimension reduction strategies to extract global context information and further compress the feature representation.
[0024] Third pooling layer:
[0025] The pooling operation is performed again to remove redundant information and ensure that only the most representative defect features are retained.
[0026] Feature high-level representation layer:
[0027] Further refine the high-level semantic features through nonlinear transformation and feature compression, so that different types of welding defects can be more accurately distinguished;
[0028] Fourth pooling layer:
[0029] Further reduce the feature dimension;
[0030] First, second and third fully connected layers:
[0031] The flattened high-level features are sequentially passed through multiple fully connected layers to learn high-dimensional mapping relationships and improve classification performance;
[0032] Softmax layer:
[0033] The final output of the third fully connected layer is passed through the Softmax layer to calculate the probability distribution of each class, and finally output the defect class to which the welding image belongs, realizing automatic defect recognition.
[0034] Further, the step 3 comprises:
[0035] The CNN image recognition and classification model uses a cross-entropy loss function as the objective function. In the welding defect recognition task, the output of the CNN image recognition and classification model is the probability distribution of each defect class. The cross-entropy loss function calculates the matching degree between the predicted probability and the true label, guides the CNN image recognition and classification model to gradually optimize the parameters, and performs regularization processing based on the optimized parameters to make the network finally converge, obtaining the trained CNN image recognition and classification model.
[0036] Further, the cross-entropy loss function is defined as:
[0037] Let the true class label of each training sample in the training set be y, and the output of the CNN image recognition and classification model be the probability distribution p of the class; if y is the One-hot encoded true label vector, then the cross-entropy loss function is defined as:
[0038]
[0039] Where N is the number of batch samples, C is the number of classification categories, y ij represents the true label value of the i-th training sample in the j-th class; p ij represents the predicted probability of the i-th sample being classified as the j-th welding defect, and the class label includes pores, slag, and weld-through. The calculation method is:
[0040]
[0041] wherein z ij is the network output before the Softmax activation function, i.e. the logit value of the i-th sample for the target class j, z ik is the logit value of the i-th sample for any class k.
[0042] Further, the cross-entropy loss function aims to minimize the difference between the predicted distribution p of the CNN image recognition and classification model and the true distribution y; when the predicted probability p ij of the CNN image recognition and classification model tends to the label value y ij of the true class, i.e. p ij → 1, the corresponding loss value -log(p ij )→ 0; on the contrary, when p ij → 0, the loss value tends to infinity.
[0043] Further, the CNN image recognition and classification model optimizes parameters, including:
[0044] Through the backpropagation algorithm, the CNN image recognition and classification model updates parameters using the Adam optimizer, and the parameter update formula is:
[0045]
[0046] wherein θ t represents the model parameters of the t-th iteration; θ t+1 represents the model parameters after the t-th iteration; η represents the learning rate; m t and v t are the first-order momentum estimate and the second-order momentum estimate of the gradient, respectively; ε is a constant.
[0047] Further, the based on the optimized parameters is subjected to regularization processing, including:
[0048] The expression of the regularization is:
[0049]
[0050] wherein λ is the weight of the regularization strength, ||θ|| 2 is the L2 norm of the model parameters, L total is the total loss function, and L is the cross-entropy loss function.
[0051] Further, the step 4 includes: after inputting the welding image to be classified into the trained CNN image recognition and classification model, normalizing the extracted features through the Softmax classification layer, and outputting the probability distribution of the sample belonging to each defect class, wherein the probability value p ijThe prediction probability of the i-th sample being classified as the j-th welding defect is represented, and the category corresponding to the maximum probability value is selected as the final defect classification result.
[0052] The application also discloses a welding defect classification system based on deep learning, which is used for implementing the welding defect classification method based on deep learning.
[0053] The preprocessing module is used for collecting welding images and taking the welding images as training samples in a training set, and pre-processing the welding images in the training set.
[0054] The model construction module is used for constructing a CNN image recognition and classification model with feature fusion.
[0055] The model training module is used for training the CNN image recognition and classification model by using the training samples, and obtaining the trained CNN image recognition and classification model.
[0056] The defect classification module is used for inputting the welding image to be classified and recognized into the trained CNN image recognition and classification model, and obtaining the defect category to which the welding image belongs through model inference.
[0057] Due to the above technical solutions, the application has the following advantages:
[0058] 1. In the CNN architecture of the application, a deep feature fusion mechanism is proposed for integrating features of different depths across layers. By combining low-level and high-level features, the network can maintain both detailed information and abstract information, thereby improving the robustness and accuracy of defect recognition. The fusion of low-level features (edge, texture) and high-level features (shape, defect position, etc.) ensures complete representation of welding defects. The fusion technology of low-level features and high-level features ensures effective integration and representation of deep features.
[0059] 2. The application introduces an adaptive feature weighting mechanism, which allows the model to dynamically weight the extracted features between different convolution layers. During the model training process, the network can learn the weighting coefficients of different levels of features, and weight and fuse them according to the importance of each layer of features, thereby improving the recognition ability of key features. In the deep neural network, the adaptive weighting strategy is used to weight and fuse the output features of different convolution layers.
[0060] 4.The application significantly improves the accuracy and efficiency of welding defect classification by using deep convolutional neural networks and feature fusion mechanisms. Multi-level convolutional neural networks can automatically extract detailed features and abstract features from welding images, avoiding the dependence on manually designed features in traditional methods. In complex welding images, especially in the case of small defects and multi-class defects, the application shows higher accuracy and robustness, effectively solving the shortcomings of traditional methods in recognition accuracy and generalization ability.
[0061] In addition, combined with multi-scale convolution kernel parallel feature extraction and pooling operation, the computational amount of the model is significantly optimized, and the processing speed is improved, meeting the demand of real-time detection in industrial field. The feature fusion mechanism further integrates low-level and high-level feature information, so that the model can fully capture the complex patterns in the welding image and reduce the error caused by external interference such as light and noise. This innovative design ensures the stability and applicability of the application in complex industrial environments.
[0062] 5.The application uses deep learning technology to realize automatic welding defect classification, which can complete feature extraction and classification tasks without human intervention, simplifying the operation process and improving the detection efficiency. At the same time, through the optimization of training method and learning rate adjustment strategy, the convergence speed and classification performance of the model are enhanced, reducing the development and running cost, and having wide industrial application value. BRIEF DESCRIPTION OF DRAWINGS
[0063] In order to more clearly illustrate the technical solutions in the embodiments of the application, the following will briefly introduce the drawings needed to be used in the embodiment description. Obviously, the drawings in the following description are only some embodiments described in the application, and other drawings can also be obtained by those skilled in the art according to these drawings.
[0064] Figure 1 It is a schematic diagram of image preprocessing in the prior art;
[0065] Figure 2 It is a schematic diagram of model training process architecture in the prior art;
[0066] Figure 3 It is a flowchart of a welding defect classification method based on deep learning according to an embodiment of the application;
[0067] Figure 4 It is a general framework diagram of CNN image recognition and classification model according to an embodiment of the application. DETAILED DESCRIPTION
[0068] The application will be further described in conjunction with the drawings and examples. The described examples are only a part of the examples of the application, rather than all the examples. All other examples obtained by those of ordinary skill in the art shall fall within the scope of protection of the examples of the application.
[0069] The application aims to solve the key technical problems existing in the traditional welding defect detection method, including low defect recognition accuracy, feature extraction limitation and poor real-time performance. The existing methods usually rely on artificial design features and traditional machine learning algorithms, which are difficult to adapt to the complexity and diversity of welding defect morphology, especially when facing fuzzy boundaries and large texture changes, the accuracy of detection and classification decreases significantly. Moreover, the traditional method has low calculation efficiency and cannot meet the real-time demand of defect detection in industrial field. Therefore, referring to Figure 3 , the application provides an embodiment of a welding defect classification method based on deep learning, which comprises:
[0070] S1: Collecting welding images as training samples in the training set and preprocessing the welding images in the training set.
[0071] The welding image is input into the system through the camera, visual sensor or other devices as the input data of the classification system. Then the image is preprocessed, denoised, normalized and grayscale to eliminate noise and unnecessary interference in the image, improve the quality of the image and ensure the accuracy of subsequent processing.
[0072] S2: Constructing a CNN image recognition and classification model with feature fusion.
[0073] Referring to Figure 4 , the CNN image recognition and classification model with feature fusion comprises a feature fusion layer, a first pooling layer, a deep feature fusion layer, a second pooling layer, a feature abstract representation layer, a third pooling layer, a feature high-level representation layer, a fourth pooling layer, a first full connection layer, a second full connection layer, a third full connection layer and a Softmax layer connected in turn; different levels of features are integrated through a multi-stage feature fusion mechanism. The welding image is processed and features are extracted through convolutional neural network (CNN), and the specific process is as follows:
[0074] Data feature fusion layer:
[0075] After the original welding image is input, multiple parallel convolution operations are performed to extract features of different scales, such as edge, texture and other basic information. By integrating features of different channels, the expression ability of the model to the defect area is enhanced, providing a basis for subsequent feature extraction. In this process, the network not only extracts deep convolutional features, but also strengthens the main features of welding defects, so that the subsequent layers can more accurately identify and classify different types of welding defects.
[0076] First pooling layer:
[0077] Max-pooling (2x2, stride 2) is applied to the feature maps generated by the data feature fusion layer, reducing the spatial dimension of the feature maps and the computational load while improving the translational invariance of the features.
[0078] Deep feature fusion layer:
[0079] The pooled feature maps are further fused to integrate information from different channels, using cross-layer connections or channel attention mechanisms to enhance feature expression capabilities, enabling the model to more effectively capture the morphology and structure of welding defects.
[0080] Second pooling layer:
[0081] Pooling operations are performed on the output of the deep feature fusion layer to reduce data dimensions while preserving main features, improving computational efficiency.
[0082] Feature abstract representation layer:
[0083] Global average pooling (GAP) or other dimension reduction strategies are applied to the pooled deep feature maps to extract global context information, further compressing feature representations and improving computational efficiency.
[0084] Third pooling layer:
[0085] Pooling operations are performed again to remove redundant information, ensuring that only the most representative defect features are retained, preparing for subsequent classification tasks.
[0086] Feature high-level representation layer:
[0087] Non-linear transformations (such as ReLU) and feature compression (such as 1x1 convolution) are used to further refine high-level semantic features, enabling more accurate differentiation between different types of welding defects.
[0088] Pooling layer:
[0089] Further reducing feature dimensions improves computational efficiency and makes classification tasks more robust.
[0090] First fully connected layer, second fully connected layer, third fully connected layer:
[0091] After flattening the pooled high-level features, multiple fully connected layers are sequentially applied to learn high-dimensional mapping relationships, improving classification performance and enabling the model to better understand complex patterns of defects.
[0092] Softmax layer:
[0093] The final output of the fully connected layer is calculated by the Softmax layer to obtain the probability distribution of each class, and finally outputs the defect class to which the welding image belongs, thereby realizing automatic defect recognition.
[0094] S3: training the CNN image recognition and classification model in S2 using the training samples in S1 to obtain a trained CNN image recognition and classification model.
[0095] The iterative training is performed until the network converges to obtain the trained CNN image recognition and classification model. In the experiment during the training, a single NVIDIA V100 32G is used as the experimental equipment, and the deep learning framework is PyTorch. In the training process, the Adam optimizer is used for training, and the initial learning rate is set to 3x10 -4 , and then gradually reduced to 2x10 -7 by exponential decay.
[0096] The CNN image recognition and classification model uses the cross-entropy loss function (Cross-Entropy Loss) as the objective function. The cross-entropy loss function is a loss function commonly used in multi-class classification tasks, which can effectively measure the difference between the predicted output of the model and the true label. In the welding defect recognition task, the output of the model is the probability distribution of each defect class, and the cross-entropy loss function calculates the matching degree of the predicted probability and the true label to guide the model to gradually optimize the parameters.
[0097] Let the true class label of each sample in the training set be y, and the output of the model be the probability distribution p of the class. If y is the One-hot encoded true label vector, then the cross-entropy loss function is defined as:
[0098]
[0099] where N is the number of batch samples, C is the number of classification categories, y ij represents the true label value (One-hot encoded as 0 or 1) of the i-th sample in the j-th class; p ij represents the predicted probability of the model that the i-th sample belongs to the j-th class, and the calculation method is:
[0100]
[0101] where z ij is the network output before the Softmax activation function, i.e., the logit value of the model.
[0102] The goal of the cross-entropy loss function is to minimize the difference between the predicted distribution p of the model and the true distribution y. When the predicted probability p ij of the model is closer to the true class label y ij , i.e., pij → 1, the corresponding loss value -log(p j )→ 0. Conversely, when p ij → 0, the loss value tends to infinity, strongly punishing the wrong classification result.
[0103] Through the backpropagation algorithm (Backpropagation), the model updates the parameters using the Adam optimizer. The Adam optimizer combines the advantages of momentum gradient descent and RMSProp, and its parameter update formula is as follows:
[0104]
[0105] Where θ t represents the model parameters of the t-th iteration; η represents the learning rate; m t and v t are the first-order momentum estimate and the second-order momentum estimate of the gradient, respectively; ε is a small constant to avoid the denominator being zero.
[0106] In this application, the step-by-step decay of the learning rate enables the training process to converge quickly, while stabilizing around the optimal point in the later period, avoiding excessive parameter updates leading to oscillation.
[0107] Using the cross-entropy loss function can effectively optimize the classification model, so that the model can maximize the prediction probability of the correct class and minimize the prediction probability of the wrong class during the training process. In the welding defect classification task, the cross-entropy loss function can guide the model to focus on the most important features and improve the accuracy of classification.
[0108] This application effectively prevents the model from overfitting the training data by introducing the regularization technique Dropout and the learning rate decay strategy, combined with the cross-entropy loss function. The mathematical form of regularization can be represented as:
[0109] L total = L + λ·||θ|| 2
[0110] Where λ is the weight of the regularization strength, and ||θ|| 2 is the L2 norm of the model parameters.
[0111] In the inference stage, the model outputs the probability distribution of each class through the Softmax layer. The probability value p ij represents the model's confidence that the sample belongs to the j-th class.
[0112] S4: input the welding image to be classified and identified into the trained CNN image recognition and classification model, and obtain the defect class to which the welding image belongs through model inference.
[0113] The welding image to be classified and identified is taken as the input of the trained CNN image recognition and classification model, and the classification of the defect type is obtained through model inference. In the model training process of the present application, the cross-entropy loss function is used for optimization, and finally the performance of the model is evaluated by calculating the classification accuracy, precision, recall, F1-score and other evaluation indexes of the model on the validation set and test set. Through these indexes, the performance of the model in the welding defect classification task can be comprehensively evaluated to ensure that the model can achieve efficient and accurate defect identification in actual application.
[0114] The present application can effectively improve the defect recognition accuracy, optimize the feature extraction process, and ensure real-time detection capability to meet the efficient and accurate welding quality control requirements of industrial sites.
[0115] The present application also provides an embodiment of a welding defect classification system based on deep learning, which is used to implement the welding defect classification method based on deep learning described in the above embodiments, and comprises:
[0116] A preprocessing module is configured to collect welding images as training samples in a training set, and pre-process the welding images in the training set.
[0117] A model construction module is configured to construct a CNN image recognition and classification model with feature fusion.
[0118] A model training module is configured to train the CNN image recognition and classification model using the training samples to obtain a trained CNN image recognition and classification model.
[0119] A defect classification module is configured to input the welding image to be classified and identified into the trained CNN image recognition and classification model, and obtain the defect category to which the welding image belongs through model inference.
[0120] Finally, it should be noted that: the above embodiments are only used to illustrate the technical solutions of the present application and not to limit them, although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that the specific embodiments of the present application can still be modified or replaced equivalently without departing from the spirit and scope of the present application, any modification or equivalent replacement thereof should be covered within the protection scope of the claims of the present application.
Claims
1. A welding defect classification method based on deep learning, characterized in that: include: Step 1: Collect welding images and use them as training samples in the training set, and preprocess the welding images in the training set; Step 2: Build a feature-fused CNN image recognition and classification model; Step 3: Use the training samples in step 1 to train the CNN image recognition and classification model in step 2 to obtain a trained CNN image recognition and classification model; Step 4: Input the welding image to be classified and identified into the trained CNN image recognition and classification model, and obtain the defect category to which the welding image belongs through model inference; The step 2 includes: The feature fusion CNN image recognition and classification model includes a data feature fusion layer, a first pooling layer, a deep feature fusion layer, a second pooling layer, a feature abstract representation layer, a third pooling layer, a feature high-level representation layer, a fourth pooling layer, a first fully connected layer, a second fully connected layer, a third fully connected layer and a Softmax layer connected in sequence; Data feature fusion layer: After the raw welding image is input, multiple parallel convolution operations are performed to extract features at different scales. By integrating features from different channels, the model's ability to represent defect areas is enhanced. The network not only extracts deep convolutional features but also strengthens the main features of welding defects, enabling subsequent layers to more accurately identify and classify different types of welding defects. Features at different scales include edges and textures. First pooling layer: Perform maximum pooling on the feature map generated by the data feature fusion layer to reduce the spatial dimension of the feature map; Deep feature fusion layer: The pooled feature maps are further fused to integrate information from different channels. Cross-layer connections or channel attention mechanisms are used to enhance feature expression capabilities, enabling the model to capture the morphology and structure of welding defects. Second pooling layer: Perform pooling on the output of the deep feature fusion layer while retaining the main features; Feature abstraction representation layer: Perform global average pooling on the pooled deep feature map to extract global context information and further compress feature representation; The third pooling layer: Perform the pooling operation again to remove redundant information and ensure that only the most representative defect features are retained; Feature high-level representation layer: Through nonlinear transformation and feature compression, high-level semantic features are further refined, so that different types of welding defects can be distinguished more accurately. Fourth pooling layer: Further reduce feature dimensions; First fully connected layer, second fully connected layer and third fully connected layer: The high-level features after flattening and pooling are sequentially passed through multiple fully connected layers to learn high-dimensional mapping relationships to improve classification performance; Softmax layer: The final output of the third fully connected layer is used to calculate the probability distribution of each category through the Softmax layer, and finally the defect category to which the welding image belongs is output, realizing automatic defect recognition; The step 3 includes: The CNN image recognition and classification model uses the cross-entropy loss function as the objective function. In the welding defect recognition task, the output of the CNN image recognition and classification model is the probability distribution of each defect category. The cross-entropy loss function guides the CNN image recognition and classification model to gradually optimize parameters by calculating the degree of match between the predicted probability and the true label. Regularization is performed based on the optimized parameters to ensure that the network eventually converges, resulting in a trained CNN image recognition and classification model. The CNN image recognition and classification model optimization parameters include: Through the back-propagation algorithm, the CNN image recognition and classification model uses the Adam optimizer to update the parameters. The parameter update formula is: Among them, θ t represents the model parameters of the tth iteration; θ t+1 represents the model parameters after the tth iteration; η represents the learning rate; m t and v t are the first-order momentum estimate and the second-order momentum estimate of the gradient respectively; ε is a constant; The step 4 comprises: After the welding image to be classified is input into the trained CNN image recognition and classification model, the extracted features are normalized through the Softmax classification layer, and the probability distribution of the sample belonging to each defect category is output, where the probability value p ij It represents the predicted probability that the i-th sample is classified as the j-th welding defect, and the category corresponding to the maximum probability value is selected as the final defect classification result.
2. The welding defect classification method based on deep learning according to claim 1 is characterized in that: The cross entropy loss function is defined as: Assume that the true category label of each training sample in the training set is y, and the output of the CNN image recognition and classification model is the probability distribution p of the category; if y is the true label vector encoded by one-hot, then the cross entropy loss function is defined as: Where N is the number of batch samples, C is the number of classification categories, and y ij represents the true label value of the i-th training sample in the j-th category; p ij It represents the predicted probability that the i-th sample is classified as the j-th welding defect. The category labels include porosity, slag, and weld penetration. The calculation method is: Among them, zij is the network output before the Softmax activation function, that is, the logit value of the i-th sample in the target category j, Z ik is the logit value of the i-th sample in any category k.
3. The welding defect classification method based on deep learning according to claim 2, characterized in that: The goal of the cross entropy loss function is to minimize the difference between the predicted distribution p of the CNN image recognition and classification model and the true distribution y; when the predicted probability p of the CNN image recognition and classification model is ij The closer the label value y is to the true category ij , that is, p ij →1, the corresponding loss value is -log(p ij )→0; On the contrary, when p ij →0, the loss value tends to infinity.
4. The welding defect classification method based on deep learning according to claim 1, characterized in that: The regularization processing based on the optimized parameters includes: The regularized expression is: L total =L+λ·‖θ|| 2 Where λ is the weight of the regularization strength, ||θ|| 2 is the L2 norm of the model parameters, L total is the total loss function and L is the cross entropy loss function.
5. A welding defect classification system based on deep learning, used to implement the welding defect classification method based on deep learning according to any one of claims 1 to 4, characterized in that: include: A preprocessing module is used to collect welding images and use them as training samples in a training set, and to preprocess the welding images in the training set; Model building module, used to build feature fusion CNN image recognition and classification models; The model training module is used to train the CNN image recognition and classification model using training samples to obtain a trained CNN image recognition and classification model; The defect classification module is used to input the welding image to be classified and identified into the trained CNN image recognition and classification model, and obtain the defect category to which the welding image belongs through model inference.
Citation Information
Patent Citations
Welding defect image preprocessing method based on multi-scale feature fusion
CN120236173A