Defect image model generation method oriented to global feature perception
Through the defect image model generation method for global feature perception, image enhancement and balanced processing are used to build and improve the global feature perception model, solving the problem of insufficient defect appearance in substation defect detection, and real and diverse generation under a small number of samples The defect sample improves detection performance.
Patent Information
- Application Number
- CN202411263339.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2023-12-18
- Filing Date
- 2024-09-10
- Publication Date
- 2024-12-13
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In substation defect detection, traditional data enhancement methods cannot effectively expand the defect appearance, resulting in limited defect detection performance. The defect image background and defects generated by traditional GANs are blurred, and the size and location of defect generation cannot be controlled.
Using the defect image model generation method for global feature perception, the target substation equipment is determined, the original image is obtained and processed, the substation equipment image data set is constructed, and the global feature perception model is built, and more real defects are generated by image enhancement and balanced processing. sample. The method includes adding defect-aware residual blocks, matching discriminators, and attention mechanisms, optimizing the loss function to generate diverse and rich defect samples.
With only a small number of defect samples, the number of defect samples is rapidly expanded to generate more realistic defect samples, greatly enriching the defect samples of substation equipment and improving the performance of defect detection.
Smart Images

Figure CN119131526A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of power system defect image generation, and in particular to a defect image model generation method oriented to global feature perception. Background Art
[0002] Substations play an important role in voltage conversion and power distribution in power grids. Their safe and reliable operation is the basis for the safety and stability of power grids. The normal operation of substation equipment is of great significance to the safe production of substations. External defects that can be found in substation equipment include metal corrosion, oil leakage, hanging objects (foreign objects, etc.). Timely discovery and elimination of these safety hazards that affect the normal operation of substation equipment are of great significance to ensuring the safe and reliable operation of substations.
[0003] In the substation defect detection scenario, the lack of defect images of substation equipment seriously affects the performance of defect detection. This problem can be solved by generating more samples as data enhancement. Using traditional data enhancement methods to expand defect samples, such as rotating, translating and adding noise to defect samples, can effectively expand the number of defect samples and enrich the defect appearance. However, the traditional data enhancement method can only expand the data volume of defect samples to a certain extent. The defect appearance after expansion is still similar to the original defect appearance. The trained model is prone to overfitting and other phenomena, which has limited help in improving the performance of deep learning models. In recent years, in the anomaly detection of class imbalanced images, the generative adversarial network (GAN) has gradually been applied in the field of sample generation and achieved good results. However, due to the complex background of substation equipment and the rich characteristics of defect types, the background and defects in the defect images generated by traditional GAN are blurred, and the size and position of defect generation cannot be controlled.
[0004] Therefore, there is an urgent need to provide a defect image model generation method for global feature perception that can quickly expand the number of defect samples and enrich the samples of substation equipment defects. Summary of the invention
[0005] The technical problem to be solved by the present invention is to provide a defect image model generation method oriented to global feature perception.
[0006] To solve the above problems, the technical solution adopted by the present invention is:
[0007] A defect image model generation method for global feature perception, the method comprising:
[0008] Step 1: determine multiple target substation equipment required for defect generation;
[0009] Step 2: for any one of the target substation equipment, a plurality of original images containing the target substation equipment are obtained, wherein the original images include a normal image of the target substation equipment and a defective image with defects;
[0010] Step 3: Perform image enhancement and equalization processing on all acquired original images;
[0011] Step 4: construct a substation equipment image dataset based on all processed images;
[0012] Step 5: Build a substation automatic inspection initial defect image generation model based on the improved global feature perception model;
[0013] Step six: using the substation equipment image data set obtained in step four to train the initial defect image generation model obtained in step five, to obtain the defect image model oriented to global feature perception.
[0014] As an embodiment of the invention, the target substation equipment in step one includes meters, transformers, insulators and bushings.
[0015] As an implementation mode of the invention, in step 2, the method of acquiring the target image includes: collecting equipment images taken by monitoring images of each substation, acquiring public data on the Internet, and acquiring images by extracting frames from videos taken on site.
[0016] As an implementation mode of the invention, in step three, a histogram equalization method is used to enhance the darker areas in the original image.
[0017] As an implementation mode of the invention, step 4 includes:
[0018] Step S401, confirming the equipment type: with reference to relevant technical specifications and according to defect generation requirements, the targets are confirmed as four categories: equipment meters, transformer bushings, equipment bodies, and insulators;
[0019] Step S402, image data set confirmation: all processed images are used to form a substation equipment image data set according to equipment categories;
[0020] Step S403, unifying the image naming format: performing unified processing on the naming standard of the defect generation target data set.
[0021] As an implementation mode of the invention, the step five comprises:
[0022] Step S501, environment deployment: download the model source code file from Github, configure the anaconda virtual environment, create a virtual environment with Python=3.7, check the CUDA version, and install the corresponding pytorch environment;
[0023] Step S502, configure hyperparameters: set learning rate, batch size, number of training rounds, training and test image sizes;
[0024] Step S503, building a basic model: using a feature-aware image generation model as a basic model;
[0025] Step S504, model improvement: improving the basic model to obtain an improved global feature perception model;
[0026] Step S505: Using the substation equipment image data set to train the improved global feature perception model to obtain the defect image model oriented to global feature perception.
[0027] As an implementation mode of the invention, in step S503, the feature-aware image generation model is composed of a generator and a discriminator;
[0028] Among them, the generator includes a backbone module and a defect-aware residual module. The backbone module adopts the original structure of StyleGAN2; the defect-aware residual module processes features starting from 64×64 resolution, and the processing area is controlled by the mask of the ToMask module. The weights of the two parts are adjusted by the corresponding mapping network; the discriminator is responsible for judging the authenticity of the image.
[0029] As an implementation mode of the invention, step S504 includes:
[0030] (1) Add defect-aware residual blocks
[0031] The defect-aware residual block has a similar structure to the synthetic block of the backbone. When the resolution of the first additional residual block is 64, both the synthetic block S and the residual block R extract the feature F from the last synthetic block with a resolution of 32. 32 , and output object feature maps respectively And defect residual feature map in N is the number of channels;
[0032] The additional ToMask module is the same as the ToRGB module of the backbone, which generates a mask To determine the defective area of the current image. Only the residual features corresponding to the defective pixels (non-negative values on the mask M) are added to the target feature map to obtain the synthesized feature map F 64 :
[0033]
[0034] Where (i, j) represents any pixel on the feature map or mask;
[0035] (2) Add a matching discriminator D match
[0036] Add a matching discriminator D with almost the same architecture as the original discriminator D on the basis of the original discriminator D match , when input D match Previously, the features of the image and the mask were combined, and the output scores were used to determine whether these defect images matched their corresponding defect masks;
[0037] D match The Wasserstein adversarial loss is optimized with R1 regularization for supervision.
[0038] (3) Introducing the attention mechanism
[0039] The attention mechanism is input x∈R H×W×C Represents the image features in the hidden layer, first through three 1×1 convolutional structure branches f(x), g(x) and h=(x), where f(x)=W f x,g(x)=W g x, the size of the feature map after linear transformation remains unchanged, f(x) and g(x) are compressed in number of channels, and the output of h(x) keeps the number of channels unchanged;
[0040] Then the two dimensions H and W are merged into N, that is, N = H × W, and the output of the tensor f(x) is transposed and multiplied with the output matrix of the tensor g(x) to obtain g(x)f(x) T , after Softmax normalization, we get an N×N attention mapping matrix β, which represents the relevance of the image content in the j region of the model to the i region, that is,
[0041]
[0042] Then, the attention mapping matrix β representing the global information and the output h(x) of the local information are matrix-multiplied to obtain the self-attention feature o=(o1,o2,…o N )∈R N×C ,in,
[0043] Finally, the self-attention feature is passed through a 1×1 convolution structure, and the output o is rescaled to [H, W, C] to obtain the self-attention feature map at this time;
[0044] (4) Loss function improvement
[0045] The loss function is obtained using the following formula:
[0046] L(G,D,D match )=LStyleGAN (G,D)+
[0047] L match (G,D match )+lL ms (G);
[0048] Where: L StyleGAN The original loss function used by StyleGAN2; L match D match The loss function of L ms is the mode seeking loss and λ is 0.1.
[0049] The beneficial effects of adopting the above technical solution are:
[0050] The present invention proposes a defect image model generation method for global feature perception, which determines multiple target substation equipment required for defect generation; for any one of the target substation equipment, obtains multiple original images containing the target substation equipment, wherein the original images include normal images of the target substation equipment and defective images with defects; performs image enhancement and equalization processing on all the acquired original images; constructs a substation equipment image data set based on all processed images; builds a substation automatic inspection initial defect image generation model based on an improved global feature perception model; and uses the obtained substation equipment image data set to train the initial defect image generation model to obtain the defect image model for global feature perception, which can achieve the purpose of generating more realistic defect samples and rapidly expanding the number of defect samples when there are only a small number of defect samples, thereby greatly enriching the samples of substation equipment defects. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] Figure 1 This is a flow chart of a method for generating substation equipment defects based on an improved global feature perception model.
[0052] Figure 2 is the image equalization effect diagram; where, (a) the original Figure Ⅰ (b) original Figure Ⅰ Histogram equalization; (c) original Figure II ; (d) original Figure II Histogram equalization.
[0053] Figure 3 It is a schematic diagram of the defect-aware residual block structure.
[0054] Figure 4 It is a schematic diagram of the matching discriminator structure.
[0055] Figure 5 This is a schematic diagram of the attention mechanism network structure.
[0056] Figure 6 This is a defect image generation effect diagram based on the improved global feature perception network model; among them, (a) defect-free body I; (b) oil stain on the surface of body I; (c) defect-free body II; (d) oil stain on the surface of body II; (e) defect-free body III; (f) oil stain on the surface of body III. DETAILED DESCRIPTION
[0057] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention is clearly and completely described below in conjunction with specific embodiments.
[0058] An embodiment of the present invention provides a method for generating a defect image model for global feature perception, the method comprising:
[0059] Step 1: Confirm multiple target substation equipment required for defect generation.
[0060] First, the substation equipment targets required in the defect generation task are confirmed, and multiple target substation equipment are obtained. The target substation equipment includes meters, transformers, insulators and bushings. Of course, each type of equipment can also be subdivided into different categories based on function, model, etc.
[0061] Step 2: For any one of the target substation equipment, obtain multiple original images containing the equipment.
[0062] The original image includes a normal image of the target substation equipment and a defective image with defects.
[0063] In this step, the original image acquisition methods include the following three methods: (1) collecting equipment images taken by monitoring images of each substation; (2) obtaining public data on the Internet; (3) obtaining images by extracting frames from videos taken on site. For example, when the target substation equipment is a meter, any one or more of the above three methods can be used to obtain normal images and defective images containing the meter (i.e., original images containing the meter).
[0064] Step 3: Perform image enhancement and equalization processing on the acquired original image. Specifically, in this step, a histogram equalization method is used to enhance the darker areas in the original image.
[0065] In order to highlight some useful information of the obtained power equipment images and improve the quality of image stitching, it is necessary to perform image enhancement processing on the original images and enhance the darker areas of the images so that the images have better visual effects after stitching. To address this problem, the present invention uses a histogram equalization method to perform image enhancement processing on target categories with insufficient data.
[0066] Histogram equalization can be effectively used in image enhancement, image segmentation and image compression. The idea is that the original image can be transformed to evenly distribute all gray levels, making the image clear. The histogram equalization calculation process is as follows: For an image, the gray level of each pixel is random and its range is in the interval [0,255]. Usually in discrete form, the image gray level r k The probability of occurrence is:
[0067]
[0068] Where P r (r k ) represents the probability of the gray level of the image appearing; n k The number of pixels with gray levels; n is the total number of pixels.
[0069] The cumulative distribution function calculation formula is:
[0070]
[0071] Where k is the gray level.
[0072] The effect of using histogram equalization to enhance the original image of substation equipment is as follows: Figure 2 shown.
[0073] Step 4: Construct a substation equipment image dataset based on all processed images.
[0074] After completing image data enhancement and equalization processing, the substation equipment image dataset construction work is carried out. The specific steps are as follows:
[0075] Step S401, confirming the equipment type: with reference to relevant technical specifications and according to defect generation requirements, the targets are confirmed as four categories: equipment meters, transformer bushings, equipment bodies, and insulators.
[0076] The relevant technical specifications can be State Grid's "Technical Specifications for Remote Intelligent Patrol Systems for 500 (330) kV and Above Substations (Trial)".
[0077] Step S402, image data set confirmation: all processed images are organized into a substation equipment image data set according to equipment categories (equipment categories include: equipment type and defect type, equipment types include meters, transformers, insulators and bushings, defect types include: normal meter, defective meter, normal transformer bushing, defective transformer bushing, normal equipment body, defective equipment body, normal insulator, and defective insulator); wherein the number of single-category target images is not less than 10,000, and illustratively, each type of target image is set to 10,000.
[0078] Step S403, unifying the image naming format: performing unified processing on the naming standard of the defect generation target data set.
[0079] In a possible implementation, the defect image naming method adopts the form of "defect type pinyin initial letter_substation equipment type pinyin initial letter_7-digit image number.jpg". For example, the first image of the body component surface oil stain defect dataset is "sly_bjbmyw_0000001.jpg".
[0080] Step 5: Build a substation defect image model based on the improved global feature perception model.
[0081] Step S501, environment deployment: download the model source code file from Github, configure the anaconda virtual environment, use to create a virtual environment of Python = 3.7, check the CUDA version, and install the corresponding pytorch environment; according to the requirements.txt file in the global feature perception source code folder, configure other related environments.
[0082] Step S502, configure hyperparameters: set learning rate, batch size, training rounds, training and test image sizes; in the present invention, the hyperparameter combination is set as follows: batch size batch = 32, training rounds epochs = 300, training and test image size img-size = 256 × 256.
[0083] Step S503, building a basic model: using a feature-aware image generation model as a basic model.
[0084] In the embodiment of the present invention, the feature-aware image generation model is composed of a generator and a discriminator;
[0085] Among them, the generator includes a backbone module and a defect-aware residual module. The backbone module adopts the original structure of StyleGAN2; the defect-aware residual module processes features starting from 64×64 resolution, and the processing area is controlled by the mask of the ToMask module. The weights of the two parts are adjusted by the corresponding mapping network; the discriminator is responsible for judging the authenticity of the image.
[0086] Step S504, model improvement: improving the basic model to obtain an improved global feature perception model;
[0087] The specific improvements are as follows:
[0088] (1) Adding a defect-aware residual block (Matching Discriminator)
[0089] In order to ensure the diversity of the generated defect images, a defect-aware residual block is added. The defect-aware residual block has a similar structure to the synthetic block of the backbone, such as Figure 3 As shown in Figure 2, when the resolution of the first residual block is 64, both the synthetic block S and the residual block R extract the feature F from the last synthetic block with a resolution of 32. 32 , and output object feature maps respectively And defect residual feature map in N is the number of channels.
[0090] The additional ToMask module is the same as the ToRGB module of the backbone, which generates a mask To determine the defective area of the current image. Only the residual features corresponding to the defective pixels (non-negative values on the mask M) are added to the target feature map to obtain the synthesized feature map F 64 :
[0091]
[0092] Where (i, j) represents any pixel on the feature map or mask.
[0093] First, the residual block only processes the target features in the defect area, while the target features in the non-defect area remain unchanged. Then the feature map F is selected 64 replace It becomes the input of the subsequent blocks. Then, at resolutions of 128 and 256, the defect residual features are controlled by sampling the corresponding resolution of the mask. The object feature map in the defect area is operated in a similar way to resolution 64. Finally, the synthetic blocks with a resolution of 32 or lower are retained, because the high-level (lower resolution) of the network determines the coarse structure of the image, while the low-level generates detailed textures including defects.
[0094] In order to ensure the diversity of the generated defect images, the present invention not only determines the defect image based on the main object feature map, but also introduces a defect mapping network to control the defect variation. The defect mapping network receives the randomly sampled defect code z defect , and output the modulation weight w defect , used to modulate the residual block similar to the backbone, both mapping networks have the same network structure. In the second training stage, global feature perception fixes its backbone network and trains the defect mapping network and the defect perception residual block proposed in this invention on defect images to generate more defect samples with high fidelity and diversity. In this stage, we control the number of trainable parameters to 3.7 million. Compared with the 23.2 million trainable parameters fixed on defect-free images in the previous stage, it is much easier to train on a small number of defect images in the second stage.
[0095] (2) Add a matching discriminator
[0096] Add a matching discriminator D based on the original discriminator D match To bridge the gap between the real defect image and mask pair and the generated defect image pair, and identify whether the defect in the image matches the mask. match has almost the same architecture as the original discriminator D, such as Figure 4 As shown, the present invention reduces the number of channels per layer by referring to whether the defect image matches the mask. match The parameters of the algorithm are fewer and it is suitable for defect image generation with a small number of samples. match Before, the features of the image and the mask are combined, and the output scores are used to determine whether these defect images match their corresponding defect masks. match The Wasserstein adversarial loss is optimized with R1 regularization to provide supervision, similar to the supervision provided by the ordinary discriminator in StyleGAN. The two discriminators cooperate with each other in the defect image generation process.
[0097] (3) Introducing the Attention Mechanism:
[0098] The global feature perception attention mechanism of this patent is input x∈R H×W×C Represents the image features in the hidden layer, and the network structure of the attention mechanism is as follows Figure 5 As shown, first, it passes through three 1×1 convolutional branches f(x), g(x) and h=(x), where f(x)=W f x,g(x)=W g x, the size of the feature map after linear transformation remains unchanged, f(x) and g(x) are compressed in number of channels, and the output of h(x) keeps the number of channels unchanged;
[0099] Then, the two dimensions H and W are combined into N, that is, N = H × W, and the output of the tensor f(x) is transposed and multiplied with the output matrix of the tensor g(x) to obtain g(x)·f(x) T , after Softmax normalization, we get an N×N attention mapping matrix β, which represents the relevance of the image content in the j region of the model to the i region, that is,
[0100]
[0101] Then, the attention mapping matrix β representing the global information and the output h(x) of the local information are matrix-multiplied to obtain the self-attention feature o=(o1,o2,…o N )∈R N×C,in,
[0102] Finally, the self-attention feature is passed through a 1x1 convolution structure, and the output o is rescaled to [H, W, C] to obtain the self-attention feature map at this time. The attention feature map can be regarded as the product of the feature map and its own transposition. This operation can enhance the association between features that are far away in the graph, thereby obtaining global features.
[0103] (4) Loss function improvement
[0104] In the original feature perception model, the generated defect image depends on the object features from the backbone network and the defect features from the defect perception residual block. This design conforms to the objective fact that object defects depend on the object itself and external factors. defect And fix z object (fixed object features), the results show that the defects are determined only by the object features, using different z defect There is almost no noticeable change when the objects are similar. Similar objects are usually accompanied by similar defects, which leads to a generally single defect generation style.
[0105] The defect mapping network uses two random defect codes and Output two corresponding modulation weights and The entire model uses and Defect masks M1 and M2 are generated on the same object. Then, global feature perception minimizes the pattern finding loss
[0106]
[0107] When using different w defect When performing the multi-layer defect mask optimization, try to maximize the difference between defect masks.
[0108] The present invention uses w defect Instead of z defect , because Karras, Laine, and Aila (2019) pointed out that the latent space of w is less entangled and therefore better represents the input space of the generator than the fixed z distribution.
[0109] Given the original loss function L used by StyleGAN2 StyleGAN (including adversarial loss, path length regularization and R1 regularization, refer to Karras, Laine, and Aila (2019)), D match The loss function L match and the pattern seeking loss Lms Therefore, the optimization model of the present invention optimizes the generator G and the discriminator D, D according to the overall objective function. match We optimized them one by one and used the following formula to get the loss function:
[0110] L(G,D,D match )=L StyleGAN (G,D)+
[0111] L match (G,D match )+lL ms (G);
[0112] Here, setting λ=0.1 usually gives good results.
[0113] Step six: using the substation equipment image data set obtained in step four to train the initial defect image generation model obtained in step five, to obtain the defect image model oriented to global feature perception.
[0114] The present invention uses the constructed substation image data set to train the initial defect image generation model. First, a global feature perception environment is deployed on the server. The server configuration is Ubuntu 18.04 system, CPU: Intel (R) Xeon (R) Silver 4214 CPU @ 2.20 GHz, CPU main frequency: 1000 MHZ, memory: 16 GB, RAM: 257580 GB, GPU: NVIDIA GeForce RTX 2080 Ti, video memory: 11 GB GDDR6. According to step 4, the improved global feature perception model training environment is configured on the server, and the hyperparameters used for training are set. After that, the improved global feature perception model is trained, and the training is stopped after the preset number of iterations to obtain a defect generation global feature perception model; the model can generate a local defect device image from a normal substation image of any input substation device and an original defect image containing any defect type; wherein the local defect device image is an image of the substation device carrying a defect type.
[0115] Furthermore, the present invention performs effect testing and evaluation on the trained model.
[0116] The present invention selects oil leakage as defect generation, including oil stains on the surface of the body parts, oil stains on the ground, and oil stains on the surface of the casing parts. The model effect is verified using the test set images. The defect generation results are as follows: Figure 6 shown.
[0117] In the first training phase, the goal of this patent is to train a generator as the backbone of the feature-aware model by randomly sampling the target code z objectTo generate various defect-free images. Since the advantage of StyleGANs lies in its strong generation ability, StyleGAN2 with adaptive differentiable enhancement is selected as the backbone. It consists of a mapping network and a synthesis network. The synthesis network is based on the learned constant feature map c and consists of convolutional synthesis blocks. The RGB appearance is accumulated into the final generated image through the ToRGB module. The mapping network converts the random z object Mapping to w object , thereby adjusting the convolution weights of the synthetic network and importing the variables into the generated image.
[0118] The second training phase is to transfer to defective images. Defective images are composed of defective areas and non-defective areas. By properly processing the potential defective areas of the object feature map, the entire model can be extended to generate defective images while maintaining the ability to generate non-defective images. This patent uses a defect residual block attached to the backbone to give a reasonable defect mask that divides the defective area and the corresponding defect features. Then, the mask and defect features are used to operate the object feature map to add defects to the non-defective image.
[0119] Table 1 Comparison results between the improved global feature perception model and several mainstream defect generation models
[0120]
[0121]
[0122] The present invention proposes a defect image model generation method for global feature perception, which determines multiple target substation equipment required for defect generation; for any one of the target substation equipment, obtains multiple original images containing the target substation equipment, wherein the original images include normal images of the target substation equipment and defective images with defects; performs image enhancement and equalization processing on all the acquired original images; constructs a substation equipment image data set based on all processed images; builds a substation automatic inspection initial defect image generation model based on an improved global feature perception model; and uses the obtained substation equipment image data set to train the initial defect image generation model to obtain the defect image model for global feature perception, which can achieve the purpose of generating more realistic defect samples and rapidly expanding the number of defect samples when there are only a small number of defect samples, thereby greatly enriching the samples of substation equipment defects.
Claims
1. A defect image model generation method for global feature perception, It is characterized in that The method comprises: Step 1: determine multiple target substation equipment required for defect generation; Step 2: for any one of the target substation equipment, a plurality of original images containing the target substation equipment are obtained, wherein the original images include a normal image of the target substation equipment and a defective image with defects; Step 3: Perform image enhancement and equalization processing on all acquired original images; Step 4: construct a substation equipment image dataset based on all processed images; Step 5: Build a substation automatic inspection initial defect image generation model based on the improved global feature perception model; Step six: using the substation equipment image data set obtained in step four to train the initial defect image generation model obtained in step five, to obtain the defect image model oriented to global feature perception.
2. According to the method for generating a defect image model for global feature perception according to claim 1, It is characterized in that The target substation equipment in step 1 includes meters, transformers, insulators, and bushings.
3. According to the method for generating a defect image model for global feature perception according to claim 1, It is characterized in that In step 2, the target image is obtained by collecting equipment images captured by monitoring images of each substation, obtaining public data on the Internet, and obtaining images by extracting frames from videos shot on site.
4. According to the method for generating a defect image model for global feature perception according to claim 1, It is characterized in that In step three, the histogram equalization method is used to enhance the darker areas in the original image.
5. According to the method for generating a defect image model for global feature perception according to claim 1, It is characterized in that Step 4 includes: Step S401, confirming the equipment type: with reference to relevant technical specifications and according to defect generation requirements, the targets are confirmed as four categories: equipment meters, transformer bushings, equipment bodies, and insulators; Step S402, image data set confirmation: all processed images are used to form a substation equipment image data set according to equipment categories; Step S403, unifying the image naming format: performing unified processing on the naming standard of the defect generation target data set.
6. The method for generating a defect image model for global feature perception according to claim 1, It is characterized in that The step five comprises: Step S501, environment deployment: download the model source code file from Github, configure the anaconda virtual environment, create a virtual environment with Python=3.7, check the CUDA version, and install the corresponding pytorch environment; Step S502, configure hyperparameters: set learning rate, batch size, number of training rounds, training and test image sizes; Step S503, building a basic model: using a feature-aware image generation model as a basic model; Step S504, model improvement: improving the basic model to obtain an improved global feature perception model; Step S505: Using the substation equipment image data set to train the improved global feature perception model to obtain the defect image model oriented to global feature perception.
7. The method for generating a defect image model for global feature perception according to claim 6, It is characterized in that In step S503, the feature-perceived image generation model is composed of a generator and a discriminator; Among them, the generator includes a backbone module and a defect-aware residual module. The backbone module adopts the original structure of StyleGAN2; the defect-aware residual module processes features starting from 64×64 resolution, and the processing area is controlled by the mask of the ToMask module. The weights of the two parts are adjusted by the corresponding mapping network; the discriminator is responsible for judging the authenticity of the image.
8. The method for generating a defect image model for global feature perception according to claim 7, It is characterized in that Step S504 includes: (1) Add defect-aware residual blocks The defect-aware residual block has a similar structure to the synthetic block of the backbone. When the resolution of the first additional residual block is 64, both the synthetic block S and the residual block R extract the feature F from the last synthetic block with a resolution of 32. 32 , and output object feature maps respectively And defect residual feature map in N is the number of channels; The additional ToMask module is the same as the ToRGB module of the backbone, which generates a mask To determine the defective area of the current image. Only the residual features corresponding to the defective pixels (non-negative values on the mask M) are added to the target feature map to obtain the synthesized feature map F 64 : Where (i, j) represents any pixel on the feature map or mask; (2) Add a matching discriminator D match Add a matching discriminator D with almost the same architecture as the original discriminator D on the basis of the original discriminator D match , when input D match Previously, the features of the image and the mask were combined, and the output scores were used to determine whether these defect images matched their corresponding defect masks; D match The Wasserstein adversarial loss is optimized with R1 regularization for supervision. (3) Introducing the attention mechanism The attention mechanism is input x∈R H×W×C Represents the image features in the hidden layer, first through three 1×1 convolutional structure branches f(x), g(x) and h=(x), where f(x)=W f x,g(x)=W g x, the size of the feature map after linear transformation remains unchanged, f(x) and g(x) are compressed in number of channels, and the output of h(x) keeps the number of channels unchanged; Then, the two dimensions H and W are combined into N, that is, N = H × W, and the output of the tensor f(x) is transposed and multiplied with the output matrix of the tensor g(x) to obtain g(x)·f(x) T , after Softmax normalization, we get an N×N attention mapping matrix β, which represents the relevance of the image content in the j region of the model to the i region, that is, Then, the attention mapping matrix β representing the global information and the output h(x) of the local information are matrix-multiplied to obtain the self-attention feature o=(o 1 ,o 2 ,…o N )∈R N×C ,in, Finally, the self-attention feature is passed through a 1×1 convolution structure, and the output o is rescaled to [H, W, C] to obtain the self-attention feature map at this time; (4) Loss function improvement The loss function is obtained using the following formula: L(G,D,D match )=L StyleGAN (G,D)+ L match (G,D match )+lL ms (G); Where: L StyleGAN The original loss function used by StyleGAN2; L match D match The loss function of L ms is the mode seeking loss and λ is 0.1.
Citation Information
Patent Citations
Power transformation equipment appearance image defect detection method based on fusion data generation and transfer learning technology
CN113724233A
Steel rail surface defect image expansion method based on attention mechanism and DCGAN
CN114842284A
Cited By
Insulator defect generation method based on small sample
CN122116053A
