Method and system for generating diffusion images of power equipment defects
By sub-region division and position encoding of normal original images of power equipment, combined with automatic encoder and multi-scale attention module, the defective images of power equipment are generated, which solves the problem of insufficient samples in the existing technology and improves the generalization ability of the model and defect identification effect.
Patent Information
- Application Number
- CN202411618092.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-13
- Publication Date
- 2025-02-18
- Estimated Expiration
- 2044-11-13
AI Technical Summary
In the prior art, in the detection of power equipment defects, the model training samples are insufficient, resulting in poor generalization capabilities of the model and it is difficult to effectively identify the defects of power equipment.
A method of generating image diffusion of power equipment defects is adopted. By obtaining the normal original image of power equipment, dividing it into sub-region images and performing position encoding, combining automatic encoder, multi-scale attention module and cross-attention module to generate high-quality and diverse Images of defects in power equipment.
This method can generate high-quality and diverse power equipment defect images, improve the sample richness and generalization ability of model training, and enhance the ability to identify power equipment defects.
Smart Images

Figure CN119130853B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electric power vision technology, and in particular to a method and system for generating a diffusion defect image of electric power equipment. Background Art
[0002] With the continuous development of my country's economy and society, the coverage area of power lines is becoming more and more extensive. In order to ensure the safety and stability of power supply, power lines need to be inspected regularly to promptly discover existing equipment defects and hidden dangers. As an efficient and convenient data collection tool, drones have been widely used in the power industry, and a large amount of inspection image data has been generated. However, the previous method of identifying equipment defects and hidden dangers by naked eyes was time-consuming and labor-intensive, and it was difficult to meet the needs of business development. Using artificial intelligence and computer vision technology to accurately detect equipment defects from inspection images has become the focus of attention in academia and industry. Artificial intelligence is a technology that is highly dependent on prior knowledge, that is, the premise that the algorithm model can identify defects in power equipment is that there are sufficient samples for it to learn, and the more samples, the better the training effect of the algorithm model, and the stronger the generalization ability. However, it is difficult to achieve this goal in the field of power facility monitoring: first, data annotation requires the experience of experts in the field, and it is necessary to be able to accurately distinguish similar equipment, normal and defective equipment, and the severity of defects; second, the number of defects in real scenarios is distributed in a long-tailed manner, and the number of defect types that are often focused on is often relatively scarce, making it difficult to ensure its training effect. In engineering applications, the tail defect image samples can be expanded through data enhancement, such as rotation, translation, scaling, mirror flipping, cropping, brightness, contrast, saturation adjustment, etc. However, this method essentially does not add new training samples and has limited effect on improving the generalization ability of the model.
[0003] In recent years, generative AI technologies represented by stable diffusion have made progress. Generating high-quality and diverse power equipment defect images through diffusion is a feasible way to solve the problem of insufficient training samples for power equipment defect detection models.
[0004] In view of this, it is necessary to propose a method and system for diffusion generation of defect images of electric power equipment to solve or at least partially solve the above technical problems. Summary of the invention
[0005] The main purpose of the present invention is to provide a method and system for the diffusion generation of defect images of power equipment, aiming to solve the technical problem that the prior art only relies on traditional methods to expand the defect image samples of power facilities, and the model generalization ability is poor when the expanded images are used for model training.
[0006] To achieve the above-mentioned object, the present invention provides a method for generating a diffusion defect image of an electric power equipment, comprising the steps of: S10, obtaining a normal original image of the electric power equipment, dividing the normal original image into a plurality of sub-region images and performing position encoding, and recording the corresponding relationship between the digital matrix position and the digital matrix content of each sub-region image in the sub-region sequence;
[0007] S20, an automatic encoder is used to reduce the dimension and map the normal original image and the proposed defect text prompt respectively, and the original feature map and text feature embedding in the low-dimensional space are obtained:
[0008] S30, adding Gaussian noise to the original feature map to obtain a noise feature map;
[0009] S40, using a multi-scale attention module based on dilated convolution to extract features from the noise feature map to obtain a first feature map containing multi-scale semantic information; using a spatial attention module to extract features from the noise feature map to obtain a second feature map focusing on the target area of the generation task;
[0010] S50, using a cross attention module to fuse the first feature map, the second feature map and the text feature embedding to obtain a fused feature map in a low-dimensional space;
[0011] S60, using a noise assessment model to guide the fusion feature map based on the position coding information to remove defect noise, and obtain a mapping feature map of a low-dimensional space of any resolution, wherein the position coding information includes a correspondence between the sub-region image and the digital matrix content;
[0012] S70, determining whether a preset termination condition is met, if the preset termination condition is met, proceeding to step S80, if the preset termination condition is not met, updating the mapping feature map to a noise feature map, and proceeding to steps S40 to S60;
[0013] S80, using a decoder to restore the mapped feature map to a three-dimensional space, and obtaining a power equipment defect diffusion image corresponding to the proposed defect text prompt.
[0014] Furthermore, step S10 specifically includes the steps of:
[0015] Obtain a three-dimensional array matrix of a normal original image of the power equipment, where the height of the three-dimensional array matrix is H, the width is W, the number of channels is 3, and both H and W are positive integers;
[0016] A sliding window with a size of m×m and a step length of n is used to divide the normal original image in the height direction and the width direction, and the divided sub-regions are combined to form a sub-region sequence, where m is a positive integer greater than or equal to 3, and n is a positive integer greater than or equal to 3;
[0017] The position code of each sub-region is calculated in turn using trigonometric functions to obtain the corresponding relationship between the position of the sub-region in the sub-region sequence and its content.
[0018] Furthermore, step S20 specifically includes:
[0019] An image encoder is used to reduce the dimension and map the normal original image to obtain the original feature map of the low-dimensional space;
[0020] A text encoder is used to reduce the dimension and map the proposed defect text prompts to obtain text feature embedding in a low-dimensional space.
[0021] Further, in step S30, Gaussian noise is added to the original feature map to obtain a noise feature map, wherein the mathematical expression of the noise addition process is:
[0022]
[0023] is the feature map after the t-th noise addition step; is a hyperparameter to control the noise intensity; It is the feature map obtained in the previous noise adding step of the t-th noise adding step; is Gaussian noise.
[0024] Furthermore, in step S40, “using a multi-scale attention module based on dilated convolution to extract features from the noise feature map to obtain a first feature map containing multi-scale semantic information” specifically includes:
[0025] Use 1×1 convolution to aggregate the noise feature map;
[0026] The aggregated noise feature map is processed by using several parallel dilated convolutions with different dilation rates to obtain several aggregated feature maps that integrate different receptive fields.
[0027] The weighted method is used to accumulate the aggregated feature maps to obtain feature maps with different receptive fields, where the weighted coefficients are learned during the model training phase;
[0028] Repeat the above steps to obtain the first feature map containing multi-scale semantic information.
[0029] Furthermore, in step S40, “using a spatial attention module to extract features from the noise feature map to obtain a second feature map focusing on the target area of the generation task” specifically includes:
[0030] The noise feature map is averaged in the channel dimension to obtain a compressed feature map with a channel number of 1;
[0031] The s×s×1 convolution is used to calculate the importance of different spaces in the compressed feature map to obtain a feature map containing spatial importance, where s is a positive integer greater than or equal to 3;
[0032] The feature map containing spatial importance is multiplied with the noisy feature map to obtain a second feature map with spatial attention.
[0033] Furthermore, through the projection matrix , projection matrix and the projection matrix The first feature map, the second feature map and the text feature embedding are mapped to obtain the query vector Q, the key vector K and the value vector V, where: , , ;
[0034] Perform dot product on the query vector Q and the key vector K, and obtain the attention weight through the ReLU function;
[0035] Multiply the attention weights by the value vector V and sum the results to get the fused feature map.
[0036] Furthermore, the defect noise distribution corresponding to the proposed defect text prompt is calculated through the noise estimation model;
[0037] Based on the position encoding information, the defect noise is subtracted from the fused feature map to obtain a mapping feature map of a low-dimensional space with arbitrary resolution;
[0038] Among them, the mathematical expression of the denoising process of defect noise is:
[0039]
[0040] in, is the feature map after the t-th denoising step; is a hyperparameter to control the noise intensity; is the feature map of the current denoising step; is the noise predicted by the noise estimation model.
[0041] Furthermore, the preset termination condition is that a specified number of repetitions is reached, or that the similarity between two adjacent mapping feature graphs is greater than a specified threshold.
[0042] The present invention also provides a system for generating a diffusion defect image of an electric power device, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the steps of the above-mentioned method for generating a diffusion defect image of an electric power device.
[0043] Compared with the prior art, the method for generating a power equipment defect image diffusion provided by the present invention has the following beneficial effects:
[0044] The invention provides a method for generating a diffusion image of a defective power equipment, which obtains a normal original image of the power equipment, divides the normal original image into multiple sub-region images and performs position encoding; uses an automatic encoder to obtain an original feature map and text feature embedding in a low-dimensional space; adds Gaussian noise to the original feature map to obtain a noise feature map; extracts features from the noise feature map to obtain a first feature map q and a second feature map k; uses a cross-attention module to fuse the first feature map q, the second feature map k and the text feature embedding to obtain a fused feature map in a low-dimensional space; processes the fused feature map to remove defect noise to obtain a mapping feature map; finally, it is determined whether a preset termination condition is met. If the preset termination condition is met, a decoder is used to restore the mapping feature map to a three-dimensional space to obtain a diffusion image of a defective power equipment corresponding to the proposed defect text prompt. If the preset termination condition is not met, the mapping feature map is updated to a noise feature map, and the above steps are repeated until the preset termination condition is met. The method for generating a diffusion image of a defective power equipment of the invention takes into account the diversity and authenticity of the generation quality and the results, can provide new training samples for downstream visual tasks, and requires less computing resources and is easy to implement. BRIEF DESCRIPTION OF THE DRAWINGS
[0045] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the structures shown in these drawings without paying creative work.
[0046] Figure 1 It is a flow chart of the method for generating a defect image diffusion of electric power equipment according to the present invention;
[0047] Figure 2 A schematic diagram of a process of obtaining a first feature map in the method for generating a diffusion defect image of an electric power device according to the present invention;
[0048] Figure 3 The present invention is a schematic diagram of a process for obtaining a second feature map in the method for generating a defect image diffusion of electric power equipment according to the present invention.
[0049] The purpose, features and advantages of the present invention will be further described with reference to the accompanying drawings in conjunction with the embodiments. DETAILED DESCRIPTION
[0050] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.
[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0052] In addition, the descriptions of "first", "second", etc. in the present invention are only used for descriptive purposes and cannot be understood as indicating or implying their relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In addition, the technical solutions between the various embodiments can be combined with each other, but they must be based on the ability of ordinary technicians in the field to implement them. When the combination of technical solutions is contradictory or cannot be implemented, it should be deemed that such a combination of technical solutions does not exist and is not within the scope of protection required by the present invention.
[0053] Please refer to Figure 1 , Figure 2 as well as Figure 3 The present invention provides a method for generating a diffusion defect image of an electric power device, comprising the steps of:
[0054] S10, obtain a normal original image of the power equipment, divide the normal original image into multiple sub-region images and perform position encoding, and record the corresponding relationship between the digital matrix position and the digital matrix content of each sub-region image in the sub-region sequence; S20, use an automatic encoder to reduce the dimension and map the normal original image and the proposed defect text prompt respectively, and obtain the original feature map and text feature embedding in the low-dimensional space: S30, add Gaussian noise to the original feature map to obtain a noise feature map; S40, use a multi-scale attention module based on dilated convolution to extract features from the noise feature map to obtain a first feature map q containing multi-scale semantic information; use a spatial attention module to extract features from the noise feature map to obtain a second feature map k focusing on the target area of the generation task; S50, A cross-attention module is used to fuse the first feature map q, the second feature map k and the text feature embedding to obtain a fused feature map in a low-dimensional space; S60, a noise assessment model is used to guide the fused feature map based on the position coding information to remove defect noise, and a mapping feature map in a low-dimensional space of any resolution is obtained, wherein the position coding information includes the correspondence between the sub-region image and the digital matrix content; S70, it is determined whether a preset termination condition is met, if the preset termination condition is met, then the process proceeds to step S80, if the preset termination condition is not met, then the mapping feature map is updated to a noise feature map, and then steps S40 to S60 are entered; S80, a decoder is used to restore the mapping feature map to a three-dimensional space to obtain a defect diffusion image of the power equipment corresponding to the proposed defect text prompt.
[0055] The invention provides a method for generating a diffusion image of a defective power equipment, which obtains a normal original image of the power equipment, divides the normal original image into multiple sub-region images and performs position encoding; uses an automatic encoder to obtain an original feature map and text feature embedding in a low-dimensional space; adds Gaussian noise to the original feature map to obtain a noise feature map; extracts features from the noise feature map to obtain a first feature map q and a second feature map k; uses a cross-attention module to fuse the first feature map q, the second feature map k and the text feature embedding to obtain a fused feature map in a low-dimensional space; processes the fused feature map to remove defect noise to obtain a mapping feature map; finally, it is determined whether a preset termination condition is met. If the preset termination condition is met, a decoder is used to restore the mapping feature map to a three-dimensional space to obtain a diffusion image of a defective power equipment corresponding to the proposed defect text prompt. If the preset termination condition is not met, the mapping feature map is updated to a noise feature map, and the above steps are repeated until the preset termination condition is met. The method for generating a diffusion image of a defective power equipment of the invention takes into account the diversity and authenticity of the generation quality and the results, can provide new training samples for downstream visual tasks, and requires less computing resources and is easy to implement.
[0056] It can be understood that in the present invention, the proposed defect text prompt can be a text prompt such as transformer oil leakage; the decoder is a decoder network corresponding to the image encoder branch, which is used to restore the final mapping feature map into a three-dimensional power equipment defect image.
[0057] Furthermore, a three-dimensional array matrix of a normal original image of the power equipment is obtained, wherein the height of the three-dimensional array matrix is H, the width is W, and the number of channels is 3, and H and W are both positive integers; a sliding window with a size of m×m and a step size of n is used to divide the normal original image in the height direction and the width direction, and the divided sub-regions are combined to form a sub-region sequence, where m is a positive integer greater than or equal to 3, and n is a positive integer greater than or equal to 3; a trigonometric function is used to calculate the position code of each sub-region in turn, and the corresponding relationship between the position of the sub-region in the sub-region sequence and its content is obtained.
[0058] In a specific implementation of the present invention, a computer program reads a normal original image of an electric power device to obtain a three-dimensional array matrix with a height of 256, a width of 256, and a channel of 3; a sliding window with a size of 32×32 and a step size of 32 is used to divide the image in the height and width directions, and the divided sub-regions are combined into a sequence with a length of 64; a trigonometric function is used to calculate the position code of each sub-region in turn to obtain the corresponding relationship between the position of the sub-region in the sub-region sequence and its content, and the calculation formula is as follows:
[0059]
[0060] Among them, PE represents the position code of a sub-region, which consists of d components, where the components on even bits are sin functions and the components on odd bits are cos functions; pos represents the index of a sub-region in the sequence, and the value of pos ranges from 0 to 63; i represents the index of the component in the position code, and the value of i ranges from 0 to 255; d is the dimension of the position code, and the value is 512.
[0061] Furthermore, step S20 specifically includes: using an image encoder to reduce the dimension and map the normal original image to obtain an original feature map in a low-dimensional space; using a text encoder to reduce the dimension and map the proposed defect text prompt to obtain text feature embedding in a low-dimensional space.
[0062] In a specific embodiment of the present invention, the autoencoder includes two parallel branches, one of which is an image encoder, which adopts an encoder-decoder structure, each of which is composed of 4 ResNet blocks and self-attention layers, and uses a GroupNorm normalization layer and a SiLU activation function; the image encoder is used to reduce the dimension and map the normal original image of the power equipment to obtain a feature map of a low-dimensional space. The other branch is a text encoder, which adopts a Transformer structure with multi-head attention and uses the parameters of the CLIP pre-trained model, specifically including an Embedding layer for amplifying dimension and position encoding, 12 multi-head self-attention layers with masks of the same structure, and the final normalization layer; the text encoder is used to map the text prompts to obtain the text feature embedding v in the same space.
[0063] Further, in step S30, Gaussian noise is added to the original feature map to obtain a noise feature map, wherein the mathematical expression of the noise addition process is:
[0064]
[0065] is the feature map after the t-th noise addition step; is a hyperparameter to control the noise intensity; It is the feature map obtained in the previous noise adding step of the t-th noise adding step; is Gaussian noise.
[0066] In a specific embodiment of the present invention, Gaussian noise refers to a type of noise whose probability density function obeys Gaussian distribution (i.e., normal distribution), denoted as , where 0 is the expectation of the Gaussian distribution, is the variance of the Gaussian distribution, and its formula is:
[0067]
[0068] The mathematical formula for the noise addition process is:
[0069]
[0070] Where: is the feature map after the t-th noise addition step, and the value of t is 6; It is a hyperparameter to control the noise intensity, and its value is 0.9; is the feature map obtained in the previous noise addition step, is Gaussian noise.
[0071] Furthermore, in step S40, "using a multi-scale attention module based on dilated convolution to extract features from the noise feature map to obtain a first feature map q containing multi-scale semantic information" specifically includes: using 1×1 convolution to aggregate the noise feature map; using several parallel dilated convolutions with different dilation rates to process the aggregated noise feature map to obtain several aggregated feature maps that fuse different receptive fields; using a weighted method to accumulate the aggregated feature maps to obtain feature maps containing different receptive fields, wherein the weighting coefficients are learned in the model training stage; repeating the above steps to obtain a first feature map q containing multi-scale semantic information.
[0072] Optionally, in a specific implementation, a 1×1 convolution is used to aggregate the noise feature map; three parallel dilated convolutions with dilation rates of 1, 2, and 3, respectively, are used to process the fused feature map to obtain three feature maps that fuse different receptive fields; a weighted method is used to accumulate the feature maps that fuse different receptive fields to obtain a feature map containing different receptive fields, wherein the weighting coefficients are learned in the model training stage; the above steps are repeated 6 times to obtain a first feature map q containing multi-scale semantic information.
[0073] Furthermore, in step S40, "using a multi-scale attention module based on dilated convolution to extract features from the noise feature map to obtain a first feature map q containing multi-scale semantic information" specifically includes: using 1×1 convolution to aggregate the noise feature map; using several parallel dilated convolutions with different dilation rates to process the aggregated noise feature map to obtain several aggregated feature maps that fuse different receptive fields; using a weighted method to accumulate the aggregated feature maps to obtain feature maps containing different receptive fields, wherein the weighting coefficients are learned in the model training stage; repeating the above steps to obtain a first feature map q containing multi-scale semantic information.
[0074] Optionally, in a specific embodiment, the noise feature map is averaged in the channel dimension to obtain a compressed feature map with a channel number of 1; a 5×5×1 convolution is used to calculate the importance of different spaces of the compressed feature map to obtain a feature map containing spatial importance; the feature map containing spatial importance is multiplied with the noise feature map to obtain a second feature map k with spatial attention.
[0075] Furthermore, through the projection matrix , projection matrix and the projection matrix The first feature map q, the second feature map k and the text feature embedding are mapped to obtain the query vector Q, the key vector K and the value vector V, where: , , ; Perform dot product on the query vector Q and the key vector K, and obtain the attention weight through the Relu function; multiply the attention weight with the value vector V, sum the results, and obtain the fused feature map.
[0076] Furthermore, the defect noise distribution corresponding to the proposed defect text prompt is calculated through the noise estimation model; the defect noise is subtracted from the fused feature map based on the position encoding information to obtain a mapping feature map of a low-dimensional space with arbitrary resolution; wherein the mathematical expression of the defect noise denoising process is:
[0077]
[0078] in, is the feature map after the t-th denoising step; is a hyperparameter to control the noise intensity; is the feature map of the current denoising step; is the noise predicted by the noise estimation model.
[0079] Further, the preset termination condition is that a specified number of repetitions is reached, or that the similarity between two adjacent mapping feature graphs is greater than a specified threshold. Optionally, the specified number of repetitions is 15 times, 20 times, 25 times, or other times.
[0080] The method for generating a defective image diffusion of electric power equipment of the present invention can generate an equipment image with specific defects based on a normal equipment image and a text prompt, with high generation quality, diversified generation content and generation size, and can provide brand-new training samples for downstream visual tasks; a multi-scale attention mechanism based on dilated convolution is adopted, which can produce a more accurate representation in pursuit of high-quality decentralized output, effectively extract small target defect features, and at the same time, utilize the expansion architecture to aggregate multi-scale context information, which can better retain the global context information and layout information of the input image sample; a spatial attention mechanism is introduced into the feature extraction network, which effectively handles long-distance dependencies and flexibly focuses on different parts of the features, so that the network pays more attention to the area of the generated task target; a training strategy based on sub-region sequences is adopted, relevant position information is introduced, and the correlation between pixel position and content is directly provided to the model, thereby generating images of arbitrary resolution.
[0081] The present invention also provides a system for generating a diffusion image of a defective power device, comprising a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to perform the steps of the above-mentioned method for generating a diffusion image of a defective power device. It should be understood by those skilled in the art that the embodiments of the present application can be provided as a method, a system, or a computer program product. Therefore, the present application can take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present application can take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer program codes. The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the steps in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0082] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A method for generating a diffusion defect image of an electric power equipment, characterized in that: Includes steps: S10, obtaining a normal original image of the power equipment, dividing the normal original image into a plurality of sub-region images and performing position encoding, and recording a corresponding relationship between a digital matrix position and a digital matrix content of each sub-region image in a sub-region sequence; S20, using an automatic encoder to reduce the dimension and map the normal original image and the proposed defect text prompt respectively, to obtain the original feature map and text feature embedding in the low-dimensional space; S30, adding Gaussian noise to the original feature map to obtain a noise feature map; S40, extracting features from the noise feature map using a multi-scale attention module based on dilated convolution to obtain a first feature map containing multi-scale semantic information; The spatial attention module is used to extract features from the noise feature map to obtain a second feature map focusing on the target area of the generation task; S50, using a cross attention module to fuse the first feature map, the second feature map and the text feature embedding to obtain a fused feature map in a low-dimensional space; S60, using a noise assessment model to guide the fusion feature map based on the position coding information to remove defect noise, and obtain a mapping feature map of a low-dimensional space of any resolution, wherein the position coding information includes a correspondence between the sub-region image and the digital matrix content; S70, determining whether a preset termination condition is met, if the preset termination condition is met, proceeding to step S80, if the preset termination condition is not met, updating the mapping feature map to a noise feature map, and proceeding to steps S40 to S60; S80, using a decoder to restore the mapped feature map to a three-dimensional space, and obtaining a power equipment defect diffusion image corresponding to the proposed defect text prompt.
2. The method for generating a diffusion defect image of an electric power equipment according to claim 1, characterized in that: Step S10 specifically includes the following steps: Obtain a three-dimensional array matrix of a normal original image of the power equipment, where the height of the three-dimensional array matrix is H, the width is W, the number of channels is 3, and both H and W are positive integers; A sliding window with a size of m×m and a step length of n is used to divide the normal original image in the height direction and the width direction, and the divided sub-regions are combined to form a sub-region sequence, where m is a positive integer greater than or equal to 3, and n is a positive integer greater than or equal to 3; The position code of each sub-region is calculated in turn using trigonometric functions to obtain the corresponding relationship between the position of the sub-region in the sub-region sequence and its content.
3. The method for generating a defect image diffusion of electric power equipment according to claim 1, characterized in that: Step S20 specifically includes: An image encoder is used to reduce the dimension and map the normal original image to obtain the original feature map of the low-dimensional space; A text encoder is used to reduce the dimension and map the proposed defect text prompts to obtain text feature embedding in a low-dimensional space.
4. The method for generating a defect image diffusion of electric power equipment according to claim 1, characterized in that: In step S30, Gaussian noise is added to the original feature map to obtain a noise feature map, wherein the mathematical expression of the noise addition process is: is the feature map after the t-th noise addition step; is a hyperparameter to control the noise intensity; It is the feature map obtained in the previous noise adding step of the t-th noise adding step; is Gaussian noise.
5. The method for generating a diffusion defect image of an electric power equipment according to claim 1, characterized in that: In step S40, "using a multi-scale attention module based on dilated convolution to extract features from the noise feature map to obtain a first feature map containing multi-scale semantic information" specifically includes: Use 1×1 convolution to aggregate the noise feature map; The aggregated noise feature map is processed by using several parallel dilated convolutions with different dilation rates to obtain several aggregated feature maps that integrate different receptive fields. The weighted method is used to accumulate the aggregated feature maps to obtain feature maps with different receptive fields, where the weighted coefficients are learned during the model training phase; Repeat the above steps to obtain the first feature map containing multi-scale semantic information.
6. The method for generating a diffusion defect image of an electric power equipment according to claim 5, characterized in that: In step S40, "using the spatial attention module to extract features from the noise feature map to obtain a second feature map focusing on the target area of the generation task" specifically includes: The noise feature map is averaged in the channel dimension to obtain a compressed feature map with a channel number of 1; The s×s×1 convolution is used to calculate the importance of different spaces in the compressed feature map to obtain a feature map containing spatial importance, where s is a positive integer greater than or equal to 3; The feature map containing spatial importance is multiplied with the noisy feature map to obtain a second feature map with spatial attention.
7. The method for generating a diffusion defect image of an electric power equipment according to claim 6, characterized in that: Through the projection matrix , projection matrix and the projection matrix The first feature map, the second feature map and the text feature embedding are mapped to obtain the query vector Q, the key vector K and the value vector V, where: , , ; Perform dot product on the query vector Q and the key vector K, and obtain the attention weight through the ReLU function; Multiply the attention weights by the value vector V and sum the results to get the fused feature map.
8. The method for generating a defect image diffusion of electric power equipment according to claim 1, characterized in that: Calculate the defect noise distribution corresponding to the proposed defect text prompt through the noise estimation model; Based on the position encoding information, the defect noise is subtracted from the fused feature map to obtain a mapping feature map of a low-dimensional space with arbitrary resolution; Among them, the mathematical expression of the denoising process of defect noise is: in, is the feature map after the t-th denoising step; is a hyperparameter to control the noise intensity; is the feature map of the current denoising step; is the noise predicted by the noise estimation model.
9. The method for generating a diffusion defect image of an electric power device according to claim 6, characterized in that: The preset termination condition is that the specified number of repetitions is reached, or the similarity between two adjacent mapping feature maps is greater than a specified threshold.
10. A system for generating a defect image diffusion of electric power equipment, characterized in that: The method comprises a microprocessor and a memory connected to each other, wherein the microprocessor is programmed or configured to execute the steps of the method for generating a defect image diffusion of an electric power device according to any one of claims 1 to 9.
Citation Information
Patent Citations
Image enhancement method and device based on diffusion model, equipment and storage medium
CN116664450A
Bearing defect detection model construction method and system
CN117152142A