Vector attention mechanism-based causal perception power distribution network image defect detection method

By adopting a causal perception detection method based on a vector attention mechanism in the image defect detection of distribution network, the problems of low accuracy and poor effect in the prior art are solved, and more efficient detection and management of distribution network equipment defects are achieved.

CN119540795AActive Publication Date: 2025-02-28STATE GRID HUBEI ELECTRIC POWER RES INST +2

Patent Information

Application Number
CN202411471031.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-02-28
Estimated Expiration
2044-10-21

AI Technical Summary

Technical Problem

The prior art has low accuracy and poor results in the detection of image defects of distribution networks. Especially in complex and changeable distribution network environments, it is difficult to effectively identify and detect safety and functional defects of distribution network equipment.

Method used

The image defect detection method of the causal perceptual distribution network based on the vector attention mechanism is adopted, and image feature extraction and defect detection are carried out by constructing a detection model including the backbone network, the vector attention module RWKV, the neck network and the causal perceptual head network. This method introduces a causal perception module to alleviate the long-tail distribution phenomenon and enhances image feature processing capabilities through vector attention mechanism.

Benefits of technology

It improves the accuracy and effect of image defect detection in distribution network, can more accurately identify and detect defects in distribution network equipment, enhances the intelligence level of equipment management, and reduces the subjective errors of manual inspection and the work burden of on-site inspection personnel.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119540795A_ABST
    Figure CN119540795A_ABST
Patent Text Reader

Abstract

The invention discloses a causal perception power distribution network image defect detection method based on a vector attention mechanism, and the method comprises the steps: collecting different types of power distribution network defect images in different scenes through mobile terminal equipment, and forming a power distribution network defect image data set; constructing a power distribution network defect image detection model based on a backbone network, a vector attention module RWKV, a feature fusion module and a causal perception head network; training a power distribution network defect image detection model by using the power distribution network defect image data set to obtain a trained power distribution network defect image detection model; collecting a to-be-detected power distribution network defect image by using mobile terminal equipment; and inputting a to-be-detected power distribution network defect image into the trained power distribution network defect image detection model to obtain a defect detection result in the power distribution network image. Compared with the prior art, the problem that complex power distribution network defect image data is low in detection precision and cannot meet the requirement for intelligent detection of power distribution network defects is solved, and accurate detection of power distribution network image defect category targets is achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of distribution network image detection, and in particular to a causal perception distribution network image defect detection method based on a vector attention mechanism. Background Art

[0002] The operation, maintenance and inspection of distribution network equipment are complex and arduous. In order to promote the intelligent transformation of distribution network equipment defect detection, improve the intelligent level of equipment management, and improve the quality and safety of distribution network equipment, the defects of distribution network equipment can be effectively identified by intelligently identifying the defects of deployed distribution network equipment based on the image information collected by drones. Since the operation scenarios of the distribution network are scattered, complex and changeable, and the defects of naturally collected distribution network images show a long-tail distribution, that is, a few defect categories (head categories) have a large number of samples, while the number of samples of most defect categories (tail categories) is very small. This long-tail distribution phenomenon leads to the insufficient detection ability of the target detection model for the tail category during the training process, which seriously affects the detection performance of the target detection model in practical applications. Therefore, developing a high-performance distribution network image defect detection model to realize automatic detection and diagnosis of equipment defects can not only reduce the subjective errors of manual detection, but also reduce the workload of on-site inspection personnel and improve the overall operation and maintenance efficiency.

[0003] Distribution network equipment defect detection mainly includes two categories: safety defects and functional defects. Safety defects include damage to the grounding wire and whether the lightning arrester is installed properly; functional defects include aging of the wire, damage to the insulator, corrosion of the equipment casing, etc. In the complex and changeable distribution network environment, the existing target detection algorithm performs poorly in detecting defects and has low detection accuracy. Therefore, in order to more efficiently and accurately identify distribution network equipment defects, it is necessary to develop a target detection model with better performance and more accurate detection effect based on the defect characteristics of the distribution network image.

[0004] Therefore, high-performance target detection models are more suitable for complex distribution network equipment distribution scenarios, but the detection performance of existing algorithms is generally poor. In order to improve the performance of distribution network defect detection models and thereby improve the overall intelligent judgment accuracy in the distribution network equipment defect detection process, it has become a technical problem that needs to be solved urgently. Summary of the invention

[0005] The purpose of the present invention is to solve the problem of low accuracy and poor effect of the existing technology in dealing with distribution network image defect detection scenarios, and to provide a causal perception distribution network image defect detection method based on a vector attention mechanism to solve the above problems.

[0006] In order to achieve the above object, the technical solution of the present invention is as follows:

[0007] A causal perception distribution network image defect detection method based on vector attention mechanism includes the following steps:

[0008] Obtain distribution network defect images: Use drones and other mobile devices to collect distribution network defect images of different scenes and types to form a distribution network defect image dataset;

[0009] Build a distribution network defect image detection model: A distribution network defect image detection model based on the backbone network, vector attention module RWKV, neck network, and causal perception head network;

[0010] Training of distribution network defect image detection model: Use distribution network defect image dataset to train the distribution network defect image detection model;

[0011] Obtaining images of distribution network defects to be detected: Using mobile devices such as drones to collect images of distribution network defects to be detected;

[0012] Obtaining distribution network image defect detection results: Inputting 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.

[0013] The steps of obtaining the distribution network defect image are as follows:

[0014] Defect images of distribution network equipment in various scenarios are collected through mobile devices such as drones. The collected distribution network defect images are marked with defect category targets using LabelImg annotation software, and an XML file containing the target category and location is generated to form a distribution network defect image dataset.

[0015] The construction of the distribution network defect image detection model comprises the following steps:

[0016] The distribution network defect image detection model is set to include 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 the basic feature extraction network of the image, which is constructed based on the ConvNeXt network and consists of superimposed 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 entire image. The input of the feature extraction network is the enhanced image of the distribution network defect image collected by mobile devices such as drones. 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 distribution network defect image.

[0018] Set the vector attention module RWKV. RWKV is a new architecture that combines the advantages of the recurrent neural network RNN ​​and the self-attention architecture Transformer model. It has superior parallel computing capabilities and time series processing capabilities, and provides a global receptive field for images to better extract image features. In order to improve the accuracy of distribution network defect detection, the distribution network defect image detection model introduces the vector attention module RWKV to strengthen the processing and enhancement of image features. It includes a spatial mixing module SMB and a channel mixing module CMB, and uses residual connections between 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, etc.

[0019] Setting the neck network: In order to detect defect categories of different scales and fuse features, the neck network of the 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 layers that fuse multi-scale information.

[0020] A causal-aware head network is set. In order to alleviate the long-tail phenomenon presented by the distribution of distribution network defect images, the distribution network defect image detection model introduces a causal-aware head network as the RoI feature extraction layer for defect detection. According to the size of the target box, it is mapped to any layer of the P2, P3, P4, and P5 layers to extract the regional features of the target corresponding position. The causal reasoning related operations are used to remove the confusion effect caused by the momentum interference of the optimizer in the distribution network defect target detection, which effectively alleviates the complex long-tail phenomenon in the distribution network image defects, and the RoIAlign operation is performed on the regional features to obtain a uniform 7×7 size RoI feature map.

[0021] The training of the distribution network defect image detection model includes the following steps:

[0022] The original defect image dataset of the distribution network is enhanced by randomly cropping the image and scaling it to the original size, performing color transformation on the image, and performing random combination enhancement during the training process.

[0023] The enhanced image is used as the input of the backbone network to extract image features. The feature extraction network is used to extract the overall feature map of the distribution network image. 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 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 to F. The SMB module first flattens it into a sequence vector X. The vector X dimension is T×C, where T=H×W, 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 will first pass through the regularization layer and then enter the image block offset layer for processing:

[0025] X s =Shift(LN(X))

[0026] Shift(X)=αC5(X)+βX

[0027] Among them, LN represents the regularization operation, Shift represents the image block shift operation, and X s represents the feature vector after regularization and offset processing, C5 represents a 5×5 convolutional layer, and α and β are two hyperparameters that can be learned during the training process. s Send it to three parallel linear mapping layers for vector mapping to generate three sets of feature vectors: R S , Receptance vector, used to represent past information and reduce the forgetting of past information; K S , Key vector, and V S , the Value vector is 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] Among them, W R , W K , W V They represent the corresponding linear mapping layers. S and V S It is used as input and transmitted to the WKV attention calculation module, namely the Bi-WKV layer. In order to ensure that the image features have a global receptive field and better extract the features, the Bi-WKV iterative operation is performed Q times. The corresponding calculation formula is as follows:

[0030] wxya t =Bi-WKV(K s , V s ) t

[0031]

[0032] wkv=Bi-WKV (Q) (K s , V s )

[0033] Among them, wkv t k represents the attention of the tth image block unit, w and u represent the hyperparameters used in the attention mechanism operation process. i and v i Respectively represent the i-th from K S and V S The calculated wkv attention weight is then combined with the R after the Sigmoid activation function. S The vector is point-multiplied and the residual connection operation is used to sum it with the original feature F. The calculation formula is as follows:

[0034] O s =(σ(R s )⊙wkv)W O +F

[0035] Among them, O s represents the output of the spatial mixing module SMB, σ is the Sigmoid activation function, W O is the corresponding feature weight.

[0036] The spatial mixing module SMB serves as the input of the channel mixing module CMB. Similar to the spatial mixing module, the input feature O s Processed by regularization layer and image block offset layer:

[0037] X c =Shift(LN(O S ))

[0038] Among them, X c is the output result. Similar to the spatial mixing module, three sets of feature vectors R can be obtained in the following way c , K c and V c :

[0039] R c =X c W R , K c =X c W K , V c =γ(K c )W V

[0040] Among them, W R , WK , W V It also represents the corresponding linear layer. γ represents the Relu activation function. c The results need to be based on K c The vector is calculated, and the vector R c It will still be processed by the Sigmoid activation function. The channel mixing module CMB also uses the residual connection operation to add the output result to the output of SMB. The output characteristics of the final vector attention RWKV module are as follows:

[0041] F out =(σ(R c )⊙V c )W O +O s

[0042] After feature processing by the vector attention module, the output features are divided into C2, C3, C4, and C5 layer feature maps, and sent to the FPN module of the neck network for multi-scale feature fusion to obtain the P2, P3, P4, and P5 layers that fuse multi-scale information.

[0043] The output of the neck network is input into the causal perception head network. This network module adds a causal perception module to the detection head to eliminate the long-tail distribution phenomenon of defect target data of complex distribution network equipment. Since the defect targets of distribution network equipment collected naturally show a more serious long-tail phenomenon, that is, a small number of head categories are large, while most of the tail categories are small, the performance of existing algorithms in distribution network image defect detection tasks is seriously affected. Specifically, the causal perception module implements causal intervention on the optimizer momentum, calculates the average deviation of features to the head during training, and uses counterfactual calculations to remove the head deviation during detection model inference, which better alleviates the long-tail phenomenon. The causal intervention formula is as follows:

[0044]

[0045] Among them, Y is the output calibration result, F represents the input feature, 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:

[0046]

[0047] Among them, τ represents the positive proportional factor for adjusting the probability value, G represents the number of category groups for dividing the weight and feature channels using the multi-head strategy, i represents the index value, and w i represents the network parameters, f i represents the feature sample, η represents a function for adjusting wi and f i The hyperparameters of ||w i || indicates w i The modulus of , T represents the temperature coefficient, ε represents the hyperparameter used to adjust the weight of the second term, represents the head feature projection quantity counted during the training process, and Y represents the output after the final causal calibration;

[0048] The loss function of the detection task is:

[0049]

[0050] Among them, λ is the weight coefficient of the regression box, L cls is the classification loss, L reg is the regression loss, N is the total number of categories;

[0051] Classification loss L cls Using cross entropy loss, the classification loss is expressed as:

[0052]

[0053] Among them, y i is the true value, is the model prediction value, and C is the number of categories.

[0054] The regression loss uses the general Smooth L1 loss function, and the regression loss is expressed as:

[0055]

[0056] The causal perception distribution network image defect detection method based on the vector attention mechanism of the present invention provides a target detection method with stronger feature differentiation and fusion capabilities, better processing capabilities for complex distribution network equipment image defect distribution, and higher recognition accuracy compared with the prior art, and realizes accurate detection of distribution network image defect category targets, which is specifically described as follows:

[0057] The present invention utilizes image enhancement to construct a distribution network image defect target detection model. Through the extraction of global features and feature enhancement by a vector attention module, the feature semantic expression capability of the distribution network image defect target detection model is enhanced, which is conducive to the distinction of various categories of targets in distribution network equipment defects. The present invention introduces a causal perception module in the head network. Aiming at the long-tail distribution phenomenon presented in complex distribution network data, the causal intervention method is used to eliminate the confusion effect generated by the optimizer momentum and the bias towards the head category during the network training process, so that the distribution network image defect target detection model can better handle defect detection tasks in complex scenarios. The causal perception distribution network image defect detection method based on the vector attention mechanism proposed in the present invention is more convenient for the actual application of distribution networks in real scenarios, and improves the efficiency of troubleshooting distribution network equipment defects. BRIEF DESCRIPTION OF THE DRAWINGS

[0058] Figure 1 This is a flow chart of a causal perception distribution network image defect detection method based on a vector attention mechanism according to an embodiment of the present invention;

[0059] Figure 2 This is a structural diagram of a distribution network defect image detection model involved in the present invention;

[0060] Figure 3 This is a diagram showing the effect of defect image detection in a distribution network using one of the examples of the method described in the present invention;

[0061] Figure 4 This is a diagram showing the effect of distribution network defect image detection using another example of the method described in the present invention. DETAILED DESCRIPTION

[0062] In order to have a further understanding and recognition of the structural features and the effects achieved by the present invention, a preferred embodiment and accompanying drawings are used for detailed description as follows:

[0063] like Figure 1 As shown, the causal perception distribution network image defect detection method based on vector attention mechanism described in the present invention includes the following steps:

[0064] The first step is to obtain distribution network defect images: use mobile devices such as drones to collect distribution network defect images of different scenes and types to form a distribution network defect image dataset.

[0065] The distribution network defect images are collected through mobile devices, and the defect category targets of the collected distribution network defect images are marked using LabelImg annotation software to generate an XML file containing the target category and location to form a distribution network defect image dataset.

[0066] The second step is to build a distribution network defect image detection model: Figure 2 As shown in the figure, a distribution network defect image detection model is constructed based on the backbone network, vector attention module RWKV, feature fusion module, and causal perception head network. The vector attention module RWKV strengthens the feature extraction of the model and enhances the feature information of the image through the operation of the global attention mechanism, and has good operation efficiency. The causal perception head network uses causal calculation and calibration to alleviate the long-tail distribution phenomenon in complex distribution network data, and at the same time improves the accuracy of the overall intelligent judgment of distribution network defect detection.

[0067] The specific steps are as follows:

[0068] (1) Set up a 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) Setting a backbone network: The backbone network is set as the basic feature extraction network of the image. It is constructed based on the ConvNeXt network and consists of superimposed 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 entire image. The input of the feature extraction network is the enhanced image of the distribution network defect image collected by mobile devices such as drones. 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 image of the distribution network defect image.

[0070] (3) Set the vector attention module RWKV. RWKV is a new architecture that combines the advantages of the recurrent neural network RNN ​​and the self-attention architecture Transformer model. It has superior parallel computing capabilities and time series processing capabilities, and provides a global receptive field for images to better extract image features. In order to improve the accuracy of distribution network defect detection, the distribution network defect image detection model introduces the vector attention module RWKV to strengthen the processing and enhancement of image features. It includes a spatial mixing module SMB and a channel mixing module CMB, and uses residual connections between 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, etc.

[0071] (4) Setting the neck network. In order to detect defect category targets of different scales and perform feature fusion, the neck network of the 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 layers that fuse multi-scale information.

[0072] (5) Setting up a causal-aware head network. In order to alleviate the long-tail phenomenon presented by the distribution of distribution network defect images, the distribution network defect image detection model introduces a causal-aware head network as the RoI feature extraction layer for defect detection. According to the size of the target frame, it is mapped to any layer of the P2, P3, P4, and P5 layers to extract the regional features of the target corresponding position. The causal reasoning-related operations are used to remove the confusion effect caused by the momentum interference of the optimizer in the distribution network defect target detection, which effectively alleviates the complex long-tail phenomenon in the distribution network image defects. The RoIAlign operation is performed on the regional features to obtain a uniform 7×7 size RoI feature map.

[0073] The third step is to train the distribution network defect image detection model: use the distribution network defect image dataset to perform end-to-end training on the distribution network defect image detection model.

[0074] The specific steps are as follows:

[0075] (1) Perform data enhancement on the original defect image dataset of the distribution network, randomly crop the images and scale them to the original size, perform color transformation on the images, and perform random combination enhancement during the training process;

[0076] The enhanced image is used as the input of the backbone network to extract image features. The feature extraction network is used to extract the overall feature map of the distribution network image. 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.

[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 to F. The SMB module first flattens it into a sequence vector X. The dimension of vector X is T×C, where T=H×W, 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 will first pass through the regularization layer and then enter the image block offset layer for processing:

[0078] X s =Shift(LN(X))

[0079] Shift(X)=αC5(X)+βX

[0080] Among them, LN represents the regularization operation, Shift represents the image block shift operation, and X s represents the feature vector after regularization and offset processing, C5 represents a 5×5 convolutional layer, and α and β are two hyperparameters that can be learned during the training process. s Send it to three parallel linear mapping layers for vector mapping to generate three sets of feature vectors: RS , Receptance vector, used to represent past information and reduce the forgetting of past information; K S , Key vector, and V S , the Value vector is used to calculate the attention mechanism:

[0081] R S =X S W R , K s =X S W K , V S =X S W V

[0082] Among them, W R , W K , W V They represent the corresponding linear mapping layers. S and V S It is used as input and transmitted to the WKV attention calculation module, namely the Bi-WKV layer. In order to ensure that the image features have a global receptive field and better extract the features, the Bi-WKV iterative operation is performed Q times. The corresponding calculation formula is as follows:

[0083] wxya t =Bi-WKV(K s , V s ) t

[0084]

[0085] wkv=Bi-WKV (Q) (K s , V s )

[0086] Among them, wkv t k represents the attention of the tth image block unit, w and u represent the hyperparameters used in the attention mechanism operation process. i and v i Respectively represent the i-th S and V S The calculated wkv attention weight is then combined with the R after the Sigmoid activation function. S The vector is point-multiplied and the residual connection operation is used to sum it with the original feature F. The calculation formula is as follows:

[0087] O s =(σ(R s )⊙wkv)W O +F

[0088] Among them, O s represents the output of the spatial mixing module SMB, σ is the Sigmoid activation function, W O is the corresponding feature weight.

[0089] The spatial mixing module SMB serves as the input of the channel mixing module CMB. Similar to the spatial mixing module, the input feature O s Processed by regularization layer and image block offset layer:

[0090] X c =Shift(LN(O S ))

[0091] Among them, X c is the output result. Similar to the spatial mixing module, three sets of feature vectors R can be obtained in the following way c , K c and V c :

[0092] R c =X c W R , K c =X c W K , V c =γ(K c )W V

[0093] Among them, W R , W K , W V It also represents the corresponding linear layer. γ represents the Relu activation function. c The results need to be based on K c The vector is calculated, and the vector R c It will still be processed by the Sigmoid activation function. The channel mixing module CMB also uses the residual connection operation to add the output result to the output of SMB. The output characteristics of the final vector attention RWKV module are as follows:

[0094] F out =(σ(R c )⊙V c )W O +O s

[0095] (3) After feature processing by the vector attention module, the output features are divided into C2, C3, C4, and C5 layer feature maps, and sent to the FPN module of the neck network for multi-scale feature fusion to obtain the P2, P3, P4, and P5 layers that fuse multi-scale information.

[0096] (5) The output of the neck network is input into the causal perception head network. This network module adds a causal perception module to the detection head to eliminate the long-tail distribution phenomenon of defect target data of complex distribution network equipment. Since the defect targets of distribution network equipment collected naturally show a serious long-tail phenomenon, that is, a small number of head categories are large, while most of the tail categories are small, the performance of existing algorithms in distribution network image defect detection tasks is seriously affected. Specifically, the causal perception module implements causal intervention on the optimizer momentum, calculates the average deviation of features to the head during training, and uses counterfactual calculation to remove the head deviation during detection model inference, which effectively alleviates the long-tail phenomenon. The causal intervention formula is as follows:

[0097]

[0098] Among them, Y is the output calibration result, F represents the input feature, 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:

[0099]

[0100] Among them, τ represents the positive proportional factor for adjusting the probability value, G represents the number of category groups for dividing the weight and feature channels using the multi-head strategy, i represents the index value, and w i represents the network parameters, f i represents the feature sample, η represents a function for adjusting w i and f i The hyperparameters of ||w i || indicates w i The modulus of , T represents the temperature coefficient, ε represents the hyperparameter used to adjust the weight of the second term, represents the head feature projection quantity counted during the training process, and Y represents the output after the final causal calibration;

[0101] (5) The overall loss function of the constructed causal perception distribution network defect image detection model based on vector attention mechanism is expressed as:

[0102]

[0103] Among them, λ is the weight coefficient of the regression box, L cls is the classification loss, L reg is the regression loss, N is the total number of categories;

[0104] Classification loss L cls Using cross entropy loss, the classification loss is expressed as:

[0105]

[0106] Among them, y i is the true value, is the model prediction 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 obtain the defect image of the distribution network to be detected: use mobile devices such as drones to collect the defect image of the distribution network to be detected.

[0110] The fifth step is to obtain the distribution network defect detection results: the distribution network defect image to be detected is input 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 analysis of defective targets in distribution networks with complex scenarios, the present invention can accurately identify and detect the current location, and also has good adaptability to multiple targets of different scales. Figure 4 As shown, for small targets in the distribution network construction quality scenario, the present invention can still accurately detect defective category targets.

[0112] The above shows and describes 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 above embodiments and descriptions only describe the principles of the present invention. The present invention may be subject to various changes and improvements without departing from the spirit and scope of the present invention. These changes and improvements fall within the scope of the present invention. The scope of protection claimed by the present invention is defined by the attached claims and their equivalents.

Claims

1. A causal perception distribution network image defect detection method based on vector attention mechanism, characterized in that: The following steps are involved: Obtain distribution network defect images: Use mobile devices to collect distribution network defect images of different scenes and types to form a distribution network defect image dataset; Construct a distribution network defect image detection model: Based on the backbone network, vector attention module RWKV, feature fusion module, and causal perception head network, a distribution network defect image detection model is constructed; Training of distribution network defect image detection model: Use the distribution network defect image dataset to train the distribution network defect image detection model to obtain the trained distribution network defect image detection model; Acquire the defect image of the distribution network to be detected: use the mobile terminal device to collect the defect image of the distribution network to be detected; Obtaining distribution network defect detection results: Inputting 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.

2. The causal perception distribution network image defect detection method based on vector attention mechanism according to claim 1 is characterized in that: The steps of obtaining the distribution network defect image are as follows: The distribution network defect images are collected through mobile devices, and the defect category targets of the collected distribution network defect images are marked using LabelImg annotation software to generate an XML file containing the target category and location to form a distribution network defect image dataset.

3. The causal perception distribution network image defect detection method based on vector attention mechanism according to claim 1 is characterized in that: The construction of the distribution network defect image detection model comprises the following steps: Set up a distribution network defect image detection model, including the backbone network, vector attention module RWKV, neck network, and causal perception head network; The backbone network is set as the basic feature extraction network of the image, which is constructed based on the ConvNeXt network and consists of superimposed 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 entire image. The input of the feature extraction network is the enhanced image of the distribution network defect image collected by the mobile device. 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 image of the distribution network defect image. Set up a vector attention module RWKV, which is a new architecture that combines the advantages of the recurrent neural network RNN ​​and the self-attention architecture Transformer model, and has parallel computing capabilities and time series processing capabilities. The vector attention module RWKV includes a spatial mixing module SMB and a channel mixing module CMB, and uses residual connections between modules to retain feature information; the spatial mixing module SMB and the channel mixing module CMB include a network regularization layer, an image block offset layer, a vector attention calculation layer, and an activation function layer; Set the neck network, which 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 layers that fuse multi-scale information. A causal-aware head network is set as the RoI feature extraction layer for defect detection. According to the size of the target box, it is mapped to any layer of the P2, P3, P4, and P5 layers to extract the regional features of the target corresponding position. The causal reasoning related operations are used to remove the confusion effect caused by the optimizer momentum interference in the distribution network defect target detection, and the RoIAlign operation is performed on the regional features to obtain a uniform 7×7 size RoI feature map.

4. The causal perception distribution network image defect detection method based on vector attention mechanism according to claim 3 is characterized in that: The training of the distribution network defect image detection model includes the following steps: The original defect image dataset of the distribution network is enhanced by randomly cropping the image and scaling it to the original size, performing color transformation on the image, and performing random combination enhancement during the training process. The enhanced image is used as the input of the backbone network to extract image features. The feature extraction network is used to extract the overall feature map of the distribution network image. 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. 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. The input feature map is set to F. The SMB module first flattens it into a sequence vector X. The vector X dimension is T×C, where T=H×W, 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 first passes through the regularization layer, and then the input image block offset layer is processed: X s =Shift(LN(X)) Shift(X)=aC5(X)+βX Among them, LN represents the regularization operation, Shift represents the image block shift operation, and X s represents the feature vector after regularization and offset processing, C5 represents a 5×5 convolutional layer, α and β are two hyperparameters that can be learned during the training process; then X s Send it to three parallel linear mapping layers for vector mapping to generate three sets of feature vectors: R S , Receptance vector, used to represent past information and reduce the forgetting of past information; K S , Key vector; V S , Value vector; three sets of feature vectors are used together to calculate the attention mechanism: R S =X S W R ,K s =X S W K ,V S =X S W V Among them, W R , W K , W V Represent the corresponding linear mapping layers respectively; K S and V S As input, it is transmitted to the WKV attention calculation module, namely the Bi-WKV layer; Bi-WKV is iterated Q times, and the corresponding calculation formula is as follows: wkv t =Bi-WKV(K s ,V s ) t wkv=Bi-WKV (Q) (K s ,V s ) Among them, wkv t represents the attention of the t-th image block unit, w and u represent the hyperparameters used in the attention mechanism operation process; k i and v i Respectively represent the i-th from K S and V S The calculated wkv attention weight is then combined with the R after the Sigmoid activation function S The vector is point-multiplied and the residual connection operation is used to sum it with the original feature F. The calculation formula is as follows: The s =(σ(R s )⊙wkv)W O +F Among them, O s represents the output of the spatial mixing module SMB, σ is the Sigmoid activation function, W O is the corresponding feature weight; 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 Processed by regularization layer and image block offset layer: X c =Shift(LN(O S )) Among them, X c is the output result; similar to the spatial mixing module, three sets of feature vectors R are obtained in the following way c , K c and V c : R c =X c W R ,K c =X c W K ,V c =γ(K c )W V Among them, W R , W K , W V It also represents the corresponding linear layer; γ represents the Relu activation function; V c The results are based on K c The vector is calculated, and the vector R c After being processed by the Sigmoid activation function; the channel mixing module CMB also uses the residual connection operation to add the output result to the output of SMB; the output characteristics of the final vector attention RWKV module are as follows: F out =(σ(R c )⊙V c )W O +O s After feature processing by the vector attention module, the output features are divided into C2, C3, C4, and C5 layer feature maps, and sent to the FPN module of the neck network for multi-scale feature fusion to obtain the P2, P3, P4, and P5 layers that fuse multi-scale information; The output of the neck network is input into the causal-aware head network. The causal-aware module implements causal intervention on the optimizer momentum. During training, it counts the average deviation of features to the head, and uses counterfactual calculation to remove the head deviation during detection model inference. The causal intervention formula is as follows: Among them, Y is the output calibration result, F represents the input feature, M represents the optimizer vector, y, f, 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: Among them, τ represents the positive proportional factor for adjusting the probability value, G represents the number of category groups for dividing the weight and feature channels using the multi-head strategy, i represents the index value, and w i represents the network parameters, f i represents the feature sample, η represents a function for adjusting w i and f i The hyperparameters of ||w i || indicates w i The modulus of , T represents the temperature coefficient, ε represents the hyperparameter used to adjust the weight of the second term, represents the head feature projection quantity counted during the training process, and Y represents the output after the final causal calibration; The overall loss function of the constructed causal-aware distribution network defect image detection model based on vector attention mechanism is expressed as: Among them, λ is the weight coefficient of the regression box, L cls is the classification loss, L reg is the regression loss, N is the total number of categories; Classification loss L cls Using cross entropy loss, the classification loss is expressed as: Among them, y i is the true value, is the model prediction value, and 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

  • Defect detection method, device and equipment for photovoltaic panel and storage medium

    CN118799297A

  • Method for small object detection in drone scene based on deep learning

    US11881020B1

Cited By

  • Vision-RWKV polarization multi-mode defect detection method and system

    CN121616927A

  • Vision-rwkv polarization multimodal defect detection method and system

    CN121616927B