Power equipment defect enhancement and generation method and system based on stable diffusion model
Through the power equipment defect enhancement and generation method based on the stable diffusion model, the problems of scarcity of power equipment defect samples and unbalanced categories are solved, and efficient and stable quality defect data set construction and model optimization are achieved.
Patent Information
- Application Number
- CN202411841432.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-04-08
AI Technical Summary
The prior art is difficult to effectively solve the problems of scarce samples of power equipment, unbalanced categories and insufficient data generation methods, resulting in the limitation of the training and application of defect detection models.
The power equipment defect enhancement and generation method based on the stable diffusion model is adopted, and high-quality and controllable defect samples are generated by training the language text model and the stable diffusion generation model, combined with the semantic guidance mechanism.
It significantly improves the construction efficiency and quality of power equipment defect data sets, improves the performance and application effect of defect detection models, and has good versatility and practical value.
Smart Images

Figure CN119785143A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision technology, and in particular to a method and system for enhancing and generating defects of power equipment based on a stable diffusion model. Background Art
[0002] In the field of power inspection defect detection, training high-performance defect detection models relies on a large amount of representative and diverse defect sample data. However, there are many challenges in the construction of defect sample data sets, which seriously restricts the training and application of models. First, defect samples are extremely scarce in many power equipment scenarios, especially equipment defects in certain specific scenarios are difficult to obtain, resulting in data scale that is difficult to meet the needs of model training and optimization. Secondly, power equipment is often in a high-voltage or ultra-high-voltage environment, and the data collection process places strict requirements on the safety of personnel. At the same time, the deployment and operation of the collection equipment are also difficult. Finally, the category distribution of power equipment defect data sets generally presents a highly unbalanced distribution, with some common defect category samples occupying most of the data, while the number of rare defect category samples is extremely scarce. This imbalance in sample distribution directly leads to a low detection rate of the model in scarce defect categories, which seriously limits the actual application effect of the model's performance.
[0003] Existing defect data expansion and generation methods have obvious limitations and are difficult to effectively solve the above problems. The traditional direct defect pasting method extracts the defect area from the original sample and pastes it into the new sample. Although this can increase the number of defective samples, the degree of natural fusion between the defect and the background image is low, which easily introduces artifacts or unreal features, weakening the effectiveness of data samples in model training. On the other hand, the defect sample generation method of the traditional generative model can directly generate defective samples, but the defect morphology and category generated are often uncontrollable, making it difficult to meet the targeted and directional data balance requirements, and unable to accurately supplement scarce categories.
[0004] Therefore, the prior art has defects and needs to be improved. Summary of the invention
[0005] The technical problem to be solved by the present invention is: to provide a method and system for enhancing and generating defects in power equipment based on a stable diffusion model, in view of the current situation of scarce power equipment defect samples, unbalanced categories and insufficient data generation methods, an innovative data expansion technology with controllable defect categories and morphologies is provided to efficiently support the training and optimization of power equipment defect detection models.
[0006] The technical solution of the present invention is as follows: a method for enhancing and generating defects of power equipment based on a stable diffusion model is provided, comprising the following steps:
[0007] S1: Collect data samples of normal and defective types of power equipment, and classify the data according to the rules.
[0008] S2: Obtaining power equipment defect image set D image , defect category description text set D text and defect area mask annotation set D mask .
[0009] S3: Training language text model M Clip And represent the text description as a semantic vector Context.
[0010] S4: Train a stable diffusion generation model to generate defect samples, using forward diffusion noise addition, reverse process denoising, and cross-attention to enhance the U-Net network.
[0011] S5: Add shape constraints of the regional position mask information and semantic prompt word description constraints for generating defects to guide the defect generation model to generate data samples.
[0012] The method for enhancing and generating defects of electric power equipment based on the stable diffusion model specifically comprises the following steps:
[0013] S1: Collect data samples of normal and defective types of power equipment in various scenarios, and sort the data according to the positive sample D p and negative samples D n The defect types are classified in a certain way.
[0014] S2: Obtain the power equipment defect image set D through data samples image , defect category description text set D text and defect area mask annotation set D mask .
[0015] S3: Training language text model M Clip The description of the power equipment defect category is embedded into a semantic vector Context representing text information.
[0016] S4: The processed image data is mapped from the pixel space to the latent vector space through an autoencoder, noise is added to the latent data during the forward diffusion process, the latent data noise is removed during the reverse process, and the denoising ability is enhanced using the cross-attention mechanism U-Net network, which transforms the internal diffusion model into a conditional image generator to train the defect generation model.
[0017] S5: Add shape constraints of regional location mask information and semantic prompt description constraints of generated defects to the trained defect generation model, guide the defect generation model to generate data samples in the direction of regional controllability and quality stability, and finally expand the equipment defect samples to improve the training effect of the patrol system algorithm.
[0018] In step S3, the language text model M is trained Clio It includes an image encoder Image encoder and a text encoder Text encoder, adopting the classic dual-tower model architecture.
[0019] From the defect image set D image and defect category description text set D text Randomly sample samples from and, when the sampled image sample matches the description text, it is considered a positive sample, and when it does not match, it is considered a negative sample; then the extracted positive and negative samples are encoded by the image encoder and the text encoder to linearly project the feature vector and L2 normalize, and finally the image embedding vector and the text embedding vector are obtained; finally, the cosine similarity is used to obtain the similarity matrix of the image embedding vector and the text embedding vector, and then the image-to-text cross entropy loss and the text-to-image cross entropy loss function are used to train and optimize the Clip model; the calculation of the similarity matrix S is:
[0020]
[0021] Among them, the element S ij It represents the similarity between the i-th image sample and the j-th text sample, where the image and text codes are I and T respectively.
[0022] The image-to-text cross entropy loss is calculated as follows:
[0023] loss i =cross_entropy_loss(S, label, axis=0);
[0024] The cross entropy loss for text to image is calculated as follows:
[0025] loss t =cross_entropy_loss(S, label, axis=1).
[0026] In step S4, the image data is mapped from the pixel space to the latent vector space by using the Auto Encoder to map the input image from the pixel space to the latent vector space, and convert the RGB image to the latent vector expression, so that the auto encoder reduces the dimension of the input image tensor to obtain the latent vector, and the forward diffusion process and the reverse denoising process are both performed in the latent vector space. In the forward diffusion process, the input image I i Gaussian noise is gradually added. This process will be performed for K rounds, generating a series of noise samples (I1, I2, ..., I K ), the process of adding noise forward can be described as:
[0027]
[0028] where k∈(0,K),I k is a data sample sampled from the true data distribution q(I), β k is the variance schedule, β k ∈(0,1) and β0 is small, β K is larger, and E represents the identity matrix.
[0029] Using the reparameterization trick we get a vector that depends only on the input image I k The formula is:
[0030]
[0031] The above formula can be used to directly calculate I at any time round k k Sampling can greatly improve the execution efficiency of the diffusion model.
[0032] The goal of the reverse diffusion process can be described as:
[0033]
[0034] Therefore, the neural network p is trained in the reverse diffusion process θ (I k-1 |I k ) to approximate the target q - (I k-1 |I k ):
[0035]
[0036] Among them, (I|I k ) obeys the normal distribution, and its mean and variance satisfy:
[0037]
[0038] The internal diffusion model is transformed into a conditional image generator by enhancing its denoising U-Net with a criss-cross attention mechanism.
[0039] For the language text model M Clip The input text embedding vector is then mapped to the U-Net layer through the multi-head attention mechanism Attention (Q, K, V) and can achieve stable diffusion for image generation based on the content of the input text embedding vector. The loss function L of the final training stable diffusion model is LDT is a measure of the inverse process distribution q - (I k-1 |I k ) and the model estimated distribution p θ (I k-1 |I k ) and is expressed as:
[0040] L LDT =D KL (q - (I k-1 |I k ,I0)||p θ (I k-1 |I k )), 0≤k≤K.
[0041] In step S5, for any image data I i The shape constraint of the regional position mask information added to the image and the defect semantic prompt word description constraint are finally generated through the model to generate defect images of corresponding categories and positions. This process can be described as:
[0042]
[0043] Among them, ∈ is a random variable with standard normal distribution, ∈0 represents the deep neural network used to predict noise, and q + (I k ) is the forward noise adding process, pro and mask represent shape constraints and description constraints respectively.
[0044] The present invention also provides a system for enhancing and generating defects of electric equipment based on a stable diffusion model, which is used to automatically complete the aforementioned method for enhancing and generating defects of electric equipment based on a stable diffusion model; and comprises the following modules:
[0045] Data upload module: used to upload the collected normal equipment data samples and defect data samples to the system database for storage, and supports uploading multiple data file formats. Through this module, users can easily manage and import image data from multiple sources, providing basic data support for subsequent processing and generation.
[0046] Data processing and extraction module: used to perform pre-reasoning defect annotation, defect area reasoning characterization, and defect type pre-reasoning description on the uploaded data samples;
[0047] Pre-inference defect labeling: Based on the preset model algorithm, pre-inference preliminary labeling of defect areas of data samples is performed; the model algorithm used is: any one of the YOLO series models, convolutional neural network, autoencoder, Transformer visual detection, and generative adversarial network.
[0048] Defect area reasoning and characterization: Accurately infer the specific area range of the defect and generate the corresponding area mask.
[0049] Defect type pre-inference description: Automatically classify and describe defect types to generate preliminary identification of defect categories.
[0050] After the processing is completed, the preprocessing results will be automatically assigned to the management personnel for review and modification; when the reviewer approves, the equipment defect image set Dimage, defect category description text set Dtext and defect area mask set Dmask annotation set are automatically divided to realize automatic extraction of data sets.
[0051] Model fine-tuning module: It is used by image generators to specifically fine-tune the stable diffusion generation model according to parameters such as the distribution characteristics of the batch of image data, data scale, sampler frequency, noise quality, and defect generation degree, so as to improve the model's generation performance for the batch of data.
[0052] Image generation module: used to generate the required defect images using the fine-tuned stable diffusion generation model.
[0053] The image generation module generates images by selecting the defect samples to be generated, the shape constraints of the defect generation model to add the regional position mask information, and the semantic prompt word prompt description constraints of the generated defects, and sets the sampling frequency, generation degree, knowledge base ratio and other parameters to generate defect images.
[0054] By adopting the above scheme, the present invention provides a method and system for enhancing and generating defects of power equipment based on a stable diffusion model, which has the following technical effects: by combining a stable diffusion model with a semantic guidance mechanism, the deficiencies of traditional defect data enhancement methods in terms of sample scarcity, category uncontrollability, and unstable generation quality are overcome. Through a standardized automation system and an innovative generation method, this application significantly improves the efficiency and quality of constructing defect data sets for power equipment, provides strong support for the optimization of defect detection models, and has good versatility and practical value. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 is a flow chart of the method of the present invention;
[0056] Figure 2 It is a functional module diagram of the system of the present invention;
[0057] Figure 3 This is a schematic diagram for explaining the Clip model;
[0058] Figure 4 This is the Latent space model architecture diagram; DETAILED DESCRIPTION
[0059] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments.
[0060] See also Figure 1-Figure 4 The present invention provides a method for enhancing and generating defects of power equipment based on a stable diffusion model, comprising the following steps:
[0061] S1: Collect data samples of normal and defective types of power equipment, and classify the data according to the rules.
[0062] S2: Obtaining power equipment defect image set D image , Defect category description text set D text and defect area mask annotation set D mask .
[0063] S3: Training language text model M Clip And represent the text description as a semantic vector Context.
[0064] S4: Train a stable diffusion generation model to generate defect samples, using forward diffusion noise addition, reverse process denoising, and cross-attention to enhance the U-Net network.
[0065] S5: Add shape constraints of the regional position mask information and semantic prompt word description constraints for generating defects to guide the defect generation model to generate data samples.
[0066] The method for enhancing and generating defects of electric power equipment based on a stable diffusion model comprises the following steps:
[0067] S1: Collect data samples of normal and defective types of power equipment in various scenarios, and sort the data according to the positive sample D p and negative samples D n The defect types are classified in a certain way.
[0068] S2: Obtain the power equipment defect image set D through data samples image , Defect category description text set D text and defect area mask annotation set D mask .
[0069] S3: Training language text model M Clip The description of the power equipment defect category is embedded into a semantic vector Context representing text information.
[0070] S4: The processed image data is mapped from the pixel space to the latent vector space through an autoencoder, noise is added to the latent data during the forward diffusion process, the latent data noise is removed during the reverse process, and the denoising ability is enhanced using the cross-attention mechanism U-Net network, which transforms the internal diffusion model into a conditional image generator to train the defect generation model.
[0071] S5: Add shape constraints of regional location mask information and semantic prompt description constraints of generated defects to the trained defect generation model, guide the defect generation model to generate data samples in the direction of regional controllability and quality stability, and finally expand the equipment defect samples to improve the training effect of the patrol system algorithm.
[0072] In the invention, through S1 and S2, a power equipment defect image set D is obtained. image , Defect category description text set D text and defect area mask set D mask Annotation set; S3 training language text large model M ClipDescription converts the text set into a semantic embedding vector, uses the similarity matrix to optimize the model training, provides semantic guidance for subsequent image generation, and effectively solves the problem that the defect morphology and category of traditional generation are often uncontrollable; S4 provides a method for training a stable diffusion model, which uses an autoencoder to map the processed image data from the pixel space to the latent vector space, effectively reducing the data dimension and retaining key features. In the forward diffusion process, noise is added to the potential data, and in the reverse process, the potential data noise is removed, and the cross-attention mechanism is used to enhance the denoising ability of the U-Net network, so as to obtain a model that can generate high-quality, reasonable and reliable defect samples, effectively improving the generation stability and data reliability of the equipment defect data set; S5 adds the shape constraint of the regional position mask information and the semantic prompt word prompt description constraint of the generated defect, and controls the specific location of the defect generation through the mask shape constraint to ensure that the generated sample meets the actual scene requirements. The defect category and morphology of the generated sample are constrained by the prompt word description constraint, ensuring the controllability and specificity of the generated result. The proposed method significantly improves the quality stability and applicability of the generated samples, and provides a flexible and efficient solution for the data expansion of scarce defect categories.
[0073] In step S3, the language text model M is trained Clip It includes an image encoder Image encoder and a text encoder Text encoder, adopting the classic dual-tower model architecture.
[0074] From the defect image set D imgae and defect category description text set D text Randomly sample samples from and, when the sampled image sample matches the description text, it is considered a positive sample, and when it does not match, it is considered a negative sample; then the extracted positive and negative samples are encoded by the image encoder and the text encoder to linearly project the feature vector and L2 normalize, and finally the image embedding vector and the text embedding vector are obtained; finally, the cosine similarity is used to obtain the similarity matrix of the image embedding vector and the text embedding vector, and then the image-to-text cross entropy loss and the text-to-image cross entropy loss function are used to train and optimize the Clip model; the calculation of the similarity matrix S is:
[0075]
[0076] Among them, the element S ij It represents the similarity between the i-th image sample and the j-th text sample, where the image and text codes are I and T respectively.
[0077] The image-to-text cross entropy loss is calculated as follows:
[0078] lossi =cross_entropy_loss(S, label, axis=0);
[0079] The cross entropy loss for text to image is calculated as follows:
[0080] loss t =cross_entropy_loss(S,lael,axis=1).
[0081] In step S4, the image data is mapped from the pixel space to the latent vector space by using the AutoEncoder to map the input image from the pixel space to the latent vector space, and convert the RGB image to the latent vector expression, so that the autoencoder reduces the dimension of the input image tensor to obtain the latent vector, and the forward diffusion process and the reverse denoising process are both performed in the latent vector space. In the forward diffusion process, the input image I i Gaussian noise is gradually added. This process will be performed for K rounds, generating a series of noise samples (I1, I2, ..., I K ), the process of adding noise forward can be described as:
[0082]
[0083] where k∈(0,K),I k is a data sample sampled from the true data distribution q(I), β k is the variance schedule, β k ∈(0,1) and β0 is small, β R is larger, and E represents the identity matrix.
[0084] Using the reparameterization trick we get a vector that depends only on the input image I k The formula is:
[0085]
[0086] The above formula can be used to directly calculate I at any time round k k Sampling can greatly improve the execution efficiency of the diffusion model.
[0087] The goal of the reverse diffusion process can be described as:
[0088]
[0089] Therefore, the neural network p is trained in the reverse diffusion process θ (I k-1 |I k ) to approximate the target q - (I k-1 |Ik ):
[0090]
[0091] Among them, (I|I k ) obeys the normal distribution, and its mean and variance satisfy:
[0092]
[0093] The internal diffusion model is transformed into a conditional image generator by enhancing its denoising U-Net with a criss-cross attention mechanism.
[0094] For the language text model M Clip The input text embedding vector is then mapped to the U-Net layer through the multi-head attention mechanism Attention (Q, K, V) and can achieve stable diffusion for image generation based on the content of the input text embedding vector. The loss function L of the final training stable diffusion model is LDT is a measure of the inverse process distribution q - (I k-1 |I k ) and the model estimated distribution p θ (I k-1 |I k ) and is expressed as:
[0095] L LDT =D KL (q-(I k-1 |I k ,I0)||p θ (I k-1 |I k )), 0≤k≤K.
[0096] In step S5, for any image data I i The shape constraints of the regional position mask information added to the image and the defect semantic prompt word description constraints are finally generated through the model to generate defect images of the corresponding categories and positions. This process can be described as:
[0097]
[0098] Among them, ∈ is a random variable with standard normal distribution, ∈0 represents the deep neural network used to predict noise, and q + (I k ) is the forward noise adding process, pro and mask represent shape constraints and description constraints respectively.
[0099] The present invention also provides a system for enhancing and generating defects of electric equipment based on a stable diffusion model, which is used to automatically complete the aforementioned method for enhancing and generating defects of electric equipment based on a stable diffusion model; and comprises the following modules:
[0100] Data upload module: used to upload the collected normal equipment data samples and defect data samples to the system database for storage, and supports uploading multiple data file formats. Through this module, users can easily manage and import image data from multiple sources, providing basic data support for subsequent processing and generation.
[0101] Data processing and extraction module: used to perform pre-reasoning defect annotation, defect area reasoning characterization, and defect type pre-reasoning description on the uploaded data samples;
[0102] Pre-inference defect labeling: Based on the preset model algorithm, pre-inference preliminary labeling of defect areas of data samples is performed; the model algorithm used is: any one of the YOLO series models, convolutional neural network, autoencoder, Transformer visual detection, and generative adversarial network.
[0103] Defect area reasoning and characterization: Accurately infer the specific area range of the defect and generate the corresponding area mask.
[0104] Defect type pre-inference description: Automatically classify and describe defect types to generate preliminary identification of defect categories.
[0105] After the processing is completed, the pre-processing results are automatically assigned to the management personnel for review and modification; when the reviewer passes, the equipment defect image set D is automatically divided image , Defect category description text set D text and defect area mask set D mask Annotation set, to achieve automated extraction of data sets.
[0106] Model fine-tuning module: It is used by image generators to specifically fine-tune the stable diffusion generation model according to parameters such as the distribution characteristics of the batch of image data, data scale, sampler frequency, noise quality, and defect generation degree, so as to improve the model's generation performance for the batch of data.
[0107] Image generation module: used to generate the required defect images using the fine-tuned stable diffusion generation model.
[0108] The system of the present invention realizes the enhancement and generation of power equipment defect data in a standardized and automated manner, including a data uploading module, a data processing and extraction module, a model fine-tuning module, and an image generation module, thereby obtaining a generation model that is fine-tuned and stably generated with semantic guidance.
[0109] The image generation module generates images by selecting the defect samples to be generated, the shape constraints of the defect generation model to add the regional position mask information, and the semantic prompt word prompt description constraints of the generated defects, and sets the sampling frequency, generation degree, knowledge base ratio and other parameters to generate defect images.
[0110] In summary, the present invention provides a method and system for enhancing and generating defects of power equipment based on a stable diffusion model, which has the following technical effects: by combining a stable diffusion model with a semantic guidance mechanism, the deficiencies of traditional defect data enhancement methods in terms of sample scarcity, category uncontrollability, and unstable generation quality are overcome. Through a standardized automation system and an innovative generation method, this application significantly improves the efficiency and quality of constructing defect data sets for power equipment, provides strong support for the optimization of defect detection models, and has good versatility and practical value.
[0111] The above are only preferred embodiments of the present invention and are not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for enhancing and generating defects in power equipment based on a stable diffusion model, characterized in that: The following steps are involved: S1: Collect data samples of normal and defective types of power equipment and classify the data according to the rules; S2: Obtaining power equipment defect image set D tmage , defect category description text set D text and defect area mask annotation set D mask ; S3: Training language text model M Clip And represent the text description as a semantic vector Context; S4: Train the stable diffusion generation model to generate defect samples, using forward diffusion denoising, reverse process denoising and cross attention to enhance the U-Net network; S5: Add shape constraints of the regional position mask information and semantic prompt word description constraints for generating defects to guide the defect generation model to generate data samples.
2. The method for enhancing and generating defects of power equipment based on a stable diffusion model according to claim 1, characterized in that: The specific steps include: S1: Collect data samples of normal and defective types of power equipment in various scenarios, and sort the data according to the positive sample D p and negative samples D n Classify defect types in a certain way; S2: Obtain the power equipment defect image set D through data samples image , Defect category description text set D text and defect area mask annotation set D mask ; S3: Training language text model M Clip The description of the power equipment defect category is embedded into a semantic vector Context representing text information; S4: Map the processed image data from pixel space to latent vector space through an autoencoder, add noise to the latent data during the forward diffusion process, remove the latent data noise during the reverse process, and use the cross-attention mechanism to enhance the denoising ability of the U-Net network, transform the internal diffusion model into a conditional image generator, and thus train the defect generation model; S5: Add shape constraints of regional location mask information and semantic prompt description constraints of generated defects to the trained defect generation model, guide the defect generation model to generate data samples in the direction of regional controllability and quality stability, and finally expand the equipment defect samples to improve the training effect of the patrol system algorithm.
3. The method for enhancing and generating defects of power equipment based on a stable diffusion model according to claim 1, characterized in that: In step S3, the language text model M is trained Clip It includes an image encoder Image encoder and a text encoder Text encoder, adopting the classic dual-tower model architecture.
4. The method for enhancing and generating defects of power equipment based on a stable diffusion model according to claim 3, characterized in that: From the defect image set D image and defect category description text set D text Randomly sample samples from and, when the sampled image sample matches the description text, it is considered a positive sample, and when it does not match, it is considered a negative sample; then the extracted positive and negative samples are encoded by the image encoder and the text encoder to linearly project the feature vector and L2 normalize, and finally the image embedding vector and the text embedding vector are obtained; finally, the cosine similarity is used to obtain the similarity matrix of the image embedding vector and the text embedding vector, and then the image-to-text cross entropy loss and the text-to-image cross entropy loss function are used to train and optimize the Clip model; the calculation of the similarity matrix S is: Among them, the element S ij It represents the similarity between the i-th image sample and the j-th text sample, where the image and text codes are I and T respectively. The image-to-text cross entropy loss is calculated as follows: loss i =cross_entropy_loss(S,lobel,axis=0); The cross entropy loss for text to image is calculated as follows: loss t =cross_entropy_loss(S,label,axts=1)。 5. The method for enhancing and generating defects of power equipment based on a stable diffusion model according to claim 2, characterized in that: In step S4, the image data is mapped from the pixel space to the latent vector space by using the Auto Encoder to map the input image from the pixel space to the latent vector space, and convert the RGB image into an implicit vector expression, so that the auto encoder reduces the dimension of the input image tensor to obtain a latent vector, and the forward diffusion process and the reverse denoising process are both performed in the latent vector space.
6. A method for enhancing and generating defects of power equipment based on a stable diffusion model according to claim 5, characterized in that: In the forward diffusion process, the input image I i Gaussian noise is gradually added. This process will be performed for K rounds, generating a series of noise samples (I1, I2, ..., I K ), the process of adding noise forward can be described as: where k∈(0,K),I k is a data sample sampled from the true data distribution q(I), β k is the variance schedule, β k ∈(0,1) and β0 is small, β K is larger, E represents the identity matrix; Using the reparameterization trick we get a vector that depends only on the input image I k The formula: The above formula can be used to directly calculate I at any time round k k Sampling can greatly improve the execution efficiency of the diffusion model; The goal of the reverse diffusion process can be described as: Therefore, the neural network p is trained in the reverse diffusion process e (I k-1 |I k ) to approximate the target q - (I k-1 |I k ): Among them, (I|I k ) obeys the normal distribution, and its mean and variance satisfy: Transform the internal diffusion model into a conditional image generator by enhancing its denoising U-Net with a cross-attention mechanism; For the language text model M Clip The input text embedding vector is then mapped to the U-Net layer through the multi-head attention mechanism Attelon (Q, K, V) and can achieve stable diffusion of image generation based on the content of the input text embedding vector; the loss function L of the final training stable diffusion model is LDF is a measure of the inverse process distribution q - (I k-1 |I k ) and the model estimated distribution p p (I k-1 |I k ) and is expressed as: L LDT =D KL (q - (I k-1 |I k ,I0)||p θ (I k-1 |I k )),0≤k≤K。 7. The method for enhancing and generating defects of power equipment based on a stable diffusion model according to claim 1, characterized in that: In step S5, for any image data I i The shape constraints of the regional position mask information added to the image and the defect semantic prompt word description constraints are finally generated through the model to generate defect images of the corresponding categories and positions. This process can be described as: Among them, ∈ is a random variable with standard normal distribution, ∈0 represents the deep neural network used to predict noise, and q + (I k ) is the forward noise adding process, pro and mask represent shape constraints and description constraints respectively.
8. A power equipment defect enhancement and generation system based on a stable diffusion model, characterized in that: Used to automatically complete the method for enhancing and generating defects of power equipment based on a stable diffusion model as described in any one of claims 1 to 7; comprising the following modules: Data upload module: used to upload the collected normal equipment data samples and defect data samples to the system database for storage, and supports uploading multiple data file formats. Through this module, users can easily manage and import image data from multiple sources, providing basic data support for subsequent processing and generation; Data processing and extraction module: used to perform pre-reasoning defect annotation, defect area reasoning characterization, and defect type pre-reasoning description on the uploaded data samples; After the processing is completed, the pre-processing results are automatically assigned to the management personnel for review and modification; when the reviewer passes, the equipment defect image set D is automatically divided image , defect category description text set D text and defect area mask set D mask Annotation set, to achieve automated extraction of data sets; Model fine-tuning module: It is used by image generators to specifically fine-tune the stable diffusion generation model according to the distribution characteristics, data scale, sampler frequency, noise quality and defect generation degree parameters of the batch of image data, so as to improve the generation performance of the model for the batch of data; Image generation module: used to generate the required defect images using the fine-tuned stable diffusion generation model.
9. The power equipment defect enhancement and generation system based on the stable diffusion model according to claim 8, characterized in that: Pre-inference defect labeling: Based on the preset model algorithm, pre-inference preliminary labeling of defect areas of data samples is performed; the model algorithm used is: any one of the YOLO series models, convolutional neural network, autoencoder, Transformer visual detection, and generative adversarial network. Defect area reasoning and characterization: Accurately infer the specific area range of the defect and generate the corresponding area mask; Defect type pre-inference description: Automatically classify and describe defect types to generate preliminary identification of defect categories.
10. The power equipment defect enhancement and generation system based on the stable diffusion model according to claim 8, characterized in that: The image generation module generates pictures by selecting the defect samples to be generated, the shape constraints of the defect generation model to add the regional position mask information, and the semantic prompt word prompt description constraints of the generated defects, and sets the sampling frequency, generation degree, and knowledge base ratio parameters to generate defect pictures.
Citation Information
Cited By
Condition-controllable image sample expansion method and system for surface defect detection
CN120525000A
A condition-controllable image sample expansion method and system for surface defect detection
CN120525000B
Multi-modal large model-based cue word automatic generation model training method and system
CN121600511A
Construction method of power grid equipment defect training sample set and defect detection method thereof
CN121903945A
Method for constructing power grid equipment defect training sample set and defect detection method thereof
CN121903945B