A causal perception power distribution network image defect detection method based on a vector attention mechanism
By constructing a causal perception distribution network image defect detection method based on vector attention mechanism, the problem of low detection accuracy in existing technologies is solved, and high-precision detection and intelligent identification of defects in complex distribution network equipment are achieved, thereby improving detection efficiency.
Patent Information
- Application Number
- CN202411471031.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-21
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2044-10-21
AI Technical Summary
Existing image defect detection models for power distribution networks have low detection accuracy in complex and ever-changing operating scenarios, especially in terms of insufficient detection capability for a few defect categories, resulting in poor detection performance.
A causal sensing image defect detection method based on vector attention mechanism is adopted. By constructing a backbone network, a vector attention module RWKV, a neck network, and a causal sensing head network, combined with image enhancement and causal sensing module, the long-tail distribution phenomenon is alleviated and the feature extraction and discrimination ability is improved.
It enables high-precision detection of defects in complex power distribution network equipment, improves the accuracy of intelligent judgment of the detection model and the efficiency of practical application, reduces subjective errors of manual detection, and reduces the workload of on-site inspection personnel.
Smart Images

Figure CN119540795B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of power distribution network image detection, in particular to a causal perception power distribution network image defect detection method based on a vector attention mechanism. BACKGROUND
[0002] The operation and maintenance of power distribution network equipment is complex and arduous. In order to promote the intelligent transformation of power distribution network equipment defect detection, improve the intelligent level of equipment management, and improve the quality and safety of power distribution network equipment, intelligent identification of power distribution network equipment defects based on image information collected by unmanned aerial vehicles can effectively identify defects in the deployment of power distribution network equipment. Due to the scattered and complex operation scenarios of power distribution networks, and the long-tail distribution of naturally collected power distribution network image defects, i.e. a small number of defect categories (head categories) have a large number of samples, while the majority of defect categories (tail categories) have very few samples. This long-tail distribution phenomenon leads to insufficient detection capability of the target detection model for tail categories during the training process, which seriously affects the detection performance of the target detection model in actual application. Therefore, developing a high-performance power distribution network image defect detection model to realize automatic detection and diagnosis of equipment defects can not only reduce subjective errors in manual detection, but also reduce the work burden of field inspection personnel and improve overall operation efficiency.
[0003] Power distribution network equipment defect detection mainly includes two categories of safety defects and functional defects. Safety defects include damage to grounding wires, whether the installation of lightning arresters is standardized, etc.; functional defects include conductor aging, broken insulators, equipment shell corrosion, etc. In the complex and variable power distribution network environment, existing target detection algorithms perform poorly when detecting defects, with low detection accuracy. Therefore, in order to more efficiently and accurately identify power distribution network equipment defects, a target detection model with superior performance and more accurate detection results needs to be developed based on the characteristics of power distribution network image defects.
[0004] Therefore, a high-performance target detection model is more suitable for complex power distribution network equipment distribution scenarios, but the detection performance of existing algorithms is generally poor. In order to improve the performance of the power distribution network defect detection model and improve the overall intelligent research and judgment accuracy in the power distribution network equipment defect detection process, it becomes a technical problem that needs to be solved. SUMMARY
[0005] The purpose of the present application is to solve the problem of low accuracy and poor effect of existing technology in response to power distribution network image defect detection scenarios, and to provide a causal perception power distribution network image defect detection method based on a vector attention mechanism to solve the above problems.
[0006] In order to achieve the above purpose, the technical solution of the present application is as follows:
[0007] A causal perception power distribution network image defect detection method based on a vector attention mechanism, comprising the following steps:
[0008] Obtaining power distribution network defect images: using mobile terminal devices such as drones to collect power distribution network defect images of different scenes and different types, forming a power distribution network defect image dataset;
[0009] Constructing a power distribution network defect image detection model: constructing a power distribution network defect image detection model based on a backbone network, a vector attention module RWKV, a neck network, and a causal perception head network;
[0010] Training of the power distribution network defect image detection model: training the power distribution network defect image detection model using the power distribution network defect image dataset;
[0011] Obtaining a power distribution network defect image to be detected: using mobile terminal devices such as drones to collect the power distribution network defect image to be detected;
[0012] Obtaining a power distribution network image defect detection result: inputting the power distribution network defect image to be detected into the trained power distribution network defect image detection model to obtain the defect detection result in the power distribution network image.
[0013] The step of obtaining the power distribution network defect images is:
[0014] Collecting defect images of power distribution network equipment in various scenes through mobile terminal devices such as drones, using LabelImg labeling software to mark the defect category targets of the collected power distribution network defect images, generating xml files containing target categories and positions, and forming a power distribution network defect image dataset.
[0015] The step of constructing the power distribution network defect image detection model comprises the following steps:
[0016] The power distribution network defect image detection model comprises a backbone network, a vector attention module RWKV, a feature fusion module, and a causal perception head network;
[0017] The backbone network is set as a basic feature extraction network of the image, is constructed based on a ConvNeXt network, and is composed of stacked multi-layer convolutional neural network layers, pooling layers, and activation function layers; the feature extraction network is used to extract feature maps of targets in the entire image; the input of the feature extraction network is an enhanced image of the power distribution network defect image collected by the mobile terminal device such as the drone; random cropping and color transformation are used as enhancement means to enhance the generalization performance of the network; and the output is the overall feature map of the power distribution network defect image after enhancement;
[0018] The vector attention module RWKV is set, and the RWKV is a new type of architecture combining the advantages of recurrent neural network RNN and self-attention architecture Transformer model, has superior parallel computing capability and time sequence processing capability, and provides a global receptive field for an image to better extract image features. In order to improve the accuracy of the power distribution network defect detection, the power distribution network defect image detection model introduces the vector attention module RWKV to strengthen the processing and enhancement of image features, which includes a spatial mixing module SMB and a channel mixing module CMB, and uses a residual connection between the modules to retain feature information. The spatial mixing module and the channel mixing module include a network regularization layer, an image block offset layer, a vector attention calculation layer, an activation function layer and the like.
[0019] The neck network is set. In order to detect defect category targets of different scales and fuse features, the neck network of the power distribution network defect image detection model adopts the FPN multi-scale structure, and the input of the neck network is the C2, C3, C4 and C5 layer feature maps of the vector attention module, and the output is the P2, P3, P4 and P5 layer fused multi-scale information.
[0020] The causal perception head network is set. In order to alleviate the long tail phenomenon presented by the distribution of the power distribution network defect image, the power distribution network defect image detection model introduces a head network based on causal perception as the RoI feature extraction layer of defect detection. According to the size of the target frame, the region features of the target corresponding position are extracted by mapping to any one of the P2, P3, P4 and P5 layers. The causal reasoning related operation is used to remove the confusion effect caused by the momentum interference of the optimizer in the power distribution network defect target detection, effectively alleviating the complex long tail phenomenon in the power distribution network image defect, and performing RoIAlign operation on the region features to obtain a uniform 7x7 size RoI feature map.
[0021] The training of the power distribution network defect image detection model includes the following steps:
[0022] The original defect image data set of the power distribution network is subjected to data enhancement, the image is randomly cropped and scaled to the original size, the image is subjected to color transformation, and random combination enhancement is performed during the training process;
[0023] The enhanced image is used as the input of the backbone network to extract image features, the overall feature map of the power distribution network image is extracted by using the feature extraction network, and the C2, C3, C4 and C5 layers of the ConvNeXt network are used to represent the features of each scale in the overall feature map.
[0024] The overall feature map output by the backbone network is taken as the input of the vector attention module RWKV. The input feature map first enters the spatial mixing module SMB. Assuming that the input feature map is F, the SMB module first flattens it into a sequence vector X, and the dimension of the vector X is TxC, where T=HxW, T represents the number of image blocks, H represents the feature height, W represents the feature width, and C represents the number of channels. The sequence vector X is first subjected to a regularization layer and then input to an image block shift layer for processing:
[0025] X s =Shift(LN(X))
[0026] Shift(X)=αC5(X)+βX
[0027] where LN represents the regularization operation, Shift represents the image block shift operation, X s represents the feature vector after regularization and shift processing, C5 represents a 5x5 convolution layer, and a and β are two learnable hyperparameters in the training process. X s is then input to three parallel linear mapping layers for vector mapping, generating three groups of feature vectors: R S , Receptance vector, used to represent past information and reduce forgetting of past information; K S , Key vector, and V S , Value vector, are used to calculate the attention mechanism:
[0028] R S =X S W R , K s =X S W K , V S =X S W V
[0029] where W R , W K , and W V represent the corresponding linear mapping layers. K S and V S will be input into the WKV attention calculation module, i.e., the Bi-WKV layer. In order to ensure that the image features have a global receptive field and better extract features, the Bi-WKV iterative operation is performed Q times, and the corresponding calculation formula is as follows:
[0030] wkv t =Bi-WKV(K s , V s ) t
[0031]
[0032] wkv = Bi-WKV (Q) (K s , V s )
[0033] where wkv t denotes the attention of the t-th image block unit, w and u denote the hyperparameters used in the attention mechanism operation process. k i and v i denote the spatial units obtained from K S and V S , respectively. The calculated wkv attention amount is then multiplied with the R S vector after the Sigmoid activation function, and summed with the original feature F using the residual connection operation, and the calculation formula is as follows:
[0034] O s = (σ(R s ) ⊙ wkv) W O + F
[0035] where O s denotes the output result of the spatial mixing module SMB, σ is the Sigmoid activation function, and W O is the corresponding feature weight.
[0036] The spatial mixing module SMB is used as the input of the channel mixing module CMB. Similar to the spatial mixing module, the input feature O s is processed by the regularization layer and the image block shift layer:
[0037] X c = Shift(LN(O S ))
[0038] where X c is the output result. Similar to the spatial mixing module, three groups of feature vectors R c , K c and V c can be obtained in the following way:
[0039] R c = X c W R , K c = X c W K , V c = γ(K c ) W V
[0040] where W R , WK , W V Similarly, represents the corresponding linear layer. γ represents the Relu activation function. c The results of need to be calculated according to K c vector, while the vector R c will still be processed through the Sigmoid activation function. The channel mixing module CMB also adopts the operation of residual connection, and adds the output results to the output of the SMB. The output features of the vector attention RWKV module are as follows:
[0041] F out = (σ (R c ) ⊙ V c ) W O + O s
[0042] After the feature processing by the vector attention module, the output features are divided into C2, C3, C4 and C5 layer feature maps, and are sent to the FPN module of the neck network for multi-scale feature fusion to obtain P2, P3, P4 and P5 layers of fused multi-scale information.
[0043] The output results of the neck network are input into the causal perception head network. The network module adds a causal perception module in the detection head to eliminate the long-tail distribution phenomenon of the complex power distribution network equipment defect target data. Since the naturally collected power distribution network equipment defects present a more serious long-tail phenomenon, that is, a small part of the head categories has a large number, while most of the tail categories have a small number, which seriously affects the performance of existing algorithms in the power distribution network image defect detection task. Specifically, the causal perception module implements causal intervention on the momentum of the optimizer, counts the average deviation of the features to the head during training, and removes the head deviation by using counterfactual calculation during the detection model inference, which better alleviates the long-tail phenomenon. The causal intervention formula is as follows:
[0044]
[0045] Where Y is the output calibration result, F represents the input feature, M represents the optimizer vector, y, f and m represent the values of Y, F and M respectively. After causal inference, the final counterfactual calibration formula used in the inference stage of the power distribution network defect detection model is as follows:
[0046]
[0047] Where τ represents a positive proportional factor of the adjustment probability value, G represents the number of class groups for dividing the channels of weights and features by applying the multi-head strategy, i represents the index value, w i represents the network parameters, f i represents the feature sample, and η represents a parameter for adjusting wi and f i The super parameter of w i || represents the weight of w i The modulus of w, T represents the temperature coefficient, and epsilon represents the super parameter for adjusting the weight of the second term, The head feature projection quantity in the training process is represented as Y, and Y represents the output after the final causal calibration.
[0048] The loss function of the detection task is:
[0049]
[0050] Wherein, lambda is the weight coefficient of the regression frame, L cls is the classification loss, L reg is the regression loss, and N is the total number of categories.
[0051] The classification loss L cls Uses cross-entropy loss, and the classification loss is represented as:
[0052]
[0053] Wherein, y i is the true value, is the model prediction value, and C is the number of categories.
[0054] The regression loss adopts a general Smooth L1 loss function, and the regression loss is represented as:
[0055]
[0056] The image defect detection method for power distribution network based on the vector attention mechanism of the application has stronger feature distinguishing and fusion ability, better processing ability for complex power distribution network equipment image defect distribution, higher identification precision, realizes accurate detection of power distribution network image defect category target, and specific description is as follows:
[0057] The application constructs a power distribution network image defect target detection model by image enhancement, extracts global features and enhances features through a vector attention module, so that the feature semantic expression ability of the power distribution network image defect target detection model is stronger, which is beneficial to the differentiation of various categories of power distribution network equipment defects; the application introduces a causal perception module in the head network, uses a causal intervention method to eliminate the confusion effect caused by the momentum of the optimizer and the bias of the head category in the network training process in view of the long-tail distribution phenomenon presented in complex power distribution network data, so that the power distribution network image defect target detection model can better handle the defect detection task in a complex scene; the causal perception power distribution network image defect detection method based on the vector attention mechanism is more convenient for the actual application of the power distribution network in a real scene, and improves the efficiency of checking power distribution network equipment defects. BRIEF DESCRIPTION OF DRAWINGS
[0058] Figure 1 A flowchart of a causal perception power distribution network image defect detection method based on a vector attention mechanism according to an embodiment of the application;
[0059] Figure 2 A power distribution network defect image detection model structure diagram according to the application;
[0060] Figure 3 A power distribution network defect image detection effect diagram using one of the methods according to the application;
[0061] Figure 4 A power distribution network defect image detection effect diagram using another method according to the application. DETAILED DESCRIPTION
[0062] In order to have a further understanding and understanding of the structural features and effects achieved by the application, the following detailed description is given in combination with preferred embodiments and drawings:
[0063] As shown in Figure 1 The causal perception power distribution network image defect detection method based on the vector attention mechanism according to the application includes the following steps:
[0064] First, acquire the power distribution network defect image: use mobile terminal devices such as drones to collect different scene and different type power distribution network defect images, and form a power distribution network defect image dataset.
[0065] Collect the power distribution network defect image through the mobile terminal device, use the LabelImg labeling software to mark the defect category target of the collected power distribution network defect image, generate an xml file containing the target category and position, and form a power distribution network defect image dataset.
[0066] Second, construct a power distribution network defect image detection model: as shown inFigure 2 As shown, the power distribution network defect image detection model is constructed based on the backbone network, the vector attention module RWKV, the feature fusion module, and the causal perception head network. The vector attention module RWKV strengthens the feature extraction of the model through the operation of the global attention mechanism, enhances the feature information of the image, and has good operation efficiency. The causal perception head network uses causal calculation and calibration to alleviate the long-tail distribution phenomenon in the complex power distribution network data, and at the same time improves the overall intelligent judgment accuracy of the power distribution network defect detection.
[0067] The specific steps are as follows:
[0068] (1) Set the power distribution network defect image detection model, including the backbone network, the vector attention module RWKV, the neck network, and the causal perception head network.
[0069] (2) Set the backbone network, set the backbone network as the basic feature extraction network of the image, and construct it based on the ConvNeXt network, which is composed of stacked multi-layer convolutional neural network layers, pooling layers, and activation function layers. The feature extraction network is used to extract the feature map of the target in the whole image. The input of the feature extraction network is the enhanced image of the power distribution network defect image collected by the mobile terminal device such as the unmanned aerial vehicle. Random cropping and color transformation are used as enhancement means to enhance the generalization performance of the network. The output is the overall feature map of the enhanced power distribution network defect image.
[0070] (3) Set the vector attention module RWKV. RWKV is a new architecture that combines the advantages of recurrent neural network RNN and self-attention architecture Transformer model, has superior parallel computing capability and time series processing capability, and provides a global receptive field for the image to better extract image features. In order to improve the accuracy of power distribution network defect detection, the power distribution network defect image detection model introduces the vector attention module RWKV to strengthen the processing and enhancement of image features, which includes a spatial mixing module SMB and a channel mixing module CMB, and uses residual connection between modules to preserve feature information. The spatial mixing module and the channel mixing module contain network regularization layers, image block offset layers, vector attention calculation layers, and activation function layers.
[0071] (4) Set the neck network. In order to detect defect category targets of different scales and fuse features, the neck network of the power distribution network defect image detection model adopts the FPN multi-scale structure. The input of the neck network is the C2, C3, C4, and C5 layer feature maps of the vector attention module, and the output is the P2, P3, P4, and P5 layer that fuses multi-scale information.
[0072] (5) Set up a causal perception head network, in order to alleviate the long tail phenomenon presented by the distribution of power distribution network defect image, a head network based on causal perception is introduced into the power distribution network defect image detection model as the RoI feature extraction layer of defect detection, according to the size of the target frame mapped to any one of P2, P3, P4 and P5 layers, the regional features corresponding to the target are extracted, the confusion effect caused by the momentum interference of the optimizer in the power distribution network defect target detection is removed by using the causal reasoning related operation, which effectively alleviates the complex long tail phenomenon in the power distribution network image defect, and the RoIAlign operation is performed on the regional features to obtain the uniform 7x7 size of RoI feature map.
[0073] Third step, training of power distribution network defect image detection model: using power distribution network defect image dataset to train power distribution network defect image detection model end to end.
[0074] The specific steps are as follows:
[0075] (1) Data enhancement is performed on the original defect image dataset of power distribution network, the image is randomly cropped and scaled to the original size, color transformation is performed on the image, and random combination enhancement is performed during training process;
[0076] The enhanced image is used as the input of the backbone network to extract the image features, the overall feature map of the power distribution network image is extracted by using the feature extraction network, and the C2, C3, C4 and C5 layers of ConvNeXt network are used to represent the features of each scale in the overall feature map;
[0077] (2) The overall feature map output by the backbone network is used as the input of the vector attention module RWKV, the input feature map first enters the spatial mixing module SMB. Set the input feature map as F, SMB module first flattens it into a sequence vector X, the dimension of vector X is TxC, where T=HxW, T represents the number of image blocks, H represents the feature height, W represents the feature width, and C represents the channel number. The sequence vector X will first pass through the regularization layer, and then input the image block offset layer for processing:
[0078] X s =Shift(LN(X))
[0079] Shift(X)=αC5(X)+βX
[0080] Where, LN represents the regularization operation, Shift represents the image block offset operation, X s represents the feature vector after regularization and offset processing, C5 represents the 5x5 convolution layer, and a and β are two learnable hyperparameters in the training process. Then X s is sent to three parallel linear mapping layers for vector mapping to generate three groups of feature vectors: RS , Receptance vector, used to represent past information, to reduce forgetting of past information; K S , Key vector, together with V S , Value vector, to perform attention mechanism calculation:
[0081] R S = X S W R , K s = X S W K , V S = X S W V
[0082] wherein W R , W K , W V represent the corresponding linear mapping layers respectively. K S and V S will be input into the WKV attention calculation module, i.e. Bi-WKV layer. In order to ensure that the image features have a global receptive field and better extract features, the Bi-WKV iterative operation is performed Q times, and the corresponding calculation formula is as follows:
[0083] wkv t = Bi-WKV(K s , V s ) t
[0084]
[0085] wkv=Bi-WKV (Q) (K s , V s )
[0086] wherein wkv t represents the attention of the tth image block unit, w and u represent the hyperparameters used in the attention mechanism operation process. k i and v i represent the i-th spatial unit obtained from K S and V S respectively. The calculated wkv attention amount is then multiplied by the R S vector after the Sigmoid activation function, and a residual connection operation is used to sum with the original feature F, and the calculation formula is as follows:
[0087] O s = (σ(R s )⊙wkv)W O +F
[0088] where O s represents the output of the spatial mixing module SMB, σ is a Sigmoid activation function, and W O is the corresponding feature weight.
[0089] The spatial mixing module SMB is input into the channel mixing module CMB. Similar to the spatial mixing module, the input feature O s is processed by the regularization layer and the image block shift layer:
[0090] X c = Shift(LN(O S ))
[0091] where X c is the output. Similar to the spatial mixing module, three groups of feature vectors R c , K c , and V c can be obtained as follows:
[0092] R c = X c W R , K c = X c W K , and V c = γ(K c )W V
[0093] where W R , W K , and W V also represent the corresponding linear layers. γ represents a Relu activation function. The result of V c is calculated based on the K c vector, and the R c vector is still processed by a Sigmoid activation function. The channel mixing module CMB also uses a residual connection operation to add the output result to the output of the SMB. The output feature of the vector attention RWKV module is as follows:
[0094] F out = (σ(R c )⊙V c )W O + O s
[0095] (3) The features output after the feature processing by the vector attention module are divided into C2, C3, C4, and C5 layer feature maps, which are sent to the FPN module of the neck network for multi-scale feature fusion to obtain P2, P3, P4, and P5 layers of fused multi-scale information.
[0096] (5) The output results of the neck network are input to the causal perception head network. The network module adds a causal perception module to the detection head to eliminate the long-tail distribution phenomenon of the complex power distribution network equipment defect target data. Since the naturally collected power distribution network equipment defect targets present a more serious long-tail phenomenon, that is, a small part of the head category has a large number, while most of the tail category has a small number, which seriously affects the performance of existing algorithms in the power distribution network image defect detection task. Specifically, the causal perception module implements causal intervention on the momentum of the optimizer, calculates the average deviation of the head during training, and removes the head deviation by using counterfactual calculation during the detection model inference, which better alleviates the long-tail phenomenon. The causal intervention formula is as follows:
[0097]
[0098] where Y is the output calibration result, F represents the input feature, M represents the optimizer vector, y, f, and m represent the values of Y, F, and M, respectively. After causal inference, the counterfactual calibration formula used in the power distribution network defect detection model inference stage is as follows:
[0099]
[0100] where τ represents a positive proportional factor of the adjustment probability value, G represents the number of class groups for dividing the weight and feature channels by applying the multi-head strategy, i represents the index value, w i represents the network parameter, f i represents the feature sample, η represents a hyperparameter for adjusting w i and f i , ||w i || represents the modulus of w i , T represents the temperature coefficient, ε represents a hyperparameter for adjusting the weight of the second term, represents the head feature projection quantity calculated during the training process, and Y represents the output after causal calibration;
[0101] (5) The overall loss function of the causal perception power distribution network defect image detection model based on the vector attention mechanism is represented as:
[0102]
[0103] where λ is the weight coefficient of the regression box, L cls is the classification loss, L reg is the regression loss, and N is the total number of categories;
[0104] The classification loss L cls uses the cross-entropy loss, and the classification loss is represented as:
[0105]
[0106] Among them, y i For the true value, Here, C represents the model's predicted value, and C is the number of categories.
[0107] The regression loss uses the general Smooth L1 loss function, and the regression loss is expressed as:
[0108]
[0109] The fourth step is to acquire images of the distribution network defects to be detected: use mobile devices such as drones to collect images of the distribution network defects to be detected.
[0110] The fifth step is to obtain the distribution network defect detection results: input the distribution network defect image to be detected into the trained distribution network defect image detection model to obtain the defect detection results in the distribution network image.
[0111] like Figure 3 As shown, for intelligent assessment of distribution network defect targets with complex scenarios, this invention can accurately identify and detect their current location, and also has good adaptability to multiple targets of different scales. Figure 4 As shown, for small targets in power distribution network construction quality scenarios, this invention can still accurately detect defect category targets.
[0112] The foregoing has shown and described the basic principles, main features, and advantages of the present invention. Those skilled in the art should understand that the present invention is not limited to the above embodiments. The embodiments and descriptions in the specification are merely principles of the invention. Various changes and modifications can be made to the invention without departing from its spirit and scope, and all such changes and modifications fall within the scope of the claimed invention. The scope of protection claimed by the appended claims and their equivalents is defined.
Claims
1. A method for detecting defects in causal sensing power distribution network images based on vector attention mechanism, characterized in that, Includes the following steps: Acquiring images of power distribution network defects: Using mobile devices to collect images of power distribution network defects in different scenarios and of different types, forming a power distribution network defect image dataset; A defect image detection model for power distribution networks was constructed based on a backbone network, a vector attention module (RWKV), a neck network, and a causal perception head network. Training of the distribution network defect image detection model: The distribution network defect image detection model is trained using the distribution network defect image dataset to obtain the trained distribution network defect image detection model; Acquiring images of defects in the power distribution network to be inspected: Using mobile devices to acquire images of defects in the power distribution network to be inspected; Obtaining distribution network defect detection results: Input the distribution network defect image to be detected into the trained distribution network defect image detection model to obtain the defect detection results in the distribution network image; The construction of the power distribution network defect image detection model includes the following steps: A defect image detection model for power distribution networks is established, including a backbone network, a vector attention module RWKV, a neck network, and a causal perception head network. The backbone network is set as the basic feature extraction network for the image. It is built based on the ConvNeXt network and consists of multiple layers of convolutional neural network, pooling layers and activation function layers. The feature extraction network is used to extract the feature map of the target in the whole image. The input of the feature extraction network is the enhanced image of the power distribution network defect image collected by the mobile device. Random cropping and color transformation are used as enhancement methods to enhance the generalization performance of the network. The output is the overall feature map of the enhanced image of the power distribution network defect image. A vector attention module RWKV is defined, which includes a spatial blending module SMB and a channel blending module CMB. Residual connections are used between modules to preserve feature information. The spatial blending module SMB and the channel blending module CMB include a network regularization layer, an image patch offset layer, a vector attention calculation layer, and an activation function layer. The neck network is set up, which adopts the FPN multi-scale structure. The input of the neck network is the feature maps of layers C2, C3, C4, and C5 of the vector attention module, and the output is layers P2, P3, P4, and P5 that fuse multi-scale information. A causal perception head network is set up as the RoI feature extraction layer for defect detection. It is mapped to any one of the P2, P3, P4, and P5 layers according to the size of the target box to extract the regional features of the target location. Causal inference correlation operations are used to remove the confusion effect caused by the optimizer momentum interference in the distribution network defect target detection. The RoIAlign operation is then performed on the regional features to obtain a uniform 7×7 size RoI feature map.
2. The method for detecting image defects in a causal sensing power distribution network based on vector attention mechanism according to claim 1, characterized in that, The steps for obtaining images of power distribution network defects are as follows: Images of power distribution network defects are collected using mobile devices. LabelImg annotation software is used to label the defect categories of the collected images, generating XML files containing the target categories and locations to form a power distribution network defect image dataset.
3. The method for detecting image defects in a causal sensing power distribution network based on vector attention mechanism according to claim 1, characterized in that, The training of the power distribution network defect image detection model includes the following steps: Data augmentation is performed on the original defect image dataset of the power distribution network. The images are randomly cropped and scaled to the original size, and the colors of the images are transformed. Random combination augmentation is performed during the training process. The enhanced image is used as input to the backbone network to extract image features. The feature extraction network is used to extract the overall feature map of the power distribution network image. The C2, C3, C4 and C5 layers of the ConvNext network are used to represent the features at each scale in the overall feature map. The overall feature map output by the backbone network is used as the input to the vector attention module RWKV. The input feature map first enters the spatial blending module SMB, and the input feature map is set as... The SMB module first flattens it into a sequence vector. ,vector Dimensions ,in , Represents the number of image patches. Represents the height of the characteristic. Represents feature width, Represents the number of channels; sequence vector First, the image passes through a regularization layer, and then the input image patch offset layer is used for processing: ; ; Where LN represents the regularization operation and Shift represents the image patch offset operation. This represents the feature vector after regularization and offset processing. This represents a 5×5 convolutional layer. and These are two hyperparameters that can be learned during training; then The vectors are fed into three parallel linear mapping layers for vector mapping, generating three sets of feature vectors: Receptance vectors are used to represent past information and reduce the forgetting of past information; Key vector; The value vector; the three sets of feature vectors are used together to calculate the attention mechanism: ; in, These represent the corresponding linear mapping layers; and As input, it is transmitted to the WKV attention calculation module, i.e., the Bi-WKV layer; the Bi-WKV iterative calculation is performed Q times, and the corresponding calculation formula is as follows: ; ; ; in, This represents the attention of the t-th image patch unit. and This refers to the hyperparameters used in the attention mechanism operation; and They represent the i-th element from... and The spatial units obtained in the process; the calculated wkv attention magnitude is then combined with the sigmoid activation function. The vectors are multiplied by a dot product and then joined with the original features using a residual join operation. The formula for summation is as follows: ; in, This indicates the output of the Spatial Mixing Module (SMB). It is the Sigmoid activation function. These are the corresponding feature weights; The Spatial Mixing Module (SMB) serves as the input to the Channel Mixing Module (CMB). Similar to the Spatial Mixing Module, its input features are... Processed by a regularization layer and an image patch offset layer: ; in, This is the output result; similar to the spatial mixing module, three sets of feature vectors are obtained in the following way. , as well as : ; in, , , Similarly, it represents the corresponding linear layer; Represents the ReLU activation function; The results are based on It is obtained by vector calculation, and vector After processing using the Sigmoid activation function, the channel blending module (CMB) also employs residual connections to add its output to the SMB output. The final output features of the vector attention (RWKV) module are as follows: ; After feature processing by the vector attention module, the output features are divided into C2, C3, C4, and C5 layer feature maps, which are then fed into the FPN module of the neck network for multi-scale feature fusion to obtain P2, P3, P4, and P5 layers that fuse multi-scale information. The output of the neck network is input into the causal perception head network. The causal perception module implements causal intervention on the optimizer momentum, calculates the average bias of the head to the statistical features during training, and removes the head bias using counterfactual calculation during the inference of the detection model. The causal intervention formula is as follows: ; Where Y represents the output calibration result, F represents the input features, M represents the optimizer vector, and y, f, and m represent the values of Y, F, and M, respectively. After causal inference, the counterfactual calibration formula finally adopted in the inference stage of the distribution network defect detection model is as follows: ; Where τ represents the proportionality factor for adjusting the probability value, G represents the number of class groups used to divide the channels of weights and features using multi-head analysis, and i represents the index value. Represents network parameters, Let η represent a feature sample, and let η represent a parameter used for adjustment. and hyperparameters, express The modulus is given by ⊤, which represents the temperature coefficient, and ε represents the hyperparameter used to adjust the weight of the second term. Y represents the number of head feature projections counted during training, and Y represents the final output after causal calibration. The overall loss function of the causal sensing power distribution network defect image detection model based on vector attention mechanism is expressed as: ; in, These are the weight coefficients of the regression boxes. For classifying losses, The regression loss is given by N, which represents the total number of categories. Classification loss Using cross-entropy loss, the classification loss is expressed as: ; in, For the true value, The predicted value is C, where C is the number of categories. The regression loss uses the general Smooth L1 loss function, and the regression loss is expressed as: 。
Citation Information
Patent Citations
Large-scale equipment fault prediction method with causal and attention emphasized in industrial internet
CN114580472A
Model construction method, device and equipment of attention mechanism based on space grid
CN118114715A