An ai generation method and system for converting a drawing into a configuration based on a cv large model
Through the drawing-to-configuration method based on the CV large model, the electrical drawings are disassembled and annotated, the recognition model is trained, and the vector format configuration diagram is generated. This solves the problem of complex electrical schematic recognition errors and improves the recognition accuracy and reliability.
Patent Information
- Application Number
- CN202510678308.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-26
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2045-05-26
AI Technical Summary
When existing technologies process complex electrical schematics, the recognition results generated by AI may contain errors or logical irrationality, resulting in insufficient accuracy and reliability in electrical drawing recognition.
An AI generation method from drawings to configurations based on the CV large model is constructed. By disassembling a system diagram into single cabinet drawings and combination cabinet drawings, image annotation is performed, and basic and complex graphic element recognition models are trained. Combined with the Cohen-Sutherland line segment clipping algorithm and the sliding window combination algorithm, a configuration diagram in vector format is generated.
The accuracy and reliability of electrical drawing recognition have been significantly improved, and it can accurately identify electrical components and topological relationships in complex circuit design scenarios and generate high-quality configuration diagrams.
Smart Images

Figure CN120198534B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of electrical technology, and in particular relates to an AI generation method and system for converting drawings into configurations based on a CV large model. Background Art
[0002] Automatic review and conversion of electrical drawings has broad application value in the field of electrical engineering. For example, in power SCADA systems, primary system diagrams can be automatically converted into interactive monitoring interfaces, enabling real-time monitoring and control of power system operating status. In industrial digital twin systems, by recognizing P&ID (Process and Instrumentation Diagram) drawings, 3D equipment configuration models can be quickly generated. In electrical intelligent operation and maintenance systems, data collected by the Internet of Things (IoT) can be combined to display key information such as equipment operating status, temperature, load, and so on, in real time in an SVG-formatted graphical interface.
[0003] However, traditional drawing review and conversion processes rely primarily on manual labor, resulting in cumbersome and inefficient processes. These processes are prone to errors and inconsistencies caused by human error, severely limiting engineering efficiency and system reliability. With the development of artificial intelligence (AI) recognition technology, computer vision (CV)-based methods can quickly and accurately identify various elements in electrical drawings, significantly improving the efficiency of drawing review and conversion and reducing human error.
[0004] Currently, automated drawing recognition technology is still in its developmental stages and has certain limitations. Major issues include the lack of large-scale, high-quality computer vision pre-training models for electrical components. When processing complex electrical schematics, the AI-generated recognition results may contain errors or illogical logic. The root cause of this problem is that the performance of AI models is highly dependent on the quality and quantity of training data. In the field of electrical drawing recognition and schematic drawing, if the training data coverage is insufficient, the samples are unevenly distributed, or the annotations are inaccurate, it will lead to AI systems making recognition errors in actual applications, limiting their reliability and widespread application.
[0005] Therefore, how to improve the accuracy and reliability of electrical drawing recognition, especially for complex circuit design scenarios, remains an important technical problem that needs to be solved urgently. Summary of the Invention
[0006] In an embodiment of the present invention, a method and system for AI generation from drawings to configurations based on a CV large model are provided to solve the problem that when processing complex electrical schematics in the prior art, the recognition results may contain errors or logical irrationality.
[0007] In order to solve the above technical problems, the embodiments of the present invention disclose the following technical solutions:
[0008] One aspect of the present invention provides an AI generation method for converting drawings into configurations based on a CV large model, which is applied to a primary system diagram of an electrical system, comprising:
[0009] The original sample set is constructed based on the single cabinet diagrams decomposed from multiple primary system diagrams. Each sample is a single cabinet diagram or a combined cabinet diagram formed by combining multiple single cabinet diagrams.
[0010] Filtering out samples containing preset complex primitives from the original sample set to form a complex primitive sample set;
[0011] Using a preset image annotation tool to annotate the preset basic primitives and inseparable combination primitives in each sample image of the original sample set, and annotate the complex primitives in each sample image of the complex primitive sample set;
[0012] The preset CV vision large model is trained based on the annotated original sample set and the complex primitive sample set to obtain the basic primitive recognition model and the complex primitive recognition model;
[0013] The complex primitive recognition model and the basic primitive recognition model are used in sequence to identify the target system diagram and obtain the type of each primitive in the target system diagram;
[0014] The coordinates of each primitive and the topological relationship between primitives are obtained, and a configuration diagram in vector format is generated.
[0015] Optionally, the constructing of the original sample set based on the single cabinet diagrams decomposed from the multiple primary system diagrams includes:
[0016] The Cohen-Sutherland line segment clipping algorithm is used to decompose each primary system diagram into multiple subsystem diagrams, and each subsystem diagram is decomposed into multiple single cabinet diagrams.
[0017] Using the sliding window combination algorithm, two or more adjacent single cabinet diagrams are combined to form different combined cabinet diagrams;
[0018] Rotate each single cabinet image and combination cabinet image to obtain a rotated image;
[0019] The original sample set is constructed based on all single cabinet drawings, combination cabinet drawings and rotation drawings.
[0020] Optionally, before executing the steps of using the Cohen-Sutherland line segment clipping algorithm to decompose each primary system diagram into multiple subsystem diagrams, and decomposing each subsystem diagram into multiple single cabinet diagrams, the method further includes:
[0021] Determine whether a system diagram is a hand-drawn or scanned diagram.
[0022] If so, the primary system image is subjected to denoising processing and then converted into a grayscale image, and a global histogram equalization processing is performed on the grayscale image.
[0023] Optionally, the step of using a preset image annotation tool to annotate preset basic primitives and inseparable combination primitives in each sample image of the original sample set, and annotating complex primitives in each sample image of the complex primitive sample set, includes:
[0024] For the original sample set, the labelme image annotation tool is used to annotate the categories and bounding boxes of various preset basic primitives and various inseparable combination primitives;
[0025] For the complex primitive sample set, the labelme image annotation tool is used to annotate the categories and bounding boxes of the preset complex primitives;
[0026] Determine whether there are any primitive categories in the original sample set after annotation whose sample number is less than the preset training amount.
[0027] If so, samples of the primitive category are added to the original sample set until the number of samples of the primitive category exceeds a preset training amount.
[0028] Optionally, the method of training a preset CV vision large model based on the annotated original sample set and the complex primitive sample set to obtain a basic primitive recognition model and a complex primitive recognition model includes:
[0029] The YOLOv12 model is trained using the annotated original sample set to obtain a basic primitive recognition model, which is used to identify basic primitives and inseparable combination primitives in the system graph.
[0030] The YOLOv12 model is trained using the labeled complex primitive sample set to obtain a complex primitive recognition model, which is used to identify complex primitives in the system graph.
[0031] Optionally, the step of sequentially using the complex primitive recognition model and the basic primitive recognition model to recognize the target system diagram to obtain the type of each primitive in the target system diagram includes:
[0032] Decompose the target system diagram to be processed into multiple subsystem diagrams;
[0033] For each subsystem diagram, the type of each element is obtained in the following way:
[0034] Determine whether the subsystem diagram contains complex primitives based on the complex primitive recognition model,
[0035] If the subsystem graph contains complex graph elements, the type and the bounding box of the complex graph elements are identified, and a mask processing is performed to cover the content in the bounding box on the subsystem graph;
[0036] After the basic graph elements and / or the non-detachable combination graph elements in the mask-processed subsystem graph are identified by using the basic graph element identification model, the mask on the subsystem graph is removed;
[0037] If the subsystem graph does not contain complex graph elements, the basic graph elements and / or the non-detachable combination graph elements in the subsystem graph are identified by using the basic graph element identification model.
[0038] Optionally, the target system graph is identified by using the complex graph element identification model and the basic graph element identification model in sequence to obtain the type of each graph element in the target system graph, and the method further includes:
[0039] For each subsystem graph, it is determined whether there is a non-detachable combination graph element, the non-detachable combination graph element includes a current transformer, a fuse, a disconnecting switch, and a capacitor, each type of the non-detachable combination graph element includes a plurality of sub-class combination graph elements,
[0040] If yes, a preset algorithm is used to determine the sub-class combination graph element corresponding to the non-detachable combination graph element.
[0041] Optionally, the preset algorithm used to determine the sub-class combination graph element corresponding to the non-detachable combination graph element includes:
[0042] For the non-detachable combination graph element of the current transformer, a Hough circle transformation algorithm is used to count the number of coils in the graph element, and the sub-class combination graph element to which the graph element belongs is determined according to the number of coils;
[0043] For the non-detachable combination graph element of the fuse, an edge detection algorithm and a contour detection algorithm are used to count the number of quadrilaterals in the graph element, the graph element with the number of quadrilaterals being 4 is determined as a voltage-dependent resistor, and the graph element with the number of quadrilaterals being 2 is determined as a fuse;
[0044] For the non-detachable combination graph element of the disconnecting switch, an edge detection algorithm and a contour detection algorithm are used to count the number of quadrilaterals in the graph element, the graph element with the number of quadrilaterals being other than 0 is determined as a fuse-type disconnecting switch, and the graph element with the number of quadrilaterals being 0 is determined as a disconnecting switch;
[0045] For the non-detachable combination graph element of the capacitor, an edge detection algorithm is used to count the number of capacitors in the graph element, the graph element with the number of capacitors being greater than 1 is determined as a capacitor, and the graph element with the number of capacitors being equal to 1 is determined as a capacitor.
[0046] Optionally, after performing the step of sequentially using the complex primitive recognition model and the basic primitive recognition model to recognize the target system diagram and obtain the type of each primitive in the target system diagram, the method further includes:
[0047] For each subsystem diagram, perform the following steps:
[0048] Determine whether the recognition result contains all sub-elements constituting any preset detachable combined element, wherein the detachable combined element is composed of two sub-elements connected and combined, and the sub-elements belong to the basic element,
[0049] If so, calculate the distance between any two sub-element bounding boxes;
[0050] A path algorithm is used to determine whether two sub-graph elements whose distance is less than a preset distance threshold are connected.
[0051] If they are connected, the corresponding detachable combined primitives are used to replace the two sub-primitives.
[0052] Optionally, obtaining the coordinates of each graphic element and the topological relationship between the graphic elements and generating a configuration diagram in a vector format includes:
[0053] For each subsystem diagram, perform the following steps:
[0054] Obtaining the outlines and electrical connections of all graphic elements in the subsystem diagram;
[0055] Extracting connection relationships between different graphics elements based on the graphics element contours and electrical connections, and generating a path sequence array, wherein the path sequence array includes the category and bounding box coordinates of the graphics element in each path;
[0056] Construct a configuration diagram in vector format based on the array of pathway sequences.
[0057] Optionally, obtaining the outlines and electrical connections of all graphic elements in the subsystem diagram includes:
[0058] Convert the subsystem graph into a grayscale graph G1;
[0059] Use Gaussian filtering on G1 to remove noise points in the image and obtain G2;
[0060] Perform global histogram equalization on G2 to enhance the image contrast, and perform binarization and black-white inversion processing to obtain G3;
[0061] The Canny edge detection algorithm is used to detect the contour lines and connecting lines of all the primitives in G3, and the morphological expansion method is used to connect the broken lines in the detection results to obtain G4.
[0062] Optionally, extracting the connection relationship between different graphic elements based on the graphic element contours and electrical connections and generating a path sequence array includes:
[0063] Mask the bounding box of the primitive in G4 so that the mask represents the corresponding primitive, obtaining G5.
[0064] Obtain all paths in G5 based on the region connectivity function, where the paths are paths connecting different primitives;
[0065] Output the category and bounding box coordinates of each primitive in all paths, and generate a path sequence array corresponding to the subsystem graph.
[0066] Optionally, constructing a configuration diagram in a vector format according to the path sequence array includes:
[0067] Establish a standard symbol library based on the information data of all graphic elements;
[0068] Represent the graphics elements in the path sequence array as points, and represent the connection relationship between graphics elements as lines;
[0069] Generate vector-format configuration diagrams based on standard symbol libraries, and use hierarchical layout algorithms to optimize the position of graphic elements and the arrangement of connections.
[0070] Optionally, the method further includes:
[0071] use Figure 1 The consistency check algorithm verifies whether the configuration diagram conforms to the electrical connection logic.
[0072] Another aspect of the present invention discloses an AI generation system from drawings to configurations based on a CV large model, which is applied to the AI generation method from drawings to configurations based on a CV large model provided in the aforementioned aspect.
[0073] The embodiment of the present invention discloses an AI generation method and system for drawings to configurations based on a CV large model. First, an original sample set is constructed based on a single cabinet diagram disassembled from multiple primary system diagrams, and samples containing preset complex primitives are screened out from the original sample set to form a complex primitive sample set; then, a preset image annotation tool is used to annotate the preset basic primitives and non-detachable combination primitives in each sample diagram of the original sample set, and the complex primitives in each sample diagram of the complex primitive sample set are annotated. The preset CV visual large model is trained based on the annotated original sample set and the complex primitive sample set respectively to obtain a basic primitive recognition model and a complex primitive recognition model; finally, the complex primitive recognition model and the basic primitive recognition model are used in turn to identify the target system diagram, obtain the type of each primitive in the target system diagram, obtain the coordinates of each primitive and the topological relationship between the primitives, and generate a configuration diagram in vector format. Applying the method and system disclosed in this application in complex circuit design scenarios can significantly improve the accuracy and reliability of electrical drawing recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0074] Figure 1 A flowchart of an AI generation method for converting drawings to configurations based on a CV large model provided by an embodiment of the present invention;
[0075] Figure 2 An implementation provided by the embodiment of the present invention Figure 1 Flow chart of step S100;
[0076] Figure 3 An implementation provided by the embodiment of the present invention Figure 1 Flow chart of step S300;
[0077] Figure 4 An implementation provided by the embodiment of the present invention Figure 1 Flow diagram of step S400;
[0078] Figure 5 An implementation provided by the embodiment of the present invention Figure 1 Flow diagram of step S500;
[0079] Figure 6 A schematic diagram of a process flow of a subsystem diagram processing process provided by an embodiment of the present invention;
[0080] Figure 7 An implementation provided by the embodiment of the present invention Figure 1 Flow chart of step S600;
[0081] Figure 8 An implementation provided by the embodiment of the present invention Figure 7 Flow diagram of step S601;
[0082] Figure 9 An implementation provided by the embodiment of the present invention Figure 7 Flow diagram of step S602;
[0083] Figure 10 An implementation provided by the embodiment of the present invention Figure 7 Flow chart of step S603 in FIG. DETAILED DESCRIPTION
[0084] In order to enable those skilled in the art to better understand the technical solution of the present invention, the present invention is further described in detail below with reference to the accompanying drawings and specific implementation methods.
[0085] Figure 1 The present invention provides a flow chart of an AI generation method for converting drawings into configurations based on a CV large model, which is used to generate a configuration vector diagram based on a primary system diagram of an electrical system. Figure 1 As shown, the method includes the following steps:
[0086] Step S100: constructing an original sample set based on single cabinet diagrams decomposed from multiple primary system diagrams.
[0087] In one embodiment disclosed in the present invention, Figure 2 As shown, step S100 can be implemented by using the following sub-steps:
[0088] Step S101: using the Cohen-Sutherland line segment clipping algorithm to decompose each primary system diagram into multiple subsystem diagrams, and decompose each subsystem diagram into multiple single cabinet diagrams.
[0089] The Cohen-Sutherland line segment clipping algorithm is used to decompose a primary system diagram. For example, a primary system diagram can be decomposed into six subsystem diagrams using the Cohen-Sutherland algorithm. The Cohen-Sutherland algorithm is a 2D graphics clipping technique based on a rectangular viewport. It compares each line segment in the diagram to a predefined window and uses region encoding to quickly determine whether the line segment is completely within the window, completely outside, or intersects the window boundary. This algorithm can logically segment wires, borders, and connections in complex system diagrams, thereby identifying relatively closed and structurally independent subregions.
[0090] After decomposing the primary system diagram into subsystem diagrams, each subsystem diagram is again decomposed into different single cabinet diagrams using the Cohen-Sutherland algorithm. For example, a subsystem diagram is decomposed into 6 single cabinet diagrams.
[0091] Since the source of the primary system diagram may be a scanned diagram or a hand-drawn diagram, in one embodiment disclosed in the present invention, before executing step S101 , it is necessary to determine whether the primary system diagram is a hand-drawn diagram or a scanned diagram.
[0092] If the primary system diagram to be disassembled is a hand-drawn or scanned diagram, it should be pre-processed before structural disassembly. The steps are as follows:
[0093] First, use Gaussian filtering to remove the noise points in the image. The calculation formula is as follows:
[0094]
[0095] in, Represents the original image, * represents the convolution operation, The standard deviation is The two-dimensional Gaussian kernel function, , x, y are the relative coordinate values corresponding to the pixels, Represents the denoised image.
[0096] Then, the obtained image is converted into a grayscale image, and the grayscale image is subjected to global histogram equalization using the cumulative distribution function (CDF) and the grayscale transformation function to increase the image brightness and contrast.
[0097] The CDF formula is: , grayscale transformation function:
[0098] Where j is the grayscale of the transformed image, j=0,1,2,…,L-1; L is the number of grayscale levels; , is the number of pixels of gray level k in the original image, n is the total number of pixels in the original image; int represents rounding operation.
[0099] After completing the above preprocessing steps, the Cohen-Sutherland line segment clipping algorithm is used to divide the processed image into several subsystem diagrams, and each subsystem diagram is disassembled into multiple single cabinet diagrams. Figure 1 Generally corresponds to an independent electrical cabinet or equipment area.
[0100] Step S102: using a sliding window combination algorithm, combining two or more adjacent single cabinet diagrams to form different combined cabinet diagrams.
[0101] In order to expand the number of samples and increase the diversity of combinations, a sliding window combination algorithm (i.e., cannon firing method) is used to combine two or more adjacent single cabinet images to form a combined cabinet image. The combination strategy usually adopts a window sliding method with a step size of 1, such as a single cabinet Figure 1 and 2 Composition 12, Figures 1 to 3 The combination of 123 and so on generates a variety of combinations including 12, 123, 1234, 2345, 3456, etc. This combination method helps improve the model's ability to understand complex electrical structures in electrical graphic recognition training.
[0102] Step S103: rotating each single cabinet image and combination cabinet image to obtain a rotated image.
[0103] Considering that components may have different orientations during actual drawing due to factors such as spatial layout, all single and combined cabinet drawings are rotated. Common rotation angles include integers such as 90, 180, and 270 degrees, and smaller rotation angles such as ±10 degrees can also be added as needed. This rotation transformation effectively simulates deviations in drawings under different shooting, scanning, or design conditions, thereby improving model recognition in real-world scenarios.
[0104] Step S104: constructing an original sample set based on all single cabinet images, combined cabinet images, and rotation images.
[0105] All single cabinet images, combination cabinet images and their rotation images are summarized to construct the original sample set.
[0106] Step S200: Filtering out samples containing preset complex primitives from the original sample set to form a complex primitive sample set.
[0107] Complex primitives are graphics with nested structures, complex connections, and high recognition difficulty, such as power supplies. Samples containing one or more complex primitives are selected from the original sample set and these samples are combined into a complex primitive sample set.
[0108] Step S300: using a preset image annotation tool to annotate the preset basic primitives and inseparable combination primitives in each sample image of the original sample set, and annotate the complex primitives in each sample image of the complex primitive sample set.
[0109] In one embodiment disclosed in the present invention, Figure 3 As shown, the following sub-steps are used to implement step S300:
[0110] Step S301: for the original sample set, use the labelme image annotation tool to annotate the categories and bounding boxes of multiple preset basic primitives and multiple inseparable combination primitives.
[0111] Basic elements are the most basic and smallest electrical symbols in electrical drawings. They correspond to single-function electrical equipment or components. These elements have clear, standard graphical representations on drawings, such as circuit breakers and disconnect switches.
[0112] An indestructible composite element is a composite element that is expressed as a whole in the drawing but contains multiple basic functional units. The internal structure of this type of composite element has been standardized or integrated into a fixed structure, and the logic cannot be further disassembled.
[0113] In a specific embodiment disclosed in the present invention, the non-detachable combination graphic elements include at least a current transformer category, a fuse category, an isolating switch category, and a capacitor category, wherein each category includes multiple subcategory combination graphic elements.
[0114] For example, the non-detachable combination graphic element of the current transformer class includes at least sub-class combination graphic elements such as three-phase current transformer, four-phase current transformer, and five-phase current transformer. The number of coils contained in the graphic elements of different sub-classes is different, among which the three-phase current transformer contains 3 coils.
[0115] The sub-sub ...
[0116] In the original sample set, for each sample image, the open source image annotation tool Labelme is used to annotate the preset basic primitives and inseparable combination primitives. The user selects the boundary area of each primitive based on the drawing content and assigns it a corresponding category label. The system will output the annotation information file for each primitive, recording its category and bounding box coordinates to form standardized training data.
[0117] In this step, only basic primitives and inseparable combined primitives are marked, and the identification of subclass combined primitives in the inseparable combined primitives will be completed in subsequent embodiments.
[0118] Step S302: for the complex primitive sample set, labelme image annotation tool is used to annotate the category and bounding box of the preset complex primitive.
[0119] In the complex primitive sample set, the Labelme tool is also used to annotate the complex primitives contained in each sample image, determine their physical boundaries, and complete classification and positioning. After the annotation is completed, a structured annotation information file is also generated.
[0120] Step S303: Determine whether there is a primitive category in the original sample set whose sample number is less than a preset training amount.
[0121] All samples in the original sample set are counted to determine the number of samples for each primitive category. This number is then compared to the preset lower limit of training data. The preset training volume is a threshold set based on the basic sample size requirements for model training. If certain primitive categories are found to appear too few times in the sample set and may not be sufficient to support effective training, they will be classified as low-sample categories.
[0122] For example, the number of each primitive category in the labeled sample set is , set the threshold for the number of target categories that meet training requirements and ,in Indicates the minimum mean value of all the categories of the labeled sample set. Indicates the minimum number of all the primitive categories in the labeled sample set. When , it is determined that the number of samples is less than the preset training amount.
[0123] If there is a primitive category whose sample number is less than the preset training amount, step S304 is executed; if there is no primitive category whose sample number is less than the preset training amount, step S400 is executed.
[0124] Step S304: adding samples of the primitive category to the original sample set until the number of samples of the primitive category exceeds a preset training amount.
[0125] To address the sample imbalance, data augmentation and sample supplementation are performed on categories with insufficient primitives. This can be done by filtering and adding more primitive samples containing the category in the original image set, or by generating new training samples by performing image augmentation on existing images (such as rotation, mirroring, and noise addition).
[0126] In this way, the number of samples of the primitive category is gradually increased to above the preset training threshold to ensure category coverage and recognition accuracy during the model training phase.
[0127] When the average number of labeled components exceeds And the number of marked components of each category exceeds , execute step S400.
[0128] Step S400: training a preset CV vision large model based on the annotated original sample set and the complex primitive sample set to obtain a basic primitive recognition model and a complex primitive recognition model.
[0129] The preset computer vision CV large model is trained to obtain deep learning models suitable for the recognition of different types of primitives.
[0130] In one embodiment disclosed in the present invention, Figure 4 As shown, step S400 can be implemented by using the following sub-steps:
[0131] Step S401: The YOLOv12 model is trained using the labeled original sample set to obtain a basic primitive recognition model.
[0132] The YOLOv12 model is trained on the annotated original sample set to obtain a basic primitive recognition model. The original sample set includes a large number of image samples labeled with basic primitives and inseparable primitives. During training, the YOLOv12 model gradually improves its recognition of these primitives by learning features such as the bounding boxes, category labels, and position distribution of the primitives. The trained model is capable of automatically detecting and annotating basic primitives and inseparable primitives in full images or sub-images, making it suitable for subsequent electrical diagram structure analysis and automated recognition processes.
[0133] Step S402: The labeled complex primitive sample set is used to train the YOLOv12 model to obtain a complex primitive recognition model.
[0134] The YOLOv12 model was trained separately using a sample set of annotated complex primitives to develop a complex primitive recognition model. The images in this sample set primarily contain complex electrical components with complex structures and diverse graphical representations. By training these complex primitives separately, the model can more accurately extract key features from complex graphics, improving recognition accuracy and robustness. Once trained, the model will be used to locate and identify various complex primitives within system diagrams, enhancing the comprehensiveness and accuracy of overall system recognition.
[0135] During model training, the annotated original sample set and complex primitive sample set are divided proportionally into training, validation, and test sets. The training set is used for model parameter learning and is the primary source of data for repeated iterations during model training, accounting for 80% of the total data. The validation set is used during training to evaluate the model's performance on untrained data in real time, adjusting hyperparameters and preventing overfitting. It accounts for 15% of the total data. The test set is not involved in training at all and is used only for objective evaluation of the model's final performance after training. It accounts for 5% of the total data.
[0136] To ensure the model can recognize all categories of primitives, when partitioning the dataset, it is also necessary to ensure that each primitive category has a sufficient number of samples in the three subsets to prevent certain categories from being "ignored" or misclassified by the model due to insufficient samples. This process can be achieved through methods such as stratified sampling to ensure that each category has a representative distribution of samples in the training, validation, and test sets.
[0137] After data segmentation, the YOLOv12 object detection model was used to train the training set. The model iteratively learned the feature information of the image elements, and the validation set was used for intermediate performance evaluation and parameter adjustment. Finally, the model was validated on the test set to evaluate its performance in actual automatic drawing recognition scenarios, such as recognition accuracy, recall rate, and localization error.
[0138] Accuracy threshold can be pre-set , when the average precision of the model exceeds , it is determined that the model has completed training.
[0139] Step S500: sequentially using a complex primitive recognition model and a basic primitive recognition model to recognize the target system diagram, and obtaining the type of each primitive in the target system diagram.
[0140] This step calls the trained complex primitive recognition model and basic primitive recognition model in sequence to achieve hierarchical recognition of multiple types of primitives.
[0141] In one embodiment disclosed in the present invention, Figure 5 As shown, step S500 may be implemented by using the following sub-steps:
[0142] Step S501: Decompose the target system diagram to be processed into multiple subsystem diagrams.
[0143] Before performing primitive recognition, the target system diagram must first be structurally disassembled. The Cohen-Sutherland line segment clipping algorithm can be used to spatially clip the line network structure in the system diagram to obtain multiple subsystem diagrams.
[0144] For each subsystem diagram, the type of each element is obtained in the following way:
[0145] Step S502: Determine whether the subsystem diagram contains complex primitives based on the complex primitive recognition model.
[0146] After each subsystem diagram is extracted, the trained complex primitive recognition model is first called to analyze it to determine whether it contains the preset complex primitives.
[0147] If the subsystem diagram contains complex graphic elements, step S503 is executed.
[0148] Step S503: Identify the type and bounding box of the complex graphic element, and perform masking to cover the content in the bounding box on the subsystem diagram.
[0149] Once the complex primitive recognition model detects a complex primitive, its type and precise location (bounding box) are recorded. The area covered by the bounding box is then masked on the original subsystem diagram. This masking method fills the area with a uniform color (such as black) to prevent its content from interfering with the subsequent judgment of the basic primitive recognition model.
[0150] Step S504: after using the basic primitive recognition model to identify the basic primitives and / or the non-detachable combination primitives in the mask-processed subsystem diagram, remove the mask on the subsystem diagram.
[0151] The basic primitive recognition model is applied to the masked image. It detects all objects in the remaining area that match the basic primitive template characteristics and outputs the type and location of each primitive. Once all basic primitives have been recognized, the previously masked areas are restored, restoring the complete primitive recognition results for the entire subsystem diagram, including both complex and basic primitives.
[0152] If the subsystem diagram does not contain complex graphics elements, step S505 is executed.
[0153] Step S505: using the basic graphic element recognition model to identify the basic graphic elements and / or the inseparable combination graphic elements in the subsystem diagram.
[0154] If no complex primitives are detected in the subsystem diagram in S502, the masking and restoration process is skipped and the basic primitive recognition model is directly called to recognize the subsystem diagram. In this case, the image has no interference areas, and the recognition model can directly locate and recognize all basic primitives and non-separable primitives in the complete image. The basic primitive recognition results are output as category labels and bounding box coordinates.
[0155] In one embodiment disclosed in the present invention, after the subsystem diagram is identified using the basic graphic element recognition mode and the recognition results are obtained, for each recognition result of the subsystem diagram, it is determined whether there are non-detachable combination graphic elements.
[0156] The non-detachable combination graphic elements include current transformers, fuses, disconnectors and capacitors. Each type of non-detachable combination graphic element includes multiple sub-type combination graphic elements. For specific classification, please refer to the description in the above embodiment.
[0157] If there are inseparable combination graphics elements in the subsystem diagram, a preset algorithm is used to determine the subclass combination graphics element corresponding to the inseparable combination graphics element.
[0158] In one embodiment disclosed in the present invention, the subclass combined primitive to which the non-detachable combined primitive belongs may be determined in the following manner:
[0159] (1) For the non-detachable combination element of the current transformer class, the Hough circle transform algorithm is used to count the number of coils in the element, and the corresponding sub-class combination element is determined according to the number of coils. Among them, if the number of coils is 3, the element is determined to be a three-phase current transformer. If the number of coils is 4, the element is determined to be a four-phase current transformer, and so on.
[0160] (2) For the non-detachable combined graphics elements of the fuse type, the edge detection algorithm and the contour detection algorithm are used to count the number of quadrilaterals in the graphics element. The graphics element with 4 quadrilaterals is determined to be a varistor, and the graphics element with 2 quadrilaterals is determined to be a fuse.
[0161] (3) For the non-detachable combined graphics elements of the disconnector type, the edge detection algorithm and the contour detection algorithm are used to count the number of quadrilaterals in the graphics element. The graphics elements with non-zero quadrilateral numbers are determined to be fuse-type disconnectors, and the graphics elements with zero quadrilateral numbers are determined to be disconnectors.
[0162] (4) For the non-detachable combined graphics elements of the capacitor type, the edge detection algorithm is used to count the number of capacitors in the graphics element. The graphics element with a capacitance greater than 1 is determined as a capacitor, and the graphics element with a capacitance equal to 1 is determined as a capacitor.
[0163] In one embodiment disclosed in the present invention, after completing step S500, for each subsystem diagram, as shown in FIG. Figure 6 As shown, the following steps are required:
[0164] Step S061: Determine whether the recognition result contains all sub-elements constituting any preset detachable combination element.
[0165] Among them, the detachable combined element is composed of two sub-elements connected together, and the sub-elements belong to the basic elements.
[0166] Check if there are any sub-elements in the subsystem diagram that meet certain pre-defined combination rules. For example, a detachable combination element might consist of a "circuit breaker" element and a "current transformer" element. If the system detection results show that these two basic elements exist in the diagram at the same time, it is considered to be a potential detachable combination element.
[0167] If the recognition result includes all sub-element constituting any preset detachable combined element, step S062 is executed; if the recognition result does not include all sub-element constituting any preset detachable combined element, step S600 is executed.
[0168] Step S062: Calculate the distance between any two sub-primitive bounding boxes.
[0169] When two sub-elements that may form a detachable combined element are found, their spatial proximity is analyzed and geometric measurements are performed on the bounding boxes of the two elements. For example, Manhattan distance or Euclidean distance can be used to measure the proximity between the two elements to determine whether they have the possibility of being combined.
[0170] Step S063: using a path algorithm to determine whether two sub-graph elements whose distance is less than a preset distance threshold are connected.
[0171] If the bounding box distance is less than a pre-set combined distance threshold (e.g., 30 pixels), they are not immediately merged. Instead, they are further verified using a path connectivity algorithm. For example, a region connectivity algorithm (such as D8 adjacency) or an image path detection algorithm (such as pixel-based line tracing) can be used to determine whether two primitives have an electrical connection or path in the image. Only when a connecting line or morphologically connected region exists between the two primitives in the image can they be considered to have a valid connection relationship.
[0172] If the two are connected, step S064 is executed: the two sub-elements are replaced by the corresponding detachable combined element.
[0173] After confirming that two sub-elements meet the triple criteria of "combination rule + distance threshold + connectivity," they are merged into a single, detachable, composite element. At the data level, the original two basic element records are replaced with the new detachable composite element record, which contains information such as the merged bounding box coordinates and element type label.
[0174] Step S600: obtaining the coordinates of each graphic element and the topological relationship between the graphic elements, and generating a configuration diagram in a vector format.
[0175] In one embodiment disclosed in the present invention, for each subsystem diagram, such as Figure 7 As shown, perform the following steps:
[0176] Step S601: Obtain the outlines and electrical connections of all graphic elements in the subsystem diagram.
[0177] This step is used to accurately extract image edges and connections, ensuring that all electrical components and their connection relationships can be converted into structured image feature data through edge recognition.
[0178] In one embodiment disclosed in the present invention, Figure 8 As shown, step S601 can be implemented by using the following sub-steps:
[0179] Step S6011: Convert the subsystem graph into a grayscale graph G1.
[0180] In order to reduce the processing complexity, the color subsystem graph is first converted into a grayscale graph G1, so that image processing only needs to focus on pixel brightness information, remove color interference, and provide a unified input format for subsequent filtering, histogram equalization and other operations.
[0181] The conversion formula is as follows:
[0182]
[0183] Among them, R, G, and B represent the values of the three primary color channels of the image, red, green, and blue, respectively, and L represents the grayscale value of the converted grayscale image.
[0184] Step S6012: Apply Gaussian filtering to G1 to remove noise points in the image to obtain G2.
[0185] The image is smoothed using a Gaussian kernel to remove the original image and the noise points caused by the decomposition of the original image. The resulting image is recorded as G2.
[0186] Step S6013: performing global histogram equalization processing on G2 to enhance image contrast, and performing binarization processing and black-white inversion processing to obtain G3.
[0187] First, global histogram equalization is used to improve the overall brightness distribution contrast of the image, making the outlines of the primitives more distinct. Then, a binarization process is performed to segment the image into foreground (lines) and background (blank space). Finally, a black-and-white inversion process is performed to make the electrical lines white and the background black, which better meets the input requirements of the edge detection algorithm in subsequent steps.
[0188] Step S6014: Use the Canny edge detection algorithm to detect the contour lines and connecting lines of all the primitives in G3, and use the morphological dilation method to connect the broken lines in the detection results to obtain G4.
[0189] The Canny algorithm is used to perform edge detection on G3, detecting significant edges and connecting lines in the image. To repair broken edges caused by image quality or complex structures, morphological dilation is further applied to the detection results. Structural elements (such as a 3×3 square kernel) are used to expand and connect edge lines, generating a G4 image with more complete edge connectivity.
[0190] Step S602: extracting connection relationships between different graphic elements based on the graphic element contours and electrical connections, and generating a path sequence array.
[0191] This step uses image structure analysis to obtain the physical connection relationships between the elements in the system diagram, namely the connection topology information, and forms a structured array for configuration diagram generation. The path sequence array contains the category and bounding box coordinates of the element in each path.
[0192] In one embodiment disclosed in the present invention, Figure 9 As shown, step S602 can be implemented by using the following sub-steps:
[0193] Step S6021: Mask the bounding box of the primitive in G4 so that the mask graphic represents the corresponding primitive, thereby obtaining G5.
[0194] Because many primitives themselves are not necessarily closed, to facilitate subsequent analysis, primitives are distinguished from lines in the image as nodes, and each identified primitive bounding box is masked, that is, a specific grayscale value (such as white) is filled in the primitive bounding box area.
[0195] Step S6022: Obtain all paths in G5 based on the region connectivity function.
[0196] Among them, the path is the path connecting different graphics elements.
[0197] Use a region connectivity function (e.g., D8 distance) to determine whether there is a path extending from one primitive's bounding box to another. Each path is considered an actual electrical connection in the system. Obtain the number of connected regions in image G5 and the label of the connected region to which each pixel belongs.
[0198] The D8 distance calculation formula is as follows:
[0199]
[0200] Where (x, y) is the coordinate of pixel p, and (u, v) is the coordinate of pixel q. When it is less than or equal to 2, point q and point p are considered to be adjacent. If there is a pixel sequence between point p and point p that satisfies that any two points are adjacent, then it is considered that there is a path between point p and point q.
[0201] Step S6023: Output the category and bounding box coordinates of each primitive in all paths, and generate a path sequence array corresponding to the subsystem graph.
[0202] After all connected paths are identified, each path contains all component categories and component bounding box coordinates on the path. These are recorded in the form of a structured array, which serves as the path sequence structure of the subsystem graph.
[0203] Step S603: constructing a configuration diagram in vector format according to the path sequence array.
[0204] In one embodiment disclosed in the present invention, Figure 10 As shown, step S603 can be implemented by using the following sub-steps:
[0205] Step S6031: Establish a standard symbol library based on the information data of all graphic elements.
[0206] All component information is converted into the internal data model of the configuration tool, and SVG DOM operations are called to generate a standard component symbol library. Each template contains standard shapes (such as SVG paths, vector geometric shapes), etc., ensuring consistent and standardized graphic element styles during drawing.
[0207] Step S6032: Represent the graphic elements in the path sequence array as points, and represent the connection relationship between the graphic elements as lines.
[0208] In a vector coordinate system, the center of each primitive's bounding box in the path sequence array is considered a node, and connections to other primitives are represented as lines. By traversing the path sequence, a node-edge topology diagram of the electrical network structure is constructed, providing a topological foundation for subsequent drawing and layout.
[0209] Step S6033: Generate a configuration diagram in vector format based on the standard symbol library, and use a hierarchical layout algorithm to optimize the position of graphic elements and the arrangement of connections.
[0210] Based on the topology structure and standard symbol library information, graphical elements are sequentially placed in the coordinate system and connected by lines. To improve image clarity and logic, a hierarchical layout algorithm is introduced to adjust the order of graphical elements based on signal flow or current direction and minimize cross-connection arrangements. The final output format can be a vector graphics file (such as SVG) for the configuration diagram data.
[0211] In one embodiment disclosed in the present invention, Figure 1 The consistency check algorithm verifies whether the configuration diagram conforms to the electrical connection logic.
[0212] After the vector format configuration diagram (SVG file) is generated, the SVG file can be uploaded to the configuration tool processing page of the cloud platform. This page is a visual environment that supports interactive graphic editing. Users can perform operations such as dragging, connecting lines, and configuring graphic attributes to further modify the graphic structure or improve the graphic logic.
[0213] After uploading the SVG file, call Figure 1 The consistency check algorithm analyzes the configuration diagram. Based on the connection rules used in electrical engineering, it verifies the connection relationships between each element in the diagram, verifying their logical correctness. For example, it determines whether the power output is connected to the load, whether the signal loop is closed, whether the connection line is broken, and whether the element is isolated. The algorithm also supports pattern matching and connection path integrity analysis for standard electrical connection patterns.
[0214] If the verification algorithm determines that there is an inconsistency or error in the connection logic of the current graphic, the problem area will be displayed in the form of graphic highlighting or prompts. At this time, the user can use the graphical interactive interface of the configuration tool to manually modify and adjust the error part by dragging, connecting, deleting or using the property panel functions until the error is passed. Figure 1 Consistency check.
[0215] After the graphic logic is corrected, users can bind the SVG graphic to a specific engineering project. First, the attribute information of each graphic element is stored in the component database, including its device type, parameters, port number, number, etc.; second, the SVG graphic element is configured and integrated with the project monitoring interface as part of the runtime monitoring interface.
[0216] The embodiment of the present invention further discloses an AI generation system from drawings to configurations based on a CV large model, which is applied to the AI generation method from drawings to configurations based on a CV large model disclosed in the aforementioned embodiment.
[0217] It will be understood that the above embodiments are merely exemplary embodiments for illustrating the principles of the present invention, and the present invention is not limited thereto. Those skilled in the art will appreciate that various modifications and improvements can be made without departing from the spirit and substance of the present invention, and such modifications and improvements are also considered to be within the scope of protection of the present invention.
Claims
1. An AI generation method from drawings to configurations based on a CV large model, applied to the primary system diagram of an electrical system, characterized in that: include: The original sample set is constructed based on the single cabinet diagrams decomposed from multiple primary system diagrams. Each sample is a single cabinet diagram or a combined cabinet diagram formed by combining multiple single cabinet diagrams. Filter out samples containing preset complex primitives from the original sample set to form a complex primitive sample set. Complex primitives are primitives with nested structures and complex connection relationships. Use the preset image annotation tool to annotate the preset basic graphics elements and inseparable combination graphics elements in each sample image of the original sample set, and annotate the complex graphics elements in each sample image of the complex graphics element sample set. The basic graphics elements are the most basic and smallest unit of electrical symbols; the inseparable combination graphics elements are composite graphics elements that are expressed as a whole and contain multiple basic functional units. The preset CV vision large model is trained based on the annotated original sample set and complex primitive sample set respectively to obtain the basic primitive recognition model and the complex primitive recognition model. The basic primitive recognition model has the ability to automatically detect and annotate basic primitives and inseparable combination primitives in the entire image or sub-image; The complex primitive recognition model and the basic primitive recognition model are used in sequence to identify the target system diagram and obtain the type of each primitive in the target system diagram, including: Decompose the target system diagram to be processed into multiple subsystem diagrams; For each subsystem diagram, the type of each element is obtained in the following way: Determine whether the subsystem diagram contains complex primitives based on the complex primitive recognition model, If the subsystem diagram contains a complex graphic element, identifying the type and bounding box of the complex graphic element, and performing masking to cover the content of the bounding box on the subsystem diagram; After identifying the basic graphic elements and / or the non-detachable combined graphic elements in the mask-processed subsystem diagram using the basic graphic element recognition model, removing the mask on the subsystem diagram; If the subsystem diagram does not contain complex primitives, a basic primitive recognition model is used to identify basic primitives and / or inseparable combination primitives in the subsystem diagram; The coordinates of each primitive and the topological relationship between primitives are obtained, and a configuration diagram in vector format is generated.
2. The generation method according to claim 1, characterized in that The original sample set is constructed based on the single cabinet diagrams decomposed from multiple primary system diagrams, including: The Cohen-Sutherland line segment clipping algorithm is used to decompose each primary system diagram into multiple subsystem diagrams, and each subsystem diagram is decomposed into multiple single cabinet diagrams. Using the sliding window combination algorithm, two or more adjacent single cabinet diagrams are combined to form different combined cabinet diagrams; Rotate each single cabinet image and combination cabinet image to obtain a rotated image; The original sample set is constructed based on all single cabinet drawings, combination cabinet drawings and rotation drawings.
3. The generation method according to claim 2, characterized in that Before executing the steps of using the Cohen-Sutherland line segment clipping algorithm to decompose each primary system diagram into a plurality of subsystem diagrams, and decomposing each subsystem diagram into a plurality of single cabinet diagrams, the method further includes: Determine whether a system diagram is a hand-drawn or scanned diagram. If so, the primary system image is subjected to denoising processing and then converted into a grayscale image, and a global histogram equalization processing is performed on the grayscale image.
4. The generation method according to claim 1, characterized in that The method of using a preset image annotation tool to annotate the preset basic primitives and inseparable combination primitives in each sample image of the original sample set, and annotating the complex primitives in each sample image of the complex primitive sample set, includes: For the original sample set, the labelme image annotation tool is used to annotate the categories and bounding boxes of various preset basic primitives and various inseparable combination primitives; For the complex primitive sample set, the labelme image annotation tool is used to annotate the categories and bounding boxes of the preset complex primitives; Determine whether there are any primitive categories in the original sample set after annotation whose sample number is less than the preset training amount. If so, samples of the primitive category are added to the original sample set until the number of samples of the primitive category exceeds a preset training amount.
5. The generation method according to claim 1, characterized in that The preset CV vision large model is trained based on the labeled original sample set and the complex primitive sample set to obtain the basic primitive recognition model and the complex primitive recognition model, including: The YOLOv12 model is trained using the annotated original sample set to obtain a basic primitive recognition model, which is used to identify basic primitives and inseparable combination primitives in the system graph. The YOLOv12 model is trained using the labeled complex primitive sample set to obtain a complex primitive recognition model, which is used to identify complex primitives in the system graph.
6. The generation method according to claim 1, characterized in that The method of sequentially using the complex primitive recognition model and the basic primitive recognition model to recognize the target system diagram to obtain the type of each primitive in the target system diagram further includes: For each subsystem diagram, it is determined whether there are any non-detachable combination elements. Non-detachable combination elements include current transformers, fuses, disconnectors, and capacitors. Each type of non-detachable combination element includes multiple sub-type combination elements. If so, a preset algorithm is used to determine the subclass combination primitive corresponding to the non-detachable combination primitive.
7. The generation method according to claim 6, characterized in that The step of using a preset algorithm to determine the subclass combination primitive corresponding to the inseparable combination primitive includes: For the non-detachable combination primitives of the current transformer class, the Hough circle transform algorithm is used to count the number of coils in the primitive, and the corresponding subclass combination primitive is determined based on the number of coils; For the non-detachable combined primitives of the fuse type, edge detection and contour detection algorithms are used to count the number of quadrilaterals in the primitives. The primitives with 4 quadrilaterals are determined to be varistors, and the primitives with 2 quadrilaterals are determined to be fuses. For non-detachable combined graphics elements such as disconnectors, edge detection algorithms and contour detection algorithms are used to count the number of quadrilaterals in the graphics element. Graphic elements with non-zero quadrilateral counts are identified as fuse-type disconnectors, and graphics elements with zero quadrilateral counts are identified as disconnectors. For the non-detachable combined graphics primitives of the capacitor type, an edge detection algorithm is used to count the number of capacitors in the graphics primitives. The graphics primitives with a capacitance greater than 1 are determined as capacitors, and the graphics primitives with a capacitance equal to 1 are determined as capacitors.
8. The generation method according to claim 7, characterized in that After performing the steps of sequentially using the complex primitive recognition model and the basic primitive recognition model to recognize the target system diagram and obtaining the type of each primitive in the target system diagram, the method further includes: For each subsystem diagram, perform the following steps: Determine whether the recognition result contains all sub-elements constituting any preset detachable combined element, wherein the detachable combined element is composed of two connected sub-elements, and the sub-elements belong to the basic element. If so, calculate the distance between any two sub-element bounding boxes; A path algorithm is used to determine whether two sub-graph elements whose distance is less than a preset distance threshold are connected. If they are connected, the corresponding detachable combined primitives are used to replace the two sub-primitives.
9. The generation method according to any one of claims 6 to 8, characterized in that: The obtaining of the coordinates of each graphic element and the topological relationship between the graphic elements and generating a configuration diagram in a vector format includes: For each subsystem diagram, perform the following steps: Obtaining the outlines and electrical connections of all graphic elements in the subsystem diagram; Extracting connection relationships between different graphics elements based on the graphics element contours and electrical connections, and generating a path sequence array, wherein the path sequence array includes the category and bounding box coordinates of the graphics element in each path; Construct a configuration diagram in vector format based on the array of pathway sequences.
10. The generation method according to claim 9, characterized in that The obtaining of the outlines and electrical connections of all graphic elements in the subsystem diagram includes: Converting the subsystem graph into a grayscale graph G1; Use Gaussian filtering on G1 to remove noise points in the image and obtain G2; Perform global histogram equalization on G2 to enhance the image contrast, and perform binarization and black-white inversion processing to obtain G3; The Canny edge detection algorithm is used to detect the contour lines and connecting lines of all the primitives in G3, and the morphological expansion method is used to connect the broken lines in the detection results to obtain G4.
11. The generation method according to claim 10, characterized in that: The method of extracting the connection relationship between different graphic elements according to the graphic element contour lines and electrical connections and generating a path sequence array includes: Mask the bounding box of the primitive in G4 so that the mask represents the corresponding primitive, obtaining G5. Obtain all paths in G5 based on the region connectivity function, where the paths are paths connecting different primitives; Output the category and bounding box coordinates of each primitive in all paths, and generate a path sequence array corresponding to the subsystem graph.
12. The generation method according to claim 11, characterized in that: The configuration diagram in vector format is constructed according to the path sequence array, including: Establish a standard symbol library based on the information data of all graphic elements; Represent the graphics elements in the path sequence array as points, and represent the connection relationship between graphics elements as lines; Generate vector-format configuration diagrams based on standard symbol libraries, and use hierarchical layout algorithms to optimize the position of graphic elements and the arrangement of connections.
13. The generation method according to claim 1, characterized in that The method further comprises: A diagram consistency check algorithm is used to verify whether the configuration diagram conforms to the electrical connection logic.
14. An AI generation system from drawings to configurations based on a CV large model, characterized in that: Applicable to the AI generation method from drawings to configurations based on a CV large model according to any one of claims 1 to 13.
Citation Information
Patent Citations
Station wiring diagram link relation automatic identification method and system, medium and equipment
CN119964189A