An automatic identification method of casting defects in X-ray images based on improved neural network

By improving the YOLOv5 network model, combining the convolution generation adversarial network and channel attention mechanism, the problem of limited recognition effect of traditional casting defect detection on complex backgrounds and low-contrast images is solved, achieving higher detection accuracy and robustness sex.

CN114372955BActive Publication Date: 2024-11-15JIASHAN SINHAI PRECISION CASTING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111474014.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-02
Publication Date
2024-11-15
Estimated Expiration
2041-12-02

AI Technical Summary

Technical Problem

When traditional casting defect detection methods identify defects in X-ray images, especially images with complex background and unobvious contrast, the effect is limited and there are repetitive problems, making it difficult to effectively improve the recognition accuracy and accuracy of small target objects.

Method used

The casting defect X-ray diagram automatic recognition method based on convolutional adversarial network and improved YOLOv5 network model is adopted to enhance the feature through convolution generation adversarial network in image preprocessing, and add channel attention mechanism and optimization loss function to build an improved model YOLOv5-SNv2-SE and YOLOv5-MNv2-SE models, using Mosaic data augmentation and CIoU_Loss loss functions, optimize model parameters to improve detection accuracy.

Benefits of technology

It significantly improves the accuracy and average accuracy of casting defect detection, enhances the robustness of the model, and has higher recognition accuracy and stability than traditional methods.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114372955B_ABST
    Figure CN114372955B_ABST
Patent Text Reader

Abstract

The present invention provides a method for automatic identification of casting defect X-ray images based on an improved neural network, which belongs to the field of material casting and defect image target detection. The technical solution adopts a convolutional generative adversarial network model to enhance the image features of a data set. An image annotation tool is used to complete the defect annotation of a casting defect data set. The network structure of the target detection YOLOv5 model is improved, an attention mechanism is added, and the loss function is improved for model training. The model is trained using a training set, and finally a variety of improved network models are compared. The accuracy, recall rate and other factors that affect the quality of the neural network model are used as evaluation indicators to obtain a YOLOv5‑MNv2‑SE4 model, which is used to detect casting images and identify defect types and position coordinates. The present invention can effectively enhance the defect features of sample images and improve the accuracy of identifying small target objects.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the field of material casting and defect image target detection, and in particular to an automatic recognition method of casting defect X-ray images based on an improved neural network. Background Art

[0002] With the development of automobile lightweight technology, the demand for aluminum alloy castings has grown rapidly, and its quality directly affects the safety performance of automobile parts. Therefore, the quality assurance of castings is extremely important. In the process of casting production, various defects such as holes and cracks are inevitably generated due to the limitations of different manufacturing processes. The existence of these defective areas will seriously affect the performance of the castings. Once they continue to be produced and used, they will bring unimaginable adverse consequences to the entire mechanical parts. In order to ensure the quality of castings, the detection method based on traditional machine vision and deep learning has been widely used, which has greatly solved the problems of low efficiency, poor accuracy, high false detection rate, etc. in the past manual detection, improved the recognition accuracy of casting defects, and greatly saved the detection cost.

[0003] Traditional machine vision inspection methods usually collect pictures first, then design features and models based on machine learning algorithms to complete image processing and finally obtain inspection results. With the development of deep learning technology, convolutional neural networks (CNNs) are used to solve difficult image-driven recognition tasks. They can effectively extract key features and learn autonomously, greatly saving the time and cost of manually designing features. As a data-driven inspection technology, deep learning-based inspection methods can achieve good training results when there are sufficient samples. In actual research, it is often necessary to process small sample data, and X-ray images obtained using X-ray detectors are an important source of sample data. However, identifying casting defects in X-ray images is still a challenging task. At the same time, for defective images with complex backgrounds and unclear contrast, traditional image processing methods such as cutting, changing contrast, and noise reduction can achieve data enhancement, but the effect is limited and repetitive. The generative adversarial network model (GAN) learns the real sample distribution through a set of random noise, greatly enhancing the data features of the image, improving the quality of generated samples and the stability of model training. Summary of the invention

[0004] The purpose of the present invention is to provide a method for automatic identification of casting defects in X-ray images based on an improved neural network, which can effectively improve the precision and accuracy of identification of small target objects.

[0005] In order to achieve the above object, the technical solution adopted by the present invention is:

[0006] A method for automatic identification of casting defect X-ray images based on an improved neural network, characterized in that it is based on a convolutional adversarial network and an improved YOLOv5 network model, and mainly includes the following steps:

[0007] (1) Input several acquired X-ray images of castings;

[0008] (2) performing image preprocessing on the image;

[0009] (3) Annotate the defects in each preprocessed image and randomly select them to form the training set and validation set in a ratio of 9:1;

[0010] (4) constructing an improved convolutional neural network model based on YOLOv5, including adding a channel attention mechanism module SENet and optimizing a loss function; and training the improved convolutional neural network model based on YOLOv5 using the training set;

[0011] (5) After N iterations, the trained model is used to complete defect recognition of the X-ray images in the verification set, and the recognition results of various comparison models are compared. If the various indicators of the evaluation model are better overall, proceed to step (7); otherwise, proceed to step (6);

[0012] (6) Using the training set, determine the convergence of model parameters, continuously improve the parameters of the network model, and return to step (4);

[0013] (7) Obtain the weight file of the improved YOLOv5 network model based on the training process;

[0014] (8) Inputting the X-ray image of the casting into the weight file of the improved YOLOv5 network model to detect and identify the defect type and position coordinates of the casting.

[0015] The image preprocessing is to use a convolutional generative adversarial network to learn the real sample distribution through a group of random noises, enhance the features of the defective image, and generate new sample data.

[0016] The defect labeling is to label the defects in each preprocessed image using a graphic image annotation tool labeling.

[0017] The casting is an aluminum alloy casting commonly used in the automobile industry.

[0018] There are six types of defects.

[0019] The improved convolutional neural network model based on YOLOv5 adopts YOLOv5s with smaller volume and weight as a model for casting defect detection and identification, and makes improvements based on this model.

[0020] The main method of training the improved convolutional neural network model based on YOLOv5 is as follows:

[0021] (4.1) The input layer adaptively scales the image, uses Mosaic data enhancement, randomly calls the image, and automatically calculates the best anchor box value of the data set;

[0022] (4.2) In the Backbone stage, the Focus structure is added to construct the CSP structure. After four slicing operations and one convolution operation with 32 convolution kernels, a complete downsampled feature map is obtained.

[0023] (4.3) The output layer uses CIoU_Loss, that is:

[0024]

[0025] In the formula, ρ 2 (b,b gt ) is the Euclidean distance between the center points of the predicted box and the true box; c is the diagonal distance of the minimum closure area that contains both the predicted box and the true box; α is a trade-off parameter; β measures the consistency of the aspect ratio, where α and β can be expressed as follows:

[0026]

[0027] The corresponding loss function is:

[0028]

[0029] Instead of GIoU as the loss function, add the intersection scale measurement;

[0030] (4.4) The ShuffleNetv2 structure or MobileNetv2 structure is used in the convolutional layer to replace the convolutional neural network layer structure except the Focus structure in the backbone of the original model. At the same time, the channel attention mechanism module SENet (Squeeze-and-Excitation Networks) is imported into the tail part of the backbone to construct the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE network models.

[0031] The various indicators of the evaluation model include GIoU Loss (generalized intersection-over-union loss), Objectness Loss (target detection loss), Classification (quasi-target classification loss), Precision (accuracy), Recall (recall rate), mAP@0.5 (the average precision of multiple categories under the generalized intersection-over-union threshold of 0.5), and mAP@0.5:0.95 (the average precision of multiple categories under the varying intersection-over-union threshold).

[0032] The various comparison models include the original YOLOv5 model, the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE network models.

[0033] The improved YOLOv5 network model is the YOLOv5-MNv2-SE model.

[0034] The beneficial effects of the present invention are:

[0035] The present invention provides an automatic identification method for casting defect X-ray images based on an improved neural network. In the image preprocessing stage, the traditional method is not used, but the convolutional generative adversarial network is used to enhance the image features of the data set. At the same time, the neural network structure is improved, the channel attention mechanism is added, and the loss function is improved. The original YOLOv5 model and other improved models are compared to select the optimal network model. Compared with the traditional machine learning method, the present invention has stronger detection accuracy, and the optimized model method has significantly improved the recognition accuracy and average precision, and has better robustness. BRIEF DESCRIPTION OF THE DRAWINGS

[0036] Figure 1 The present invention is a flow chart of an automatic identification method of casting defect X-ray images based on an improved neural network.

[0037] Figure 2 It is a network structure diagram of an automatic identification method of casting defect X-ray images based on an improved neural network of the present invention.

[0038] Figure 3 The invention discloses a target image type and quantity histogram of a casting defect X-ray image automatic recognition method based on an improved neural network.

[0039] Figure 4 The invention is a graph showing the convergence of improved model parameters of an automatic identification method of casting defect X-ray images based on an improved neural network.

[0040] Figure 5 This is a comparison chart of key indicators of three models of the automatic identification method of casting defect X-ray images based on improved neural network of the present invention.

[0041] Figure 6 The invention discloses an identification result diagram of a target defect by an automatic identification method of a casting defect X-ray image based on an improved neural network. DETAILED DESCRIPTION

[0042] The present invention is described in detail below in conjunction with specific embodiments. The following embodiments will help those skilled in the art to further understand the present invention, but are not intended to limit the present invention in any form. It should be noted that, for those of ordinary skill in the art, several variations and improvements may be made without departing from the concept of the present invention. These all belong to the protection scope of the present invention.

[0043] Reference Figures 1 to 4 As shown, an automatic identification method of casting defect X-ray images based on an improved neural network, based on a convolutional adversarial network and an improved YOLOv5 network model, mainly includes the following steps:

[0044] (1) Input several acquired X-ray images of castings;

[0045] (2) performing image preprocessing on the image;

[0046] (3) Annotate the defects in each preprocessed image and randomly select them to form the training set and validation set in a ratio of 9:1;

[0047] (4) constructing an improved convolutional neural network model based on YOLOv5, including adding a channel attention mechanism module SENet and optimizing a loss function; and training the improved convolutional neural network model based on YOLOv5 using the training set;

[0048] (5) After N iterations, the trained model is used to complete defect recognition of the X-ray images in the verification set, and the recognition results of various comparison models are compared. If the various indicators of the evaluation model are better overall, proceed to step (7); otherwise, proceed to step (6);

[0049] (6) Using the training set, determine the convergence of model parameters, continuously improve the parameters of the network model, and return to step (4);

[0050] (7) Obtain the weight file of the improved YOLOv5 network model based on the training process;

[0051] (8) Inputting the X-ray image of the casting into the weight file of the improved YOLOv5 network model to detect and identify the defect type and position coordinates of the casting.

[0052] In step 1, the casting is an aluminum alloy casting commonly used in the automotive industry, and the defect types in the image are six categories.

[0053] In step 2, the image preprocessing is to use a convolutional generative adversarial network to learn the real sample distribution through a set of random noise, enhance the features of the defective image, and generate new sample data. The convolutional generative adversarial network is a DCGAN network structure, which is mainly composed of a generator (G) and a discriminator (D). The core idea is to achieve Nash equilibrium through the competition between G and D, and to generate a data set with obvious enhanced data features by continuously learning the mathematical distribution of real sample data.

[0054] In step 3, the graphic image annotation tool labeling is used to mark the defects in each preprocessed image.

[0055] In step 4, the improved convolutional neural network model based on YOLOv5 adopts YOLOv5s with smaller volume and weight as the model for casting defect detection and recognition, and improves it on the basis of this model. The main training method is as follows:

[0056] 1) The input layer adaptively scales the image, uses Mosaic data enhancement, randomly calls the image, and automatically calculates the optimal anchor box value of the data set;

[0057] 2) In the Backbone stage, a Focus structure is added to construct a CSP structure. After four slicing operations and one convolution operation with 32 convolution kernels, a complete downsampled feature map is obtained.

[0058] 3) The output layer uses CIoU_Loss, that is:

[0059]

[0060] In the formula, ρ 2 (b,b gt ) is the Euclidean distance between the center points of the predicted box and the true box; c is the diagonal distance of the minimum closure area that contains both the predicted box and the true box; α is a trade-off parameter; β measures the consistency of the aspect ratio, where α and β can be expressed as follows:

[0061]

[0062] The corresponding loss function is:

[0063]

[0064] Instead of GIoU as the loss function, add the intersection scale measurement;

[0065] 4) In the convolutional layer, the ShuffleNetv2 structure or MobileNetv2 structure is used to replace the convolutional neural network layer structure except the Focus structure in the backbone of the original model. At the same time, the channel attention mechanism module SENet (Squeeze-and-Excitation Networks) is imported into the tail part of the backbone to construct the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE network models.

[0066] The various indicators of the evaluation model described in steps 5-7 include GIoU Loss (generalized intersection-over-union loss), Objectness Loss (target detection loss), Classification (quasi-target classification loss), Precision (accuracy), Recaljil (recall rate), mAP@0.5 (multi-category average precision value under 0.5 generalized intersection-over-union threshold), mAP@0.5:0.95 (multi-category average precision value under variable intersection-over-union threshold). The various comparison models include the original YOLOv5 model, the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE network models.

[0067] In step 8, the detection and identification of casting defects utilizes the improved optimal YOLOv5-MNv2-SE model to identify and coordinate the defects.

[0068] Reference Figure 5 As shown in the figure, the key indicators of the original YOLOv5 model, the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE are compared after thousands of iterations. With the increase of the number of iterations, compared with the original YOLOv5, the target recognition accuracy (Precision) and the average precision value (mAP@0.5) of the three improved models continue to improve. On the whole, the use of YOLOv5-MNv2-SE for X-ray casting defect image recognition has the best effect.

[0069] Reference Figure 6 As shown, the target defect recognition result diagram is obtained by using the improved YOLOv5-MNv2-SE network model, loading the weight file obtained in the training process, and inputting the image data set to obtain the target defect recognition result.

[0070] The specific embodiments of the present invention are described above in conjunction with the accompanying drawings. It should be understood that the present invention is not limited to the above specific embodiments, and those skilled in the art may make various modifications or variations within the scope of the claims, which do not affect the essence of the present invention.

Claims

1. A method for automatic identification of casting defects in X-ray images based on an improved neural network, characterized in that: Based on the convolutional adversarial network and improved YOLOv5 network model, the following steps are included: (1) Input several acquired X-ray images of castings; (2) performing image preprocessing on the image; (3) Annotate the defects in each preprocessed image and randomly select them to form the training set and validation set in a ratio of 9:1; (4) constructing an improved convolutional neural network model based on YOLOv5, including adding a channel attention mechanism module SENet and optimizing a loss function; and training the improved convolutional neural network model based on YOLOv5 using the training set; The improved convolutional neural network model based on YOLOv5 adopts YOLOv5s with smaller volume and weight as a model for casting defect detection and identification, and makes improvements based on this model; The method for training the improved convolutional neural network model based on YOLOv5 is as follows: (4.1) The input layer adaptively scales the image, uses Mosaic data enhancement, randomly calls the image, and automatically calculates the best anchor box value of the data set; (4.2) In the Backbone stage, the Focus structure is added to construct the CSP structure. After four slicing operations and one convolution operation with 32 convolution kernels, a complete downsampled feature map is obtained. (4.3) The output layer uses CIoU_Loss, that is: In the formula, ρ 2 (b,b gt ) is the Euclidean distance between the center points of the predicted box and the true box; c is the diagonal distance of the minimum closure area that contains both the predicted box and the true box; α is a trade-off parameter; β measures the consistency of the aspect ratio, where α and β are expressed as follows: The corresponding loss function is: Instead of GIoU as the loss function, add the intersection scale measurement; (4.4) The convolutional layer uses the ShuffleNetv2 structure or the MobileNetv2 structure to replace the convolutional neural network layer structure except the Focus structure in the backbone of the original model, and at the same time, the channel attention mechanism module SENet (Squeeze-and-Excitation Networks) is imported into the tail part of the backbone to construct the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE network models; (5) After N iterations, the trained model is used to complete defect recognition of the X-ray images in the verification set, and the recognition results of various comparison models are compared. If the various indicators of the evaluation model are better overall, proceed to step (7); otherwise, proceed to step (6); (6) Using the training set, determine the convergence of model parameters, continuously improve the parameters of the network model, and return to step (4); (7) Obtain the weight file of the improved YOLOv5 network model based on the training process; (8) Inputting the X-ray image of the casting into the weight file of the improved YOLOv5 network model to detect and identify the defect type and position coordinates of the casting.

2. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1 is characterized in that: The image preprocessing is to use a convolutional generative adversarial network to learn the real sample distribution through a group of random noises, enhance the features of the defective image, and generate new sample data.

3. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1, characterized in that: The defect labeling is to label the defects in each preprocessed image using a graphic image annotation tool labeling.

4. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1, characterized in that: The casting is an aluminum alloy casting commonly used in the automobile industry.

5. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1, characterized in that: There are six types of defects.

6. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1, characterized in that: The various comparison models include the original YOLOv5 model, the improved YOLOv5-SNv2-SE and YOLOv5-MNv2-SE network models.

7. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1, characterized in that: The improved YOLOv5 network model is the YOLOv5-MNv2-SE model.

8. The method for automatic identification of casting defects based on X-ray images of improved neural networks according to claim 1, characterized in that: The various indicators of the evaluation model include GIoU Loss (generalized intersection-over-union loss), Objectness Loss (target detection loss), Classification (quasi-target classification loss), Precision (accuracy), Recall (recall rate), mAP@0.5 (the average precision of multiple categories under the generalized intersection-over-union threshold of 0.5), and mAP@0.5:0.95 (the average precision of multiple categories under the varying intersection-over-union threshold).