A weld defect detection method based on improved YOLOX

Through the improved YOLOX network, combined with the deep separation convolution and attention mechanism, the problems of manual missed inspection and edge information loss in the detection of internal defects of welds are solved, and efficient real-time detection of aluminum alloy welds is achieved, and detection is improved. Performance and accuracy.

CN114240821BActive Publication Date: 2025-01-07SHANGHAI DIANJI UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111240117.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-25
Publication Date
2025-01-07
Estimated Expiration
2041-10-25

AI Technical Summary

Technical Problem

The prior art has problems of missed and missed detection of internal defects of welds, which has low detection efficiency. Traditional algorithms are prone to lose edge information when detecting small target defects, resulting in poor prediction effect.

Method used

Using a deep learning network based on improved YOLOX, the data set is expanded through data augmentation and labeling, and an object detection model including backbone feature extraction module, enhanced feature extraction module and output prediction module are constructed. The deep separation convolution, attention mechanism and CSP module and other technologies realize real-time detection of internal defects of aluminum alloy welds.

Benefits of technology

Real-time detection and identification of internal defects of aluminum alloy X-ray welds is realized. By iteratively optimizing the model prediction weight, the detection performance is improved, the recall and average accuracy are significantly improved, and the leakage detection rate is reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114240821B_ABST
    Figure CN114240821B_ABST
Patent Text Reader

Abstract

A weld defect detection method based on improved YOLOX belongs to the field of image recognition technology. This method adopts the currently widely used deep learning-based algorithm to realize the detection and identification of weld X-ray internal defects. The present invention is based on the YOLOX‑s algorithm, and adds an attention mechanism to its backbone feature extraction network Backbone, so that the model pays more attention to edge information. Secondly, some convolutions in the network are changed to deep separable convolutions to reduce the number of parameters. Finally, the cosine annealing method is used to adjust the learning rate in the model training process to achieve a better result. The method of the present invention can detect and identify internal defects of welds more quickly and accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of image recognition, and in particular to a weld defect detection method based on improved YOLOX. Background Art

[0002] In industrial production, X-ray technology is often used to detect internal defects in welds, and then the images are input into computers for manual evaluation. However, the results of manual inspections are limited by the level of inspectors and are prone to missed detections and false detections, large inspection workloads, and low inspection efficiency. The traditional internal defect detection algorithm structure is to obtain an image that is easy to detect through image preprocessing, and then use statistical machine learning methods to extract image features to achieve the goal of defect detection. However, the image preprocessing steps are numerous and highly targeted, and the robustness is poor.

[0003] Therefore, with the rapid development of computer and digital image processing technology, an effective method for automatic detection and identification of weld X-ray flaw detection defects is needed. Deep learning has achieved very good results in feature extraction and positioning. More and more scholars and engineers have begun to introduce deep learning algorithms into the field of defect detection. Therefore, the target detection algorithm based on deep learning is particularly important. From the perspective of ideas, the target detection algorithm can be divided into two categories. One is the two-stage method, which is to divide the whole into two parts, generate candidate boxes and identify objects in the box. It is mainly the RCNN series network, and the commonly used ones include RCNN, Faster RCNN and Mask RCNN. However, RCNN is a multi-stage training process, which consumes a lot of computing and storage resources. Faster RCNN improves accuracy through regional generation network RPNs, but the speed is still not satisfactory. The other is the one-stage method, which unifies the entire process and directly gives the detection results, including SSD, YOLOv3 and YOLOv4. Because of its fast detection speed and high accuracy, it is widely used in real-time industrial detection. However, it is easy to lose edge information when detecting small target defects, resulting in poor overall prediction results. Summary of the invention

[0004] In response to the above problems, according to the characteristics of internal defects of aluminum alloy welds, the present invention proposes a method for detecting and identifying internal defects of aluminum alloy X-ray welds based on a deep learning network.

[0005] The technical solution provided by the present invention is as follows:

[0006] A weld defect detection method based on improved YOLOX, characterized in that it comprises the following steps:

[0007] S1: For the collected X-ray weld internal defect images, the weld internal defect data set is expanded through data enhancement, and the defects are annotated. The expanded data set is used as a training set and a validation set;

[0008] S2: Construct a target detection model for detecting and identifying internal defects of welds, including a backbone feature extraction module, an enhanced feature extraction module, and an output prediction module;

[0009] S3: Input the expanded dataset into the target detection model for feature extraction and prediction;

[0010] S4: Adjust the parameters and methods in the model training process, train the target detection model using the method in step S3 and the data set obtained in step S1, and stop training when the set epoch is reached;

[0011] The trained weights are put into the model, tested on the entire dataset, and the overall detection performance of the model is evaluated.

[0012] Furthermore, in step S2:

[0013] The backbone feature extraction module includes the Focus module, the first depth-wise separable convolution, the first attention mechanism, the first CSP1 module, the second depth-wise separable convolution, the second attention mechanism, the second CSP1 module, the third depth-wise separable convolution, the third CSP1 module, the fourth depth-wise separable convolution, the SPP module, the fourth CSP1 module, and the first CBA module in sequence; the Focus module is used to implement the slicing operation of the input image to achieve downsampling without information loss; the depth-wise separable convolution is used to change the convolution mode to reduce the number of convolution executions; the attention mechanism is a resource allocation mechanism used to assign weights to corresponding channels so that the model pays more attention to useful information; the CSP1 module is connected through two branches, one of which is to perform convolution normalization and activation function operations on the input feature layer, and the other branch is processed by the activation function and then processed by n Bottle modules, and the last two branches are connected; the SPP module is used to perform maximum pooling on the input feature layer through different pooling kernel sizes and then short-circuit the feature layer containing the input as the output of the module;

[0014] The enhanced feature extraction module integrates the feature information extracted from the model context through a structure composed of a CSP2 module and upsampling; the CSP2 module includes two branches, one branch performs activation function processing on the input feature layer, and the other branch performs two activation functions and depth-separable convolution processing on the input feature layer, and finally connects the two branches;

[0015] The output prediction module mainly performs a series of branch decoupling operations of activation functions and vector convolution operations on the feature layer extracted by the enhanced feature extraction network. The Sigmoid function is used to judge the target category prediction cls and whether the target box is the foreground or background obj, and the prediction box is trained and adjusted to obtain the final prediction box.

[0016] Furthermore, step S3 specifically includes the following steps:

[0017] S31: Use the Focus structure in the backbone feature extraction network (Backbone) to slice the input image, that is, get a value for every other pixel in an image;

[0018] S32: Input the feature layer after preliminary extraction into the enhanced feature extraction network; first, upsample the last feature layer extracted by the backbone network, i.e., the first feature layer, and fuse it with the feature map obtained by the third CSP1 module of the backbone network to obtain the second feature layer, extract the features of the second feature layer through the CSP2 module and the second CBA module to obtain the third feature layer, and then fuse it with the feature map obtained by the second CSP1 module of the backbone network to obtain the fourth feature layer; secondly, pass the fourth feature layer through the CSP2 module to obtain the fifth feature layer, and fuse it with the third feature layer after passing through the third CBA module to obtain the sixth feature layer; finally, pass the sixth feature layer through CSP2 to obtain the seventh feature layer, extract the features through the fourth CBA module, and fuse it with the first feature layer to obtain the eighth feature layer; finally, input the fifth feature layer, the seventh feature layer, and the eighth feature layer into the Decouple Head part;

[0019] S33: The three feature layers of 13×13, 26×26 and 52×52 obtained in step S32 are subjected to branch decoupling operation through the Decouple Head part. Each feature layer includes three branches: cls for predicting the category of the target, obj for judging whether the target box is foreground or background, and reg for predicting the target box information (x, y, w, h), where (x, y) is the coordinate of the center point of the predicted target box, and w and h are the width and height of the predicted target box respectively; cls and obj are both processed by the BCEWithLog_Loss loss function; reg is the coordinate information trained by the IOU loss function;

[0020] S34: The three branches corresponding to the three feature layers are fused to obtain 13×13×8, 26×26×8 and 52×52×8; the overall Concat Reshape operation is performed to obtain 3549×8 prediction information, where 3549 is the number of candidate boxes, and 8 is the information of each candidate box, namely x, y, w, h, obj in S33 and cls containing three categories;

[0021] S35: Preliminary screening is performed among the 3549 candidate frames through the center point and the target frame, and the candidate frames preliminarily screened out are refined through positive sample information extraction, cost calculation and SimOTA to determine the final candidate frames.

[0022] The technical effect of the present invention is as follows: the present invention can realize real-time detection of internal defects of aluminum alloy X-ray welds, and continuously iteratively optimizes the prediction weights of the YOLOX-s-Tiny model through forward propagation and back propagation, and various model evaluation indicators have achieved better results, so that the model can effectively detect and identify specific categories of defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more intuitively illustrate the technical solution implemented by the present invention, necessary drawings will be introduced.

[0024] Figure 1 is a flowchart of the steps of the weld defect detection method based on the improved YOLOX in Example 2 of the present invention;

[0025] Figure 2 This is a network structure diagram of YOLOX-s-Tiny in Example 2 of the present invention;

[0026] Figure 3 Schematic diagram of missed detection rate of network training of YOLOX-s-Tiny in Example 2 of the present invention;

[0027] Figure 4 It is a schematic diagram of F1 of the network training of YOLOX-s-Tiny in Example 2 of the present invention;

[0028] Figure 5 This is a diagram showing the prediction effect of the network training of YOLOX-s-Tiny in Example 2 of the present invention. DETAILED DESCRIPTION

[0029] In order to make the advantages and technical solutions of the present invention clearer, the following description will be given, but it is not considered to be a limitation of the present invention.

[0030] Example 1

[0031] The weld defect detection method based on the improved YOLOX includes the following steps:

[0032] S1: For the collected X-ray weld internal defect images, the weld internal defect dataset is expanded through data enhancement, and the defects are annotated through Labelme (deep learning image annotation tool) to obtain an XML file containing the defect location and type. The expanded dataset is divided into a training set and a validation set at a ratio of 9:1;

[0033] S2: Construct a target detection model for detecting and identifying internal defects of welds, which mainly includes a backbone feature extraction module (Backbone), an enhanced feature extraction module (PANet+FPN) and an output prediction module.

[0034] The backbone feature extraction module is mainly composed of the Focus module, the depthwise separable convolution (DWConv), the attention mechanism (SELayer), the CSP1 module and the SPP module, etc. Specifically, it includes the Focus module, the first DWConv, the first attention mechanism, the first CSP1 module, the second DWConv, the second attention mechanism, the second CSP1 module, the third DWConv, the third CSP1 module, the fourth DWConv, the SPP module, the fourth CSP1 module, and the first CBA module. The Focus module mainly implements the slicing operation of the input image to achieve downsampling without information loss; the depth-wise separable convolution (DWConv) changes the convolution method to reduce the number of convolution executions, effectively reducing the number of model parameters; the attention mechanism (SELayer) is also a resource allocation mechanism, that is, assigning weights to corresponding channels so that the model pays more attention to useful information; the CSP1 module is connected through two branches, one of which is to perform convolution normalization and activation function (CBL) operations on the input feature layer, and the other branch is processed by CBL and then processed by n Bottle modules. The last two branches are connected to effectively extract features and enhance the semantic information of the model; the SPP module mainly performs maximum pooling on the input feature layer with different pooling kernel sizes, and then short-circuits and stacks it with the feature layer containing the input as the output of the module.

[0035] The enhanced feature extraction module integrates the feature information extracted from the model context through the PANet and FPN structure composed of the CSP2 module and upsample. The CSP2 module includes two branches, one branch performs CBL processing on the input feature layer, and the other branch performs two CBL and DWConv processing on the input feature layer, and finally connects the two branches.

[0036] The output prediction module mainly performs a series of CBL and Conv (vector convolution operation) branch decoupling operations on the feature layer extracted by the enhanced feature extraction network, and uses the Sigmoid function to judge the cls (category loss gain) of the target category prediction and the obj (whether there is object loss gain) of whether the target box is the foreground or background, and trains and adjusts the prediction box to obtain the final prediction box.

[0037] S3: Input the expanded data set into the target detection model for feature extraction and prediction, including the following steps:

[0038] S31: Use the Focus structure in the backbone feature extraction network (Backbone) to slice the input image, that is, get a value for every other pixel in an image, similar to neighboring downsampling, avoiding information loss and achieving downsampling. After slicing, a series of CSP1 modules containing multiple residual blocks and DWConv modules are stacked to deepen the network to achieve preliminary feature extraction and reduce a large number of training parameters. During the stacking process, the attention mechanism (SELayer) makes the model focus on effective information, bringing continuous performance improvement to the model. Finally, an SPP module is used to solve the problem of non-fixed input image size;

[0039] S32: Input the feature layer after preliminary extraction into the enhanced feature extraction network combining PAN and FPN. First, the last feature layer extracted by the backbone network, that is, the first feature layer is upsampled and fused with the feature map obtained by the third CSP1 module of the backbone network to obtain the second feature layer, and the second feature layer is subjected to feature extraction by the CSP2 module and the second CBA module to obtain the third feature layer, and then fused with the feature map obtained by the second CSP1 module of the backbone network to obtain the fourth feature layer. Secondly, the fourth feature layer is subjected to the CSP2 module to obtain the fifth feature layer, and after passing through the third CBA module, it is fused with the third feature layer to obtain the sixth feature layer. Finally, the sixth feature layer is subjected to CSP2 to obtain the seventh feature layer, and after feature extraction by the fourth CBA module, it is fused with the first feature layer to obtain the eighth feature layer. Finally, the fifth feature layer, the seventh feature layer and the eighth feature layer are input into the Decouple Head part; the fifth feature layer, the seventh feature layer and the eighth feature layer are the fifth feature layer, the seventh feature layer and the eighth feature layer respectively.

[0040] S33: The three feature layers of 13×13, 26×26 and 52×52 obtained in step S32 are subjected to branch decoupling operation through the Decouple Head part to speed up network training and achieve better results. Each feature layer includes three branches: cls for predicting the category of the target, obj for judging whether the target box is foreground or background, and reg for predicting the target box information (x, y, w, h), where (x, y) is the coordinate of the center point of the predicted target box, and w and h are the width and height of the predicted target box, respectively. Both cls and obj are processed by the BCEWithLog_Loss loss function. reg is mainly the coordinate information trained by the IOU loss function;

[0041] S34: The three branches corresponding to the three feature layers are fused to obtain 13×13×8, 26×26×8 and 52×52×8. Then the Reshape operation is performed to obtain 3549×8 prediction information, where 3549 is the number of candidate boxes and 8 is the information of each candidate box, i.e., x, y, w, h, obj in S33 and cls containing three categories.

[0042] The Reshape operation is to adjust the shape of the matrix. In Python, Reshape is used to adjust the dimension and shape of the matrix, such as adjusting a 2*3 matrix to a 3*2 matrix.

[0043] The Concat method is used to concatenate tensors, which means fusing multiple layers of features.

[0044] S35: Preliminary screening is performed among the 3549 candidate frames through the center point and the target frame, and the candidate frames preliminarily screened out are refined through positive sample information extraction, cost calculation and SimOTA solution to determine the final candidate frames.

[0045] The solution process of SimOTA is as follows:

[0046] (1) Set the number of candidate boxes;

[0047] (2) Select candidate boxes by cost, mainly using the torch.clamp function to assign candidate boxes to different target boxes based on the value calculated by the cost function;

[0048] (3) Filtering the shared candidate boxes. Some candidate boxes may be associated with multiple targets. Therefore, it is necessary to further filter by comparing the cost values ​​to obtain the most suitable candidate boxes relative to the target box.

[0049] (4) Perform loss calculation on the corresponding target box and the predicted box of the positive sample.

[0050] S4: Adjust the parameters and methods in the model training process, train YOLOX-s-Tiny using the method in S3 and the data set obtained in S1, and stop training when the set epoch is reached;

[0051] S5: Put the trained weights into the model, test the entire dataset, and evaluate the overall detection performance of the model.

[0052] Preferably, in step S1, the defect data set is expanded mainly by rotating, cropping and contrast enhancing the image, and the position and category information are marked.

[0053] Preferably, in step S3, the improvement of the YOLOX-s network structure is mainly divided into two parts:

[0054] -Added an attention mechanism (SELayer) to the backbone feature extraction network (Backbone), which brought continuous performance improvements to the model;

[0055] -Change some convolution methods in the network to depthwise separable convolution to reduce a large number of parameters during training.

[0056] Preferably, in step S33, a Sigmoid function is used, and its formula is: Normalize the output value to between 0 and 1. The cross entropy function formula (BCELoss) is: Where N is the total number of samples, y i is the category of the i-th sample, p i is the predicted value of the i-th sample. Therefore, cls and obj are trained to achieve classification through the BCEWithLog_Loss loss function, which includes Sigmoid and BCELoss. This loss function can improve the stability of numerical calculations. reg uses the IOU loss function to perform regression training on the coordinates. The formula is: IOU loss =1-IOU(bbox gt ,bbox pred ). Among them, IOU(bbox gt ,bbox pred ) represents the intersection-over-union ratio between the original labeled box and the candidate box.

[0057] Preferably, in step S35, the position of the detection box predicted by the network, the foreground and background target scores, and the category scores are extracted, and the loss calculation of reg and cls is performed to obtain the cost, and the calculation formula is: in represents the loss of category prediction, Represents the prediction loss of the target box, and λ represents the corresponding weight. The candidate boxes are screened by cost and the shared candidate boxes are filtered.

[0058] Preferably, in step S4, the entire training process uses the cosine annealing method to adjust the model learning rate. As the epoch increases, the learning rate first drops rapidly and then increases sharply. This process is repeated continuously so that the model skips the local optimal solution and reaches the optimal solution.

[0059] Preferably, in step S5, the entire data set is put into the model for testing, and the model is evaluated by evaluation indicators such as precision, recall, average precision AP, average precision mAP of all types of defects, and weight size.

[0060] Example 2

[0061] This embodiment is a specific application example of the method of the present invention.

[0062] like Figure 1 As shown, the weld defect detection method includes the following steps:

[0063] S1: Expand the internal defect map of aluminum alloy X-ray welds including pores, slag inclusions and incomplete penetration, divide the expanded data set into training set and validation set, and annotate them through Labelme.

[0064] S2: Construct a target detection model for internal defect detection of aluminum alloy X-ray welds.

[0065] Because the data set includes defects such as pores and slag inclusions, the recognition and positioning network model needs to pay attention to the retention of edge information of small targets to avoid poor detection results due to downsampling and convolution.

[0066] The recognition and positioning network model constructed considering the above factors consists of three modules: backbone feature extraction network, enhanced feature extraction network and prediction layer.

[0067] The attention mechanism is added to the backbone feature extraction network. Its essence is a set of weight coefficients learned by the network itself, which emphasizes the area of ​​interest while suppressing irrelevant background areas in a "dynamic weighted" manner. This mechanism enables the model to pay more attention to important information such as edge features of small targets.

[0068] Some convolutions in the backbone feature extraction network and the enhanced feature extraction network are changed to depthwise separable convolutions, which not only ensures the extraction and transmission of features but also reduces the number of parameters for training calculations. The feature layers extracted by the backbone network are fused at multiple scales through the PAN and FPN structures. Different feature layers are interconnected, which enables better transmission of upper and lower features and improves the final detection accuracy of the model.

[0069] The PAN structure is a bottom-up feature extraction, and the FPN structure is a top-down feature extraction.

[0070] The prediction layer uses the Decoupled Head structure to perform branch decoupling operations on the three feature layers and reduces the number of parameters through the AnchorFree method. The candidate boxes are preliminarily screened based on the center point and the target box, and the preliminarily screened candidate boxes are refined through sample information extraction, cost calculation and SimOTA solution to screen out the candidate boxes corresponding to the target box, and the final screened candidate boxes are trained through the loss function.

[0071] The overall model framework of weld defect detection is shown in the figure Figure 2 As shown in the figure, after the input image is sliced ​​by the Focus structure, a series of convolutions and attentions bring continuous performance improvements to the model. Then, through the SPP structure, the feature layers are changed to the same size and convolved before being sent to the structure of the combination of PANet and FPN. Through the continuous extraction and fusion of context features, the semantic information of the model is improved and more effective features are obtained. Finally, the three feature layers are trained and adjusted through the loss function of the finely screened candidate boxes through the DecoupleHead structure, and the Anchor Free method is used to obtain the best final effect and the weight with the lowest overall model loss to achieve real-time prediction.

[0072] S3: After the model is built, it is unfrozen and trained. The experiment is implemented in the Window10 system based on the Pytorch deep learning framework, with an i5-11400 processor, an RTX 3060 graphics card, and 16GB of memory.

[0073] The total training epoch is set to 200, and the input image size is 416 × 416. The parameters before and after unfreezing training are shown in Tables 1 and 2.

[0074] Table 1. Training parameters before thawing

[0075]

[0076] Table 2 Training parameters after thawing

[0077]

[0078] S4: After training, evaluate the performance of the model. Precision, recall, AP and mAP are important indicators for judging the model. Compare with the original YOLOX-s model.

[0079] S41: The calculation formulas for precision and recall are as follows:

[0080]

[0081]

[0082] Taking the defect of lack of penetration as an example, TP in the formula represents the number of defects correctly detected as lack of penetration, FP represents the number of defects incorrectly detected as lack of penetration, and FN represents the number of defects that are not detected as lack of penetration.

[0083] The results are shown in Table 3.

[0084] Table 3 Results comparison

[0085]

[0086] Analyzing the results in the above table, compared with the original YOLOX-s model, the recall rate of YOLOX-s-Tiny for the three defects has been significantly improved, and the recall rate for the incomplete penetration defect has been increased by 34.34%.

[0087] S42:AP is the average precision, mAP is the average precision of all defect types, and the calculation formula is as follows:

[0088]

[0089]

[0090] The results are shown in Table 4.

[0091] Table 4 Comparison of AP and mAP of different models

[0092]

[0093] It can be seen from Table 4 that the AP value and mAP value of YOLOX-s-Tiny on different defects have been significantly improved, indicating that the improved model has better overall detection effect and better indicators.

[0094] Compared with the original model, the S43:YOLOX-s-Tiny model has effectively reduced the number of parameters, the obtained weights occupy less memory, and can be embedded in hardware more conveniently and quickly, as shown in Table 5.

[0095] Table 5 Comparison of parameter quantities and weights

[0096]

[0097] Figure 3 It can be seen that the missed detection rate of the improved model for the three defects has been effectively reduced, and it is most obvious in the lack of penetration.

[0098] S44: F1 takes into account both precision and recall. It is calculated as follows:

[0099]

[0100] The F1 values ​​of different models are calculated and compared using the above formula. The results are as follows: Figure 4 As shown in the figure, it is obvious that the F1 value of YOLOX-s-Tiny on the three defects is higher than that of the original model, and the overall detection accuracy is higher.

[0101] Figure 5 This is the detection effect diagram of the YOLOX-s-Tiny model. From top to bottom, the figure shows the detection diagrams of three defects: pores, slag inclusions, and incomplete penetration. It is difficult to extract the edge information of incomplete penetration detection, and it is easy to lose edge information, making detection more difficult. It can be seen from the figure that the model accurately selects the three defects and the overall detection effect is good.

Claims

1. A weld defect detection method based on improved YOLOX, characterized in that: The following steps are involved: S1: For the collected X-ray weld internal defect images, the weld internal defect data set is expanded through data enhancement, and the defects are annotated. The expanded data set is used as a training set and a validation set; S2: Construct a target detection model for detecting and identifying internal defects of welds, including a backbone feature extraction module, an enhanced feature extraction module, and an output prediction module; S3: Input the expanded dataset into the target detection model for feature extraction and prediction; S4: Adjust the parameters and methods in the model training process, train the target detection model using the method in step S3 and the data set obtained in step S1, and stop training when the set epoch is reached; In step S2: The backbone feature extraction module includes the Focus module, the first depthwise separable convolution, the first attention mechanism, the first CSP1 module, the second depthwise separable convolution, the second attention mechanism, the second CSP1 module, the third depthwise separable convolution, the third CSP1 module, the fourth depthwise separable convolution, the SPP module, the fourth CSP1 module, and the first CBA module in sequence; the Focus module is used to implement the slicing operation of the input image to achieve downsampling without information loss; the depthwise separable convolution is used to change the convolution mode to reduce the number of convolution executions; The attention mechanism is a resource allocation mechanism that is used to assign weights to corresponding channels so that the model pays more attention to useful information. The CSP1 module is connected through two branches, one of which is to perform convolution normalization and activation function operations on the input feature layer, and the other branch is processed by the activation function and then processed by n Bottle modules. Finally, the two branches are connected. The SPP module is used to perform maximum pooling on the input feature layer through different pooling kernel sizes and then short-circuit the feature layer containing the input as the output of the module. The enhanced feature extraction module integrates the feature information extracted from the model context through a structure composed of a CSP2 module and upsampling; The CSP2 module consists of two branches. One branch processes the input feature layer with an activation function, and the other branch processes the input feature layer with two activation functions and depthwise separable convolution. Finally, the two branches are connected. The output prediction module performs a series of branch decoupling operations of activation functions and vector convolution operations on the feature layer extracted by the enhanced feature extraction network, uses the Sigmoid function to judge the target category prediction cls and whether the target box is the foreground or background obj, and trains and adjusts the prediction box to obtain the final prediction box.

2. The weld defect detection method based on improved YOLOX according to claim 1, characterized in that: The X-ray weld internal defect map in step S1 includes three defects: porosity, slag inclusion and incomplete penetration. The three defects are expanded in number through rotation, cropping and contrast enhancement methods, and the positions and categories of all defects in the map are marked by a marking tool.

3. The weld defect detection method based on improved YOLOX according to claim 1, characterized in that: Step S3 specifically includes the following steps: S31: Use the Focus structure in the backbone feature extraction network to slice the input image, that is, get a value for every other pixel in an image; S32: Input the feature layer after preliminary extraction into the enhanced feature extraction network; first, upsample the last feature layer extracted by the backbone network, i.e., the first feature layer, and fuse it with the feature map obtained by the third CSP1 module of the backbone network to obtain the second feature layer, extract the features of the second feature layer through the CSP2 module and the second CBA module to obtain the third feature layer, and then fuse it with the feature map obtained by the second CSP1 module of the backbone network to obtain the fourth feature layer; secondly, pass the fourth feature layer through the CSP2 module to obtain the fifth feature layer, and fuse it with the third feature layer after passing through the third CBA module to obtain the sixth feature layer; finally, pass the sixth feature layer through CSP2 to obtain the seventh feature layer, extract the features through the fourth CBA module, and fuse it with the first feature layer to obtain the eighth feature layer; finally, input the fifth feature layer, the seventh feature layer, and the eighth feature layer into the Decouple Head part; S33: The three feature layers of 13×13, 26×26 and 52×52 obtained in step S32 are subjected to branch decoupling operation through the Decouple Head part. Each feature layer includes three branches: cls for predicting the category of the target, obj for judging whether the target box is foreground or background, and reg for predicting the target box information (x, y, w, h), where (x, y) is the coordinate of the center point of the predicted target box, and w and h are the width and height of the predicted target box respectively; cls and obj are both processed by the BCEWithLog_Loss loss function; reg is the coordinate information trained by the IOU loss function; S34: The three branches corresponding to the three feature layers are fused to obtain 13×13×8, 26×26×8 and 52×52×8 respectively; then the Reshape operation is performed to obtain 3549×8 prediction information, where 3549 is the number of candidate boxes, and 8 is the information of each candidate box, i.e., x, y, w, h, obj in S33 and cls containing three categories; S35: Preliminary screening is performed among the 3549 candidate frames through the center point and the target frame, and the candidate frames preliminarily screened out are refined through positive sample information extraction, cost calculation and SimOTA to determine the final candidate frames.

4. The weld defect detection method based on improved YOLOX according to claim 3 is characterized in that: In step S33, the Sigmoid function is used, as shown in Formula 1: Formula 1; Normalize the output value to between 0 and 1; the cross entropy function is shown in Formula 2: Formula 2: in is the total number of samples, is the category to which the i-th sample belongs, is the predicted value of the i-th sample; reg performs regression training on the coordinates through the IOU loss function, as shown in Formula 3: Formula 3; in Represents the intersection-over-union ratio of the original labeled box and the candidate box.

5. The weld defect detection method based on improved YOLOX according to claim 3 is characterized in that: In step S35, the position of the detection box predicted by the network, the background target scores and the category scores are extracted, and the loss of reg and cls is calculated to obtain the cost, as shown in Publication 4: Publicity 4; in represents the loss of category prediction, represents the prediction loss of the target box, Indicates the corresponding weight; the candidate boxes are screened and the shared candidate boxes are filtered through the cost.

6. The weld defect detection method based on improved YOLOX according to claim 1, characterized in that: In step S4, the cosine annealing method is used to adjust the model learning rate during the entire training process. As the epoch increases, the learning rate first drops rapidly and then increases sharply. This process is repeated continuously so that the model skips the local optimal solution and reaches the optimal solution.

7. The weld defect detection method based on improved YOLOX according to claim 1, characterized in that: The method also includes step S5: putting the trained weights into the model, testing the entire data set, and evaluating the overall detection performance of the model.

8. The weld defect detection method based on improved YOLOX according to claim 7, characterized in that: In step S5, the entire data set is put into the model for testing, and the model is evaluated by evaluation indicators, including precision, recall, average precision AP, average precision mAP of all types of defects, and weight size.

Citation Information

Patent Citations

  • Deep learning based image classification of dangerous goods of gun type

    AU2017101803A4

  • Insulator defect detection method based on improved YOLOv5 convolutional neural network

    CN112819804A