End plug welding seam image defect detection method based on improved YOLOv5 algorithm
By improving the YOLOv5 algorithm, including replacing the loss function, adding attention mechanism and using a lightweight network structure, the experience dependence and fatigue problems of manually detecting the weld defects of the end plug welding are solved, and high accuracy and rapid defect detection effects are achieved.
Patent Information
- Application Number
- CN202411715558.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-27
- Publication Date
- 2025-03-11
AI Technical Summary
Manually detecting end plug weld defects has problems such as experience varies from person to person and long-term detection, and the prior art has not yet been applied to image recognition and defect automatic detection of X-ray digital imaging of fuel rod end plug welds.
The improved YOLOv5 algorithm is adopted, and the accuracy and generalization ability of the model are improved by replacing the CIOU Loss loss function as the EIOU Loss loss function, adding the SimAM attention mechanism module, and using the lightweight backbone network Ghostnet as Backbone.
It realizes high accuracy and fast running speed for image defect detection of end plug welding welds, which can effectively replace traditional manual detection methods and improve detection efficiency and accuracy.
Smart Images

Figure CN119600000A_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of defect detection technology, and in particular, relates to an end plug welding weld image defect detection method based on an improved YOLOv5 algorithm. Background Art
[0002] Nuclear fuel rods are key components in the operation of nuclear reactors and work under harsh conditions such as high temperature and high pressure. This requires ensuring the safety of nuclear fuel rod components. The cladding and end plugs of nuclear fuel rods are welded together, so the weld of the end plug weld is the most likely location to cause nuclear leakage. Defects may occur in the weld of the end plug weld during the actual welding process. The main defect type is tungsten inclusion defect, which will seriously affect the safety of nuclear fuel rods. Therefore, it is very important to detect whether the end plug weld has defects.
[0003] At present, the main defect detection method for end plug weld images is manual detection, but there are many shortcomings due to the fact that manual detection may have different experiences from person to person and long-term detection is tiring. With the development of science and technology and information data processing, the application of deep learning image defect detection is becoming more and more extensive. The convolutional neural network is used to extract image features for defect detection, which has the advantages of strong generalization ability and labor cost saving. It can almost replace the traditional manual detection method and has better detection effect. At present, the algorithm has been applied to the rapid detection of small targets in remote sensing satellite images, but has not yet been applied to image recognition and automatic defect detection in X-ray digital imaging of fuel rod end plug welds. Summary of the invention
[0004] The purpose of this application is to provide a method for detecting end plug weld image defects based on an improved YOLOv5 algorithm, to solve the problems of experience and fatigue in manual detection, and to improve the accuracy and generalization ability of the original YOLOv5 model defects.
[0005] In order to achieve the above objectives, this application provides the following technical solutions:
[0006] The present application provides a method for detecting end plug welding weld image defects based on an improved YOLOv5 algorithm, comprising:
[0007] S1: Collect end plug welding image data, perform image preprocessing and image enhancement;
[0008] S2: Annotate the defective parts in the end plug welding seam image and create a semantic segmentation dataset;
[0009] S3: Replace the original CIOU Loss function in the YOLOv5 model with the EIOU Loss function;
[0010] S4: Add the SimAM attention mechanism module into the original YOLOv5 model;
[0011] S5: Use the lightweight backbone network Ghostnet as the infrastructure of Backbone;
[0012] S6: Use the YOLOv5 model improved by S3-S5 for training to obtain the training model results;
[0013] S7: Run the trained improved YOLOv5 model to test the end plug weld image to complete the defect detection of the end plug weld image.
[0014] In some embodiments, the image is contrast adjusted, flipped, or rotated.
[0015] In some embodiments, labelimg software is used to mark defective locations in the end plug weld image.
[0016] In some embodiments, the annotation results are divided into a training set, a test set, and a validation set.
[0017] In some embodiments, the loss function is:
[0018]
[0019] In the formula, w c Indicates the width of the minimum bounding rectangle of the target detection box and the true bounding box, h c represents the height of the minimum enclosing rectangle of the target detection box and the real delineated box, and ρ represents the Euclidean distance between the two coordinate points;
[0020] When calculating the loss, EIoU Loss introduces three factors: overlapping area, center point distance, and aspect ratio.
[0021] In some embodiments, the importance of each neuron is evaluated and the energy function defined for each neuron is:
[0022]
[0023] Using binary labels and adding regularization terms, the final energy function is defined as follows:
[0024]
[0025] In some embodiments, the analytical solution of the energy function of each channel is:
[0026]
[0027] in:
[0028]
[0029] The minimum energy is obtained as:
[0030]
[0031] Compared with the prior art, the end plug welding weld image defect detection method based on the improved YOLOv5 algorithm provided in this application has the following beneficial effects:
[0032] This application uses the improved YOLOv5 model to test the test images. The defect detection results are more accurate and run faster, which can meet the defect detection requirements of end plug welding weld images.
[0033] Furthermore, this application changes the original CIOU Loss loss function in the YOLOv5 model to the EIOU Loss loss function, adds a SimAM attention mechanism module to the original YOLOv5 model in the model network, uses the lightweight backbone network Ghostnet as the infrastructure of Backbone, uses the improved YOLOv5 model for training, and runs the trained improved YOLOv5 model to test the end plug welding weld image, thereby realizing defect detection of the end plug welding weld image. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] In order to more clearly illustrate the technical solution of the present application, the following is a brief introduction to the drawings required for the technical description.
[0035] Figure 1 A flow chart of the end plug welding weld image defect detection method based on the improved YOLOv5 algorithm provided in this application;
[0036] Figure 2 This is the original image of tungsten inclusion defect;
[0037] Figure 3 For this application Figure 2 The effect of reducing contrast.
[0038] Figure 4 For this application Figure 2 The effect of contrast enhancement operation;
[0039] Figure 5 For this application Figure 2 The effect image after horizontal flip operation;
[0040] Figure 6 This is a diagram showing the effect of using the improved YOLOv5 model to detect tungsten inclusion defects provided in this application. DETAILED DESCRIPTION
[0041] The following is further explained in detail through specific implementation methods.
[0042] like Figure 1 As shown, the present application provides an end plug weld image defect detection method based on the improved YOLOv5 algorithm, collects end plug weld images for preprocessing and image enhancement, and then annotates and divides the data set, and then uses the model improved by replacing the loss function, adding the attention mechanism, and using the lightweight network structure for training and verification. The specific steps include:
[0043] S1: Collect the end plug welding image data, and perform image preprocessing and image enhancement, including contrast adjustment, image flipping and rotation, etc. The image preprocessing part is as follows: Figures 2 to 5 shown.
[0044] S2: Use labelimg software to annotate the defective parts in the end plug welding weld image, and divide the annotation results into training set, test set and validation set to produce a semantic segmentation dataset.
[0045] S3: The original CIOU Loss loss function in the YOLOv5 model is replaced with the EIOU Loss loss function. The EIOULoss loss function introduces height-width loss. The height-width loss can minimize the height-width difference between the target detection box and the true delineation box, so it converges faster.
[0046] The EIoU Loss loss function consists of three parts: IoU loss, distance loss, and height-width loss (overlapping area, center point distance, and aspect ratio). The mathematical principle of the loss function is:
[0047]
[0048] Among them, w c Indicates the width of the minimum bounding rectangle of the target detection box and the true bounding box, h c It represents the height of the minimum enclosing rectangle of the target detection box and the real delineated box, and ρ represents the Euclidean distance between the two coordinate points.
[0049] When calculating the loss, EIoU Loss introduces three factors: overlapping area, center point distance, and aspect ratio at the same time. This enables the model to more comprehensively consider the difference between the predicted box and the true box during training, thereby improving the accuracy and efficiency of target detection.
[0050] S4: Adding the SimAM attention mechanism module into the original YOLOv5 model can help the model better focus on the target area and better handle targets in complex scenes, thereby improving the accuracy and robustness of target detection.
[0051] The attention mechanism SimAM is a parameter-free attention mechanism that improves the recognition effect of the model by calculating the weight of each available point, inferring three-dimensional attention weights for the feature map, and can assign a separate scalar to each point of the feature, unify the weights, and make the features more global.
[0052] In order to better implement the attention mechanism, it is necessary to evaluate the importance of each neuron. Each neuron defines an energy function:
[0053]
[0054] Minimizing the above formula is equivalent to training the linear separability between neuron t and other neurons in the same channel. Next, binary labels are used and regularization terms are added. The final energy function is defined as follows:
[0055]
[0056] In theory, the energy function of each channel has the following analytical solution:
[0057]
[0058] in:
[0059]
[0060] The minimum energy can be expressed as:
[0061]
[0062] It can be seen that the lower the energy, the greater the difference between neuron t and its neighboring neurons. Therefore, the importance of a neuron can be known by 1 / e*.
[0063] S5: Using the lightweight backbone network Ghostnet as the infrastructure of Backbone, compared with traditional convolution operations, it greatly reduces the number of parameters and calculations. While maintaining high performance, it can significantly reduce the size of the model and the use of computing resources, saving the time of model running.
[0064] Ghostnet uses the Ghost Module module to replace the traditional convolution operation. It uses 1x1 convolution to compress the number of channels of the image, and then obtains some feature maps through separable convolution operations. Then, different feature maps are connected and combined into a new output image. When a picture is input into the Ghostnet network, it will enter the 16-channel 1x1 convolution module, and then through the superposition of Ghost Bottlenecks, a 1x1 convolution module is used to adjust the number of channels, and then global average pooling is performed. Finally, after tiling and full connection, the image target can be classified.
[0065] S6: Use the improved YOLOv5 model in steps S3-S5 for training to obtain the trained model results.
[0066] S7: Run the trained improved YOLOv5 model to test the end plug weld image to complete the defect detection of the end plug weld image.
[0067] Manual inspection has problems such as different experience from person to person and long-term inspection leading to fatigue of inspectors. The present invention improves the accuracy and efficiency of end plug welding weld defect detection by replacing the loss function of the YOLOv5 model, adding an attention mechanism, and using a lightweight network structure. Figure 6 shown.
[0068] The above description is only a specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by any technician familiar with the technical field within the technical scope disclosed in the present application should be covered within the protection scope of the present application.
Claims
1. A method for detecting end plug welding weld image defects based on an improved YOLOv5 algorithm, characterized in that: include: S1: Collect end plug welding image data, perform image preprocessing and image enhancement; S2: Annotate the defective parts in the end plug welding seam image and create a semantic segmentation dataset; S3: Replace the original CIOU Loss function in the YOLOv5 model with the EIOU Loss function; S4: Add the SimAM attention mechanism module into the original YOLOv5 model; S5: Use the lightweight backbone network Ghostnet as the infrastructure of Backbone; S6: Use the YOLOv5 model improved by S3-S5 for training to obtain the training model results; S7: Run the trained improved YOLOv5 model to test the end plug weld image to complete the defect detection of the end plug weld image.
2. The end plug welding weld image defect detection method based on the improved YOLOv5 algorithm according to claim 1 is characterized in that: In S1, the image is contrast adjusted, flipped, and rotated.
3. The end plug welding weld image defect detection method based on the improved YOLOv5 algorithm according to claim 1 is characterized in that: In S2, labelimg software is used to mark the defective parts in the end plug welding weld image.
4. The end plug welding weld image defect detection method based on the improved YOLOv5 algorithm according to claim 3 is characterized in that: The annotation results are divided into training set, test set and validation set.
5. The end plug welding weld image defect detection method based on the improved YOLOv5 algorithm according to claim 1 is characterized in that: In S3, the loss function is: In the formula, w c Indicates the width of the minimum bounding rectangle of the target detection box and the true bounding box, h c represents the height of the minimum enclosing rectangle of the target detection box and the real delineated box, and ρ represents the Euclidean distance between the two coordinate points; When calculating the loss, EIoU Loss introduces three factors: overlapping area, center point distance, and aspect ratio.
6. The end plug welding weld image defect detection method based on the improved YOLOv5 algorithm according to claim 1 is characterized in that: In S4, the importance of each neuron is evaluated, and the energy function defined for each neuron is: Using binary labels and adding regularization terms, the final energy function is defined as follows:
7. The end plug welding weld image defect detection method based on the improved YOLOv5 algorithm according to claim 6 is characterized in that: The analytical solution of the energy function of each channel is: in: The minimum energy is obtained as: