Data processing method and device, electronic equipment and storage medium
By initializing and updating the parameters of the target defect image generation model, the problem of insufficient accuracy of generated defect data is solved and the effect of defect analysis is improved.
Patent Information
- Application Number
- CN202510656800.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-09-23
- Estimated Expiration
- 2045-05-21
AI Technical Summary
Existing technologies have difficulty generating sufficient, high-quality, and fully labeled defect data, resulting in low accuracy of defect analysis models.
By obtaining the sample model parameters of the pre-trained reference defect image generation model, the pre-built target defect image generation model is initialized, and the model parameters are updated in combination with the real defect image to generate high-quality virtual defect images.
The accuracy of defect data generation is improved, the performance of the model is optimized, and the effect of defect analysis is enhanced.
Smart Images

Figure CN120689277A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a data processing method and device, an electronic device, and a storage medium. Background Art
[0002] Defect analysis refers to the process of analyzing product defect data collected during industrial production through technical means. For example, images of metal parts or glass products with surface defects can be analyzed to identify characteristics such as defect type, location, and severity. By analyzing defect data, defect characteristics can be quantified and their causes traced, providing data support for optimizing industrial production processes and improving products.
[0003] Existing technologies typically use models for defect analysis, but these models require a large amount of defect data. However, in actual production, sufficient, high-quality, and fully labeled defect data is difficult to obtain, making it difficult for models to accurately determine the characteristics of product defects. Therefore, data processing methods are needed to simulate various possible defect characteristics in products to generate corresponding defect data and provide sufficient data support for defect analysis.
[0004] However, in the related art, the accuracy of the generated defect data is low. Summary of the Invention
[0005] The main purpose of the embodiments of the present application is to provide a data processing method and device, an electronic device and a storage medium, which can improve the accuracy of generated defect data.
[0006] To achieve the above objectives, a first aspect of an embodiment of the present application provides a data processing method, the method comprising: Obtaining sample model parameters of a pre-trained reference defect image generation model, and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters; Acquire a defect image feature set, wherein the defect image feature set includes a first sample defect feature generated by the reference defect image generation model; Calling the target defect image generation model after model parameter initialization to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image; updating the model parameters of the target defect image generation model after the model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set; A target defect image set is constructed based on the target defect image generation model and the target virtual defect image after the model parameters are updated.
[0007] In some embodiments, the reference defect image generation model includes an encoding layer and a decoding layer, and the training process of the reference defect image generation model includes the following steps: Obtaining a first sample defect image training set; Calling the encoding layer to extract defect features from the first sample defect image training set to obtain second sample defect features; Calling the decoding layer to perform a defect image generation operation on the second sample defect feature to obtain a first sample virtual defect image; The model parameters of the reference defect image generation model are updated based on the first sample virtual defect image and the real defect image corresponding to the first sample defect image training set.
[0008] In some embodiments, the sample model parameters include first model parameters, and the target defect image generation model includes a generation layer; The acquiring of sample model parameters of a pre-trained reference defect image generation model and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters includes: When the reference defect image generation model completes training, obtaining a first model parameter of the decoding layer; Initializing model parameters of the generating layer based on the first model parameters; The target defect image generation model after calling the model parameters initialized performs a defect image generation operation on the defect image feature set to obtain a target virtual defect image, including: The generation layer after model parameter initialization is called to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image.
[0009] In some embodiments, the sample model parameters further include a second model parameter, and the target defect image generation model includes a discriminant layer; The acquiring of sample model parameters of a pre-trained reference defect image generation model and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters includes: When the reference defect image generation model completes training, obtaining a second model parameter of the encoding layer; Initializing the model parameters of the discriminant layer based on the second model parameters; The updating of model parameters of the target defect image generation model after model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set includes: The model parameters of the discriminant layer after model parameter initialization and the generative layer after model parameter initialization are updated based on the target virtual defect image and the real defect image corresponding to the defect image feature set.
[0010] In some embodiments, constructing a target defect image set based on the target defect image generation model and the target virtual defect image after the model parameters are updated includes: Performing quality inspection on the target virtual defect image to obtain a quality inspection score; When the quality detection score is greater than or equal to a preset threshold, constructing an initial defect image set based on the target virtual defect image and the first sample defect image training set; The target defect image generation model after model parameter update is called to perform a defect image generation operation on the initial defect image set, and the target defect image set is constructed based on the generated virtual defect image and the initial defect image set.
[0011] In some embodiments, the encoding layer includes a convolutional layer, a first fully connected layer, and a second fully connected layer. Calling the encoding layer to extract defect features from the first sample defect image training set to obtain second sample defect features includes: Calling the convolution layer to extract defect features from the first sample defect image training set to obtain sample convolution features; Calling the first fully connected layer to perform mean feature normalization on the sample convolution feature to obtain a sample mean feature; Calling the second fully connected layer to perform variance feature normalization on the sample convolution feature to obtain a sample variance feature; The second sample defect feature is determined based on the sample mean feature and the sample variance feature.
[0012] In some embodiments, the decoding layer includes a third fully connected layer and a deconvolution layer, and calling the decoding layer to perform a defect image generation operation on the second sample defect feature to obtain a first sample virtual defect image includes: Calling the third fully connected layer to perform potential feature normalization on the second sample defect feature to obtain a sample potential feature; The deconvolution layer is called to perform a defect image generation operation on the sample potential features to obtain the first sample virtual defect image.
[0013] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a data processing device, comprising: A parameter acquisition module, configured to acquire sample model parameters of a pre-trained reference defect image generation model, and initialize model parameters of a pre-built target defect image generation model based on the sample model parameters; a data acquisition module, configured to acquire a defect image feature set, wherein the defect image feature set includes first sample defect features generated by the pre-trained reference defect image generation model; An image generation module is used to call the target defect image generation model after the model parameters are initialized to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image; a parameter updating module, configured to update the model parameters of the target defect image generation model after the model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set; A data generation module is used to construct a target defect image set based on the target defect image generation model and the target virtual defect image after the model parameters are updated.
[0014] To achieve the above-mentioned purpose, the third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the method described in the first aspect when executing the computer program.
[0015] To achieve the above-mentioned purpose, the fourth aspect of the embodiments of the present application proposes a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the method described in the first aspect.
[0016] The data processing method and device, electronic device and storage medium proposed in the present application obtain sample model parameters of a pre-trained reference defect image generation model, and initialize the model parameters of a pre-built target defect image generation model based on the sample model parameters; obtain a defect image feature set, which includes a first sample defect feature generated by the pre-trained reference defect image generation model; call the target defect image generation model after the model parameter initialization to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image; update the model parameters of the target defect image generation model after the model parameter initialization based on the target virtual defect image and the real defect image corresponding to the defect image feature set; and construct a target defect image set based on the target defect image generation model and the target virtual defect image after the model parameter update.
[0017] The present application initializes the model parameters of the target defect image generation model using the sample model parameters of the pre-trained reference defect image generation model, and determines the target virtual defect image through the initialized target defect image generation model based on the defect image feature set, and then updates the model parameters of the initialized target defect image generation model based on the target virtual defect image and the real defect image. In this way, the model parameters of the target defect image generation model can be initialized using the model parameters of the pre-trained model, thereby improving the initial performance of the target defect image generation model at the beginning of training, and the parameters of the target defect image generation model can be updated in combination with the real defect image to further optimize the performance of the model. That is, the present application can improve the accuracy of the generated defect data. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] Figure 1 is a flow chart of the data processing method provided in an embodiment of the present application; Figure 2 yes Figure 1 Flowchart of step S105 in FIG. Figure 3 This is a flowchart of the reference defect image generation model training process provided by an embodiment of the present application; Figure 4 yes Figure 3 Flowchart of step S302 in FIG. Figure 5 yes Figure 3 Flowchart of step S303 in FIG. Figure 6 This is a schematic diagram of a specific process of training a reference defect image generation model provided in an embodiment of the present application; Figure 7 This is a schematic diagram of the specific process of training the target defect image generation model provided in the embodiment of the present application; Figure 8 This is a schematic diagram of a specific flow chart of the data processing method provided in an embodiment of the present application; Figure 9 is a structural diagram of a data processing device provided in an embodiment of the present application; Figure 10 This is a schematic diagram of the hardware structure of the electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0019] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0020] It should be noted that although the device schematics illustrate functional module divisions and the flowcharts illustrate logical sequences, in certain circumstances, the steps shown or described may be performed in a sequence that differs from the module divisions in the device or the sequence in the flowcharts. The terms "first," "second," and so on, in the specification, claims, and drawings, are used to distinguish similar items and are not necessarily used to describe a specific sequence or precedence.
[0021] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application pertains. The terms used herein are for the purpose of describing the embodiments of this application only and are not intended to limit this application.
[0022] First, let’s analyze some of the terms used in this application: A neural network model is a computational model inspired by biological neural networks and used in machine learning and artificial intelligence. It consists of a hierarchy of neurons, each connected to the neurons in the next layer. These connections have weights, and through these weights and activation functions, the neural network can learn complex patterns and relationships in the input data.
[0023] Convolutional Neural Network (CNN): A deep neural network model designed to process grid-structured data. In defect data generation tasks, CNN learns the mapping between input defect images and corresponding complete features, extracts defect features from the image, and optimizes them to generate defect data.
[0024] Generative Adversarial Network (GAN): A neural network model consisting of a generator and a discriminator. In defect data generation tasks, GANs use adversarial training between the generator and the discriminator. The generator continuously learns to generate realistic defective image data to deceive the discriminator, while the discriminator strives to distinguish between real defective image data and generated defective image data. Ultimately, the generator's defective image data becomes indistinguishable from real defective image data, thus generating defective data.
[0025] An autoencoder (AE) is an unsupervised neural network model consisting of an encoder and a decoder. The encoder uses a neural network to compress input data into a low-dimensional representation (encoding) in a latent space, while the decoder attempts to reconstruct the original input data from this encoding. In defect data generation tasks, the AE can learn effective feature representations of defect data. By minimizing the difference between the input and the reconstructed output, the model can grasp the key characteristics of the defect.
[0026] Variational Autoencoder (VAE): A generative model that uses an encoder to map input data to the mean and variance of a latent space. It then samples the latent variables using a reparameterization technique, and uses a decoder to restore the sampled latent variables to the original data. In defect data generation tasks, VAEs can learn the latent distribution of defect data, capture the overall structure of defect features, and generate new defect data with similar characteristics.
[0027] With the increasing automation and intelligence of industrial production, defect analysis has gradually become an important means of improving product quality. However, traditional defect analysis methods, such as manual inspection and image processing technology, have shortcomings such as low efficiency, strong subjectivity, and susceptibility to human factors. Due to the strong feature learning capabilities of deep learning methods, existing technologies generally use deep learning methods for defect analysis. However, due to the low probability of product defects in industrial production, the variety of defect types, and the high cost of artificial manufacturing defects and labeling, the field of industrial defect analysis generally suffers from data scarcity and category imbalance. In other words, it is difficult to obtain sufficient, high-quality, and fully labeled defect datasets. As a result, defect analysis based on deep learning methods lacks qualified training data, making it difficult to capture the key features of defects, which in turn affects the performance of defect analysis. Therefore, it is necessary to simulate the various defect features that may occur in products through data processing methods to generate corresponding defect data and provide sufficient data support for defect analysis.
[0028] However, the accuracy of defect data generated in related technologies is low. For example, traditional data processing methods, such as geometric transformations like rotation, translation, and cropping, can expand defect data to a certain extent, but they struggle to generate data with realistic defect characteristics. Alternatively, resampling-based techniques, such as oversampling minority class data or undersampling majority class data, can result in defect information loss or overfitting. Related technologies also train defect data generation models using a small amount of existing defect sample data, enabling the model to grasp the defect feature distribution of the defect data. This trained defect data generation model can then be used to cost-effectively generate large amounts of realistic defect data. For example, GAN models generate defect data through adversarial training between a generator and a discriminator. However, the GAN model training process is unstable and prone to mode collapse, resulting in relatively monotonous defect data that fails to fully capture the complexity and diversity of defect data. Furthermore, GAN models require extensive random trial-and-error to generate high-quality defect data. The unstable adversarial relationship between the generator and the discriminator can lead to slow training convergence or even failure, increasing training difficulty and further wasting computing resources. Alternatively, VAE models generate defect data by learning the overall distribution and structural characteristics of the data. However, the VAE model generation effect is limited by the distribution of the latent space, and there are obvious deficiencies in restoring the details of defect features. As a result, the generated defect data is prone to problems such as blurred details or feature loss. Based on this, the embodiment of the present application provides a data processing method to improve the accuracy of the generated defect data.
[0029] The data processing method provided in the embodiment of the present application relates to the field of computer technology. The data processing method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, or can be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the data processing method, etc., but is not limited to the above forms.
[0030] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, and the like. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, and the like that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments in which tasks are performed by remote processing devices connected via a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.
[0031] Figure 1 This is an optional flowchart of the data processing method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S105.
[0032] Step S101, obtaining sample model parameters of a pre-trained reference defect image generation model, and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters; Step S102, obtaining a defect image feature set; Step S103, calling the target defect image generation model after the model parameters are initialized to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image; Step S104, updating the model parameters of the target defect image generation model after the model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set; Step S105 , constructing a target defect image set based on the target defect image generation model and the target virtual defect image after the model parameters are updated.
[0033] In step S101 of some embodiments, the pre-trained reference defect image generation model may refer to a neural network model pre-trained based on a completed defect data generation task related to the current task. For example, the pre-trained reference defect image generation model may be an AE model trained for the task of generating surface defect images of electronic components; alternatively, the pre-trained reference defect image generation model may be a VAE model trained for the task of generating internal defect images of metal materials, without specific limitation. The sample model parameters may refer to the network weights of the pre-trained reference defect image generation model. For example, if the pre-trained reference defect image generation model is a trained VAE model, the sample model parameters may be the connection weights between the neurons in each layer of the decoder and encoder of the pre-trained reference defect image generation model. The pre-built target defect image generation model may refer to a neural network model built for the current specific defect data generation task. For example, the pre-built target defect image generation model may be a GAN model used to generate surface defect images of electronic components; alternatively, the pre-built target defect image generation model may be a CNN model used to generate internal defect images of metal materials, without specific limitation. It is understood that the pre-built target defect image generation model and the pre-trained reference defect image generation model are designed for the same defect data generation scenario. For example, if the reference defect image generation model was trained for the generation of metal surface defect images, then the target defect image generation model should also be used for this scenario. Model parameter initialization can refer to the process of migrating the sample model parameters of the pre-trained reference defect image generation model to the pre-built target defect image generation model.
[0034] In step S102 of some embodiments, the defect image feature set may refer to a collection of first sample defect features generated by a pretrained reference defect image generation model and the corresponding real defect image. For example, if the pretrained reference defect image generation model is a trained VAE model, the defect image feature set may be a latent feature vector obtained by the VAE model and the real defect image corresponding to the latent feature vector. The first sample defect feature may refer to a feature vector containing defect information generated by the pretrained reference defect image generation model; the real defect image may refer to the actual, defective image corresponding to the feature vector. For example, in the task of generating a surface defect image of a metal material, the first sample defect feature may be a latent feature vector obtained by processing an input image of a scratched metal material surface by the VAE model; the real defect image may refer to the actual, defective metal material surface image corresponding to the latent feature vector. It will be understood that the defect image feature set may be formed by inputting a real defect image into the pretrained reference defect image generation model to generate a feature vector containing defect information, and then pairing the feature vector with the real defect image.
[0035] In step S103 of some embodiments, the target defect image generation model after model parameter initialization may refer to a model obtained by initializing the model parameters of a pre-built target defect image generation model using sample model parameters. The defect image generation operation may refer to the process of converting a first sample defect feature in a defect image feature set into an image using the target defect image generation model after model parameter initialization. The target virtual defect image may refer to a virtual defect image used to simulate a real defect feature, obtained by performing a defect image generation operation on the first sample defect feature using the target defect image generation model after model parameter initialization.
[0036] In step S104 of some embodiments, updating the model parameters of the target defect image generation model after the model parameters are initialized can be achieved by calculating the error between the target defect image generation model after the model parameters are initialized and the real defect image corresponding to the defect image feature set, and then adjusting the model parameters based on the error. It is understandable that embodiments of the present application can train the target defect image generation model after the model parameters are initialized by using multiple sets of first sample defect features and real defect images corresponding to the first sample defect features, and continuously iteratively update the model parameters, thereby gradually improving the accuracy of the defect data generated by the model.
[0037] In step S105 of some embodiments, the target defect image set may refer to an image set containing virtual defect images generated by the target defect image generation model after the model parameters have been updated. The target defect image set may be constructed by performing feature analysis on the target virtual defect images, extracting corresponding latent variable distribution features, randomly sampling the extracted latent variable distribution features, and then inputting the extracted latent variable distribution features into the target defect image generation model after the model parameters have been updated to generate a large number of virtual defect images. The latent variable distribution features refer to the defect distribution features in the latent variable space corresponding to the target virtual defect images.
[0038] See also Figure 2 In some embodiments, step S105 includes but is not limited to steps S201 to S203: Step S201, performing quality inspection on the target virtual defect image to obtain a quality inspection score; Step S202 , when the quality detection score is greater than or equal to a preset threshold, constructing an initial defect image set based on the target virtual defect image and the first sample defect image training set; Step S203 , calling the target defect image generation model after the model parameters are updated to perform a defect image generation operation on the initial defect image set, and constructing a target defect image set based on the generated virtual defect image and the initial defect image set.
[0039] In step S201 of some embodiments, quality detection may refer to the process of detecting the quality of the target virtual defect image using a specific algorithm or model. The quality detection score may refer to the score obtained by performing the quality detection on the target virtual defect image. For example, the target virtual defect image may be input into a CNN model for quality detection. The CNN model will output a score between 0 and 1, which is the quality detection score. The quality detection score is used to quantitatively assess the quality of the target virtual defect image.
[0040] In step S202 of some embodiments, the initial defect image set may refer to an image set constructed using target virtual defect images and the first sample defect image training set when the quality detection score is greater than or equal to a preset threshold. The preset threshold may refer to a pre-set value used to determine whether the defect characteristics of the target virtual defect image match those of the real defect image. It will be understood that when the quality detection score is less than the preset threshold, indicating that the defect characteristics of the target virtual defect image do not match those of the real defect image, the initial defect image set is the first sample defect image training set.
[0041] In step S203 of some embodiments, the target defect image set may refer to an image set containing virtual defect images generated by the target defect image generation model after the model parameters are updated. The target defect image set may be performed by the target defect image generation model after the model parameters are updated to perform a defect image generation operation on the initial defect image set, and perform feature analysis on the generated virtual defect image to extract the corresponding latent variable distribution features, and then randomly sample the extracted latent variable distribution features and input them into the target defect image generation model after the model parameters are updated to generate virtual defect images, and finally construct the virtual defect images by the generated virtual defect images and the target virtual defect images in the initial defect image set. Among them, the latent variable distribution features may refer to the distribution features of the virtual defect images obtained in the latent variable space after the target defect image generation model after the model parameters are updated performs a defect image generation operation on the initial defect image set. It can be understood that when iteratively training the target defect image generation model after the model parameters are updated, the embodiment of the present application can perform quality detection on the virtual defect image output by the model, so as to screen out virtual defect images that meet the defect characteristics of the real defect image, and add the virtual defect image to the first sample defect image training set for subsequent iterative training of the target defect image generation model after the model parameters are updated, so that the model of subsequent iterative training can learn more accurate defect characteristics, thereby improving the accuracy of the defect data generated by the model.
[0042] The training process of the reference defect image generation model and the target defect image generation model is described in detail below.
[0043] First, the training process of the reference defect image generation model is described. Figure 3 The reference defect image generation model includes an encoding layer and a decoding layer. The training process of the reference defect image generation model may include steps S301 to S304: Step S301, obtaining a first sample defect image training set; Step S302: calling the encoding layer to extract defect features from the first sample defect image training set to obtain second sample defect features; Step S303: calling the decoding layer to perform a defect image generation operation on the second sample defect feature to obtain a first sample virtual defect image; Step S304 : updating model parameters of the reference defect image generation model based on the first sample virtual defect image and the real defect image corresponding to the first sample defect image training set.
[0044] In step S301 of some embodiments, the first sample defect image training set may refer to an image set used to train a reference defect image generation model. The first sample defect image training set may include multiple images with real defects that are related to the current defect data generation task. For example, in the task of generating surface defect images of metal materials, the first sample defect image training set may be an image set containing multiple real defects on the surface of metal materials (such as scratches, pits, or cracks, etc.). It is understandable that the first sample defect image training set can be obtained by collecting images of defective products during the production process, and the first sample defect image training set can also be obtained from a publicly available defect image dataset, without specific limitation. It is understandable that the real defect images contained in the first sample defect image training set may be consistent with the real defect images contained in the defect image feature set.
[0045] In step S302 of some embodiments, the encoding layer may refer to a neural network layer used to extract image features in a reference defect image generation model. For example, if the reference defect image generation model is a CNN model, the encoding layer may be a convolutional layer and a downsampling layer; or, if the reference defect image generation model is a VAE model, the encoding layer may be a fully connected layer and a convolutional layer, without specific limitation. Defect feature extraction may refer to the process of processing an input real defect image through the encoding layer to generate a feature vector that can characterize the defect features in the real defect image. The second sample defect feature may refer to a feature vector containing defect features obtained after defect feature extraction is performed on the input real defect image through the encoding layer. For example, if the encoding layer is a convolutional layer and a pooling layer in a CNN model, the second sample defect feature may be a feature vector containing defect information obtained by inputting the real defect image into the convolutional layer for feature extraction, and inputting the extracted features into the downsampling layer for downsampling. It can be understood that by randomly sampling the second sample defect feature, the first sample defect feature in the defect image feature set can be obtained.
[0046] In step S303 of some embodiments, the decoding layer may refer to a neural network layer in the reference defect image generation model that is used to restore the feature vector to an image. For example, if the reference defect image generation model is a VAE model, the decoding layer may be a fully connected layer and a deconvolution layer; or, if the reference defect image generation model is a CNN model, the decoding layer may be a deconvolution layer and an upsampling layer, without specific limitation. The defect image generation operation may refer to the process of converting the second sample defect feature into an image through the decoding layer. The first sample virtual defect image may refer to a virtual defect image obtained by performing a defect image generation operation on the second sample defect feature through the decoding layer. For example, if the decoding layer is a deconvolution layer and an upsampling layer of a CNN model, the first sample virtual defect image may be a virtual defect image obtained by extracting features from the feature vector through the deconvolution layer and upsampling the extracted features through the upsampling layer.
[0047] In step S304 of some embodiments, updating the model parameters of the reference defect image generation model is achieved by calculating the parameters that need to be updated in the reference defect image generation model using the first sample virtual defect image and the real defect image corresponding to the first sample defect image training set, and then adjusting the model parameters of the reference defect image generation model based on the parameters that need to be updated. For example, the gradient value of the reference defect image generation model can be calculated based on the first sample virtual defect image and the real defect image corresponding to the first sample defect image training set based on the stochastic gradient descent method, and the adjustment direction and magnitude of the model parameters are determined based on the gradient value. The model parameters are then adjusted accordingly to achieve the parameter update of the reference defect image generation model. See also Figure 4In some embodiments, the encoding layer includes a convolutional layer, a first fully connected layer, and a second fully connected layer. Step S302 may include, but is not limited to, steps S401 to S404: Step S401: calling the convolution layer to extract defect features from the first sample defect image training set to obtain sample convolution features; Step S402: Call the first fully connected layer to perform mean feature normalization on the sample convolution features to obtain the sample mean feature; Step S403: Call the second fully connected layer to perform variance feature normalization on the sample convolution feature to obtain the sample variance feature; Step S404: determining a second sample defect feature based on the sample mean feature and the sample variance feature.
[0048] In step S401 of some embodiments, the convolution layer may refer to a neural network layer comprising a plurality of sequentially connected convolution units. For example, the convolution layer may comprise three sequentially connected convolution units, and the convolution layer may further comprise four sequentially connected convolution units, without specific limitation. Among them, the convolution unit may refer to a unit for performing a convolution operation. It can be understood that, among the multiple sequentially connected convolution units comprised in the convolution layer, the output of the previous convolution unit serves as the input of the next adjacent convolution unit. The convolution layer may be used to extract defect features from the input first sample defect image training set. Defect feature extraction may refer to the process of identifying and extracting defect features of real defect images in the first sample defect image training set through a convolution layer. Sample convolution features may refer to a defect feature map obtained after defect feature extraction is performed on real defect images in the first sample defect image training set through a convolution layer. For example, if the convolution layer includes three sequentially connected convolution units, the first sample defect image training set is first input into the first convolution unit for preliminary defect feature extraction to obtain the first sub-sample convolution feature; then the first sub-sample convolution feature is input into the second convolution unit for further defect feature extraction to obtain the second sub-sample convolution feature; finally, the second sub-sample convolution feature is input into the third convolution unit for final defect feature extraction to obtain the sample convolution feature. Among them, the first sub-sample convolution feature can refer to the defect feature map obtained after the first convolution unit performs preliminary defect feature extraction on the real defect image in the first sample defect image training set; the second sub-sample convolution feature can refer to the defect feature map obtained after the second convolution unit performs further defect feature extraction on the first sub-sample convolution feature. It can be understood that the sample convolution feature is obtained by outputting the last convolution unit among multiple sequentially connected convolution units. It can be understood that the embodiment of the present application can perform layer-by-layer defect feature extraction on the first sample defect image training set through multiple sequentially connected convolution units, gradually refine and extract the defect features of the real defect image, thereby improving the feature extraction performance of the reference defect image generation model.
[0049] In step S402 of some embodiments, the first fully connected layer may refer to a neural network layer that performs mean feature normalization on the input sample convolution features. Mean feature normalization may refer to the process of processing the sample convolution features through the first fully connected layer so that the output defect features have zero mean. The sample mean feature may refer to the feature vector obtained after the sample convolution features are mean normalized by the first fully connected layer.
[0050] In step S403 of some embodiments, the second fully connected layer may refer to a neural network layer that performs variance feature normalization on the input sample convolution features. Variance feature normalization may refer to the process of processing the sample convolution features through the second fully connected layer so that the output defect features have unit variance. The sample variance feature may refer to the feature vector obtained after variance feature normalization is performed on the sample convolution features through the second fully connected layer.
[0051] In step S404 of some embodiments, the second sample defect feature can be obtained by concatenating or fusing the sample mean feature and the sample variance feature. For example, the second sample defect feature can be obtained by concatenating the sample mean feature vector and the sample variance feature vector in element order to form a new feature vector. It can be understood that the embodiments of the present application fuse the mean information and variance information of the defect feature through the first fully connected layer and the second fully connected layer, so that the reference defect image generation model can more comprehensively learn the defect features of the real defect image, thereby improving the accuracy of the defect data generated by the model.
[0052] See also Figure 5 In some embodiments, the decoding layer includes a third fully connected layer and a deconvolution layer, and step S303 may also include but is not limited to steps S501 to S502: Step S501: Call the third fully connected layer to perform latent feature normalization on the second sample defect feature to obtain the sample latent feature; Step S502 : calling the deconvolution layer to perform a defect image generation operation on the sample potential features to obtain a first sample virtual defect image.
[0053] In step S501 of some embodiments, the third fully connected layer may refer to a neural network layer for performing potential feature normalization on the input second sample defect feature. Potential feature normalization may refer to the process of linearly transforming and scaling the second sample defect feature through the third fully connected layer, and randomly sampling the second sample defect feature after the linear transformation and scaling. The sample potential feature may refer to the feature vector obtained after the second sample defect feature is subjected to potential feature normalization by the second fully connected layer. It can be understood that the embodiment of the present application performs potential feature normalization on the second sample defect feature through the third fully connected layer, which can make the first sample virtual defect image generated by the reference defect image generation model in subsequent iterative training have diversity, and can synthesize virtual defect images containing various possible defect forms, thereby improving the generalization ability of the model.
[0054] In step S502 of some embodiments, the deconvolution layer may refer to a neural network layer comprising a plurality of sequentially connected deconvolution units. For example, the deconvolution layer may comprise three sequentially connected deconvolution units, or may comprise four sequentially connected deconvolution units, and the specific number of deconvolution units included in the deconvolution layer is consistent with the number of convolution units included in the convolution layer. Among them, the deconvolution unit may refer to a unit for performing a deconvolution operation. It can be understood that, among the multiple sequentially connected deconvolution units included in the deconvolution layer, the output of the previous deconvolution unit serves as the input of the next adjacent deconvolution unit. The deconvolution layer may be used to perform a defect image generation operation on the input sample potential features. The defect image generation operation may refer to the process of converting the sample potential features into an image through the deconvolution layer. The first sample virtual defect image may refer to the image obtained after the sample potential features are subjected to a defect image generation operation through the deconvolution layer. For example, if the deconvolution layer includes three sequentially connected deconvolution units, the sample potential features are first input into the first deconvolution unit for preliminary feature restoration to obtain a first sub-sample feature map; the first sub-sample feature map is then input into the second deconvolution unit for further feature restoration to obtain a second sub-sample feature map; and finally, the second sub-sample feature map is input into the third deconvolution unit for the final defect image generation operation to obtain a first sample virtual defect image. It can be understood that the embodiment of the present application performs defect image generation operations on the sample potential features layer by layer through multiple sequentially connected deconvolution units, gradually constructing a more refined and complete virtual defect image, so that the first sample virtual defect image is closer to the real defect image in terms of details and overall structure, thereby improving the accuracy of defect data generated by the model.
[0055] See also Figure 6 , Figure 6This is a schematic diagram of the detailed process flow for training the reference defect image generation model provided in an embodiment of the present application. The process specifically includes: First, real defect images from real production scenarios are collected through techniques such as equipment photography, industrial radiography, or red ink detection to construct a first sample defect image training set required for training. This training set contains real defect images with all possible defect features. The first sample defect image training set is preprocessed (e.g., size normalization or standardization) to provide more stable data input for training the reference defect image generation model. Then, the preprocessed real defect images, sized 128×128×3, are input into an encoder to obtain a feature map (i.e., the second sample defect feature) of size 512×8×8. The encoder consists of four sequentially connected convolutional units and two independent fully connected layers (i.e., the first fully connected layer and the second fully connected layer). Each convolutional unit uses a 4×4 convolution kernel with a stride of 2 and padding of 1. The number of channels in each convolutional unit is 64, 128, 256, and 512, respectively, increasing with each layer. Each convolutional unit is followed by batch normalization and a leaky rectified linear unit activation function (labeled "LeakyReLU activation function") to ensure training stability and efficient gradient propagation. Furthermore, the 512×8×8 feature map is flattened into a feature vector, which is fed into two separate fully-connected layers to generate the mean (i.e., mean feature normalization) and log-variance (i.e., variance feature normalization) of the latent space, thereby forming a probability distribution representation of the latent variable (i.e., the second sample defect feature). Furthermore, the probability distribution representation of the latent variable is sampled using a reparameterization technique, and the sampled latent variable is fed into the fully-connected layer (i.e., the third fully-connected layer) contained in the decoder, which maps the latent variable back to the sample latent feature of the same size as the encoder output, 512×8×8. The sample latent feature is then upsampled layer by layer through the four deconvolutional units contained in the decoder, outputting a reconstructed defect image (i.e., the first sample virtual defect image). The first three deconvolution layers are followed by batch normalization and a rectified linear unit activation function (labeled "ReLU activation function"), and the last deconvolution layer is followed by batch normalization and a hyperbolic tangent activation function (labeled "Tanh activation function") to improve reconstruction quality and model training stability. Each deconvolution unit uses a 4×4 convolution kernel with a stride of 2 and padding of 1. The number of channels in each convolution unit is 512, 256, 128, and 64, respectively, decreasing with each layer. Furthermore, the loss of the reference defect image generation model is calculated based on the reconstruction loss and distribution loss. The reconstruction loss measures the difference between the reconstructed image (i.e., the first sample virtual defect image) and the original input image (i.e., the real defect image corresponding to the first sample defect image training set) using the mean squared error (MSE) to ensure the quality of the reconstructed image.The distribution loss reflects the difference between the potential distribution of the encoder output (i.e., the second sample defect feature) and the standard normal distribution (i.e., a Gaussian distribution with a mean of 0 and a variance of 1). It is understandable that the embodiment of the present application can set corresponding weight coefficients for the reconstruction loss and the distribution loss respectively, and perform weighted calculation of the reconstruction loss and the distribution loss by the set weight coefficients to determine the loss of the reference defect image generation model. By setting the weight coefficients in this way, the attention of the reference defect image generation model to specific losses during the training process can be enhanced, thereby improving the training effect. Finally, the calculated loss is used to update the parameters of the model through the back propagation algorithm and with the help of the Adam optimizer (labeled as "Adam optimizer"). It is understandable that the reference defect image generation model of the embodiment of the present application can complete the training of the model by repeating the above training process, after multiple iterations, until the loss function converges or reaches a preset number of training times.
[0056] Secondly, the training process of the target defect image generation model is explained.
[0057] In some embodiments, the sample model parameters include first model parameters, the target defect image generation model includes a generation layer, and step S101 may include the following sub-steps: When the reference defect image generation model completes training, obtaining the first model parameter of the decoding layer; Initialize the model parameters of the generation layer based on the first model parameters.
[0058] In some embodiments, the first model parameter may refer to the network weight corresponding to the decoding layer of a trained reference defect image generation model (i.e., a pre-trained reference defect image generation model). Initializing the model parameters of the generation layer can be achieved by migrating the first model parameter to the generation layer of the target defect image generation model. It will be understood that the embodiments of the present application initialize the network weights of the generation layer of the target defect image generation model using the network weights corresponding to the decoding layer of the trained reference defect image generation model. This can utilize the latent spatial feature distribution and structural features of the real defect data learned by the trained reference defect image generation model to accelerate the training process of the target defect image generation model, thereby reducing the computational complexity of the model.
[0059] Step S103 may include the following sub-steps: The generation layer after model parameter initialization is called to perform defect image generation operation on the defect image feature set to obtain the target virtual defect image.
[0060] In some embodiments, the target virtual defect image may refer to a virtual defect image obtained by performing a defect image generation operation on a defect image feature set by calling a generation layer after model parameter initialization. For example, if the target defect image generation model is a GAN model, the generation layer of the GAN model after model parameter initialization may be called to restore the first sample defect feature in the defect image feature set to the target virtual defect image. It is understandable that the embodiment of the present application generates the target virtual defect image by calling a generation layer after model parameter initialization, which can avoid the mode collapse problem caused by excessive randomness of a single model and ensure that the generated virtual defect image maintains good continuity, diversity and structural consistency in the latent space.
[0061] In some embodiments, the sample model parameters further include a second model parameter, the target defect image generation model includes a discriminant layer, and step S101 may include the following sub-steps: When the reference defect image generation model completes training, obtaining a second model parameter of the encoding layer; The model parameters of the discriminant layer are initialized based on the second model parameters.
[0062] In some embodiments, the second model parameter may refer to the network weight corresponding to the encoding layer of the reference defect image generation model that has completed training. Initializing the model parameters of the discriminant layer can be achieved by migrating the second model parameter to the discriminant layer of the target defect image generation model. It can be understood that the embodiment of the present application initializes the network weight corresponding to the discriminant layer of the target defect image generation model by using the network weight corresponding to the encoding layer of the reference defect image generation model that has completed training. The feature extraction capability that has been learned by the trained model can be used to improve the discriminant layer's discrimination performance for the target virtual defect image, thereby improving the accuracy of the defect data generated by the model.
[0063] Step S104 may include the following sub-steps: The model parameters of the discriminant layer and the generative layer after the model parameters are initialized are updated based on the target virtual defect image and the real defect image corresponding to the defect image feature set.
[0064] In some embodiments, the model parameters of the discriminant layer after the model parameters are initialized and the generation layer after the model parameters are initialized are updated. The loss of the model can be calculated based on the target virtual defect image and the real defect image corresponding to the defect image feature set, and the model parameters are adjusted based on the calculated loss to achieve the parameter update of the target defect image generation model. For example, based on the adversarial loss function with gradient penalty (Binary Cross-Entropy With LogitsLoss), the adversarial loss of the model is calculated based on the target virtual defect image and the real defect image corresponding to the defect image feature set, and the adversarial loss is used to guide the parameter update process of the target defect image generation model, thereby achieving the update of the model parameters. It can be understood that the embodiment of the present application performs adversarial training on the target virtual defect image and the real defect image corresponding to the defect image feature set, and updates the parameters of the target defect image generation model based on the results of the adversarial training, thereby further improving the detail quality of the generated data and significantly improving the comprehensiveness and authenticity of the defect feature expression.
[0065] See also Figure 7 , Figure 7It is a specific flow chart of the target defect image generation model training process provided by an embodiment of the present application, which specifically includes: first, constructing a defect image feature set through the first sample defect feature generated by the pre-trained reference defect image generation model and the real defect image corresponding to the first sample defect feature. It can be understood that in order to enhance the diversity of the generated data, additional noise perturbations can be introduced into the first sample defect feature generated by the pre-trained reference defect image generation model. Then, the first sample defect feature is converted into a feature map of size 512×8×8 through the fully connected layer included in the generation layer, and the feature map of size 512×8×8 is input into the generation layer for upsampling to obtain the target virtual defect image. Among them, the generation layer is constructed based on the decoding layer of the reference defect image generation model. The generation layer consists of four sequentially connected deconvolution units, each deconvolution unit uses a 4×4 convolution kernel, a stride of 2, and a padding of 1. The number of channels of each convolution unit is 512, 256, 128 and 64, respectively, and the number of channels decreases layer by layer. The first three deconvolution units are followed by batch normalization and ReLU activation functions, and the last deconvolution unit is followed by batch normalization and Tanh activation functions. Furthermore, the generated target virtual defect image and the real defect image are input into the discriminant layer for feature extraction. The extracted features are flattened and then input into the fully connected layer contained in the discriminant layer, which outputs a scalar for true or false judgment. The discriminant layer is constructed based on the encoding layer of the reference defect image generation model. The discriminant layer contains four sequentially connected convolution units. Each convolution unit uses a 4×4 convolution kernel, a stride of 2, and a padding of 1. The number of channels of each convolution unit is 64, 128, 256, and 512, respectively, and the number of channels increases layer by layer. Each convolution unit is followed by batch normalization and LeakyReLU activation functions. Finally, based on the adversarial loss function, the adversarial loss of the target defect image generation model is calculated based on the target virtual defect image and the real defect image corresponding to the defect image feature set. A gradient penalty term is added to the calculated adversarial loss, that is, the adversarial loss is weighted by a preset weight coefficient. Then, based on the weighted loss value, the model parameters of the target defect image generation model are updated through an optimization algorithm (labeled as "Adam algorithm"). It can be understood that the target defect image generation model of the embodiment of the present application can complete the training of the model by repeating the above training process for multiple iterations until the loss function converges or a preset number of training times is reached.
[0066] The data processing method provided in the embodiment of the present application, first, initializes the model parameters of the generation layer of the target defect image generation model through the first model parameters of the decoding layer of the pre-trained reference defect image generation model, and initializes the model parameters of the discriminant layer of the target defect image generation model according to the second model parameters of the encoding layer of the pre-trained reference defect image generation model. Then, the target defect image generation model after the model parameters are initialized is iteratively trained through the defect image feature set. Furthermore, during the iterative training process, the virtual defect images generated by the target defect image generation model are quality-checked to screen out virtual defect images that meet the feature distribution of the real defect images. Furthermore, the virtual defect images that meet the feature distribution of the real defect images are used in the iterative training process of the target defect image generation model. Finally, a target defect image set is constructed based on the trained target defect image generation model and the virtual defect images that meet the feature distribution of the real defect images. In this way, the data processing method provided in the embodiment of the present application can effectively use the parameters of the pre-trained model to initialize the target defect image generation model, reduce the computational complexity of the model training, and accelerate the training convergence speed. Moreover, the data processing method provided in the embodiment of the present application can also use virtual defect images that conform to the feature distribution of real defect images to guide the iterative training process of the target defect image generation model, thereby avoiding the model from learning incorrect defect features during the iterative training process, further reducing the computational complexity of model training, improving the accuracy and generalization ability of the defect data generated by the model, and enriching the defect data samples used to train the model.
[0067] See also Figure 8 , Figure 8The following is a schematic flow chart of a data processing method provided in an embodiment of the present application, specifically comprising: first, constructing a first sample defect image training set, which includes real defect images captured by equipment in an actual industrial environment. Then, before training the VAE model (i.e., the reference defect image generation model), determining whether suitable sample model parameters exist based on the specific scenario and task requirements. If suitable sample model parameters exist, the VAE model is not trained. If suitable sample model parameters do not exist or the current sample model parameters do not meet the requirements of the current defect data generation task, the VAE model is trained to obtain sample model parameters that better meet the actual requirements. Furthermore, the model parameters of the generative layer of the GAN model (i.e., the target defect image generation model) are initialized based on the first model parameters of the decoding layer of the pre-trained VAE model, enabling the generative layer to more quickly and accurately generate virtual defect images with stable structures. The model parameters of the discriminative layer of the GAN model are initialized based on the second model parameters of the encoding layer of the pre-trained VAE model, enabling the discriminative layer to achieve efficient feature extraction, thereby improving the training efficiency of the GAN model and the accuracy of the generated defect data. It can be understood that the embodiment of the present application not only reduces the complexity and computational overhead of GAN model training through this parameter sharing mechanism, but also improves the training speed and accuracy of the GAN model. Furthermore, a defect image feature set is constructed by using the first sample defect feature generated by the pre-trained VAE model and the real defect image corresponding to the first sample defect feature, and the GAN model with the model parameters initialized is iteratively trained using the defect image feature set. Furthermore, based on the CNN model, the target virtual defect image generated by the GAN model with the model parameters initialized during the iterative training process is quality-checked to obtain a quality score, and the target virtual defect image that meets the real defect feature is judged based on the comparison of the quality score with the preset threshold. Further, the target virtual defect image that meets the real defect feature is added to the first sample defect image training set to construct an initial defect image set. Further, the GAN model with the model parameters initialized is iteratively trained using the initial defect image set. Finally, the GAN model with the updated model parameters is called to perform defect image generation operations on the initial defect image set, and the target defect image set is constructed based on the generated virtual defect image and the initial defect image set. It can be understood that the embodiments of the present application can perform quality inspection and screening on the virtual images generated during the iterative training process, add the screened high-quality virtual defect images to the first sample defect image training set to construct an initial defect image set, and use the initial defect image set to train the GAN model, so that the GAN model not only considers the distribution consistency of the data in the process of generating virtual defect images, but also more fully reflects the defect characteristics of the real defect images, significantly improves the generalization ability and actual application effect of the model, and ensures that the generated data always meets the needs of the actual industrial site.
[0068] See also Figure 9 The present application also provides a data processing device that can implement the above data processing method. The device includes: A parameter acquisition module 901 is used to obtain sample model parameters of a pre-trained reference defect image generation model and initialize model parameters of a pre-built target defect image generation model based on the sample model parameters; A data acquisition module 902 is configured to acquire a defect image feature set, wherein the defect image feature set includes first sample defect features generated by a pre-trained reference defect image generation model; An image generation module 903 is configured to call a target defect image generation model after model parameters are initialized to perform a defect image generation operation on a defect image feature set to obtain a target virtual defect image; A parameter updating module 904 is configured to update the model parameters of the target defect image generation model after the model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set; The data generation module 905 is used to construct a target defect image set based on the target defect image generation model and the target virtual defect image after the model parameters are updated.
[0069] The specific implementation of the data processing device is basically the same as the specific embodiment of the above-mentioned data processing method, and will not be repeated here.
[0070] The present application also provides an electronic device comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the above-mentioned data processing method when executing the computer program. The electronic device can be any smart terminal including a tablet computer, an in-vehicle computer, or the like.
[0071] See also Figure 10 , Figure 10 The hardware structure of an electronic device according to another embodiment is shown. The electronic device includes: The processor 1001 can be implemented as a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application. The memory 1002 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 1002 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 1002 and is called by the processor 1001 to execute the data processing method of the embodiments of this application. Input / output interface 1003, used to implement information input and output; Communication interface 1004, used to implement communication interaction between this device and other devices, which can be achieved through wired means (such as USB, network cable, etc.) or wireless means (such as mobile network, WiFi, Bluetooth, etc.); Bus 1005 , which transmits information between various components of the device (e.g., processor 1001 , memory 1002 , input / output interface 1003 , and communication interface 1004 ); The processor 1001 , the memory 1002 , the input / output interface 1003 and the communication interface 1004 are connected to each other in communication within the device via the bus 1005 .
[0072] An embodiment of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned data processing method is implemented.
[0073] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0074] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0075] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0076] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0077] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0078] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0079] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0080] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0081] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0082] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0083] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0084] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A data processing method, characterized in that: The method comprises: Obtaining sample model parameters of a pre-trained reference defect image generation model, and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters; Acquire a defect image feature set, wherein the defect image feature set includes first sample defect features generated by the reference defect image generation model; Calling the target defect image generation model after model parameter initialization to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image; updating the model parameters of the target defect image generation model after the model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set; A target defect image set is constructed based on the target defect image generation model and the target virtual defect image after the model parameters are updated.
2. The method according to claim 1, characterized in that The reference defect image generation model includes an encoding layer and a decoding layer. The training process of the reference defect image generation model includes the following steps: Obtaining a first sample defect image training set; Calling the encoding layer to extract defect features from the first sample defect image training set to obtain second sample defect features; Calling the decoding layer to perform a defect image generation operation on the second sample defect feature to obtain a first sample virtual defect image; The model parameters of the reference defect image generation model are updated based on the first sample virtual defect image and the real defect image corresponding to the first sample defect image training set.
3. The method according to claim 2, characterized in that The sample model parameters include first model parameters, and the target defect image generation model includes a generation layer; The acquiring of sample model parameters of a pre-trained reference defect image generation model and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters includes: When the reference defect image generation model completes training, obtaining a first model parameter of the decoding layer; Initializing model parameters of the generating layer based on the first model parameters; The target defect image generation model after calling the model parameters initialized performs a defect image generation operation on the defect image feature set to obtain a target virtual defect image, including: The generation layer after model parameter initialization is called to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image.
4. The method according to claim 3, characterized in that The sample model parameters also include a second model parameter, and the target defect image generation model includes a discriminant layer; The acquiring of sample model parameters of a pre-trained reference defect image generation model and initializing model parameters of a pre-built target defect image generation model based on the sample model parameters includes: When the reference defect image generation model completes training, obtaining a second model parameter of the encoding layer; Initializing the model parameters of the discriminant layer based on the second model parameters; The updating of model parameters of the target defect image generation model after model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set includes: The model parameters of the discriminant layer after model parameter initialization and the generative layer after model parameter initialization are updated based on the target virtual defect image and the real defect image corresponding to the defect image feature set.
5. The method according to claim 2, characterized in that The target defect image generation model based on the target defect image after the model parameters are updated and the target virtual defect image is used to construct a target defect image set, including: Performing quality inspection on the target virtual defect image to obtain a quality inspection score; When the quality detection score is greater than or equal to a preset threshold, constructing an initial defect image set based on the target virtual defect image and the first sample defect image training set; The target defect image generation model after the model parameters are updated is called to perform a defect image generation operation on the initial defect image set, and the target defect image set is constructed based on the generated virtual defect image and the initial defect image set.
6. The method according to claim 2, characterized in that The encoding layer includes a convolutional layer, a first fully connected layer, and a second fully connected layer. Calling the encoding layer to extract defect features from the first sample defect image training set to obtain second sample defect features includes: Calling the convolution layer to extract defect features from the first sample defect image training set to obtain sample convolution features; Calling the first fully connected layer to perform mean feature normalization on the sample convolution feature to obtain a sample mean feature; Calling the second fully connected layer to perform variance feature normalization on the sample convolution feature to obtain a sample variance feature; The second sample defect feature is determined based on the sample mean feature and the sample variance feature.
7. The method according to claim 2, characterized in that The decoding layer includes a third fully connected layer and a deconvolution layer, and calling the decoding layer to perform a defect image generation operation on the second sample defect feature to obtain a first sample virtual defect image includes: Calling the third fully connected layer to perform potential feature normalization on the second sample defect feature to obtain a sample potential feature; The deconvolution layer is called to perform a defect image generation operation on the sample potential features to obtain the first sample virtual defect image.
8. A data processing device, characterized in that: The device comprises: A parameter acquisition module, configured to acquire sample model parameters of a pre-trained reference defect image generation model, and initialize model parameters of a pre-built target defect image generation model based on the sample model parameters; a data acquisition module, configured to acquire a defect image feature set, wherein the defect image feature set includes first sample defect features generated by the pre-trained reference defect image generation model; An image generation module is used to call the target defect image generation model after the model parameters are initialized to perform a defect image generation operation on the defect image feature set to obtain a target virtual defect image; a parameter updating module, configured to update the model parameters of the target defect image generation model after the model parameters are initialized based on the target virtual defect image and the real defect image corresponding to the defect image feature set; A data generation module is used to construct a target defect image set based on the target defect image generation model and the target virtual defect image after the model parameters are updated.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Face image semantic restoration method based on multi-scale feature fusion
CN113112411A
Casting defect identification model training method, defect identification method, device and system
CN115661572A
Product defect detection method, detection terminal and storage medium
CN117934405A
Strip steel surface defect data enhancement method based on Wasserstein GAN
CN118658023A
Diffusion model construction method and device, equipment and storage medium
CN119399018A