Strip steel surface defect data enhancement method based on Wasserstein GAN
The adversarial network generated by Wasserstein GAN solves the problem of data imbalance in strip surface defect detection, generates high-quality false data, improves the recognition performance and generalization ability of the model, and solves the problem of insufficient defect detection accuracy in the existing technology. question.
Patent Information
- Application Number
- CN202410678656.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-29
- Publication Date
- 2024-09-17
AI Technical Summary
In the steel manufacturing industry, there are problems of category imbalance and insufficient labeled sample data in strip surface defect detection, which results in the deep learning model's insufficient ability to identify a few categories of defects and affects the model's defect recognition performance.
The data enhancement method based on Wasserstein GAN is used to generate false data similar to real defect images through a generative adversarial network, supplement the original data set, and construct an enhanced data set for training deep learning classification models and alleviating the problem of data imbalance.
It improves the training efficiency and recognition performance of the classification model, enhances the generalization ability of the model, and improves the recognition accuracy of strip surface defects.
Smart Images

Figure CN118658023A
Abstract
Description
Technical Field
[0001] The present invention relates to the field of steel surface defect recognition, and in particular to a strip steel surface defect data enhancement method based on Wasserstein GAN. Background Art
[0002] In the steel manufacturing industry, the quality of strip products is directly related to the safety and reliability of downstream applications. The presence of surface defects on strips, such as cracks, inclusions, scale, etc., not only affects the appearance quality of the product, but may also weaken its mechanical properties and shorten the product life. Therefore, timely and accurate detection and classification of surface defects on strips are crucial to ensure product quality, improve production efficiency and reduce enterprise costs.
[0003] Traditional strip surface defect detection methods mainly rely on manual visual inspection, which is time-consuming and error-prone. With the development of machine learning and deep learning technologies, automatic defect detection systems based on image processing have gradually become a research hotspot. However, deep learning models, especially convolutional neural networks and their variants, usually require a large amount of labeled data for training to achieve accurate recognition and classification of various defect types.
[0004] In actual industrial production environments, the obtained strip surface defect datasets often have problems of category imbalance or insufficient labeled sample data. This will cause the model to be unable to fully learn the characteristics of various defects during the training process, especially the defect categories with a small number of samples. This unbalanced data distribution may lead to insufficient recognition of defects of a few categories by the model, thereby affecting the defect recognition performance of the model. Therefore, the present invention provides a strip surface defect data enhancement method based on Wasserstein GAN. Summary of the invention
[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a strip surface defect data enhancement method based on Wasserstein GAN.
[0006] The purpose of the present invention can be achieved by the following technical solutions:
[0007] The present invention provides a strip steel surface defect data enhancement method based on Wasserstein GAN, comprising the following steps:
[0008] Step S1, preprocessing the original image data set of strip surface defects;
[0009] Step S2, constructing a generative model and a discriminative model of a generative adversarial network, wherein the generative model consists of 1 fully connected layer and 4 deconvolution upsampling layers; the discriminative model consists of 4 convolution downsampling layers and 1 fully connected layer;
[0010] Step S3, inputting the original image data set into a generative adversarial network for training. In each training process, the parameters of the generative adversarial network are updated by back propagation in two stages until the number of training times is reached to obtain a trained generative model.
[0011] Step S4, inputting the original image data set into the trained generation model to generate a false image, and supplementing the false image into the original image data set to obtain an enhanced image data set of surface defects of the strip.
[0012] The fully connected layer of the generative model uses Mish as the activation function, the first, second and third deconvolution layers use LeakyReLU as the activation function, and the fourth deconvolution layer uses Tanh as the activation function.
[0013] The first convolutional downsampling layer of the discriminant model uses Mish as the activation function, the second, third and fourth convolutional downsampling layers use LeakyReLU as the activation function, and the fully connected layer does not set the activation function.
[0014] The generative model uses batch normalization to unify the input data of the entire batch, and the discriminative model uses instance normalization to normalize each image separately.
[0015] Furthermore, the fully connected layer and the first, second and third convolutional layers of the generative model all use batch normalization operations, and the fourth deconvolutional layer does not use any normalization operation.
[0016] All convolutional downsampling layers of the discriminant model use instance normalization operations, and the fully connected layers do not use any normalization operations.
[0017] The two back-propagation stages complete the training, including: in the first stage, the discriminant model calculates the difference between the generated false image and the real image distribution, obtains the loss value of the discriminant model loss function, adds a gradient penalty to the loss value, and then performs back-propagation training to update only the parameters of the discriminant model;
[0018] In the second stage, the generative model generates false images again, and passes the false images and real images through the discriminant model together. The loss function of the generative model calculates the gap between the distributions of the two types of images, and obtains the loss value of the generative model loss function. Then, back propagation is performed and only the parameters of the generative model are updated. When the set number of training times is reached, a trained generative model is obtained.
[0019] Furthermore, the generative model loss function is as follows:
[0020]
[0021] Among them, G is the generating network, D is the discriminating network, and z is the noise p from the standard normal distribution. z (z), D(G(z)) is the score of the discriminator on the generator, and the Wasserstein distance is directly calculated.
[0022] The discriminant model loss function is as follows:
[0023]
[0024] in, represents the expected value, G is the generating network, D is the discriminating network, and p data (x) is the distribution of real data, p z (z) is the noise distribution that conforms to the standard normal distribution, and x is the noise distribution from the real data p data (x) is the real data sample extracted from the noise p z (z), D(x) is the score of the discriminator on the real data, and D(G(z)) is the score of the discriminator on the generator. is the interpolation sample between the real data and the generated data, is the gradient of the discriminator with respect to these interpolated samples, and λ is the hyperparameter of the gradient penalty.
[0025] The deep learning classification models include VGG16, Resnet50, and VIT16.
[0026] Compared with the prior art, the present invention has the following beneficial effects:
[0027] The strip surface defect data enhancement method based on Wasserstein GAN in the embodiment of the present invention, especially the generative adversarial network based on Wasserstein GAN and gradient penalty, can generate high-quality data similar to real strip surface defect image samples, thereby expanding the training data set, improving the training efficiency of the classification model and the defect recognition performance. At the same time, it alleviates the class imbalance problem existing in the original data set, helps the classification model to conduct more comprehensive training, and improves the generalization ability of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a flowchart of steps of an embodiment of the present invention;
[0029] Figure 2 is a diagram of a generative adversarial network structure according to an embodiment of the present invention;
[0030] Figure 3 is a generated network structure diagram of an embodiment of the present invention;
[0031] Figure 4 4 is a diagram of a discriminant network structure according to an embodiment of the present invention. DETAILED DESCRIPTION
[0032] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.
[0033] This embodiment provides a strip surface defect data enhancement method based on Wasserstein GAN, such as Figure 1 As shown, the following steps are included:
[0034] Step S1, preprocessing the strip surface defect image data and dividing it into a test set.
[0035] Specifically, this embodiment uses a publicly available raw image dataset of strip surface defects, NEU-CLS. Preprocessing the strip surface defect images includes unifying the size of all images and storing them in corresponding folders according to categories; and randomly selecting 100 images from all categories as the test set.
[0036] Step S2, constructing a generative model and a discriminative model of a generative adversarial network.
[0037] Specifically, Figure 2 , Figure 3 and Figure 4 As shown in the figure, the generation model consists of 1 fully connected layer and 4 deconvolution upsampling layers, and the discriminative model consists of 4 convolution downsampling layers and 1 fully connected layer.
[0038] The activation function of the first shallow network of the generative model and the discriminative model all uses Mish, and the remaining deep networks mostly use LeakyReLU. Specifically, for the generative model, such as Figure 3 As shown in , the fully connected layer uses Mish as the activation function, the first, second and third deconvolution layers use LeakyReLU as the activation function, and the last fourth deconvolution layer uses Tanh as the activation function; for the discriminant model, as shown in Figure 4 As shown in the figure, the first convolutional downsampling layer uses Mish as the activation function, the second, third and fourth convolutional downsampling layers use LeakyReLU as the activation function, and the last fully connected layer does not set the activation function.
[0039] The generator network uses batch normalization to unify the input data of the entire batch, and the discriminator network uses instance normalization to normalize each image separately. Specifically, for the generator model, batch normalization is used in the fully connected layer and the first, second, and third convolutional layers, and the last fourth deconvolutional layer does not use any normalization operation; for the discriminator model, all convolutional downsampling layers use instance normalization operations, and the last fully connected layer does not use any normalization operation.
[0040] Step S3, input the original image data set into the generative adversarial network training, train and update the parameters in the network until the network training times are reached to obtain a trained generative model.
[0041] Specifically, in each training process, the training is completed by two back propagation stages. Figure 2 As shown, in the first stage, first, the noise that meets the standard normal distribution passes through the generative model to generate a false image, and the false image and the real image pass through the discriminant model together. The loss function of the discriminant model calculates the difference between the distribution of the two types of images to obtain the loss value of the discriminant function, and at the same time adds a gradient penalty to the loss value of the discriminant function, and then back propagates, and only updates the parameters of the discriminant model. In the second stage, the generative model generates a false image again according to the above conditions, and the false image and the real image pass through the discriminant model together. The difference between the distribution of the two types of images is calculated by the loss function of the generative model to obtain the loss value, and then back propagates, and only updates the parameters of the generative model. Repeat the above training process until the number of trainings reaches the preset requirement. In this embodiment, the preset number of trainings is 500 times.
[0042] The generative network loss function of the generative adversarial network of the strip surface defect data enhancement method based on Wasserstein GAN is as follows:
[0043]
[0044] In the formula, G is the generating network, D is the discriminating network, and z is the noise P from the standard normal distribution. Z (z), D(G(z)) is the score of the discriminator on the generator, and the Wasserstein distance is directly calculated.
[0045] The discriminant network loss function of the generative adversarial network of the strip surface defect data enhancement method based on Wasserstein GAN is as follows:
[0046]
[0047] In the formula, represents the expected value, G is the generating network, D is the discriminating network, and p data(x) is the distribution of real data, p z (z) is the noise distribution that conforms to the standard normal distribution, and x is the noise distribution from the real data p data (x) is the real data sample extracted from the noise p z (z), D(x) is the score of the discriminator on the real data, and D(G(z)) is the score of the discriminator on the generator. is the interpolation sample between the real data and the generated data, is the gradient of the discriminator with respect to these interpolated samples, and λ is the hyperparameter of the gradient penalty.
[0048] The goal of these loss functions is to train the generator to generate data that is closer and closer to the real data distribution, while training the discriminator to distinguish between real data and generated data more and more accurately.
[0049] Furthermore, in order to verify the effect of this embodiment on strip surface defect data enhancement, the data enhanced images and the original images were used to train the deep learning classification model respectively, and the effect of the strip surface defect data enhancement method was verified by improving the recognition performance.
[0050] Step S4, using the generative model to generate image data to supplement the original data set.
[0051] Table 1. Number of defects in the original data set
[0052]
[0053] Specifically, the generative model is used to generate image datasets for defect category images that account for a relatively small proportion of the original dataset. Table 1 shows all defect categories included in the original dataset and the corresponding number of samples. The generative model is used to generate image data for six defect categories, namely ps, in, sc, sp, gg, and rp. The generated image data is supplemented into the original dataset to construct a new enhanced dataset.
[0054] Step S5, dividing the enhanced image data set into a training set and a verification set;
[0055] Specifically, the constructed enhanced dataset is divided into training data, and the training set and validation set account for 80% and 20% of the new dataset respectively.
[0056] Step S6, constructing a deep learning classification model, training and updating the parameters in the deep learning classification model using the original image data set and the enhanced image data set until convergence, to obtain the trained first and second deep learning classification models respectively.
[0057] Specifically, the classification models constructed include VGG16, Resnet50 and VIT16. The images after data set division are input into the classification model. The defect category of the image is calculated by the model. The loss value is calculated by the result information and the category label, and then backpropagation is performed to update the model parameters until the model converges.
[0058] Step S7, input the test set into the first and second deep learning classification models respectively, and obtain two defect recognition results respectively. By comparing the two defect recognition results, the quality of the false image generated by the generative adversarial network through the second deep learning classification model trained by the enhanced image data set is judged.
[0059] Specifically, the defect image is input into the trained model for classification to obtain the defect recognition result. The data supplement data set generated by the strip surface defect data enhancement method based on Wasserstein GAN in this embodiment and the data set composed of other methods are trained separately. The comprehensive recognition accuracy of the classification model on the test set is shown in Table 2:
[0060] Table 2 Comparison of comprehensive accuracy of defect recognition of classification models before and after enhancing the dataset
[0061]
[0062] From the results in Table 2, it can be seen that the strip surface defect data enhancement method based on Wasserstein GAN in this embodiment can generate high-quality defect data images to supplement the original data set. The newly constructed enhanced data set improves the training efficiency of the classification model and the recognition performance of defects for deep classification. Compared with the original data set, the accuracy is improved by 2.77%, 1.56% and 1.56% on VGG16, Resnet50 and VIT respectively. It shows that the data generation method in this embodiment can well generate high-quality data for supplementation, which is helpful for more comprehensive training of the classification model, improves the generalization ability of the model, and has high application value.
[0063] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.
Claims
1. A strip surface defect data enhancement method based on Wasserstein GAN, characterized in that: The following steps are involved: Step S1, preprocessing the original image data set of strip surface defects; Step S2, constructing a generative model and a discriminative model of a generative adversarial network, wherein the generative model consists of 1 fully connected layer and 4 deconvolution upsampling layers; the discriminative model consists of 4 convolution downsampling layers and 1 fully connected layer; Step S3, inputting the original image data set into a generative adversarial network for training. In each training process, the parameters of the generative adversarial network are updated by back propagation in two stages until the number of training times is reached to obtain a trained generative model. Step S4, inputting the original image data set into the trained generation model to generate a false image, and supplementing the false image into the original image data set to obtain an enhanced image data set of surface defects of the strip.
2. The method for enhancing surface defect data of strip steel based on Wasserstein GAN according to claim 1, characterized in that: The fully connected layer of the generative model uses Mish as the activation function, the first, second and third deconvolution layers use LeakyReLU as the activation function, and the fourth deconvolution layer uses Tanh as the activation function.
3. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 1, characterized in that: The first convolutional downsampling layer of the discriminant model uses Mish as the activation function, the second, third and fourth convolutional downsampling layers use LeakyReLU as the activation function, and the fully connected layer does not set the activation function.
4. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 1, characterized in that: The generative model uses batch normalization to unify the input data of the entire batch, and the discriminative model uses instance normalization to normalize each image separately.
5. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 4, characterized in that: The fully connected layer and the 1st, 2nd and 3rd convolutional layers of the generative model all use batch normalization operations, and the 4th deconvolutional layer does not use any normalization operation.
6. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 4, characterized in that: All convolutional downsampling layers of the discriminant model use instance normalization operations, and the final fully connected layer does not use any normalization operation.
7. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 1, characterized in that: The two back-propagation stages complete the training, including: in the first stage, the discriminant model calculates the difference between the generated false image and the real image distribution, obtains the loss value of the discriminant model loss function, adds a gradient penalty to the loss value, and then performs back-propagation training to update only the parameters of the discriminant model; In the second stage, the generative model generates false images again, and passes the false images and real images through the discriminant model together. The loss function of the generative model calculates the gap between the distributions of the two types of images, and obtains the loss value of the generative model loss function. Then, back propagation is performed and only the parameters of the generative model are updated. When the set number of training times is reached, a trained generative model is obtained.
8. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 7, characterized in that: The generative model loss function is as follows: Among them, G is the generating network, D is the discriminating network, and z is the noise p from the standard normal distribution. z (z), D(G(z)) is the score of the discriminator on the generator, and the Wasserstein distance is directly calculated.
9. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 7, characterized in that: The discriminant model loss function is as follows: in, represents the expected value, G is the generating network, D is the discriminating network, and p data (x) is the distribution of real data, p z (z) is the noise distribution that conforms to the standard normal distribution, and x is the noise distribution from the real data p data (x) is the real data sample extracted from the noise p z (z), D(x) is the score of the discriminator on the real data, and D(G(z)) is the score of the discriminator on the generator. is the interpolation sample between the real data and the generated data, is the gradient of the discriminator with respect to these interpolated samples, and λ is the hyperparameter of the gradient penalty.
10. The method for enhancing strip surface defect data based on Wasserstein GAN according to claim 1, characterized in that: The deep learning classification models include VGG16, Resnet50, and VIT16.
Citation Information
Patent Citations
Unsupervised enhancement method for surface defect image data of hot-rolled plate coil
CN111986142A
Strip steel surface small target defect detection method and system based on super-resolution and YOLOv8
CN116630301A
Cited By
Tire defect detection method based on anomaly detection and conditional generative adversarial network
CN120088199A
Data processing method and device, electronic equipment and storage medium
CN120689277A
Data processing method and apparatus, electronic device, and storage medium
CN120689277B
Rotating shaft simulation data enhancement method and system combined with generative adversarial network
CN121389804A
Method and system for data augmentation of simulated data with rotation axis for generative adversarial networks
CN121389804B
