Substation equipment defect image generation method based on diffusion model and related equipment

CN122966765APending Publication Date: 2026-10-23CSG EHV POWER TRANSMISSION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611045450.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-14
Publication Date
2026-10-23

AI Technical Summary

Technical Problem

若生成条件只描述缺陷名称或平面掩膜区域,扩散模型在去噪过程中会依据训练数据中的统计纹理进行补全,容易把缺陷生成在不应发生的部位,或在缺陷边界形成与原有部件纹理不一致的突变区域,使生成样本对后续缺陷识别训练的支撑能力受限

Benefits of technology

本发明通过对带有缺陷标注的变电设备图像进行部件语义解析,建立关键部件区域与缺陷标注区域之间的缺陷发生拓扑图,并将缺陷标注区域反演为缺陷中心域、边界过渡域和非缺陷保持域,使扩散模型的生成条件从单一类别约束或单一掩膜约束,转变为部件位置、缺陷形态和保留区域共同限定的图像生成约束。缺陷发生拓扑图用于限定缺陷与变电设备部件之间的对应关系,掩膜反演结果用于限定缺陷区域内部和边界周围的空间层次,分阶段条件注入使拓扑约束、掩膜约束和纹理保持约束分别进入扩散去噪的不同阶段。由此,生成过程能够在保持设备主体结构的基础上,使缺陷区域落入与部件语义匹配的位置,并使缺陷边界沿部件表面形成连续过渡,减少缺陷位置偏移、边缘突兀和纹理断裂造成的图像失真。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122966765A_ABST
    Figure CN122966765A_ABST
Patent Text Reader

Abstract

The present application relates to the field of artificial intelligence, in particular to a substation equipment defect image generation method based on a diffusion model and related equipment, the method comprising: obtaining a substation equipment image with defect labels, and parsing to obtain a device main body region, a key component region, a background region and a defect label region; establishing a defect occurrence topology graph according to the spatial correspondence relationship between the key component region and the defect label region, and inversely obtaining a defect center domain, a boundary transition domain and a non-defect preservation domain from the defect label region mask; encoding the defect occurrence topology graph and the inverse result of the mask into layered generation conditions of a diffusion model, and injecting the layered generation conditions in stages in a diffusion denoising process; performing semantic consistency constraint screening on the generation result to obtain a substation equipment defect image generation result; the present application can constrain the defect generation position, boundary transition and texture continuation relationship, and reduce the cases of unreasonable component, defect boundary mutation and non-defect region being mistakenly rewritten.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of artificial intelligence technology, and in particular to a method and related equipment for generating defect images of substation equipment based on a diffusion model. Background Technology

[0002] Image generation of substation equipment defects falls under the fields of image processing and image generation, typically addressing issues such as insufficient real-world defect samples, uneven distribution of defect types, and inadequate training sample coverage. Existing conventional methods often use labeled substation equipment defect images as training data, inputting defect categories, text descriptions, original images, or local masks into a diffusion model. The model learns the data distribution of defect images through progressive noise addition and denoising, and then generates new defect images according to a given category during the sampling phase. For images of insulator cracks, bushing flashover marks, hardware corrosion, and localized transformer leaks, conventional methods usually use defect bounding boxes or defect masks as generation constraints, causing the model to generate textures similar to the defect category within a specified area. While these methods can obtain images with defect appearances, the generation process is primarily controlled by category and pixel region conditions, failing to adequately utilize constraints related to the substation equipment's component hierarchy, relationships between adjacent components, surface continuity of components, and the potential locations of defects.

[0003] In existing technologies, some solutions add semantic segmentation or object detection processing before the diffusion model to segment the main body of the substation equipment, insulating components, conductive components, hardware components, and background areas in the image. The segmentation results are then input into the diffusion model as a conditional map to preserve the image structure during generation. Other solutions employ an image inpainting-based generation method, first setting a defect mask region in the original image, then using the diffusion model to complete the defect texture within the mask, while constraining the non-mask regions to remain unchanged using the original image. Compared to generation methods that only use category labels, this type of processing has certain limitations on the equipment outline and local generation range. However, its semantic segmentation results are usually only used as planar region labels, without further expressing the topological relationships between components; the mask is often treated as a fixed filling area, failing to distinguish between defect centers, boundary transitions, and non-defect-preserving areas; and the conditional injection during the diffusion denoising process lacks hierarchical control corresponding to the noise stage.

[0004] In the process of generating defect images for substation equipment, the lack of coordinated constraints on equipment structure among defect category conditions, component semantic conditions, and mask region conditions makes it difficult for the defect images generated by the diffusion model to simultaneously meet the requirements of reasonable defect location, natural defect boundary, and continuity of defect texture with the equipment surface. The technical reason for this problem is that substation equipment defects are not solely determined by visual texture, but are constrained by the equipment component type, spatial relationships between adjacent components, surface material orientation, and the defect morphology extension path. If the generation conditions only describe the defect name or planar mask region, the diffusion model will complete the model based on statistical textures in the training data during denoising, easily generating defects in inappropriate locations or creating abrupt regions at the defect boundary that are inconsistent with the original component texture. This limits the ability of the generated samples to support subsequent defect recognition training. Summary of the Invention

[0005] In view of this, embodiments of the present invention propose a method and related equipment for generating defect images of substation equipment based on a diffusion model, aiming to achieve accurate generation of defect images of substation equipment and effectively constrain defect location, boundary transition and texture continuity.

[0006] On one hand, embodiments of the present invention provide a method for generating defect images of substation equipment based on a diffusion model, the method comprising the following steps: Obtain images of substation equipment with defect annotations, perform component semantic parsing on the substation equipment images, and obtain key component regions, background regions, and defect annotation regions; A defect occurrence topology map is established based on the spatial correspondence between the key component area and the defect annotation area. The defect occurrence topology map includes defect occurrence nodes, defect occurrence prohibited nodes, and restricted expansion nodes. The background region and the defect-marked region are masked and inverted to obtain the defect center region, the boundary transition region, and the non-defect preservation region. The defect occurrence topology map and the mask inversion result are encoded as the layered generation conditions of the diffusion model, and the layered generation conditions are injected in stages during the diffusion denoising process to obtain the generation result; the staged injection includes injecting topology conditions in the high noise stage of diffusion denoising, injecting mask morphology conditions in the medium noise stage, and injecting texture preservation conditions in the low noise stage. The generated results are filtered by semantic consistency constraints to obtain the generated images of substation defects.

[0007] Optionally, establishing a defect occurrence topology map based on the spatial correspondence between the key component region and the defect annotation region includes: The component semantic category corresponding to the key component region is used as the topology node, and the boundaries, inclusion relationships, connection relationships and surface continuity relationships of adjacent components are used as the topology edges; The defect annotation area is mapped to the corresponding topology node, and the defect type, the component where the defect is located, the relative position of the defect and the component boundary, and the extension direction of the defect along the component surface are recorded. Regions that do not exhibit defects but have topological edges with the component containing the defect are marked as restricted expansion regions, forming a graph structure that includes nodes where defects can occur, nodes where defects are prohibited, and restricted expansion nodes.

[0008] Optionally, the step of performing mask inversion on the background region and the defect-annotated region to obtain the defect center region, the boundary transition region, and the non-defect-preserving region includes: The defect annotation mask is skeletonized to obtain the defect centerline or set of center points; Calculate the spatial distance field of the defect boundary based on the defect centerline or set of center points, and divide the defect center domain and boundary transition domain according to the spatial distance field. The region containing non-defective pixels that are adjacent to the boundary transition region and belong to the same critical component region is defined as the texture reference region. The background region and the critical component region that does not match the defect type are identified as non-defect preservation regions, thus obtaining the inversion mask conditions.

[0009] Optionally, encoding the defect occurrence topology map and the mask inversion result into hierarchical generation conditions for the diffusion model, and injecting the hierarchical generation conditions in stages during the diffusion denoising process to obtain the generation result includes: In the high-noise stage of diffusion denoising, the component position embedding and topological edge embedding obtained by the defect occurrence topology graph encoding are injected into the low-resolution feature layer of the denoising network. In the middle noise stage of diffusion denoising, the mask conditions corresponding to the defect center domain and the boundary transition domain are injected into the intermediate feature layer of the denoising network. In the low-noise stage of diffusion denoising, the image features corresponding to the texture reference domain and the non-defect preservation domain are injected into the high-resolution feature layer of the denoising network, and the conditional embeddings of different stages share the same defect type identifier.

[0010] Optionally, after forming a graph structure containing defect-prone nodes, defect-prohibited nodes, and restricted expansion nodes, the method further includes: Generability encoding of topological nodes includes: generating a node generability vector based on the component semantic category corresponding to the topological node, the shortest topological distance between the node and the defect annotation area, the node surface material characteristics, and the node boundary direction; generating an edge constraint vector based on the spatial angle between two topological nodes connected by a topological edge, the degree of boundary continuity, and the consistency of the defect extension direction; and merging the node generability vector and the edge constraint vector into a topological condition matrix. Graph attention propagation is performed on the topology condition matrix to transmit defect extension features from the topology node where the defect is located to the restricted extension node, and to transmit inhibition features from the prohibited node to its neighboring node. Project the node features after graph attention propagation onto a spatial condition map of the same size as the substation image; Based on the node characteristics of the topological node to which each pixel belongs in the spatial condition map, a pixel-level topological constraint embedding is generated, and the pixel-level topological constraint embedding and the time-step embedding of the diffusion model are jointly input into the denoising network.

[0011] Optionally, after obtaining the inversion mask conditions, the method further includes: Constructing a mask gradient guidance map includes: generating a defect intensity decreasing sequence along the direction from the defect center domain to the boundary transition domain, generating a texture fusion sequence along the direction from the boundary transition domain to the texture reference domain, and mapping the defect intensity decreasing sequence and the texture fusion sequence into a two-dimensional weight field; in the two-dimensional weight field, setting a preservation flag for pixels belonging to the non-defect preservation domain, and setting a condition opening flag for regions corresponding to restricted expansion nodes in the defect occurrence topology map, thereby obtaining gradient guidance conditions aligned with the inversion mask condition space; During the diffusion sampling process, a mask consistency write-back is performed on the intermediate denoised image. The mask consistency write-back includes: at each preset denoising time step, spatially registering the candidate defect regions of the intermediate denoised image with the two-dimensional weight field; replacing candidate pixels that fall into the non-defect-preserving domain and carry defect textures with the latent variable features of the corresponding pixels in the original substation equipment image; and correcting candidate pixels that fall into the boundary transition domain and whose texture direction is inconsistent with the texture fusion sequence with the directional features of the adjacent texture reference domain.

[0012] Optionally, the step of injecting the image features corresponding to the texture reference domain and the non-defect-preserving domain into the high-resolution feature layer of the denoising network during the low-noise stage of diffusion denoising includes: Local color distribution, edge direction distribution, and surface texture frequency distribution are extracted from non-defective pixels adjacent to the boundary transition domain and belonging to the same key component region, and the extraction results are cross-attention matched with the latent variable features of the low-noise stage. An attention masking map is generated based on the non-defect preservation domain, so that the defect type identifier only participates in attention calculation in the regions corresponding to the restricted extension nodes in the defect center domain, the boundary transition domain, and the defect occurrence topology map. The matched local texture features are written into the latent variable channel corresponding to the defect boundary.

[0013] Optionally, the step of performing semantic consistency constraint filtering on the generated results to obtain the generated substation equipment defect image includes: The generated results are then subjected to semantic parsing of components and parsing of defect regions to obtain generated component regions and generated defect regions. Map the generated defect region to the defect occurrence topology graph, and calculate the matching relationship between the topology node to which the generated defect region belongs and the generability code; The boundary orientation of the generated defect region is compared with the defect extension features embedded in the pixel-level topological constraints; When the matching relationship and the comparison result do not meet the preset consistency conditions, the latent variable state, time step information and hierarchical generation conditions of the corresponding generated result are re-input into the diffusion model for resampling.

[0014] On the other hand, embodiments of the present invention provide a device for generating defect images of substation equipment based on a diffusion model, comprising: The first module is used to acquire images of substation equipment with defect annotations, perform component semantic parsing on the substation equipment images, and obtain the main equipment area, key component area, background area and defect annotation area. The second module is used to establish a defect occurrence topology map based on the spatial correspondence between the key component area and the defect marking area. The defect occurrence topology map includes defect occurrence nodes, defect occurrence prohibited nodes, and restricted expansion nodes. The third module is used to perform mask inversion on the background area and the defect annotation area to obtain the defect center domain, the boundary transition domain, and the non-defect preservation domain. The fourth module is used to encode the defect occurrence topology map and the mask inversion result into the layered generation conditions of the diffusion model, and inject the layered generation conditions in stages during the diffusion denoising process to obtain the generation result; the staged injection includes injecting topology conditions in the high noise stage of diffusion denoising, injecting mask morphology conditions in the medium noise stage, and injecting texture preservation conditions in the low noise stage. The fifth module is used to perform semantic consistency constraint filtering on the generated results to obtain the generated images of substation defects.

[0015] On the other hand, embodiments of the present invention provide a computer program product, including a computer program that, when executed by a processor, implements the above-described method.

[0016] On the other hand, embodiments of the present invention provide a substation equipment defect image generation system based on a diffusion model, comprising: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0017] The embodiments of the present invention have the following beneficial effects: This invention performs component semantic analysis on images of substation equipment with defect annotations, establishing a defect occurrence topology map between key component regions and defect annotation regions. The defect annotation regions are then inverted into defect center regions, boundary transition regions, and non-defect preservation regions. This transforms the generation conditions of the diffusion model from single-class constraints or single-mask constraints to image generation constraints jointly defined by component location, defect morphology, and preserved regions. The defect occurrence topology map defines the correspondence between defects and substation equipment components, while the mask inversion results define the spatial hierarchy within and around the defect region. Staged condition injection allows topology constraints, mask constraints, and texture preservation constraints to enter different stages of diffusion denoising. Thus, the generation process, while preserving the main structure of the equipment, ensures that defect regions fall into positions semantically matching the components and that defect boundaries form a continuous transition along the component surface, reducing image distortion caused by defect location offsets, abrupt edges, and texture breaks. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0019] Figure 1 This is a flowchart illustrating the steps of a method for generating defect images of substation equipment based on a diffusion model, as provided in an embodiment of the present invention. Figure 2 yes Figure 1 A flowchart illustrating step S200; Figure 3 yes Figure 1 A flowchart illustrating step S300; Figure 4 yes Figure 1 A flowchart illustrating step S400; Figure 5 This is a structural block diagram of a device for generating defect images of substation equipment based on a diffusion model, provided in an embodiment of the present invention. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.

[0021] It should be noted that although the device diagram shows a modular division and the flowchart illustrates a logical order, in some cases, the steps shown or described may be performed in a different order than the modular division in the device or the order shown in the flowchart. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used herein is for the purpose of describing embodiments of the invention only and is not intended to limit the invention.

[0022] Furthermore, the described features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. Numerous specific details are provided in the following description to give a full understanding of embodiments of the invention. However, those skilled in the art will recognize that the technical solutions of the invention can be practiced without one or more of the specific details, or other methods, components, apparatuses, steps, etc., can be employed. In other instances, well-known methods, apparatuses, implementations, or operations are not shown or described in detail to avoid obscuring various aspects of the invention.

[0023] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities can be implemented in software, in one or more hardware modules or integrated circuits, or in different network and / or processor devices and / or microcontroller devices.

[0024] The flowcharts shown in the accompanying drawings are merely illustrative and do not necessarily include all content and operations / steps, nor do they necessarily have to be performed in the described order. For example, some operations / steps can be broken down, while others can be combined or partially combined; therefore, the actual execution order may change depending on the specific circumstances.

[0025] To address the aforementioned technical problems, this invention proposes a method and related equipment for generating defect images of substation equipment based on a diffusion model. By constructing a defect occurrence topology map and inversion mask conditions, and combining layered generation conditions with a staged diffusion denoising process, the method achieves accurate generation of defect images of substation equipment, effectively constraining defect location, boundary transition, and texture continuity.

[0026] like Figure 1 As shown, Figure 1 A method for generating defect images of substation equipment based on a diffusion model, provided in this embodiment of the invention, includes the following steps: S100: Obtain an image of a power equipment with defect annotations, perform component semantic parsing on the power equipment image, and obtain the key component area, background area, and defect annotation area; S200, a defect occurrence topology map is established based on the spatial correspondence between the key component area and the defect marking area. The defect occurrence topology map includes defect occurrence nodes, defect occurrence prohibited nodes, and restricted expansion nodes. S300, perform mask inversion on the background area and the defect annotation area to obtain the defect center domain, the boundary transition domain, and the non-defect preservation domain; S400, the defect occurrence topology map and the mask inversion result are encoded as the layered generation conditions of the diffusion model, and the layered generation conditions are injected in stages during the diffusion denoising process to obtain the generation result; the staged injection includes injecting topology conditions in the high noise stage of diffusion denoising, injecting mask morphology conditions in the medium noise stage, and injecting texture preservation conditions in the low noise stage. S500 performs semantic consistency constraint filtering on the generated results to obtain the generated images of substation defects.

[0027] This invention proposes a method and related equipment for generating defect images of substation equipment based on a diffusion model. By constructing a defect occurrence topology map and inversion mask conditions, it organically combines component semantic constraints, topological relationship constraints, and mask spatial constraints to form a complete image generation chain. Specifically, component semantic parsing accurately divides the main body of the substation equipment image, key components, and background regions, providing a regional foundation for subsequent topology mapping. The defect occurrence topology map uses key component regions as topological nodes and the spatial relationships between components as topological edges, mapping defect-annotated regions to corresponding topological nodes, forming a graph structure containing defect-prone nodes, prohibited nodes, and restricted expansion nodes, thus expanding the defect generation region from a pixel mask to component-level spatial constraints. Mask inversion decomposes a single defect-annotated region into a defect center region, a boundary transition region, a texture reference region, and a non-defect-preserving region, enabling the diffusion denoising process to distinguish between defect internal generation, boundary fusion, and non-defect preservation. Staged condition injection ensures that topological constraints are injected into the low-resolution feature layer during high-noise stages, mask constraints into the intermediate feature layer during medium-noise stages, and texture preservation constraints into the high-resolution feature layer during low-noise stages. This avoids interference between structural and texture constraints caused by mixing all conditions at the same level. This method effectively constrains defect generation locations, boundary transitions, and texture continuity relationships, reducing the occurrence of defects in unreasonable components, abrupt defect boundaries, and erroneous rewriting of non-defect regions.

[0028] The following is a detailed description of the method for generating defect images of power equipment based on a diffusion model proposed in this invention: In this embodiment, firstly, images of substation equipment with defect annotations are acquired, and then a defect image generation framework based on a diffusion model is constructed according to the characteristics of the substation equipment images. In this embodiment, the substation equipment image with defect annotations can be an inspection image, a maintenance image, or an image from a historical defect database. The defect annotation must at least include the defect pixel region or the defect surrounding region. Component semantic parsing is used to distinguish the transformer casing, bushings, insulators, hardware, conductor connections, supports, and background areas in the same image into mutually unambiguous semantic regions. The defect occurrence topology map is used to record the possible relationships and spatial connectivity between defects and key components. Mask inversion is used to decompose a single defect region into a central generation region, a transition fusion region, and an invariant region. The diffusion model accepts structural conditions in the high-noise stage, morphological conditions in the medium-noise stage, and texture preservation conditions in the low-noise stage. Semantic consistency constraint filtering is used to eliminate generated images whose defect location, defect boundary, or defect extension direction does not conform to the semantic relationships of equipment components. In this embodiment, the defect image generation process is changed from being driven by defect category to being driven by equipment component constraints, defect mask constraints, and texture preservation constraints, which enables the defect location, boundary transition, and local texture in the generated image to be consistent with the structure of the substation equipment image.

[0029] Specifically, component semantic parsing can be performed using a trained image segmentation network, a region classification model trained based on labeled samples, or a semantic parsing method combining image block segmentation and contour merging. The input is an image of substation equipment with defect annotations, and the output is a semantic label map of the same size as the original image. Each pixel in the semantic label map corresponds to one of the following region categories: the main body region, the key component region, the background region, or the defect annotation region. Subsequently, connected component analysis is performed on the semantic label map, merging pixels of the same component category with connected boundaries into candidate component regions. Then, the key component region where the defect is located is determined based on the intersection area, boundary distance, and coverage relationship between the defect annotation region and the candidate component regions. For cases where the defect annotation region spans multiple candidate component regions, the primary and secondary related components are determined according to the region where the defect center point falls, the region through which the defect's long axis passes, and the region where the defect boundary fits. This avoids the diffusion model generating images based solely on defect categories while ignoring the component bearing relationships of the substation equipment. In this embodiment, the semantic label map provides a unified coordinate reference for subsequent topology mapping, mask inversion, and layered generation conditions, ensuring that the processing results correspond in the same image space.

[0030] In some embodiments, reference Figure 2 The step of establishing a defect occurrence topology map based on the spatial correspondence between the key component area and the defect annotation area includes: S210, the component semantic category corresponding to the key component region is used as the topology node, and the adjacent component boundary, inclusion relationship, connection relationship and surface continuity relationship are used as the topology edge; S220, map the defect marking area to the corresponding topology node, and record the defect type, the component where the defect is located, the relative position of the defect and the component boundary, and the extension direction of the defect along the component surface; S230 marks the regions where no defects have occurred but which have topological edges with the component where the defect is located as restricted expansion regions, forming a graph structure containing nodes where defects can occur, nodes where defects are prohibited from occurring, and restricted expansion nodes.

[0031] Specifically, the defect occurrence topology map consists of topology nodes, topology edges, and defect mapping relationships. Topology nodes correspond to key component regions separated from the semantic label map, topology edges correspond to adjacent component boundaries, inclusion relationships, connection relationships, or surface continuity relationships, and defect mapping relationships are used to record the spatial correspondence between defect-labeled regions and topology nodes. During map construction, the centroid coordinates, outer contour direction, principal axis direction, component category, and local texture direction of each key component region can be written into the topology node attributes. The shortest boundary distance, shared boundary length, angle relationship, and image plane adjacency relationship between two key component regions can be written into the topology edge attributes. Furthermore, the defect type, the component where the defect is located, the relative position of the defect to the component boundary, and the extension direction of the defect along the component surface can be written into the defect mapping attributes. This allows the defect occurrence topology map to simultaneously express the possible locations of defects and the extension paths of defect morphology. In this embodiment, the topology map is not a simple record of component regions, but rather a transformation of planar semantic regions into structured constraint data that can be read by the diffusion model conditional encoder.

[0032] The spatial matching between defects and critical component areas is calculated using the following formula: ; in, This represents the spatial matching value between the j-th type of defect and the ith critical component region. This indicates a defect annotation mask. This represents the region of the i-th critical component. Indicates the calculation of area. Indicates the calculation of boundary length. Indicates the boundary of the region. Indicates the direction of the major axis of the defect. Indicates the main direction of the component surface. , , These represent the weights for region overlap, boundary alignment, and direction consistency, respectively, and their values ​​are non-negative and satisfy the following conditions: When the defect mask is mainly located in the casing area and its boundary fits the outer contour of the casing and extends along the casing axis, the spatial matching value is... A value close to 1 indicates that the critical component region is identified as a defect-prone node. When the defect mask coincides with the background region but their orientations do not match, the spatial matching value... If the value is close to 0, the region is identified as a node that is prohibited from occurring.

[0033] In some embodiments, after forming a graph structure including defect-prone nodes, defect-prohibited nodes, and restricted expansion nodes, the method further includes: S241, Generative encoding of topological nodes is performed, which includes: generating a node generative vector based on the component semantic category corresponding to the topological node, the shortest topological distance between the node and the defect annotation area, the surface material characteristics of the node, and the node boundary direction; generating an edge constraint vector based on the spatial angle between two topological nodes connected by a topological edge, the degree of boundary continuity, and the consistency of the defect extension direction; and merging the node generative vector and the edge constraint vector into a topological condition matrix. S242, Perform graph attention propagation on the topology condition matrix to enable the topology node where the defect is located to transmit the defect extension feature to the restricted extension node, and enable the prohibited node to transmit the inhibition feature to the adjacent node. S243, Project the node features after graph attention propagation onto a spatial condition map of the same size as the substation image; S244, according to the node characteristics of the topological node to which each pixel belongs in the spatial condition map, generate a pixel-level topological constraint embedding, and input the pixel-level topological constraint embedding and the time-step embedding of the diffusion model into the denoising network.

[0034] Specifically, the node generativeability vector can be obtained by concatenating component category embedding, topological distance embedding, material texture embedding, and boundary direction embedding, followed by linear mapping. The edge constraint vector can be obtained by normalizing the relational features composed of spatial angle, shared boundary ratio, and directional consistency. The rows of the topological condition matrix correspond to topological nodes, and the columns correspond to node attributes and constraint attributes after edge propagation. In this embodiment, generativeability encoding transforms discrete generative, prohibitive, and restricted propagation markers into continuous condition vectors, facilitating the use of the diffusion model in denoising networks.

[0035] For the i-th topological node, its component semantic category embedding, the shortest topological distance embedding between the node and the defect annotation region, the node surface material features, and the node boundary direction features are concatenated. Then, this concatenation is weighted and summed with the edge constraint vectors of the connected topological edges, followed by a normalized mapping operation to obtain the generativeability code of the topological node. The generativeability code of the topological node is calculated using the following formula: ; in, This represents the generativeability code of the i-th topological node. This represents the normalization mapping operation. Represents the encoding weight matrix. Indicates component semantic category embedding, The embedding represents the shortest topological distance between a node and the defect annotation region. Indicates the surface material characteristics of the node. Indicates the directional characteristics of the node boundary. Let represent the set of topological edges connected to the i-th node. This represents the constraint weight of the r-th topological edge. Let represent the edge constraint vector of the r-th topological edge. This is true when a node is short in distance from the node containing the defect, has the same surface material, and its boundary direction aligns with the defect's extension direction. The open generation component takes a larger value when a node has no continuous topological edge with the node where the defect is located and the component category does not match. The suppression component in the formula is set to a larger value.

[0036] Furthermore, when the topological condition matrix is ​​used as part of the hierarchical generation conditions, graph attention propagation is performed on the topological condition matrix. This allows the topological node containing the defect to transmit defect extension features to the restricted extension node, and the prohibited occurrence node to transmit suppression features to its neighboring nodes. The node features after graph attention propagation are projected onto a spatial condition map of the same size as the substation image. Pixel-level topological constraint embeddings are generated according to the node features of the topological node to which each pixel belongs in the spatial condition map. These pixel-level topological constraint embeddings are then jointly input into the denoising network along with the time-step embedding of the diffusion model. Graph attention propagation can calculate the information transmission weights between nodes based on the topological edge constraint vectors. Restricted extension nodes only receive open features from the node containing the defect and nodes with which they have surface continuity. When the prohibited occurrence node transmits suppression features to its neighboring nodes, it only affects the pixel region near the prohibited boundary. The spatial condition map is obtained by filling the corresponding semantic region with node encodings. In this embodiment, component-level topological constraints are transformed into pixel-level conditions, enabling the diffusion model to distinguish between generateable, restricted-generate, and preserved regions at the image generation resolution.

[0037] In some embodiments, reference Figure 3 The step of performing mask inversion on the background region and the defect-annotated region to obtain the defect center region, the boundary transition region, and the non-defect-preserving region includes: S310, skeletonizes the defect annotation mask to obtain the defect centerline or set of center points; S320, calculate the spatial distance field of the defect boundary based on the defect centerline or set of center points, and divide the defect center domain and boundary transition domain according to the spatial distance field; S330, the region containing non-defective pixels that are adjacent to the boundary transition region and belong to the same critical component region is determined as the texture reference region; S340, the background area and the critical component area that does not match the defect type are identified as non-defect preservation domains, and the inversion mask conditions are obtained.

[0038] Specifically, mask inversion performs center extraction, distance field construction, boundary band division, and preservation region confirmation on the defect-annotated region. The defect-annotated region can first undergo hole filling and isolated point removal, then obtain the defect centerline or set of center points through skeletonization. Subsequently, using the defect centerline or set of center points as the starting point, the distance from each defect pixel to the center set and the distance to the defect boundary are calculated. Pixels close to the center and located inside the defect are assigned to the defect center domain; pixels close to the defect boundary and adjacent to the same critical component region are assigned to the boundary transition domain; neighboring regions located on the same critical component surface and not covered by the defect annotation are assigned to the texture reference domain; and background regions and critical component regions that do not match the defect type are assigned to the non-defect preservation domain, forming the inversion mask conditions. In this embodiment, a single mask is split into multiple spatial domains with different generation constraint meanings, enabling the diffusion denoising process to distinguish between defect-internal generation, boundary fusion, and non-defect preservation.

[0039] The inversion mask category is calculated using the following formula: ; in, The inversion mask category for pixel x is represented by C, where C represents the defect center region, B represents the boundary transition region, T represents the texture reference region, and H represents the non-defect preservation region. This represents the normalized distance from pixel x to the defect boundary. Indicates the boundary of the central domain. Indicates the location in the critical component area Inside and close to the defect boundary The neighborhood, when When the value is close to 1, the pixel is in a stable region inside the defect and enters the defect center region. When the value is close to 0 and the pixel is still within the defect mask, it enters the boundary transition domain; when the pixel is outside the defect and close to the same part surface, it enters the texture reference domain.

[0040] In some embodiments, after obtaining the inversion mask conditions, the method further includes: S351, Construct a mask gradient guidance map, wherein constructing the mask gradient guidance map includes: generating a defect intensity decreasing sequence along the direction from the defect center domain to the boundary transition domain, generating a texture fusion sequence along the direction from the boundary transition domain to the texture reference domain, and mapping the defect intensity decreasing sequence and the texture fusion sequence into a two-dimensional weight field; in the two-dimensional weight field, setting a preservation flag for pixels belonging to the non-defect preservation domain, setting a condition opening flag for regions corresponding to restricted expansion nodes in the defect occurrence topology map, thereby obtaining gradient guidance conditions aligned with the inversion mask condition space; S352, In the diffusion sampling process, a mask consistency write-back is performed on the intermediate denoised image. The mask consistency write-back includes: at each preset denoising time step, spatially registering the candidate defect region of the intermediate denoised image with the two-dimensional weight field; replacing candidate pixels that fall into the non-defect preservation domain and carry defect textures with the latent variable features of the corresponding pixels in the original substation equipment image; and correcting candidate pixels that fall into the boundary transition domain and whose texture direction is inconsistent with the texture fusion sequence with the directional features of the adjacent texture reference domain.

[0041] Specifically, the defect intensity decreasing sequence can be formed by the normalized distance from the central domain pixel to the boundary transition domain pixel, and the texture fusion sequence can be formed by the adjacency direction from the boundary transition domain pixel to the texture reference domain pixel. Each pixel in the two-dimensional weight field contains defect generation weights, texture fusion weights, and preservation weights. The diffusion model reads the defect generation weights in the medium noise stage, the texture fusion weights in the low noise stage, and the preservation weights during the write-back process. In this embodiment, the mask gradient guidance map expresses the generation intensity of defects from the center to the boundary and the fusion relationship from the boundary to the original texture as a continuous spatial constraint.

[0042] In a two-dimensional weighted field, the overall guidance value of pixel x is obtained by weighted summation of the defect generation guidance component, the texture blending guidance component, and the region preservation guidance component. The defect generation guidance component is determined by the distance from the pixel to the defect center region and the distance from the pixel to the boundary transition region. The overall guidance value of pixel x in the two-dimensional weighted field is calculated using the following formula: ; in, This represents the overall guiding value of pixel x in the two-dimensional weight field. This represents the distance from pixel x to the center of the defect. This represents the distance from pixel x to the boundary transition region. This represents the distance from pixel x to the texture reference domain. This indicates that the identifier is retained and takes a value of 1 in the non-defect retention field and a value of 0 in other areas. , , These represent the guiding weights for defect generation, texture blending, and region preservation, respectively. This represents a constant to prevent the denominator from being zero, when the pixel is located near the center of the defect. The smaller and defect generation weights dominate, the texture fusion weights dominate when the pixel is near the texture reference domain, and the retention label makes the write-back process prioritize the preservation of the original image features when the pixel belongs to the non-defect preservation domain.

[0043] Furthermore, after obtaining the gradient guidance conditions, a mask consistency write-back is performed on the intermediate denoised image during the diffusion sampling process: at each preset denoising time step, the defect candidate region of the intermediate denoised image is spatially registered with the two-dimensional weight field; for candidate pixels falling into the non-defect-preserving domain and carrying defect texture, the latent variable features of the corresponding pixels in the original substation equipment image are replaced; for candidate pixels falling into the boundary transition domain and whose texture direction is inconsistent with the texture fusion sequence, the directional features of the adjacent texture reference domain are corrected. The defect candidate region can be determined by the difference region between the intermediate denoised image and the original image in the latent variable space, or by the candidate defect probability map output by the defect parsing branch. Spatial registration is completed using the mask index under the same image coordinates. The latent variable feature replacement is performed in the current time step state of the denoising network. The directional feature correction is completed by adjusting the gradient direction of the candidate pixel neighborhood to be consistent with the main direction of the texture reference domain. In this embodiment, the intermediate write-back process ensures that the non-defect-preserving domain is continuously constrained during the sampling process, rather than being passively screened out only after sampling.

[0044] In some embodiments, reference Figure 4 The step of encoding the defect occurrence topology map and mask inversion results into hierarchical generation conditions for the diffusion model, and injecting the hierarchical generation conditions in stages during the diffusion denoising process, to obtain the generation results includes: S410, in the high-noise stage of diffusion denoising, the component position embedding and topological edge embedding obtained by the defect occurrence topology map encoding are injected into the low-resolution feature layer of the denoising network. S420, In the middle noise stage of diffusion denoising, the mask conditions corresponding to the defect center domain and the boundary transition domain are injected into the intermediate feature layer of the denoising network. S430, in the low-noise stage of diffusion denoising, the image features corresponding to the texture reference domain and the non-defect preservation domain are injected into the high-resolution feature layer of the denoising network, and the conditional embeddings of different stages share the same defect type identifier.

[0045] Specifically, the layered generation conditions consist of topological conditions, masking conditions, and image preservation conditions. Topological conditions are derived from node categories, node positions, topological edge relationships, and defect mapping relationships in the defect occurrence topology graph. Masking conditions are derived from the defect center domain, boundary transition domain, texture reference domain, and non-defect preservation domain. Image preservation conditions are derived from the color distribution, edge direction distribution, and texture frequency distribution of the original substation image in the non-defect region. During the training phase, the diffusion model adds noise to the real defect image, creating noisy images at different time steps, and learns to recover the real defect image under given layered generation conditions. During the sampling phase, denoising is gradually performed starting from the noisy image. In the high-noise stage, the topological conditions are received at a low-resolution feature layer, limiting the spatial layout of the image subject and key components. In the medium-noise stage, the masking conditions are received at an intermediate feature layer, limiting the defect center and defect boundary morphology. In the low-noise stage, the image preservation conditions are received at a high-resolution feature layer, allowing the defect boundary to be fused with the texture of adjacent components. In this embodiment, staged injection allows different conditions to enter the appropriate image generation layer, avoiding interference between structural and texture constraints caused by mixing all conditions at the same layer.

[0046] Table 1 shows the correspondence between the layered generation conditions and the diffusion denoising stage, which is used to illustrate the formation method and writing location of various types of data during the implementation process.

[0047] Table 1: Correspondence between layer generation conditions and diffusion denoising stage

[0048] In some embodiments, injecting the image features corresponding to the texture reference domain and the non-defect-preserving domain into the high-resolution feature layer of the denoising network during the low-noise stage of diffusion denoising includes: S431, extract local color distribution, edge direction distribution and surface texture frequency distribution from non-defective pixels that are adjacent to the boundary transition domain and belong to the same key component region, and perform cross-attention matching between the extraction results and the latent variable features of the low noise stage; S432, Generate an attention masking map based on the non-defect preservation domain, so that the defect type identifier only participates in attention calculation in the regions corresponding to the restricted extension nodes in the defect center domain, the boundary transition domain, and the defect occurrence topology map; S433, write the matched local texture features into the latent variable channel corresponding to the defect boundary.

[0049] Specifically, the local color distribution can be obtained from the color histogram statistics of pixels in the texture reference domain, the edge direction distribution can be obtained from the gradient direction statistics of the neighborhood, and the surface texture frequency distribution can be obtained from local frequency domain transformation or multi-scale filtering response. Cross-attention matching uses latent variable features as query terms and texture reference domain features as keys and values. The attention masking map excludes non-defect-preserving domains from the calculation range of defect type identifiers. In this embodiment, the texture generation of defect boundaries uses the surface texture of the same component as a reference, enabling the boundary transition domain to be continuous with adjacent original textures.

[0050] For pixel x, a query vector is generated from its latent variable features. A key vector and a value vector are generated from the features of pixels in the texture reference domain. The exponential dot product of the query vector and the key vector is calculated and normalized to obtain the attention weight. The attention weight is multiplied by the value vector to obtain the attention output. This output is then weighted by the open coefficients of the attention masking map and added to the original latent variable state to obtain the latent variable state after being written into the texture features. The state of the latent variable channel after being written into the texture features is calculated using the following formula: ; in, This represents the state of pixel x after the latent variable channel is written into the texture feature. This indicates the state of the implicit variable before it is written. This represents the query vector generated from the latent variable features of pixel x. The key vector representing the texture reference pixel y. This represents the value vector of the pixel y in the texture reference domain. Indicates exponentiation. This represents the openness coefficient of the attention masking map at pixel x, which is 0 in the non-defect-preserving region. When pixel x belongs to the boundary transition region and is close to the direction of the texture reference region, the attention weights are concentrated on the texture pixels in the same direction. When pixel x belongs to the non-defect-preserving region... Set to 0 and stop writing defect textures.

[0051] In some embodiments, the diffusion model training employs a conditional denoising objective. Training samples consist of real substation defect images, component semantic label maps, defect occurrence topology maps, inversion mask conditions, and gradient guidance conditions. During training, noise is added to the latent variables of the real images at different noise time steps. Time-step embedding, pixel-level topological constraint embedding, mask condition embedding, and image-preserving condition embedding are input into the denoising network. The denoising network outputs estimates of the noisy or noise-free latent variables. The training loss consists of noise estimation error, semantic region constraint error, non-defect preservation error, and boundary texture consistency error. The semantic region constraint error is calculated by the deviation between the generated defect candidate region and the defect occurrence node. The non-defect preservation error is calculated by the difference between the generated latent variable and the original latent variable within the non-defect preservation domain. The boundary texture consistency error is calculated by the difference in directional features between the boundary transition domain and the texture reference domain. In this embodiment, the training objective corresponds to the conditional injection and consistency write-back in the sampling phase, facilitating the model's learning of the constraint methods for each condition during the training phase.

[0052] In some embodiments, the step of performing semantic consistency constraint filtering on the generated results to obtain the generated image of the substation defect includes: S510, perform component semantic parsing and defect region parsing on the generated result again to obtain the generated component region and the generated defect region; S520, map the generated defect region to the defect occurrence topology map, and calculate the matching relationship between the topology node to which the generated defect region belongs and the generability code; S530, compare the boundary orientation of the generated defect region with the defect extension features in the pixel-level topological constraint embedding; S540, when the matching relationship and comparison result do not meet the preset consistency conditions, the latent variable state, time step information and hierarchical generation conditions of the corresponding generated result are re-input into the diffusion model for resampling.

[0053] Specifically, semantic consistency constraint filtering is performed after diffusion sampling is completed, or it can be performed at some intermediate time steps. The filtering process includes re-analyzing the component semantics and defect regions of the generated image to obtain the generated component region and the generated defect region. The generated defect region is projected onto the defect occurrence topology map to determine whether the generated defect region falls into a defect-prone node or a restricted extension node, and whether the boundary direction of the generated defect region is consistent with the defect extension direction recorded in the topology map. If the generated defect region falls into a prohibited occurrence node, crosses a topology edge that does not have surface continuity, or forms a defect texture in a non-defect-preserving domain, the latent variable state, sampling time step, and layered generation conditions corresponding to the generated image are recorded, and the data is returned to the diffusion sampling process for further denoising. In this embodiment, the filtering process uses semantic parsing results and topological constraints as the basis for judgment, which can exclude or write back images that do not conform to the structural relationship of the substation equipment.

[0054] For each pixel in the generated defect region, determine whether it falls within the pixel region corresponding to a defect-prone node or a restricted extension node. The pixel counts falling into the defect-prone region and the pixel counts falling into the restricted extension region are weighted by a reduction factor, summed, and then divided by the total number of pixels in the generated defect region to obtain the region matching ratio. The cosine value of the directional consistency between the principal direction of the generated defect region's boundary and the target extension direction in the pixel-level topological constraint embedding is calculated. The region matching ratio is multiplied by the directional consistency cosine value to obtain the consistency evaluation value. The consistency evaluation value of the generated result is calculated using the following formula: ; Where E represents the consistency evaluation value of the generated results. This indicates the generation of defective regions. This is an indicator function that takes the value 1 when the condition is true and 0 when the condition is false. This indicates the pixel region corresponding to the node where defects can occur. This represents the pixel region corresponding to the restricted expansion node, and k represents the reduction factor of the restricted expansion region, with a value between 0 and 1. This indicates the number of pixels in the generated defect area. Indicates the main direction of the boundary of the generated defect region. E represents the target extension direction in pixel-level topological constraint embedding. When the generated defect region mainly falls into the possible region and the boundary direction is close to the target extension direction, E takes a larger value. When the generated defect region enters the prohibited region or the boundary direction is opposite to the target extension direction, E takes a smaller value and triggers resampling.

[0055] Resampling does not completely discard the generation process. Instead, it utilizes the latent variable states corresponding to the inconsistent regions for local correction. Specifically, it maps the inconsistent defect regions obtained from the generation result back to the latent variable positions of the corresponding sampling time steps, retains the latent variable features of consistent regions, applies constraint embeddings from non-defect-preserving domains or restricted extension nodes to the inconsistent regions, and recovers the diffusion denoising process from the recorded time steps. If the inconsistent region is located at a prohibited node, the latent variable features of the corresponding position in the original substation image are used to replace the region, and the attention channel for the defect type identifier is turned off. If the inconsistent region is located at a restricted extension node but the orientation is inconsistent, the defect candidate texture of the region is retained, and the boundary orientation features are adjusted. If the inconsistent region is located in a boundary transition domain and the texture changes abruptly, the color distribution and edge orientation distribution of the texture reference domain are reread for low-noise stage writing. In this embodiment, resampling is completed using local write-back and conditional correction methods, ensuring that existing correct structural information is preserved.

[0056] In a preferred embodiment, for situations where there is occlusion, uneven lighting, or complex background in the image of the power equipment, the semantic parsing results of the components can be reverse-corrected using a defect occurrence topology map. Specifically, isolated regions inconsistent with the known component topology relationships are searched in the semantic label map. If a region is identified as a critical component but has no connection to the main equipment area and is surrounded by background areas, it is considered a suspected misclassified region, and the open generation component in the generative coding is reduced. If a region is identified as background but is located between the continuous boundaries of two critical components and has similar texture directions, it is considered a candidate component region for topology edge judgment. If there is a small misalignment between the defect labeling area and the boundary of the semantic label map, the component where the defect center is located is taken as the primary occurrence node, and the adjacent areas of the same material covered by the boundary transition domain are set as restricted extension areas. In this embodiment, the topology relationship can constrain the semantic parsing error, preventing the segmentation error from being directly transmitted as an incorrect defect generation location.

[0057] In one embodiment, different defect type identifiers can be set within a shared diffusion model framework to address different defect appearances such as insulator cracks, bushing flashover, hardware corrosion, and leakage marks. However, different defect types still use the same component semantic parsing, topology mapping, mask inversion, and layered condition injection processes. The defect center region of crack-type defects is mainly along the skeleton centerline, with the boundary transition region extending along both sides of the centerline; the defect center region of flashover-type defects is mainly a dark deposition area, with the boundary transition region extending along the surface flow direction; the defect center region of corrosion-type defects is mainly a patch center, with the boundary transition region spreading along the metal surface texture; the defect center region of leakage-type defects is mainly a region with strong color changes, with the boundary transition region extending along the gravity direction or surface flow direction. In this embodiment, the differences between different defect types are reflected through defect type identifiers and mask inversion morphology, while the core processing chain remains consistent.

[0058] In a preferred embodiment, when the input image lacks complete pixel-level defect annotations but only has circumscribed region annotations, candidate defect masks can be generated within the circumscribed region using color differences, local texture anomalies, and edge abrupt changes. The candidate defect masks are then intersected with the component semantic parsing results to obtain the initial defect annotation region. This initial defect annotation region undergoes connected component filtering, hole filling, and boundary smoothing before entering the mask inversion process. If the circumscribed region spans the background and multiple key component regions, the key component region with the largest overlap with the candidate defect mask is selected as the primary generating component. Adjacent key component regions with surface continuity and located along the long axis of the defect are designated as restricted expansion regions. The portion of the circumscribed region falling into the background or prohibited generating nodes does not participate in the construction of the defect center region. In this embodiment, even coarse-grained defect annotations can still form usable inversion mask conditions after component semantic and topological correction.

[0059] Furthermore, image preservation conditions can be formed simultaneously in the latent variable space and pixel space. In the latent variable space, the latent variable features obtained from the original substation equipment image by the encoder are used to extract preservation features according to the non-defect preservation domain. In the pixel space, the local color distribution, edge direction distribution, and surface texture frequency distribution are extracted from the texture reference domain. During the low-noise stage of diffusion sampling, the latent variable space preservation features are preferentially used to write back the non-defect preservation domain, and the pixel space texture features are used to correct the orientation of the boundary transition domain. If the latent variable features and pixel space texture features are inconsistent in orientation during the low-noise stage, the texture reference domain closest to the boundary transition domain within the same critical component area is used as the dominant correction. In this embodiment, the latent variable preservation constraint and the pixel texture constraint jointly define the non-defect region and the defect boundary, without relying on a single image domain for judgment.

[0060] In one embodiment, the output of the generated image may include a complete substation equipment defect image, a defect region analysis map corresponding to the generated image, a component semantic analysis map, and a consistency evaluation record. The complete substation equipment defect image is used for subsequent image sample processing; the defect region analysis map is used to identify the area where the generated defect is located; the component semantic analysis map is used to retain the correspondence between the generated defect and key components; and the consistency evaluation record is used to record the topology node to which the generated defect area belongs, the boundary orientation, the occupancy of the restricted extended area, and whether resampling occurred. All output data maintain the same coordinate dimensions as the input image, facilitating consistency between the image and annotation in subsequent defect detection or defect classification sample libraries. In this embodiment, the generation result simultaneously provides image data and structured constraint data, enabling a traceable technical record of the sample generation process.

[0061] In a preferred embodiment, the hierarchical generation conditions can be validated by conditional ablation after the diffusion model training is completed. During validation, topological conditions, inversion mask conditions, or texture preservation conditions are removed respectively, and the generation results are subjected to the same semantic consistency parsing. If the proportion of generated defects falling into prohibited nodes increases after removing the topological conditions, the injection position and encoding method of the topological conditions are retained. If the generated defect boundary deviates from the original labeled boundary after removing the inversion mask conditions, the noise injection method of the defect center domain and boundary transition domain is retained. If the boundary transition domain shows a region inconsistent with the direction of the texture reference domain after removing the texture preservation condition, the cross-attention writing and preservation domain masking of the low-noise stage are retained. In this embodiment, conditional ablation validation is used to confirm the correspondence of each hierarchical condition in the generation chain and avoid irrelevant conditions from entering the model and causing interference.

[0062] Furthermore, the entire processing can be implemented in a computer program. After receiving the substation equipment image and defect annotation data, the program executes the process in the following order: semantic parsing, topology mapping, mask inversion, conditional encoding, diffusion sampling, consistency filtering, and result output. The region label map generated by semantic parsing, the graph structure generated by topology mapping, the spatial domain labels generated by mask inversion, the vector matrix generated by conditional encoding, and the latent variable states generated by diffusion sampling are all associated with image coordinates or node indices. Any intermediate result can be traced back to the original image region through image coordinates or topology node numbers. If consistency filtering triggers a write-back during the sampling process, the program reads the saved latent variable states and hierarchical generation conditions and continues denoising from the corresponding time step. In this embodiment, there is a clear mapping relationship between the data objects, which enables the stable execution of the substation equipment defect image generation process.

[0063] In all embodiments described in this implementation, the core processing objects are always the substation equipment image, component semantic regions, defect-annotated regions, defect occurrence topology maps, inversion mask conditions, and diffusion model latent variables. The core processing logic always revolves around the consistency between the defect location, defect boundary, and defect texture and the substation equipment structure. Component semantic parsing provides a regional basis for topology mapping, the defect occurrence topology map provides component-level constraints for diffusion generation, mask inversion provides spatial hierarchy for defect regions, and phased condition injection allows topology, morphology, and texture conditions to enter different denoising stages. Semantic consistency constraint screening and mask consistency write-back perform closed-loop correction of the generated results, thereby forming a complete technical chain from the input image to the generated sample. The advantage of this implementation is that the generated image can be constrained by component topology, defect mask, and texture preservation conditions simultaneously, reducing the occurrence of defects in unreasonable components, abrupt defect boundary changes, and erroneous rewriting of non-defect regions.

[0064] This invention further constrains the diffusion sampling process and generation results through generative coding, edge constraint vectors, mask gradient guidance maps, attention masking maps, and semantic consistency constraint filtering. The topological condition matrix, after graph attention propagation, forms pixel-level topological constraint embeddings, enabling defect extension features and prohibited generation features to be mapped to the image space. Two-dimensional weight fields, preservation markers, and conditional open markers are used to distinguish defect centers, transition boundaries, expandable regions, and preservation regions. In the low-noise stage, the local color distribution, edge direction distribution, and surface texture frequency distribution of the texture reference domain constrain the detailed generation of defect boundaries. Mask consistency back-writing of the intermediate denoised image suppresses the appearance of defect textures in non-defect preservation regions. After generation, component semantic parsing and defect region parsing are performed, and the parsing results are back-mapped to the graph structure for consistency judgment. Samples that do not conform to topological constraints and defect extension constraints are returned to the diffusion sampling process for regeneration, thereby improving the consistency between the generated image and the actual structure of the substation equipment.

[0065] See Figure 5 This invention provides a device for generating defect images of substation equipment based on a diffusion model, comprising: The first module is used to acquire images of substation equipment with defect annotations, perform component semantic parsing on the substation equipment images, and obtain the main equipment area, key component area, background area and defect annotation area. The second module is used to establish a defect occurrence topology map based on the spatial correspondence between the key component area and the defect marking area. The defect occurrence topology map includes defect occurrence nodes, defect occurrence prohibited nodes, and restricted expansion nodes. The third module is used to perform mask inversion on the background area and the defect annotation area to obtain the defect center domain, the boundary transition domain, and the non-defect preservation domain. The fourth module is used to encode the defect occurrence topology map and the mask inversion result into the layered generation conditions of the diffusion model, and inject the layered generation conditions in stages during the diffusion denoising process to obtain the generation result; the staged injection includes injecting topology conditions in the high noise stage of diffusion denoising, injecting mask morphology conditions in the medium noise stage, and injecting texture preservation conditions in the low noise stage. The fifth module is used to perform semantic consistency constraint filtering on the generated results to obtain the generated images of substation defects.

[0066] It is evident that the content of the above method embodiments is applicable to this device embodiment. The specific functions implemented in this device embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0067] This invention provides a system for generating defect images of substation equipment based on a diffusion model, comprising: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method described above.

[0068] It is evident that the content of the above method embodiments is applicable to this system embodiment. The specific functions implemented in this system embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0069] Furthermore, embodiments of the present invention also disclose a computer program product or computer program stored in a computer-readable storage medium. A processor of a computer device can read the computer program from the computer-readable storage medium, and the processor executes the computer program, causing the computer device to perform the described method. Similarly, the content of the above method embodiments is applicable to this storage medium embodiment. The specific functions implemented in this storage medium embodiment are the same as those in the above method embodiments, and the beneficial effects achieved are also the same as those achieved in the above method embodiments.

[0070] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs.

[0071] Those skilled in the art will understand that all or some of the steps in the methods disclosed above, as well as the functional modules / units in the systems and devices, can be implemented as software, firmware, hardware, or suitable combinations thereof.

[0072] The terms "first," "second," "third," "fourth," etc. (if present) in the specification and accompanying drawings of this invention are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that embodiments of the invention described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0073] It should be understood that in this invention, "at least one (item)" refers to one or more, and "more than one" refers to two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, "A and / or B" can represent three cases: only A exists, only B exists, and both A and B exist simultaneously, where A and B can be singular or plural. The character " / " generally indicates that the preceding and following related objects are in an "or" relationship. "At least one (item) of the following" or similar expressions refer to any combination of these items, including any combination of single or plural items. For example, at least one (item) of a, b, or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0074] In the several embodiments provided by this invention, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0075] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0076] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0077] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes multiple instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0078] The preferred embodiments of the present invention have been described above with reference to the accompanying drawings, but this does not limit the scope of the claims of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and spirit of the present invention should be within the scope of the claims of the present invention.

Claims

1. A method for generating defect images of substation equipment based on a diffusion model, characterized in that, The method includes the following steps: Obtain images of substation equipment with defect annotations, perform component semantic parsing on the substation equipment images, and obtain key component regions, background regions, and defect annotation regions; A defect occurrence topology map is established based on the spatial correspondence between the key component area and the defect annotation area. The defect occurrence topology map includes defect occurrence nodes, defect occurrence prohibited nodes, and restricted expansion nodes. The background region and the defect-marked region are masked and inverted to obtain the defect center region, the boundary transition region, and the non-defect preservation region. The defect occurrence topology map and the mask inversion result are encoded as the layered generation conditions of the diffusion model, and the layered generation conditions are injected in stages during the diffusion denoising process to obtain the generation result; the staged injection includes injecting topology conditions in the high noise stage of diffusion denoising, injecting mask morphology conditions in the medium noise stage, and injecting texture preservation conditions in the low noise stage. The generated results are filtered by semantic consistency constraints to obtain the generated images of substation defects.

2. The method according to claim 1, characterized in that, The step of establishing a defect occurrence topology map based on the spatial correspondence between the key component region and the defect annotation region includes: The component semantic category corresponding to the key component region is used as the topology node, and the boundaries, inclusion relationships, connection relationships and surface continuity relationships of adjacent components are used as the topology edges; The defect annotation area is mapped to the corresponding topology node, and the defect type, the component where the defect is located, the relative position of the defect and the component boundary, and the extension direction of the defect along the component surface are recorded. Regions that do not exhibit defects but have topological edges with the component containing the defect are marked as restricted expansion regions, forming a graph structure that includes nodes where defects can occur, nodes where defects are prohibited, and restricted expansion nodes.

3. The method according to claim 1, characterized in that, The process of performing mask inversion on the background region and the defect-annotated region to obtain the defect center region, boundary transition region, and non-defect-preserving region includes: The defect annotation mask is skeletonized to obtain the defect centerline or set of center points; Calculate the spatial distance field of the defect boundary based on the defect centerline or set of center points, and divide the defect center domain and boundary transition domain according to the spatial distance field. The region containing non-defective pixels that are adjacent to the boundary transition region and belong to the same critical component region is defined as the texture reference region. The background region and the critical component region that does not match the defect type are identified as non-defect preservation regions, thus obtaining the inversion mask conditions.

4. The method according to claim 3, characterized in that, The step of encoding the defect occurrence topology map and mask inversion results into hierarchical generation conditions for the diffusion model, and injecting these hierarchical generation conditions in stages during the diffusion denoising process, yields the following generation results: In the high-noise stage of diffusion denoising, the component position embedding and topological edge embedding obtained by the defect occurrence topology graph encoding are injected into the low-resolution feature layer of the denoising network. In the middle noise stage of diffusion denoising, the mask conditions corresponding to the defect center domain and the boundary transition domain are injected into the intermediate feature layer of the denoising network. In the low-noise stage of diffusion denoising, the image features corresponding to the texture reference domain and the non-defect preservation domain are injected into the high-resolution feature layer of the denoising network, and the conditional embeddings of different stages share the same defect type identifier.

5. The method according to claim 2, characterized in that, After forming a graph structure containing defect-prone nodes, defect-prohibited nodes, and restricted expansion nodes, the method further includes: Generability encoding of topological nodes includes: generating a node generability vector based on the component semantic category corresponding to the topological node, the shortest topological distance between the node and the defect annotation area, the node surface material characteristics, and the node boundary direction; generating an edge constraint vector based on the spatial angle between two topological nodes connected by a topological edge, the degree of boundary continuity, and the consistency of the defect extension direction; and merging the node generability vector and the edge constraint vector into a topological condition matrix. Graph attention propagation is performed on the topology condition matrix to transmit defect extension features from the topology node where the defect is located to the restricted extension node, and to transmit inhibition features from the prohibited node to its neighboring node. Project the node features after graph attention propagation onto a spatial condition map of the same size as the substation image; Based on the node characteristics of the topological node to which each pixel belongs in the spatial condition map, a pixel-level topological constraint embedding is generated, and the pixel-level topological constraint embedding and the time-step embedding of the diffusion model are jointly input into the denoising network.

6. The method according to claim 3, characterized in that, After obtaining the inversion mask conditions, the method further includes: Constructing a mask gradient guidance map includes: generating a defect intensity decreasing sequence along the direction from the defect center domain to the boundary transition domain, generating a texture fusion sequence along the direction from the boundary transition domain to the texture reference domain, and mapping the defect intensity decreasing sequence and the texture fusion sequence into a two-dimensional weight field; in the two-dimensional weight field, setting a preservation flag for pixels belonging to the non-defect preservation domain, and setting a condition opening flag for regions corresponding to restricted expansion nodes in the defect occurrence topology map, thereby obtaining gradient guidance conditions aligned with the inversion mask condition space; During the diffusion sampling process, a mask consistency write-back is performed on the intermediate denoised image. The mask consistency write-back includes: at each preset denoising time step, spatially registering the candidate defect regions of the intermediate denoised image with the two-dimensional weight field; replacing candidate pixels that fall into the non-defect-preserving domain and carry defect textures with the latent variable features of the corresponding pixels in the original substation equipment image; and correcting candidate pixels that fall into the boundary transition domain and whose texture direction is inconsistent with the texture fusion sequence with the directional features of the adjacent texture reference domain.

7. The method according to claim 4, characterized in that, In the low-noise stage of diffusion denoising, the image features corresponding to the texture reference domain and the non-defect-preserving domain are injected into the high-resolution feature layer of the denoising network, including: Local color distribution, edge direction distribution, and surface texture frequency distribution are extracted from non-defective pixels adjacent to the boundary transition domain and belonging to the same key component region, and the extraction results are cross-attention matched with the latent variable features of the low-noise stage. An attention masking map is generated based on the non-defect preservation domain, so that the defect type identifier only participates in attention calculation in the regions corresponding to the restricted extension nodes in the defect center domain, the boundary transition domain, and the defect occurrence topology map. The matched local texture features are written into the latent variable channel corresponding to the defect boundary.

8. The method according to claim 5, characterized in that, The step of performing semantic consistency constraint filtering on the generated results to obtain the defect image generation result of the substation equipment includes: The generated results are re-analyzed for component semantics and defect regions to obtain the generated component region and the generated defect region. Map the generated defect region to the defect occurrence topology graph, and calculate the matching relationship between the topology node to which the generated defect region belongs and the generability code; The boundary orientation of the generated defect region is compared with the defect extension features embedded in the pixel-level topological constraints; When the matching relationship and the comparison result do not meet the preset consistency conditions, the latent variable state, time step information and hierarchical generation conditions of the corresponding generated result are re-input into the diffusion model for resampling.

9. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method of any one of claims 1 to 8.

10. A system for generating defect images of substation equipment based on a diffusion model, characterized in that, include: At least one processor; At least one memory for storing at least one program; When the at least one program is executed by the at least one processor, the at least one processor performs the method as described in any one of claims 1 to 8.