A method, device, equipment and storage medium for digital label defect detection

By training a generative adversarial network with a multimodal input and multi-model fusion architecture, the problem of detecting defects in digital labels on freight train bodies was solved, achieving high-precision defect detection and improving transportation safety and management.

CN118429988BActive Publication Date: 2024-09-13ANXIN TUORI INFORMATION TECH CO LTD +1
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202410896545.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-05
Publication Date
2024-09-13
Estimated Expiration
2044-07-05

AI Technical Summary

Technical Problem

Existing technology cannot effectively detect defects in the numerical markings on freight train bodies, which affects transportation safety and management efficiency.

Method used

A multimodal input and multi-model fusion architecture is adopted. The generator and discriminator are trained by generative adversarial network. Self-attention and wide residual network are used for digital label defect detection. Iterative training is carried out by combining a loss function with feature information, and a threshold is set to determine the defective image.

Benefits of technology

This improved the accuracy and stability of digital label defect detection, ensuring the safety and management efficiency of freight train transportation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118429988B
    Figure CN118429988B
Patent Text Reader

Abstract

The present invention discloses a method, device, equipment and storage medium for digital label defect detection, including: intercepting digital label images and annotating them to form a supervised data set; using random numbers to set arbitrary noise a, inputting the noise a into a generator to generate images, and using a discriminator to determine whether the generated image and the supervised data set are supervised data or generated data to judge and train the generator and discriminator; preparing a test image, and then using the trained generator and discriminator to generate a generated noise b closest to the test image; generating an image based on the calculated noise b, and calculating the difference between it and the test image; setting a threshold of 600, and determining that the difference is greater than the threshold as generated data, that is, a defective image. The multi-feature multi-model fusion architecture adopted in this scheme and the iterative training of the combined loss function containing feature information can fully and focusedly learn and calculate predictions of digital label features, thereby improving the accuracy of defect detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for digital label defect detection. Background Art

[0002] With the continuous development of modern science and technology, the logistics industry has also been greatly developed and improved. Freight trains, as one of the important modes of logistics and transportation, play an irreplaceable role in the field of freight. Our company's steel industry logistics and transportation also use a lot of freight trains. However, due to the harsh operating environment of freight trains, the car body is often affected by bad weather and long-term wear, resulting in some potential hidden dangers in the car body. Among them, digital label defects are one of the most important detection contents.

[0003] Digital marking defects refer to the digital markings on the car body used to mark the vehicle number and other information. Due to long-term exposure to the external environment, they may be eroded by natural factors such as rain, sunlight, wind and sand, resulting in blurring or falling off of the digital markings. The clarity and correctness of digital markings are very important for the operation safety and management of freight trains. Once digital marking defects occur, it will bring certain troubles and hidden dangers to train transportation.

[0004] In order to timely discover and deal with digital label defects and ensure the transportation safety and efficiency of freight trains, modern technology provides us with a convenient and efficient solution - digital label defect detection technology. This technology uses advanced technical means such as computer vision and artificial intelligence to take all-round photos and monitor the train body through high-definition cameras during the operation of freight trains, quickly and accurately discover digital label defects, and feedback relevant information to the transportation management department so that it can take timely measures to repair them.

[0005] The application of digital label defect detection technology has not only improved the safety level of freight train transportation and reduced the risk of accidents, but also improved transportation efficiency and management level, making important contributions to the development and progress of the logistics industry. In the future, with the continuous innovation and improvement of science and technology, digital label defect detection technology will become more popular and perfect, bringing more convenience and security to freight train transportation. Summary of the invention

[0006] In view of this, an object of the present invention is to provide a method, device, equipment and storage medium for digital label defect detection, which solves the technical problem that digital label defect detection cannot be performed in the prior art.

[0007] In order to solve the above technical problems, the present invention provides a method for detecting digital label defects, comprising:

[0008] Step 1: obtain digital labels, capture digital label images and annotate them to form a supervised data set;

[0009] Step 2: Use a random number to set an arbitrary noise a, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervision data set are supervision data or generated data, and train the generator and discriminator;

[0010] Step 3: prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. When the total loss value ALoss converges, generate noise b;

[0011] Step 4, generate an image based on the calculated noise b, and calculate the sum of the differences between the image and the test image;

[0012] Step 5, set the threshold to 600, and the difference greater than the threshold is determined as generated data, that is, a defective image.

[0013] Optionally, the generator structure is: layer1, layer2, layer3, layer4, self-attention layer, layer5, which is one-way feature information; the wide residual network layer of the generator, that is, 50-layer WideResNet, which is two-way feature information; the one-way feature information and the two-way feature information are followed by the following layers: self-attention layer, transposed convolution ConvTranspose2d layer, activated Relu layer, output layer;

[0014] Among them, the structures of layer1, layer2, layer3, layer4 and layer5 are: spectral normalization spectral_norm (ConvTranspose2d) layer, batch normalization BatchNorm2d layer, and activation Relu layer;

[0015] The discriminator structure is: layer1c, layer2c, layer3c, layer4c, the self-attention layer, layer5c, which is three-way feature information; the wide residual network layer of the discriminator, that is, the 50-layer WideResNet, which is four-way feature information; the three-way feature information and the four-way feature information are followed by the following layers: the self-attention layer, the transposed convolution ConvTranspose2d layer, and the output layer;

[0016] Among them, the structures of layer1c, layer2c, layer3c, layer4c and layer5c are: spectral normalization spectral_norm (ConvTranspose2d) layer, activation LeakyRelu layer.

[0017] Optionally, the step of using a random number to set an arbitrary noise a in step 2, inputting the noise a into the generator to generate an image, and using a discriminator to determine whether the generated image and the supervision data set are supervision data or generated data, and training the generator and the discriminator, includes:

[0018] The loss function used by the generator is:

[0019] ;

[0020] L A is the least squares loss function, L F is the loss function of feature matching, L M is the Mel-spectrogram loss function, G is the generator, D is the discriminator, and the loss weight β 1 =2, loss weight β 2 =8;

[0021] The loss function used by the discriminator is:

[0022] ;

[0023] is a binary label 0 or 1, N represents the number of images that the model discriminates, Indicates the output label probability.

[0024] Optionally, the self-attention layer includes:

[0025] First, the input data of the self-attention layer is point-convolved to reduce the dimension to obtain the data tensor x, and then x is enlarged to obtain y, which is used as the input data of the next layer. Here, the calculation formula of y is:

[0026] ;

[0027] Here, the coefficient α is set to 0.6, and the calculation formula of H is:

[0028] ;

[0029] β is the matrix after the matrix A is standardized. T is the transposed matrix of β, and the calculation formula of A is:

[0030] A=x T x;

[0031] where x T is the transpose of the tensor x.

[0032] Optionally, the spectrum normalization calculation method in the spectrum normalization layer is:

[0033] First, the maximum eigenvector in the amplified value of each input eigenvector data is calculated, and then the maximum eigenvector is divided by the weight parameter in the network layer to complete the spectrum normalization calculation.

[0034] Optionally, prepare the test image as described in step 3, and then use the trained generator and discriminator to iterate 1000 times. At this time, when the total loss value ALoss converges, the calculation method of the generated noise b is:

[0035] Use a random number to set an arbitrary noise b, and use this noise to generate an image; then calculate the difference in pixel level in each channel of the generated image and the test image, and calculate the sum of the absolute values ​​of the pixel differences as the loss value Rloss;

[0036] The absolute values ​​of the differences in the pixel levels of the generated image and the test image of the layer4c, the self-attention layer, and the layer5c network layer of the three-way feature information in the trained discriminator are recorded as DLoss1, DLoss2, and DLoss3 respectively;

[0037] The following formula calculates the total loss value Aloss of the test image and the generated image:

[0038] ;

[0039] Here c=0.2, controls the weights of different losses;

[0040] The differential value of b is calculated for the total loss value Aloss, b is updated according to the obtained differential value, and an image is generated using the updated b, which is closer to the test image than the previous image;

[0041] Among them, the update method of b is:

[0042] Use the total loss value Aloss to iterate b for 1000 training times until the total loss value ALoss converges. At this time, the optimal b value is calculated, that is, the generated noise b that is closest to the test image.

[0043] The present application also provides a digital label defect detection device, comprising:

[0044] A supervised data set determination module is used to obtain digital labels, intercept digital labeled images and annotate them to form a supervised data set;

[0045] The generator and discriminator determination module is used to set an arbitrary noise a using a random number, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervision data set are supervision data or generated data to determine and train the generator and the discriminator;

[0046] Generate a noise determination module to prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. When the total loss value ALoss converges, generate noise b;

[0047] A difference and determination module, used for generating an image according to the calculated noise b, and calculating the difference between the image and the test image;

[0048] The defect judgment module is used to set the threshold value to 600, and the difference and the value greater than the threshold value are judged as generated data, that is, defective images.

[0049] The present application also provides a digital label defect detection device, comprising:

[0050] Memory for storing computer programs;

[0051] A processor is used to implement the steps of the above-mentioned method for digital label defect detection when executing the computer program.

[0052] The present application also provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are loaded and executed by a processor, the steps of the method for digital label defect detection as described above are implemented.

[0053] It can be seen that the present invention obtains digital labels, intercepts digital label images and annotates them to form a supervised data set through step 1; step 2, uses random numbers to set an arbitrary noise a, inputs the noise a into the generator and generates an image, and uses a discriminator to determine whether the generated image and the supervised data set are supervised data or generated data, and trains the generator and the discriminator; step 3, prepares a test image, and then uses the trained generator and discriminator to iterate 1000 times for training, and when the total loss value ALoss converges, generates noise b; step 4, generates an image based on the calculated noise b, and calculates the difference between it and the test image; step 5, sets the threshold to 600, and the difference sum greater than the threshold is determined to be generated data, that is, a defective image.

[0054] The present invention adopts multi-modal input, multi-model fusion architecture and constructs a combined loss function containing feature information for iterative training, which can fully and focusedly learn and calculate and predict digital label features, thereby improving the accuracy of defect detection.

[0055] In addition, the present invention also provides a device, equipment and storage medium for digital label defect detection, which also have the above-mentioned beneficial effects. BRIEF DESCRIPTION OF THE DRAWINGS

[0056] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0057] Figure 1 A flowchart of a method for detecting digital label defects provided by an embodiment of the present invention;

[0058] Figure 2 A schematic diagram of performing discrimination training to improve the embodiment of the present invention;

[0059] Figure 3 A schematic diagram of the structure of a trained generator provided by an embodiment of the present invention;

[0060] Figure 4 A schematic diagram of the structure of a layer provided by an embodiment of the present invention;

[0061] Figure 5 A schematic diagram of a trained discriminator provided by an embodiment of the present invention;

[0062] Figure 6 A schematic diagram of the structure of a discriminator layer provided by an embodiment of the present invention;

[0063] Figure 7 A schematic diagram of performing defect detection on a test image provided by an embodiment of the present invention;

[0064] Figure 8 A schematic diagram of the structure of a digital label defect detection device provided by an embodiment of the present invention;

[0065] Fig. 9 A schematic diagram of the structure of a digital label defect detection device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0066] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0067] Please refer to Figure 1 , Figure 1 A flowchart of a method for detecting digital label defects provided by an embodiment of the present invention. The method may include:

[0068] S101, obtain digital labels, capture digital label images and annotate them to form a supervised data set.

[0069] This embodiment can be applied to the detection of digital label defects on freight train bodies.

[0070] S102, use a random number to set an arbitrary noise a, input the noise a into the generator and generate an image, and use a discriminator to determine whether the generated image and the supervision data set are supervision data or generated data, and train the generator and the discriminator.

[0071] In this embodiment, random numbers are used to set an arbitrary noise. For ease of understanding, please refer to Figure 2 , Figure 2 A schematic diagram of a discriminant training improved according to an embodiment of the present invention, wherein an arbitrary noise a is set using a random number, the noise a is input into a generator and an image is generated, and the generated image (generated image) and a supervision data set are discriminated by a discriminator to determine whether they are supervision data or generated data for discriminative training.

[0072] It should be further explained that in order to improve the accuracy of the image generated by the generator, the above generator structure is: layer1, layer2, layer3, layer4, self-attention Self-Attention layer, layer5, which is one-way feature information; WideResNet-50 layer (the wide residual network layer of the generator), that is, 50-layer WideResNet, which is two-way feature information; one-way feature information and two-way feature information are connected to the following layers: Self-Attention Self-Attention layer (here the Self-Attention layer fuses the two-way feature information and redistributes some weights), transposed convolution ConvTranspose2d layer, activated Relu layer, output layer; among which the structures of layer1, layer2, layer3, layer4 and layer5 are: spectral normalization spectral_norm (ConvTranspose2d) layer, batch normalization B atchNorm2d layer, activate Relu layer; the discriminator structure is: layer1c, layer2c, layer3c, layer4c, self-attention Self-Attention layer, layer5c, which is three-way feature information; WideResNet-50 layer (wide residual network layer of the discriminator), that is, 50-layer WideResNet, which is four-way feature information; the three-way feature information and the four-way feature information are followed by the following layers: Self-Attention Self-Attention layer (here the Self-Attention layer fuses the two-way feature information and redistributes some weights), transposed convolution ConvTranspose2d layer, output layer; among them, the structures of layer1c, layer2c, layer3c, layer4c and layer5c are all: spectral normalization spectral_norm (ConvTranspose2d) layer, activate LeakyRelu layer.

[0073] Layer1, layer2, layer3, layer4 and layer5 in this embodiment represent the initial layer of the generator, the second layer of the generator, the third layer of the generator, the fourth layer of the generator and the fifth layer of the generator respectively; the Self-Attention layer in this embodiment represents the self-attention mechanism layer, and the Self-Attention layer fuses the two-way feature information and redistributes part of the weights; the ConvTranspose2d (transposed convolution layer) in this embodiment is an upsampling technology widely used in deep learning, which can convert low-resolution feature maps into high-resolution feature maps; the Tanh layer (hyperbolic tangent) in this embodiment usually refers to the layer that uses the hyperbolic tangent activation function in the neural network. In this embodiment, the generation of one-way feature information and the generation of two-way feature information are followed by the following layers: the Self-Attention layer (here the Self-Attention layer fuses the two-way feature information and redistributes part of the weights), the ConvTranspose2d layer (transposed convolution layer) and the Relu layer. For ease of understanding, please refer to Figure 3 , Figure 3 A schematic diagram of the structure of a trained generator provided by an embodiment of the present invention. It can be understood that the multi-layer structure design of the generator provides a powerful and flexible framework for generative adversarial networks by combining a variety of advanced neural network technologies and components. This structure can not only effectively generate high-quality outputs, but also has good training stability and generalization ability. For ease of understanding, please refer to Figure 4 , Figure 4 A schematic diagram of a layer structure provided by an embodiment of the present invention, from Figure 4 It can be seen that the structures of layer1, layer2, layer3, layer4, Self-Attention layer and layer5 include a spectrum normalization layer, a batch normalization layer and a Relu layer (non-linear activation function layer). Among them, the spectrum normalization calculation method in the spectrum normalization layer in this embodiment is: first, the maximum feature vector is selected from the amplified values ​​of various input feature vector data, and then the maximum feature vector is divided by the weight parameter in the network layer to complete the spectrum normalization calculation.

[0074] In this embodiment, layer1c, layer2c, layer3c, layer4c and layer5c respectively represent the first layer of the discriminator, the second layer of the discriminator, the third layer of the discriminator, the fourth layer of the discriminator and the fifth layer of the discriminator. For ease of understanding, please refer to Figure 5 , Figure 5 For a schematic diagram of a trained discriminator provided in an embodiment of the present invention, please refer to Figure 6 , Figure 6A schematic diagram of the structure of a discriminator layer provided by an embodiment of the present invention, from Figure 6 It can be seen that the structures of layer1c, layer2c, layer3c, layer4c and layer5c all include a spectral_norm (ConvTranspose2d) layer, i.e., a spectral normalization layer and a LeakyRelu layer.

[0075] It should be further explained that in step 2, a random number is used to set an arbitrary noise a, the noise a is input into the generator to generate an image, and the generated image and the supervision data set are used by the discriminator to determine whether they are supervision data or generated data, and the steps of training the generator and the discriminator include: the loss function used by the generator is: L A is the least squares loss function, L F is the loss function of feature matching, L M is the Mel-spectrogram loss function, G is the generator, D is the discriminator, and the loss weight β 1 =2, loss weight β 2 =8; the loss function used by the discriminator is: ; is a binary label 0 or 1, N represents the number of images that the model discriminates, Indicates the output label probability.

[0076] It should be further explained that the self-attention layer can include: firstly, performing point convolution on the input data of the self-attention layer to reduce the dimension to obtain the data tensor x, and then amplifying x to obtain y, which is used as the input data of the next layer. Here, the calculation formula of y is: Here, the coefficient α is set to 0.6, and the calculation formula of H is: ; β is the matrix after the matrix A is standardized, β T is the transposed matrix of β, and the calculation formula of A is: A=x T x; where x T is the transpose of the tensor x.

[0077] It should be further explained that the above spectrum normalization calculation method is: first find the maximum eigenvector in the amplified value of each input eigenvector data, and then use the maximum eigenvector to divide the weight parameter in the network layer to complete the spectrum normalization calculation.

[0078] S103, prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. At this time, when the total loss value ALoss converges, generate noise b.

[0079] This embodiment can prepare a test image, and then use the trained generator and discriminator to generate the generated noise b that is closest to the test image, that is, the generated noise b when the total loss value ALoss converges. It should be further explained that the test image is prepared above, and then the trained generator and discriminator are used to iterate 1000 times for training. At this time, when the total loss value ALoss converges, the calculation method of the generated noise b is: use a random number to set an arbitrary noise b, and use the noise to generate an image; calculate the difference in pixel level in each channel of the generated image and the test image, and calculate the sum of the absolute values ​​of the pixel differences as the loss value Rloss; the absolute sum of the difference in the feature quantities of the three-way feature information layer4c, the self-attention layer, and the layer5c network layer in the discriminator at the pixel level of the generated image and the test image is recorded as DLoss1, DLoss2, and DLoss3 respectively; the following formula calculates the total loss value ALoss of the test image and the generated image, and the formula is as follows:

[0080] Here c=0.2, which controls the weights of different losses. The differential value of b is obtained for the total loss value ALoss, and b is updated according to the obtained differential value. The updated b is used to generate an image, which is closer to the test image than the previous image. The updating method of b is: b is iterated 1000 times using the total loss function ALoss until ALoss converges, at which time the optimal b value is calculated.

[0081] S104, generating an image according to the calculated noise b, and calculating the sum of the differences between the image and the test image.

[0082] S105, setting the threshold to 600, and determining that the difference is greater than the threshold as generated data, that is, a defective image.

[0083] For easier understanding, please refer to Figure 7 , Figure 7 A schematic diagram of performing defect detection on a test image provided by an embodiment of the present invention, from Figure 7 It can be seen that first, a test image needs to be prepared, noise of an image most similar to the test image is generated, a similar noise image is determined using the noise, the difference between the similar noise image and the test image is calculated, and then the test image is judged whether there are defects based on the set difference threshold.

[0084] The digital label defect detection method provided by the embodiment of the present invention uses multi-modal input, multi-model fusion architecture and constructs a combined loss function containing feature information for iterative training, which can fully and focusedly learn and calculate predictions of digital label features, thereby improving the accuracy of defect detection. In addition, the multi-layer structure design of the generator provides a powerful and flexible framework for generative adversarial networks by combining a variety of advanced neural network technologies and components. This structure can not only effectively generate high-quality outputs, but also has good training stability and generalization capabilities; and the discriminator in this embodiment includes multiple layers, so that the discriminator has better discriminative performance; and the generated noise in this embodiment is continuously updated, which improves the accuracy of the generated noise determination.

[0085] A digital label defect detection device provided by an embodiment of the present invention is introduced below. The digital label defect detection device described below and the digital label defect detection method described above can be referred to each other.

[0086] Please refer to Figure 8 , Figure 8 A schematic diagram of a structure of a digital label defect detection device provided by an embodiment of the present invention may include:

[0087] A supervision data set determination module 100 is used to obtain digital labels, intercept digital label images and annotate them to form a supervision data set;

[0088] The generator and discriminator determination module 200 is used to set an arbitrary noise a using a random number, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervision data set are supervision data or generated data to determine and train the generator and the discriminator;

[0089] Generate a noise determination module 300, which is used to prepare a test image, and then use the trained generator and discriminator to iterate 1000 times of training. At this time, when the total loss value ALoss converges, generate noise b;

[0090] A difference sum determination module 400 is used to generate an image according to the calculated noise b, and calculate the difference sum between the image and the test image;

[0091] The defect determination module 500 is used to set the threshold value to 600, and the difference and the value greater than the threshold value are determined as generated data, that is, defective images.

[0092] Further, based on the above embodiment, the generator structure is: layer1, layer2, layer3, layer4, self-attention layer, layer5, which is one-way feature information; the wide residual network layer of the generator, that is, 50-layer WideResNet, which is two-way feature information; one-way feature information and two-way feature information are connected to the following layers: self-attention layer, transposed convolution ConvTranspose2d layer, activation Relu layer, output layer;

[0093] Among them, the structures of layer1, layer2, layer3, layer4 and layer5 are: spectral normalization spectral_norm (ConvTranspose2d) layer, batch normalization BatchNorm2d layer, and activation Relu layer;

[0094] The discriminator structure is: layer1c, layer2c, layer3c, layer4c, the self-attention layer, layer5c, which is three-way feature information; the wide residual network layer of the discriminator, that is, the 50-layer WideResNet, which is four-way feature information; the three-way feature information and the four-way feature information are followed by the following layers: the self-attention layer, the transposed convolution ConvTranspose2d layer, and the output layer;

[0095] Among them, the structures of layer1c, layer2c, layer3c, layer4c and layer5c are: spectral normalization spectral_norm (ConvTranspose2d) layer, activation LeakyRelu layer.

[0096] Further, based on any of the above embodiments, the generator and discriminator determination module 200 may include:

[0097] The loss function used by the generator is:

[0098] ;

[0099] L A is the least squares loss function, L F is the loss function of feature matching, L M is the Mel-spectrogram loss function, G is the generator, D is the discriminator, and the loss weight β 1 =2, loss weight β 2 =8;

[0100] The loss function used by the discriminator is:

[0101] ;

[0102] is a binary label 0 or 1, N represents the number of images that the model discriminates, Indicates the output label probability.

[0103] Further, based on the above embodiment, the self-attention layer may include: firstly performing point convolution on the input data of the self-attention layer to reduce the dimension to obtain a data tensor x, and then amplifying x to obtain y, where y is used as the input data of the next layer, where the calculation formula of y is: ; Here the coefficient α is set to 0.6, and the calculation formula of H is: ; β is the matrix after the matrix A is standardized, β T is the transposed matrix of β, and the calculation formula of A is: A=x T x; where x T is the transpose of the tensor x.

[0104] Further, based on the above embodiment, the spectrum normalization calculation method in the spectrum normalization layer is: first, the maximum eigenvector in the amplified value of each input eigenvector data is calculated, and then the maximum eigenvector is divided by the weight parameter in the network layer to complete the spectrum normalization calculation.

[0105] Further, based on the above embodiment, the test image is prepared, and then the trained generator and discriminator are used to iterate 1000 times for training. At this time, when the total loss value ALoss converges, the noise b is generated, that is, the calculation method of the generated noise b when the total loss value ALoss converges is: use a random number to set an arbitrary noise b, and use the noise to generate an image; then calculate the difference in pixel level in each channel of the generated image and the test image, and calculate the sum of the absolute values ​​of the pixel differences as the loss value Rloss; the absolute values ​​of the differences in the feature quantities of the layer4c, self-attention layer, and layer5c network layer of the three-way feature information in the trained discriminator at the pixel level of the generated image and the test image are recorded as DLoss1, DLoss2, and DLoss3 respectively; the total loss value Aloss of the test image and the generated image is calculated by the following formula, and the formula is as follows: ; Here c=0.2, which controls the weights of different losses; the differential value of b is obtained for the total loss value Aloss, b is updated according to the obtained differential value, and an image is generated using the updated b, which is closer to the test image than the previous image; wherein, the updating method of b is: b is iterated 1000 times using the total loss value Aloss to train until the total loss value ALoss converges, at which time the optimal b value is calculated, that is, the generated noise b that is closest to the test image.

[0106] It should be noted that the order of the modules and units in the above-mentioned digitally labeled defect detection device can be changed without affecting the logic.

[0107] A device for digital label defect detection provided by an embodiment of the present invention may include: a supervisory data set determination module 100, which is used to obtain digital labels, intercept digital label images and annotate them to form a supervisory data set; a generator and discriminator determination module 200, which is used to use random numbers to set an arbitrary noise a, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervisory data set are supervisory data or generated data, and train the generator and the discriminator; a generated noise determination module 300, which is used to prepare a test image, and then use the trained generator and discriminator to iterate 1000 times for training, and when the total loss value ALoss converges, generate noise b; a difference and determination module 400, which is used to generate an image based on the calculated noise b, and calculate the difference and the test image; a defect judgment module 500, which is used to set the threshold to 600, and the difference and the sum greater than the threshold are judged as generated data, that is, a defective image. This application uses multi-modal input, multi-model fusion architecture and constructs a combined loss function containing feature information for iterative training, which can fully and focusedly learn and calculate predictions of digital label features, thereby improving the accuracy of defect detection. In addition, the multi-layer structure design of the generator provides a powerful and flexible framework for generative adversarial networks by combining a variety of advanced neural network technologies and components. This structure can not only effectively generate high-quality outputs, but also has good training stability and generalization capabilities; and the discriminator in this embodiment includes multiple layers, so that the discriminator has better discriminative performance; and the generated noise in this embodiment is continuously updated, which improves the accuracy of the generated noise determination.

[0108] A digital label defect detection device provided by an embodiment of the present invention is introduced below. The digital label defect detection device described below and the digital label defect detection method described above can be referred to each other.

[0109] Please refer to Fig. 9 , Fig. 9 A schematic diagram of a structure of a digital label defect detection device provided by an embodiment of the present invention may include:

[0110] A memory 10, used for storing computer programs;

[0111] The processor 20 is used to execute a computer program to implement the above-mentioned digital label defect detection method.

[0112] The memory 10 , the processor 20 , and the communication interface 30 all communicate with each other via a communication bus 40 .

[0113] In the embodiment of the present invention, the memory 10 is used to store one or more programs, and the program may include program code, and the program code includes computer operation instructions. In the embodiment of the present invention, the memory 10 may store programs for implementing the following functions:

[0114] Step 1: obtain digital labels, capture digital label images and annotate them to form a supervised data set;

[0115] Step 2: Use a random number to set an arbitrary noise a, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervision data set are supervision data or generated data, and train the generator and discriminator;

[0116] Step 3: prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. When the total loss value ALoss converges, generate noise b;

[0117] Step 4, generate an image based on the calculated noise b, and calculate the sum of the differences between the image and the test image;

[0118] Step 5, set the threshold to 600, and the difference greater than the threshold is determined as generated data, that is, a defective image.

[0119] In a possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store an operating system and an application required for at least one function, etc.; the data storage area may store data created during use.

[0120] In addition, the memory 10 may include a read-only memory and a random access memory, and provide instructions and data to the processor. A portion of the memory may also include an NVRAM. The memory stores an operating system and operating instructions, executable modules or data structures, or a subset thereof, or an extended set thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and processing hardware-based tasks.

[0121] The processor 20 may be a central processing unit (CPU), an application specific integrated circuit, a digital signal processor, a field programmable gate array or other programmable logic device, a microprocessor or any conventional processor, etc. The processor 20 may call a program stored in the memory 10 .

[0122] The communication interface 30 may be an interface of a communication module, and is used to connect to other devices or systems.

[0123] Of course, it should be noted that Fig. 9 The structure shown does not constitute a limitation on the digital label defect detection device in the embodiment of the present invention. In actual applications, the digital label defect detection device may include Fig. 9 More or fewer components than shown, or combinations of certain components.

[0124] The computer-readable storage medium provided by an embodiment of the present invention is introduced below. The computer-readable storage medium described below and the method for detecting digital label defects described above can be referred to each other.

[0125] The present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned method for detecting digital label defects are implemented.

[0126] The readable storage medium may include: 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, and other media that can store program codes.

[0127] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0128] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0129] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprises" or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.

[0130] The above is a detailed introduction to the method, device, equipment and storage medium for digital label defect detection provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for detecting digital label defects, characterized in that: The following steps are involved: Step 1: obtain digital labels, capture digital label images and annotate them to form a supervised data set; Step 2: Use a random number to set an arbitrary noise a, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervision data set are supervision data or generated data, and train the generator and discriminator; These include: The generator structure is: layer1, layer2, layer3, layer4, self-attention layer, layer5, which is one-way feature information; the wide residual network layer of the generator, that is, the 50-layer WideResNet, which is two-way feature information; the one-way feature information and the two-way feature information are followed by the following layers: self-attention layer, transposed convolution ConvTranspose2d layer, activation Relu layer, output layer; Among them, the structures of layer1, layer2, layer3, layer4 and layer5 are: spectral normalization spectral_norm layer, batch normalization BatchNorm2d layer, and activation Relu layer; The discriminator structure is: layer1c, layer2c, layer3c, layer4c, self-attention layer, layer5c, which is three-way feature information; the wide residual network layer of the discriminator, that is, 50-layer WideResNet, which is four-way feature information; the three-way feature information and the four-way feature information are followed by the following layers: self-attention layer, transposed convolution ConvTranspose2d layer, output layer; Among them, the structures of layer1c, layer2c, layer3c, layer4c and layer5c are: spectral normalization spectral_norm layer, activation LeakyRelu layer; Step 3: prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. When the total loss value ALoss converges, generate noise b; Step 4, generate an image based on the calculated noise b, and calculate the sum of the differences between the image and the test image; Step 5, set the threshold to 600, and the difference greater than the threshold is determined as generated data, that is, a defective image.

2. A method for detecting digital label defects according to claim 1, characterized in that: In step 2, a random number is used to set an arbitrary noise a, the noise a is input into the generator to generate an image, and the generated image and the supervision data set are judged by the discriminator to determine whether they are supervision data or generated data, and the steps of training the generator and the discriminator include: The loss function used by the generator is: ; is the least squares loss function , is the loss function for feature matching , is the Mel-spectrogram loss function, G is the generator, D is the discriminator, loss weight β1=2, loss weight β2=8; The loss function used by the discriminator is: ; is a binary label 0 or 1, N represents the number of images that the model discriminates, Indicates the output label probability.

3. A method for detecting digital label defects according to claim 1, characterized in that: The self-attention layer includes: First, the input data of the self-attention layer is point-convolved to reduce the dimension to obtain the data tensor x, and then x is enlarged to obtain y, which is used as the input data of the next layer. Here, the calculation formula of y is: ; Here, the coefficient α is set to 0.6, and the calculation formula of H is: ; β is the matrix after the matrix A is standardized. T is the transposed matrix of β, and the calculation formula of A is: A=x T x; where x T is the transpose of the tensor x.

4. A method for detecting digital label defects according to claim 1, characterized in that: The spectrum normalization calculation method in the spectrum normalization layer is: First, the maximum eigenvector in the amplified value of each input eigenvector data is calculated, and then the maximum eigenvector is divided by the weight parameter in the network layer to complete the spectrum normalization calculation.

5. A method for detecting digital label defects according to claim 1, characterized in that: In step 3, prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. When the total loss value ALoss converges, the calculation method of the generated noise b is: Use a random number to set an arbitrary noise b, and use this noise to generate an image; then calculate the difference in pixel level in each channel of the generated image and the test image, and calculate the sum of the absolute values ​​of the pixel differences as the loss value Rloss; The absolute values ​​of the differences in the pixel levels of the generated image and the test image for the three-way feature information of layer4c, self-attention layer, and layer5c of the trained discriminator are recorded as DLoss1, DLoss2, and DLoss3 respectively; The following formula calculates the total loss value Aloss of the test image and the generated image: ; Here c=0.2, controls the weights of different losses; The differential value of b is calculated for the total loss value Aloss, b is updated according to the obtained differential value, and an image is generated using the updated b, which is closer to the test image than the previous image; Among them, the update method of b is: Use the total loss value Aloss to iterate b for 1000 training times until the total loss value ALoss converges, at which time the optimal b value is calculated.

6. A digital label defect detection device, characterized in that: include: A supervised data set determination module is used to obtain digital labels, intercept digital labeled images and annotate them to form a supervised data set; The generator and discriminator determination module is used to set an arbitrary noise a using a random number, input the noise a into the generator and generate an image, and use the discriminator to determine whether the generated image and the supervision data set are supervision data or generated data to determine and train the generator and the discriminator; These include: The generator structure is: layer1, layer2, layer3, layer4, self-attention layer, layer5, which is one-way feature information; the wide residual network layer of the generator, that is, the 50-layer WideResNet, which is two-way feature information; the one-way feature information and the two-way feature information are followed by the following layers: self-attention layer, transposed convolution ConvTranspose2d layer, activation Relu layer, output layer; Among them, the structures of layer1, layer2, layer3, layer4 and layer5 are: spectral normalization spectral_norm layer, batch normalization BatchNorm2d layer, and activation Relu layer; The discriminator structure is: layer1c, layer2c, layer3c, layer4c, self-attention layer, layer5c, which is three-way feature information; the wide residual network layer of the discriminator, that is, 50-layer WideResNet, which is four-way feature information; the three-way feature information and the four-way feature information are followed by the following layers: self-attention layer, transposed convolution ConvTranspose2d layer, output layer; Among them, the structures of layer1c, layer2c, layer3c, layer4c and layer5c are: spectral normalization spectral_norm layer, activation LeakyRelu layer; Generate a noise determination module to prepare the test image, and then use the trained generator and discriminator to iterate 1000 times. When the total loss value ALoss converges, generate noise b; A difference and determination module, used for generating an image according to the calculated noise b, and calculating the difference between the image and the test image; The defect judgment module is used to set the threshold value to 600, and the difference and the value greater than the threshold value are judged as generated data, that is, defective images.

7. A digital label defect detection device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for detecting digital label defects as claimed in any one of claims 1 to 5 when executing the computer program.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, and when the computer-executable instructions are loaded and executed by a processor, the steps of the method for digital label defect detection as described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Semi-supervised X-ray image automatic labeling based on generative adversarial network

    CN110110745A

  • Household appliance fingerprint data generation method based on generative adversarial network

    CN113343876A

  • Digital printing fabric defect detection method based on generative adversarial network

    CN117237274A

  • Training method of image super-division model and image super-division method

    CN118052717A

  • Generative adversarial networks with temporal and spatial discriminators for efficient video generation

    WO2020234449A1