Power grid wiring diagram composite graph element construction method, system, device and medium
By segmenting and detecting primitives and connections in power grid wiring diagrams using deep learning algorithms, and combining this with a composite primitive construction algorithm, the problem of poor composite primitive recognition is solved, achieving more efficient power grid wiring diagram recognition.
Patent Information
- Application Number
- CN202511588575.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-03
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2045-11-03
AI Technical Summary
Existing technologies have poor recognition performance for composite elements in power grid wiring diagrams. In particular, due to the small amount of data, large target size, and similar shape and structure to basic elements, the detection rate of one-stage or multi-stage detection algorithms is insufficient and the false detection rate is high.
Deep learning algorithms are used to segment primitives and their connections using a primitive connection segmentation model, detect the bounding boxes and types of basic primitives using a basic primitive detection model, and construct refined bounding boxes and types of composite primitives using a composite primitive construction algorithm. Finally, the primitive connection segmentation mask image and the basic primitive detection results are fused together.
It effectively improved the recognition level of composite elements, enhanced the perception capability of composite elements in power grid wiring diagrams, and strengthened the recognition effect.
Smart Images

Figure CN121074417B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of image processing, and in particular to a power grid wiring diagram composite graph element construction method, system, device and medium. BACKGROUND
[0002] The power grid wiring diagram plays an important role in the intelligent regulation of the power grid. It not only clearly shows the connection relationship between graph elements, the information relationship between graph elements and text, the topological relationship between bus lines and branch lines, etc., but also provides an important basis for power grid wiring diagram automatic modeling, power grid device state perception, and power grid digital system analysis. At present, for high-resolution power grid wiring diagram graph element recognition, the recognition effect of conventional basic graph elements is generally good due to the large amount of data, while the composite graph elements composed of basic graph elements often have less data, larger target size, and similar structure to part of the basic graph elements, resulting in poor perception of the trained model for composite graph elements. Therefore, how to improve the perception ability of composite graph elements has become a key to power grid wiring diagram graph element recognition.
[0003] At present, power grid wiring diagram graph element recognition often uses YOLO series, Cascade-Rcnn and other detection algorithms, but for composite graph elements with high resolution, less data, large target size, and similar structure to part of the basic graph elements, directly using one-stage detection algorithms or multi-stage detection algorithms often presents the phenomenon of insufficient detection rate and high false detection rate. SUMMARY
[0004] Therefore, the purpose of the present application is to overcome the deficiencies in the prior art and provide a power grid wiring diagram composite graph element construction method, system, device and medium.
[0005] The present application provides the following technical solutions:
[0006] In a first aspect, the present application provides a power grid wiring diagram composite graph element construction method, which comprises:
[0007] Obtaining a power grid wiring diagram, and performing sliding window cropping on the power grid wiring diagram according to a first preset resolution and a second preset resolution to obtain a first sub-image set and a second sub-image set, respectively;
[0008] Assigning a weight to each sliding window sub-image in the first sub-image set to obtain a plurality of sliding window weight sub-images, inputting the first sub-image set into a graph element connection line segmentation model to obtain a plurality of graph element connection line segmentation mask sub-images, and using each sliding window weight sub-image and each graph element connection line segmentation mask sub-image to obtain a graph element connection line segmentation mask image;
[0009] inputting the second sub-image set into a basic graph element detection model to obtain a plurality of initial basic graph element rectangular frames and corresponding basic graph element types, mapping and filtering each of the initial basic graph element rectangular frames to obtain a plurality of basic graph element rectangular frames and corresponding basic graph element types;
[0010] projecting each of the basic graph element rectangular frames and the corresponding basic graph element types onto the graph element connection segmentation mask image, searching for a graph element connection mask region within a range of each of the basic graph element rectangular frames to obtain a plurality of basic graph element refined frames and corresponding basic graph element types;
[0011] constructing each of the basic graph element refined frames and the corresponding basic graph element types by using a composite graph element construction algorithm to obtain a composite graph element refined frame and a corresponding composite graph element type, deleting a basic graph element refined frame inside the composite graph element refined frame to obtain a remaining basic graph element refined frame, merging the composite graph element refined frame and the corresponding composite graph element type with the remaining basic graph element refined frame and the corresponding basic graph element type to obtain a graph element refined frame and a corresponding graph element type, and determining the graph element refined frame and the corresponding graph element type as an electrical grid wiring diagram recognition result;
[0012] determining whether the electrical grid wiring diagram recognition result is empty, if yes, recording the electrical grid wiring diagram recognition result list as empty, and if not, recording the graph element refined frame and the corresponding graph element type in the recognition result list and saving.
[0013] In a second aspect, an electrical grid wiring diagram composite graph element construction system is provided in the embodiments of the present disclosure, and the system comprises:
[0014] a clipping module configured to obtain an electrical grid wiring diagram, clip the electrical grid wiring diagram according to a first preset resolution and a second preset resolution respectively by using a sliding window to obtain a first sub-image set and a second sub-image set respectively;
[0015] a segmentation module configured to assign a weight to each sliding window sub-image in the first sub-image set to obtain a plurality of sliding window weight sub-images, input the first sub-image set into a graph element connection segmentation model to obtain a plurality of graph element connection segmentation mask sub-images, and obtain a graph element connection segmentation mask image by using each of the sliding window weight sub-images and each of the graph element connection segmentation mask sub-images;
[0016] a detection module configured to input the second sub-image set into a basic graph element detection model to obtain a plurality of initial basic graph element rectangular frames and corresponding basic graph element types, and map and filter each of the initial basic graph element rectangular frames to obtain a plurality of basic graph element rectangular frames and corresponding basic graph element types;
[0017] The refining module is configured to project each of the basic primitive rectangular frame and the corresponding basic primitive type onto the primitive connection segmentation mask image, search a primitive connection mask region within each of the basic primitive rectangular frame, and obtain a plurality of basic primitive refined frames and corresponding basic primitive types;
[0018] The constructing module is configured to construct each of the basic primitive refined frame and the corresponding basic primitive type by using a composite primitive construction algorithm, obtain a composite primitive refined frame and a corresponding composite primitive type, delete the basic primitive refined frame inside the composite primitive refined frame to obtain a remaining basic primitive refined frame, merge the composite primitive refined frame and the corresponding composite primitive type with the remaining basic primitive refined frame and the corresponding basic primitive type to obtain a primitive refined frame and a corresponding primitive type, and determine the primitive refined frame and the corresponding primitive type as the power grid connection diagram recognition result.
[0019] The recording module is configured to determine whether the power grid connection diagram recognition result is empty, record the power grid connection diagram recognition result list as empty if the power grid connection diagram recognition result is empty, and record the primitive refined frame and the corresponding primitive type in the recognition result list if the power grid connection diagram recognition result is not empty.
[0020] In a third aspect, a computer device is provided in the embodiments of the present disclosure. The computer device includes a memory and a processor. The memory stores a computer program. The processor implements the steps of the power grid connection diagram composite primitive construction method in the first aspect when executing the computer program.
[0021] In a fourth aspect, a computer readable storage medium is provided in the embodiments of the present disclosure. The computer readable storage medium stores a computer program. The computer program implements the steps of the power grid connection diagram composite primitive construction method in the first aspect when executed by a processor.
[0022] The present application has the following beneficial effects:
[0023] The power grid connection diagram composite primitive construction method provided by the embodiments of the present application is based on a deep learning algorithm. The primitive and connection are segmented from the background by using a primitive connection segmentation model, the basic primitive rectangular frame and type are detected by using a basic primitive detection model, the refined basic primitive refined frame and type are fused by using a segmentation mask image and a basic primitive detection result, and finally the refined composite primitive refined frame and type are constructed by using a composite primitive construction algorithm. Therefore, the recognition level of the composite primitive is effectively improved.
[0024] In order to make the above objectives, characteristics and advantages of the present application more apparent and easy to understand, the following preferred embodiments are described in detail below, and the accompanying drawings are referred to. BRIEF DESCRIPTION OF DRAWINGS
[0025] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings needed to be used in the embodiments will be briefly introduced as follows. It should be understood that the following drawings only show some of the embodiments of the present application, and therefore should not be regarded as a limitation on the scope. Other related drawings can also be obtained by those of ordinary skill in the art without creative labor on the basis of these drawings. In the various drawings, similar components are denoted by similar reference numerals.
[0026] Figure 1 A flowchart of a method for constructing a composite graph element of a power grid wiring diagram is shown;
[0027] Figure 2 A network structure diagram of an improved YOLO12 detection algorithm is shown;
[0028] Figure 3 A network structure diagram of a first spatial attention module is shown;
[0029] Figure 4 A network structure diagram of a first efficient attention module is shown;
[0030] Figure 5 A diagram of a preset digital matrix and a preset type matrix is shown;
[0031] Figure 6 A diagram of a first digital search path from a starting point graph element to a reference graph element and a first type search path from a starting point graph element type to a reference graph element type is shown;
[0032] Figure 7 A diagram of a second digital search path or a third digital search path from a reference graph element and a second type search path or a third type search path from a reference graph element type is shown;
[0033] Figure 8 One of the example diagrams of a composite graph element and a basic graph element is shown;
[0034] Figure 9 One of the example diagrams of a preset digital matrix and a preset type matrix is shown;
[0035] Figure 10 One of the example diagrams of a first digital search path from a starting point graph element to a reference graph element and a first type search path from a starting point graph element type to a reference graph element type is shown;
[0036] Figure 11 This application provides an example diagram of a second or third digital search path that diffuses outward from a reference primitive and a second or third type search path that diffuses outward from a reference primitive type, as provided in this application embodiment.
[0037] Figure 12 This illustration shows a second example of a composite primitive and a basic primitive provided in an embodiment of this application;
[0038] Figure 13 This illustration shows a second example of a preset digital matrix and a preset type matrix provided in an embodiment of this application;
[0039] Figure 14 This illustration shows a second example of a first digital search path from a starting element to a reference element and a first type search path from a starting element type to a reference element type, provided by an embodiment of this application.
[0040] Figure 15 This illustration shows a second example diagram of a second or third digital search path that diffuses outward from a reference primitive and a second or third type search path that diffuses outward from a reference primitive type, as provided in an embodiment of this application.
[0041] Figure 16 This paper presents a schematic diagram of a composite element construction system for power grid wiring diagrams provided in an embodiment of this application. Detailed Implementation
[0042] Embodiments of the present invention are described in detail below. Examples of these embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention.
[0043] Example 1
[0044] like Figure 1 The diagram shown is a flowchart of a method for constructing composite elements of a power grid wiring diagram according to an embodiment of this application. The method for constructing composite elements of a power grid wiring diagram provided in this embodiment includes the following steps:
[0045] Step S110: Obtain the power grid wiring diagram, and crop the power grid wiring diagram by sliding window according to the first preset resolution and the second preset resolution to obtain the first sub-image set and the second sub-image set respectively.
[0046] Firstly, the power grid wiring diagram is acquired, and the power grid wiring diagram is respectively cut according to the first preset resolution size and the second preset resolution size to obtain a first sub-image set and a second sub-image set.
[0047] In the embodiment, the first preset resolution and the second preset resolution are both 1500*1500. In actual situations, the first preset resolution and the second preset resolution can be the same or different, and the embodiment does not limit this. In addition, if the width and height of the power grid wiring diagram are lower than 1500 pixels, padding filling processing is performed.
[0048] The above steps cut the power grid wiring diagram according to the first and second preset resolutions, which can not only decompose the high-resolution large graph into subgraphs suitable for subsequent model processing, but also ensure the size uniformity of small-size images, thereby laying a data foundation for accurate execution of subsequent graph element connection segmentation and basic graph element detection and avoiding the influence of image size difference on model processing effect.
[0049] In step S120, a weight is assigned to each sliding window sub-image in the first sub-image set to obtain a plurality of sliding window weight sub-images. The first sub-image set is input into a graph element connection segmentation model to obtain a plurality of graph element connection segmentation mask sub-images. The graph element connection segmentation mask image is obtained by using the sliding window weight sub-images and the graph element connection segmentation mask sub-images.
[0050] Specifically, a corresponding weight is assigned to each sliding window sub-image in the first sub-image set according to a two-dimensional normal probability distribution to obtain a plurality of sliding window weight sub-images with large center region weights and small edge region weights. Then, the first sub-image set is input into a graph element connection segmentation model to obtain a plurality of graph element connection segmentation mask sub-images.
[0051] Then, the coordinates of the sliding window weight sub-images and the coordinates of the graph element connection segmentation mask sub-images are respectively mapped back to the coordinates of the power grid wiring diagram to obtain a plurality of mapped sliding window weight sub-images and a plurality of mapped graph element connection segmentation mask sub-images. Then, the mapped sliding window weight sub-images and the mapped graph element connection segmentation mask sub-images are normalized by using a preset normalization formula to obtain a graph element connection segmentation mask image, wherein the preset normalization formula is:
[0052]
[0053] In the formula, x and y represent the coordinates of the power grid wiring diagram, and the mask value of the graph element connection segmentation mask image corresponding to the coordinates x and y in the power grid wiring diagram is represented by f(x, y). a mask value of a mapped primitive line segmentation mask sub-image, default 0 if not present, representing coordinates in the power grid wiring diagram the first weight value of a mapped sliding window weight sub-image corresponding to the premises, default 0 if not present, representing the number of sliding window sub-images.
[0054] It should be noted that in the present embodiment, the training process of the primitive line segmentation model is as follows: according to the high-resolution power grid wiring diagram, two types of labels of primitive line and background are constructed, and a primitive line mask image is labeled (in order to quickly label the primitive line mask image in the present embodiment, a threshold segmentation algorithm can be used for preliminary segmentation, and a labeling tool can be used for mask information correction), and then a primitive line original sample library is obtained; according to the primitive line original sample library, image cropping is performed through a sliding window (in the present embodiment, the cropping resolution is 1500 pixels x 1500 pixels, and if the width and height of the original image are lower than 1500 pixels, padding filling processing will be performed), and then a primitive line original sub-image library is obtained; according to the primitive line original sample library, a primitive line augmented sample library is constructed (the augmentation methods include left-right flipping, angle rotation, Gaussian noise, etc.), and image cropping is performed through a sliding window (in the present embodiment, the cropping resolution is 1500 pixels x 1500 pixels, and if the width and height of the original image are lower than 1500 pixels, padding filling processing will be performed), and then a primitive line augmented sub-image library is obtained; the primitive line original sub-image library and the primitive line augmented sub-image library are merged to obtain a primitive line training sample library; according to the primitive line training sample library, a U-Net semantic segmentation algorithm is trained to obtain a primitive line segmentation model.
[0055] The above step assigns a weight of "high center weight and low edge weight" to the sliding window sub-image, and a primitive line segmentation mask image is obtained by combining the normalization operation and the U-Net semantic segmentation model, which can effectively reduce the edge error during sliding window splicing and improve the segmentation accuracy of primitives and lines, providing a clear line area reference for subsequent refinement of basic primitive boxes and construction of composite primitives.
[0056] In step S130, the second sub-image set is input into the basic primitive detection model to obtain a plurality of initial basic primitive rectangular boxes and their corresponding basic primitive types, and the initial basic primitive rectangular boxes are mapped and filtered to obtain a plurality of basic primitive rectangular boxes and their corresponding basic primitive types.
[0057] Further, the second sub-image set is input into the basic graph element detection model to obtain a plurality of initial basic graph element rectangular frames and corresponding basic graph element types. Then, coordinates of each initial basic graph element rectangular frame are mapped back to coordinates of the power grid connection diagram to obtain a plurality of mapped basic graph element rectangular frames and corresponding basic graph element types (including circuit breakers, disconnectors, capacitors, reactances, transformers, and the like).
[0058] Next, for each basic graph element type, a corresponding confidence threshold is set, the confidence of each mapped basic graph element rectangular frame is obtained, and rectangular frames with a confidence lower than the confidence threshold (for example, 0.35) of the corresponding basic graph element type are filtered out to obtain a plurality of filtered basic graph element rectangular frames and corresponding basic graph element types. For each basic graph element type, a corresponding variation overlap rate threshold is set, the variation overlap rate of each filtered basic graph element rectangular frame is calculated using an area non-maximum suppression processing algorithm (ANMS), and rectangular frames with a variation overlap rate greater than the variation overlap rate threshold (for example, 0.85) of the corresponding basic graph element type are deleted to obtain a plurality of basic graph element rectangular frames and corresponding basic graph element types.
[0059] In the above process, since the basic graph element detection model detects sliding window images, some sliding window images contain complete target contours, but some sliding window images contain only partial target contours. Thus, after detection by the basic graph element detection model, rectangular frames of complete target contours and rectangular frames of partial target contours are obtained. Therefore, the area non-maximum suppression processing algorithm is used to retain the rectangular frames of complete target contours detected by the basic graph element detection model and delete the rectangular frames of partial target contours detected by the basic graph element detection model.
[0060] Preferably, the flow of the area non-maxima suppression processing algorithm is as follows: first, sort all the rectangular frames in descending order of the area of the rectangular frame; then, select the rectangular frame with the largest area as the registration rectangular frame, and calculate the mutation overlap rate of each remaining rectangular frame with the registration rectangular frame using the preset mutation overlap rate formula, so that each remaining rectangular frame corresponds to a mutation overlap rate, if the mutation overlap rate is greater than the preset mutation overlap rate threshold (for example, 0.85), the corresponding remaining rectangular frame is deleted, and if the mutation overlap rate is less than or equal to the preset mutation overlap rate threshold, the corresponding remaining rectangular frame is retained; then, select the rectangular frame with the largest area in the remaining rectangular frames as the registration rectangular frame in the new round, calculate the mutation overlap rate of each other remaining rectangular frame with the registration rectangular frame in the new round using the preset mutation overlap rate formula, delete the other remaining rectangular frame with the mutation overlap rate greater than the preset mutation overlap rate threshold, and retain the other remaining rectangular frame with the mutation overlap rate less than or equal to the preset mutation overlap rate threshold, and continue to repeat the above steps until there is no rectangular frame with a mutation overlap rate greater than the preset mutation overlap rate threshold in all selected registration rectangular frames; finally, all selected registration rectangular frames are taken as the output rectangular frame of the final algorithm.
[0061] Understandably, the preset mutation overlap rate formula is:
[0062]
[0063] In the formula, represents the mutation overlap rate of the rectangular frame ABCD and the rectangular frame EFGH, represents the intersection area of the rectangular frame ABCD and the rectangular frame EFGH, is the area of the rectangular frame ABCD, is the area of the rectangular frame EFGH, is the horizontal coordinate of the top-left point A of the rectangular frame ABCD, is the vertical coordinate of the top-left point A of the rectangular frame ABCD, is the horizontal coordinate of the bottom-right point C of the rectangular frame ABCD, is the vertical coordinate of the bottom-right point C of the rectangular frame ABCD, is the horizontal coordinate of the top-left point E of the rectangular frame EFGH, is the vertical coordinate of the top-left point E of the rectangular frame EFGH, is the horizontal coordinate of the bottom-right point G of the rectangular frame EFGH, is the vertical coordinate of the bottom-right point G of the rectangular frame EFGH.
[0064] It should be noted that in the present embodiment, the training process of the basic graph element detection model is as follows: according to the high-resolution power grid wiring diagram, a basic graph element multi-class label is constructed, and a basic graph element bounding box and a basic graph element type are labeled to obtain a basic graph element original sample library; according to the basic graph element original sample library, image cropping is performed through a sliding window (in the present embodiment, the cropping resolution is 1500 pixels x 1500 pixels, and if the width and height of the original image are lower than 1500 pixels, padding filling processing will be performed), and then a basic graph element original subgraph library is obtained; according to the basic graph element original sample library, a basic graph element augmented sample library is constructed (the augmentation methods include left-right flipping, angle rotation, Gaussian noise, etc., and since the basic graph element type is determined according to the shape and connection direction of the graph element, the label category will be changed after left-right flipping and angle rotation), and image cropping is performed through a sliding window (in the present embodiment, the cropping resolution is 1500 pixels x 1500 pixels, and if the width and height of the original image are lower than 1500 pixels, padding filling processing will be performed), and then a basic graph element augmented subgraph library is obtained; the basic graph element original subgraph library and the basic graph element augmented subgraph library are merged to obtain a basic graph element training sample library; the improved YOLO12 detection algorithm is trained according to the basic graph element training sample library, and the basic graph element detection model is obtained.
[0065] Understandably, given the large number of basic graph element types, the varying sizes of the targets, and the complex shape and connection changes, in order to accurately detect the basic graph element region, the present application adopts the improved YOLO12 detection algorithm to build the basic graph element detection model, which not only effectively covers the scale range of each basic graph element, but also effectively perceives the features of each basic graph element itself.
[0066] In order to accurately obtain high-level detail features and quickly extract power grid wiring diagram basic graph elements, the present application introduces a spatial attention module (SAM) in the feature pyramid network part of the original YOLO12 detection algorithm, so that the network pays more attention to the basic graph element, and introduces an efficient attention module (EAM) module after the fusion of 3 layers of feature maps, so that the network can quickly capture the detail features of the basic graph element.
[0067] As shown in Figure 2 , the improved YOLO12 detection algorithm includes a backbone network, a feature pyramid network, and a decoupling head, the feature pyramid network includes a first spatial attention module, a second spatial attention module, a first convolutional module, a second convolutional module, a first efficient attention module, a second efficient attention module, and a third efficient attention module, and the decoupling head includes a first classification regression module, a second classification regression module, and a third classification regression module.
[0068] Specifically, the second sub-image set is input into the basic primitive detection model to obtain multiple initial basic primitive bounding boxes and their corresponding basic primitive types. The specific process is as follows:
[0069] First, such as Figure 2 As shown, each sliding window sub-image of the power grid wiring in the second sub-image set is processed through a backbone network (Conv3~Conv5) jointly constructed by the C3K2 module and the A2C2F module to obtain a first-layer feature map F3, a second-layer feature map F4, and a third-layer feature map F5. Then, F3~F5 are input into the feature pyramid network PA-SACM-FPN, where the third-layer feature map F5 and the second-layer feature map F4 are processed by the first spatial attention module to obtain a first spatial attention feature map SAF4. Then, the first spatial attention feature map SAF4 is processed by the first spatial attention module. The two-layer feature map F4 is concatenated to generate the first fused feature map ~P4. Then, the first fused feature map ~P4 and the first-layer feature map F3 are passed through the second spatial attention module to obtain the second spatial attention feature map SAF3. Next, the second spatial attention feature map SAF3 is concatenated with the first-layer feature map F3 to generate the second fused feature map P3. Then, the second fused feature map P3 is passed through the first convolution module to generate the first feature map PAF4 with the same resolution as the first fused feature map ~P4. The first feature map PAF4 is further concatenated with the first fused feature map ~P4. Figures P3 to P4 are concatenated to generate a third fused feature map P4. Then, the third fused feature map P4 is passed through a second convolution module to generate a second feature map PAF5 with the same resolution as the third-layer feature map F5. The second feature map PAF5 is further concatenated with the third-layer feature map F5 to generate a fourth fused feature map P5. Then, the second fused feature map P3, the third fused feature map P4, and the fourth fused feature map P5 are passed through the first, second, and third efficient attention modules, respectively, to obtain the first efficient attention feature map T3, the second efficient attention feature map T4, and the third efficient attention feature map T5. This results in cross-level detail feature maps (T3~T5) arranged from top to bottom and bottom to top. Finally, the first efficient attention feature map T3, the second efficient attention feature map T4, and the third efficient attention feature map T5 are classified and regressed through the first, second, and third classification regression modules in the decoupling head, respectively, to obtain multiple initial basic primitive rectangles and their corresponding basic primitive types for the second sub-image set, completing the detection task of basic primitives in the power grid wiring diagram.
[0070] It should be noted that, in Figure 2 In this context, "concat" refers to the operation of stitching multiple images together along a certain dimension to facilitate subsequent calculations.
[0071] Understandably, as Figure 3 The working principle of the spatial attention module in the above process is as follows (taking the third layer feature map F5 and the second layer feature map F4 as input of the first spatial attention module, and taking the first spatial attention feature map SAF4 as an example): first, the low layer high resolution feature map (the second layer feature map F4) is respectively subjected to channel maximum pooling and channel average pooling, to obtain single channel maximum value feature map and average feature map; then, the maximum value feature map and the average feature map are subjected to channel splicing to obtain two channel feature maps, and the two channel feature maps are subjected to 1x1 convolution operation to obtain a single channel feature map, and the single channel feature map is subjected to Relu activation function to obtain a spatial weighting feature map; then, the high layer low resolution feature map (the third layer feature map F5) is sequentially subjected to 1x1 convolution and up sampling to obtain an up sampling feature map with the same resolution as the low layer high resolution feature map; finally, the spatial weighting feature map and the up sampling feature map are subjected to product operation to obtain the first spatial attention feature map SAF4.
[0072] It should be noted that in the process of inputting the first fusion feature map ~P4 and the first layer feature map F3 into the second spatial attention module to obtain the second spatial attention feature map SAF3, the first fusion feature map ~P4 is a high layer low resolution feature map, and the first layer feature map F3 is a low layer high resolution feature map, and the specific principle is the same as that of the first spatial attention module, which will not be repeated here.
[0073] Understandably, as Figure 4As shown, the working principle of the high-efficiency attention module in the above process is as follows (taking the second fusion feature map P3 as input of the first high-efficiency attention module and obtaining the first high-efficiency attention feature map T3 as an example): first, according to the channel number c of the second fusion feature map P3, the second fusion feature map P3 is evenly divided into two fusion feature subgraphs, and the channel numbers of the two fusion feature subgraphs are c / 2 and c / 2 respectively; the two fusion feature subgraphs are respectively subjected to spatial maximum pooling and spatial average pooling, and are subjected to channel splicing to obtain a channel feature map with a channel number of c; then, the channel feature map is subjected to 1x1 convolution and is subjected to a Relu activation function to obtain a channel weighting feature map, and the second fusion feature map P3 and the channel weighting feature map are subjected to matrix multiplication operation to obtain a channel attention feature map; then, according to the channel number c of the channel attention feature map, the channel attention feature map is evenly divided into two channel attention feature subgraphs, and the channel numbers of the two channel attention feature subgraphs are c / 2 and c / 2 respectively; the two channel attention feature subgraphs are respectively subjected to channel maximum pooling and channel average pooling, and are subjected to channel splicing to obtain a spatial feature map with a channel number of 2; the spatial feature map is subjected to 1x1 convolution and is subjected to a Relu activation function to obtain a spatial weighting feature map with a channel number of 1, and finally the channel attention feature map and the spatial weighting feature map are subjected to matrix multiplication operation to obtain the first high-efficiency attention feature map T3.
[0074] It should be noted that the specific principle of inputting the third fusion feature map P4 into the second high-efficiency attention module to obtain the second high-efficiency attention feature map T4, and inputting the fourth fusion feature map P5 into the third high-efficiency attention module to obtain the third high-efficiency attention feature map T5 is consistent with the principle of the above-mentioned first high-efficiency attention module, and this embodiment will not be repeated here.
[0075] In the above step, the improved YOLO12 detection algorithm is used in the basic graph element detection model, the spatial attention module is used to give the high-level feature map a detailed attention degree in the low-level feature map, and the high-efficiency attention module is used for fast and detailed learning of target features, which not only enhances the expression of high-level semantic features of the target, but also effectively controls the calculation efficiency of the target features, laying a foundation for the accuracy and speed of the basic graph element detection.
[0076] In step S140, each basic graph element rectangular frame and its corresponding basic graph element type are projected onto the graph element connection segmentation mask image, and the graph element connection mask region in each basic graph element rectangular frame is searched to obtain a plurality of basic graph element refinement frames and their corresponding basic graph element types.
[0077] Further, the base primitive rectangle frame and the corresponding base primitive type are projected onto the primitive line segmentation mask image, and the primitive line mask region within the base primitive rectangle frame is searched to obtain a plurality of primitive line mask rectangle frames, and each primitive line mask rectangle frame is taken as a base primitive refinement frame, and a plurality of base primitive refinement frames and the corresponding base primitive types are obtained.
[0078] The above step projects the base primitive rectangle frame onto the primitive line segmentation mask image, searches and acquires the primitive line mask region as the base primitive refinement frame, which can optimize the boundary of the base primitive frame in combination with the segmentation result, so that the frame body is more fitted to the range of the actual primitive and the line, and provides accurate frame body data support for the subsequent "center distance calculation" and "line without other primitive judgment" in the composite primitive construction.
[0079] In step S150, the base primitive refinement frame and the corresponding base primitive type are constructed by using a composite primitive construction algorithm to obtain a composite primitive refinement frame and the corresponding composite primitive type, the base primitive refinement frame inside the composite primitive refinement frame is deleted to obtain a remaining base primitive refinement frame, the composite primitive refinement frame and the corresponding composite primitive type are merged with the remaining base primitive refinement frame and the corresponding base primitive type to obtain a primitive refinement frame and the corresponding primitive type, and the primitive refinement frame and the corresponding primitive type are determined as the power grid wiring diagram recognition result.
[0080] Understandably, in a high-resolution power grid wiring diagram, the amount of base primitive data is relatively large, and the recognition effect is generally good. The composite primitive composed of the base primitive often has less data, a larger target size, and a similar structure to the base primitive, which leads to poor perception of the model trained for the composite primitive. In order to improve the recognition effect of the composite primitive and eliminate the ambiguity of the base primitive and the composite primitive during model training, the application only trains a base primitive detection model, and constructs a composite primitive by using a composite primitive construction algorithm based on the base primitive detection, thereby effectively taking into account the recognition effect of the base primitive and the composite primitive.
[0081] First, a preset matrix is constructed, the preset matrix including a preset number matrix and a preset type matrix, the preset number matrix including a plurality of basic graph elements, and the preset type matrix including a plurality of basic graph element types corresponding to the basic graph elements, wherein the preset number matrix is used to mark a search level and a search direction of a composite graph element, and the preset type matrix is used to mark a search space and a search relationship of the composite graph element; the composite graph element is split into single basic graph elements according to a composition structure of the composite graph element, the basic graph elements in the preset number matrix are marked as component graph elements, the basic graph element types in the preset type matrix are marked as component graph element types, the component graph elements in a central region of the preset number matrix are marked as reference graph elements, and the component graph element types in the central region of the preset type matrix are marked as reference graph element types.
[0082] As shown in the example, Figure 5 , the preset number matrix is , and the preset type matrix is . The number 0 in the preset number matrix corresponds to the reference graph element type in the preset type matrix . All component graph elements adjacent to the reference graph element 0 are marked as first component graph elements, that is, the numbers 1 in the eight positions in the preset number matrix correspond to the component graph element types in the preset type matrix . ( ~ The graph element types can be the same or different); if there are remaining component graph elements that have not been marked, the remaining component graph elements adjacent to the first component graph elements are marked as second component graph elements, that is, the numbers 2 in the 16 positions in the preset number matrix correspond to the component graph element types in the preset type matrix . ~ ( ~ The graph element types can be the same or different); if there are remaining component graph elements that have not been marked, the remaining component graph elements adjacent to the second component graph elements are marked as third component graph elements, that is, the numbers 3 in the 24 positions in the preset number matrix correspond to the component graph element types in the preset type matrix . ~ ( ~ The graph element types can be the same or different); and the process is sequentially repeated.
[0083] It should be noted that according to the current statistics of all composite graph element structures, the reference graph element in the center region to the component graph element in the edge region will not exceed 3 layers, the total number of types will not exceed 49 types, and the number of component graph element instances will not exceed 49, so the preset digital matrix of 7x7 is used in the embodiment of the application to mark the search level of the composite graph element, and the preset type matrix of 7x7 to mark the search space of the composite graph element. However, in actual situations, the specific matrix form can be determined according to actual situations, and the embodiment of the application does not limit this.
[0084] Then, the number of all basic graph element refinement boxes is counted, and in the preset type matrix , the number of basic graph element refinement boxes corresponding to each component graph element type is screened out. In order to speed up the search efficiency and construct a fast composite graph element, the component graph element type with the least number of basic graph element refinement boxes is selected as the starting graph element type of the composite graph element search, the position of the starting graph element type is marked in the preset type matrix , and the position of the starting graph element type is projected into the preset digital matrix to obtain the position of the starting graph element.
[0085] For example, assuming that the component graph element type with the least number of refinement boxes is , as shown in Figure 6 , the coordinate in the preset type matrix is (1, 2), and the projection into the preset digital matrix corresponds to the number 3 with the coordinate (1, 2).
[0086] Next, in the preset digital matrix , if the starting graph element is located outside the reference graph element, a first digital search path (such as the search arrow path in the preset digital matrix Figure 6 , that is, 3→2→1→0) from the starting graph element to the reference graph element is determined, and the first digital search path is projected into the preset type matrix to obtain the corresponding first type search path (such as the search arrow path in the preset type matrix , that is, Figure 6 → → → → → The algorithm iterates through each refinement box of the starting point primitive type, marking the component primitive types in the first type search path as node primitive types, and searches according to the first type search path. If the refinement boxes of two node primitive types in the first type search path do not meet the preset composite primitive matching rules, it indicates that the corresponding refinement box of the base primitive type cannot be found, and the search process for the refinement box of the current starting point primitive type ends. If the refinement boxes of any two adjacent node primitive types in the first type search path meet the preset composite primitive matching rules, it indicates that the corresponding refinement box of the base primitive type can be found, and a second digital search path is determined to expand outward from the base primitive (e.g., ...). Figure 7 Preset digital matrix (Search arrow path in the middle), and project the second numerical search path onto the preset type matrix. In the middle, the corresponding second type of search path is obtained (such as...) Figure 7 Preset type matrix The search proceeds along the second type of search path (using the search arrow path in the image). If the refined bounding boxes of two node element types in the second type of search path do not meet the preset composite element matching rules, it indicates that not all component element types can be found, and the search process for the refined bounding box of the current starting element type ends. If the refined bounding boxes of any two adjacent node element types in the second type of search path meet the preset composite element matching rules, it indicates that all component element types can be found, and the refined bounding box of the base element type is merged with the refined bounding boxes of all component element types to obtain the first merged box. The first merged box is determined as the composite element refined box, the element type of the composite element refined box is determined as the composite element type, and the search process for the refined bounding box of the current starting element type ends.
[0087] Next, in the preset digital matrix In the process, if the starting point element coincides with the reference element, a third digital search path is determined that expands outward from the starting point element (e.g., ...). Figure 7 Preset digital matrix (Search arrow path in the middle), and project the third number search path onto the preset type matrix. In the middle, the corresponding third type of search path is obtained (such as...) Figure 7 Preset type matrix searching arrow path in the first type search path), traversing each refinement box of the starting graph element type, marking the component graph element types in the third type search path as node graph element types, and searching according to the third type search path, if the refinement boxes of any two node graph element types in the third type search path do not satisfy the preset composite graph element matching rule, it indicates that the refinement boxes of all component graph element types cannot be found, and the searching process of the refinement box of the starting graph element type is ended; if the refinement boxes of any two adjacent node graph element types in the third type search path satisfy the preset composite graph element matching rule, it indicates that the refinement boxes of all component graph element types can be found, at this time, the refinement box of the starting graph element type is merged with the refinement boxes of all component graph element types to obtain a second merged box, the second merged box is determined as the composite graph element refinement box, the graph element type of the composite graph element refinement box is determined as the composite graph element type, and the searching process of the refinement box of the starting graph element type is ended.
[0088] It should be noted that the first digital search path from the starting graph element to the reference graph element in the above process is determined by referring to the principle of step-by-step climbing, and is searched in a step-by-step manner (i.e., one step at a time to climb uphill, and only one step is needed at the same level). Like steadily climbing to the top along fixed steps, the reference graph element is quickly locked and the reference graph element is quickly positioned and accurately reached, avoiding redundant calculation of invalid paths. The second digital search path or the third digital search path spreading outwards from the reference graph element in the above process is determined by referring to the principle of multiple people downhill from multiple paths, taking the reference graph element as the core diffusion point, and synchronously traversing outward along multiple independent paths (i.e., multiple people downhill from different paths in parallel, so that multiple people can quickly complete the downhill). Through multi-branch parallel advancement, all component graph elements to be matched can be quickly covered, effectively avoiding the redundant time consumption of single path searching, and ensuring the efficiency of composite graph element construction. Finally, when the searching process of the refinement box of all starting graph element types ends, the composite graph element refinement box and the corresponding composite graph element type are obtained, and the composite graph element refinement box and the corresponding composite graph element type are taken as the composite graph element construction result.
[0089] Example one, as shown in the composite graph element shown in Figure 8 , is composed of 6 basic graph elements, and the knife gate graph element (green box) in the central region is taken as the reference graph element. The corresponding preset digital matrix and preset type matrix are as shown in Figure 9 . At this time, the preset digital matrix has 1 reference graph element and 5 first component graph elements, and the corresponding preset type matrix has a reference graph element type of and first component graph element types of , , , , ,in and Same type and Same type; assuming type The minimum number of refinement boxes is then used. Given the starting primitive type, the first numerical search path from the starting primitive to the base primitive and the first type search path from the starting primitive type to the base primitive type are as follows: Figure 10 As shown, the second or third digital search path expanding outward from the base primitive and the second or third type search path expanding outward from the base primitive type are as follows: Figure 11 As shown.
[0090] Example 2, such as Figure 12 The composite graphic shown consists of 9 basic graphic elements. Taking the fuse graphic element in the central area (green box) as the base graphic element, the corresponding preset number matrix and preset type matrix are as follows: Figure 13 As shown, the preset digital matrix at this time There is one base primitive (green box), five first component primitives (blue box), and three second component primitives (black box), corresponding to a preset type matrix. The base primitive type is The first component primitive type is , , , , The second component primitive type is , , ,in , Same type; assuming type The minimum number of refinement boxes is then used. Given the starting primitive type, the first numerical search path from the starting primitive to the base primitive and the first type search path from the starting primitive type to the base primitive type are as follows: Figure 14 As shown, the second or third digital search path expanding outward from the base primitive and the second or third type search path expanding outward from the base primitive type are as follows: Figure 15 As shown.
[0091] It should be noted that the preset composite element matching rules in this application are explained as follows:
[0092] (1) First, based on the preset composite primitive sample set, the maximum distance between the center points of the refinement boxes of two adjacent component primitive types in the preset composite primitive sample set is calculated, and the maximum distance of the preset multiple (e.g., 2 times) is marked as the spatial search range.
[0093] (2) Then, any two adjacent node elements in the current number search path (first number search path, second number search path or third number search path) are marked as the preceding node element and the following node element, respectively. The preceding node element and the following node element have corresponding preceding node element types and following node element types in the current type search path. According to the current type search path (first type search path, second type search path or third type search path), the position of the preceding node element type is determined. The direction from the preceding node element type to the following node element type is determined as the target search direction. Within the spatial search range corresponding to this target search direction, multiple candidate following node element types are filtered out.
[0094] (3) If a refined frame of a subsequent node element type that meets the preset conditions can be selected from the refined frames of each candidate subsequent node element type, then it is determined that the refined frame of the preceding node element type and the refined frame of the subsequent node element type that meets the preset conditions satisfy the preset composite element matching rules. The preset conditions are that the straight-line distance between the center point of the refined frame of the preceding node element type and the center point of the refined frame of the subsequent node element type is the shortest, and there are no other basic element refined frames in the area connected between the center point of the refined frame of the preceding node element type and the center point of the refined frame of the subsequent node element type.
[0095] For example: (1) Determine the direction from the starting primitive type to the first node primitive type according to the search trajectory of the type matrix (e.g., Figure 6 of → , exist (Lower right), and within the spatial search range in this search direction, find the first node element type of the thinning box with the shortest distance between its center and the center of the thinning box, and no other basic element thinning boxes on the line connecting the centers of the thinning boxes (e.g., the first node element type of the thinning box). Figure 3 of exist The closest one in the bottom right corner and There are no other basic graphic elements on the center line of the refinement box. and (1) Satisfy the preset composite primitive matching rules); (2) Determine the direction from the first node primitive type to the second node primitive type according to the search trajectory of the type matrix (e.g., Figure 6 of → , exist the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the Figure 6 the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the Figure 6 the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the Figure 6 the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the the second node graph element type whose distance to the center of the refining box is the shortest and which has no other basic graph element refining box on the connecting line of the centers of the refining boxes of the two node graph element types, in the spatial search range of the search direction (such as the refining box of the
[0096] Further, after obtaining the composite graph element construction result, the basic graph element refining boxes inside the composite graph element refining box are deleted to obtain the remaining basic graph element refining boxes, the composite graph element refining box and the corresponding composite graph element type and the remaining basic graph element refining box and the corresponding basic graph element type are merged, the graph element refining box and the corresponding graph element type are finally obtained, and the graph element refining box and the corresponding graph element type are determined as the power connection diagram recognition result.
[0097] The above steps adopt the composite graph element construction algorithm, which not only eliminates the ambiguity of the basic graph element and the composite graph element during model training, but also effectively avoids the problem that the integrity of the composite graph element is damaged due to the overlapping sliding window, and deletes the basic box inside the composite graph element and merges the result, which takes into account the recognition effect of the basic graph element and the composite graph element, and greatly improves the recognition level of the composite graph element.
[0098] In step S160, it is judged whether the power connection diagram recognition result is empty. If yes, the recognition result list of the power connection diagram is recorded as empty. If not, the graph element refining box and the corresponding graph element type are recorded into the recognition result list and saved.
[0099] Understandably, after obtaining the power grid wiring diagram recognition result, it is determined whether the recognition result is empty. If the recognition result is empty, it proves that no element refinement box and its corresponding element type were detected. In this case, the power grid wiring diagram recognition result list is recorded as empty, and the corresponding record is saved. If the recognition result is not empty, it proves that the element refinement box and its corresponding element type were detected. In this case, the element refinement box and its corresponding element type are recorded in the recognition result list, and the corresponding record is saved. The process of constructing composite elements for the power grid wiring diagram ends.
[0100] The above steps, by determining whether the identification result is empty and recording it accordingly, can completely retain the identification data of the power grid wiring diagram. This not only ensures the traceability of the results but also provides standardized result data for subsequent scenarios such as automated modeling of power grid wiring diagrams and equipment status awareness, avoiding the impact of missing result records on subsequent applications.
[0101] The method for constructing composite primitives in power grid wiring diagrams provided in this application is based on a deep learning algorithm. First, primitives and connections are segmented from the background using a primitive connection segmentation model. Then, basic primitive detection models are used to detect the bounding boxes and types of basic primitives. Next, the segmentation mask image and the basic primitive detection results are fused to generate refined basic primitive bounding boxes and types. Finally, a composite primitive construction algorithm is used to construct refined composite primitive bounding boxes and types, thereby effectively improving the recognition level of composite primitives.
[0102] Example 2
[0103] like Figure 16 The diagram shown is a structural schematic of a power grid wiring diagram composite element construction system 1600 according to an embodiment of this application. The system includes:
[0104] The cropping module 1610 is used to acquire the power grid wiring diagram and crop the power grid wiring diagram by sliding window according to the first preset resolution and the second preset resolution to obtain the first sub-image set and the second sub-image set respectively.
[0105] The segmentation module 1620 is used to assign weights to each sliding window sub-image in the first sub-image set to obtain multiple sliding window weight sub-images. The first sub-image set is input into the primitive connection segmentation model to obtain multiple primitive connection segmentation mask sub-images. Using each sliding window weight sub-image and each primitive connection segmentation mask image, a primitive connection segmentation mask image is obtained.
[0106] The detection module 1630 is used to input the second sub-image set into the basic primitive detection model to obtain multiple initial basic primitive rectangles and their corresponding basic primitive types, and to map and filter each initial basic primitive rectangle to obtain multiple basic primitive rectangles and their corresponding basic primitive types.
[0107] The refining module 1640 is configured to project each basic primitive rectangle frame and the corresponding basic primitive type to the primitive line segmentation mask image, search the primitive line mask region within each basic primitive rectangle frame, and obtain a plurality of basic primitive refinement frames and the corresponding basic primitive types;
[0108] The constructing module 1650 is configured to construct each basic primitive refinement frame and the corresponding basic primitive type by using a composite primitive construction algorithm, obtain a composite primitive refinement frame and the corresponding composite primitive type, delete the basic primitive refinement frame inside the composite primitive refinement frame to obtain a remaining basic primitive refinement frame, merge the composite primitive refinement frame and the corresponding composite primitive type with the remaining basic primitive refinement frame and the corresponding basic primitive type to obtain a primitive refinement frame and the corresponding primitive type, and determine the primitive refinement frame and the corresponding primitive type as the power grid wiring diagram recognition result.
[0109] The recording module 1660 is configured to determine whether the power grid wiring diagram recognition result is empty, record the power grid wiring diagram recognition result list as empty if the power grid wiring diagram recognition result is empty, and record the primitive refinement frame and the corresponding primitive type to the recognition result list and save if the power grid wiring diagram recognition result is not empty.
[0110] The power grid wiring diagram composite primitive construction system provided by the embodiment can implement each process of the power grid wiring diagram composite primitive construction method corresponding to the embodiment 1, and achieve the same technical effects. To avoid repetition, details are not described herein.
[0111] In the embodiment of the present disclosure, a computer device is also provided, which includes a memory and a processor. The memory stores a computer program, and the processor implements the steps of the power grid wiring diagram composite primitive construction method described in the embodiment 1 when executing the computer program.
[0112] In the embodiment of the present disclosure, a computer readable storage medium is also provided, which stores a computer program. The computer program is executed by a processor to implement the steps of the power grid wiring diagram composite primitive construction method described in the embodiment 1.
[0113] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or replacements within the technical range disclosed by the present application, which should be covered within the protection scope of the present application.
Claims
1. A method of constructing a composite graph element for a power grid diagram, characterized by, The method comprises: acquiring a power grid wiring diagram, and performing sliding window cutting on the power grid wiring diagram according to a first preset resolution and a second preset resolution respectively to obtain a first sub-image set and a second sub-image set respectively; assigning a weight to each sliding window sub-image in the first sub-image set to obtain a plurality of sliding window weight sub-images, inputting the first sub-image set into a graph element connection segmentation model to obtain a plurality of graph element connection segmentation mask sub-images, and using each sliding window weight sub-image and each graph element connection segmentation mask sub-image to obtain a graph element connection segmentation mask image; inputting the second sub-image set into a basic graph element detection model to obtain a plurality of initial basic graph element rectangular frames and corresponding basic graph element types, performing mapping and filtering on each initial basic graph element rectangular frame to obtain a plurality of basic graph element rectangular frames and corresponding basic graph element types; projecting each basic graph element rectangular frame and the corresponding basic graph element type onto the graph element connection segmentation mask image, searching for a graph element connection mask region within a range of each basic graph element rectangular frame, and obtaining a plurality of basic graph element refined frames and corresponding basic graph element types; using a composite graph element construction algorithm to construct each basic graph element refined frame and the corresponding basic graph element type to obtain a composite graph element refined frame and a corresponding composite graph element type, deleting a basic graph element refined frame inside the composite graph element refined frame to obtain a remaining basic graph element refined frame, merging the composite graph element refined frame and the corresponding composite graph element type with the remaining basic graph element refined frame and the corresponding basic graph element type to obtain a graph element refined frame and a corresponding graph element type, and determining the graph element refined frame and the corresponding graph element type as a power grid wiring diagram recognition result; determining whether the power grid wiring diagram recognition result is empty, recording the recognition result list of the power grid wiring diagram as empty if the power grid wiring diagram recognition result is empty, and recording the graph element refined frame and the corresponding graph element type in the recognition result list and saving if the power grid wiring diagram recognition result is not empty; the composite graph element construction algorithm comprises: constructing a preset matrix, the preset matrix comprising a preset digital matrix and a preset type matrix, the preset digital matrix comprising a plurality of basic graph elements, and the preset type matrix comprising a plurality of basic graph element types, marking the basic graph elements in the preset digital matrix as component graph elements, marking the basic graph element types in the preset type matrix as component graph element types, marking a component graph element in a central region of the preset digital matrix as a reference graph element, and marking a component graph element type in the central region of the preset type matrix as a reference graph element type; counting numbers of the base primitive refinement boxes of all the base primitive refinement boxes, and screening the number of the base primitive refinement boxes corresponding to each component primitive type in the preset type matrix, selecting a component primitive type with the least number of base primitive refinement boxes as a starting primitive type, marking the position of the starting primitive type in the preset type matrix, and projecting the position of the starting primitive type into the preset digital matrix to obtain the position of a starting primitive; in the preset digital matrix, if the starting primitive is outside the reference primitive, determining a first digital search path from the starting primitive to the reference primitive, projecting the first digital search path into the preset type matrix to obtain a corresponding first type search path, marking component primitive types in the first type search path as node primitive types by traversing each refinement box of the starting primitive type, and searching according to the first type search path, if the refinement boxes of any two adjacent node primitive types in the first type search path both satisfy a preset composite primitive matching rule, determining a second digital search path diffusing outward from the reference primitive, projecting the second digital search path into the preset type matrix to obtain a corresponding second type search path, and searching according to the second type search path, if the refinement boxes of any two adjacent node primitive types in the second type search path both satisfy the preset composite primitive matching rule, merging the refinement box of the reference primitive type and the refinement boxes of each component primitive type to obtain a first merged box, and determining the first merged box as the composite primitive refinement box and determining the primitive type of the composite primitive refinement box as the composite primitive type; in the preset digital matrix, if the starting primitive coincides with the reference primitive, determining a third digital search path diffusing outward from the starting primitive, projecting the third digital search path into the preset type matrix to obtain a corresponding third type search path, marking component primitive types in the third type search path as node primitive types by traversing each refinement box of the starting primitive type, and searching according to the third type search path, if the refinement boxes of any two adjacent node primitive types in the third type search path both satisfy the preset composite primitive matching rule, merging the refinement box of the starting primitive type and the refinement boxes of each component primitive type to obtain a second merged box, and determining the second merged box as the composite primitive refinement box and determining the primitive type of the composite primitive refinement box as the composite primitive type.
2. The method of claim 1, wherein, the preset composite primitive matching rule is: counting the maximum distance between the center points of the refinement boxes of two adjacent component primitive types in the preset composite primitive sample set, and marking a preset multiple of the maximum distance as a spatial search range; Mark any two adjacent node graph element types in the current type search path as a former node graph element type and a latter node graph element type respectively, determine the position of the former node graph element type according to the current type search path, determine the direction from the former node graph element type to the latter node graph element type as a target search direction, and screen a plurality of candidate latter node graph element type refinement boxes in a spatial search range corresponding to the target search direction; If a latter node graph element type refinement box meeting a preset condition can be screened from the candidate latter node graph element type refinement boxes, it is determined that the former node graph element type refinement box and the latter node graph element type refinement box meeting the preset condition meet the preset composite graph element matching rule, wherein the preset condition is that the straight-line distance between the center point of the former node graph element type refinement box and the center point of the latter node graph element type refinement box is the shortest, and there is no other basic graph element refinement box in the connection region between the center point of the former node graph element type refinement box and the center point of the latter node graph element type refinement box.
3. The method of grid diagram composite meta-construct construction of claim 1, wherein, The obtaining of the graph element connection segmentation mask image from the sliding window weight sub-image and the graph element connection segmentation mask sub-image comprises: Mapping the coordinates of each sliding window weight sub-image and the coordinates of each graph element connection segmentation mask sub-image back to the coordinates of the power grid connection diagram respectively to obtain a plurality of mapped sliding window weight sub-images and a plurality of mapped graph element connection segmentation mask sub-images respectively; Performing normalization operation on each mapped sliding window weight sub-image and each mapped graph element connection segmentation mask sub-image by using a preset normalization formula to obtain the graph element connection segmentation mask image; The preset normalization formula is: wherein, a mask value of a primitive connected line segmentation mask image corresponding to a coordinate in the electrical network diagram, a mask value of a primitive connected line segmentation mask image corresponding to a coordinate in the electrical network diagram, a mask value of an m-th mapped primitive connected line segmentation mask sub-image corresponding to a coordinate defaulted to 0 if not present, a weight value of an m-th mapped sliding window weight sub-image corresponding to a coordinate in the electrical network diagram, a weight value of an m-th mapped sliding window weight sub-image corresponding to a coordinate defaulted to 0 if not present, a number of the sliding window sub-images.
4. The power grid diagram composite graph element construction method of claim 1, wherein, The mapping and filtering of each initial basic graph element rectangular box to obtain a plurality of basic graph element rectangular boxes and their corresponding basic graph element types comprises: Mapping the coordinates of each initial basic graph element rectangular box back to the coordinates of the power grid connection diagram to obtain a plurality of mapped basic graph element rectangular boxes and their corresponding basic graph element types; For each basic graph element type, a corresponding confidence threshold is set, the confidence of each mapped basic graph element rectangular box is obtained, and rectangular boxes with a confidence lower than the confidence threshold of the corresponding basic graph element type are filtered out to obtain a plurality of filtered basic graph element rectangular boxes and their corresponding basic graph element types; For each basic graph element type, a corresponding variation overlap rate threshold is set, the variation overlap rate of each filtered basic graph element rectangular box is calculated by using an area non-maximum suppression processing algorithm, and rectangular boxes with a variation overlap rate greater than the variation overlap rate threshold of the corresponding basic graph element type are deleted to obtain a plurality of basic graph element rectangular boxes and their corresponding basic graph element types.
5. The power grid diagram composite graph element construction method of claim 1, wherein, The base primitive detection model is based on an improved YOLO12 detection algorithm, the improved YOLO12 detection algorithm includes a backbone network, a feature pyramid network and a decoupling head, the feature pyramid network includes a first spatial attention module, a second spatial attention module, a first convolution module, a second convolution module, a first efficient attention module, a second efficient attention module and a third efficient attention module, the decoupling head includes a first classification regression module, a second classification regression module and a third classification regression module, the second sub-image set is input into the base primitive detection model, a plurality of initial base primitive rectangular frames and corresponding base primitive types thereof are obtained, comprising: The third layer feature map and the second layer feature map are input into the first spatial attention module to obtain a first spatial attention feature map, and the first spatial attention feature map and the second layer feature map are concatenated to obtain a first fusion feature map; The first fusion feature map and the first layer feature map are input into the second spatial attention module to obtain a second spatial attention feature map, and the second spatial attention feature map and the first layer feature map are concatenated to obtain a second fusion feature map; The second fusion feature map is input into the first convolution module to obtain a first feature map, and the first feature map and the first fusion feature map are concatenated to obtain a third fusion feature map; The third fusion feature map is input into the second convolution module to obtain a second feature map, and the second feature map and the third layer feature map are concatenated to obtain a fourth fusion feature map; The second fusion feature map is input into the first efficient attention module to obtain a first efficient attention feature map, the third fusion feature map is input into the second efficient attention module to obtain a second efficient attention feature map, and the fourth fusion feature map is input into the third efficient attention module to obtain a third efficient attention feature map; The first efficient attention feature map, the second efficient attention feature map and the third efficient attention feature map are input into the first classification regression module, the second classification regression module and the third classification regression module respectively to obtain a plurality of initial base primitive rectangular frames and corresponding base primitive types of the second sub-image set. The third layer feature map and the second layer feature map are input into the first spatial attention module to obtain a first spatial attention feature map, comprising:
6. The method of grid diagram composite meta-construct construction of claim 5, wherein, The second layer feature map is respectively subjected to channel maximum pooling and channel average pooling to obtain a maximum value feature map and an average value feature map, the maximum value feature map and the average value feature map are subjected to channel splicing to obtain a two-channel feature map, and the two-channel feature map is subjected to 1*1 convolution to obtain a single-channel feature map, and the single-channel feature map is subjected to a Relu activation function to obtain a spatial weighting feature map; The third layer feature map is sequentially subjected to 1*1 convolution and up-sampling to obtain an up-sampled feature map; The up-sampling feature map is multiplied with the spatial weighted feature map to obtain the first spatial attention feature map; The second fusion feature map is input into the first efficient attention module to obtain a first efficient attention feature map, including: According to the number of channels of the second fusion feature map, the second fusion feature map is evenly divided into two fusion feature subgraphs, spatial maximum pooling and spatial average pooling are respectively performed on the two fusion feature subgraphs, and channel splicing is performed to obtain a channel feature map; The channel feature map is subjected to 1×1 convolution and passed through the Relu activation function to obtain a channel weighted feature map, and the second fusion feature map is multiplied with the channel weighted feature map to obtain a channel attention feature map; According to the number of channels of the channel attention feature map, the channel attention feature map is evenly divided into two channel attention feature subgraphs, channel maximum pooling and channel average pooling are respectively performed on the two channel attention feature subgraphs, and channel splicing is performed to obtain a spatial feature map; The spatial feature map is subjected to 1×1 convolution and passed through the Relu activation function to obtain a spatial weighted feature map, and the channel attention feature map is multiplied with the spatial weighted feature map to obtain the first efficient attention feature map.
7. A power grid diagram composite graphic element construction system, characterized by, The system comprises: The clipping module is configured to obtain a power grid wiring diagram, and perform sliding window clipping on the power grid wiring diagram according to a first preset resolution and a second preset resolution to obtain a first sub-image set and a second sub-image set respectively; The segmentation module is configured to assign a weight to each sliding window sub-image in the first sub-image set to obtain a plurality of sliding window weight sub-images, input the first sub-image set into a graph element connection segmentation model to obtain a plurality of graph element connection segmentation mask sub-images, and obtain a graph element connection segmentation mask image by using each sliding window weight sub-image and each graph element connection segmentation mask sub-image; The detection module is configured to input the second sub-image set into a basic graph element detection model to obtain a plurality of initial basic graph element rectangular frames and corresponding basic graph element types, and perform mapping and filtering on each initial basic graph element rectangular frame to obtain a plurality of basic graph element rectangular frames and corresponding basic graph element types; The refinement module is configured to project each basic graph element rectangular frame and the corresponding basic graph element type onto the graph element connection segmentation mask image, search for a graph element connection mask region within each basic graph element rectangular frame, and obtain a plurality of basic graph element refined frames and corresponding basic graph element types. The constructing module is configured to construct each of the basic graph element refinement frame and the corresponding basic graph element type by using a composite graph element construction algorithm, to obtain a composite graph element refinement frame and a corresponding composite graph element type, to delete the basic graph element refinement frame inside the composite graph element refinement frame to obtain a remaining basic graph element refinement frame, to merge the composite graph element refinement frame and the corresponding composite graph element type with the remaining basic graph element refinement frame and the corresponding basic graph element type to obtain a graph element refinement frame and a corresponding graph element type, and to determine the graph element refinement frame and the corresponding graph element type as the power grid wiring diagram recognition result; The recording module is configured to determine whether the power grid wiring diagram recognition result is empty, to record the recognition result list of the power grid wiring diagram as empty if the power grid wiring diagram recognition result is empty, and to record the graph element refinement frame and the corresponding graph element type in the recognition result list and save if the power grid wiring diagram recognition result is not empty; The constructing module is configured to construct each of the basic graph element refinement frame and the corresponding basic graph element type by using a composite graph element construction algorithm, to obtain a composite graph element refinement frame and a corresponding composite graph element type, to delete the basic graph element refinement frame inside the composite graph element refinement frame to obtain a remaining basic graph element refinement frame, to merge the composite graph element refinement frame and the corresponding composite graph element type with the remaining basic graph element refinement frame and the corresponding basic graph element type to obtain a graph element refinement frame and a corresponding graph element type, and to determine the graph element refinement frame and the corresponding graph element type as the power grid wiring diagram recognition result; The constructing module is configured to construct each of the basic graph element refinement frame and the corresponding basic graph element type by using a composite graph element construction algorithm, to obtain a composite graph element refinement frame and a corresponding composite graph element type, to delete the basic graph element refinement frame inside the composite graph element refinement frame to obtain a remaining basic graph element refinement frame, to merge the composite graph element refinement frame and the corresponding composite graph element type with the remaining basic graph element refinement frame and the corresponding basic graph element type to obtain a graph element refinement frame and a corresponding graph element type, and to determine the graph element refinement frame and the corresponding graph element type as the power grid wiring diagram recognition result; The constructing module is configured to construct each of the basic graph element refinement frame and the corresponding basic graph element type by using a composite graph element construction algorithm, to obtain a composite graph element refinement frame and a corresponding composite graph element type, to delete the basic graph element refinement frame inside the composite graph element refinement frame to obtain a remaining basic graph element refinement frame, to merge the composite graph element refinement frame and the corresponding composite graph element type with the remaining basic graph element refinement frame and the corresponding basic graph element type to obtain a graph element refinement frame and a corresponding graph element type, and to determine the graph element refinement frame and the corresponding graph element type as the power grid wiring diagram recognition result; If the starting point element is outside the reference element in the preset digital matrix, a first digital search path from the starting point element to the reference element is determined, the first digital search path is projected into the preset type matrix to obtain a corresponding first type search path, each refinement box of the starting point element type is traversed, the component element types in the first type search path are marked as node element types, and searching is performed according to the first type search path; if the refinement boxes of any two adjacent node element types in the first type search path both satisfy a preset composite element matching rule, a second digital search path diffusing outward from the reference element is determined, the second digital search path is projected into the preset type matrix to obtain a corresponding second type search path, and searching is performed according to the second type search path; if the refinement boxes of any two adjacent node element types in the second type search path both satisfy the preset composite element matching rule, the refinement box of the reference element type is combined with the refinement boxes of the component element types to obtain a first combined box, the first combined box is determined as the composite element refinement box, and the element type of the composite element refinement box is determined as the composite element type. If the starting point element coincides with the reference element in the preset digital matrix, a third digital search path diffusing outward from the starting point element is determined, the third digital search path is projected into the preset type matrix to obtain a corresponding third type search path, each refinement box of the starting point element type is traversed, the component element types in the third type search path are marked as node element types, and searching is performed according to the third type search path; if the refinement boxes of any two adjacent node element types in the third type search path both satisfy the preset composite element matching rule, the refinement box of the starting point element type is combined with the refinement boxes of the component element types to obtain a second combined box, the second combined box is determined as the composite element refinement box, and the element type of the composite element refinement box is determined as the composite element type.
8. A computer device, comprising: The computer readable storage medium stores a computer program, and the computer program is executed by the processor to realize the steps of the power grid wiring diagram composite element construction method in any one of claims 1-6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, and the computer program is executed by the processor to realize the steps of the power grid wiring diagram composite element construction method in any one of claims 1-6.
Citation Information
Patent Citations
Wiring diagram primitive identification method and device, electronic equipment and storage medium
CN119478592A
Unstructured file identification method based on primitive identification
CN120260065A