Method and device for constructing image sample generation model and image sample generation method

By building a preset neural network model, using feature extractor and inverse encoder to generate image samples, and combining with discriminators for adversarial training, the problem of insufficient sample size of image data is solved, and the generalization ability and image samples of deep learning models are improved. quality.

CN118968212APending Publication Date: 2024-11-15SUNWODA MOBILITY ENERGY TECHNOLOGY CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410924526.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-09
Publication Date
2024-11-15

AI Technical Summary

Technical Problem

In the manufacturing process of power battery, insufficient image data sample size leads to poor training results in deep learning model, and the accuracy of identification and detection is reduced. It is difficult to ensure the quality and reliability of the battery cell in cell quality and safety detection.

Method used

Build an image sample generation model, including a preset neural network model, feature extraction of images through the first feature extractor and the second feature extractor, generate fusion feature vectors, and input the inverse encoder to generate image samples, and combine it with the discriminator for adversarial training. , optimize the generalization ability of the model.

Benefits of technology

It improves the generalization ability of the image sample generation model, the generated image samples are of higher quality, and can process images of different types and styles, avoid overfitting and parameter redundancy, and enhances the training efficiency and recognition ability of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118968212A_ABST
    Figure CN118968212A_ABST
Patent Text Reader

Abstract

The invention provides a construction method and device of an image sample generation model and an image sample generation method. The construction method comprises the steps of constructing an image training set; constructing a preset neural network model; wherein the preset neural network model comprises a first feature extractor, a second feature extractor, an inverse encoder and a discriminator; the inverse encoder and the network structure of the first feature extractor are mutually symmetrical; inputting the image training set into a preset neural network model for feature extraction operation, and generating a first feature vector and a second feature vector; splicing the vectors to obtain a fusion feature vector, and generating an image sample based on the fusion feature vector; generating an adversarial loss function between the image and the image sample; and generating a total loss function according to the adversarial loss function, and when the total loss function converges or reaches the maximum number of iteration training times, determining that the training is completed, and obtaining an image sample generation model. The generalization of the image sample generation model can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of deep learning technology, and in particular to a method and device for constructing an image sample generation model and an image sample generation method. Background Art

[0002] In the process of power battery manufacturing, X-rays can be used to achieve functions such as quantity control, material analysis, thickness measurement and structural analysis, so as to identify potential safety hazards of wound battery cells and ensure the quality of battery cell products. Therefore, artificial intelligence combined with X-ray image data can realize automatic identification and detection of battery cell defects.

[0003] However, with the continuous improvement of production control, manufacturing process and equipment accuracy, the number of cells with defects is extremely limited, and it is difficult to directly collect a large amount of X-ray abnormal image data of wound cells. In the case of insufficient sample size of image data, the training of deep learning models in subsequent power battery manufacturing tasks will also be affected, which will cause the model to perform poorly in test sets or actual applications, reduce the accuracy of recognition and detection, and lead to increased missed and misjudgment rates, especially in key detection links such as cell quality and safety. The quality and reliability of the cell cannot be ensured. Therefore, in order to effectively train deep learning models, it is necessary to increase the number and diversity of samples so that the model can learn more comprehensively and adapt to different scenarios and changes.

[0004] Most existing technologies use data enhancement methods such as rotation, flipping, random cropping, color transformation, affine transformation, elastic transformation, and adding random noise to expand the X-ray abnormal image data of wound battery cells. However, this method may cause distortion of the enhanced image, incomplete targets, and distorted geometric shapes. It may also cause the model to focus too much on noise and ignore real features. This type of method cannot provide fast and high-quality generation results. There are also some methods that generate samples through pixel fusion, but if the foreground of the image is offset, the quality of the generated image will be greatly reduced. How to improve the generalization performance of deep learning models when the data of abnormal battery cell X-ray images is limited is a technical problem that needs to be solved urgently. Summary of the invention

[0005] The present invention aims to provide a method and device for constructing an image sample generation model and an image sample generation method to solve the above technical problems and improve the generalization of the image sample generation model.

[0006] In order to solve the above technical problems, the present invention provides a method for constructing an image sample generation model, comprising:

[0007] Constructing an image training set; wherein the image training set includes a number of abnormal images;

[0008] Constructing a preset neural network model; wherein the preset neural network model includes a first feature extractor, a second feature extractor, an inverse encoder and a discriminator; the network structure of the inverse encoder is symmetrical to the network structure of the first feature extractor;

[0009] Inputting the image training set as a first image into the preset neural network model for iterative training, so that the first feature extractor and the second feature extractor perform a feature extraction operation on the input first image to generate a first feature vector and a second feature vector;

[0010] concatenating the first feature vector and the second feature vector to obtain a fused feature vector, and inputting the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector; inputting the first image and the first image sample to the discriminator so that the discriminator performs adversarial training and generates an adversarial loss function between the first image and the first image sample;

[0011] The total loss function of the preset neural network model is generated according to the adversarial loss function. When the total loss function converges or the preset neural network model reaches the maximum number of iterative training times, it is determined that the training of the preset neural network model is completed, and an image sample generation model is obtained.

[0012] In the above scheme, a neural network model is constructed to perform unsupervised adversarial learning on the acquired X-ray image of the wound battery core. The first feature extractor and the second feature extractor are used to extract features of the input image, and feature information of different levels and different degrees of abstraction can be obtained, which helps the model to better understand the content and structure of the image and improve the recognition and generation capabilities of the model. Then the two feature vectors obtained are fused, and the information of the two feature vectors can be comprehensively utilized to obtain a richer and more comprehensive feature expression, which helps to improve the quality and diversity of the image generated by the inverse encoder. Further, the network structure of the inverse encoder is set to be symmetrical with the network structure of the first feature extractor in the vertical direction, and the information symmetry between the fused feature vector and the generated image sample can be maintained. This symmetry can help the network better learn the mapping relationship between the input features and the generated image, thereby improving the quality of the generated image sample. The symmetric structure can enable the inverse encoder and the first feature extractor to share some parameters, reduce the number of parameters of the model, and improve the training efficiency and generalization ability of the model. This parameter sharing helps to better utilize the training data for model training and avoid overfitting and parameter redundancy. Then the discriminator is introduced for adversarial training, which can make the image samples generated by the inverse encoder more realistic and closer to the real image distribution. Through adversarial training and comprehensive consideration of multi-level feature information, the obtained image sample generation model has good generalization ability, can process image samples of different types and styles, and generate images with good quality.

[0013] In one implementation, the constructing of the image training set specifically includes:

[0014] Collecting several abnormal initial images;

[0015] The abnormal initial image is flipped horizontally and vertically respectively to obtain a first transformed initial image and a second transformed initial image;

[0016] The abnormal initial image, the first transformed initial image and the second transformed initial image are respectively used as initial images and are standardized according to a first standardization processing formula to obtain a standardized image, a first transformed image and a second transformed image respectively; wherein the expression of the first standardization processing formula is:

[0017]

[0018] In the formula, is the gray value of the pixel after standardization; is the grayscale value of the pixel in the initial image; μ is the mean value of the pixel in the initial image; σ is the variance of the pixel in the initial image;

[0019] The standardized image, the first transformed image and the second transformed image are used as abnormal images to construct the image training set.

[0020] In one implementation, the first feature extractor and the second feature extractor perform a feature extraction operation on the input first image to generate a first feature vector and a second feature vector, specifically including:

[0021] Constructing the first feature extractor based on a ResNet neural network; wherein the cross-channel connection is achieved through a residual block in the ResNet network;

[0022] Constructing the second feature extractor based on the VGG neural network; wherein the VGG neural network uses a global average pooling layer to replace the fully connected layer;

[0023] Extracting a style feature vector of the first image by using the ResNet neural network as the first feature vector;

[0024] The attribute feature vector of the first image is extracted by the VGG neural network as the second feature vector.

[0025] In one implementation, before inputting the fused feature vector into the inverse encoder step, the method further includes:

[0026] The fused feature vector is standardized according to a second standardization processing formula to obtain a standard fused feature vector; wherein the expression of the second standardization processing formula is:

[0027]

[0028] In the formula, f4 is the standard fusion feature vector; σ(f1) is the accumulated standard deviation of the first feature vector; μ(f1) is the accumulated mean of the first feature vector; μ(f2) is the accumulated mean of the second feature vector; σ(f2) is the accumulated standard deviation of the second feature vector; f1 is the first feature vector; f2 is the second feature vector.

[0029] In one implementation, the step of inputting the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector specifically includes:

[0030] The inverse encoder converts the fused feature vector into a pixel-level semantic feature based on a transposed convolution;

[0031] The pixel-level semantic features are input into an inverse encoder so that the inverse encoder outputs a first image sample.

[0032] In one implementation, the discriminator performs adversarial training to generate an adversarial loss function between the first image and the first image sample, specifically including:

[0033] The discriminator calculates the distribution distance between the first image and the first image sample based on the Wasserstein distance;

[0034] Based on the distribution distance, the adversarial loss between the first image and the first image sample is calculated according to the adversarial loss function; wherein the adversarial loss function is expressed as:

[0035]

[0036] Where, L G To combat the loss function, x i is any image in the first image; j is any image in the first image samples; real is the data distribution in the first image; fake is the data distribution of the first image sample; K is the gradient penalty factor; λ and β are weight factors of the balanced adversarial loss function; G is the discriminator; For x i The gradient of,R| x′,x″ is the approximate gradient change;

[0037] The calculation formula of the approximate gradient change is:

[0038]

[0039] In the formula, x i ′ and x i ″ is to add random noise of different intensities to x i The obtained data sample; C is a custom constant.

[0040] In one implementation, before calculating the total loss function of the preset neural network model according to the adversarial loss, it also includes calculating a first distribution approximation loss and a second distribution approximation loss between the first image sample and the first image, specifically:

[0041] Define the first distribution approximation loss function of the first image sample and the first image according to the relative entropy to obtain the first distribution approximation loss; wherein the expression of the first distribution approximation loss function is:

[0042]

[0043] Where, L D Approximate the loss function for the first distribution; x iis any image in the first image; j is any image in the first image sample; D is the inverse encoder; f4 is the standard fusion feature vector; P fake is the data distribution of the first image sample; real is the data distribution of the first image;

[0044] Inputting the standard fused feature vector into an inverse encoder to obtain a first image sample, and inputting the first image sample into the first feature extractor so that the first feature extractor outputs a first feature vector of the first image sample;

[0045] A second distribution approximation loss function between the first eigenvector of the first image sample and the first eigenvector of the first image is defined according to relative entropy to obtain the second distribution approximation loss; wherein the expression of the second distribution approximation loss function is:

[0046]

[0047] In the formula, Approximate the loss function for the second distribution, x j is any image in the first image samples; fake is the data distribution of the first image sample; real is the data distribution of the first image; F1 is the first feature extractor; D is the inverse encoder; x i is any image in the first images; f4 is the standard fusion feature vector; f1 is the first feature vector.

[0048] In one implementation, generating the total loss function of the preset neural network model according to the adversarial loss function specifically includes:

[0049] Substitute the first distribution approximation loss function and the second distribution approximation loss function into the generalized entropy index calculation formula respectively to obtain a first weight factor and a second weight factor; wherein the generalized entropy index calculation formula is expressed as:

[0050]

[0051] In the formula, A α is the weight factor, M is the number of images in each batch training; L i is the loss function value corresponding to the i-th image; α is the generalized entropy index; Represents the average loss function value of the images in the same batch of training;

[0052] The adversarial loss function, the first distribution approximation loss function, the second distribution approximation loss function, the first weight factor and the second weight factor are weighted and superimposed to obtain the total loss function; wherein the expression of the total loss function is:

[0053]

[0054] Where, L total is the total loss function; α D is the first weight factor; L D Approximate the loss function for the first distribution; is the second weight factor; Approximate the loss function for the second distribution; L G is the adversarial loss function.

[0055] In a second aspect, the present application further provides an X-ray image sample generating device, comprising: a first building module, a second building module, a first training module, a second training module and a training discrimination module;

[0056] The first construction module is used to construct an image training set; wherein the image training set includes a number of abnormal images;

[0057] The second construction module constructs a preset neural network model; wherein the preset neural network model includes a first feature extractor, a second feature extractor, an inverse encoder and a discriminator; the network structure of the inverse encoder is symmetrical to the network structure of the first feature extractor;

[0058] The first training module is used to input the image training set as the first image into the preset neural network model for iterative training, so that the first feature extractor and the second feature extractor perform feature extraction operations on the input first image to generate a first feature vector and a second feature vector;

[0059] The second training module is used to concatenate the first feature vector and the second feature vector to obtain a fused feature vector, and input the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector; input the first image and the first image sample to the discriminator so that the discriminator performs adversarial training and generates an adversarial loss function between the first image and the first image sample;

[0060] The training judgment module is used to generate a total loss function of the preset neural network model according to the adversarial loss function. When the total loss function converges or the preset neural network model reaches a maximum number of iterative training times, it is determined that the training of the preset neural network model is completed, and an image sample generation model is obtained.

[0061] In the above scheme, a neural network model is constructed to perform unsupervised adversarial learning on the acquired X-ray image of the wound battery core. The first feature extractor and the second feature extractor are used to extract features of the input image, and feature information of different levels and different degrees of abstraction can be obtained, which helps the model to better understand the content and structure of the image and improve the recognition and generation capabilities of the model. Then the two feature vectors obtained are fused, and the information of the two feature vectors can be comprehensively utilized to obtain a richer and more comprehensive feature expression, which helps to improve the quality and diversity of the image generated by the inverse encoder. Further, the network structure of the inverse encoder is set to be symmetrical with the network structure of the first feature extractor in the vertical direction, and the information symmetry between the fused feature vector and the generated image sample can be maintained. This symmetry can help the network better learn the mapping relationship between the input features and the generated image, thereby improving the quality of the generated image sample. The symmetric structure can enable the inverse encoder and the first feature extractor to share some parameters, reduce the number of parameters of the model, and improve the training efficiency and generalization ability of the model. This parameter sharing helps to better utilize the training data for model training and avoid overfitting and parameter redundancy. Then the discriminator is introduced for adversarial training, which can make the image samples generated by the inverse encoder more realistic and closer to the real image distribution. Through adversarial training and comprehensive consideration of multi-level feature information, the obtained image sample generation model has good generalization ability, can process image samples of different types and styles, and generate images with good quality.

[0062] In one implementation, the first construction module of the module of the model construction device is used to construct an image training set, and specifically includes:

[0063] Collecting a number of abnormal initial images, and constructing an initial image training set based on the abnormal initial images;

[0064] Collecting several abnormal initial images;

[0065] The abnormal initial image is flipped horizontally and vertically respectively to obtain a first transformed initial image and a second transformed initial image;

[0066] The abnormal initial image, the first transformed initial image and the second transformed initial image are respectively used as initial images and are standardized according to a first standardization processing formula to obtain a standardized image, a first transformed image and a second transformed image respectively; wherein the expression of the first standardization processing formula is:

[0067]

[0068] In the formula, is the gray value of the pixel after standardization; is the grayscale value of the pixel in the initial image; μ is the mean value of the pixel in the initial image; σ is the variance of the pixel in the initial image;

[0069] The standardized image, the first transformed image and the second transformed image are used as abnormal images to construct the image training set.

[0070] In one implementation, the first feature extractor and the second feature extractor perform a feature extraction operation on the input first image to generate a first feature vector and a second feature vector, specifically including:

[0071] Constructing the first feature extractor based on a ResNet neural network; wherein the cross-channel connection is achieved through a residual block in the ResNet network;

[0072] Constructing the second feature extractor based on the VGG neural network; wherein the VGG neural network uses a global average pooling layer to replace the fully connected layer;

[0073] Extracting a style feature vector of the first image by using the ResNet neural network as the first feature vector;

[0074] The attribute feature vector of the first image is extracted by the VGG neural network as the second feature vector.

[0075] In one implementation, before inputting the fused feature vector into the inverse encoder step, the method further includes:

[0076] The fused feature vector is standardized according to a second standardization processing formula to obtain a standard fused feature vector; wherein the expression of the second standardization processing formula is:

[0077]

[0078] In the formula, f4 is the standard fusion feature vector; σ(f1) is the accumulated standard deviation of the first feature vector; μ(f1) is the accumulated mean of the first feature vector; μ(f2) is the accumulated mean of the second feature vector; σ(f2) is the accumulated standard deviation of the second feature vector; f1 is the first feature vector; f2 is the second feature vector.

[0079] In one implementation, the step of inputting the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector specifically includes:

[0080] The inverse encoder converts the fused feature vector into a pixel-level semantic feature based on a transposed convolution;

[0081] The pixel-level semantic features are input into an inverse encoder, so that the inverse encoder outputs a first image sample.

[0082] In one implementation, the discriminator performs adversarial training to generate an adversarial loss function between the first image and the first image sample, specifically including:

[0083] The discriminator calculates the distribution distance between the first image and the first image sample based on the Wasserstein distance;

[0084] Based on the distribution distance, the adversarial loss between the first image and the first image sample is calculated according to the adversarial loss function; wherein the adversarial loss function is expressed as:

[0085]

[0086] Where, L G To combat the loss function, x i is any image in the first image; j is any image in the first image samples; real is the data distribution in the first image; fake is the data distribution of the first image sample; K is the gradient penalty factor; λ and β are weight factors of the balanced adversarial loss function; G is the discriminator; For x i The gradient of,R| x′,x″ is the approximate gradient change;

[0087] The calculation formula of the approximate gradient change is:

[0088]

[0089] In the formula, x i ′ and x i ″ is to add random noise of different intensities to x i The obtained data sample; C is a custom constant.

[0090] In one implementation, before calculating the total loss function of the preset neural network model according to the adversarial loss, it also includes calculating a first distribution approximation loss and a second distribution approximation loss between the first image sample and the first image, specifically:

[0091] Define the first distribution approximation loss function of the first image sample and the first image according to the relative entropy to obtain the first distribution approximation loss; wherein the expression of the first distribution approximation loss function is:

[0092]

[0093] Where, L D Approximate the loss function for the first distribution; x i is any image in the first image; j is any image in the first image sample; D is the inverse encoder; f4 is the standard fusion feature vector; P fake is the data distribution of the first image sample; real is the data distribution of the first image;

[0094] Inputting the standard fused feature vector into an inverse encoder to obtain a first image sample, and inputting the first image sample into the first feature extractor so that the first feature extractor outputs a first feature vector of the first image sample;

[0095] A second distribution approximation loss function between the first eigenvector of the first image sample and the first eigenvector of the first image is defined according to relative entropy to obtain the second distribution approximation loss; wherein the expression of the second distribution approximation loss function is:

[0096]

[0097] In the formula, Approximate the loss function for the second distribution, x j is any image in the first image samples; fake is the data distribution of the first image sample; real is the data distribution of the first image; F1 is the first feature extractor; D is the inverse encoder; x i is any image in the first images; f4 is the standard fusion feature vector; f1 is the first feature vector.

[0098] In one implementation, the training discrimination module is used to generate a total loss function of the preset neural network model according to the adversarial loss function, specifically including:

[0099] Substitute the first distribution approximation loss function and the second distribution approximation loss function into the generalized entropy index calculation formula respectively to obtain a first weight factor and a second weight factor; wherein the generalized entropy index calculation formula is expressed as:

[0100]

[0101] In the formula, A α is the weight factor, M is the number of images in each batch training; L i is the loss function value corresponding to the i-th image; α is the generalized entropy index; Represents the average loss function value of the images in the same batch of training;

[0102] The adversarial loss function, the first distribution approximation loss function, the second distribution approximation loss function, the first weight factor and the second weight factor are weighted and superimposed to obtain the total loss function; wherein the expression of the total loss function is:

[0103]

[0104] Where, L total is the total loss function; α D is the first weight factor; L D Approximate the loss function for the first distribution; is the second weight factor; Approximate the loss function for the second distribution; L G is the adversarial loss function.

[0105] In a third aspect, the present application also provides an image sample generation method, comprising:

[0106] Acquire abnormal images of the battery cells to be tested;

[0107] The abnormal cell image is input into an image sample generation model generated by using the method for constructing an image sample generation model as described above, so that the image sample generation model outputs a corresponding abnormal cell image sample. BRIEF DESCRIPTION OF THE DRAWINGS

[0108] Figure 1 A schematic diagram of a flow chart of a method for constructing an image sample generation model provided in one embodiment of the present invention;

[0109] Figure 2 A schematic diagram of a network structure of a preset neural network model provided in one embodiment of the present invention;

[0110] Figure 3 A schematic diagram of an image sample generation provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0111] The specific implementation of the present invention is further described in detail below in conjunction with the accompanying drawings and examples. The following examples are used to illustrate the present invention, but are not intended to limit the scope of the present invention.

[0112] The terms "first" and "second" and the like in the specification, claims and drawings of this application are used to distinguish different objects, rather than to describe a specific order. 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 comprising a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.

[0113] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0114] First, some terms in this application are explained to facilitate understanding by those skilled in the art.

[0115] (1) ImageNet dataset: It is a large-scale image database containing millions of labeled high-resolution images covering thousands of different categories and themes. This dataset is commonly used to train and test image classification algorithms and deep learning models.

[0116] (2) ResNet Neural Network: (Residual Network) is a deep residual network that aims to solve the problems of gradient vanishing and training difficulty in deep neural networks. Its core idea is to learn residual mapping by introducing residual blocks, so that the network can still be effectively trained and optimized when it is deeper.

[0117] (3) VGG neural network: (Visual Geometry Group) is a deep convolutional neural network architecture proposed by a research team at the University of Oxford. Its main features are the use of a very small convolution kernel size (usually 3x3) and a deep network structure.

[0118] Example 1

[0119] See also Figure 1 , Figure 1 The flowchart of a method for constructing an image sample generation model provided in an embodiment of the present invention is as follows. The present invention provides a method for constructing an image sample generation model, including steps 101 to 105, each of which is as follows:

[0120] Step 101: construct an image training set; wherein the image training set includes a number of abnormal images.

[0121] In one embodiment, constructing an image training set specifically includes: collecting a number of abnormal initial images, first flipping the abnormal initial images horizontally and vertically, respectively, to obtain a first transformed initial image and a second transformed initial image; then performing standardization processing on the abnormal initial image, the first transformed initial image and the second transformed initial image according to a first standardization processing formula, that is, substituting the abnormal initial image, the first transformed initial image and the second transformed initial image as initial images into the first standardization processing formula to obtain a standardized image, a first transformed image and a second transformed image, respectively; wherein the expression of the first standardization processing formula is:

[0122]

[0123] In the formula, is the gray value of the pixel after standardization; is the gray value of the pixel in the initial image; μ is the mean of the pixel in the initial image; σ is the variance of the pixel in the initial image;

[0124] Thereafter, the standardized image, the first transformed image, and the second transformed image are taken as abnormal images and an image training set is constructed.

[0125] In an embodiment of the present invention, several abnormal initial images are collected by X-ray image acquisition devices such as X-ray cameras, X-ray flat panel detectors, and X-ray fluoroscopy machines, and then the collected abnormal images are expanded. Specifically, the abnormal initial image is first flipped to obtain a horizontally symmetrical image, i.e., a first transformed initial image, and a vertically symmetrical transformed image, i.e., a second transformed initial image, to further expand the image set, and then these initial images are standardized by a standardized processing formula. Preferably, the mean and variance of these initial images can be calculated by the ImageNet data set. The ImageNet data set is a large-scale data set that covers thousands of different categories and themes, so the calculated mean and variance are well representative and suitable for a variety of image classification and computer vision tasks. Then, standardized processing is used to obtain standardized images, first transformed images, and second transformed images, respectively, and the above-mentioned standardized images, first transformed images, and second transformed images are all used as abnormal images to construct an image training set, and the height and width dimensions of all images in the image training set are unified to 256*256. In the embodiment of the present invention, the diversity of abnormal image data can be increased through operations such as flipping and standardization, so that the model is more robust during training and can learn more features and change patterns, thereby improving the generalization ability.

[0126] Step 102: Construct a preset neural network model; wherein the preset neural network model includes a first feature extractor, a second feature extractor, an inverse encoder and a discriminator; the network structure of the inverse encoder is symmetrical to the network structure of the first feature extractor in the vertical direction.

[0127] See also Figure 2 , Figure 2 A schematic diagram of the network structure of a preset neural network model provided in one embodiment of the present invention. In the embodiment of the present invention, a preset neural network model including a first feature extractor, a second feature extractor, an inverse encoder and a discriminator is constructed, and the network structure of the inverse encoder and the structure of the first feature extractor are set to be symmetrical to each other in the vertical direction. The goal of the inverse encoder is to reconstruct the original image from the abstract feature representation. Setting the network structure of the inverse encoder to be vertically symmetrical to the feature extractor can help ensure that the reconstruction process from high-level features to the original image is symmetrical. The inverse encoder can learn how to restore the original image from the high-level feature representation, which helps to retain the information of the original image, thereby better achieving the task of image reconstruction. And the network structure of the inverse encoder is set to be opposite to the network structure of the feature extractor in the vertical direction. Since the two can share similar structures and parameters, the design and training process of the model can also be simplified.

[0128] Step 103: Input the image training set into a preset neural network model for iterative training, so that the first feature extractor and the second feature extractor perform feature extraction operations on the input first image to generate a first feature vector and a second feature vector.

[0129] In one embodiment, a first feature extractor and a second feature extractor perform a feature extraction operation on an input first image to generate a first feature vector and a second feature vector, specifically including: constructing a first feature extractor based on a ResNet neural network; wherein cross-channel connection is achieved through residual blocks in the ResNet network; constructing a second feature extractor based on a VGG neural network; wherein a global average pooling layer is used in the VGG neural network to replace a fully connected layer; extracting a style feature vector of the first image through the ResNet neural network; and extracting an attribute feature vector of the first image through the VGG neural network.

[0130] In an embodiment of the present invention, a first feature extractor F1(·) is constructed based on a ResNet neural network. The ResNet neural network includes an input layer, a convolutional layer, a residual block, a global average pooling layer, and a fully connected layer. The input layer is used to receive an input image or a feature vector; the convolutional layer is used to extract image features such as edges, textures, etc. using convolution operations; the residual block is a key component of ResNet, and each residual block contains two branches: a main path and a shortcut. The main path contains a series of convolutional layers, batch normalization layers, and activation function layers, and the shortcut is a direct connection across the convolutional layers. This structure allows the network to learn residual mapping, that is, to learn the difference from input to output, rather than directly learning the complete mapping relationship; the global average pooling layer is used to convert the feature map of the last residual block into a global feature, usually reducing the height and width of the feature map to 1; the fully connected layer is used for classification tasks to map global features to probability distributions of different categories. In an embodiment of the present invention, cross-channel connection is achieved through residual blocks. Specifically, the input abnormal image passes through each layer of ResNet, undergoes a series of convolution, batch normalization, activation function and other operations, and finally reaches the part containing the residual block. In each residual block, after the input data undergoes a series of convolution operations, the residual result (residual information) is added to the original input image through a cross-channel connection to obtain the output after residual learning. As the data passes through different residual block levels, more abstract and complex feature representations are gradually extracted in the depth direction of the network. After the feature extraction is completed, a global average pooling operation is usually applied to reduce the dimension of the feature map of the last layer to a one-dimensional vector. The final one-dimensional vector is further mapped to the target feature vector space through a fully connected layer. In an embodiment of the present invention, the first image of the input is feature extracted by a constructed ResNet neural network to generate a style feature vector, i.e., a first feature vector f1.

[0131] Furthermore, a second feature extractor F2(·) is constructed based on the VGG neural network. The VGG neural network includes an input layer, a convolutional layer, a pooling layer, and a fully connected layer. The input layer is used to receive an input image or a feature vector;

[0132] The convolution layer consists of multiple consecutive convolution layers, each of which uses a 3x3 convolution kernel for feature extraction. A ReLU activation function layer is usually added after each convolution layer to increase the nonlinearity of the network. The pooling layer is located after the convolution layer and is used to reduce the spatial dimension of the feature map while retaining important feature information; the fully connected layer is used to map the feature map to the final output category. Preferably, the embodiment of the present invention uses a global average pooling layer instead of a fully connected layer for feature mapping. Global average pooling is an operation that reduces the dimension of the feature map. It calculates the average value of all pixels on the feature map instead of taking only the maximum value or average value of the local area like the traditional pooling layer. The fully connected layer usually contains a large number of parameters, which increases the complexity and computational complexity of the model. Using an average pooling layer can reduce the number of parameters, thereby reducing the complexity of the model and reducing the risk of overfitting. The average pooling layer can help the model better capture the locality of features because it performs an average pooling operation on the feature map instead of directly connecting all features. This helps to improve the model's perception of local features, thereby improving the performance of the model. The constructed VGG neural network is used to extract features of the input first image to generate an attribute feature vector, that is, the second feature item vector f2.

[0133] Step 104: Concatenate the first feature vector and the second feature vector to obtain a fused feature vector and send the fused feature vector to the inverse encoder, so that the inverse encoder generates a first image sample based on the fused feature vector; input the first image sample to the discriminator, so that the discriminator performs adversarial training to generate an adversarial loss function between the first image and the first image sample.

[0134] In an embodiment of the present invention, the first eigenvector and the second eigenvector obtained are spliced ​​in the channel direction through a broadcast mechanism to obtain a fused feature item vector f3. Assume that the dimension of the first eigenvector is ([H, W, C1]), where (H) represents the height, (W) represents the width, and (C1) represents the number of channels; the dimension of the second eigenvector is ([H, W, C2]), where (C2) represents the number of channels. Through the broadcast mechanism, the first eigenvector is expanded into a matrix of the same dimension as the second eigenvector, and then the two are spliced ​​along the channel dimension (C) to form a new eigenvector. By splicing the first eigenvector and the second eigenvector in the channel dimension and fusing them together, the network can use attribute information and style information at the same time to better learn feature representation and improve network performance and generalization ability.

[0135] In one embodiment, before inputting the fused feature vector into the inverse encoder step, the method further includes:

[0136] The fused feature vector is standardized according to the second standardization processing formula to obtain a standard fused feature vector; wherein the expression of the second standardization processing formula is:

[0137]

[0138] Wherein, f4 is the standard fusion feature vector; σ(f1) is the standard deviation of the first eigenvector obtained by accumulation; μ(f1) is the mean of the first eigenvector obtained by accumulation; μ(f2) is the mean of the second eigenvector obtained by accumulation; σ(f2) is the standard deviation of the second eigenvector obtained by accumulation; f1 is the first eigenvector; f2 is the second eigenvector.

[0139] In the embodiment of the present invention, before the fused feature item vector f3 is input to the inverse encoder, the obtained fused feature vector is also subjected to adaptive instance normalization processing by the second normalization formula to obtain a standard fused feature vector f4. Through the adaptive instance normalization processing, the parameters of the feature vector are adjusted, and while ensuring the stability and easier convergence of the training process, the generated samples can be adjusted to be more similar to the data of the image training set in terms of generation style, so that the inverse encoder module can more accurately learn the data distribution of the real image samples in the image training set, thereby making the generated samples more real and reliable.

[0140] In one embodiment, the fused feature vector is sent to an inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector, specifically including: the inverse encoder converts the fused feature vector into a pixel-level semantic feature based on a transposed convolution; and the pixel-level semantic feature is input into the inverse encoder so that the inverse encoder outputs the first image sample.

[0141] In an embodiment of the present invention, an inverse encoder is arranged vertically symmetrically according to the network structure of the first feature extractor, and the inverse encoder gradually expands the size of the feature map and restores its pixel semantic features through transposed convolution, and then inputs the pixel-level semantic features into the encoder so that the encoder outputs a first image sample. Pixel-level semantic features refer to the semantic information of each pixel in the image, that is, the content or category represented by the pixel. In image processing, these features usually refer to information such as edges, textures, colors, etc. in the image, as well as the object or object class to which the pixel belongs. The inverse encoder can be used to obtain the corresponding generated image sample while retaining higher quality feature information.

[0142] Furthermore, in an embodiment of the present invention, a discriminator including a three-layer neural network is constructed, and the first feature extractor and the second feature extractor are subjected to adversarial training, and the input real image and the generated image sample, that is, the first image and the first image sample are compared. In an embodiment of the present invention, the similarity between the generated image sample and the input image sample is measured by the Wasserstein distance. Furthermore, in order to meet the Lipschitz continuity condition, the discriminator optimization target is bounded by gradient penalty, and the adversarial loss function of the discriminator is defined based on the Wasserstein distance as follows.

[0143] In one embodiment, the discriminator performs adversarial training to generate an adversarial loss function between the first image and the first image sample, specifically including:

[0144] The discriminator calculates a distribution distance between the first image and the first image sample based on the Wasserstein distance;

[0145] Based on the distribution distance, the adversarial loss between the first image and the first image sample is calculated according to the adversarial loss function; wherein the expression of the adversarial loss function is:

[0146]

[0147] Where, L G To combat the loss function, x i is any image in the first image; x j is any image in the first image sample; P real is the data distribution in the first image; P fake is the data distribution of the first image sample; K is the gradient penalty factor; λ and β are the weight factors of the balanced adversarial loss function; For x i The gradient of,R| x′,x" is the approximate gradient change;

[0148] The value of K can be determined according to the gradient change of the training process, and is usually set in the range of K∈(0,0.5); λ and β are weight factors for balancing the relative relationship between different components in the adversarial loss function. In some embodiments, λ can be set to 8 and β can be set to 3. The values ​​of K, λ and β can be customized according to the actual application situation and are not limited here.

[0149] The calculation formula for the approximate gradient change is;

[0150]

[0151] In the formula, x i ′ and x i " is to add Gaussian noise with different means and variances to xi The obtained data samples; C is a custom constant, according to the training process The value of determines the specific value, which is used to limit the training process x i ′ and x i The addition of ″ is used to simulate data perturbations and improve robustness. Used to approximate the gradient and restrict its range to satisfy the Lipschitz continuity condition.

[0152] Step 105: Generate a total loss function of a preset neural network model based on the adversarial loss function. When the total loss function converges or the preset neural network model reaches a maximum number of iterative training times, it is determined that the training of the preset neural network model is completed, and an image sample generation model is obtained.

[0153] For any image in the image training set, the image sample generated by the inverse encoder should maintain a high similarity with the original image as much as possible. Therefore, in the embodiment of the present invention, before calculating the total loss function of the neural network model, the first distribution approximation loss function based on the relative entropy definition of the overall first distribution approximation loss function is used to calculate the first distribution approximation loss between the first image sample and the first image. Furthermore, since the network structure of the inverse encoder and the network structure of the first feature extractor are symmetrical to each other in the vertical direction, the feature vector obtained after the first image sample generated by the inverse encoder passes through the first feature extractor is also called a pseudo-attribute feature. The pseudo-attribute feature is consistent with the original attribute feature, that is, the first feature vector obtained by inputting the first image sample into the first feature extractor. Therefore, in the embodiment of the present invention, the second distribution approximation function of the attribute feature is also defined based on the relative entropy to calculate the first feature vector of the first image sample and the second distribution approximation loss between the first feature vector of the first image.

[0154] In one embodiment, the first distribution approximation loss and the second distribution approximation loss between the first image sample and the first image are specifically:

[0155] The first distribution approximation loss function of the first image sample and the first image is defined according to the relative entropy to obtain the first distribution approximation loss; wherein the expression of the first distribution approximation loss function is:

[0156]

[0157] Where, L D Approximate the loss function for the first distribution; x i is any image in the first image; x j is any image in the first image sample; D is the inverse encoder; f4 is the standard fusion feature vector; P fake is the data distribution of the first image sample; P real is the data distribution of the first image;

[0158] Inputting the standard fused feature vector into the inverse encoder to obtain a first image sample, and inputting the first image sample into the first feature extractor so that the first feature extractor outputs a first feature vector of the first image sample;

[0159] The second distribution approximation loss function between the first eigenvector of the first image sample and the first eigenvector of the first image is defined according to the relative entropy, and the second distribution approximation loss is obtained; wherein the expression of the second distribution approximation loss function is:

[0160]

[0161] In the formula, Approximate the loss function for the second distribution, x j is any image in the first image sample; P fake is the data distribution of the first image sample; P real is the data distribution of the first image; F1 is the first feature extractor; D is the inverse encoder; x i is any image in the first image; f4 is the standard fusion feature vector; f1 is the first feature vector.

[0162] Although after adversarial training, the confusion between the generated image samples and the images in the image training set can be achieved as much as possible. However, the difficulty of generating samples varies for different input images. Therefore, in the embodiment of the present invention, the generalized entropy index is used to make the first feature extractor and the inverse encoder consistent for different input samples, and the total loss function of the neural network model is calculated based on the weight factor obtained by the generalized entropy index.

[0163] In one embodiment, the total loss function of the preset neural network model is generated according to the adversarial loss function, specifically including:

[0164] Substitute the first distribution approximation loss function and the second distribution approximation loss function into the generalized entropy index calculation formula respectively to obtain the first weight factor and the second weight factor; wherein, the generalized entropy index calculation formula is expressed as:

[0165]

[0166] In the formula, A α is the weight factor, M is the number of images in each batch training; L i is the loss function value corresponding to the i-th image; α is the generalized entropy index; Represents the average loss function value of the images in the same batch of training;

[0167] The adversarial loss function, the first distribution approximation loss function, the second distribution approximation loss function, the first weight factor and the second weight factor are weighted and superimposed to obtain the total loss function; wherein, the expression of the total loss function is:

[0168]

[0169] Where, L total is the total loss function; α D is the first weight factor; L D Approximate the loss function for the first distribution; is the second weight factor; Approximate the loss function for the second distribution; L G is the adversarial loss function.

[0170] In the embodiment of the present invention, the first distribution approximation loss function and the second distribution approximation loss function are respectively substituted into L in the expression formula of the generalized entropy index. i , calculate the loss function value. Based on the obtained loss function value, calculate the first weight factor α corresponding to the first distribution approximation function and the second distribution approximation function D and the second weighting factor Preferably, in the embodiment of the present invention, the generalized entropy index α is 0.5.

[0171] In the embodiment of the present invention, samples are randomly selected from the image training set, and the batch stochastic gradient descent method is used for training, and the learning rate is set to exponential decay for more stable convergence. The batch stochastic gradient descent method divides the image training set into small batches (batches), each batch containing multiple images. A batch of samples is used to estimate the gradient in each iteration, and then the model parameters are updated. Training using the batch stochastic gradient descent method means that during the training process, a small batch of samples is used to estimate the gradient and update the model parameters in each iteration to gradually optimize the model to minimize the loss function. The batch stochastic gradient descent method maintains a high computational efficiency while reducing the variance of the gradient estimate, making the model update more stable and the convergence speed faster. After repeated iterative training, when the total loss function obtained converges or reaches the maximum number of training iterations, it is determined that the training of the preset neural network model is completed, and the image sample generation model is obtained.

[0172] Preferably, an embodiment of the present invention further provides an image sample generation method, comprising: obtaining an abnormal image of a wound battery cell to be detected; inputting the abnormal image into an image sample generation model generated by the above-mentioned method for constructing an image sample generation model, so that the image sample generation model outputs a corresponding abnormal image sample of the battery cell. The abnormal image of the wound battery cell can be obtained by X-ray detection.

[0173] In an embodiment of the present invention, a device for constructing an image sample generation model is also provided, including a processor, a memory, and a computer program stored in the memory and configured to be executed by the processor. When the processor executes the computer program, the above-mentioned method for constructing the image sample generation model is implemented.

[0174] In an embodiment of the present invention, a computer-readable storage medium is further provided. The computer-readable storage medium includes a stored computer program. When the computer program is running, the device where the computer-readable storage medium is located is controlled to execute the above-mentioned method for constructing an image sample generation model.

[0175] Exemplarily, the computer program may be divided into one or more modules, one or more modules are stored in a memory and executed by a processor to implement the present invention. One or more modules may be a series of computer program instruction segments capable of implementing specific functions, and the instruction segments are used to describe the execution process of the computer program in a device for constructing an image sample generation model.

[0176] The device for constructing the image sample generation model may be a computing device such as a desktop computer, a notebook, a PDA, and a cloud server. The device for constructing the image sample generation model may include, but is not limited to, a processor, a memory, and a display. Those skilled in the art will appreciate that the above components are merely examples of the device for constructing the image sample generation model and do not constitute a limitation on the device for constructing the image sample generation model. The device may include more or fewer components than the components, or may combine certain components, or different components. For example, the device for constructing the image sample generation model may also include input and output devices, network access devices, buses, and the like.

[0177] The processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc. The processor is the control center of the device for constructing the image sample generation model, and uses various interfaces and lines to connect various parts of the device for constructing the entire image sample generation model.

[0178] The memory can be used to store computer programs and / or modules. The processor realizes various functions of the device for constructing the image sample generation model by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory. The memory can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, a text conversion function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, text message data, etc.), etc. In addition, the memory can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.

[0179] Among them, if the module based on the construction of the image sample generation model 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 such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electric carrier signal, telecommunication signal and software distribution medium, etc. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0180] The embodiment of the present invention provides an X-ray image sample generation method, constructs a neural network model to perform unsupervised adversarial learning on the acquired X-ray image of the wound battery core, and extracts features of the input image through a first feature extractor and a second feature extractor, so that feature information of different levels and different degrees of abstraction can be obtained, which helps the model to better understand the content and structure of the image and improve the recognition and generation capabilities of the model. Then, the two feature vectors obtained are fused, and the information of the two feature vectors can be comprehensively utilized to obtain a richer and more comprehensive feature expression, which helps to improve the quality and diversity of the image generated by the inverse encoder. Furthermore, the network structure of the inverse encoder is set to be symmetrical with the network structure of the first feature extractor in the vertical direction, and the information symmetry between the fused feature vector and the generated image sample can be maintained. This symmetry can help the network better learn the mapping relationship between the input features and the generated image, thereby improving the quality of the generated image sample. The symmetric structure can enable the inverse encoder and the first feature extractor to share some parameters, reduce the number of parameters of the model, and improve the training efficiency and generalization ability of the model. This parameter sharing helps to better utilize the training data for model training and avoid overfitting and parameter redundancy. Then, the discriminator is introduced for adversarial training, which can make the image samples generated by the inverse encoder more realistic and closer to the real image distribution. Through adversarial training and comprehensive consideration of multi-level feature information, the image sample generation model obtained has good generalization ability, can process image samples of different types and styles, and generate images with good quality.

[0181] Example 2

[0182] Figure 3 The module diagram of a device for constructing an image sample generation model provided in an embodiment of the present invention. The embodiment of the present invention provides a device for constructing an image sample generation model, comprising: a first construction module 201, a second construction module 202, a first training module 203, a second training module 204 and a training discrimination module 205;

[0183] The first construction module 201 is used to construct an image training set; wherein the image training set includes abnormal images;

[0184] The second construction module 202 is used to construct a preset neural network model; wherein the preset neural network model includes a first feature extractor, a second feature extractor, an inverse encoder and a discriminator;

[0185] The first training module 203 is used to input the image training set as the first image into the preset neural network model for iterative training, so that the first feature extractor and the second feature extractor perform feature extraction operations on the input first image to generate a first feature vector and a second feature vector;

[0186] The second training module 204 is used to concatenate the first feature vector and the second feature vector to obtain a fused feature vector and send the fused feature vector to the inverse encoder, so that the inverse encoder generates a first image sample based on the fused feature vector; input the first image sample to the discriminator, so that the discriminator performs adversarial training and generates an adversarial loss function between the first image and the first image sample;

[0187] The training judgment module 205 is used to generate a total loss function of a preset neural network model according to the adversarial loss function. When the total loss function converges or the preset neural network model reaches the maximum number of iterative training times, it is determined that the training of the preset neural network model is completed and an image sample generation model is obtained.

[0188] The embodiment of the present invention provides an X-ray image sample generation device, which constructs a neural network model to perform unsupervised adversarial learning on the acquired X-ray image of the wound battery core. The first feature extractor and the second feature extractor perform feature extraction on the input image, and feature information of different levels and different abstract degrees can be obtained, which helps the model to better understand the content and structure of the image and improve the recognition and generation capabilities of the model. Then, the two feature vectors obtained are fused, and the information of the two feature vectors can be comprehensively utilized to obtain a richer and more comprehensive feature expression, which helps to improve the quality and diversity of the image generated by the inverse encoder. Furthermore, the network structure of the inverse encoder is set to be symmetrical with the network structure of the first feature extractor in the vertical direction, and the information symmetry between the fused feature vector and the generated image sample can be maintained. This symmetry can help the network better learn the mapping relationship between the input feature and the generated image, thereby improving the quality of the generated image sample. The symmetric structure can enable the inverse encoder and the first feature extractor to share some parameters, reduce the number of parameters of the model, and improve the training efficiency and generalization ability of the model. This parameter sharing helps to better utilize the training data for model training and avoid overfitting and parameter redundancy. Then, the discriminator is introduced for adversarial training, which can make the image samples generated by the inverse encoder more realistic and closer to the real image distribution. Through adversarial training and comprehensive consideration of multi-level feature information, the image sample generation model obtained has good generalization ability, can process image samples of different types and styles, and generate images with good quality.

[0189] The above are only preferred embodiments of the present invention. It should be pointed out that, for ordinary technicians in this technical field, several improvements and substitutions can be made without departing from the technical principles of the present invention. These improvements and substitutions should also be regarded as the scope of protection of the present invention.

Claims

1. A method for constructing an image sample generation model, It is characterized in that include: Constructing an image training set; wherein the image training set includes a number of abnormal images; Constructing a preset neural network model; wherein the preset neural network model includes a first feature extractor, a second feature extractor, an inverse encoder and a discriminator; the network structure of the inverse encoder is symmetrical to the network structure of the first feature extractor; Inputting the image training set as a first image into the preset neural network model for iterative training, so that the first feature extractor and the second feature extractor perform a feature extraction operation on the input first image to generate a first feature vector and a second feature vector; concatenating the first feature vector and the second feature vector to obtain a fused feature vector, and inputting the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector; inputting the first image and the first image sample to the discriminator so that the discriminator performs adversarial training and generates an adversarial loss function between the first image and the first image sample; The total loss function of the preset neural network model is generated according to the adversarial loss function. When the total loss function converges or the preset neural network model reaches the maximum number of iterative training times, it is determined that the training of the preset neural network model is completed, and an image sample generation model is obtained.

2. A method for constructing an image sample generation model as claimed in claim 1, It is characterized in that The constructing of the image training set specifically includes: Collecting several abnormal initial images; The abnormal initial image is flipped horizontally and vertically respectively to obtain a first transformed initial image and a second transformed initial image; The abnormal initial image, the first transformed initial image and the second transformed initial image are respectively used as initial images and are standardized according to a first standardization processing formula to obtain a standardized image, a first transformed image and a second transformed image respectively; wherein the expression of the first standardization processing formula is: In the formula, is the gray value of the pixel after standardization; is the grayscale value of the pixel in the initial image; μ is the mean value of the pixel in the initial image; σ is the variance of the pixel in the initial image; The standardized image, the first transformed image and the second transformed image are used as abnormal images to construct the image training set.

3. The method for constructing an image sample generation model according to claim 1, It is characterized in that The first feature extractor and the second feature extractor perform a feature extraction operation on the input first image to generate a first feature vector and a second feature vector, specifically including: Constructing the first feature extractor based on a ResNet neural network; wherein the cross-channel connection is achieved through a residual block in the ResNet network; Constructing the second feature extractor based on the VGG neural network; wherein the VGG neural network uses a global average pooling layer to replace the fully connected layer; Extracting a style feature vector of the first image by using the ResNet neural network as the first feature vector; The attribute feature vector of the first image is extracted by the VGG neural network as the second feature vector.

4. The method for constructing an image sample generation model according to claim 1, It is characterized in that Before inputting the fused feature vector into the inverse encoder step, the step further includes: The fused feature vector is standardized according to a second standardization processing formula to obtain a standard fused feature vector; wherein the expression of the second standardization processing formula is: In the formula, f 4 is the standard fusion feature vector; σ(f 1 ) is the standard deviation of the first eigenvector obtained by accumulation; μ(f 1 ) is the accumulated mean of the first eigenvector; μ(f 2 ) is the accumulated mean of the second eigenvector; σ(f 2 ) is the standard deviation of the second eigenvector obtained by accumulation; f 1 is the first eigenvector; f 2 is the second eigenvector.

5. The method for constructing an image sample generation model according to claim 1, It is characterized in that Inputting the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector specifically includes: The inverse encoder converts the fused feature vector into a pixel-level semantic feature based on a transposed convolution; The pixel-level semantic features are input into the inverse encoder so that the inverse encoder outputs a first image sample.

6. The method for constructing an image sample generation model according to claim 1, It is characterized in that The discriminator performs adversarial training to generate an adversarial loss function between the first image and the first image sample, specifically including: The discriminator calculates the distribution distance between the first image and the first image sample based on the Wasserstein distance; Based on the distribution distance, the adversarial loss between the first image and the first image sample is calculated according to the adversarial loss function; wherein the adversarial loss function is expressed as: Where, L G To combat the loss function, x i is any image in the first image; j is any image in the first image samples; real is the data distribution in the first image; fake is the data distribution of the first image sample; K is the gradient penalty factor; λ and β are weight factors of the balanced adversarial loss function; G is the discriminator; For x i The gradient of,R| x′,x″ is the approximate gradient change; The calculation formula of the approximate gradient change is: In the formula, x i ′ and x i ″ is to add random noise of different intensities to x i The obtained data sample; C is a custom constant.

7. The method for constructing an image sample generation model according to claim 1, It is characterized in that Before calculating the total loss function of the preset neural network model according to the adversarial loss, the method further includes calculating a first distribution approximation loss and a second distribution approximation loss between the first image sample and the first image, specifically: Define the first distribution approximation loss function of the first image sample and the first image according to the relative entropy to obtain the first distribution approximation loss; wherein the expression of the first distribution approximation loss function is: Where, L D Approximate the loss function for the first distribution; x i is any image in the first image; j is any image in the first image sample; D is the inverse encoder; f 4 is the standard fusion feature vector; P fake is the data distribution of the first image sample; real is the data distribution of the first image; Inputting the standard fused feature vector into an inverse encoder to obtain a first image sample, and inputting the first image sample into the first feature extractor so that the first feature extractor outputs a first feature vector of the first image sample; A second distribution approximation loss function between the first eigenvector of the first image sample and the first eigenvector of the first image is defined according to relative entropy to obtain the second distribution approximation loss; wherein the expression of the second distribution approximation loss function is: In the formula, Approximate the loss function for the second distribution, x j is any image in the first image samples; fake is the data distribution of the first image sample; real is the data distribution of the first image; F 1 is the first feature extractor; D is the inverse encoder; x i is any one of the first images; 4 is the standard fusion feature vector; f 1 is the first eigenvector.

8. The method for constructing an image sample generation model according to claim 7, It is characterized in that Generating the total loss function of the preset neural network model according to the adversarial loss function specifically includes: Substitute the first distribution approximation loss function and the second distribution approximation loss function into the generalized entropy index calculation formula respectively to obtain a first weight factor and a second weight factor; wherein the generalized entropy index calculation formula is expressed as: In the formula, A α is the weight factor, M is the number of images in each batch training; L i is the loss function value corresponding to the i-th image; α is the generalized entropy index; Represents the average loss function value of the images in the same batch of training; The adversarial loss function, the first distribution approximation loss function, the second distribution approximation loss function, the first weight factor and the second weight factor are weighted and superimposed to obtain the total loss function; wherein the expression of the total loss function is: Where, L total is the total loss function; α D is the first weight factor; L D Approximate the loss function for the first distribution; is the second weight factor; Approximate the loss function for the second distribution; L G is the adversarial loss function.

9. A device for constructing an image sample generation model, It is characterized in that It includes a first construction module, a second construction module, a first training module, a second training module and a training discrimination module; The first construction module is used to construct an image training set; wherein the image training set includes a number of abnormal images; The second construction module constructs a preset neural network model; wherein the preset neural network model includes a first feature extractor, a second feature extractor, an inverse encoder and a discriminator; the network structure of the inverse encoder is symmetrical to the network structure of the first feature extractor; The first training module is used to input the image training set as the first image into the preset neural network model for iterative training, so that the first feature extractor and the second feature extractor perform feature extraction operations on the input first image to generate a first feature vector and a second feature vector; The second training module is used to concatenate the first feature vector and the second feature vector to obtain a fused feature vector, and input the fused feature vector to the inverse encoder so that the inverse encoder generates a first image sample based on the fused feature vector; input the first image and the first image sample to the discriminator so that the discriminator performs adversarial training and generates an adversarial loss function between the first image and the first image sample; The training judgment module is used to generate a total loss function of the preset neural network model according to the adversarial loss function. When the total loss function converges or the preset neural network model reaches a maximum number of iterative training times, it is determined that the training of the preset neural network model is completed, and an image sample generation model is obtained.

10. A method for generating an image sample, It is characterized in that include: Acquire abnormal images of the battery cells to be tested; The abnormal cell image is input into an image sample generation model generated by the method for constructing an image sample generation model according to any one of claims 1 to 8, so that the image sample generation model outputs a corresponding abnormal cell image sample.

Citation Information

Cited By

  • Picture reconstruction method, system and device and storage medium

    CN120807284A