A transformer leakage oil detection system and method based on an adaptive transformer segmentation network
By employing statistical alignment gating attention, dynamic feature selection, and a multi-path decoder in an adaptive Transformer segmentation network, the problem of easy confusion between oil leakage and shadows in transformer oil leakage detection is solved, achieving more efficient oil leakage detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NORTH CHINA ELECTRIC POWER UNIV
- Filing Date
- 2026-02-25
- Publication Date
- 2026-06-05
AI Technical Summary
Existing semantic segmentation methods based on Transformer lack adaptability in transformer oil leakage detection, making it difficult to accurately identify oil leakage and shadows in complex outdoor environments, resulting in low detection efficiency.
An adaptive Transformer segmentation network is adopted, and the accuracy of oil leakage detection is improved by statistical alignment gating attention, dynamic feature selection module and multi-path adaptive decoder.
It improves the efficiency of transformer oil leakage detection, reduces the confusion between oil leakage and shadows, enhances the network's ability to identify oil leakage areas, and suppresses the influence of background noise.
Smart Images

Figure CN122156108A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of image recognition technology for power equipment, and in particular to a transformer oil leakage detection system and method based on an adaptive Transformer segmentation network. Background Technology
[0002] Transformers are the core hub of the power system, responsible for switching between different voltage levels, and their operating status directly affects the stability of the power grid. Oil-plate insulation systems are a common insulation method in transformers, but during long-term use, factors such as seal aging and external damage can lead to oil leakage. Oil leakage is a major threat to the safety of the power system, not only causing a continuous decline in transformer insulation and leading to equipment failure, but also causing environmental pollution and even serious fire and explosion accidents. Therefore, accurate detection of transformer oil leakage is crucial to ensuring the normal operation of the power system.
[0003] Early research on intelligent inspection mainly employed traditional digital image processing methods such as threshold segmentation, color space analysis, and edge detection. However, these methods struggled to achieve stable detection in complex environments. In recent years, semantic segmentation has become a crucial research area in computer vision, capable of obtaining fine, pixel-level boundaries of objects in images. Convolutional neural network-based semantic segmentation methods like U-Net and PSPNet can extract local image features, while Transformer-based methods such as SETR and SegFormer can establish long-range dependencies between image pixels. Semantic segmentation technology has wide applications in transformer oil leakage detection. DAttRes-Unet uses spatial and channel attention in its residual network to highlight the oil leakage area and suppress background noise, helping the network better identify oil leakage. DSACP uses depthwise separable convolutional blocks to optimize the hole pyramid to obtain rich semantic features, improving the network's accuracy in detecting oil leakage. SE-FormerSeg enhances the network's spatial feature learning ability through spatial augmentation Transformer and performs multi-stage feature fusion of low-level and high-level feature maps, helping the network effectively identify oil leakage areas.
[0004] Unlike semantic segmentation in general scenarios, transformer oil leakage segmentation presents certain challenges due to its inherent characteristics and environmental influences. Transformers are typically placed outdoors, and inspection images are affected by sunlight, resulting in numerous shadows. Since the shape and features of leaking oil are highly similar to shadows, accurately identifying the leaking oil and the shadows becomes a significant challenge. Directly using existing Transformer-based semantic segmentation methods for transformer oil leakage segmentation lacks adaptability. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a transformer oil leakage detection system and method based on an adaptive Transformer partitioning network, which can overcome the shortcomings of the prior art and improve the detection efficiency of transformer oil leakage.
[0006] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows.
[0007] A transformer oil leakage detection system based on an adaptive Transformer partitioning network includes, The Transformer module of statistical alignment gated attention is used to embed overlapping patches, then convert the input image into a patch sequence, which is then normalized by layers and fed into statistical alignment gated attention, followed by layer normalization and fed into a feedforward neural network. Finally, overlapping patches are merged to generate feature maps of different scales. The dynamic feature selection module is used to select important features from deep feature maps, solving the problems of local spatial detail loss and global channel information redundancy. A multi-path adaptive decoder is used to generate leaked oil segmentation results.
[0008] A transformer oil leakage detection method based on an adaptive Transformer segmentation network, implemented using the aforementioned transformer oil leakage detection system based on an adaptive Transformer segmentation network, includes the following steps: The Transformer module of statistical alignment gated attention performs overlapping patch embedding, then converts the input image into a patch sequence, which is then normalized by layers and fed into the statistical alignment gated attention, followed by layer normalization and fed into the feedforward neural network. Finally, overlapping patches are merged to generate feature maps of different scales. The dynamic feature selection module selects important features from deep feature maps, solving the problems of local spatial detail loss and global channel information redundancy. The multi-path adaptive decoder generates the leakage oil segmentation results.
[0009] Preferably, the Transformer module with statistically aligned gated attention generates the lost feature map by including the following steps. A1. Statistical alignment gating attention performs a linear mapping on the input feature map X to generate a query. ,key Sum For query s and keys By introducing the statistical distribution of the root mean square normalized stable dot product result, the stability of the attention dot product calculation is improved, and a normalized query is obtained. s and keys ; A2. The statistical alignment-gated attention mechanism introduces a learnable temperature coefficient for each attention head to adaptively scale the dot product results of different attention heads. This scaling is achieved through a normalization method coupled to the attention head dimension, ensuring numerical stability while calibrating the attention distribution pattern head-by-head. A sigmoid mapping is used to impose numerical constraints on temperature adjustment, preventing attention distribution degradation. The scaling factor s... h Defined as, , , in, This represents the Sigmoid activation function. Indicates learnable parameters, The parameter represents temperature, h represents the attention head order, and d represents the dimension per head; after obtaining the scaling factor, the aligned gating attention pairs are statistically analyzed for the query. s and keys Calculate attention score using matrix multiplication ; A3. Statistical alignment gating attention sets context-aware semantic bias, directly injecting contextual information into the bias term of the attention score through head-by-head semantic score and global context coefficient, and performing fine-grained calibration of attention distribution; A4. The statistical alignment gating attention design incorporates a directional frequency domain collaborative enhancement module to enhance the input feature map, which is then passed through a linear layer to obtain the final feature map. ; A5. Statistical Alignment Gating Attention Pairs Perform statistical alignment to obtain the key The first-order and second-order statistics are consistent. ; , in, and Let represent the mean and standard deviation, respectively. Statistical alignment gating attention is calculated using the mean cosine similarity. The semantic consistency score is obtained based on the similarity between K and K. ; A6. Statistical alignment gating attention will and and Multiply by each to obtain and ; A7. Statistical alignment gating attention is implemented using an adaptive gating fusion mechanism. and The integration.
[0010] Preferably, step A3 includes, Context-aware semantic bias will query s and keys Source feature X q and X k Perform independent linear transformations to map to the semantic space corresponding to the number of attention heads, generating head-by-head scalar scores s q and s k Context-aware semantic bias will adjust the source feature X q Global average pooling is performed to obtain the global context vector, which is then input into a context-aware module consisting of two linear layers and a Gelu activation function to obtain the context coefficients c. The context coefficients c are defined as follows: , Here, L1 and L2 represent linear layers. L1 compresses the high-dimensional context vector to a low dimension to obtain useful context information, while L2 maps the compressed information dimension to a value consistent with the number of attention heads. This represents the Gelu activation function. This represents the Sigmoid activation function; finally, the head-by-head scalar score s is calculated. q and s k After multiplication, element-wise multiplication with the context coefficient c yields the complete bias term B; statistical alignment gating attention will... The final attention score is obtained by adding B, and the attention weight distribution is generated using the Softmax activation function. .
[0011] Preferably, step A4 includes, The directional frequency domain co-operation module first uses a convolution kernel size of 1. 3,3 1 and 3 A depthwise separable convolution of size 3 extracts spatial features of the input feature map along its horizontal, vertical, and diagonal directions, respectively, using learnable weights. The feature maps extracted by convolution in different directions are weighted and summed to generate a feature map with directional feature information. The directional frequency domain coordination module utilizes different frequency domain feature information to... Averaging pooling to obtain low-frequency components helps the network focus on the shape and overall structure of the leaking oil, through calculation. The difference between low-frequency components generates high-frequency components to obtain the texture and edge features of the leaking oil; through a... Global average pooling features generate two gate signals for the input gating network. and , , , Where GAP represents global pooling operation, and Conv1 represents 1 1. Convolution operation, This represents the Gelu activation function. The sigmoid activation function is represented by 'Sigmoid', and 'Chunk' represents the separation operation. The directional frequency domain coordination module multiplies the low-frequency and high-frequency components with their corresponding gated signals, and then connects them to the gated signal via residuals. Add them together, then use a linear layer to obtain the result. .
[0012] Preferably, step A7 includes, Adaptive gating fusion mechanisms include uncertainty gating, credibility gating, and learnable gating per head; Uncertainty gating directly uses the normalized entropy of attention weights. Help the network obtain gating signals Determine the reliability of the attention results and select the main dependent features; if the entropy is low, then rely on the enhanced features. Otherwise, it depends on the basic features. ; The calculation process is as follows: , Where t represents the learnable threshold and α represents the learnable slope. This represents the Sigmoid activation function; Trustworthiness gating is achieved through semantic consistency scores. The gating signal is obtained by utilizing a learnable threshold and slope. Determine the enhanced features Credibility, The calculation process is as follows: , in, β represents the learnable threshold, and β represents the learnable slope. This represents the Sigmoid activation function; Learnable gating to obtain gating signals This allows different attention heads to achieve varying enhancement intensities during the fusion stage by leveraging their own semantic features and attention distribution characteristics, thus enabling collaboration between attention heads. The calculation process is as follows: , Where a and b represent learnable parameters, This represents the Sigmoid activation function. SAGA multiplies the three gated signals and then... and Multiply the differences and connect them with the residuals. Addition output Achieve adaptive attention fusion. The calculation process is as follows: .
[0013] Preferably, the dynamic feature selection module selects important features from the deep feature map using the following steps. B1. The dynamic feature selection module obtains multi-scale texture features through local branches; within the local branches, the dynamic feature selection module uses 3... 3. Standard convolution extracts spatial feature information from feature maps, and then uses 3... 3. Deep convolution captures spatial relationships within channels to obtain spatially enhanced feature maps. The dynamic feature selection module will select the feature map. Feature maps are obtained by evenly dividing along the channel dimension. and ; feature map and They were fed into 3 with expansion rates of 2 and 3 respectively. 3. Deep dilated convolution helps the network obtain multi-scale spatial feature maps under different receptive fields. and Feature map Feature map containing local edge feature information It has contextual features; the dynamic feature selection module will and Element-wise multiplication is performed to achieve adaptive selection of cross-scale features, retaining only discriminative features that respond at different scales. This suppresses scale redundancy and enhances the effectiveness of local features, resulting in a discriminative local feature map. Local feature map After 1 1. Convolution is used to increase the dimensionality of channels and obtain local feature maps. ; B2. The dynamic feature selection module obtains global context information through global branches. In the global branches, the dynamic feature selection module first uses global average pooling and global max pooling to model the global context, capturing global features and salient features to obtain feature maps. and ;Will and Feed into the shared bottleneck network, which contains two 1s. 1. Convolution operation, the first 1 The first convolution operation performs channel reduction to filter important global features, and the second 1 1. Convolutional operations are used to perform channel-level dimensionality enhancement to model the relationships between global features and obtain feature maps. and The dynamic feature selection module will select the feature map. and A concatenation operation is performed along the channel dimension to fuse global contextual information and obtain feature maps. , feature map Divide equally along the channel dimension and pass through 1 respectively. 1. Convolution and Sigmoid activation function yield two global weights and ; B3. The dynamic feature selection module will apply global weights. With local feature map Element-wise multiplication yields feature maps This allows local feature maps to learn features with fine-grained spatial structure and semantics on a global dimension; the dynamic feature selection module applies global weights... Element-wise multiplication with the input feature map yields a feature map with global context. The dynamic feature selection module will select the feature map. and The final feature map is obtained by adding it to the input feature map. .
[0014] Preferably, the multi-path adaptive decoder generates the leaked oil segmentation results by including the following steps. C1, the multi-scale feature map obtained from the encoder by the multi-path adaptive decoder is {C1, C2, C3, C4} from shallow to deep layers; the multi-path adaptive decoder performs spatial modeling on feature map C1 through a spatial enhancement module, strengthening texture and edge features; the spatial enhancement module uses 1... After adjusting the channel dimensions using convolution, the data is fed into a four-branch structure for spatial feature extraction. The four-branch structure consists of 3... 3 depthwise convolution, 3 3 depth dilated convolution, 1 3-depth convolution and 3 1. Constructed by depthwise convolution, 3. 3D convolution can capture the local spatial dependencies of feature maps, with a dilation rate of 2. 3. Deep dilated convolution can expand the receptive field to capture contextual information. 3-depth convolution and 3 1. Depthwise convolution can capture spatial features in the horizontal and vertical directions respectively; the spatial augmentation module concatenates the feature maps generated by the four-branch structure and uses 1 1. Convolutional fusion to obtain spatial feature maps Space enhancement module for Edge feature enhancement is performed. In edge feature enhancement, the spatial enhancement module uses 1 3-group convolution and 3 1. Each group of convolutions independently extracts horizontal and vertical edge features within the feature channels, and then pointwise convolutions are used to fuse cross-channel features to obtain an edge enhancement feature map; C2, Multipath Adaptive Decoder uses 1 1. After adjusting the channel dimensions of the feature map {C2, C3, C4} using convolution, an upsampling operation is performed to ensure that the size of the feature map is consistent with that of feature map C1, thus obtaining the feature map. ; C3, the multi-path adaptive decoder will use the feature map splice and use 1 1. Convolution and Softmax activation functions fuse feature information at each pixel location to generate weights. The multi-path adaptive decoder will weight Divide into three equal parts, each corresponding to a feature map. Multiplication followed by addition completes dynamic semantic feature fusion to obtain the feature map. Multi-path adaptive decoder for feature maps Through 3 3. Convolution is used for feature optimization, aggregating local neighboring pixel feature information to obtain feature maps. ; C4, the multi-path adaptive decoder will convert the feature map , and Splice and feed into 1 1. Convolution and Softmax activation functions learn the features of each pixel to achieve feature complementarity and generate weights. ; weight Divide into three parts and respectively with feature map , and After multiplication, the features are added together to complete adaptive feature fusion and obtain the feature map. For feature maps Perform 3 The final fused feature map is obtained by three convolutional operations. ; C5, Path Adaptive Decoder via 1 1 convolution Mapping to the category space yields the final segmentation prediction result.
[0015] The beneficial effects of adopting the above technical solution are as follows: The statistical alignment-gated attention mechanism in this invention solves the problems of lack of feature distribution constraints and limited spatial feature representation ability in traditional standard self-attention mechanisms through feature alignment and adaptive gating fusion, helping the network to accurately identify oil leakage and shadow areas. The dynamic feature selection module utilizes the strong semantic information of deep features through local and global branches to help the network obtain important feature information. The multi-path adaptive decoder fully utilizes the rich spatial features in shallow feature maps and dynamically fuses multi-level feature maps to generate more accurate segmentation results. This invention can alleviate the problem of easy confusion between oil leakage and shadows during transformer oil leakage segmentation. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the present invention. Detailed Implementation
[0017] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit the present invention.
[0018] Reference Figure 1 A transformer oil leakage detection system based on an adaptive Transformer segmentation network includes, The Transformer module of statistical alignment gated attention is used to embed overlapping patches, then convert the input image into a patch sequence, which is then normalized by layers and fed into statistical alignment gated attention, followed by layer normalization and fed into a feedforward neural network. Finally, overlapping patches are merged to generate feature maps of different scales. The dynamic feature selection module is used to select important features from deep feature maps, solving the problems of local spatial detail loss and global channel information redundancy. A multi-path adaptive decoder is used to generate leaked oil segmentation results.
[0019] Compared to existing Transformer-based segmentation networks, this invention replaces the labeled self-attention in existing Transformer blocks with the statistically aligned gated attention proposed in this invention; this invention adds a dynamic feature selection module proposed in this invention after feature extraction in the fourth stage of the encoder; this invention replaces the existing Transformer decoder with the multi-path adaptive decoder proposed in this invention. The statistically aligned gated attention utilizes both global and local semantics to help the network focus on the shape and texture features of the leaking oil, and can solve the feature offset problem of the standard self-attention mechanism in existing Transformer blocks; the dynamic feature selection module can use multi-scale texture features and global context to help the network compensate for the feature loss problem caused by multiple downsampling in existing Transformer networks and reduce the redundancy of channel feature information; the multi-path adaptive decoder dynamically fuses feature maps of different levels through an adaptive fusion mechanism to alleviate the feature confusion effect caused by directly adding or splicing multi-level feature maps in the decoding stage of existing Transformer networks.
[0020] A transformer oil leakage detection method based on an adaptive Transformer segmentation network, implemented using the aforementioned transformer oil leakage detection system based on an adaptive Transformer segmentation network, includes the following steps: The Transformer module of statistical alignment-gated attention performs overlapping patch embedding, then converts the input image into a patch sequence, normalizes it, and feeds it into the statistical alignment-gated attention module. After further normalization, it is fed into a feedforward neural network, and finally, overlapping patches are merged to generate feature maps at different scales. Specifically, this includes... A1. Statistical alignment gating attention performs a linear mapping on the input feature map X to generate a query. ,key Sum For query s and keys By introducing the statistical distribution of the root mean square normalized stable dot product result, the stability of the attention dot product calculation is improved, and a normalized query is obtained. s and keys .
[0021] Existing standard self-attention mechanisms typically use a fixed scaling factor to normalize the dot product of the query vector and the key vector to alleviate training instability caused by excessively large numerical amplitudes. However, this fixed scaling method cannot be adjusted according to the distribution characteristics of different attention heads, lacking adaptive control over the attention distribution pattern, which can easily lead to some attention heads being too concentrated or too dispersed. Existing methods directly scale the attention weights or output results. In step A2 of this invention, the statistical alignment gating attention mechanism introduces a learnable temperature coefficient per attention head to adaptively scale the dot product results of different attention heads, and adjusts it through a normalization method coupled with the attention head dimension, calibrating the attention distribution pattern per attention head while ensuring numerical stability; the use of a Sigmoid mapping gives the temperature adjustment numerical constraints, avoiding attention distribution degradation; the scaling factor s h Defined as, , , in, This represents the Sigmoid activation function. Indicates learnable parameters, The parameter represents temperature, h represents the attention head order, and d represents the dimension per head; after obtaining the scaling factor, the aligned gating attention pairs are statistically analyzed for the query. s and keys Calculate attention score using matrix multiplication .
[0022] A3. Unlike existing technologies that typically use global context to generate gating coefficients and perform overall weighting on attention output or feature channels, statistical alignment gating attention sets a context-aware semantic bias. By directly injecting contextual information into the bias term of the attention score through head-by-head semantic scores and global context coefficients, fine-grained calibration of the attention distribution is achieved.
[0023] Context-aware semantic bias will query s and keys Source feature X q and X k Perform independent linear transformations to map to the semantic space corresponding to the number of attention heads, generating head-by-head scalar scores s q and s k Context-aware semantic bias will adjust the source feature X q Global average pooling is performed to obtain the global context vector, which is then input into a context-aware module consisting of two linear layers and a Gelu activation function to obtain the context coefficients c. The context coefficients c are defined as follows: , Here, L1 and L2 represent linear layers. L1 compresses the high-dimensional context vector to a low dimension to obtain useful context information, while L2 maps the compressed information dimension to a value consistent with the number of attention heads. This represents the Gelu activation function. This represents the Sigmoid activation function; finally, the head-by-head scalar score s is calculated. q and s k After multiplication, element-wise multiplication with the context coefficient c yields the complete bias term B; statistical alignment gating attention will... The final attention score is obtained by adding B, and the attention weight distribution is generated using the Softmax activation function. .
[0024] A4. The statistical alignment gating attention design incorporates a directional frequency domain collaborative enhancement module to enhance the input feature map, which is then passed through a linear layer to obtain the final feature map. Compared to existing standard self-attention modules that generate values V using only simple linear layers, this module helps the network obtain more fine-grained features.
[0025] The directional frequency domain co-operation module first uses a convolution kernel size of 1. 3,3 1 and 3 A depthwise separable convolution of size 3 extracts spatial features of the input feature map along its horizontal, vertical, and diagonal directions, respectively, using learnable weights. The feature maps extracted by convolution in different directions are weighted and summed to generate a feature map with directional feature information. The directional frequency domain coordination module utilizes different frequency domain feature information to... Averaging pooling to obtain low-frequency components helps the network focus on the shape and overall structure of the leaking oil, through calculation. The difference between low-frequency components generates high-frequency components to obtain the texture and edge features of the leaking oil; through a... Global average pooling features generate two gate signals for the input gating network. and , , , Where GAP represents global pooling operation, and Conv1 represents 1 1. Convolution operation, This represents the Gelu activation function. The sigmoid activation function is represented by 'Sigmoid', and 'Chunk' represents the separation operation. The directional frequency domain coordination module multiplies the low-frequency and high-frequency components with their corresponding gated signals, and then connects them to the gated signal via residuals. Add them together, then use a linear layer to obtain the result. .
[0026] A5. Statistical Alignment Gating Attention Pairs Perform statistical alignment to obtain the key The first-order and second-order statistics are consistent. ; , in, and Let represent the mean and standard deviation, respectively. Statistical alignment gating attention is calculated using the mean cosine similarity. The semantic consistency score is obtained based on the similarity between K and K. .
[0027] A6. Statistical alignment gating attention will and and Multiply by each to obtain and .
[0028] A7. To achieve stable attention fusion, statistical alignment-gated attention uses an adaptive gating fusion mechanism. and The integration.
[0029] In existing technologies, attention fusion typically employs a single gating or a single weight to linearly weight multiple features, or adjusts the fusion ratio based on a certain metric, making it difficult to guarantee the stability of the fusion process. Unlike existing technologies, the adaptive gating fusion mechanism of this invention includes uncertainty gating, credibility gating, and learnable gating per head.
[0030] In existing technologies, the entropy or uncertainty metric of attention weights is typically used as a regularization constraint or auxiliary loss term during the training phase to guide the smoothness of the attention distribution, rather than as a gating signal to directly control the feature fusion ratio. In contrast, uncertainty gating directly uses the normalized entropy of the attention weights. Help the network obtain gating signals Determine the reliability of the attention results and select the main dependent features; if the entropy is low, then rely on the enhanced features. Otherwise, it depends on the basic features. ; The calculation process is as follows: , Where t represents the learnable threshold and α represents the learnable slope. This represents the Sigmoid activation function.
[0031] In existing technologies, semantic similarity or consistency scores are typically used in attention weight calculation or feature matching stages to measure the correlation between different features; their role is primarily limited to the feature generation process. Credibility gating utilizes semantic consistency scores. The gating signal is obtained by utilizing a learnable threshold and slope. Determine the enhanced features Credibility, The calculation process is as follows: , in, β represents the learnable threshold, and β represents the learnable slope. This represents the Sigmoid activation function.
[0032] In existing technologies, multi-head attention mechanisms typically perform uniform weighting, concatenation, or linear transformation on the results of each attention head during the output stage. Since each attention head shares the same fusion strategy during the fusion process, it is difficult to reflect the differences in semantic modeling capabilities among different attention heads. In contrast, learnable gating per head obtains the gating signal. This allows different attention heads to achieve varying enhancement intensities during the fusion stage by leveraging their own semantic features and attention distribution characteristics, thus enabling collaboration between attention heads. The calculation process is as follows: , Where a and b represent learnable parameters, This represents the Sigmoid activation function. SAGA multiplies the three gated signals and then... and Multiply the differences and connect them with the residuals. Addition output Achieve adaptive attention fusion. The calculation process is as follows: .
[0033] The dynamic feature selection module selects important features from deep feature maps, addressing the issues of local spatial detail loss and global channel information redundancy. Specifically, it includes the following steps: In existing technologies, multi-scale local features are typically obtained through parallel convolution or simple feature concatenation. The lack of explicit selection or interaction mechanisms between features of different scales easily leads to scale redundancy. The dynamic feature selection module obtains multi-scale texture features through local branches; within these local branches, the dynamic feature selection module uses 3... 3. Standard convolution extracts spatial feature information from feature maps, and then uses 3... 3. Deep convolution captures spatial relationships within channels to obtain spatially enhanced feature maps. The dynamic feature selection module will select the feature map. Feature maps are obtained by evenly dividing along the channel dimension. and ; feature map and They were fed into 3 with expansion rates of 2 and 3 respectively. 3. Deep dilated convolution helps the network obtain multi-scale spatial feature maps under different receptive fields. and Feature map Feature map containing local edge feature information It has contextual features; the dynamic feature selection module will and Element-wise multiplication is performed to achieve adaptive selection of cross-scale features, retaining only discriminative features that respond at different scales. This suppresses scale redundancy and enhances the effectiveness of local features, resulting in a discriminative local feature map. Local feature map After 1 1. Convolution is used to increase the dimensionality of channels and obtain local feature maps. .
[0034] Existing global context modeling methods typically employ only a single global average pooling or channel attention to generate global weights, making it difficult to simultaneously consider both overall semantics and salient features. The dynamic feature selection module obtains global context information through a global branch. Within this global branch, the dynamic feature selection module first performs global average pooling and global max pooling respectively to model the global context, capturing global features and salient features to obtain feature maps. and ;Will and Feed into the shared bottleneck network, which contains two 1s. 1. Convolution operation, the first 1 The first convolution operation performs channel reduction to filter important global features, and the second 1 1. Convolutional operations are used to perform channel-level dimensionality enhancement to model the relationships between global features and obtain feature maps. and The dynamic feature selection module will select the feature map. and A concatenation operation is performed along the channel dimension to fuse global contextual information and obtain feature maps. , feature map Divide equally along the channel dimension and pass through 1 respectively. 1. Convolution and Sigmoid activation function yield two global weights and .
[0035] In existing technologies, local and global features are often fused by direct addition or concatenation, lacking a dynamic selection mechanism based on global semantics. This can easily lead to over-amplification of local details or global semantics. A dynamic feature selection module will incorporate global weights... With local feature map Element-wise multiplication yields feature maps This allows local feature maps to learn features with fine-grained spatial structure and semantics on a global dimension; the dynamic feature selection module applies global weights... Element-wise multiplication with the input feature map yields a feature map with global context. The dynamic feature selection module will select the feature map. and The final feature map is obtained by adding it to the input feature map. .
[0036] In existing feature enhancement or feature selection methods, local feature extraction and global context modeling are usually designed independently: one type of method focuses on extracting local texture or edge information through multi-scale convolution, but lacks global semantic constraints and is prone to introducing redundant or noisy features; another type of method models the global context through global pooling or channel attention, but its ability to select local fine-grained structures is limited, making it difficult to balance local discriminativity and global consistency. Therefore, existing technologies still have shortcomings in the collaborative selection and dynamic control of local and global features. To solve the above problems, this invention proposes a dynamic feature selection module, which achieves multi-scale local feature extraction in the feature generation stage through the collaborative design of local and global branches, and introduces global weights to dynamically control local and global features in the feature selection stage.
[0037] The multi-path adaptive decoder generates leaked oil segmentation results, specifically including the following steps. The multi-path adaptive decoder obtains multi-scale feature maps from the encoder, ranging from shallow to deep, as {C1, C2, C3, C4}. In existing technologies, shallow features are typically directly involved in subsequent fusion or simply processed using single-path convolution, making it difficult to fully exploit their spatial information across different directions and scales. The multi-path adaptive decoder uses a spatial enhancement module to spatially model feature map C1, strengthening texture and edge features; the spatial enhancement module uses 1... After adjusting the channel dimensions using convolution, the data is fed into a four-branch structure for spatial feature extraction. The four-branch structure consists of 3... 3 depthwise convolution, 3 3 depth dilated convolution, 1 3-depth convolution and 3 1. Constructed by depthwise convolution, 3. 3D convolution can capture the local spatial dependencies of feature maps, with a dilation rate of 2. 3. Deep dilated convolution can expand the receptive field to capture contextual information. 3-depth convolution and 3 1. Depthwise convolution can capture spatial features in the horizontal and vertical directions respectively; the spatial augmentation module concatenates the feature maps generated by the four-branch structure and uses 1 1. Convolutional fusion to obtain spatial feature maps Space enhancement module for Edge feature enhancement is performed. In edge feature enhancement, the spatial enhancement module uses 1 3-group convolution and 3 1. Each group of convolutions independently extracts horizontal and vertical edge features within the feature channels, and then pointwise convolutions are used to fuse cross-channel features to obtain an edge enhancement feature map.
[0038] The multipath adaptive decoder uses 1 1. After adjusting the channel dimensions of the feature map {C2, C3, C4} using convolution, an upsampling operation is performed to ensure that the size of the feature map is consistent with that of feature map C1, thus obtaining the feature map. .
[0039] In existing decoder architectures, multi-scale semantic features are typically fused after size alignment by adding them with fixed weights or by simple concatenation followed by convolution. This makes it difficult to select the most suitable semantic level for different pixel locations, resulting in a lack of adaptability. Multi-path adaptive decoders integrate feature maps... splice and use 1 1. Convolution and Softmax activation functions fuse feature information at each pixel location to generate weights. The multi-path adaptive decoder will weight Divide into three equal parts, each corresponding to a feature map. Multiplication followed by addition completes dynamic semantic feature fusion to obtain the feature map. Multi-path adaptive decoder for feature maps Through 3 3. Convolution is used for feature optimization, aggregating local neighboring pixel feature information to obtain feature maps. .
[0040] C4, the multi-path adaptive decoder will convert the feature map , and Splice and feed into 1 1. Convolution and Softmax activation functions learn the features of each pixel to achieve feature complementarity and generate weights. ; weight Divide into three parts and respectively with feature map , and After multiplication, the features are added together to complete adaptive feature fusion and obtain the feature map. For feature maps Perform 3 The final fused feature map is obtained by three convolutional operations. .
[0041] C5, Path Adaptive Decoder via 1 1 convolution Mapping to the category space yields the final segmentation prediction result.
[0042] In existing semantic segmentation or dense prediction tasks, decoders typically employ a top-down feature fusion structure, fusing multi-scale features from the encoder through upsampling and layer-by-layer addition or concatenation. However, such methods often suffer from the following shortcomings: on the one hand, while shallow features possess rich edge and texture information, their spatial modeling capabilities are limited, making it difficult to effectively enhance structural details; on the other hand, multi-scale semantic features often employ fixed weights or simple linear combinations during fusion, lacking pixel-level dynamic selection mechanisms, which can easily lead to semantic feature interference or edge information being covered by higher-level semantics, thus affecting the localization accuracy and semantic consistency in the decoding stage. To address these issues, this invention proposes a multi-path adaptive decoder that achieves refined modeling and fusion of spatial, edge, and semantic information in the decoding stage through spatial feature enhancement, multi-scale semantic adaptive fusion, and collaborative selection of multiple feature types.
[0043] To verify the superiority of this invention, it was compared with other methods on a transformer oil leakage image dataset. The ATSNet-S model of this invention is lightweight, while the ATSNet-L model is the best performing model. Mean Intersection over Union (mIou), Mean Precision (mP), and Mean Recall (mR) were used as accuracy evaluation metrics, parameter count as network size evaluation metrics, and giga-floating-point operations (GFLOPs) as network computational overhead evaluation metrics. The results are shown in Table 1. The results show that this invention can detect oil leakage more accurately than other methods, reduces the confusion between oil leakage and shadows compared to other segmentation methods, accurately identifies the boundaries between oil leakage and shadow regions, suppresses the influence of background noise on the segmentation results, and reduces false positives and false negatives.
[0044] Table 1. Comparison of results of different algorithms on transformer oil leakage image dataset.
[0045] This invention can alleviate the problem of easily confusing leaking oil with shadows during the identification of transformer oil leaks. Experiments have verified the effectiveness of this invention in transformer oil leak identification.
[0046] Finally, it should be noted that the above descriptions are merely preferred embodiments of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions described in the foregoing embodiments or make equivalent substitutions for some of the technical features. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A transformer oil leakage detection system based on an adaptive Transformer partitioning network, characterized in that: include, The Transformer module of statistical alignment gated attention is used to embed overlapping patches, then convert the input image into a patch sequence, which is then normalized by layers and fed into statistical alignment gated attention, followed by layer normalization and fed into a feedforward neural network. Finally, overlapping patches are merged to generate feature maps of different scales. The dynamic feature selection module is used to select important features from deep feature maps, solving the problems of local spatial detail loss and global channel information redundancy. A multi-path adaptive decoder is used to generate leaked oil segmentation results.
2. A transformer oil leakage detection method based on an adaptive Transformer partitioning network, implemented using the transformer oil leakage detection system based on an adaptive Transformer partitioning network as described in claim 1, characterized in that... Includes the following steps: The Transformer module of statistical alignment gated attention performs overlapping patch embedding, then converts the input image into a patch sequence, which is then normalized by layers and fed into the statistical alignment gated attention, followed by layer normalization and fed into the feedforward neural network. Finally, overlapping patches are merged to generate feature maps of different scales. The dynamic feature selection module selects important features from deep feature maps, solving the problems of local spatial detail loss and global channel information redundancy. The multi-path adaptive decoder generates the leakage oil segmentation results.
3. The transformer oil leakage detection method based on adaptive Transformer segmentation network according to claim 2, characterized in that: The statistically aligned gated attention Transformer module generates the lost feature maps through the following steps. A1. Statistical alignment gating attention performs a linear mapping on the input feature map X to generate a query. ,key Sum For query s and keys By introducing the statistical distribution of the root mean square normalized stable dot product result, the stability of the attention dot product calculation is improved, and a normalized query is obtained. s and keys ; A2. The statistical alignment-gated attention mechanism introduces a learnable temperature coefficient for each attention head to adaptively scale the dot product results of different attention heads. This scaling is achieved through a normalization method coupled to the attention head dimension, ensuring numerical stability while calibrating the attention distribution pattern head-by-head. A sigmoid mapping is used to impose numerical constraints on temperature adjustment, preventing attention distribution degradation. The scaling factor s... h Defined as, , , in, This represents the Sigmoid activation function. Indicates learnable parameters, The parameter represents temperature, h represents the attention head order, and d represents the dimension per head; after obtaining the scaling factor, the aligned gating attention pairs are statistically analyzed for the query. s and keys Calculate attention score using matrix multiplication ; A3. Statistical alignment gating attention sets context-aware semantic bias, directly injecting contextual information into the bias term of the attention score through head-by-head semantic score and global context coefficient, and performing fine-grained calibration of attention distribution; A4. The statistical alignment gating attention design incorporates a directional frequency domain collaborative enhancement module to enhance the input feature map, which is then passed through a linear layer to obtain the final feature map. ; A5. Statistical Alignment Gating Attention Pairs Perform statistical alignment to obtain the key The first-order and second-order statistics are consistent. ; , in, and Let represent the mean and standard deviation, respectively. Statistical alignment gating attention is calculated using the mean cosine similarity. The semantic consistency score is obtained based on the similarity between K and K. ; A6. Statistical alignment gating attention will and and Multiply by each to obtain and ; A7. Statistical alignment gating attention is implemented using an adaptive gating fusion mechanism. and The integration.
4. The transformer oil leakage detection method based on adaptive Transformer partitioning network according to claim 3, characterized in that: Step A3 includes, Context-aware semantic bias will query s and keys Source feature X q and X k Perform independent linear transformations to map to the semantic space corresponding to the number of attention heads, generating head-by-head scalar scores s q and s k Context-aware semantic bias will adjust the source feature X q Global average pooling is performed to obtain the global context vector, which is then input into a context-aware module consisting of two linear layers and a Gelu activation function to obtain the context coefficients c. The context coefficients c are defined as follows: , Here, L1 and L2 represent linear layers. L1 compresses the high-dimensional context vector to a low dimension to obtain useful context information, while L2 maps the compressed information dimension to a value consistent with the number of attention heads. This represents the Gelu activation function. This represents the Sigmoid activation function; finally, the head-by-head scalar score s is calculated. q and s k After multiplication, element-wise multiplication with the context coefficient c yields the complete bias term B; statistical alignment gating attention will... The final attention score is obtained by adding B, and the attention weight distribution is generated using the Softmax activation function. .
5. The transformer oil leakage detection method based on adaptive Transformer segmentation network according to claim 4, characterized in that: Step A4 includes, The directional frequency domain co-operation module first uses a convolution kernel size of 1. 3,3 1 and 3 A depthwise separable convolution of size 3 extracts spatial features of the input feature map along its horizontal, vertical, and diagonal directions, respectively, using learnable weights. The feature maps extracted by convolution in different directions are weighted and summed to generate a feature map with directional feature information. The directional frequency domain coordination module utilizes different frequency domain feature information to... Averaging pooling to obtain low-frequency components helps the network focus on the shape and overall structure of the leaking oil, through calculation. The difference between low-frequency components generates high-frequency components to obtain the texture and edge features of the leaking oil; through a... Global average pooling features generate two gate signals for the input gating network. and , , , Where GAP represents global pooling operation, and Conv1 represents 1 1. Convolution operation, This represents the Gelu activation function. The sigmoid activation function is represented by 'Sigmoid', and 'Chunk' represents the separation operation. The directional frequency domain coordination module multiplies the low-frequency and high-frequency components with their corresponding gated signals, and then connects them to the gated signal via residuals. Add them together, then use a linear layer to obtain the result. .
6. The transformer oil leakage detection method based on adaptive Transformer segmentation network according to claim 5, characterized in that: Step A7 includes, Adaptive gating fusion mechanisms include uncertainty gating, credibility gating, and learnable gating per head; Uncertainty gating directly uses the normalized entropy of attention weights. Help the network obtain gating signals Determine the reliability of the attention results and select the main dependent features; if the entropy is low, then rely on the enhanced features. Otherwise, it depends on the basic features. ; The calculation process is as follows: , Where t represents the learnable threshold and α represents the learnable slope. This represents the Sigmoid activation function; Trustworthiness gating is achieved through semantic consistency scores. The gating signal is obtained by utilizing a learnable threshold and slope. Determine the enhanced features Credibility, The calculation process is as follows: , in, β represents the learnable threshold, and β represents the learnable slope. This represents the Sigmoid activation function; Learnable gating to obtain gating signals This allows different attention heads to achieve varying enhancement intensities during the fusion stage by leveraging their own semantic features and attention distribution characteristics, thus enabling collaboration between attention heads. The calculation process is as follows: , Where a and b represent learnable parameters, This represents the Sigmoid activation function. SAGA multiplies the three gated signals and then... and Multiply the differences and connect them with the residuals. Addition output Achieve adaptive attention fusion. The calculation process is as follows: 。 7. The transformer oil leakage detection method based on adaptive Transformer segmentation network according to claim 2, characterized in that: The dynamic feature selection module selects important features from the deep feature map, including the following steps. B1. The dynamic feature selection module obtains multi-scale texture features through local branches; within the local branches, the dynamic feature selection module uses 3...
3. Standard convolution extracts spatial feature information from feature maps, and then uses 3...
3. Deep convolution captures spatial relationships within channels to obtain spatially enhanced feature maps. ; The dynamic feature selection module will select feature maps Feature maps are obtained by evenly dividing along the channel dimension. and ; feature map and They were fed into 3 with expansion rates of 2 and 3 respectively.
3. Deep dilated convolution helps the network obtain multi-scale spatial feature maps under different receptive fields. and Feature map Feature map containing local edge feature information It has contextual features; The dynamic feature selection module will and Element-wise multiplication is performed to achieve adaptive selection of cross-scale features, retaining only discriminative features that respond at different scales. This suppresses scale redundancy and enhances the effectiveness of local features, resulting in a discriminative local feature map. Local feature map After 1 1. Convolution is used to increase the dimensionality of channels and obtain local feature maps. ; B2. The dynamic feature selection module obtains global context information through global branches; In the global branch, the dynamic feature selection module first uses global average pooling and global max pooling to perform global context modeling, capturing global features and salient features to obtain feature maps. and ;Will and Feed into the shared bottleneck network, which contains two 1s.
1. Convolution operation, the first 1 The first convolution operation performs channel reduction to filter important global features, and the second 1 1. Convolutional operations are used to perform channel-level dimensionality enhancement to model the relationships between global features and obtain feature maps. and ; The dynamic feature selection module will select feature maps and A concatenation operation is performed along the channel dimension to fuse global contextual information and obtain feature maps. , feature map Divide equally along the channel dimension and pass through 1 respectively.
1. Convolution and Sigmoid activation function yield two global weights and ; B3. The dynamic feature selection module will apply global weights. With local feature map Element-wise multiplication yields feature maps This allows local feature maps to learn features with fine-grained spatial structure and semantics on a global dimension; the dynamic feature selection module applies global weights... Element-wise multiplication with the input feature map yields a feature map with global context. ; The dynamic feature selection module will select feature maps and The final feature map is obtained by adding it to the input feature map. .
8. The transformer oil leakage detection method based on adaptive Transformer segmentation network according to claim 2, characterized in that: The multi-path adaptive decoder generates leaked oil segmentation results through the following steps: C1, the multi-scale feature map obtained from the encoder by the multi-path adaptive decoder, is {C1, C2, C3, C4} from shallow to deep layers; the multi-path adaptive decoder performs spatial modeling on feature map C1 through a spatial enhancement module, strengthening texture and edge features; spatial The enhancement module uses 1 on C1 After adjusting the channel dimensions using convolution, the data is fed into a four-branch structure for spatial feature extraction. The four-branch structure consists of 3... 3 depthwise convolution, 3 3 depth dilated convolution, 1 3-depth convolution and 3 1. Constructed by depthwise convolution, 3. 3D convolution can capture the local spatial dependencies of feature maps, with a dilation rate of 2.
3. Deep dilated convolution can expand the receptive field to capture contextual information. 3-depth convolution and 3 1. Depthwise convolution can capture spatial features in both the horizontal and vertical directions, respectively; The spatial augmentation module stitches together the feature maps generated by the four-branch structure and uses 1 1. Convolutional fusion to obtain spatial feature maps Space enhancement module for Edge feature enhancement is performed. In edge feature enhancement, the spatial enhancement module uses 1 3-group convolution and 3 1. Each group of convolutions independently extracts horizontal and vertical edge features within the feature channels, and then pointwise convolutions are used to fuse cross-channel features to obtain an edge enhancement feature map; C2, Multipath Adaptive Decoder uses 1 1. After adjusting the channel dimensions of the feature map {C2, C3, C4} using convolution, an upsampling operation is performed to ensure that the size of the feature map is consistent with that of feature map C1, thus obtaining the feature map. ; C3, the multi-path adaptive decoder will use the feature map splice and use 1 1. Convolution and Softmax activation functions fuse feature information at each pixel location to generate weights. The multi-path adaptive decoder will weight Divide into three equal parts, each corresponding to a feature map. Multiplication followed by addition completes dynamic semantic feature fusion to obtain the feature map. Multi-path adaptive decoder for feature maps Through 3 3. Convolution is used for feature optimization, aggregating local neighboring pixel feature information to obtain feature maps. ; C4, the multi-path adaptive decoder will convert the feature map , and Splice and feed into 1 1. Convolution and Softmax activation functions learn the features of each pixel to achieve feature complementarity and generate weights. ; weight Divide into three parts and respectively with feature map , and After multiplication, the features are added together to complete adaptive feature fusion and obtain the feature map. For feature maps Perform 3 The final fused feature map is obtained by three convolutional operations. ; C5, Path Adaptive Decoder via 1 1 convolution Mapping to the category space yields the final segmentation prediction result.