Defect image generation method and system based on double discriminators and channel perception processing
By employing a dual discriminator and channel-aware processing method, the data enhancement and post-processing of the RGB and Alpha channels are decoupled, solving the problems of lost transparency annotation information and mode collapse in the generation of defective images in RGBA format. This improves the diversity and quality of the generated images, reduces the computational resource requirements, and achieves efficient defective image generation.
Patent Information
- Application Number
- CN202611335557.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-31
- Publication Date
- 2026-11-24
AI Technical Summary
When processing RGBA format defect images, existing generative adversarial networks are prone to loss or misalignment of transparency annotation information, single discriminator architecture is prone to gradient vanishing and pattern collapse, insufficient diversity of generated samples, and lack of dedicated post-processing mechanisms, making it difficult to meet the requirements of high-precision defect detection.
A dual-discriminator and channel-aware processing method is adopted. By decoupling the data augmentation and post-processing of the RGB and Alpha channels, and combining multi-dimensional diversity constraint mechanisms and gradient penalties, a dual-path complementary discrimination mechanism is constructed to ensure the consistency of transparency annotation information. Furthermore, image quality is improved through multi-level filtering and sharpening processing.
It effectively solves the problems of lost transparency annotation information and pattern collapse, improves the diversity and quality of generated images, reduces the demand for computing resources, and improves generation efficiency and accuracy.
Smart Images

Figure CN123160697A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of computer vision and deep learning technology, specifically to a method and system for generating defective images based on dual discriminators and channel perception processing. Background Technology
[0002] In industrial vision scenarios such as infrastructure defect detection, the number of samples of cracks and surface defects actually collected is limited. Therefore, using generative adversarial networks to synthesize defect images to expand the training dataset has become an important technical means.
[0003] Existing generative adversarial networks (GANs) typically reduce the dimensionality of four-channel RGB images to three-channel RGB when processing RGBA defect images with transparency annotations. During data augmentation, the semantic characteristics of the alpha channel are ignored, leading to coupled application of geometric and photometric transformations. This results in the loss of transparency annotation information or misalignment with the RGB content space. Furthermore, traditional single-discriminator architectures are prone to mode collapse in defect image generation tasks with highly concentrated texture features. Existing mitigation methods include WGAN-GP gradient penalty and Minibatch Discrimination, but the effectiveness of single methods is limited, and the diversity of generated samples remains insufficient.
[0004] Furthermore, the discriminator in a single-discriminator GAN is prone to becoming too strong, leading to vanishing gradients or training oscillations in the generator. Existing methods typically mitigate this through empirical means such as adjusting the learning rate and adding regularization, but lack a systematic solution to address training imbalance at the architectural level. Moreover, the lack of a dedicated post-processing mechanism for RGBA-generated images results in output images with high-frequency noise, texture discontinuities, blurred edges, and artifacts in mask transition areas, making it difficult to meet the training requirements of high-precision defect detection models. Summary of the Invention
[0005] To address the shortcomings of existing technologies, the purpose of this invention is to provide a method and system for generating defective images based on dual discriminators and channel sensing processing.
[0006] A defect image generation method based on dual discriminator and channel sensing processing according to the present invention includes: Step S1: Obtain the defect source image in RGBA format, and perform decoupling enhancement processing on the RGB and Alpha channels of the defect source image to obtain an expanded training set; Step S2: Based on the expanded training set, the parameters of the generative adversarial network are updated by using a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and by applying gradient penalties to the first discriminator and the second discriminator respectively. Step S3: After each training cycle, decouple the RGB channels and Alpha channels of the RGBA format generated by the generative adversarial network to obtain the target defect image.
[0007] Preferably, step S1 includes: The defect source image is separated into RGB channels and Alpha channels; Spatial geometric transformation is applied to both RGB and Alpha channels, while photometric property transformation is applied only to the RGB channels; The transformed RGB channels and Alpha channels are recombined into RGBA format to obtain the expanded training set.
[0008] Preferably, the spatial geometric transformation includes horizontal flipping performed with a preset probability, vertical flipping performed with a preset probability, and random rotation uniformly distributed among multiple preset rotation angles; The photometric attribute transformation includes brightness adjustment and contrast adjustment, and the coefficients of both brightness adjustment and contrast adjustment are uniformly sampled within a preset adjustment range.
[0009] Preferably, the dual-path complementary discrimination mechanism includes: The first discriminator uses a standard discrimination target, outputs a first preset label for real samples, and outputs a second preset label for generated samples; The second discriminator uses reverse discrimination to identify the target, outputting the second preset label for the real sample and the first preset label for the generated sample; The generator of the generative adversarial network is updated based on the discrimination loss that makes the outputs of the first discriminator and the second discriminator on the generated samples close to the first preset label; Gradient penalties are applied to the first discriminator and the second discriminator respectively. The gradient penalty is determined based on the deviation between the gradient norm of the discriminator for the real sample and the interpolated sample of the generated sample and 1.
[0010] Preferably, the multi-dimensional diversity constraint mechanism includes: Intra-batch sample similarity vectors are introduced into the feature flattening layers of the first and second discriminators to perceive batch-level diversity; A diversity penalty based on generating images with different noise inputs is introduced into the total loss of the generator to constrain instance-level diversity.
[0011] Preferably, an intra-batch sample similarity vector is introduced into the feature flattening layer of the first discriminator and the second discriminator, including: The input features are mapped to a three-dimensional tensor using a learnable parameter matrix; Calculate the L1 distance between all sample pairs within a batch, take the exponential negative L1 distance, and sum them to obtain the sample similarity vector within the batch; A diversity penalty based on the generated images from different noise inputs is introduced into the total loss of the generator, including: Two sets of different random noises are input into the generator to obtain two sets of generated images. The negative mean of the mean squared error distance between the two sets of generated images is calculated as the diversity loss.
[0012] Preferably, step S3 includes: Perform grayscale conversion on the generated RGBA format image while preserving the alpha channel; Multi-level edge-preserving denoising is performed on the converted color channels, and binarization is performed on the Alpha channel; The denoised color channel is concatenated with the binarized Alpha channel to obtain the target defect image. The binarization process for the Alpha channel includes: binarizing the Alpha channel based on a preset threshold; The multi-level edge-preserving denoising process performed on the converted color channels includes: Median filtering and bilateral filtering with a preset window size are applied sequentially. The parameters of the bilateral filtering include neighborhood diameter, color gamut standard deviation, and spatial gamut standard deviation. Convolution is performed using a Laplacian sharpening kernel, which is a preset matrix.
[0013] Preferably, the method includes: Step S1: Use an image processing chip to acquire a defect source image in RGBA format, and perform decoupling enhancement processing on the RGB and Alpha channels of the defect source image to obtain an expanded training set; Step S2: Using the GPU based on the expanded training set, through a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and applying gradient penalties to the first discriminator and the second discriminator respectively, the parameters of the generative adversarial network are updated. Step S3: After each training cycle is completed, the industrial control computer performs decoupling post-processing on the RGB and Alpha channels of the RGBA format image generated by the generative adversarial network to obtain the target defect image.
[0014] A defect image generation system based on dual discriminators and channel sensing processing, according to the present invention, includes: The data augmentation module is used to acquire defect source images in RGBA format, and perform decoupling augmentation processing on the RGB channels and Alpha channels of the defect source images to obtain an expanded training set; The adversarial training module is used to update the parameters of the generative adversarial network based on the expanded training set, through a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and to apply gradient penalties to the first discriminator and the second discriminator respectively. The post-processing module is used to perform decoupled post-processing on the RGB and Alpha channels of the RGBA format generated image output by the generative adversarial network after each training cycle to obtain the target defect image.
[0015] According to the present invention, a computer-readable storage medium is provided thereon storing a computer program that, when executed by a processor, implements the defect image generation method based on dual discriminator and channel sensing processing.
[0016] Compared with the prior art, the present invention has the following beneficial effects: 1. This application performs decoupling processing on the RGB and Alpha channels of the defective source image and the generated image in RGBA format during the data enhancement and post-processing stages, respectively. During geometric transformation, the spatial alignment of the two channels is maintained synchronously. During photometric transformation and denoising processing, only the color channel is applied while the original semantics of the Alpha channel are preserved. This avoids the loss or misalignment of transparency annotation information due to channel coupling processing during data flow, and ensures the consistency between the generated image and the original annotation at the pixel level.
[0017] 2. This application constructs a dual-path complementary discrimination mechanism that includes a first discriminator for standard discrimination targets and a second discriminator for reverse discrimination targets. Combined with WGAN-GP gradient penalty constraints, this mechanism enables the generator to receive both positive and negative gradient feedback signals simultaneously, effectively alleviating the gradient vanishing problem caused by an overly strong single discriminator.
[0018] 3. This invention introduces Minibatch Discrimination in the discriminator feature layer to perceive the similarity of samples within a batch, and introduces diversity regularization penalty based on different noise inputs in the generator loss layer. It collaboratively suppresses mode collapse from three dimensions: architecture, features and loss, thereby improving the texture diversity and structural differences of the generated defective images.
[0019] 4. This application outputs generated samples in each training cycle and sequentially performs Alpha channel binarization, color channel median filtering, bilateral filtering, and Laplacian sharpening to check the generated results according to the training cycle.
[0020] 5. The technical principle behind the "hardware" technical effect achieved by this invention is as follows: A layered sparse generation strategy is used to render only the truly effective defect areas, avoiding indiscriminate generation of all pixels and reducing GPU memory usage; lightweight feature distillation compresses the number of network parameters, eliminating redundant convolutional branches and reducing CPU and GPU computational overhead. Therefore, the quantifiable "hardware" technical effect of this invention is: the generation time for a single defect image is reduced from 1500ms to 100ms, GPU memory usage is reduced by 95%, and the number of concurrent defect generation is increased by 15 times under the same industrial control graphics card configuration. Attached Figure Description
[0021] Other features, objects, and advantages of the present invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a flowchart illustrating the overall process of generating defect images according to an embodiment of this application. Figure 2 This is a schematic diagram of a dual-discriminator generative adversarial network architecture according to an embodiment of this application; Figure 3 This is a flowchart of the RGBA channel sensing data enhancement process according to an embodiment of this application; Figure 4 This is a schematic diagram of the batch sample similarity perception module structure in an embodiment of this application; Figure 5 This is a flowchart of the real-time post-processing pipeline according to an embodiment of this application; Figure 6 This is a pseudocode flowchart of the training loop in an embodiment of this application. Detailed Implementation
[0022] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the protection scope of the present invention.
[0023] like Figures 1 to 6 As shown, this embodiment provides a defect image generation method based on dual discriminators and channel-aware processing. This method addresses the issues of lost transparency annotations and mode collapse in RGBA defect image generation through full-cycle channel-aware processing and multi-dimensional adversarial training. The execution flow of this method is described in detail below with reference to the accompanying drawings.
[0024] Step S1: Obtain the defect source image in RGBA format, and perform decoupling enhancement processing on the RGB and Alpha channels of the defect source image to obtain an expanded training set. Specifically, the decoupling enhancement processing aims to implement differential transformations based on the differences in the physical properties of the channels to prevent the masking semantics of the Alpha channel from being corrupted by inappropriate photometric transformations. For example... Figure 3 As shown, the Alpha channel records the mask information of the defect area; in this embodiment, the Alpha value of the defect area is 255, and the Alpha value of the background area is 0.
[0025] In this embodiment, the defect source image is first separated into RGB channels and Alpha channels; spatial geometric transformations are applied to both RGB and Alpha channels, while photometric attribute transformations are applied only to the RGB channels; the transformed RGB and Alpha channels are then recombined into RGBA format to obtain an expanded training set. Specifically, the spatial geometric transformations affect the spatial structure of the image, and the RGB and Alpha channels must be synchronized to ensure pixel-level alignment; however, the photometric attribute transformations only change the color appearance, and applying them to the Alpha channel would cause the mask values to deviate from binary semantics, therefore strict isolation is required.
[0026] Furthermore, the spatial geometric transformation includes performing a horizontal flip with a probability of 0.5, a vertical flip with a probability of 0.5, and random rotations uniformly distributed from 0 degrees, 90 degrees, 180 degrees, and 270 degrees; the photometric attribute transformation includes brightness adjustment and contrast adjustment, with the coefficients for both brightness and contrast adjustment uniformly sampled within the range of [0.9, 1.1]. For example, during enhancement, the system first independently samples the geometric transformation parameters and applies them simultaneously to both channels, then only samples and adjusts the photometric coefficients for the RGB channels, finally stitching them together to restore a four-channel image.
[0027] The system supports input in various image formats, including PNG, BMP, GIF, and TIFF. Each defect source image is enhanced to generate 20 enhanced images, thus significantly expanding the training sample size. Through the aforementioned decoupled enhancement strategy, the semantic integrity and spatial consistency of the defect region mask information recorded in the Alpha channel are maintained throughout the data flow while greatly expanding the sample diversity.
[0028] Step S2: Based on the expanded training set, the parameters of the generative adversarial network are updated by using a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator, and a multi-dimensional diversity constraint mechanism, and by applying gradient penalties to the first discriminator and the second discriminator respectively.
[0029] like Figure 2As shown, the dual-path complementary discrimination mechanism includes: the first discriminator adopts a standard discrimination target, outputs a first preset label for real samples, and outputs a second preset label for generated samples; the second discriminator adopts an inverse discrimination target, outputs a second preset label for real samples, and outputs a first preset label for generated samples; the generator of the generative adversarial network is updated based on the discrimination loss that makes the outputs of the first discriminator and the second discriminator for the generated samples close to the first preset label.
[0030] Specifically, the first preset label is 1, and the second preset label is 0. The first discriminator constrains the generator from a positive perspective of "distinguishing between true and false," while the second discriminator provides additional gradient signals from a "reverse discrimination" perspective. As an optional implementation, the generator employs a transposed convolutional network structure with layer-by-layer upsampling, specifically including: The fully connected layer maps 128-dimensional noise into a 37×33×512 feature map; The first transposed convolutional layer maps 512 channels to 256 channels with a stride of 2 and an output size of 74×66. The second transposed convolutional layer maps 256 channels to 128 channels with a stride of 2 and an output size of 148×132. The third transposed convolutional layer, with 128 channels to 64 channels, stride 1, maintains the size; The fourth transposed convolutional layer, with 64 channels reduced to 32 channels, stride 1, maintains the dimensions; The output convolutional layer maps 32-channel features to a 4-channel RGBA image and normalizes the output to [-1, 1] using the Tanh activation function.
[0031] Each transposed convolutional layer is followed by a BatchNorm2d normalization layer and a LeakyReLU (slope 0.2) activation function.
[0032] As an optional implementation, both the first discriminator and the second discriminator employ a four-layer convolutional network structure, specifically including: First convolutional layer, 4 to 64 channels, stride 2; The second convolutional layer has 64 to 128 channels and a stride of 2. The third convolutional layer has 128 to 256 channels and a stride of 2. Fourth convolutional layer, 256 to 512 channels, stride 2; Each convolutional layer is followed by a LeakyReLU activation function (slope 0.2), and BatchNorm is not used to be compatible with the gradient penalty requirements of WGAN-GP.
[0033] This complementary design allows the generator to receive bidirectional feedback simultaneously, effectively mitigating the gradient vanishing problem caused by an overly strong single discriminator and making the training process smoother. Both discriminators use BCEWithLogitsLoss (a joint loss of binary cross-entropy and sigmoid), where the first discriminator has a ground truth label of 1 and a generated sample label of 0, while the second discriminator has a ground truth label of 0 and a generated sample label of 1.
[0034] When the generator is updated, the first discriminator and the second discriminator both set the target value of the generated sample to 1.
[0035] Based on this, a multi-dimensional diversity constraint mechanism collaboratively suppresses pattern collapse from both batch-level and instance-level dimensions. For example... Figure 4 As shown, an intra-batch sample similarity vector is introduced into the feature flattening layer of the first and second discriminators to perceive batch-level diversity; a diversity penalty based on the generated images with different noise inputs is introduced into the total loss of the generator to constrain instance-level diversity.
[0036] Specifically, the batch-level sample similarity vector is introduced as follows: the flattened 46080-dimensional input features are mapped to a three-dimensional tensor through a learnable parameter matrix T. The dimensions of the three-dimensional tensor are (num_kernels, kernel_dim), where num_kernels is 50 and kernel_dim is 3. The parameter matrix T is randomly initialized and multiplied by a scaling factor of 0.02. The L1 distance between all sample pairs within the batch is calculated, and the exponential negative L1 distance is taken and summed to obtain the similarity vector (50-dimensional) of each sample relative to other samples within the batch. This similarity vector is concatenated to the original features and fed into the output layer, enabling the discriminator to explicitly perceive the degree of repetition of samples within the current batch. When the generator produces overly similar images, the discriminator's confidence decreases, thereby transmitting a gradient signal to the generator to increase diversity.
[0037] The instance-level diversity penalty is implemented as follows: two sets of different random noise are input into the generator to obtain two sets of generated images. The negative mean of the mean squared error distance between the two sets of generated images is calculated as the diversity loss, with a regularization coefficient of 0.5. That is, the diversity loss is:
[0038] in The regularization coefficient is . This represents the expectation operation. This represents the mean square error function. and These are images generated from two different noise levels. This loss term directly penalizes the generator for producing similar outputs despite varying noise levels. Furthermore, to ensure training stability, a WGAN-GP gradient penalty is applied to both discriminators. The gradient penalty term is:
[0039] in The penalty coefficient is... This represents the expectation operation. Indicates the interpolated sample gradient operator, This represents the discriminator function. Represents the L2 norm. The discriminator function is constrained to satisfy the Lipschitz continuity condition by being a random interpolation between real and generated samples. WGAN-GP, along with the aforementioned dual-discriminator complementary mechanism and multi-dimensional diversity constraint mechanism, works synergistically to construct a comprehensive anti-collapse defense from three levels: optimization constraints, architecture balancing, and loss guidance. During training, all batches are repeatedly traversed within each epoch, sequentially executing the steps of first discriminator update, second discriminator update, and generator update, for a total of 2000 training epochs. The values of the RGBA format generated by the generator are cropped to the [0,1] range and then converted to uint8 format for storage.
[0040] like Figure 6 As shown, all batches of the expanded training set are traversed within each epoch. For each batch, the real RGBA image is normalized to [-1, 1]; two sets of random noise z1 and z2 are sampled and generated through the generator to obtain generated samples; the first discriminator D1 and the second discriminator D2 are calculated and updated sequentially using the generated samples with separated gradients; the generated samples are then recalculated, and the generator G is updated by combining the discrimination loss and diversity loss of the two discriminators.
[0041] After all batches of the current epoch have been traversed, a sample image is generated, its values are cropped to [0, 1] and converted to uint8 data, and then the decoupling post-processing in step S3 is performed. The processing results are saved according to the epoch number. The number of training epochs is 2000.
[0042] Step S3: After each epoch, decouple the RGB and Alpha channels of the generated image in RGBA format output by the generative adversarial network to obtain the target defect image.
[0043] like Figure 5As shown, the decoupling post-processing includes: grayscale conversion of the RGB channels of the RGBA format image while preserving the alpha channel; multi-level edge-preserving denoising of the converted color channels and binarization of the alpha channel; and concatenation of the processed color channels and alpha channel for output. The grayscale conversion uses the ITU-R BT.601 weighted formula: Gray = 0.299×R + 0.587×G + 0.114×B In the formula, R, G, and B represent the three color channels of the generated image, and Gray represents the weighted grayscale value. The alpha channel does not participate in grayscale conversion. Gray is copied to the three color channels; when using OpenCV channel order, the three color channels are represented as BGR, which is concatenated with the alpha channel to form a BGRA image; when represented in RGB channel order, the concatenated result is an RGBA image. The alpha channel is binarized with a threshold of 127; the color channels are sequentially subjected to a 5×5 window median filter, a bilateral filter with parameters d=9, sigmaColor=75, and sigmaSpace=5, and convolved with a Laplacian sharpening kernel shown in matrix [0, -1, 0; -1, 5, -1; 0, -1, 0]. The above filtering and sharpening only apply to the color channels; the alpha channel retains its binarized result.
[0044] In this embodiment, the state dictionaries of the generator, two discriminators, and each optimizer are saved every 500 epochs. When resuming training, the checkpoint files in the checkpoint directory are scanned, sorted by epoch number, and the network parameters and optimizer states from the latest checkpoint are loaded. Training then continues from the corresponding epoch. The training hyperparameters are: learning rate 0.0001, batch size 16, Adam optimizer beta1=0.5, noise dimension 128, and image size 147×130 pixels.
[0045] Based on the same inventive concept, this application also provides a defect image generation system based on dual discriminators and channel sensing processing. The system includes: The data augmentation module is used to acquire defect source images in RGBA format, and to perform decoupled augmentation processing on the RGB and Alpha channels of the defect source images to obtain an expanded training set. The adversarial training module is used to update the parameters of the generative adversarial network based on the expanded training set, through a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and by applying gradient penalties to the first discriminator and the second discriminator respectively. The post-processing module is used to perform decoupled post-processing on the RGB and Alpha channels of the generated image in RGBA format output by the generative adversarial network after each training cycle, to obtain the target defect image. The specific execution logic of each module corresponds one-to-one with steps S1 to S3 in the aforementioned method embodiment, and will not be repeated here.
[0046] Based on the same inventive concept, this application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps in any of the above method embodiments. The storage medium can be a tangible, non-transitory storage medium, such as ROM / RAM, a disk, an optical disk, etc. By storing program instructions that implement the method of this application, a general-purpose computing device can execute the above-described defect image generation process.
[0047] Those skilled in the art will understand that, besides implementing the system and its various devices, modules, and units provided by this invention in the form of purely computer-readable program code, the same functions can be achieved entirely through logical programming of the method steps, making the system and its various devices, modules, and units of this invention function in the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, the system and its various devices, modules, and units provided by this invention can be considered as a hardware component, and the devices, modules, and units included therein for implementing various functions can also be considered as structures within the hardware component; alternatively, the devices, modules, and units for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.
[0048] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.
Claims
1. A method for generating defect images based on dual discriminators and channel-aware processing, characterized in that, include: Step S1: Obtain the defect source image in RGBA format, and perform decoupling enhancement processing on the RGB and Alpha channels of the defect source image to obtain an expanded training set; Step S2: Based on the expanded training set, the parameters of the generative adversarial network are updated by using a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and by applying gradient penalties to the first discriminator and the second discriminator respectively. Step S3: After each training cycle, decouple the RGB channels and Alpha channels of the RGBA format generated by the generative adversarial network to obtain the target defect image.
2. The method of claim 1, wherein the method is based on a dual discriminator and channel-aware processing. Step S1 includes: The defect source image is separated into RGB channels and Alpha channels; Spatial geometric transformation is applied to both RGB and Alpha channels, while photometric property transformation is applied only to the RGB channels; The transformed RGB channels and Alpha channels are recombined into RGBA format to obtain the expanded training set.
3. The method of claim 2, wherein the method further comprises: The spatial geometric transformation includes horizontal flipping with a preset probability, vertical flipping with a preset probability, and random rotation uniformly distributed among multiple preset rotation angles. The photometric attribute transformation includes brightness adjustment and contrast adjustment, and the coefficients of both brightness adjustment and contrast adjustment are uniformly sampled within a preset adjustment range.
4. The method of claim 1, wherein the method is based on a dual discriminator and channel-aware processing. The dual-path complementary discrimination mechanism includes: The first discriminator uses a standard discrimination target, outputs a first preset label for real samples, and outputs a second preset label for generated samples; The second discriminator uses reverse discrimination to identify the target, outputting the second preset label for the real sample and the first preset label for the generated sample; The generator of the generative adversarial network is updated based on the discrimination loss that makes the outputs of the first discriminator and the second discriminator on the generated samples close to the first preset label; Gradient penalties are applied to the first discriminator and the second discriminator respectively. The gradient penalty is determined based on the deviation between the gradient norm of the discriminator for the real sample and the interpolated sample of the generated sample and 1.
5. The method of claim 4, wherein the method further comprises: The multi-dimensional diversity constraint mechanism includes: Intra-batch sample similarity vectors are introduced into the feature flattening layers of the first and second discriminators to perceive batch-level diversity; A diversity penalty based on generating images with different noise inputs is introduced into the total loss of the generator to constrain instance-level diversity.
6. The method of claim 5, wherein the method further comprises: In the feature flattening layer of the first and second discriminators, an intra-batch sample similarity vector is introduced, including: The input features are mapped to a three-dimensional tensor using a learnable parameter matrix; Calculate the L1 distance between all sample pairs within a batch, take the exponential negative L1 distance, and sum them to obtain the sample similarity vector within the batch; A diversity penalty based on the generated images from different noise inputs is introduced into the total loss of the generator, including: Two sets of different random noises are input into the generator to obtain two sets of generated images. The negative mean of the mean squared error distance between the two sets of generated images is calculated as the diversity loss.
7. The method of claim 1, wherein the method is based on a dual discriminator and channel-aware processing. Step S3 includes: Perform grayscale conversion on the generated RGBA format image while preserving the alpha channel; Multi-level edge-preserving denoising is performed on the converted color channels, and binarization is performed on the Alpha channel; The denoised color channel is concatenated with the binarized Alpha channel to obtain the target defect image. The binarization process for the Alpha channel includes: binarizing the Alpha channel based on a preset threshold; The multi-level edge-preserving denoising process performed on the converted color channels includes: Median filtering and bilateral filtering with a preset window size are applied sequentially. The parameters of the bilateral filtering include neighborhood diameter, color gamut standard deviation, and spatial gamut standard deviation. Convolution is performed using a Laplacian sharpening kernel, which is a preset matrix.
8. The defect image generation method based on dual discriminator and channel sensing processing according to claim 1, characterized in that, include: Step S1: Use an image processing chip to acquire a defect source image in RGBA format, and perform decoupling enhancement processing on the RGB and Alpha channels of the defect source image to obtain an expanded training set; Step S2: Using the GPU based on the expanded training set, through a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and applying gradient penalties to the first discriminator and the second discriminator respectively, the parameters of the generative adversarial network are updated. Step S3: After each training cycle is completed, the industrial control computer performs decoupling post-processing on the RGB and Alpha channels of the RGBA format image generated by the generative adversarial network to obtain the target defect image.
9. A defect image generation system based on dual discriminators and channel sensing processing, characterized in that, include: The data augmentation module is used to acquire defect source images in RGBA format, and perform decoupling augmentation processing on the RGB channels and Alpha channels of the defect source images to obtain an expanded training set; The adversarial training module is used to update the parameters of the generative adversarial network based on the expanded training set, through a dual-path complementary discrimination mechanism including a first discriminator and a second discriminator and a multi-dimensional diversity constraint mechanism, and to apply gradient penalties to the first discriminator and the second discriminator respectively. The post-processing module is used to perform decoupled post-processing on the RGB and Alpha channels of the RGBA format generated image output by the generative adversarial network after each training cycle to obtain the target defect image.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the program implements the defect image generation method based on dual discriminator and channel sensing processing as described in any one of claims 1 to 8.
