Substation fault image generation method and system based on improved DCGAN
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- STATE GRID JIANGSU ELECTRIC POWER CO LTD CHANGZHOU BRANCH
- Filing Date
- 2026-07-10
- Publication Date
- 2026-08-07
AI Technical Summary
[0007]本发明的目的在于提供一种基于改进DCGAN的变电故障图像生成方法及系统,在传统DCGAN的基础上,在生成器部分引入渐进式故障课程生成策略及频域-梯度引导注意力机制,解决了生成的图像结构保真度不足、高频细节模糊、训练过程中容易出现训练不稳定、生成样本多样性差、分辨率适应差等问题
Smart Images

Figure CN122530733A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of image processing technology. It relates to a method and system for generating substation fault images based on an improved DCGAN. Background Technology
[0002] With the widespread application of deep learning technology in image processing, Generative Adversarial Networks (GANs) are widely used to automatically learn data distributions and generate high-quality images. Deep Convolutional Generative Adversarial Networks (DCGANs), a classic variant of GANs, improves model stability and image quality to some extent through fully convolutional network structure optimization, using deconvolution with stride and batch normalization. However, in substation fault images, simply using spatial convolution often fails to capture subtle multi-scale texture features, and the diversity and structural fidelity of generated samples still need improvement. Therefore, using this method in substation fault image gain suffers from limited feature extraction capabilities and inconsistent quality of generated samples.
[0003] The journal paper "An Improved Method for Generating Tire Defect Images Based on DCGAN" addresses the shortcomings of DCGAN in two aspects: First, it embeds "basic blocks" (i.e., a composite structure formed by fusing residual blocks of the residual network with the CBAM attention mechanism) into the network structure, combining the skip connections of the residual network with the CBAM attention mechanism, and enhancing feature extraction capabilities by allocating weights through channel and spatial attention; Second, at the loss function level, it replaces JS divergence with Wasserstein distance with a gradient penalty term to alleviate the gradient vanishing problem and improve training stability.
[0004] However, existing technologies still have limitations in substation fault image generation scenarios: on the one hand, their attention mechanisms only target the spatial and channel dimensions, lacking explicit modeling of frequency domain features, making it difficult to capture the multi-scale frequency features of substation equipment defects (such as the high-frequency components of discharge traces); on the other hand, the loss function does not directly constrain the structural diversity of generated samples, which may lead to pattern collapse and fail to cover the complex distribution of different types of faults. Furthermore, existing methods use fixed network structures for training and do not introduce progressive generation strategies, resulting in detail blurring when processing high-resolution substation fault images.
[0005] Existing generative models have limited ability to represent the global structure of substation fault images when performing substation fault image gain tasks, making it difficult to maintain the geometric shape and overall contour of the fault image. Overemphasis on high-frequency components during training leads to insufficient learning of low-frequency structural features, resulting in structural distortion in the generated results. Furthermore, existing generative models lack the ability to model high-frequency texture information, failing to effectively recover detailed features in the image and causing blurry artifacts in the generated results.
[0006] Traditional GANs are prone to mode collapse during high-resolution training, leading to unstable convergence and exacerbating the unpredictability of the generated results. Mode collapse also results in a narrow distribution of output samples, with significantly lower sample diversity than the real distribution, making it difficult to cover the various manifestations of substation fault images. Furthermore, existing solutions lack the ability to generate images layer by layer, making it difficult to work effectively at multiple resolution scales. The lack of a progressive training strategy makes it difficult to generate detailed defect images at high resolutions. Summary of the Invention
[0007] The purpose of this invention is to provide a substation fault image generation method and system based on an improved DCGAN. On the basis of traditional DCGAN, a progressive fault course generation strategy and a frequency domain-gradient guided attention mechanism are introduced into the generator part, which solves the problems of insufficient structural fidelity of the generated images, blurring of high-frequency details, easy training instability during training, poor diversity of generated samples, and poor resolution adaptation.
[0008] The technical solution to achieve the purpose of this invention is as follows: A method for generating substation fault images based on an improved DCGAN includes the following steps: Obtain real images of substation faults; An improved DCGAN model is constructed, using DCGAN as the basic framework. A progressive fault course generation method is employed in the generator, dividing the generation process into multiple stages from low resolution to high resolution. In the first stage, the generator generates a basic image at low resolution. A gradient-guided attention module is introduced in this stage to enhance the fault contour. In the second stage, a frequency-domain self-attention module is introduced to refine features under frequency-domain guidance. In the third stage, the features obtained from the first and second stages are fused to obtain the generated substation fault image. During training, real and generated substation fault images are input into the discriminator, which outputs a true / false discrimination score. Based on the calculated loss, the network parameters of the generator and discriminator are updated through backpropagation. The acquired real substation fault image data is input into the trained generator, which outputs a substation fault gain image.
[0009] In the preferred technical solution, the processing procedure of the gradient-guided attention module includes: Input feature map It is divided into two parallel branches: one is retained as the backbone feature, and the other is input to the attention mask generation branch; in the attention mask generation branch, the input feature map is first processed. Perform average pooling along the channel dimension to compress its space into a single-channel grayscale feature map. Then, Spatial convolution is performed by inputting the Sobel operators in the horizontal and vertical directions respectively, and the corresponding horizontal gradient matrix is extracted. With the vertical gradient matrix , in turn and Perform a square operation to obtain and Then, the two are added element by element and the square root operation is performed to calculate the comprehensive gradient magnitude map M; The gradient magnitude map M is input into the Sigmoid activation function for normalization, nonlinearly mapping it to the probability interval [0,1] to generate a single-channel attention weight map W. Channel dimension expansion is then performed on the weight map W to generate a multi-channel attention mask. Finally, the retained backbone is input into the feature map. The enhanced feature map is then multiplied element-wise with the multi-channel attention mask. And pass it on to the subsequent generation stage.
[0010] In the preferred technical solution, the processing procedure of the frequency domain self-attention module includes: Input feature map It is divided into two parallel branches: one is directly retained as a residual connection to the end of the network, and the other is input to the main path of frequency domain feature processing; In the main path of frequency domain feature processing, the input feature map is first processed... Perform a Fast Fourier Transform to obtain the frequency domain complex feature tensor. The complex features of this frequency domain Decoupling and separation as real features Features of the imaginary part Real features Features of the imaginary part The inputs are fed in parallel into two independent 1×1 convolutional layers for cross-channel frequency feature interaction. After the convolution operation, the two feature paths are non-linearly mapped using the LeakyReLU activation function to obtain the processed real part features. With processed imaginary part features The updated real features Features of the imaginary part Recombining them according to the rules of complex number operations, we obtain the processed frequency domain complex feature tensor. ; For frequency domain complex feature tensors Performing a fast inverse Fourier transform yields the processed spatial feature map. Spatial feature map Compared with the initially preserved input feature map Perform element-wise residual summation to output the enhanced feature map. And pass it on to the subsequent generation stage.
[0011] In the preferred technical solution, during the progressive fault course generation process, a course scheduler monitors the current training progress and resolution stage of the model and dynamically adjusts the structural constraint weights. In the low-resolution stage, the course scheduler assigns... With lower weight values, the course scheduler dynamically amplifies the values through step or linear increments at medium to high resolutions. The weight value.
[0012] In the preferred technical solution, the loss calculation method includes: The real image discrimination result d is obtained. real and the generated image discrimination result d fake Calculate the basic adversarial loss ; Initialize structural similarity loss Enter the loop and iterate through different scaling scales. For each scaling scale, scale the real substation fault image and the generated substation fault image to obtain the scaled image. Then, use the scaled image to calculate the SSIM loss at the current scale and add the calculated result to the structural similarity loss. After all scaling scales have been traversed, the batch size and latent vector z are obtained. The latent vector z is then randomly shuffled to obtain... The data is then input into a generator to produce new images. Features are extracted from the real substation fault image, the generated substation fault image, and the scrambled generated substation fault image. Their covariance matrices are calculated, and the latent spatial diversity loss is calculated using the covariance matrices. ; Finally, the weighted sum of the basic adversarial loss, structural similarity loss, and potential spatial diversity loss yields the total loss.
[0013] in, This represents the diversity weighting coefficient. The structural constraint weights are dynamically controlled by the course scheduler. t This is the gradual generation stage.
[0014] In the preferred technical solution, the basic adversarial loss is calculated. include: Discriminator D for real substation fault images The output scalar value is Discriminator D generates substation fault images. The output scalar value is ; The basic adversarial losses are:
[0015] in, Indicates the current training batch; Indicates the discriminator on the first The discriminant scalar value output by the feature of a real substation fault image; Indicates the discriminator on the first The discrimination scalar value of the generated substation fault image feature output.
[0016] In the preferred technical solution, the calculation of structural similarity loss includes: The SSIM index is defined on a single scale as follows:
[0017] in, and Images of substation faults Local mean; and For variance; For covariance; and It is a constant; Use different scaling scales Images of real substation faults and generating substation fault images Scaling:
[0018] in, This indicates that the input image is downsampled by s; and These represent the real image and the generated image after being scaled by a scale s, respectively. By summing the losses at different scales, we obtain the multi-scale structural similarity loss:
[0019] in, It is a structural similarity index. This indicates the current training batch.
[0020] In the preferred technical solution, calculating the potential spatial diversity loss includes: Randomly permuting the latent vectors yields latent noise vectors with their order randomly shuffled. And generate shuffled samples through generator G. Extracting real substation fault images from discriminator D Generate substation fault images shuffle the samples The characteristics are denoted as follows: ; The resulting feature matrices are denoted as follows: ; The true sample covariance matrix Cov(R) is:
[0021] in, Let be the mean vector in the feature space. Indicates the current training batch; Generate the substation fault image covariance matrix Cov(G) and the shuffled sample covariance matrix Cov(H):
[0022] in, and These represent the mean vectors of the feature matrices H and G, calculated along the sample dimension, respectively. Let the covariance matrix Cov(R) of the real substation fault image, the covariance matrix Cov(G) of the generated substation fault image, and the covariance matrix Cov(H) of the shuffled samples be respectively denoted as . , , ; Then potential spatial diversity loss for:
[0023] in, This represents the square of the Frobenius norm.
[0024] This invention also discloses a substation fault image generation system based on an improved DCGAN, used to implement the aforementioned substation fault image generation method based on an improved DCGAN, comprising: The image acquisition module acquires real substation fault images; An improved DCGAN model training module was constructed, using DCGAN as the basic framework. The generator employs a progressive fault course generation method, dividing the generation process into multiple stages from low to high resolution. In the first stage, the generator generates a basic image at low resolution, introducing a gradient-guided attention module to enhance fault contours. In the second stage, a frequency-domain self-attention module is introduced to refine features under frequency-domain guidance. In the third stage, the features obtained from the first and second stages are fused to obtain the generated substation fault image. The discriminator uses the DCGAN discriminator. During training, real and generated substation fault images are input into the discriminator, which outputs a true / false discrimination score. Based on the calculated loss, the network parameters of the generator and discriminator are updated through backpropagation. The image generation module inputs the acquired real substation fault image data into the trained generator and outputs a substation fault gain image.
[0025] The present invention also discloses a computer storage medium storing a computer program thereon, wherein when the computer executes the computer program, it implements the substation fault image generation method based on the improved DCGAN described above.
[0026] Compared with the prior art, the significant advantages of this invention are: (1) Based on the traditional DCGAN, this invention significantly improves the gain and training stability of substation fault images by designing a structure-aware adversarial diversity loss SAD_Loss, introducing progressive fault course generation, and a frequency domain + gradient-guided attention mechanism. Unlike schemes that only use JS divergence or simple WGAN-GP adversarial loss, this invention not only maintains the smooth adversarial gradient in the form of Wasserstein, but also adds SSIM structure fidelity constraints and diversity excitation based on the discriminator intermediate feature covariance at multiple scales, so that the generated images can take into account both the overall contour and local details at three resolutions: 32×32, 64×64, and 128×128. In the experiment, the FID index obtained by training with standard DCGAN averaged around 180, while it could be reduced to around 110 after introducing SAD_Loss. At the same time, the multi-scale SSIM improved from the original 0.62 to 0.74, and the overall structure and texture restoration was greatly enhanced.
[0027] (2) This invention introduces progressive fault course generation, which first converges quickly to the rough shape of arc discharge in the low-resolution stage, then guides attention to the crack edge and high response area with gradient, and finally refines the small particles on the metal surface in the high-resolution stage, making the training more stable. The Epoch convergence speed is about 25% faster than that of non-progressive training. Attached Figure Description
[0028] Figure 1 This is a flowchart of the substation fault image generation method based on the improved DCGAN in this embodiment; Figure 2 This is a schematic diagram of the improved DCGAN network structure in this embodiment; Figure 3 This is a flowchart illustrating the progressive fault course generation process in this embodiment. Figure 4 This is a structural diagram of the gradient-guided attention module in this embodiment; Figure 5 This is a structural diagram of the frequency domain self-attention module in this embodiment; Figure 6 This is a flowchart of the structure-aware adversarial diversity loss SAD_Loss algorithm in this embodiment; Figure 7 This is a graph showing the results of the comparative ablation experiment in this embodiment. Detailed Implementation
[0029] The principle of this invention is to improve upon the DCGAN baseline model. The improvements primarily involve introducing a progressive fault course generation strategy and a frequency-domain gradient-guided attention mechanism into the generator. This prioritizes high-gradient regions such as fault edges and contours, accurately capturing high-frequency detail features like discharge traces and metal cracks to output high-fidelity substation fault images. The invention also incorporates a structure-aware adversarial diversity loss, integrating basic adversarial loss to ensure the generated distribution closely approximates the real distribution, multi-scale structural similarity loss to constrain the structural fidelity of the generated images, and latent spatial diversity loss to prevent mode collapse and improve sample coverage. This addresses issues such as insufficient structural fidelity in the generated images, blurred high-frequency details, training instability, poor sample diversity, and poor resolution adaptation.
[0030] Example: like Figure 1 As shown, a method for generating substation fault images based on an improved DCGAN includes the following steps: Obtain real images of substation faults; An improved DCGAN model is constructed, using DCGAN as the basic framework. A progressive fault course generation method is employed in the generator, dividing the generation process into multiple stages from low resolution to high resolution. In the first stage, the generator generates a basic image at low resolution. A gradient-guided attention module is introduced in this stage to enhance the fault contour. In the second stage, a frequency-domain self-attention module is introduced to refine features under frequency-domain guidance. In the third stage, the features obtained from the first and second stages are fused to obtain the generated substation fault image. During training, real and generated substation fault images are input into the discriminator, which outputs a true / false discrimination score. Based on the calculated loss, the network parameters of the generator and discriminator are updated through backpropagation. The acquired real substation fault image data is input into the trained generator, which outputs a substation fault gain image.
[0031] In a preferred embodiment, the processing procedure of the gradient-guided attention module includes: Input feature map It is divided into two parallel branches: one is retained as the backbone feature, and the other is input to the attention mask generation branch; in the attention mask generation branch, the input feature map is first processed. Perform average pooling along the channel dimension to compress its space into a single-channel grayscale feature map. Then, Spatial convolution is performed by inputting the Sobel operators in the horizontal and vertical directions respectively, and the corresponding horizontal gradient matrix is extracted. With the vertical gradient matrix , in turn and Perform a square operation to obtain and Then, the two are added element by element and the square root operation is performed to calculate the comprehensive gradient magnitude map M; The gradient magnitude map M is input into the Sigmoid activation function for normalization, nonlinearly mapping it to the probability interval [0,1] to generate a single-channel attention weight map W. Channel dimension expansion is then performed on the weight map W to generate a multi-channel attention mask. Finally, the retained backbone is input into the feature map. The enhanced feature map is then multiplied element-wise with the multi-channel attention mask. And pass it on to the subsequent generation stage.
[0032] In a preferred embodiment, the processing procedure of the frequency domain self-attention module includes: Input feature map It is divided into two parallel branches: one is directly retained as a residual connection to the end of the network, and the other is input to the main path of frequency domain feature processing; In the main path of frequency domain feature processing, the input feature map is first processed... Perform a Fast Fourier Transform to obtain the frequency domain complex feature tensor. The complex features of this frequency domain Decoupling and separation as real features Features of the imaginary part Real features Features of the imaginary part The inputs are fed in parallel into two independent 1×1 convolutional layers for cross-channel frequency feature interaction. After the convolution operation, the two feature paths are non-linearly mapped using the LeakyReLU activation function to obtain the processed real part features. With processed imaginary part features The updated real features Features of the imaginary part Recombining them according to the rules of complex number operations, we obtain the processed frequency domain complex feature tensor. ; For frequency domain complex feature tensors Performing a fast inverse Fourier transform yields the processed spatial feature map. Spatial feature map Compared with the initially preserved input feature map Perform element-wise residual summation to output the enhanced feature map. And pass it on to the subsequent generation stage.
[0033] In a preferred embodiment, during the progressive fault course generation process, a course scheduler monitors the model's current training progress and resolution stage, and dynamically adjusts the structural constraint weights. In the low-resolution stage, the course scheduler assigns... With lower weight values, the course scheduler dynamically amplifies the values through step or linear increments at medium to high resolutions. The weight value.
[0034] In a preferred embodiment, the method for calculating the loss includes: The real image discrimination result d is obtained. real and the generated image discrimination result d fake Calculate the basic adversarial loss ; Initialize structural similarity loss Enter the loop and iterate through different scaling scales. For each scaling scale, scale the real substation fault image and the generated substation fault image to obtain the scaled image. Then, use the scaled image to calculate the SSIM loss at the current scale and add the calculated result to the structural similarity loss. After all scaling scales have been traversed, the batch size and latent vector z are obtained. The latent vector z is then randomly shuffled to obtain... The data is then input into a generator to produce new images. Features are extracted from the real substation fault image, the generated substation fault image, and the scrambled generated substation fault image. Their covariance matrices are calculated, and the latent spatial diversity loss is calculated using the covariance matrices. ; Finally, the weighted sum of the basic adversarial loss, structural similarity loss, and potential spatial diversity loss yields the total loss.
[0035] in, This represents the diversity weighting coefficient. The structural constraint weights are dynamically controlled by the course scheduler. t This is the gradual generation stage.
[0036] In a preferred embodiment, the basic adversarial loss is calculated. include: Discriminator D for real substation fault images The output scalar value is Discriminator D generates substation fault images. The output scalar value is ; The basic adversarial losses are:
[0037] in, Indicates the current training batch; Indicates the discriminator on the first The discriminant scalar value output by the feature of a real substation fault image; Indicates the discriminator on the first The discrimination scalar value of the generated substation fault image feature output.
[0038] In a preferred embodiment, calculating the structural similarity loss includes: The SSIM index is defined on a single scale as follows:
[0039] in, and Images of substation faults Local mean; and For variance; For covariance; and It is a constant; Use different scaling scales Images of real substation faults and generating substation fault images Scaling:
[0040] in, This indicates that the input image is downsampled by s; and These represent the real image and the generated image after being scaled by a scale s, respectively. By summing the losses at different scales, we obtain the multi-scale structural similarity loss:
[0041] in, It is a structural similarity index. This indicates the current training batch.
[0042] In a preferred embodiment, calculating the potential spatial diversity loss includes: Randomly permuting the latent vectors yields latent noise vectors with their order randomly shuffled. And generate shuffled samples through generator G. Extracting real substation fault images from discriminator D Generate substation fault images shuffle the samples The characteristics are denoted as follows: ; The resulting feature matrices are denoted as follows: ; The true sample covariance matrix Cov(R) is:
[0043] in, Let be the mean vector in the feature space. Indicates the current training batch; Generate the substation fault image covariance matrix Cov(G) and the shuffled sample covariance matrix Cov(H):
[0044] in, and These represent the mean vectors of the feature matrices H and G, calculated along the sample dimension, respectively. Let the covariance matrix Cov(R) of the real substation fault image, the covariance matrix Cov(G) of the generated substation fault image, and the covariance matrix Cov(H) of the shuffled samples be respectively denoted as . , , ; Then potential spatial diversity loss for:
[0045] in, This represents the square of the Frobenius norm.
[0046] Another embodiment provides a substation fault image generation system based on an improved DCGAN, used to implement the aforementioned substation fault image generation method based on an improved DCGAN, comprising: The image acquisition module acquires real substation fault images; An improved DCGAN model training module is constructed, using DCGAN as the basic framework. The generator employs a progressive fault course generation method, dividing the generation process into multiple stages from low to high resolution. In the first stage, the generator generates a basic image at low resolution, introducing a gradient-guided attention module to enhance fault contours. In the second stage, a frequency-domain self-attention module is introduced to refine features under frequency-domain guidance. In the third stage, an additional transposed convolutional layer fuses the features learned in the first two stages to obtain the generated substation fault image. The discriminator uses the DCGAN discriminator. During training, real and generated substation fault images are input into the discriminator, which outputs a true / false discrimination score. Based on the calculated loss, the network parameters of the generator and discriminator are updated through backpropagation. The image generation module inputs the acquired real substation fault image data into the trained generator and outputs a substation fault gain image.
[0047] The following example illustrates the workflow of a substation fault image generation system based on an improved DCGAN, including the following steps: Step S1: Initialization and data input.
[0048] Obtain a real substation fault image dataset and generate a random noise vector as the initial input to the generator network.
[0049] Step S2: First-stage progressive generation (low-resolution structure and contour learning).
[0050] Random noise is input into the generator to first generate a base image at a resolution of 32×32. At this stage, a gradient-guided attention mechanism is introduced. The horizontal and vertical gradient magnitudes of the image features are calculated using the Sobel operator and normalized. These are then extended to all color channels as attention weights and multiplied with the original image in a weighted manner. This assigns higher weights to edges and texture regions with the strongest gradient responses, prioritizing the learning of the global contour and geometry of the fault.
[0051] Step S3: Second stage progressive generation (medium resolution, high frequency and detail enhancement).
[0052] After the model has stabilized and grasped the basic form of the low-resolution model, the feature map is upsampled to a 64×64 stage. At this stage, a frequency domain self-attention mechanism is introduced. The input features are transformed into the frequency domain by fast Fourier transform, cross-channel frequency feature fusion is performed, and then restored by inverse fast Fourier transform and residual connection is performed. This allows for the accurate capture of key high-frequency features such as discharge traces and metal cracks at the spectral level, refining the details of defect texture.
[0053] Step S4: Third-stage progressive generation (high-resolution detail blending).
[0054] After outputting a 64×64 frequency domain enhanced feature map in the second stage, the third stage upsamples the feature map to 128×128 using an additional transposed convolutional layer. The transposed convolutional layer is selected based on the upsampling factor between two adjacent resolution stages; when upsampling from 64×64 to 128×128, a transposed convolutional layer with an upsampling factor of 2 is used. This transposed convolutional layer has a kernel size of 4×4, a stride of 2, and padding of 1, thus expanding the spatial resolution of the output feature map to twice that of the input feature map. Following the transposed convolutional layer are a batch normalization layer and a ReLU activation function to stabilize the feature distribution after upsampling.
[0055] In the feature fusion process, the low-resolution structural features enhanced by the gradient-guided attention module in the first stage are used as fault contour features, and the medium-resolution features enhanced by the frequency domain self-attention module in the second stage are used as frequency domain detail features. Since the two types of features have different spatial resolutions, the fault contour features and frequency domain detail features are first upsampled to 128×128 using a transposed convolutional layer, and then a 1×1 convolution is used to ensure that the number of channels for both types of features is consistent. Subsequently, the two types of features with consistent channel number and spatial resolution are concatenated along the channel dimension, and then a 1×1 convolution is used to perform channel compression and weight allocation on the concatenated features to obtain the fused feature map. Finally, the fused feature map is input into a 3×3 convolutional layer for local spatial integration, and then passed through an output convolutional layer and a Tanh activation function to generate a 128×128 substation fault image.
[0056] Through the third stage of processing described above, the structural information such as fault edges and contours learned in the first stage is fused with the high-frequency detail information such as discharge traces and metal cracks learned in the second stage at the same spatial scale, thereby obtaining a substation fault image with complete structure and clear details.
[0057] Step S5: Calculate the structure-aware adversarial diversity loss (SAD_Loss) and update the model.
[0058] During training, real images and images generated at each stage are input into the discriminator, and SAD_Loss is calculated to optimize the network. The calculation of this loss consists of three parts: Basic adversarial losses ( adv ): The difference between the generated distribution and the true distribution is calculated using the WGAN method.
[0059] Multiscale structural similarity loss ( ssim At three scale factors of 1.0, 0.5 and 0.25, the real image and the generated image are scaled and the local mean and variance are calculated respectively. The multi-scale SSIM loss is accumulated to constrain the structure fidelity.
[0060] Potential spatial diversity loss ( div ): Randomly shuffle the latent vectors to generate new images, extract features from the real image, the generated image, and the shuffled generated image, and calculate the sample covariance matrix to encourage diversity in the latent space and prevent mode collapse.
[0061] Based on the calculated total SAD_Loss loss, the network parameters of the generator and discriminator are updated through backpropagation.
[0062] Step S6: Output the final gain image.
[0063] Steps S2 through S5 are repeated until the model training is stable and converges. During the testing or inference phase, new random noise is input into the trained generator to directly output a high-quality, high-resolution substation fault gain image with multi-scale structure and high-frequency details.
[0064] Specifically, such as Figure 2As shown, this invention proposes Gradient-Freq DCGAN (GF-DCGAN), a model based on DCGAN as its backbone, retaining its core architecture of "generator-discriminator" adversarial training, while making multi-dimensional customized improvements for substation fault characteristics. First, the generator takes latent spatial random noise as input and sequentially completes the upsampling process at three resolution stages: 32×32, 64×64, and 128×128. In the low-resolution 32×32 stage, a gradient-guided attention module is embedded. The Sobel operator is used to calculate the feature gradient magnitude to generate an attention mask, prioritizing the enhancement of high-gradient regions such as fault edges and contours, allowing the model to quickly learn the global geometric structure of the substation fault. In the medium-resolution 64×64 stage, a frequency-domain self-attention module is embedded. Fast Fourier Transform (FFT) is used to convert features to the frequency domain, accurately capturing high-frequency details such as discharge traces and metal cracks. These details are then restored using inverse Fourier Transform and fused through residual connections to compensate for the insufficient modeling of high-frequency information by spatial convolution. Finally, in the high-resolution 128×128 stage, upsampling is achieved through transposed convolution. The structural and detail features from the first two stages are fused to output a high-fidelity substation fault image. The generator uses the DCGAN standard activation rule throughout, with BN+ReLU used in the intermediate layers to stabilize feature propagation. The output layer uses Tanh to normalize pixel values to [-1,1] to ensure numerical reasonableness. Meanwhile, the discriminator adopts the convolutional discriminant architecture of DCGAN, taking real substation fault images and generated fake samples as inputs. It extracts deep features through convolutional layers and outputs real and fake discrimination scores. At the same time, it extracts intermediate layer features for calculating potential spatial diversity loss, providing accurate gradient feedback for the generator.
[0065] To further constrain the generation process, the model replaces the single adversarial loss of the original DCGAN with structure-aware adversarial diversity loss (SAD-Loss). It integrates basic adversarial loss to ensure that the generated distribution is close to the real distribution, multi-scale structural similarity loss to constrain the structural fidelity of the generated images, and latent spatial diversity loss to prevent mode collapse and improve sample coverage. The structural constraint weights are dynamically adjusted through a curriculum scheduler to achieve a synergistic improvement in training stability and generation quality.
[0066] In the substation fault image gain task, fault samples include both macroscopic features such as arc discharge, flashes, flashovers, and local crack contours, as well as microscopic features such as oxide spots on metal surfaces. Therefore, if the generator is directly trained at high resolution, the network needs to learn both global structures and local details simultaneously, which can easily lead to training instability, gradient explosion, or mode collapse, resulting in the generation of images that lose key features or produce severe artifacts. Progressive training is introduced to reduce training difficulty through staged optimization, and the regularization effect of the attention mechanism is used to suppress meaningless noise and false defects.
[0067] like Figure 3 As shown, the substation fault image gain task employs a progressive fault curriculum generation approach. By dividing the generation process into multiple stages from low resolution to high resolution, stable generation of substation fault images is achieved. This method first allows the network to learn the overall layout and large-scale structure of the substation fault image on a coarse 32×32 version. In this stage, a gradient-guided attention module is introduced, utilizing the Sobel operator to capture the edges and texture regions with the strongest gradient responses, building a global contour skeleton of the fault for the network and clarifying the approximate location and shape of the defect. Once the model has stably mastered the basic shape at low resolution, it enters the 64×64 stage. A frequency-domain self-attention module captures high-frequency features such as discharge traces and metal fractures at the spectral level. Finally, in the 128×128 stage, an additional transposed convolutional layer further amplifies and refines the image, organically fusing the global structure and high-frequency details learned in the previous two stages to obtain a high-quality substation fault image. By adopting a progressive fault course generation method, we not only avoid the training instability and mode collapse that are prone to occur when directly training large-scale networks at the beginning, but also enable the generator to gradually accumulate an understanding of all key features at different resolutions. As a result, we can obtain smoother, more reliable and more detailed results in the substation fault image gain task, which is extremely sensitive to high-frequency texture and multi-scale structure.
[0068] In substation fault image gain tasks, it is necessary to pay attention to both the local texture details and the global structure of the image. Especially when processing high-frequency and complex texture features such as arc flashovers, insulation damage cracks, and ablation areas, images generated by traditional DCGANs often suffer from structural distortion and blurred details. Traditional DCGANs use a fully convolutional structure, relying solely on the local receptive field of the convolutional kernel to extract texture layer by layer. While this approach is less likely to cause structural distortion and blurred details when dealing with low-frequency image data such as natural images and faces, it is prone to problems such as blurred edges, missing details, or high-frequency artifacts in scenarios like substation fault images, where multi-scale abrupt edges and detailed changes are the main information sources.
[0069] To compensate for this deficiency, this invention introduces two key attention mechanism modules: FreqSelfAttention and GradGuidedAttention. These two modules are inserted into different stages of the generator to specifically enhance fault contours and edge structures at low resolution.
[0070] like Figure 4 The diagram shown is the algorithm flowchart for the gradient-guided attention module. The input to this module is a feature map tensor. Where C represents the number of channels and 32×32 represents the spatial resolution. The input feature map is divided into two parallel branches: one is retained as the backbone feature, and the other is input to the attention mask generation branch. In the attention generation branch, the input feature map is first processed... Perform average pooling along the channel dimension to compress its space into a single-channel grayscale feature map. This effectively aggregates the brightness information of the global channels. Then, Spatial convolution is performed by inputting the Sobel operators in the horizontal and vertical directions respectively, and the corresponding horizontal gradient matrix is extracted. With the vertical gradient matrix To integrate bidirectional edge responses, sequentially... and Perform a square operation to obtain and The two are then element-wise added together and the square root is taken to calculate the comprehensive gradient magnitude map M. Next, this gradient magnitude map M is input into a Sigmoid activation function for normalization, non-linearly mapping it to the probability interval [0,1] to generate a single-channel attention weight map W. To match the dimensionality of the original input features, a channel dimension expansion operation is performed on the weight map W, i.e., copying and broadcasting along the channel dimension to generate a multi-channel attention mask. Finally, the retained backbone input feature map... The feature map is then multiplied element-wise with the multi-channel attention mask. This weighting mechanism assigns greater network weights to high-gradient response regions such as defect edges in substation fault images, specifically enhancing spatial detail representation at low resolution, and ultimately outputting an enhanced feature map. And pass it on to the subsequent generation stage.
[0071] like Figure 5 The diagram shown is the algorithm flowchart for the frequency domain self-attention module. The input to the module is the feature map tensor. Where C represents the number of channels, and 64×64 represents the spatial resolution. This is the input feature map. It is divided into two parallel branches: one is retained directly to the end of the network as a residual connection, and the other is input to the frequency domain feature processing backbone. In the frequency domain processing backbone, the input feature map is first processed... Perform a Fast Fourier Transform (FFT) to transform it from the spatial domain to the frequency domain, obtaining the frequency domain complex feature tensor. To independently extract and enhance key information from different frequency components, this frequency domain complex feature... Decoupling and separation as real features Features of the imaginary part Subsequently, real features Features of the imaginary part The inputs are fed in parallel into two independent 1×1 convolutional layers for cross-channel frequency feature interaction. After convolution, the two feature paths are non-linearly mapped using the LeakyReLU activation function. This process adjusts the network weights of the high- and low-frequency components while strictly maintaining the number of channels C and the spatial resolution, thus obtaining the processed real part features. With processed imaginary part features After feature processing is complete, the updated real part features will be... Features of the imaginary part Recombining them according to the rules of complex number operations, the processed frequency domain complex feature tensor is constructed. Its recombination calculation logic can be expressed as: , i The imaginary unit is used. Next, the characteristics of this recombined complex number are discussed. Performing an inverse fast Fourier transform (iFFT) remaps its feature representation from the frequency domain back to the spatial domain, resulting in a processed spatial feature map. Finally, the spatial feature map after frequency domain fusion processing is... Compared with the initially preserved input feature map Element-wise residual addition is performed. This residual connection architecture effectively alleviates the gradient vanishing problem in deep networks, enabling the model to explicitly capture and refine high-frequency key structural details such as discharge paths and microcracks in substation fault images through frequency domain processing branches while preserving the basic global structural information of the image. The module ultimately outputs an enhanced feature map. Its calculation formula is The output tensor dimension is preserved. And it continues to be passed on to the subsequent generative network stage.
[0072] In a preferred implementation, to ensure a smooth transition between the three progressive generation stages, this invention synchronously designs a Curriculum Scheduler within the staged upsampling network architecture. This scheduler monitors the model's current training progress and resolution stage, and dynamically adjusts the structural constraint weights (i.e., the weights in the structure-aware adversarial diversity loss) accordingly. Parameters). Specifically: In the initial low-resolution phase of 32×32, the course scheduler assigns... Lower weights give the generator greater freedom to explore the latent space and learn the global coarse distribution; as the network progresses to medium-to-high resolutions of 64×64 and 128×128, the course scheduler dynamically scales up in a step or linear manner. The weight values are dynamically adjusted. This dynamic adjustment mechanism forces the model to strictly maintain the consistency of multi-scale structure when refining edges and high-frequency textures, thereby effectively avoiding gradient explosion or mode collapse caused by introducing overly strong constraints in the early stages, and achieving a synergistic improvement in resolution and structural fidelity.
[0073] like Figure 6 The diagram shows the flowchart of the structure-aware adversarial diversity loss (SAD_Loss) algorithm. First, the real substation fault image and the generated substation fault image are input into the discriminator to obtain the discrimination result d. real and d fake Then, the basic adversarial loss `adv_loss` is calculated. Next, the structural similarity loss `ssim_loss` is initialized, and a loop is entered to iterate through scale factors (scaling scales) of 1.0, 0.5, and 0.25. For each scale factor, the real substation fault image and the generated substation fault image are scaled to obtain a scaled image. Then, the SSIM loss at the current scale is calculated using the scaled image, and the calculated result is added to the structural similarity loss. After all scale factors have been traversed, the batch size and latent vector `z` are obtained. The latent vector `z` is randomly shuffled to obtain `z_shuffle`, which is then input into the generator to generate a new image `fake_shuffle`. Then, features are extracted from the real substation fault image, the generated substation fault image, and the shuffled generated substation fault image, and their covariance matrices are calculated. The diversity loss `div_loss` is calculated using the covariance matrices. Finally, the basic adversarial loss, structural similarity loss, and diversity loss are weighted and summed to obtain the total loss `total_loss`, which is `SAD_Loss`.
[0074] Specifically, the following is the derivation process of the structure-aware adversarial diversity loss SAD_Loss: I. Calculate the basic adversarial loss : Discriminator D for real substation fault images The output scalar value is Discriminator D generates substation fault images. The output scalar value is The generation of substation fault images is performed by generator G based on latent vectors. generate.
[0075] The basic adversarial loss adopts the WGAN form, which measures the difference between the generated distribution and the real distribution by calculating the difference between the mean of the discrimination output of the generated substation fault image and the mean of the discrimination output of the real substation fault image. The basic adversarial loss is:
[0076] in, Indicates the current training batch; Indicates the discriminator on the first The discriminant scalar value output by the feature of a real substation fault image; This indicates that the discriminator network is for the first... The discrimination scalar value output by the generator of substation fault image features; the greater the difference between the distribution of the generated substation fault image and the distribution of the real image, the more significant the difference. The larger the value, the better. The generator minimizes... This makes the generated distribution closer to the real distribution, narrowing the gap between the two, thereby improving the quality and realism of the generated image.
[0077] II. Calculate multi-scale structural similarity loss : The SSIM index is defined on a single scale as follows:
[0078] in, and Images of substation faults Local mean; and For variance; For covariance; and It is a constant used to ensure numerical stability.
[0079] This invention utilizes multi-scale SSIM at different scaling scales. Real substation fault images were analyzed respectively. and generating substation fault images Scaling:
[0080] in, Indicates the first A high-resolution sample of real substation fault images; The image generated by the generator; This is the scaling factor; This indicates that the input image is downsampled by s; and These represent the real image and the generated image after being scaled by a scale s, respectively.
[0081] By summing the losses at different scales, a multi-scale structural similarity loss can be obtained:
[0082] in, The structural similarity index is used to quantitatively assess the similarity between two images in terms of brightness, contrast, and structural topology. The closer the value is to 1, the more consistent the structures are.
[0083] At different scaling scales The local mean is calculated using sliding window convolution. and variance The SSIM value is then calculated using the formula. Multi-scale accumulation ensures that the generated substation fault image maintains structural consistency at both the original resolution and the downsampled resolution, thereby improving the structural similarity between the generated substation fault image and the real substation fault image at different scales.
[0084] III. Calculating Potential Spatial Diversity Loss : Randomly permuting the latent vectors yields latent noise vectors with their order randomly shuffled. Furthermore, a "scrambled sample" is generated using a generator G. Next, features from the intermediate layer of discriminator D are extracted, i.e., real substation images are extracted. Generate substation images shuffle the samples The characteristics of. Described respectively as ,in , , ∈R d d is the feature dimension.
[0085] The characteristic matrices are denoted as: .
[0086] Next, we calculate the sample covariance matrix, given the true sample feature matrix. ∈R d , ∈R d Let be the feature vector of the i-th real sample. Then the covariance matrix Cov(R) of the real samples is:
[0087] in, The mean vector in the feature space represents the central tendency of the sample distribution; R is the feature matrix; This means subtracting the mean from all features; This represents the matrix transpose operation.
[0088] Similarly, we can obtain the generated sample covariance matrix Cov(G) and the shuffled sample covariance matrix Cov(H):
[0089] in, and These represent the mean vectors calculated along the sample dimensions of the feature matrices H and G, respectively, characterizing the central tendency of the sample distribution.
[0090] Let the covariance matrix Cov(R) of the real samples, the covariance matrix Cov(G) of the generated samples, and the covariance matrix Cov(H) of the shuffled samples be denoted as follows: , , .
[0091] Then potential spatial diversity loss for:
[0092] in, The forced generation of images also indicates the distribution divergence. Align with the distribution divergence of real images ; This is represented by the introduction of a random shuffling mechanism for the latent space (input noise). It forces the network to maintain the overall distribution of its output feature pool as close as possible to the diversity of the real distribution when faced with chaotic input perturbations.
[0093] IV calculates total loss (That is, SAD_Loss):
[0094] in, This is the diversity weighting coefficient (default setting is 0.3). The structural constraint weights are dynamically controlled by the course scheduler, and these weights change dynamically with the progressive generation stage t of the training. For example, in a 32×32 stage... It is initialized to a low value of 0.1, dynamically adjusted to a medium value of 0.3 in the 64×64 stage, and further adjusted to a peak value of 0.5 in the 128×128 stage.
[0095] During the implementation of this invention, targeted comparative ablation experiments were conducted, such as... Figure 7 As shown in the figure. Experimental data shows that, under the same basic network architecture, introducing SE or CBAM modules results in FID values of approximately 145 and 138 respectively, and multi-scale SSIM values of approximately 0.65 and 0.68, still exhibiting bottlenecks in detail blurring. However, by employing the "frequency domain + gradient-guided attention" combination proposed in this invention, the FID of the generated substation fault image is significantly reduced to approximately 110, and the multi-scale SSIM is greatly improved to 0.74.
[0096] In another embodiment, a computer storage medium stores a computer program thereon, wherein when a computer executes the computer program, it implements the substation fault image generation method based on the improved DCGAN described above.
[0097] The specific implementation method is the one described above, and will not be repeated here.
[0098] The above embodiments are preferred embodiments of the present invention, but the embodiments of the present invention are not limited to the above embodiments. Any changes, modifications, substitutions, combinations, or simplifications made without departing from the spirit and principle of the present invention shall be considered equivalent substitutions and shall be included within the protection scope of the present invention.
Claims
1. A method for generating substation fault images based on an improved DCGAN, characterized in that, Includes the following steps: Obtain real images of substation faults; An improved DCGAN model is constructed, using DCGAN as the basic framework. A progressive fault course generation method is employed in the generator, dividing the generation process into multiple stages from low resolution to high resolution. In the first stage, the generator generates a basic image at low resolution. A gradient-guided attention module is introduced in this stage to enhance the fault contour. In the second stage, a frequency-domain self-attention module is introduced to refine features under frequency-domain guidance. In the third stage, the features obtained from the first and second stages are fused to obtain the generated substation fault image. During training, real and generated substation fault images are input into the discriminator, which outputs a true / false discrimination score. Based on the calculated loss, the network parameters of the generator and discriminator are updated through backpropagation. The acquired real substation fault image data is input into the trained generator, which outputs a substation fault gain image.
2. The substation fault image generation method based on improved DCGAN according to claim 1, characterized in that, The processing steps of the gradient-guided attention module include: Input feature map It is divided into two parallel branches: one is retained as the backbone feature, and the other is input to the attention mask generation branch; in the attention mask generation branch, the input feature map is first processed. Perform average pooling along the channel dimension to compress its space into a single-channel grayscale feature map. Then, Spatial convolution is performed by inputting the Sobel operators in the horizontal and vertical directions respectively, and the corresponding horizontal gradient matrix is extracted. With the vertical gradient matrix , in turn and Perform a square operation to obtain and Then, the two are added element by element and the square root operation is performed to calculate the comprehensive gradient magnitude map M. The gradient magnitude map M is input into the Sigmoid activation function for normalization, nonlinearly mapping it to the probability interval [0,1] to generate a single-channel attention weight map W. Channel dimension expansion is then performed on the weight map W to generate a multi-channel attention mask. Finally, the retained backbone is input into the feature map. The enhanced feature map is then multiplied element-wise with the multi-channel attention mask. And pass it on to the subsequent generation stage.
3. The substation fault image generation method based on improved DCGAN according to claim 1, characterized in that, The processing steps of the frequency domain self-attention module include: Input feature map It is divided into two parallel branches: one is directly retained as a residual connection to the end of the network, and the other is input to the main path of frequency domain feature processing; In the main path of frequency domain feature processing, the input feature map is first processed. Perform a Fast Fourier Transform to obtain the frequency domain complex feature tensor. The complex features of this frequency domain Decoupling and separation as real features Features of the imaginary part Real features Features of the imaginary part The inputs are fed in parallel into two independent 1×1 convolutional layers for cross-channel frequency feature interaction. After the convolution operation, the two feature paths are non-linearly mapped using the LeakyReLU activation function to obtain the processed real part features. With processed imaginary part features The updated real features Features of the imaginary part Recombining them according to the rules of complex number operations, we obtain the processed frequency domain complex feature tensor. ; For frequency domain complex feature tensors Performing a fast inverse Fourier transform yields the processed spatial feature map. Spatial feature map Compared with the initially preserved input feature map Perform element-wise residual summation to output the enhanced feature map. And pass it on to the subsequent generation stage.
4. The substation fault image generation method based on improved DCGAN according to claim 1, characterized in that, During the progressive fault course generation process, a course scheduler monitors the model's current training progress and resolution stage, and dynamically adjusts the structural constraint weights. In the low-resolution stage, the course scheduler assigns... With lower weight values, the course scheduler dynamically amplifies the values through step or linear increments at medium and high resolutions. The weight value.
5. The substation fault image generation method based on improved DCGAN according to claim 1, characterized in that, Methods for calculating loss include: The true image discrimination result d is obtained. real and the generated image discrimination result d fake Calculate the basic adversarial loss ; Initialize structural similarity loss Enter the loop and iterate through different scaling scales. For each scaling scale, scale the real substation fault image and the generated substation fault image to obtain the scaled image. Then, use the scaled image to calculate the SSIM loss of the current scaling scale and add the calculated result to the structural similarity loss. After all scaling scales have been traversed, the batch size and latent vector z are obtained. The latent vector z is then randomly shuffled to obtain... The data is then input into a generator to produce new images. Features are extracted from the real substation fault image, the generated substation fault image, and the scrambled generated substation fault image. Their covariance matrices are calculated, and the latent spatial diversity loss is calculated using the covariance matrices. ; Finally, the weighted sum of the basic adversarial loss, structural similarity loss, and potential spatial diversity loss yields the total loss. in, This represents the diversity weighting coefficient. The structural constraint weights are dynamically controlled by the course scheduler. t This is the gradual generation stage.
6. The substation fault image generation method based on improved DCGAN according to claim 5, characterized in that, Calculate the basic adversarial loss include: Discriminator D for real substation fault images The output scalar value is Discriminator D generates substation fault images. The output scalar value is ; The basic adversarial losses are: in, Indicates the current training batch; Indicates the discriminator on the first The discriminant scalar value output by the feature of a real substation fault image; Indicates the discriminator on the first The discrimination scalar value of the generated substation fault image feature output.
7. The substation fault image generation method based on improved DCGAN according to claim 5, characterized in that, Calculating structural similarity loss includes: The SSIM index is defined on a single scale as follows: in, and Images of substation faults Local mean; and For variance; For covariance; and It is a constant; Use different scaling scales Images of real substation faults and generating substation fault images Scaling: in, This indicates that the input image is downsampled by s; and These represent the real image and the generated image after being scaled by a scale s, respectively. By summing the losses at different scales, we obtain the multi-scale structural similarity loss: in, It is a structural similarity index. This indicates the current training batch.
8. The substation fault image generation method based on improved DCGAN according to claim 5, characterized in that, Calculating the potential spatial diversity loss includes: Randomly permuting the latent vectors yields latent noise vectors with their order randomly shuffled. And generate shuffled samples using generator G. Extracting real substation fault images from discriminator D Generate substation fault images shuffle the samples The characteristics are respectively denoted as ; The resulting feature matrices are denoted as follows: ; The true sample covariance matrix Cov(R) is: in, Let be the mean vector in the feature space. Indicates the current training batch; Generate the substation fault image covariance matrix Cov(G) and the shuffled sample covariance matrix Cov(H): in, and These represent the mean vectors of the feature matrices H and G, calculated along the sample dimension, respectively. Let the covariance matrix Cov(R) of the real substation fault image, the covariance matrix Cov(G) of the generated substation fault image, and the covariance matrix Cov(H) of the shuffled samples be respectively denoted as . , , ; Then potential spatial diversity loss for: in, This represents the square of the Frobenius norm.
9. A substation fault image generation system based on an improved DCGAN, characterized in that, The method for generating substation fault images based on improved DCGAN as described in any one of claims 1-8 includes: The image acquisition module acquires real substation fault images; An improved DCGAN model training module was constructed, using DCGAN as the basic framework. The generator employs a progressive fault course generation method, dividing the generation process into multiple stages from low to high resolution. In the first stage, the generator generates a basic image at low resolution, introducing a gradient-guided attention module to enhance fault contours. In the second stage, a frequency-domain self-attention module is introduced to refine features under frequency-domain guidance. In the third stage, the features obtained from the first and second stages are fused to obtain the generated substation fault image. The discriminator uses the DCGAN discriminator. During training, real and generated substation fault images are input into the discriminator, which outputs a true / false discrimination score. Based on the calculated loss, the network parameters of the generator and discriminator are updated through backpropagation. The image generation module inputs the acquired real substation fault image data into the trained generator and outputs a substation fault gain image.
10. A computer storage medium having a computer program stored thereon, characterized in that, When the computer executes the computer program, it implements the substation fault image generation method based on the improved DCGAN as described in any one of claims 1-8.