A power grid wiring diagram electrical element cascade detection method based on transformer and residual convolution

By proposing a cascaded detection method for electrical components in power grid wiring diagrams based on Transformer and residual convolution, the problem of electrical component identification in multi-scale and ultra-high resolution drawings in the prior art has been solved. This method achieves high-precision electrical component detection and standardized input, thereby improving the intelligent processing capability of power grid wiring diagrams.

CN118172334BActive Publication Date: 2026-06-23TONGJI UNIV

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
TONGJI UNIV
Filing Date
2024-03-20
Publication Date
2026-06-23

AI Technical Summary

Technical Problem

Existing methods for identifying electrical components in power grid wiring diagrams based on image processing and pattern matching have limitations when processing multi-scale and ultra-high resolution drawings, making it difficult to achieve high-precision detection of electrical components.

Method used

A method for cascaded detection of electrical components in power grid wiring diagrams based on Transformer and residual convolution is adopted. By preprocessing, data augmentation, Transformer-Lite module, fully convolutional Anchor Free detector and cascaded residual convolution module, combined with size-related loss function optimization model, the recognition accuracy of small-sized components is improved.

Benefits of technology

It effectively improves the identification accuracy of electrical components, reduces the consumption of computing resources, enhances the model's ability to fit small-sized electrical components, and realizes intelligent identification and standardized input of power grid wiring diagrams.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118172334B_ABST
    Figure CN118172334B_ABST
Patent Text Reader

Abstract

The application discloses a kind of based on Transformer and residual convolution's power grid wiring diagram electrical element cascade detection method.The present application is in view of the problems that existing element recognition method based on image processing and pattern matching has limitations in processing multiscale element and super-resolution drawing method, proposes based on Transformer and residual convolution's power grid wiring diagram electrical element cascade detection method.In target area detection stage, the global information extraction capability of Transformer model is used, and the sub-region containing electrical elements is obtained specifically.In target fine detection stage, a target fine detection network based on residual convolution is designed to realize region-based element recognition.The experimental results show that the cascade detection based on Transformer and residual convolution can significantly improve the accuracy of electrical element detection in power grid wiring diagram.
Need to check novelty before this filing date? Find Prior Art

Description

Technical fields:

[0001] This invention relates to the fields of smart grids and computer vision, and in particular to a method for detecting the cascaded electrical components in power grid wiring diagrams based on Transformer and residual convolution. Background technology:

[0002] With the rapid development of my country's national economy, the scale and complexity of the power grid are also constantly increasing. To ensure the safe and stable operation of large power grids and achieve globally optimized economic dispatch, the State Grid Corporation of China has jointly developed a smart grid dispatch and control system. This system uses CIM format files based on a general information model to describe power grid diagrams and electrical equipment, enabling visual monitoring of the power grid's safety status. However, dispatch and maintenance personnel need to manually draw CIM power grid diagrams and electrical equipment based on the original power grid wiring diagram design. Due to the complexity of the graphic styles and the large number of equipment types, maintenance work is cumbersome and prone to problems such as missing attributes, incorrect associations, and loose connections. Against this backdrop, there is an urgent need to develop methods for intelligent identification, modification, correction, and standardized input of power grid wiring diagrams.

[0003] In recent years, with the development of artificial intelligence technology, more and more research has applied it to various industrial fields. Object detection based on deep learning has become a potential pathway for the automation and intelligentization of power grid wiring diagram operations. Object detection technology, based on the geometric and statistical features of targets, can locate and identify specific targets in input images and output the target's position, size, and confidence level. Applying object detection technology to engineering design drawings can achieve multiple optimizations in time consumption, labor costs, and work quality, thereby enabling intelligent identification, modification, correction, and standardized input of power grid wiring diagrams.

[0004] The closest existing technology and its evaluation: Seong et al. (Seong DS, Choi YK, Kim HS, et al. An algorithm for optimal isomorphism between two random graphs[J]. Patternrecognition letters, 1994, 15(4): 321-327.) performed global feature information statistics on power grid wiring diagrams through linear scanning, extracted the feature information of electrical components in the wiring diagrams, and thus realized the identification of electrical components. Llados et al. (Llados J, Marti E, Villanueva J J. Symbol recognition by error-tolerant subgraph matching between region adjacency graphs[J]. IEEE Transactions on Pattern Analysis and Machine Intelligence, 2001, 23(10): 1137-1143.) proposed an image vectorization algorithm, which realized full pixel-level recognition based on the natural features of elements in the image in an object-oriented manner. However, this method has difficulties in recognizing small primitives or components, and the processing methods for different types of graphics cannot be unified. Fahmy et al. (Fahmy H, Blostein DA graph grammar programming style for recognition of music notation[J].Machine Vision and Applications,1993,6(2):83-99.) proposed a method for recognizing hand-drawn electronic circuit diagrams. This method first detects and classifies each component present in the hand-drawn circuit diagram. In order to achieve the purpose of component recognition, a feature vector is constructed by combining local binary patterns and statistical features based on pixel density, and a support vector machine classifier

[13] is used to classify the components. Finally, it is tested on 100 hand-drawn circuit diagrams of different complexity and types. The accuracy of this method reaches more than 99%, which has a good detection effect.Santosh et al. (Santosh KC, Lamiroy B, Wendling L. Integrating vocabulary clustering with spatial relations for symbol recognition[J]. International Journal on Document Analysis and Recognition(IJDAR),2014,17(1):61-78.) first used the Faster R-CNN object detection method to detect and identify electrical components. Then, they used image processing methods to remove the identified electrical components from the wiring diagram. Next, they extracted all the connecting lines in the drawing. Finally, they designed a topology relationship detection algorithm to perform correlation calculations on the location information of electrical components and the information of connecting lines to obtain the topological structure relationship of the drawing. The model was trained using the actual power grid wiring diagram dataset used by the State Grid Corporation of China. At the same time, tests and related experiments were completed to verify the generalization ability of the proposed algorithm to identify electrical components. Santosh et al. (Santosh KC, LAMIROY B, WENDLING L. Integrating Vocabulary Clustering with Spatial Relations for Symbol Recognition[J]. International Journal on Document Analysis and Recognition(IJDAR), 2014, 17(1):61–78.) proposed a symbol detection method for power grid wiring diagrams based on a two-layer-block detection network to address the problem of low symbol detection accuracy in high-resolution power grid wiring diagrams. The authors first segmented the electrical power grid wiring diagram according to electrical logic, then identified 11 classic graphic elements, including disconnect switches and grounding switches. An Area-YOLOv5 network was designed for the key area detection layer of the target, and an Obj-YOLOv5 network was used to implement specific graphic element recognition. Finally, a key area detection accuracy of 98.5% and a symbol recognition accuracy of 96.3% were obtained, demonstrating that the proposed method can achieve high accuracy in recognizing and detecting graphic symbols in electrical power grid wiring diagrams. David et al. (David G. Lowe. Object recognition from local scale-invariant features. ICCV 1999.) used mathematical transformation formulas to fit the contours of symbolic images.Adam et al. (Adam VanEtten. You Only Look Twice: Rapid Multi-Scale Object Detection In Satellite Imagery arXiv:1805.09512 2018) addressed the challenges of large backgrounds and small, infrequent targets in drone aerial photography by proposing a lightweight target detection algorithm, YOLOX-IM, based on YOLOX-s. They used a slice-assisted inference algorithm and coordinate correction matrices to preprocess and augment the training set, improving the model's performance in detecting small targets. Then, a shallow feature map and an ultra-lightweight spatial attention module were introduced into the PAN (Packet Approach). Finally, good results were achieved on the VisDrone2019 dataset, and an accuracy of 96.14% was obtained on data from on-site traffic monitoring of the Lishui River in Tianjin. Summary of the Invention

[0005] The purpose of this invention is to provide a method for detecting cascaded electrical components in power grid wiring diagrams based on Transformer and residual convolution.

[0006] Key points of the technical solution:

[0007] This invention addresses the limitations of existing component recognition methods based on image processing and pattern matching in handling multi-scale components and ultra-high resolution drawings. It proposes a method for cascade detection of electrical components in power grid wiring diagrams based on Transformer and residual convolution.

[0008] The technical solution of this invention is as follows:

[0009] A method for detecting cascaded electrical components in a power grid wiring diagram based on Transformer and residual convolution, characterized by comprising the following steps:

[0010] Step 1: Preprocess the power grid wiring diagram dataset and expand the dataset based on image enhancement technology, dividing it into training and test sets according to the proportions;

[0011] Step 2: Construct and optimize a Transformer-based target region detection model;

[0012] Step 3: Construct and optimize a fine-grained target detection model based on residual convolution;

[0013] Step 4: Using the training dataset, train the electrical component cascade detection model built in Steps 2 and 3, and calculate the loss to adjust the model parameters;

[0014] Step 5: Repeat step 4 until the model converges, and save the optimal model file;

[0015] Step 6: Based on the cascaded detection model of electrical components obtained in Step 5, deploy the model and input the test power grid wiring diagram dataset to obtain the electrical component identification results and calculate the accuracy.

[0016] Furthermore, step 1:

[0017] Step 1.1 Perform grayscale, Gaussian smoothing, and sharpening on the power grid wiring diagram.

[0018] The task of classifying electrical components in a power grid wiring diagram mainly considers the geometric characteristics of the components; the grayscale conversion formula is as follows:

[0019] Gray=(76×R+150×G+30×B)>>8

[0020] Where: R represents the red channel in the image color channels, G represents the green channel in the image color channels, and B represents the blue channel in the color channels.

[0021] Step 1.2 Data augmentation of the power grid wiring diagram

[0022] Data augmentation methods include random rotation, horizontal mirroring, adding noise, and brightness adjustment, which modify the components in the wiring diagram based on the electrical component labeling information.

[0023] Step 2: Constructing an electrical component area detection network

[0024] Step 2.1 Design the Transformer-Lite module to extract global feature information from the power grid wiring diagram.

[0025] After the wiring diagram is processed through convolutional layers to obtain feature maps, Transformer-Lite first calculates the weights of the divided feature blocks and determines whether each feature block contains a pure white background. Background feature blocks that do not contain targets are merged and compressed to reduce the computational cost of the model. For feature blocks that may contain targets, normal token transformation is performed, followed by global self-attention calculation for all tokens.

[0026] Step 2.2 Design a fully convolutional Anchor-Free detector to output candidate regions for electrical components.

[0027] The region detection network employs an anchor-free detection mechanism, which obtains heatmaps from the feature map and determines the extent of the target region based on these heatmaps; the detector is a fully convolutional classification network.

[0028] Step 3: Constructing a fine-scale electrical component detection network

[0029] Step 3.1 Design a cascaded residual convolution module to extract features from candidate element regions.

[0030] First, the input feature map undergoes a 7x7 involution operation, and then the output is divided into four branches. Three of these branches are processed through a 3x3 involution and a 1x1 convolution, respectively. During this process, the input of the second branch is fused with the involution output of the first branch, equivalent to a 5x5 involution operation. Similarly, the third branch fuses the involution output of the second branch, equivalent to a 7x7 involution operation. Finally, the outputs of the three branches after the above operations are concatenated with the 7x7 involution output. Then, a 1x1 convolution is introduced to adjust the output channels.

[0031] Step 3.2 Design a feature mixing module to fuse the features extracted in steps 2.1 and 3.1 respectively.

[0032] Before feature fusion, it is necessary to first map the output sub-region of step 2.2 back to the feature map of the corresponding layer, and then crop the feature map of the current layer to ensure that the feature map from step 2.1 and the feature map of the corresponding layer in step 3.1 are feature information of the same target region.

[0033] The channel shuffle method was used to recombine the channels of the two feature maps to be fused. Then, 3*3 convolution and activation function were used for feature extraction and nonlinearization. Finally, 1*1 convolution was used for channel adjustment to obtain the fused output.

[0034] The stitched feature maps are divided into two groups according to channels. Since the size of the component regions output in step 2.2 is not fixed, it is assumed here that the size of each group of feature maps is W. i *H i *32, where i represents the i-th element region in the output. Each group is convolved with 16 3*3*32 convolutional kernels, resulting in two groups (the size of the output feature maps is kept unchanged through padding), with a scale of W. i *H i *16 feature maps. Next, rearrange the two sets of feature maps by channel. Place channel 1 of the first set in the first layer, channel 1 of the second set in the second layer, channel 2 of the first set in the third layer, channel 2 of the second set in the fourth layer, and so on.

[0035] Step 3.3 Design the loss function for the cascaded detection model of electrical components for model parameter optimization.

[0036] Introduce a loss parameter related to component size into the loss function to increase the weight of loss for small-sized electrical components during training.

[0037] First, the target area is normalized using the normalization function g(x). Then, the normalized area value is subtracted from the normalized value using an adjustable parameter k. The resulting loss balance factor is negatively correlated with the predicted box area. The loss balance factor value corresponding to the predicted boxes of large and medium targets is generally less than 1, while the loss balance factor value for small targets is greater than 1. The loss parameter is multiplied by the original loss, increasing the loss weight for small targets and keeping the loss weight for large and medium targets unchanged or decreasing it. This achieves the goal of balancing the loss. Finally, the formula for calculating the loss balance factor is expressed as:

[0038]

[0039] Where k is an adjustable parameter, x is the area of ​​the candidate box, and Xmax is the maximum area of ​​all candidate boxes.

[0040] Finally, by introducing a loss parameter into the classification loss and bounding box regression loss, the total training loss L of the automatic electrical component identification model is calculated. component Represented as:

[0041]

[0042] Where N pos This indicates the total number of candidate boxes. This represents the loss parameter for the i-th candidate box. This represents the classification loss of the candidate boxes. This represents the regression loss of the candidate boxes.

[0043] By adopting the above solution, the beneficial effects of the present invention are:

[0044] 1. This invention proposes a method for detecting electrical component areas in power grid wiring diagrams based on Transformer, which overcomes the information loss problem caused by directly downsampling the original wiring diagram to a predetermined size. Furthermore, it performs parameter dimensionality reduction on the Transformer module, and the lightweight network can effectively reduce the consumption of computer resources during algorithm implementation.

[0045] 2. This invention proposes a method for detecting electrical components in power grid wiring diagrams based on cascaded residual convolution. By utilizing the detection results of electrical component regions, the method extracts feature information of electrical components at different levels based on residual convolutional networks and downsampling operations. At the same time, the method fuses the relevant regional feature information extracted by Transformer, which can effectively improve the model's ability to fit small-sized electrical components during training, thereby improving the final recognition accuracy of electrical components. Attached Figure Description

[0046] Figure 1This is a basic flowchart of the present invention, which is a method for cascading detection of electrical components in power grid wiring diagrams based on Transformer and residual convolution.

[0047] Figure 2 This invention relates to the design of an electrical component area detection network structure.

[0048] Figure 3 yes Figure 2 Design of Transformer-Lite network.

[0049] Figure 4 This invention relates to a fine-tuning network structure design for electrical components.

[0050] Figure 5 yes Figure 4 Design of a cascaded residual convolution module.

[0051] Figure 6 This is the detection result of the automatic identification model for electrical components of this invention.

[0052] Figure 7 This is a comparison of the precision and recall of the present invention and existing mainstream technologies. Detailed Implementation

[0053] The following is in conjunction with the appendix Figure 1 The flowchart shown further illustrates the invention. The dataset used in the experiment comes from power grid wiring diagrams used in the actual State Grid dispatching system, containing 112 diagrams from different power grid sites. Each diagram contains an average of about 80 different electrical components, mainly including circuit breakers, generators, capacitors, reactors, transformers, etc. The structure of the automatic identification model for electrical components in power grid wiring diagrams is attached. Figure 2 As shown. Figure 6 The practical recognition effect of the method of the present invention on power grid wiring diagrams is demonstrated. Experimental results show that the recognition method can effectively improve the judgment accuracy. The present invention also conducted additional comparative experiments with existing mainstream recognition technologies, such as... Figure 7 As shown, the comparison results of the present invention and the prior art on the State Grid wiring diagram test set are presented. The experimental results show that the present invention has the highest accuracy in this test data.

[0054] This invention proposes a method for detecting cascaded electrical components in power grid wiring diagrams based on Transformer and residual convolution.

[0055] Step 1: Preprocess the power grid wiring diagram dataset and expand it using image enhancement techniques, dividing it into training and test sets according to a set ratio. Specifically, this includes:

[0056] Step 1.1 Perform grayscale conversion, Gaussian smoothing, and sharpening on the power grid wiring diagram.

[0057] The task of classifying electrical components in power grid wiring diagrams primarily considers the geometric characteristics of the components. Since component color is not helpful for classification, converting the wiring diagram to grayscale reduces the number of pixels in the drawing and decreases the number of model parameters. The grayscale conversion formula used in this invention is as follows:

[0058] Gray=(76×R+150×G+30×B)>>8

[0059] Where: R represents the red channel in the image color channels, G represents the green channel in the image color channels, and B represents the blue channel in the color channels.

[0060] After the drawing is converted to grayscale, a Gaussian filter is used for smoothing to remove useless details and filter out noise, thereby improving the accuracy and efficiency of subsequent detection. Since Gaussian filtering blurs the image and weakens edge textures, the image is then sharpened to improve the distinction between components and the background, making the edge information of connecting lines more prominent.

[0061] Step 1.2 Data augmentation of the power grid wiring diagram

[0062] Because many power grid diagrams cannot be publicly released in real-world scenarios, the number of collected power grid wiring diagrams is limited, while a large dataset is required during model training. Therefore, data augmentation is necessary.

[0063] The methods used in this invention include random rotation, horizontal mirroring, adding noise, and brightness adjustment. Based on the electrical component labeling information obtained from the above steps, the components in the wiring diagram are modified.

[0064] The formula for calculating random rotation is as follows:

[0065]

[0066] Where θ represents the degree of rotation of the element, and (i,j) represents the original position coordinates of the element.

[0067] The formula for calculating horizontal mirror image is as follows:

[0068]

[0069] Where N represents the width of the original image, and (i,j) represents the original position coordinates of the element.

[0070] The formula for calculating brightness adjustment is as follows:

[0071] R = R0 + d * 255

[0072] Where d represents the brightness transformation coefficient, which is a randomly generated real number conforming to a uniform distribution, and R0 is the initial RGB value of a pixel in the image.

[0073] Step 2: Construct an electrical component area detection network

[0074] The component area detection network structure is shown in the attached figure. Figure 2 As shown

[0075] First, a brief overview:

[0076] The power grid wiring diagram from step 1 is input into the network. After convolution, a feature map is obtained, which is then fed into the Transformer module for global feature extraction. The Transformer module can capture long-range dependencies in the input feature map. Next, downsampling convolution is used to downsample the feature map, increasing the receptive field. Then, feature maps of different scales obtained through four convolutions, Transformer operations, and downsampling are fused. Finally, a fully convolutional anchor-free detector outputs a binary map indicating whether electrical components are present, based on the feature map information. Finally, connected component analysis is performed on the binary map to obtain the regions that may contain electrical components.

[0077] Furthermore, the component region detection network structure is described in detail:

[0078] Step 2.1 Design a Transformer-Lite network to extract global feature information of the power grid wiring diagram.

[0079] Unlike the standard Vision Transformer network, the Transformer-Lite network of this invention achieves a lightweight version of the Transformer based on the characteristics of power grid wiring diagram data. After the wiring diagram is processed through convolutional layers to obtain feature maps, the Transformer-Lite network first calculates the weights of the divided feature blocks and determines whether each feature block contains a pure white background. Background feature blocks that do not contain targets are merged and compressed to reduce the computational cost of the model. For feature blocks that may contain targets, normal token transformation is performed, followed by global self-attention calculation for all tokens. This operation mainly reduces computational cost by compressing background region features, and the compression of background features also reduces their interference with positive sample features.

[0080] For the detailed calculation process of the Transformer-Lite network, please refer to the appendix. Figure 3The network is primarily used to process the input feature map to detect component regions in the power grid wiring diagram. First, the input feature map is roughly divided into six identical feature blocks. For each feature block, a 5x5 convolution operation is used to obtain corresponding spatial weights. If the feature block contains components, the corresponding weight is not 0; if the feature block does not contain components (i.e., the background area is white), the corresponding weight is 0. This process yields the weights of six feature blocks. The two foreground feature blocks with non-zero spatial weights are retained and converted into corresponding token representations; the four background feature blocks are compressed to obtain one background feature block, which is then converted into a token representation. After obtaining two foreground tokens and one background token, they are input together into a multi-head self-attention mechanism to further extract global feature information. This process utilizes the Transformer's self-attention mechanism to capture the relationships between features, thereby achieving global feature extraction. The calculation formula for the self-attention mechanism is shown below:

[0081]

[0082] Where Q represents the target matrix, K represents the key feature matrix, and V represents the original feature matrix. This is a normalization factor introduced in the self-attention mechanism, which ensures gradient stability during training. Here, d... k Given a Q and K vector dimension, softmax represents the normalization function and outputs similarity weights.

[0083] Step 2.2 Design a fully convolutional Anchor-Free detector to output candidate regions for electrical components.

[0084] The region detection network employs an anchor-free detection mechanism, avoiding the use of traditional sliding window detection. This method improves detection efficiency by acquiring heatmaps in the feature map and determining the range of the target region based on these heatmaps. The detector is essentially a fully convolutional classification network. It performs a series of dilated convolution operations on the feature map, specifically including three convolutions with a 3x3 kernel, 512 channels, and a dilation factor of 2; one convolution with a 3x3 kernel, 256 channels, and a dilation factor of 4; one convolution with a 3x3 kernel, 128 channels, and a dilation factor of 4; and one convolution with a 3x3 kernel, 64 channels, and a dilation factor of 5. Dilated convolutions expand the receptive field of the convolution operation, thereby better capturing the spatial contextual information of the target.

[0085] Finally, a 1×1 convolution kernel is used for channel adjustment to obtain the binary image information output by the model, where high values ​​indicate the presence of electrical components in the current region. Next, image processing methods are used to perform connected component analysis on the binarized binary image, with each connected component representing a candidate region containing electrical components. This design avoids the problem of setting a large number of anchor points required in traditional object detection algorithms, reduces the imbalance between positive and negative samples, and improves detection efficiency.

[0086] Step 3: Construct a fine-grained testing network for electrical components

[0087] Detailed design of the fine detection network is attached. Figure 4 As shown.

[0088] First, a brief overview:

[0089] The network input consists of multiple candidate regions containing electrical components, output from step 2. Taking one component region as an example, firstly, the region undergoes five cascaded residual modules and downsampling convolution operations to extract features from the input region, resulting in a feature map. Secondly, through region location mapping, the feature map extracted in step 2 based on the Transformer is cropped to ensure that the feature map from step 2 and the feature map from step 3 originate from the same component region. The two feature maps are then fused using a mixing module to obtain richer feature information. Finally, the fused feature map is subjected to a 1*1 convolution operation for channel adjustment, thereby obtaining the component location information, confidence level, and category information of the candidate region. A loss function is then designed to train the network model, and the parameters are adjusted.

[0090] Further details:

[0091] Step 3.1 Design a cascaded residual convolution module to extract features from candidate element regions.

[0092] The design of cascaded residual convolution modules is as follows: Figure 5 As shown. Since the features extracted in step 2 are for global information, many detailed features of components are lost. Therefore, feature extraction needs to be performed again for specific component candidate regions. This invention performs cascaded convolutional operations on the residual module to ensure that the module can obtain a rich receptive field, thereby extracting electrical component features at different scales. To avoid a sharp increase in network parameters, a combination of involution and convolution is used to simplify the network parameters. The specific calculation process is as follows.

[0093] First, the input feature map undergoes a 7x7 involution operation, and then the output is divided into four branches: three of these branches undergo a 3x3 involution and a 1x1 convolution, respectively. During this process, the input of the second branch is fused with the output of the first branch's involution, equivalent to a 5x5 involution operation; similarly, the third branch fuses the output of the second branch's involution, equivalent to a 7x7 involution operation. This is equivalent to a large convolutional kernel while maintaining a small number of parameters. Finally, the outputs of the three branches after the above operations are concatenated with the output of the 7x7 involution, further fusing feature information and improving the model's backpropagation ability, thereby reducing the risk of gradient vanishing to some extent. Then, a 1x1 convolution is introduced to adjust the output channels.

[0094] Step 3.2 Design a feature blending module to fuse the features extracted in steps 2.1 and 3.1 respectively.

[0095] During the feature information fusion process in step 2.1, since the output of step 2.1 is the feature of the entire image, while the output of step 3.1 is the feature of the segmented sub-image, in order to ensure the accuracy of feature fusion, before feature fusion, it is necessary to first map the sub-regions output in step 2.2 to the feature maps of the corresponding layers, and then crop the feature maps of the current layer, so as to ensure that the feature maps from step 2.1 and the feature maps of the corresponding layers in step 3.1 are feature information from the same target region.

[0096] Since the feature maps come from two different networks, they need to be fully fused to allow for information flow and improve their expressive power. A channel shuffle technique was used to recombine the channels of the two feature maps to be fused. Then, 3x3 convolutions and activation functions were used for feature extraction and non-linearization. Finally, 1x1 convolutions were used for channel adjustment to obtain the fused output.

[0097] The stitched feature maps are divided into two groups by channel. Since the component region size output in step 2.2 is not fixed, we take a feature map size of 256*256*32 as an example. Each group is convolved with 16 3*3*32 convolutional kernels, resulting in two groups of feature maps with a scale of 256*256*16 (the output feature map size is kept constant through padding). Next, the two groups of feature maps are rearranged by channel. Channel 1 of the first group is placed in the first layer, channel 1 of the second group is placed in the second layer, channel 2 of the first group is placed in the third layer, channel 2 of the second group is placed in the fourth layer, and so on.

[0098] Step 3.3 Design the loss function for the cascaded detection model of electrical components for model parameter optimization.

[0099] In power grid wiring diagram datasets, there are numerous types of electrical components with significant size variations. Training with the Focal loss function reveals poor recognition accuracy for small-sized components. This invention considers the area factor of electrical components and introduces a loss parameter related to component size into the loss function. This increases the weight of the loss for small-sized components during training, thereby enhancing the model's recognition efficiency for these components.

[0100] First, the target area is normalized using the normalization function g(x). Then, the normalized area value is subtracted from the normalized value using an adjustable parameter k. The resulting loss balance factor is negatively correlated with the predicted box area. The loss balance factor value corresponding to the predicted boxes of large and medium targets is generally less than 1, while the loss balance factor value for small targets is generally greater than 1. The loss parameter is multiplied by the original loss, increasing the loss weight for small targets and keeping the loss weight for large and medium targets unchanged or decreasing it. This achieves the goal of balancing the loss. Finally, the formula for calculating the loss balance factor can be expressed as:

[0101]

[0102] Where k is an adjustable parameter, x is the area of ​​the candidate box, and Xmax is the maximum area of ​​all candidate boxes.

[0103] Finally, by introducing a loss parameter into the classification loss and bounding box regression loss, the total training loss L of the automatic electrical component identification model is calculated. component It can be represented as:

[0104]

[0105] Where N pos This indicates the total number of candidate boxes. This represents the loss parameter for the i-th candidate box. This represents the classification loss of the candidate boxes. This represents the regression loss of the candidate boxes.

[0106] Step 4: Using the training dataset, train the electrical component cascade detection model built in Steps 2 and 3, and calculate the loss to adjust the model parameters;

[0107] Step 5: Repeat step 4 until the model converges, and save the optimal model file.

[0108] Step 6: Based on the optimal electrical component cascade detection model obtained in Step 5, deploy the model and input the power grid wiring diagram test dataset to obtain the electrical component identification results and calculate the accuracy.

[0109] The detection visualization results of the automatic recognition model designed in this invention are shown in the appendix. Figure 6 As shown, a comparison of the accuracy and recall of this invention with current mainstream technologies is attached. Figure 7 As shown, LBP represents Local Binary Pattern, HOG represents Histogram of Oriented Gradient algorithm, and SSD represents Single Shot MultiBoxDetector algorithm. It is evident that this invention significantly improves both detection accuracy and recall.

[0110] The above description is merely a description of preferred embodiments of this application and is not intended to limit the scope of this application in any way. Any changes or modifications made by those skilled in the art based on the above-disclosed technical content should be considered as equivalent and valid embodiments and fall within the scope of protection of the technical solution of this application.

Claims

1. A method for cascading detection of electrical components in power grid wiring diagrams based on Transformer and residual convolution, characterized in that, Includes the following steps: Step 1: Preprocess the power grid wiring diagram dataset and expand the dataset using image enhancement techniques, dividing it into training and test sets according to the specified proportions; Step 2: Construct and optimize a Transformer-based target region detection model; Step 2 includes the following steps: Step 2.1 Design the Transformer-Lite module to extract global feature information from the power grid wiring diagram; After the wiring diagram is processed by the convolutional layer to obtain the feature map, Transformer-Lite first calculates the weights of the divided feature blocks and determines whether the feature block contains a pure white background. Background feature blocks that do not contain the target are merged and compressed to reduce the computational cost of the model. For feature blocks that may contain the target, normal token transformation is performed, and then global self-attention is calculated for all tokens. Step 2.2 Design a fully convolutional Anchor-Free detector to output candidate regions for electrical components; The region detection network employs an anchor-free detection mechanism, which acquires heatmaps from feature maps and determines the extent of the target region based on these heatmaps; the detector is a fully convolutional classification network. Step 3: Construct and optimize a fine-grained target detection model based on residual convolution; It includes a cascaded residual convolution module for feature extraction of candidate component regions; a feature mixing module designed to recombine the channels of two feature maps to be fused using a channel shuffle method; and a loss parameter related to component size introduced into the loss function to increase the loss weight of small-sized electrical components during training. Step 4: Using the training dataset, train the electrical component cascade detection model built in Steps 2 and 3, and calculate the loss to adjust the model parameters; Step 5: Repeat step 4 until the model converges, and save the optimal model file; Step 6: Based on the cascaded detection model of electrical components obtained in Step 5, deploy the model and input the test power grid wiring diagram dataset to obtain the electrical component identification results and calculate the accuracy.

2. The method for cascade detection of electrical components in power grid wiring diagrams based on Transformer and residual convolution as described in claim 1, characterized in that, Step 1 includes the following steps: Step 1.1 Perform grayscale conversion, Gaussian smoothing, and sharpening on the power grid wiring diagram; The task of classifying electrical components in a power grid wiring diagram mainly considers the geometric characteristics of the components; the grayscale conversion formula is as follows: Gray=(76×R+150×G+30×B)>>8 Where: R represents the red channel in the image color channels, G represents the green channel in the image color channels, and B represents the blue channel in the color channels; Step 1.2 Data augmentation of the power grid wiring diagram Data augmentation methods include random rotation, horizontal mirroring, adding noise, and brightness adjustment; and changing the components in the wiring diagram based on the electrical component labeling information.

3. The method for cascade detection of electrical components in power grid wiring diagrams based on Transformer and residual convolution as described in claim 1, characterized in that, Step 3 includes the following steps: Step 3.1 Design a cascaded residual convolution module to extract features from candidate element regions; First, the input feature map undergoes a 7x7 involution operation, and then the output is divided into four branches. Three of these branches undergo a 3x3 involution and a 1x1 convolution, respectively. During this process, the input of the second branch is fused with the involution output of the first branch, equivalent to a 5x5 involution operation. The third branch, by fusing the involution output of the second branch, is equivalent to a 7x7 involution operation. Finally, the outputs of the three branches after the above operations are concatenated with the 7x7 involution output. Then, a 1x1 convolution is introduced to adjust the output channels. Step 3.2 Design a feature mixing module to fuse the features extracted in Step 2.1 and Step 3.1 respectively; Before feature fusion, it is necessary to first map the output sub-region of step 2.2 back to the feature map of the corresponding layer, and then crop the feature map of the current layer to ensure that the feature map from step 2.1 and the feature map of the corresponding layer in step 3.1 are feature information of the same target region. The channel shuffle method is used to recombine the channels of the two feature maps to be fused. Then, 3*3 convolution and activation function are used for feature extraction and non-linearization. Finally, 1*1 convolution is used for channel adjustment to obtain the fused output. The concatenated feature maps are divided into two groups according to channels. Assume the size of each group of feature maps is W. i *H i *32, where i represents the i-th element region of the output; each group is convolved with 16 3*3*32 convolution kernels, thus obtaining two groups with scale W. i *H i *16 feature maps; Next, rearrange the two sets of feature maps by channel, placing channel 1 of the first group in the first layer, channel 1 of the second group in the second layer, channel 2 of the first group in the third layer, channel 2 of the second group in the fourth layer, and so on. Step 3.3 Design the loss function for the cascaded detection model of electrical components for model parameter optimization; Introduce a loss parameter related to component size into the loss function to increase the weight of loss for small-sized electrical components during training; First, the target area is normalized using the normalization function g(x). Then, the normalized area value is subtracted from the normalized value using an adjustable parameter k. The resulting loss balance factor is negatively correlated with the predicted box area. The loss balance factor value corresponding to the predicted boxes of large and medium targets is generally less than 1, while the loss balance factor value for small targets is greater than 1. The loss parameter is multiplied by the original loss, increasing the loss weight for small targets and keeping the loss weight for large and medium targets unchanged or decreasing, thus achieving the purpose of balancing the loss. Finally, the formula for calculating the loss balance factor is expressed as: Where k is an adjustable parameter, x is the area of ​​the candidate box, and Xmax is the maximum area of ​​all candidate boxes; Finally, by introducing a loss parameter into the classification loss and bounding box regression loss, the total training loss of the automatic electrical component identification model is increased. Represented as: in This indicates the total number of candidate boxes. This represents the loss parameter for the i-th candidate box. This represents the classification loss of the candidate boxes. This represents the regression loss of the candidate boxes.