A method and system for identifying inter-graphic element connection relationships based on image recognition
By constructing a primitive extraction model and a differentiable physical simulator, and combining deep learning and traditional image processing techniques, the problems of lack of primitive semantic information and poor robustness in traditional electrical wiring diagram recognition methods are solved, and efficient and accurate recognition of electrical wiring diagrams is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- STATE GRID SICHUAN ELECTRIC POWER CORP ELECTRIC POWER RES INST
- Filing Date
- 2026-01-30
- Publication Date
- 2026-04-28
AI Technical Summary
Traditional electrical wiring diagram recognition methods lack the ability to mine and extract semantic information of graphic elements, have poor robustness of connections between graphic elements, and lack reasonable judgment on the generated topology under physical laws and electrical rules.
A primitive extraction model is constructed, and the model is pre-trained using a pre-built training dataset. Primitives are identified using deep learning and traditional image processing techniques. A graph attention network is used to capture potential associations, generating a primitive priority connection table. Circuit semantic simulation is performed using a differentiable physical simulator to verify the model, and an accurate primitive connection network is generated through iterative optimization.
It achieves high-precision and high-efficiency identification of electrical wiring diagrams, improves the overall efficiency of identifying element connection relationships, and ensures the physical rationality and robustness of the generated results.
Smart Images

Figure CN121616843B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image processing technology, and more specifically, to a method and system for recognizing the connection relationships between graphic elements based on image recognition. Background Technology
[0002] Electrical wiring diagrams, as key technical documents describing the connection relationships of electrical systems, are widely used in industrial fields such as power system design, equipment manufacturing, operation and maintenance. With the acceleration of digital transformation, how to achieve high-precision recognition of electrical wiring diagrams has become a major challenge for industrial intelligence. Traditional wiring diagram analysis methods often have certain limitations in the face of this challenge.
[0003] On the one hand, traditional methods typically identify only labeled boxes as primitives, often lacking the mining and extraction of semantic information, and are often less robust when extracting connecting lines between primitives. On the other hand, traditional methods mostly start from the visual features of the image, often lacking the judgment of whether the generated topology is reasonable under physical laws and electrical rules.
[0004] Therefore, this application is hereby submitted. Summary of the Invention
[0005] The purpose of this invention is to provide a method and system for recognizing the connection relationship between graphic elements based on image recognition, so as to achieve high-precision and high-efficiency recognition of the connection relationship between graphic elements.
[0006] The above-mentioned technical objective of the present invention is achieved through the following technical solution:
[0007] In a first aspect, this application provides a method for recognizing the connection relationship between primitives based on image recognition, including the following specific steps:
[0008] S1. Construct a primitive extraction model and pre-train the model using a pre-built training dataset. The primitive extraction model includes a primitive recognition submodule and a neural coding submodule.
[0009] S2, input the wiring diagram to be identified into the primitive extraction model for analysis and identification, and output the primitive neural coding set, which includes the primitive entity set and the entity coding set;
[0010] S3, perform primitive connection relationship reasoning on primitive neural coding set based on generative flow network, and generate the corresponding initial primitive connection network;
[0011] S4. A pre-built differentiable physical simulator is used to perform circuit semantic simulation verification on the initial primitive connection network, and simulation verification results are generated.
[0012] S5. Based on the simulation verification results, iteratively execute steps S3 to S4 to generate an accurate primitive connection network.
[0013] Based on the above technical solution, the present invention can be further improved as follows.
[0014] Furthermore, the above-mentioned primitive extraction model is constructed and pre-trained using a pre-built training dataset, including:
[0015] A set of synthetic electrical wiring diagrams is constructed by combining preset electrical constraint rules and a preset primitive knowledge base, and the set of synthetic electrical wiring diagrams is used as the first training dataset.
[0016] Obtain historically identified electrical wiring diagrams and combine them to generate a second training dataset.
[0017] Each wiring diagram in the first training dataset and the second training dataset corresponds to a primitive attribute set, which includes at least primitive category data, primitive attribute data and text attributes.
[0018] The YOLOv5 architecture is optimized using the CARAFE upsampling operator, and a primitive detector is built based on the optimized YOLOv5 architecture.
[0019] A bus detector is constructed using traditional image processing algorithms and a preset set of bus constraint rules.
[0020] A text recognizer is constructed using a text detection model based on differentiable binarization and a convolutional recurrent neural network.
[0021] A primitive recognition submodule is constructed based on a primitive detector, a bus detector, and a text recognizer. This primitive recognition submodule is used to generate primitive entity sets.
[0022] Furthermore, the above methods also include:
[0023] A primitive attribute encoder is constructed based on a preset primitive knowledge base and preset encoding rules. The primitive attribute encoder is used to generate corresponding attribute codes for each primitive in the primitive entity set.
[0024] Attribute encoding includes at least primitive ID, semantic feature attributes, visual feature attributes, and spatial feature attributes;
[0025] A graph neural network is used to construct a graph primitive connection priority predictor. The graph primitive connection priority predictor performs multi-feature evaluation based on the graph primitive entity set and the corresponding attribute encoding to generate a graph primitive priority connection table.
[0026] Multi-feature evaluation includes at least semantic compatibility evaluation, spatial proximity evaluation, directional consistency evaluation, and textual context evaluation;
[0027] A neural coding submodule is constructed based on a primitive attribute encoder and a primitive connection priority predictor. The neural coding submodule is used to generate entity coding sets.
[0028] The primitive recognition submodule and the neural coding submodule are pre-trained by combining the first training dataset and the second training dataset.
[0029] Furthermore, the wiring diagram to be identified is input into the primitive extraction model for analysis and identification, and the output primitive neural coding set includes:
[0030] After the wiring diagram to be identified is input into the graphic element extraction model, the graphic element recognition submodule performs graphic element recognition and extraction on the wiring diagram to be identified, and generates a corresponding graphic element entity set. The attributes of each graphic element entity in the graphic element entity set include at least graphic element type, spatial features and corresponding entity features.
[0031] The neural coding submodule performs semantic matching from a preset primitive knowledge base based on the primitive type in the primitive entity set to generate corresponding semantic feature attributes.
[0032] The entity features and spatial features are encoded by combining preset encoding rules to generate corresponding visual feature attributes and spatial feature attributes;
[0033] Semantic, visual, and spatial features are encapsulated into entity encoding sets. Multi-feature evaluation is performed by combining the primitive entity set with the entity encoding set to generate a primitive priority connection table.
[0034] The primitive entity set, entity encoding set, and primitive priority connection table are output as the primitive neural encoding set.
[0035] Furthermore, the above-mentioned inference of primitive connection relationships on the primitive neural coding set based on the generative flow network generates the corresponding initial primitive connection network, specifically as follows:
[0036] A graph attention network is used to decode the graph primitive neural coding set, dynamically capture the latent semantic relationships between graph primitives, and generate a graph primitive attention weight matrix.
[0037] A hierarchical decision-making generative flow network iteratively optimizes the original primitive connection network to generate the corresponding initial primitive connection network. The hierarchical decision-making generative flow network includes a macroscopic routing layer and a microscopic path layer, wherein:
[0038] The macro-routing layer generates the original primitive connection backbone network based on the primitive attention weight matrix and the preset primitive prior knowledge base;
[0039] The micro-path layer is based on the original primitive connection backbone network, and simultaneously combines the primitive priority connection table contained in the primitive neural coding set to perform fine branch connections, generating the original primitive connection network.
[0040] The original primitive connection network is evaluated based on a multi-dimensional primitive connection evaluation mechanism. The original primitive connection network is then optimized based on the evaluation results to generate an initial primitive connection network.
[0041] Furthermore, the original primitive connectivity network is evaluated based on the multi-dimensional primitive connectivity evaluation mechanism, and optimized according to the evaluation results to generate an initial primitive connectivity network, including:
[0042] The matching degree between the primitive connection lines in the original primitive connection network and the corresponding visual feature attributes in the primitive neural coding set is evaluated to generate a visual fit score.
[0043] A deep learning-based latent empirical encoder is used to re-encode the original primitive connection network to generate latent feature codes, and the corresponding latent empirical fit score is generated based on the latent feature codes.
[0044] Uncertainty assessment is performed on the original primitive connection network to generate a corresponding uncertainty knowledge graph, which is used to characterize the uncertainty of each connection in the original primitive connection network.
[0045] A comprehensive evaluation result is generated based on visual consistency score, implicit experience consistency score, and uncertainty knowledge graph.
[0046] If the comprehensive evaluation results meet the preset qualification conditions, the original primitive connection network will be output as the initial primitive connection network.
[0047] If the comprehensive evaluation results do not meet the preset qualification conditions, the original primitive connection network will be iteratively optimized based on the comprehensive evaluation results until the preset qualification conditions are met.
[0048] Furthermore, the above-mentioned pre-built differentiable physical simulator is used to perform circuit semantic simulation verification on the initial primitive connection network, generating simulation verification results, including:
[0049] Based on a pre-defined primitive knowledge base, each identified primitive in the initial primitive connection network is materialized to obtain a set of physical models corresponding to all primitives.
[0050] The physical model set and the initial primitive connection network are input into a predefined differentiable physical simulator for simulation, and the simulation results are obtained.
[0051] Based on the preset physical consistency verification rules and simulation results, the initial primitive connection network is error located and corresponding simulation verification results are generated.
[0052] The simulation verification results should include at least the physical consistency loss, error localization map, and corresponding gradient quantization values.
[0053] The error localization map is represented by the primitive connection relationships in the initial primitive connection network that are determined to have connection errors during circuit semantic simulation verification.
[0054] Furthermore, the aforementioned preset physical consistency verification rules include:
[0055] The preset physical consistency verification rule is represented by transforming the constraint rules in the preset electrical constraint rule library into a rule verification loss function, and obtaining the corresponding rule verification loss by combining the simulation results;
[0056] The rule verification loss function includes at least conductor consistency loss, switch state consistency loss and energy conservation loss;
[0057] The conductor consistency loss is obtained by verifying whether the voltage difference between the two ends of the conductor conforms to a predetermined rule.
[0058] The switch state consistency loss is obtained by verifying whether the actual state of the switch matches the predefined state.
[0059] By verifying the balance of input and output power in the circuit, the energy conservation loss can be obtained;
[0060] The weighted fusion rule verification loss generates the physical consistency loss, and the connection error judgment and gradient quantization are performed on the primitive connection relationship of the initial primitive connection network based on the physical consistency loss;
[0061] If the physical consistency loss does not reach the predetermined threshold, the process ends;
[0062] If the physical consistency loss reaches a predetermined threshold, the error primitive connection relationship is located in the initial primitive connection network, and the corresponding gradient quantization value is generated.
[0063] The gradient quantization value indicates the contribution of each primitive connection relationship in the initial primitive connection network to the physical consistency loss. The larger the gradient quantization value, the greater the error of the primitive connection relationship.
[0064] Furthermore, the above-mentioned iterative execution steps S3 to S4 based on simulation verification results generate an accurate primitive connection network, including:
[0065] The simulation verification results are input into the generator flow network. The generator flow network fine-tunes the priority connection table of the primitives corresponding to the wiring diagram to be identified and the strategy network parameters inside the generator flow network based on the error localization map and the corresponding gradient quantization value contained in the simulation verification results.
[0066] After completing the corresponding parameter adjustments, a new initial primitive connection network is regenerated, and the circuit semantic simulation verification is performed on this new initial primitive connection network again.
[0067] The iterative process of adjusting execution parameters, generating the initial primitive connection network, and performing circuit semantic simulation verification continues until a predetermined iteration termination condition is met, at which point the loop ends; where:
[0068] The predetermined iteration termination condition is expressed as at least satisfying any one of the following: the physical consistency loss is less than a predetermined threshold, the loss decrease in consecutive iterations is less than a predetermined loss decrease, or the predetermined maximum number of safe iterations is reached.
[0069] Secondly, this application provides an image recognition-based system for identifying inter-element connection relationships, applied to any of the image recognition-based methods for identifying inter-element connection relationships in the first aspect, comprising:
[0070] The model building module is used to build a primitive extraction model and pre-train the model using a pre-built training dataset.
[0071] The primitive encoding module is used to input the wiring diagram to be identified into the primitive extraction model for analysis and identification, and output the primitive neural encoding set.
[0072] The connection reasoning module is used to infer the primitive connection relationships of the primitive neural coding set based on the generated flow network, and generate the corresponding initial primitive connection network.
[0073] The simulation verification module is used to perform circuit semantic simulation verification on the initial primitive connection network based on the differentiable physical simulator, and generate simulation verification results.
[0074] The iterative optimization module is used to iteratively execute the methods from the connection inference module to the simulation verification module based on the simulation verification results, and generate an accurate primitive connection network.
[0075] Thirdly, this application provides an electronic device, including: at least one processor, at least one memory, and a data bus;
[0076] In this system, the processor and the memory communicate with each other via a data bus; the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute a method for recognizing the connection relationship between primitives based on image recognition, as described in any of the first aspects.
[0077] Fourthly, this application provides a non-transitory computer-readable storage medium that stores computer instructions that cause a computer to execute any one of the methods for recognizing the connection relationship between graphic elements based on image recognition in the first aspect.
[0078] Compared with the prior art, the present invention has at least the following beneficial effects:
[0079] 1. Construct a primitive extraction model and pre-train it using a pre-built training dataset. Input the wiring diagram to be identified into the primitive extraction model for analysis and recognition, and output a primitive neural coding set. The primitive neural coding set includes a primitive entity set and an entity coding set. By integrating deep learning and traditional image processing techniques, high-precision recognition of electrical primitives and symbolic conversion of corresponding features are achieved, providing a data foundation for subsequent reasoning and analysis of primitive connection relationships. At the same time, by combining a graph attention network to dynamically capture potential associations between primitives, a primitive priority connection table is generated, thereby compressing the huge primitive connection possibility space into a smaller high-probability region, providing key prior knowledge for subsequent steps, and improving the overall efficiency of primitive connection relationship recognition.
[0080] 2. Based on the generative flow network, the graph primitive neural coding set is used to infer the graph primitive connection relationship and generate the corresponding initial graph primitive connection network. A hierarchical generative flow network with macro-routing and micro-path coordination is used to explore a variety of possible reasonable topological assumptions in parallel, thereby ensuring robustness in complex scenarios.
[0081] 3. A pre-built differentiable physical simulator is used to perform circuit semantic simulation verification on the initial primitive connection network, generating simulation verification results. By constructing a differentiable physical simulation engine, the physical contradictions in the initial primitive connection network are accurately located, and a clear gradient direction is provided for automatic correction, thereby ensuring the physical rationality of the generated results.
[0082] 4. Based on the simulation verification results, iteratively execute steps S3 to S4 to generate a precise primitive connection network, ultimately achieving efficient, fast, and accurate identification of electrical wiring diagrams. Attached Figure Description
[0083] The accompanying drawings, which are included to provide a further understanding of embodiments of the invention and form part of this application, do not constitute a limitation thereof. In the drawings:
[0084] Figure 1 This is a flowchart of the method for identifying the connection relationship between graphic elements in an embodiment of the present invention;
[0085] Figure 2 This is a schematic diagram of the primitive extraction model in the primitive connection relationship recognition method in this embodiment of the invention;
[0086] Figure 3 This is a connection diagram of the inter-element connection relationship recognition system in an embodiment of the present invention. Detailed Implementation
[0087] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations.
[0088] Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0089] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures.
[0090] In the description of the embodiments of the present invention, "multiple" means at least two.
[0091] Example 1: This example provides a method for recognizing the connection relationship between primitives based on image recognition, such as... Figure 1 and Figure 2 As shown, it includes the following steps:
[0092] Step S1: Construct a primitive extraction model and pre-train the model using a pre-built training dataset. The primitive extraction model includes a primitive recognition submodule and a neural coding submodule.
[0093] Understandably, a set of synthetic electrical wiring diagrams is constructed by combining preset electrical constraint rules and a preset primitive knowledge base, and the set of synthetic electrical wiring diagrams is used as the first training dataset; historically identified electrical wiring diagrams are obtained, and the historically identified electrical wiring diagrams are combined to generate a second training dataset; each wiring diagram in the first training dataset and the second training dataset corresponds to a primitive attribute set, and the primitive attribute set includes at least primitive category data, primitive attribute data, and text attributes.
[0094] In this embodiment, step S1 includes:
[0095] Step S1-1: Construct and train the primitive recognition submodule.
[0096] Specifically, the CARAFE upsampling operator is used to optimize the YOLOv5 architecture, and a primitive detector is built based on the optimized YOLOv5 architecture; a bus detector is built using traditional image processing algorithms and a preset bus constraint rule set; a text recognizer is built using a text detection model based on differentiable binarization and a convolutional recurrent neural network; a primitive recognition submodule is built based on the primitive detector, the bus detector, and the text recognizer, and the primitive recognition submodule is pre-trained using the first training dataset and the second training dataset.
[0097] In one possible embodiment, a primitive detector based on an improved YOLOv5 is first constructed. The improved YOLOv5 refers to replacing the standard upsampling operation at the connection between the Backbone and Neck with the CARAFE upsampling operator. Specifically, the CARAFE upsampling operator includes two components: a kernel prediction module and a content-aware reconstruction module. The kernel prediction module predicts the reconstruction kernel for each position in the wiring diagram to be identified using a 1×1 convolution and a sigmoid activation function. The content-aware reconstruction module then performs weighted reconstruction of the contextual features of that position based on the reconstruction kernel predicted by the kernel prediction module. For example, when the primitive detector needs to detect a miniature current transformer that occupies only 0.3% of the image area, during the upsampling process from the fourth layer feature map to the third layer, CARAFE analyzes the contextual features of the connecting wires and insulators around the area where the miniature current transformer is located, predicts a reconstruction kernel specifically optimized for small ring structures, and performs weighted reconstruction of its original features based on this reconstruction kernel, thereby enhancing the circular features of the transformer.
[0098] During training, a progressive multi-scale training strategy is employed to train the primitive detector. Specifically, during training, the wiring diagram images in each batch are randomly scaled to any size within the range of [320×320, 960×960]. Simultaneously, random color adjustments, rotations, and shearing are applied, along with Mosaic-9 data augmentation for electrical primitives. Nine training images are then stitched together into one, significantly improving the primitive detector's ability to identify densely packed small targets. The loss function is a joint loss function of GIoU loss, classification loss, and object-specific loss, and backpropagation automatically learns the most suitable recombination strategy for electrical primitive features. To address the imbalance in the number of primitive categories in the wiring diagram, Focal Loss is introduced to reduce the weight of easily classified samples, allowing the primitive detector to focus more on rare primitives that are difficult to classify. For example, when there are far more circuit breaker samples than disconnector samples in the training data, Focal Loss will automatically reduce the loss contribution of a large number of circuit breaker samples and increase the training weight of disconnector samples, which have a relatively smaller number of samples.
[0099] For busbars, which have unique geometric characteristics, a busbar detector based on traditional image processing algorithms is constructed. Specifically, firstly, all line segments in the wiring diagram to be identified are extracted using the LSD straight line detection algorithm. Then, busbar identification is performed according to a preset three-level filtering rule. The three-level filtering rule includes: a length threshold filtering rule, which removes horizontal line segments whose length exceeds 1 / 4 of the width of the input image and vertical line segments whose length exceeds 1 / 4 of the height of the input image; an endpoint analysis filtering rule, which removes line segments whose ends are connected to other graphic elements; and a vertical connection point verification rule, which retains line segments with graphic element connections in the vertical direction in the middle of the line. For example, when detecting the main busbar that runs through the top of the drawing, firstly, line segments that do not reach the threshold are removed according to the length threshold filtering rule. Then, line segments with graphic elements connected to both ends are filtered out according to the endpoint analysis filtering rule. Finally, it is confirmed whether the retained line segments have multiple down leads connected to graphic element devices in the vertical direction, thereby completing the detection and identification of the busbar.
[0100] The text recognizer is constructed using a differentiable binarization-based text detection model and a convolutional recurrent neural network. The differentiable binarization-based text detection model enhances the primitive recognition submodule's ability to recognize irregular text. During training, it incorporates a hard example mining strategy to automatically recognize and process irregular text samples such as those that are stuck to primitives or distorted. The convolutional recurrent neural network improves the text recognition accuracy of the primitive recognition submodule in complex backgrounds. For example, when recognizing the text "QF-102" that overlaps with the circuit breaker symbol, the differentiable binarization-based text detection model first segments the text into character regions. The attention mechanism within the convolutional recurrent neural network focuses on the connection between "Q" and "F" and the numerical region of "102" during text recognition, thus avoiding misidentifying "QF" as "OF".
[0101] Steps S1-2: Construct and train the neural coding submodule.
[0102] Specifically, a primitive attribute encoder is constructed based on a pre-defined primitive knowledge base and pre-defined encoding rules. The primitive attribute encoder is used to generate corresponding attribute codes for each primitive in the primitive entity set. The attribute codes include at least primitive ID, semantic feature attributes, visual feature attributes, and spatial feature attributes. A primitive connection priority predictor is constructed using a graph neural network. The primitive connection priority predictor performs multi-feature evaluation based on the primitive entity set and the corresponding attribute codes to generate a primitive priority connection table. The multi-feature evaluation includes at least semantic compatibility evaluation, spatial proximity evaluation, directional consistency evaluation, and textual context evaluation. A neural coding submodule is constructed based on the primitive attribute encoder and the primitive connection priority predictor, and the neural coding submodule is pre-trained using the first training dataset and the second training dataset.
[0103] In one possible embodiment, the invocation of the preset encoding rules of the primitive attribute encoder is accomplished by three components: a visual feature encoder, a knowledge query module, and a spatial relationship encoder. The visual feature encoder is used to extract depth features from the detected primitive regions; the knowledge query module is used to retrieve semantic attributes of the corresponding primitive type from the preset primitive knowledge base; and the spatial relationship encoder is used to calculate the relative position and orientation features between primitives. Specifically, the visual feature encoder adopts a deep convolutional neural network structure and uses a feature extraction mechanism based on Faster R-CNN for feature optimization, and finally outputs a depth feature vector. During the training process, an end-to-end training method is used to learn the discriminative feature representation of electrical primitives. For example, when processing a detected disconnector primitive, the visual feature encoder will focus on extracting its unique disconnector structure features and insulator support features, relatively ignoring its drawing style, color, and other conventional features, and finally generate a depth feature vector that can effectively distinguish between disconnectors and circuit breakers.
[0104] The knowledge query module is used to retrieve information from a pre-defined primitive knowledge base. This base is constructed by parsing standard documents and industry design specifications in the electrical field. It stores knowledge in the form of a knowledge graph, where each node's attributes include semantic information such as primitive type, electrical attributes, and connection rules. Both electrical attributes and connection rules correspond to a specific function form to facilitate subsequent circuit semantic simulation verification. The knowledge query module uses a graph neural network to encode the pre-defined primitive knowledge base, transforming the discrete, symbolic primitive knowledge into a continuous vector representation. When a specific primitive type is input, the module performs multi-hop reasoning within the pre-defined primitive knowledge base using a graph attention mechanism to retrieve relevant primitive attribute information and corresponding constraints. For example, when querying semantic knowledge information about a voltage transformer, the module not only retrieves and returns basic semantic attributes such as measuring equipment and single-phase / three-phase, but also derives deeper semantic information such as mandatory grounding and accuracy requirements by inferring the relational edges in the corresponding knowledge graph of the pre-defined primitive knowledge base.
[0105] The spatial relationship encoder is used to process eight basic spatial relationships: top left, top right, top right, left, right, bottom left, bottom right, and bottom right, as well as precise spatial distance and angle information. It captures the complex spatial relationships between primitives and their multiple neighboring primitives through a multi-head attention mechanism, generating a comprehensive spatial context feature vector. For example, when analyzing the relationship between a circuit breaker and an adjacent disconnector, the spatial relationship encoder first calculates the spatial distance and direction angle between them, and then analyzes the spatial relationships between them and adjacent primitives such as buses and loads, generating the corresponding spatial context feature vector.
[0106] The spatial relationship encoder is trained using a multi-task joint loss function that combines soft-label cross-entropy loss, smooth L1 loss, multi-label softmax loss, and hierarchical classification loss. The soft-label cross-entropy loss is used to avoid overfitting the training data, the smooth L1 loss is used to regress the coordinates of primitive connection points, the multi-label softmax loss is used to predict the electrical attributes of primitives, and the hierarchical classification loss is used to identify the functional categories of primitives. The weights of the above four loss functions are adaptively adjusted using an uncertainty weighting method to ensure that the performance of the multi-task joint loss function reaches its optimal level.
[0107] An undirected fully connected graph is constructed based on the set of graph entity identified by the graph entity recognition submodule. The node attributes of the nodes in the undirected fully connected graph consist of semantic feature attributes, visual feature attributes, and spatial feature attributes extracted by the graph entity attribute encoder. A graph entity connection priority predictor is established using a three-layer graph attention network architecture. It should be noted that each layer of the graph attention network contains 8 attention heads, each of which corresponds to an attention direction. For example, there are Euclidean distance attention heads, relative orientation attention heads, connection point orientation matching attention heads, latent path complexity attention heads, electrical type compatibility attention heads, functional hierarchy consistency attention heads, betweenness centrality attention heads, and indirect association reasoning attention heads.
[0108] The first layer of the graph attention network uses the ELU activation function. Each attention head in this layer is used to calculate the attention coefficients between nodes, calculate the correlation scores between node features, and normalize the correlation scores using softmax normalization to generate corresponding attention weights. At the same time, the node attributes of each graph node in the undirected fully connected graph are updated based on the attention weights, and the updated node attributes and corresponding attention weights of each graph node are input into the second layer of the attention network. The second layer of the attention network performs residual concatenation between the output of the first layer and the original graph node attributes of the undirected fully connected graph, and calculates the attention weights again. The third layer of the attention network uses average pooling to aggregate the outputs of multiple attention heads, and uses the sigmoid function to generate a normalized connection priority score for the connection relationship between each graph node and its corresponding graph node, finally generating a complete primitive priority connection table.
[0109] For example, suppose a simple wiring diagram contains the following three main elements: circuit breaker CB1, located in the upper left corner of the diagram; horizontal busbar BUS1, running across the top of the diagram; and load LOAD1, located in the lower right corner of the diagram. The goal of the element connection priority predictor is to predict the connection priority of circuit breaker CB1 with horizontal busbar BUS1 and load LOAD1, respectively. First, these three elements are constructed into a graph structure, where each element corresponds to a graph node. Some node attributes of node CB1 are {visual feature attribute: rectangular switch shape, semantic feature attribute: two-port device, spatial feature attribute: coordinates in the upper left corner}; some node attributes of node BUS1 are {visual feature attribute: long straight line, semantic feature attribute: common conductor, spatial feature attribute: coordinates in the top}; and some node attributes of node LOAD1 are {visual feature attribute: circular or rectangular symbol, semantic feature attribute: energy-consuming device, spatial feature attribute: coordinates in the lower right corner}.
[0110] The first layer of the graph attention network has eight attention heads. Assuming attention head 1 focuses on analyzing the electrical type compatibility of semantic feature attributes, it finds that CB1 and BUS1 have a very good electrical type compatibility match. Because circuit breakers are often connected to busbars, it assigns a relevance score of 2.5 to connecting CB1 to BUS1. Meanwhile, the electrical type compatibility between CB1 and LOAD1 is relatively weaker, thus assigning a relevance score of 1.2. Then, after the soft... After max normalization, the attention weights for CB1 connecting to BUS1 and CB1 connecting to LOAD1 are 0.79 and 0.21, respectively. Similarly, the attention weights for the other 7 attention heads for CB1 connecting to BUS1 and CB1 connecting to LOAD1 are {0.97, 0.48, 0.55, 0.70, 0.90, 0.60, 0.75} and {0.03, 0.52, 0.45, 0.30, 0.10, 0.40, 0.25}, respectively. The relevance scores of the 8 attention heads are weighted and fused to generate attention weights for CB1 connecting to BUS1 and CB1 connecting to LOAD1 of 0.72 and 0.28, respectively. The graph node attributes are then weighted and fused using these attention weights. That is, the graph node attributes of CB1 are weighted and fused with the graph node attributes of BUS1 and LOAD1 in a ratio of 0.72:0.28. Similarly, the graph node attributes of BUS1 and LOAD1 are fused in the same way.
[0111] The second-layer graph attention network receives the attention weights output by the first-layer graph attention network and, through residual connections, superimposes and merges the node attributes of the graph nodes updated based on the attention weights with the original node attributes that have not been updated, generating corresponding enhanced node attributes. At the same time, the second-layer attention head recalculates the attention weights based on the enhanced node attributes. Assuming that the attention weights corresponding to CB1 connecting BUS1 and CB1 connecting LOAD1 generated by the second layer are 0.65 and 0.35 respectively, the graph node attributes corresponding to each graph node are updated again based on these attention weights.
[0112] Similarly, the third-layer graph attention network repeats the above operations to update the graph node attributes corresponding to each graph node, generating the final graph node attributes for each graph node. Assuming that the attention weights for CB1 connecting to BUS1 and CB1 connecting to LOAD1 are 0.68 and 0.32 respectively, the absolute values of the element-wise differences between the graph node attributes of CB1 and BUS1, and CB1 and LOAD1 are obtained, generating two feature difference vectors. Assuming that the feature vectors corresponding to the final graph node attributes of CB1, BUS1, and LOAD1 are [0.8, 0.75, 0.68], [0.7, 0.66, 0.72], and [0.56, 0.43, 0.71], then the corresponding feature differences... The vectors are [0.1, 0.09, 0.04] and [0.24, 0.32, 0.01]. The above feature difference vectors are input into a multilayer perceptron. The output of the Sigmoid activation function is a scalar between 0 and 1. This scalar is the final connection priority score. Suppose that the final connection priority scores for CB1 connecting to BUS1 and CB1 connecting to LOAD1 are 0.96 and 0.25, respectively. This indicates that the primitive extraction model believes that CB1 should be directly connected to BUS1, while the possibility of CB1 being directly connected to LOAD1 is very low (this is just an example of the operation process of the three-layer graph attention network architecture. The specific implementation needs to be adjusted according to the actual situation).
[0113] Step S2: Input the wiring diagram to be identified into the primitive extraction model for analysis and identification, and output the primitive neural coding set, which includes the primitive entity set and the entity coding set.
[0114] Specifically, after the wiring diagram to be identified is input into the primitive extraction model, the primitive recognition submodule performs primitive recognition and extraction on the wiring diagram to be identified, generating a corresponding primitive entity set. The attributes of each primitive entity in the primitive entity set include at least primitive type, spatial features, and corresponding entity features. The neural coding submodule performs semantic matching from a preset primitive knowledge base based on the primitive type in the primitive entity set, generating corresponding semantic feature attributes. It then encodes the entity features and spatial features in combination with preset coding rules, generating corresponding visual feature attributes and spatial feature attributes. The semantic feature attributes, visual feature attributes, and spatial feature attributes are encapsulated into an entity coding set. Multi-feature evaluation is performed by combining the primitive entity set and the entity coding set to generate a primitive priority connection table. Finally, the primitive entity set, entity coding set, and primitive priority connection table are output as a primitive neural coding set.
[0115] In one possible embodiment, before the wiring diagram to be identified is input into the primitive extraction model, it first needs to be grayscaled and adaptively binarized to enhance the contrast between the foreground and background. Then, a multi-scale sliding window strategy is used to segment the image, generating sub-image blocks of different sizes, such as 256×256, 512×512, and 1024×1024, to ensure that primitives of different scales can be effectively detected. After each sub-image block is input into the primitive extraction model, primitive detection is performed by combining a primitive detector, a bus detector, and a text recognizer. The model outputs the category label, confidence score, and bounding box coordinates of each primitive in the wiring diagram to be identified. Simultaneously, non-maximum suppression is applied to the output results to eliminate duplicate detections. For example, in a 512×512 sub-image block, the primitive detector detects a circuit breaker primitive, whose corresponding feature vector is {primitive category: circuit breaker}. The bounding box coordinates are (100, 50, 150, 100), and the confidence level is 0.95. A text region is detected near the circuit breaker element, and the feature vector corresponding to this region can be represented as {text content: QF1, bounding box: (110, 40, 130, 60), confidence level: 0.98}. This text will be associated with the corresponding circuit breaker element and used as its text label. At the same time, a relay element is also detected, and its corresponding feature vector is {element category: relay, bounding box coordinates: (200, 80, 220, 100), confidence level: 0.32}. Non-maximum suppression is applied to the detected results. At this time, the detection results with high confidence will be retained, and the detection results with low confidence that may overlap will be removed. It should be noted that the evaluation criteria for high and low confidence are based on a preset confidence threshold, which is obtained by analyzing historical data.
[0116] All detection results are input into the neural coding submodule for symbolic transformation. This module generates a unique primitive ID for each primitive and constructs a multidimensional feature vector, which includes semantic, visual, and spatial features. Simultaneously, it combines the primitive connection priority predictor within the module to analyze the priority of the connection relationships between primitives and outputs the corresponding connection priority score. Finally, the multidimensional feature vectors corresponding to the detection results of all sub-image blocks are combined and deduplicated to generate a structured feature list, which is output as the primitive neural coding set. For example, for the detected circuit breaker primitive, part of its corresponding multidimensional feature vector can be represented as {ID: CB001, type: circuit breaker, semantic attribute: [dual-port device, normal closure], spatial attribute: center coordinates (125, 75), connection priority score: [connected to bus: 0.95, connected to distant load: 0.15}.
[0117] Step S3: Based on the generative flow network, perform graph primitive connection relationship reasoning on the graph primitive neural coding set to generate the corresponding initial graph primitive connection network.
[0118] Specifically, a graph attention network is used to decode the graph primitive neural encoding set, dynamically capturing the latent semantic relationships between graph primitives and generating a graph primitive attention weight matrix. A hierarchical decision-making generative flow network is used to iteratively optimize the original graph primitive connection network. The hierarchical decision-making generative flow network includes a macro-routing layer and a micro-path layer. The macro-routing layer generates the original graph primitive connection backbone network based on the graph primitive attention weight matrix and a preset graph primitive prior knowledge base. The micro-path layer, based on the original graph primitive connection backbone network, simultaneously combines the graph primitive priority connection table contained in the graph primitive neural encoding set to perform fine branch connections, generating the original graph primitive connection network.
[0119] Furthermore, the matching degree between the primitive connections in the original primitive connection network and the corresponding visual feature attributes in the primitive neural coding set is evaluated to generate a visual fit score. The original primitive connection network is re-encoded using a deep learning-based latent empirical encoder to generate latent feature codes, and the corresponding latent empirical fit score is generated based on the latent feature codes. The uncertainty of the original primitive connection network is evaluated to generate a corresponding uncertainty knowledge graph, which is used to represent the uncertainty of each connection in the original primitive connection network.
[0120] A comprehensive evaluation result is generated based on visual consistency score, implicit experience consistency score, and uncertainty knowledge graph.
[0121] If the comprehensive evaluation results meet the preset qualification conditions, the original primitive connection network will be output as the initial primitive connection network.
[0122] If the comprehensive evaluation results do not meet the preset qualification conditions, the original primitive connection network will be iteratively optimized based on the comprehensive evaluation results until the preset qualification conditions are met.
[0123] Understandably, the Latent Empirical Encoder (LEE) performs message passing and feature aggregation on the topology of the initial primitive connection network using a graph convolutional network or a graph attention network, outputting the mean and variance vectors of its distribution in a predefined latent space. Its decoder uses a simple inner product operation to reconstruct the original adjacency matrix from the mean and variance vectors. The LEE uses a large number of identified wiring diagrams as training data and is trained with the goal of minimizing the reconstruction error and the regularization term of the latent distribution, thereby learning to encode the topology of the initial primitive connection network into a compact continuous space.
[0124] In one possible embodiment, a graph attention network is used to decode the primitive neural encoding set, dynamically capturing the latent semantic relationships between primitives and generating a primitive attention weight matrix. Specifically, based on a confidence benchmark, the primitive priority connection table contained in the primitive neural encoding set is filtered, and primitive connection pairs with connection priority scores not lower than the confidence benchmark are defined as high-confidence primitive connection pairs. These primitive connection pairs are directly converted into a binary skeleton attention weight matrix, thereby quickly forming a reliable and simplified topological skeleton, reducing the search space required for the generated flow network. Taking circuit breaker CB1, bus BUS1, and load LOAD1 as an example, assuming P(CB1-BUS1)=0.95 and P (BUS1-LOAD1)=0.87, meaning the connection priority scores of CB1 connecting BUS1 and LOAD1 are 0.95 and 0.87 respectively. Assuming that a confidence baseline of 0.85 is defined through analysis of historical data, since the connection priority scores of the above two primitive connection pairs are not lower than 0.85, they are selected. In the generated skeleton attention matrix, A(CB1,BUS1)=1, A(BUS1,LOAD1)=1. Assuming that P(CB1-LOAD1)=0.15 is lower than 0.85, A(CB1,LOAD1)=0. This matrix clearly indicates that the generated flow network should prioritize building the backbone path CB1-BUS1-LOAD1.
[0125] The macro-routing layer constructs the original primitive connection backbone network based on the skeleton attention matrix and the preset primitive prior knowledge base. The preset primitive prior knowledge base is used to constrain the construction of the original primitive connection backbone network to not deviate from the electrical rules corresponding to the wiring diagram. For example, circuit breakers should be directly connected to the bus. It should be noted that although the preset primitive prior knowledge base has been used for constraints in the primitive extraction model, the macro-routing layer's construction of the original primitive connection backbone network is based on the skeleton attention matrix, which only contains some wiring diagram primitives. There may be connection interruptions. In this case, combining the preset primitive prior knowledge base for constraints can avoid primitive connections that obviously violate electrical rules.
[0126] The micro-path layer performs fine-grained path optimization and connection supplementation based on the original primitive connection backbone network determined by the macro-routing layer, ultimately generating a complete initial primitive connection network. This layer combines a complete primitive priority connection table and a preset primitive prior knowledge base to generate specific connection paths. The parameters corresponding to the connection path include at least the path direction, inflection point position, and curve parameters. Taking the primitive connection pair CB1 to BUS1 as an example, the micro-path layer will generate specific connection paths, such as starting from the right connection point of CB1, extending upward at a 45-degree angle, passing through a smooth inflection point, and then horizontally connecting to the bottom connection point of BUS1.
[0127] The initial primitive connection network is comprehensively evaluated. Specifically, the vector connection paths in the initial primitive connection network are rasterized onto a binary mask of the same size as the original drawing of the wiring diagram to be identified, generating a predicted path mask. This mask is then combined with the real line mask contained in the visual feature attributes of the primitive neural encoding set to calculate visual similarity. The similarity calculation between the two masks can be achieved using the Dice coefficient. For example, for the primitive connection pair CB1 connecting BUS1, assuming that the generated vector path, after rasterization, covers 1500 pixels, and the corresponding line area in the original drawing has 1600 pixels, with 1400 overlapping pixels, then the visual similarity score calculated using the Dice coefficient is (2*1400) / (1500+1600)≈0.90. This indicates that the generated path is similar to the original drawing. The generated path is highly consistent with the visual image evidence corresponding to the wiring diagram to be identified. An implicit empirical fit evaluation is performed on the initial primitive connection network, i.e., to check whether the generated topology conforms to the conventional design practices of electrical engineers. An implicit empirical encoder is used to compress the initial primitive connection network into a low-dimensional latent vector representing its pattern. The Mahalanobis distance between this latent vector and a predefined latent vector center reference is calculated. The latent vector center reference is based on the aggregation of latent vectors corresponding to all identified wiring diagrams in the training dataset corresponding to the implicit empirical encoder. It should be noted that the Mahalanobis distance measures outliers by analyzing the covariance of the data distribution. The greater the Mahalanobis distance, the more the analyzed topology deviates from conventional design practices, resulting in a lower final implicit empirical fit score. Specifically, exp(−λ*D) can be used. M The implicit empirical fit score is derived, where λ is a scaling parameter and defaults to 1, and D... M For example, if the Mahalanobis distance between primitives CB1 and BUS1 is 0.5, then the corresponding implicit empirical fit score is 0.61.
[0128] While generating the initial primitive connection network at the micro-path layer, Monte Carlo Dropout is used for N forward inferences. Uncertainty is quantified through these multiple forward inferences. Specifically, due to the randomness of Monte Carlo Dropout, each forward inference will produce a slightly different generated path. For each edge in the initial primitive connection network, the variance of its N generation results, such as path length and average curvature, is calculated. The larger the variance of an edge, the higher its uncertainty. Finally, the coefficient of variation is used to map the corresponding uncertainty value, expressed as standard deviation / mean. For example, performing 100 Monte Carlo samplings on the edge BUS1-LOAD1 generates 100 slightly different paths. Assuming the standard deviation of the length of these 100 paths is 15 pixels and the average path length is 200 pixels, the uncertainty value of this edge is 0.075. Similarly, assuming the standard deviation of the path length of CB1-BUS1 is 5 pixels and the average length is 100 pixels, the corresponding uncertainty value is 0.05. The uncertainty knowledge graph formed by connecting the two edges can be represented as {CB1-BUS1: 0.05, BUS1-LOAD1: 0.075}.
[0129] The visual similarity score, implicit experience similarity score, and uncertainty knowledge graph are encapsulated into a comprehensive evaluation result, which is then compared with preset qualification conditions. If the comprehensive evaluation result meets the preset qualification conditions, such as the average uncertainty value in the uncertainty knowledge graph not exceeding 0.08, the visual similarity score not lower than 0.85, and the implicit experience similarity score not lower than 0.68, then the original primitive connection network is output as the initial primitive connection network. If the comprehensive evaluation result does not meet the preset qualification conditions, the original primitive connection network is iteratively optimized based on the comprehensive evaluation result, that is, the edge connections in the initial primitive connection network that caused the comprehensive evaluation result to fail are specifically adjusted until the preset qualification conditions are met.
[0130] Step S4: Use a pre-built differentiable physical simulator to perform circuit semantic simulation verification on the initial primitive connection network and generate simulation verification results.
[0131] Specifically, based on a pre-defined primitive knowledge base, each identified primitive in the initial primitive connection network is materialized to obtain a set of physical models corresponding to all primitives. The physical model set and the initial primitive connection network are input into a predefined differentiable physical simulator for simulation to obtain simulation results. According to the pre-defined physical consistency verification rules and the simulation results, the initial primitive connection network is used to locate errors and generate corresponding simulation verification results. The simulation verification results include at least the physical consistency loss, error location map, and corresponding gradient quantization value. The error location map is represented by the primitive connection relationships in the initial primitive connection network that are determined to have connection errors during circuit semantic simulation verification.
[0132] Understandably, the preset physical consistency verification rule is represented by converting the constraint rules in the preset electrical constraint rule library into a rule verification loss function, and obtaining the corresponding rule verification loss by combining the simulation results; wherein the rule verification loss function includes at least conductor consistency loss, switch state consistency loss and energy conservation loss; conductor consistency loss is obtained by verifying whether the voltage difference between the two ends of the conductor meets the predetermined rule; switch state consistency loss is obtained by verifying whether the actual state of the switch matches the predefined state; and energy conservation loss is obtained by verifying the balance of input and output power in the circuit.
[0133] The weighted fusion rule verification loss generates a physical consistency loss. Based on the physical consistency loss, the connection error of the primitive connection relationship in the initial primitive connection network is judged and gradient quantized. If the physical consistency loss does not reach a predetermined threshold, the process ends. If the physical consistency loss reaches the predetermined threshold, the error primitive connection relationship in the initial primitive connection network is located, and the corresponding gradient quantization value is generated. The contribution of each primitive connection relationship in the initial primitive connection network to the physical consistency loss is identified according to the gradient quantization value. The larger the gradient quantization value, the greater the error of the primitive connection relationship.
[0134] In one possible embodiment, the initial primitive connection network is compiled into a data structure that can be used by a differentiable physical simulator, such as compiling the initial primitive connection network into a standard circuit netlist. Each primitive in the initial primitive connection network is instantiated as a corresponding physical component model according to its electrical type, and the connections between primitives are treated as ideal wires. The simulation netlist is input into a differentiable physical simulator based on Kirchhoff's laws, test stimuli are set, such as injecting current into power nodes, and the circuit equations are solved using a differentiable sparse matrix solver to obtain the voltage of each node and the current of each branch in the initial primitive connection network. The simulation process supports gradient backpropagation. Specifically, the netlist to be verified is first... The initial primitives are connected to the standard circuit netlist. Based on Kirchhoff's current law, a current balance equation is established for each independent node in the circuit. This current balance equation can be expressed as YV=I, where Y represents the node admittance matrix, V represents the node voltage to be solved, and I represents the current source vector injected into the node. It should be noted that the admittance matrix Y is sparse; the positions of the non-zero elements are determined by the topological connections, and their values are determined by the component parameters. A differentiable sparse linear solver is used to solve the current balance equation to obtain the node voltage V. After obtaining the node voltage V, the current and voltage of each branch corresponding to that node are calculated differentially. For example, the current I of branch k connecting nodes i and j is... k =(V i -V j ) / R k It should be noted that in circuit simulation, each branch will be defined as a physical model of a resistive element. Therefore, when calculating the current in that branch, Ohm's law needs to be applied, and the resistance value of the resistive element itself, i.e., R mentioned above, needs to be used. k .
[0135] The pre-collected physical laws are transformed into a computable loss function term, thereby quantifying the deviation between the topology of the initial primitive connection network and the physical principle. Specifically, the loss function mainly consists of the following parts: the sum of squares of the voltage difference between the two ends of the edge to be modeled as an ideal conductor is used as the conductor consistency loss, which is used to penalize those connections that are marked as ideal conductors but have voltage differences at both ends, forcing the conductors in the generated primitive connection network to be as close as possible to the ideal short-circuit characteristics. For example, if the voltage difference between the two ends of conductor L1 is 0.5V, the corresponding loss is 0.25.
[0136] The switching state consistency loss is expressed as a comparison between the simulated state of the switching element and its symbolic definition state. That is, when the switch is open, the current in its branch should approach zero, and the square of the current flowing through it is taken as the corresponding loss. When the switch is closed, the voltage difference between its two ends should approach zero, and the square of the voltage difference between the two ends is taken as the corresponding loss. For example, if a switch in the open state is calculated to have a current flowing through it of 0.1A, then its corresponding switching state consistency loss is 0.01.
[0137] Energy conservation loss is expressed as the difference between the total power injected into the circuit and the total power consumed by all loads and line losses, and the square of this difference is taken as the corresponding loss. For example, if the power supply output power is 10W, the total load consumption is 9.5W, and the energy loss is 0.5W, then the corresponding energy conservation loss is 0.25.
[0138] The physical consistency loss is generated by weighting the conductor consistency loss, switch state consistency loss and energy conservation loss with a weight ratio of 1:1:1. The physical consistency loss is compared with a predetermined threshold. For example, if the threshold is found to be 0.75 by analyzing historical data, the process ends if the physical consistency loss does not reach the predetermined threshold.
[0139] If the physical consistency loss reaches a predetermined threshold, the error primitive connection relationship is located in the initial primitive connection network and the corresponding gradient quantization value is generated. Specifically, the gradient of the physical consistency loss relative to the topological elements, such as switch states and connection relationships, is calculated through backpropagation. The magnitude of the gradient value directly represents the degree of contribution of the element to the physical violation. Based on the gradient value, the location information is located. For example, the gradient of the physical consistency loss L with the state parameter of switch S1 is ∂L / ∂S1=0.8, while the gradient with respect to another switch S2 is ∂L / ∂S2=0.05. This indicates that the erroneous state of switch S1 is the main root cause of this physical violation, and switch S1 should be corrected first.
[0140] The automatic correction process is initiated synchronously. The automatic correction process includes: parameter correction, which directly adjusts the state of components, such as the on / off state of a toggle switch; structural correction, which adds or removes connections. For example, if the gradient shows that a connection that should exist is missing, causing the loop current to be blocked, the process will attempt to add this connection; after correction, the simulation-evaluation-positioning cycle is repeated until the physical consistency loss is lower than a predetermined threshold.
[0141] Step S5: Based on the simulation verification results, iteratively execute steps S3 to S4 to generate an accurate primitive connection network.
[0142] Specifically, the simulation verification results are input into the generator flow network. The generator flow network fine-tunes the priority connection table of the primitives corresponding to the wiring diagram to be identified and the strategy network parameters inside the generator flow network based on the error localization map and the corresponding gradient quantization value contained in the simulation verification results. After the corresponding parameter adjustment is completed, a new initial primitive connection network is regenerated, and circuit semantic simulation verification is performed on this new initial primitive connection network again. The loop process of parameter adjustment, initial primitive connection network generation and circuit semantic simulation verification is iteratively executed until the predetermined iteration termination condition is reached, and the loop ends. The predetermined iteration termination condition is expressed as at least satisfying any one of the following: the physical consistency loss is lower than a predetermined threshold, the loss reduction of multiple consecutive iterations is lower than a predetermined loss reduction, or the predetermined maximum safe iteration number is reached.
[0143] Example 2: This application provides an image recognition-based system for identifying inter-primary connections, applied to the image recognition-based method for identifying inter-primary connections in Example 1, such as... Figure 3 As shown, it includes:
[0144] The model building module is used to build a primitive extraction model and pre-train the model using a pre-built training dataset.
[0145] The primitive encoding module is used to input the wiring diagram to be identified into the primitive extraction model for analysis and identification, and output the primitive neural encoding set.
[0146] The connection reasoning module is used to infer the primitive connection relationships of the primitive neural coding set based on the generated flow network, and generate the corresponding initial primitive connection network.
[0147] The simulation verification module is used to perform circuit semantic simulation verification on the initial primitive connection network based on the differentiable physical simulator, and generate simulation verification results.
[0148] The iterative optimization module is used to iteratively execute the methods from the connection inference module to the simulation verification module based on the simulation verification results, and generate an accurate primitive connection network.
[0149] The specific usage and function of this embodiment are as follows:
[0150] First, a primitive extraction model is constructed and pre-trained using a pre-built training dataset. The wiring diagram to be identified is input into the primitive extraction model for analysis and recognition, and the output primitive neural coding set is generated. By integrating deep learning and traditional image processing techniques, high-precision recognition of electrical primitives and symbolic conversion of corresponding features are achieved, providing a data foundation for subsequent reasoning and analysis of primitive connection relationships.
[0151] Simultaneously, by combining graph attention networks to dynamically capture potential relationships between graph primitives and generate a graph primitive priority connection table, the huge graph primitive connection possibility space is compressed into a smaller high-probability region, which not only provides prior knowledge for subsequent steps, but also improves the overall efficiency of graph primitive connection relationship recognition.
[0152] Next, based on the generative flow network, the primitive neural coding set is used to infer the primitive connection relationship, and the corresponding initial primitive connection network is generated. A hierarchical exploration strategy that combines macro-routing and micro-path is adopted to explore multiple possible reasonable topological assumptions in parallel, thereby ensuring robustness in complex scenarios.
[0153] Then, a pre-built differentiable physical simulator is used to perform circuit semantic simulation verification on the initial primitive connection network, generating simulation verification results. By constructing a differentiable physical simulation engine, the physical contradictions in the initial primitive connection network are accurately located, and a clear gradient direction is provided for automatic correction, thereby ensuring the physical rationality of the generated results.
[0154] Finally, based on the simulation verification results, steps S3 to S4 are iteratively executed to generate a precise primitive connection network, thereby achieving efficient, fast, and accurate identification of electrical wiring diagrams.
[0155] Example 3: This application provides an electronic device, including: at least one processor, at least one memory, and a data bus;
[0156] In this system, the processor and the memory communicate with each other via a data bus; the memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute a method for recognizing the connection relationship between primitives based on image recognition, as described in Example 1.
[0157] Example 4: This application provides a non-transitory computer-readable storage medium that stores computer instructions, which cause the computer to execute a method for identifying the connection relationship between graphic elements based on image recognition, as described in Example 1.
[0158] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0159] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0160] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0161] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0162] Those skilled in the art will understand that all or part of the steps in the above facts and methods can be implemented by a program instructing related hardware. The program or the program involved can be stored in a computer-readable storage medium. When the program is executed, it includes the following steps: at this time, the corresponding method steps are introduced. The storage medium can be ROM / RAM, magnetic disk, optical disk, etc.
[0163] The above specific embodiments further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above are merely specific embodiments of the present invention and are not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for recognizing line relationships between primitives based on image recognition, characterized in that, The specific steps include the following: S1, Construct a primitive extraction model and pre-train the model using a pre-constructed training dataset. The primitive extraction model includes a primitive recognition submodule and a neural coding submodule. S2, input the wiring diagram to be identified into the primitive extraction model for analysis and identification, and output the primitive neural coding set, which includes a primitive entity set and an entity coding set; S3, perform primitive connection relationship reasoning on the primitive neural coding set based on the generative flow network to generate the corresponding initial primitive connection network; The graph element connection relationship reasoning is represented by using a graph attention network to decode the graph element neural coding set, dynamically capturing the potential semantic relationships between graph elements, and generating a graph element attention weight matrix; A hierarchical decision-making generative flow network iteratively optimizes the original primitive connection network to generate the corresponding initial primitive connection network. The hierarchical decision-making generative flow network includes a macroscopic routing layer and a microscopic path layer, wherein: The macro-routing layer generates the original primitive connection backbone network based on the primitive attention weight matrix and the preset primitive prior knowledge base. The micro-path layer is based on the original primitive connection backbone network, and simultaneously combines the primitive priority connection table contained in the primitive neural coding set to perform fine branch connections, thereby generating the original primitive connection network. The original primitive connection network is evaluated based on a multi-dimensional primitive connection evaluation mechanism. The original primitive connection network is then optimized based on the evaluation results to generate an initial primitive connection network. S4. A pre-built differentiable physical simulator is used to perform circuit semantic simulation verification on the initial primitive connection network, and simulation verification results are generated. The circuit semantic simulation verification is represented by materializing each identified primitive in the initial primitive connection network based on a preset primitive knowledge base, and obtaining a set of physical models corresponding to all primitives. The physical model set and the initial primitive connection network are input into a predefined differentiable physical simulator for simulation, and the simulation results are obtained. Based on the preset physical consistency verification rules and simulation results, the initial primitive connection network is error-located, and corresponding simulation verification results are generated. The simulation verification results should include at least the physical consistency loss, error localization map, and corresponding gradient quantization values. The error localization map is represented by the connection relationships of primitives in the initial primitive connection network that are determined to have connection errors during circuit semantic simulation verification. S5. Based on the simulation verification results, iteratively execute steps S3 to S4 to generate a precise primitive connection network.
2. The method for recognizing inter-primary connections based on image recognition according to claim 1, characterized in that, Construct a primitive extraction model and pre-train it using a pre-built training dataset, including: A set of synthetic electrical wiring diagrams is constructed by combining preset electrical constraint rules and a preset primitive knowledge base, and the set of synthetic electrical wiring diagrams is used as the first training dataset. Obtain historically identified electrical wiring diagrams and combine the historically identified electrical wiring diagrams to generate a second training dataset; Each wiring diagram in the first training dataset and the second training dataset corresponds to a primitive attribute set, which includes at least primitive category data, primitive attribute data and text attributes. The YOLOv5 architecture is optimized using the CARAFE upsampling operator, and a primitive detector is built based on the optimized YOLOv5 architecture. A bus detector is constructed using traditional image processing algorithms and a preset set of bus constraint rules. A text recognizer is constructed using a text detection model based on differentiable binarization and a convolutional recurrent neural network. A primitive recognition submodule is constructed based on the primitive detector, bus detector and text recognizer. The primitive recognition submodule is used to generate primitive entity sets.
3. The method for recognizing inter-primary connections based on image recognition according to claim 2, characterized in that, The method further includes: A primitive attribute encoder is constructed based on a preset primitive knowledge base and preset encoding rules. The primitive attribute encoder is used to generate corresponding attribute codes for each primitive in the primitive entity set. The attribute encoding includes at least primitive ID, semantic feature attributes, visual feature attributes, and spatial feature attributes; A graph neural network is used to construct a graph primitive connection priority predictor. The graph primitive connection priority predictor performs multi-feature evaluation based on the graph primitive entity set and the corresponding attribute encoding to generate a graph primitive priority connection table. The multi-feature evaluation includes at least semantic compatibility evaluation, spatial proximity evaluation, directional consistency evaluation, and textual context evaluation; A neural coding submodule is constructed based on the primitive attribute encoder and the primitive connection priority predictor, and the neural coding submodule is used to generate entity coding sets. The primitive recognition submodule and the neural coding submodule are pre-trained by combining the first training dataset and the second training dataset.
4. The method for recognizing inter-primary connections based on image recognition according to claim 1, characterized in that, The wiring diagram to be identified is input into the primitive extraction model for analysis and identification, and the output primitive neural coding set includes: After the wiring diagram to be identified is input into the graphic element extraction model, the graphic element recognition submodule performs graphic element recognition and extraction on the wiring diagram to be identified, and generates a corresponding graphic element entity set. The attributes of each graphic element entity in the graphic element entity set include at least graphic element type, spatial features and corresponding entity features. The neural coding submodule performs semantic matching from a preset primitive knowledge base based on the primitive type in the primitive entity set to generate corresponding semantic feature attributes. The entity features and spatial features are encoded by combining preset encoding rules to generate corresponding visual feature attributes and spatial feature attributes; The semantic feature attributes, the visual feature attributes, and the spatial feature attributes are encapsulated into an entity encoding set. The primitive entity set and the entity encoding set are combined to perform multi-feature evaluation and generate a primitive priority connection table. The primitive entity set, the entity encoding set, and the primitive priority connection table are output as a primitive neural encoding set.
5. The method for recognizing inter-primary connections based on image recognition according to claim 1, characterized in that, The original primitive connectivity network is evaluated based on a multi-dimensional primitive connectivity evaluation mechanism. The original primitive connectivity network is then optimized based on the evaluation results to generate an initial primitive connectivity network, including: The matching degree between the primitive connection lines in the original primitive connection network and the corresponding visual feature attributes in the primitive neural coding set is evaluated to generate a visual fit score. The original primitive connection network is re-encoded using a deep learning-based latent experience encoder to generate latent feature codes, and a corresponding latent experience fit score is generated based on the latent feature codes. Uncertainty assessment is performed on the original primitive connection network to generate a corresponding uncertainty knowledge graph, which is used to characterize the uncertainty of each connection in the original primitive connection network. A comprehensive evaluation result is generated based on the visual consistency score, implicit experience consistency score, and uncertainty knowledge graph. If the comprehensive evaluation result meets the preset qualification conditions, the original primitive connection network will be output as the initial primitive connection network. If the comprehensive evaluation result does not meet the preset qualification conditions, the original primitive connection network will be iteratively optimized based on the comprehensive evaluation result until the preset qualification conditions are met.
6. The method for recognizing inter-primary connections based on image recognition according to claim 1, characterized in that, The preset physical consistency verification rules include: The preset physical consistency verification rule is represented by transforming the constraint rules in the preset electrical constraint rule library into a rule verification loss function, and obtaining the corresponding rule verification loss by combining the simulation results; The rule verification loss function includes at least conductor consistency loss, switch state consistency loss and energy conservation loss; The conductor consistency loss is obtained by verifying whether the voltage difference between the two ends of the conductor conforms to a predetermined rule. The switch state consistency loss is obtained by verifying whether the actual state of the switch matches the predefined state. By verifying the balance of input and output power in the circuit, the energy conservation loss can be obtained; The weighted fusion of the rule verification loss generates a physical consistency loss, and the connection error judgment and gradient quantization are performed on the primitive connection relationship of the initial primitive connection network based on the physical consistency loss; If the physical consistency loss does not reach the predetermined threshold, the process ends; If the physical consistency loss reaches a predetermined threshold, the error primitive connection relationship is located in the initial primitive connection network, and the corresponding gradient quantization value is generated. The gradient quantization value indicates the contribution of each primitive connection relationship in the initial primitive connection network to the physical consistency loss. The larger the gradient quantization value, the greater the error of the primitive connection relationship.
7. The method for recognizing inter-primary connections based on image recognition according to claim 1, characterized in that, Based on the simulation verification results, iteratively execute steps S3 to S4 to generate a precise primitive connection network, including: The simulation verification results are input into the generator flow network. The generator flow network fine-tunes the priority connection table of the primitives corresponding to the wiring diagram to be identified and the strategy network parameters inside the generator flow network based on the error localization map and the corresponding gradient quantization value contained in the simulation verification results. After completing the corresponding parameter adjustments, a new initial primitive connection network is regenerated, and the circuit semantic simulation verification is performed on this new initial primitive connection network again. The iterative process of adjusting execution parameters, generating the initial primitive connection network, and performing circuit semantic simulation verification continues until a predetermined iteration termination condition is met, at which point the loop ends; where: The predetermined iteration termination condition is defined as satisfying at least one of the following: the physical consistency loss is less than a predetermined threshold, the loss decrease in consecutive iterations is less than a predetermined loss decrease, or the predetermined maximum number of safe iterations is reached.
8. A system for recognizing inter-primary connections based on image recognition, used to implement the method for recognizing inter-primary connections based on image recognition as described in any one of claims 1 to 7, characterized in that, include: The model building module is used to build a primitive extraction model and pre-train the model using a pre-built training dataset. The primitive encoding module is used to input the wiring diagram to be identified into the primitive extraction model for analysis and identification, and output a primitive neural encoding set. The connection inference module is used to infer the primitive connection relationships of the primitive neural coding set based on the generated flow network, and generate a corresponding initial primitive connection network. The simulation verification module is used to perform circuit semantic simulation verification on the initial primitive connection network according to the differentiable physical simulator, and generate simulation verification results. An iterative optimization module is used to iteratively execute the method from the connection inference module to the simulation verification module based on the simulation verification results, and generate an accurate primitive connection network.
Citation Information
Patent Citations
Generative flow network-based gene regulatory network construction method
CN118212989A
Medical text big data intelligent labeling and knowledge graph construction method and system
CN119851968A