A small sample-based insulator defect generation method
By combining generative adversarial networks with residual mechanisms, and utilizing defect-aware residual blocks and modulation normalization modules, the problem of insufficient generation capability in power equipment defect generation is solved. This achieves defect image generation with high realism and accurate defect localization, thus improving the performance of the detection model.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HARBIN ENGINEERING UNIVERSITY SANYA NANHAI INNOVATION & DEVELOPMENT BASE
- Filing Date
- 2026-04-30
- Publication Date
- 2026-05-29
AI Technical Summary
Existing technologies for generating defects in power equipment suffer from problems such as insufficient defect morphology generation capability, lack of refined spatial control in the generation process, and unstable training under small sample sizes, making it difficult to generate highly realistic and diverse defect images.
We employ a deep fusion approach based on Generative Adversarial Networks (GANs) and residual mechanisms, combining defect-aware residual blocks, ToMask modules, modulation normalization modules, and dual discriminator mechanisms to generate high-quality and diverse defect images through multi-conditional constraints.
Defect images with high realism and accurate defect localization were generated under small sample conditions, which improved the generalization ability and detection accuracy of the detection model and reduced the pain point of data scarcity.
Smart Images

Figure CN122116053A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of defect sample generation technology in visual inspection of power equipment, and in particular to a method for generating insulator defects based on small samples. Background Technology
[0002] Regular inspection and defect detection of power equipment (such as insulators) are crucial for ensuring the safe and stable operation of the power grid. With the development of computer vision and deep learning technologies, image-based automatic defect detection methods have gradually replaced traditional manual inspections, becoming an important means of improving operation and maintenance efficiency. However, these methods heavily rely on a large number of high-quality labeled defect samples for model training. In actual industrial scenarios, the vast majority of equipment is in normal condition, and the acquisition frequency of real defect samples (such as insulator bursts, surface cracks, dirt accumulation, corona burns, etc.) is extremely low, and the acquisition cost is high. Furthermore, the defect morphology is highly complex and diverse due to factors such as equipment type, material aging, and environmental stress. Therefore, how to generate high-quality, diverse defect images using limited defect samples to expand the training dataset and improve the generalization ability and robustness of the detection model has become a core problem urgently needing to be solved in the field of intelligent operation and maintenance of power equipment.
[0003] Currently, there are several main technical approaches for image data augmentation and sample generation, but they still have significant limitations when applied to generating defects in power equipment: (1) Traditional data augmentation techniques: These methods increase the number of samples by applying low-level geometric and pixel transformations to the original image, including rotation, flipping, scaling, cropping, brightness adjustment, contrast adjustment, and noise injection. While simple to implement and computationally inexpensive, they are essentially shallow signal transformations of existing samples and cannot generate new defect morphologies unseen at the semantic level. For power equipment with complex defect structures and specific locations, traditional enhancement methods struggle to simulate the real defect generation mechanisms and visual representations, resulting in a severe lack of diversity and realism in the generated samples.
[0004] (2) Generative Adversarial Networks and their general variants: Generative Adversarial Networks (GANs) learn the distribution of real data through adversarial training between the generator and discriminator, enabling them to synthesize visually high-quality images. However, the generation process of standard GANs and their improved models (such as DCGAN and WGAN) is dominated by random noise, lacking control over the generated content and making it difficult to generate physically accurate defects for specific devices and locations. Furthermore, when defect samples are extremely scarce, GAN training is prone to pattern collapse or instability, resulting in poor diversity of generated samples and blurred or distorted defect features.
[0005] (3) Conditional Generative Adversarial Networks: To improve the controllability of the generated data, conditional generative adversarial networks (cGANs) incorporate conditional information such as category labels and text descriptions into the input, achieving a certain degree of targeted generation. However, the control granularity of existing cGANs and their variants (such as AC-GAN and StyleGAN) is still relatively coarse, mostly limited to global semantic control, making it difficult to achieve fine-grained spatial localization and morphological control of defects in images. For defects in power equipment, their local features such as location, size, and texture have strong prior constraints. Existing methods cannot effectively incorporate such structured knowledge, resulting in unreasonable defect locations or inconsistencies with the equipment structure, affecting the credibility and usability of the samples.
[0006] In summary, existing technologies for generating small-sample images of power equipment defects generally suffer from common problems such as insufficient defect morphology generation capability, lack of refined spatial control in the generation process, and unstable training and monotonous patterns under small sample conditions. Therefore, there is an urgent need for a novel generation method that can fully integrate prior equipment knowledge, achieve precise local editing of defects, and stably generate highly realistic and diverse defect images under small sample conditions, in order to support the training and performance improvement of subsequent defect detection models. Summary of the Invention
[0007] By deeply integrating Generative Adversarial Networks (GANs) with residual mechanisms, this invention proposes a method for generating insulator defects based on small samples to address the problem of expanding sparse defect samples for power equipment. This technical solution can not only generate diverse defect images that conform to the actual situation of power equipment, but also ensure the authenticity and semantic consistency of the generated defects, thereby providing more efficient data support for defect detection and prediction of power equipment.
[0008] To achieve the above objectives, the present invention provides a method for generating insulator defects based on small samples, comprising: The pre-trained StyleGAN3-T generative model is used as the backbone synthesis network to generate normal insulator images; During the process of generating images by the backbone synthesis network, when the resolution reaches or exceeds the preset resolution, the backbone synthesis network generates an object feature map at the current resolution based on the input feature map. The object feature map represents the content of a defect-free insulator image. A defect-aware residual block is introduced. Based on the defect-aware residual block, the same input feature map as the backbone synthesis network is processed to output a defect residual feature map. The corresponding defect mask is generated through the ToMask module. The randomly sampled defect codes are input into the defect mapping network, and the output is the modulation weights used to control the defect features; Using the defect mask and the modulation weights, the defect residual feature map and the object feature map are adaptively fused through a modulation normalization module conditioned on the mask to obtain a fused feature map. An insulator image containing controllable defects is generated based on the fused feature map.
[0009] Preferably, the corresponding defect mask is generated through the ToMask module, specifically as follows: ; In the formula, For defect mask, This is a feature map of defect residuals.
[0010] Preferably, the defect mask is used to delineate the defect region and to display the defect residual feature map corresponding to the defect pixel. Add to target feature map Above, specifically: ; In the formula, For any pixel on the combined feature map, For the mask coverage of any pixel, For any pixel on the target feature map, For any pixel on the defect residual feature map.
[0011] Preferably, the processing procedure of the modulation normalization module includes: The defect residual feature map and the defect mask are input into the prediction network to obtain scaling parameters and offset parameters. The object feature map is subjected to feature normalization processing to obtain normalized features; The normalized features are modulated based on the scaling and offset parameters; Using a softened defect mask as weights, the modulated features are weighted and fused with the object feature map to generate the fused feature map.
[0012] Preferably, obtaining the normalized features includes: ; In the formula, Norm is the normalization operation. The characteristics after fusion These are the learnable scaling parameters in the StyleGAN3 network. These are the learnable offset parameters in the StyleGAN3 network. These are the characteristics of the original object.
[0013] Preferably, the method further includes adversarial training using dual discriminators, wherein the first discriminator is used to determine the authenticity of the image, and the second discriminator is used to determine whether the generated defect image matches the defect mask.
[0014] Preferably, the number of network parameters of the second discriminator is less than that of the first discriminator, and the input of the second discriminator is a tensor formed by splicing the generated defect image and the defect mask along the channel dimension.
[0015] Preferably, during training, a contrastive loss function is used to measure the distance between the generated image and the real image, specifically: ; In the formula, To compare loss functions, and The first i Feature representations of real and generated images for each sample It's a tag. For the threshold, N This refers to the number of samples used in a single calculation.
[0016] Preferably, the method further includes multi-condition constraint control, which controls the type and / or location of generated defects by injecting multi-dimensional condition variables into the backbone synthesis network; wherein the defect type is controlled by category labels and the defect location is controlled by location masks or spatial coordinates.
[0017] Compared with the prior art, the present invention has the following advantages and technical effects: (1) The network architecture proposed in this invention combines defect-aware residual blocks with a modulation normalization module conditioned on a mask, effectively solving the problem of harsh transitions in defect boundaries caused by traditional residual addition. This allows the generated defect textures to blend smoothly into the background area, significantly improving the visual realism of defect images. In the dual discriminator mechanism, the image real / fake discriminator provides adversarial supervision to ensure the overall realism of the generated images, while the defect matching discriminator achieves precise control over defect localization accuracy through the splicing input of the image and the mask. The synergistic effect of the two allows the generated images to maintain both high realism and accurate defect localization even under small sample training. The multi-condition constraint control mechanism achieves precise control over key features such as defect type, location, and size through defect type label injection and location mask, coordinate input, etc., greatly enhancing the diversity and application adaptability of the generated images. The introduction of the contrastive learning mechanism and feature consistency loss further promotes the deep matching of the generated images with real samples in the feature space, effectively avoiding pattern collapse and comprehensively improving the generation quality and controllability of defect images.
[0018] (2) This invention constructs an efficient small-sample defect image generation framework by introducing a defect-aware residual block and a modulation normalization module, combined with a dual discriminator mechanism and multi-condition constraint control. This framework only requires a small number of real defect samples as references to generate a large number of highly realistic and diverse defect images through learning and optimization by a generative adversarial network. Specifically, the contrastive learning mechanism helps the generator quickly capture the distribution pattern of defect features with limited samples by maximizing the feature distance between positive and negative samples; the feature consistency loss ensures that the generated image is consistent with the real sample in the intermediate layer feature space, avoiding pattern homogenization due to insufficient samples. This small-sample learning capability significantly reduces the model's demand for defect samples, effectively alleviating the pain point of data scarcity in the field of industrial defect detection, and providing a feasible path to solve the problem of difficulty in obtaining defect samples in actual production.
[0019] (3) The defect images generated by this invention have high realism and accurate defect localization capabilities, providing high-quality and diverse training data for downstream defect detection algorithms. By controlling the generation of different types, locations, and sizes of defect images through multi-condition constraints, the generalization recognition capability of the detection model for various types of defects can be effectively improved. At the same time, accurate defect mask information also provides a reliable annotation basis for semi-supervised or weakly supervised defect detection tasks, which helps to reduce the training difficulty of downstream detection models, improve detection accuracy and efficiency, and promote the practical application and development of industrial defect detection technology. Attached Figure Description
[0020] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments and descriptions of this application are used to explain this application and do not constitute an undue limitation of this application. In the drawings: Figure 1 This is a schematic diagram of the network architecture according to an embodiment of the present invention. Detailed Implementation
[0021] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.
[0022] It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0023] This embodiment proposes a method for generating insulator defects based on small samples, including: The pre-trained StyleGAN3-T generative model is used as the backbone synthesis network to generate normal insulator images; During the process of generating images by the backbone synthesis network, when the resolution reaches or exceeds the preset resolution, the backbone synthesis network generates an object feature map at the current resolution based on the input feature map. The object feature map represents the content of a defect-free insulator image. A defect-aware residual block is introduced. Based on the defect-aware residual block, the same input feature map as the backbone synthesis network is processed to output a defect residual feature map. The corresponding defect mask is generated through the ToMask module. The randomly sampled defect codes are input into the defect mapping network, and the output is the modulation weights used to control the defect features; Using the defect mask and the modulation weights, the defect residual feature map and the object feature map are adaptively fused through a modulation normalization module conditioned on the mask to obtain a fused feature map. An insulator image containing controllable defects is generated based on the fused feature map.
[0024] Specifically, StyleGAN3-T inherits the decoupled control capability of the StyleGAN architecture. Its core workflow is still divided into two major modules: the mapping network and the synthesis network. However, through fundamental modifications to the structure of the synthesis network, it achieves a high degree of equivariance in image translation, thereby eliminating the "texture stickiness" problem that existed in the previous generation model.
[0025] First, mapping network Responsible for random sampling of latent vectors ( Transforming (for dimensions) into more decoupled style vectors This process is achieved through a multilayer perceptron (MLP): ; In the formula, The mapping network's function is to transform "random numbers" into "ordered feature vectors".
[0026] Secondly, synthetic networks The workflow is key to StyleGAN3-T's achievement of equivariance. Traditional StyleGAN generators start with a fixed learning constant or image, introducing discrete pixel grid bias. StyleGAN3-T addresses this issue through continuous signal representation and aliasing-free operations. It uses latent vectors... Encoding Fourier features as continuous-domain features as the initial input to the generator avoids the introduction of fixed-position information. Furthermore, the model completely removes pixel Gaussian noise directly added to the feature map in StyleGAN2, as fixed-position noise would also disrupt translational equivariance. Texture details will naturally emerge from the style vector during high-fidelity equivariance operations. Generated in the middle.
[0027] Finally, the achievement of isovariability relies on aliased upsampling and convolution for each generated block in the synthetic network. In the feature enhancement stage of StyleGAN3-T, all upsampling operations (such as...) (Amplification) must be accompanied by precise low-pass filtering. This aims to eliminate aliasing during signal upsampling, which is the root cause of texture stickiness. Specifically, a convolutional layer F, during upsampling... First, a low-pass filter L is applied: ; in, denoted as convolution; L is a carefully designed bandpass or lowpass filter; Output feature map; This is the input feature map.
[0028] The filters used in StyleGAN3-T are designed to be more flexible to preserve more high-frequency information and image details while maximizing translational equivariance. In this way, StyleGAN3-T ensures that all operations in the synthesis network (including style injection, convolution, and upsampling) maintain translational equivariance in the continuous domain. When the final generated image is translated and interpolated in the latent space, all its details (texture, structure) can move in a smooth and consistent manner, thus achieving high-quality, non-viscous generation.
[0029] In StyleGAN2 and earlier versions, when attempting to generate insulator images with minor viewpoint changes or translations, surface textures (such as dirt, minor scratches, and light reflections) could become "stuck" to specific pixel locations instead of moving with the insulator's geometry. StyleGAN3-T aims to achieve translation equivariance. This means that when you translate the generated insulator in latent space, all details of the insulator (including surface texture) smoothly and consistently follow the subject's movement. The generated image sequences (e.g., simulating a drone's slight viewpoint change as it flies over an insulator) will be extremely realistic and artifact-free, which is crucial for training insulator defect generation models that require geometric invariance. Furthermore, generating images of insulators with defects (such as cracks or dirt) requires a highly realistic image of a normal insulator as a base. StyleGAN3-T eliminates various low-quality artifacts common in StyleGAN2, ensuring the highest realism of the baseline image. By leveraging StyleGAN's style mixing mechanism, localized, high-frequency defects (such as fine cracks or dirt textures) can be added by controlling the style vectors of high-resolution layers, while low-resolution layers continue to control the overall structure and orientation of the insulator. StyleGAN3-T's smoothness ensures this mixing is more natural. In summary, StyleGAN3-T provides a state-of-the-art solution for generating power grid insulator images, a scenario requiring high realism and emphasizing geometric consistency and detail accuracy.
[0030] Furthermore, before focusing on the implementation of defect-aware residual blocks, let's explain the working principle of ordinary defect-aware residual blocks. The first residual block is added when the backbone network reaches a resolution of 64×64. This block is added to the synthesis network of the pre-trained StyleGAN3 backbone generator. Images below this resolution remain unchanged because the lower-layer networks (low resolution) only determine the coarse structure of the image, while this embodiment focuses on the higher-layer networks (high resolution) generating detailed appearances including defects. Defect-aware residual blocks learn to generate appropriate defect masks and manipulate features within the mask regions accordingly. and the corresponding backbone composite block Receive from the previous composite block (e.g., resolution) Features Defect-aware residual block Output defect residual feature map Main composite block Output target feature map The formula is expressed as follows: ; ; Furthermore, exist After the output is processed, a ToMask module is connected, whose function is to analyze the defect residual feature map. Generate a defect mask Specifically: ; In the formula, For defect mask, This is a feature map of defect residuals.
[0031] Specifically, the defect mask is used to delineate the defect region and control the specific pixel location where feature manipulation occurs. The manipulation process is as follows: only pixels corresponding to defects (defect mask) are manipulated. Defect residual characteristic map (non-negative values on) It will be added to the target feature map Above, specifically: ; In the formula, For any pixel on the combined feature map, For mask coverage of any pixel: a value greater than or equal to 0 indicates that the pixel is within the mask's effective area. For any pixel in the target feature map, For any pixel on the defect residual feature map.
[0032] In this way, the defect-aware residual block manipulates the target features only within the defect region, while features in non-defect regions remain unchanged. (Manipulated feature map) Subsequently, the defect residual feature map was replaced. This becomes the input for subsequent block generation. Similarly, at resolution... and Hierarchy, defect mask It will be upsampled to the corresponding resolution, and the defect residual features will continue to be controlled in a similar way, thereby manipulating the target feature map.
[0033] Furthermore, such as Figure 1 The diagram shown has a defect mapping network in the upper right corner, which is responsible for outputting a modulation weight. This controls the weights of the residual blocks. The defect mapping network receives a randomly sampled defect code. As input, to ensure that the generated defects are diverse.
[0034] After clarifying the principle of defect-aware residual blocks, practical application revealed that the defect images generated by these blocks exhibit abrupt transitions at mask boundaries, making natural texture blending difficult. To address this issue, this embodiment proposes a modulation normalization module conditioned on a mask to achieve feature fusion. The specific method is as follows: First, the target feature map With defect residual feature map The process remains unchanged, but the defect features and defect masks are no longer directly used for addition. Instead, they are jointly input into a small network (a micro-convolutional layer) to predict the modulation parameters. and (i.e., the scaling and offset parameters in StyleGAN3), the formula is as follows: ; In the formula, These are the learnable scaling parameters in the StyleGAN3 network. These are the learnable offset parameters in the StyleGAN3 network. This is a feature map of defect residuals.
[0035] in, This determines the direction of modulation (i.e., the specific appearance of the defect), and It provides the location and intensity of the modulation (i.e., the boundary and extent of the defect).
[0036] Furthermore, regarding feature fusion, the predicted modulation parameters are used to perform adaptive normalization on the object features, thereby softly embedding defect information into the object features: ; In the formula, Norm is the normalization operation. The characteristics after fusion These are the characteristics of the original object.
[0037] exist During the prediction process, the area outside the forced mask is... Approaching 1.0, Approximately 0 to ensure it has no impact on object features. After modulation-normalized fusion, soft mask weights (e.g., those after Sigmoid processing) are used. To blend the features of the original object and the characteristics after fusion By modulating, the defect features dynamically change the object features in terms of channel statistics (mean and variance), so that the color, lighting and texture of the defects can be smoothly integrated into the background, avoiding the abruptness caused by hard addition.
[0038] Furthermore, the method also includes adversarial training using dual discriminators, wherein the first discriminator is used to determine the authenticity of the image, and the second discriminator is used to determine whether the generated defect image matches the defect mask.
[0039] Specifically, the first discriminator is directly transferred from the first stage and only requires fine-tuning for defective image discrimination; however, it only focuses on "image authenticity" and cannot determine whether the mask is reasonable. It essentially retains the structure of the original StyleGAN3 discriminator. It is a standard convolutional neural network used to progressively downsample feature maps from high resolution and ultimately output a score to determine whether an image is real or fake. In the first stage, it is pre-trained on defect-free images along with the StyleGAN3 backbone network. In the second stage, it is fine-tuned to provide adversarial supervision for defective images.
[0040] The second discriminator is a defect matching discriminator. This is responsible for determining whether the generated defect image and its corresponding defect mask match precisely. It receives the generated defect image and the generated defect mask, concatenates them, and then feeds them into the discriminator. Its structure is similar to the first discriminator, but because determining whether the image and mask match is "easier" than determining the image's authenticity, the defect matching discriminator... The number of parameters in each layer has been reduced. Simultaneously, to accommodate training with small sample sizes, the number of parameters in this discriminator is significantly reduced compared to the original StyleGAN3. This discriminator provides supervision of the defect mask, ensuring that the generated defect mask accurately delineates the defect region, which is crucial for downstream tasks requiring defect localization (such as insulator defect segmentation). Through this dual supervision, the network presented in this embodiment can generate defect images with both high realism and accurate defect localization capabilities even with only a small number of defect samples.
[0041] To further improve the controllability of the generated images, this embodiment introduces a multi-condition constraint control mechanism. By controlling the multi-dimensional condition variables input to the generator, the type, location, size, and other characteristics of the generated defects can be precisely controlled. This constraint not only enhances the diversity of the generated images but also ensures that the generated defect images meet specific application requirements.
[0042] Defect type control enables the generator to produce images of different types of defects based on preset conditions. For example, common defect types in electrical equipment include cracks, corrosion, burns, and dirt. Each defect type has different shapes, textures, and features. By introducing defect type labels, the generator can accurately generate defect images that conform to specific types.
[0043] The implementation methods for defect type control include: condition variable injection and type selection mechanism. Condition variable injection involves injecting defect type labels (such as cracks, corrosion, burns, etc.) as conditional information into the generator, and the generator generates defects of the corresponding type based on these conditions. The type selection mechanism, through the control of condition variables, allows the generator to select and generate specific types of defects, ensuring that the type of the generated image is consistent with the target.
[0044] Defects in electrical equipment often have a clear spatial location; for example, cracks typically appear in weak points of the equipment, while corrosion may occur in high-temperature or high-pressure areas. To ensure that the generated defect image conforms to the actual structure and fault distribution of the equipment, the generator can precisely control the location of the defect in the image through defect location masks or coordinate input.
[0045] Implementation methods for defect location control: Location mask: By providing a location mask for each image, the generator can generate defects within a specified area. The mask defines the specific location and shape of the defect.
[0046] Coordinate input: The generator can also precisely control the spatial distribution of defects by inputting coordinates (such as the start and end points of the defects).
[0047] Furthermore, the generative model in this embodiment is based on a Generative Adversarial Network (GAN) architecture and incorporates various optimization strategies to improve the quality, realism, and diversity of the generated defective images. The training and optimization process includes the following key strategies: Contrastive Learning Mechanism: Contrastive learning mechanisms enhance the discriminative power of samples by maximizing the distance between positive and negative samples. In this embodiment, the generator not only needs to generate realistic images, but also needs to ensure that the similarity between the generated images and real images in the feature space is maximized, and that it can effectively distinguish different defect types and device categories.
[0048] Implementation method: (1) Definition of positive and negative samples: During training, positive samples refer to real defect images, while negative samples refer to pseudo images generated by the generator. Through contrastive learning, the generator can learn how to generate pseudo images that are as close as possible to real images in the feature space.
[0049] (2) Loss Function Design: A contrastive loss function (or other loss function) is used to measure the distance between the generated image and the real image. The specific mathematical representation of the contrastive loss function is as follows: ; In the formula, To compare loss functions, and The first i Feature representations of real images and feature representations of generated images for each sample These are labels (1 represents a positive sample, and 0 represents a negative sample). The threshold controls the minimum distance between positive and negative samples. N This refers to the number of samples used in a single calculation.
[0050] By maximizing the feature differences between positive and negative samples, the generator can learn more accurate generation rules, making the details and overall structure of the generated image closer to the real sample.
[0051] Feature consistency loss is used to ensure that the features of the generated image in the intermediate layers match those of the real sample, avoiding mode collapse during the generation process. This method helps the model maintain the diversity and high quality of the generated images.
[0052] Intermediate layer feature matching: During the training of the generative network, the differences between the feature maps extracted from the generated image and the real image in multiple convolutional layers (intermediate layers) are calculated. By minimizing this difference, it is ensured that the feature distribution of the generated image is similar to that of the real image.
[0053] Feature consistency loss ensures that the generated image not only approximates the real image at the pixel level, but also maintains consistency in the high-level feature space, preventing the generated image from losing details or exhibiting unnatural patterns.
[0054] The network architecture proposed in this embodiment effectively solves the problem of abrupt defect boundary transitions caused by traditional residual addition by combining defect-aware residual blocks with a modulation normalization module conditioned on a mask. This allows the generated defect textures to blend smoothly into the background area, significantly improving the visual realism of defect images. In the dual discriminator mechanism, the image real / fake discriminator provides adversarial supervision to ensure the overall realism of the generated images, while the defect matching discriminator achieves precise control over defect localization accuracy through the splicing input of the image and mask. The synergistic effect of the two allows the generated images to maintain both high realism and accurate defect localization even under small sample training. The multi-condition constraint control mechanism achieves precise control over key features such as defect type, location, and size through defect type label injection and location mask and coordinate input, greatly enhancing the diversity and application adaptability of the generated images. The introduction of the contrastive learning mechanism and feature consistency loss further promotes the deep matching of the generated images with real samples in the feature space, effectively avoiding pattern collapse and comprehensively improving the generation quality and controllability of defect images.
[0055] Traditional defect image generation methods often rely on large-scale labeled defect data for model training, which faces challenges such as difficult data acquisition and high labeling costs in real-world industrial scenarios. This embodiment, however, introduces a defect-aware residual block and a modulation normalization module, combined with a dual discriminator mechanism and multi-condition constraint control, to construct an efficient small-sample defect image generation framework. This framework requires only a small number of real defect samples as references to generate a large number of highly realistic and diverse defect images through learning and optimization by a generative adversarial network. Specifically, the contrastive learning mechanism maximizes the feature distance between positive and negative samples, helping the generator quickly capture the distribution patterns of defect features with limited samples; feature consistency loss ensures that the generated images remain consistent with real samples in the intermediate layer feature space, avoiding pattern homogenization due to insufficient samples. This small-sample learning capability significantly reduces the model's requirement for defect samples, effectively alleviating the pain point of data scarcity in the field of industrial defect detection and providing a feasible path to solve the problem of difficult defect sample acquisition in actual production.
[0056] The defect images generated by this invention possess high realism and accurate defect localization capabilities, providing high-quality and diverse training data for downstream defect detection algorithms. By controlling the generation of defect images of different types, locations, and sizes through multi-condition constraints, the generalization recognition ability of detection models for various types of defects can be effectively improved. Simultaneously, accurate defect mask information also provides reliable annotation basis for semi-supervised or weakly supervised defect detection tasks, helping to reduce the training difficulty of downstream detection models, improve detection accuracy and efficiency, and promote the practical application and development of industrial defect detection technology.
[0057] The above are merely preferred embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for generating insulator defects based on small samples, characterized in that, include: The pre-trained StyleGAN3-T generative model is used as the backbone synthesis network to generate normal insulator images; During the process of generating images by the backbone synthesis network, when the resolution reaches or exceeds the preset resolution, the backbone synthesis network generates an object feature map at the current resolution based on the input feature map. The object feature map represents the content of a defect-free insulator image. A defect-aware residual block is introduced. Based on the defect-aware residual block, the same input feature map as the backbone synthesis network is processed to output a defect residual feature map. The corresponding defect mask is generated through the ToMask module. The randomly sampled defect codes are input into the defect mapping network, and the output is the modulation weights used to control the defect features; Using the defect mask and the modulation weights, the defect residual feature map and the object feature map are adaptively fused through a modulation normalization module conditioned on the mask to obtain a fused feature map. An insulator image containing controllable defects is generated based on the fused feature map; Specifically, the ToMask module generates the corresponding defect mask, as follows: ; In the formula, For defect mask, This is a feature map of defect residuals.
2. The insulator defect generation method based on small samples according to claim 1, characterized in that, The defect mask is used to delineate the defect region and to display the defect residual feature map corresponding to the defect pixel. Add to target feature map Above, specifically: ; In the formula, For any pixel on the combined feature map, For the mask coverage of any pixel, For any pixel on the target feature map, For any pixel on the defect residual feature map.
3. The insulator defect generation method based on small samples according to claim 1, characterized in that, The processing steps of the modulation normalization module include: The defect residual feature map and the defect mask are input into the prediction network to obtain scaling parameters and offset parameters. The object feature map is subjected to feature normalization processing to obtain normalized features; The normalized features are modulated based on the scaling and offset parameters; Using a softened defect mask as weights, the modulated features are weighted and fused with the object feature map to generate the fused feature map.
4. The insulator defect generation method based on small samples according to claim 3, characterized in that, Obtaining the normalized features includes: ; In the formula, Norm is the normalization operation. The characteristics after fusion These are the learnable scaling parameters in the StyleGAN3 network. These are the learnable offset parameters in the StyleGAN3 network. These are the characteristics of the original object.
5. The insulator defect generation method based on small samples according to claim 1, characterized in that, The method further includes adversarial training using dual discriminators, wherein the first discriminator is used to determine the authenticity of the image, and the second discriminator is used to determine whether the generated defect image matches the defect mask.
6. The insulator defect generation method based on small samples according to claim 5, characterized in that, The second discriminator has fewer network parameters than the first discriminator, and the input to the second discriminator is a tensor formed by stitching the generated defect image and the defect mask along the channel dimension.
7. The insulator defect generation method based on small samples according to claim 6, characterized in that, During training, a contrastive loss function is used to measure the distance between the generated image and the real image, specifically: ; In the formula, To compare loss functions, and The first i Feature representations of real and generated images for each sample It's a tag. For the threshold, N This refers to the number of samples used in a single calculation.
8. The method for generating insulator defects based on small samples according to claim 1, characterized in that, The method also includes multi-condition constraint control, which controls the type and / or location of generated defects by injecting multi-dimensional condition variables into the backbone synthesis network; wherein the defect type is controlled by category label and the defect location is controlled by location mask or spatial coordinates.