A gas diffusion layer fiber binder segmentation method based on global and local feature fusion
By fusing global and local features, and combining feature aggregation and interaction modules, the VisionTransformer model was improved, which solved the problem of insufficient accuracy in the segmentation of gas diffusion layer fibers and binder, and achieved a more accurate segmentation effect.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TONGJI UNIV
- Filing Date
- 2026-03-10
- Publication Date
- 2026-06-09
AI Technical Summary
Existing technologies struggle to effectively capture global and local features during the segmentation of gas diffusion layer fibers and binders, resulting in insufficient segmentation accuracy, especially at complex texture boundaries where misjudgment and omissions are common.
By employing a global and local feature fusion approach, and designing a global and local feature aggregation module (GLIB), a high-low resolution feature interaction module (LBWA), and a large kernel convolutional attention module (LKAT), combined with data preprocessing and enhancement strategies, an improved VisionTransformer segmentation model is constructed to achieve accurate segmentation of fibers and adhesives.
It improves the segmentation accuracy of SEM images of gas diffusion layers, accurately segmenting the background, carbon fiber, and binder regions, providing reliable quantification data of microstructure, and exhibiting good generalization and segmentation performance.
Smart Images

Figure CN122176302A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of material microscopic image segmentation, specifically a gas diffusion layer fiber binder segmentation method based on the fusion of global and local features. Background Technology
[0002] Microscopic images of materials can reveal their structure, distribution, and defects, providing researchers with information on the distribution of components and their coupling relationships. This offers insights into material properties and pathways for future optimization. In the gas diffusion layer material of proton exchange membrane fuel cells, fibers and binders are distributed in a disordered and interwoven manner. Typically, fibers are long and span long areas of the image, while the binder consists of large, amorphous blocks and smaller, more similar shapes. In such cases, researchers need to expend considerable effort to distinguish the components, which is susceptible to subjective biases leading to misclassification and omissions. Therefore, employing a suitable neural network structure for effective automatic segmentation is essential.
[0003] Deep learning, with its powerful learning capabilities, has been introduced into the field of material segmentation. U-Net and its derivatives are widely used in image segmentation in materials science. Their architecture has an excellent ability to capture local texture details and achieves relatively accurate image segmentation with a relatively simple structure. However, pure convolutional methods focus more on texture information and have shortcomings in constructing long-distance spatial relationships. Transformer is an architecture that is good at establishing long-distance dependencies and replaces the convolutional method with a pure attention mechanism. On this basis, the TransUNet architecture uses Transformer to encode CNN feature maps, achieving accurate localization while restoring local details. However, it is difficult to effectively extract the connections in complex features using only unmodified TransUNet or UNet.
[0004] Therefore, it is evident that the neural network model structure should be improved, and feature engineering should be implemented according to the task to adjust the network structure. Capturing both global and local features helps to enhance segmentation at boundaries. However, most current research on fiber and adhesive segmentation focuses on obtaining accurate, high-resolution datasets; methods to improve segmentation accuracy by optimizing the model itself still need further development. Summary of the Invention
[0005] The purpose of this invention is to propose a gas diffusion layer fiber binder segmentation method based on global and local feature fusion to improve the segmentation accuracy of SEM images of gas diffusion layers. This invention designs a global and local feature aggregation module (GLIB), a high-low resolution feature interaction module (LBWA), and a large kernel convolutional attention (LKAT) module. Global features enhance the localization of fibers and binders, while local features help identify boundaries and small pieces of binder. The boundary features of fibers and binders are aggregated and iteratively weighted. Combined with targeted data preprocessing and enhancement strategies, accurate segmentation of three types of regions—background, carbon fibers, and binder—is achieved, providing reliable quantitative data on the microstructure of gas diffusion layers for structural performance analysis.
[0006] To achieve the above objectives, the technical solution adopted by the present invention is as follows: A method for segmenting gas diffusion layer fiber binders based on the fusion of global and local features includes the following steps: S1: Acquire SEM images of the gas diffusion layer and preprocess the acquired SEM images; manually annotate the SEM images after grayscale balancing to generate mask label images corresponding to the SEM images; S2: Data Augmentation: Perform data augmentation operations simultaneously on the SEM images obtained in step S1 and the corresponding mask label images to finally obtain the image dataset; S3: Construct an improved VisionTransformer (ViT) segmentation model: The model includes a Transformer encoder, a GLIB module, an LBWA module, a DecoderCup decoder, an LKAT module, and a SegmentationHead segmentation head; GLIB fuses global context features and local details, and LBWA performs interactive fusion of high- and low-level features; the fused features are decoded by the decoder to obtain the segmentation result; Step S4, Model Training and Inference: The image dataset obtained in Step S2 is divided into a training set and a test set according to a preset ratio. The training set is input into the improved VisionTransformer segmentation model constructed in Step S3 to carry out model training. After the model training converges and reaches the preset accuracy requirement, the SEM image of the gas diffusion layer to be segmented is input into the trained improved segmentation model, and the model outputs the image segmentation results of the fiber phase and binder phase in the gas diffusion layer.
[0007] Furthermore, the preprocessing process in step S1 specifically involves converting the original gas diffusion layer SEM image into an 8-bit bit-depth format and uniformly cropping the converted image to match the size of the cropped image with the input size of the improved segmentation model.
[0008] Furthermore, the data augmentation operations in step S2 include random rotation (rotation angle range of 0°-360°), horizontal / vertical flipping, and random sliding window cropping. The original images in the gas diffusion layer image dataset are cropped to the preset model input size. The cropped original images are converted into tensor types and normalized to serve as input images. The label images in the gas diffusion layer image dataset are cropped to the same size. The cropped label images are converted into tensor types and together with the input images constitute training samples.
[0009] Furthermore, the Transformer encoder described in step S3 is used to transform the input image into sequence features containing global context, including an embedding layer and an encoder layer.
[0010] Furthermore, the Embedding layer segments the image into smaller pixel patches using the PatchEmbed module, transforms them into feature vectors through convolution, and then superimposes them with the learnable positional embedding vector PosEmbed to obtain the sequence features Embeddings = PatchEmbed(x) + PosEmbed; the Encoder layer consists of 12 stacked blocks, each containing an attention layer and an MLP layer, and enhances the flow of features through residual connections and LayerNorm. ; ; Where x is the input feature, x1 is the attention output, and x2 is the normalized input of the MLP layer. The MLP layer uses the GELU activation function to achieve feature mapping through two linear transformations: .
[0011] Furthermore, the GLIB module is used to fuse global context and local detail features, and its structure includes projection convolutional layers, QKV convolutional layers, and depthwise separable convolutional layers; the feature processing is as follows: Let the input feature map be Where B is the batch size, C is the number of channels, and H and W are the image height and width, respectively, the projection features are obtained after processing by the projection convolutional layer. ; Will Based on channels, it is divided into global branch features. g Local branching features l , ; The global branch generates a query vector q, a key vector k, and a value vector v through a QKV convolutional layer, satisfying... , Based on the query vector With key vector Calculate attention weights and apply them to the value vector. Perform weighted summation to obtain the global output features. ; For the local branch features Depthwise separable convolution and point convolution are performed sequentially to obtain local output features. ; The global output features With local output features The features are concatenated and fused using convolution operations to obtain the module output features; Flatten and transpose q, k, and v to obtain sequence features. , , Attention calculation satisfies: ; Local branches are processed using depthwise separable convolutions and point convolutions, satisfying... ; The final fusion features satisfy .
[0012] This module uses a gating mechanism to adaptively balance global contextual information with local detail features at the feature level, enhancing the model's ability to perceive complex texture boundaries.
[0013] Furthermore, in the GLIB module, let the convolutional features be... The global features of Transformer are First, channel alignment and normalization were performed. , get and The importance of different features is dynamically adjusted by calculating channel attention weights, specifically as follows: ; in, For global average pooling, This represents vector concatenation. , For the weights of the fully connected layer, This is the Sigmoid activation function.
[0014] Finally, feature weighting and fusion are performed based on the weights. Feature reshaping is performed using 3×3 convolution. .
[0015] Furthermore, the LBWA module is mainly used to achieve interactive fusion of high- and low-level features, with high-resolution features as input. With low-resolution features The processing procedure is as follows: Convolutional dimensionality reduction is performed on the high-resolution features and low-resolution features respectively to obtain intermediate features: ; Where H mid With L mid These are intermediate features for high-level and low-level structures, respectively. Weight coefficients for high-level and low-level layers are generated based on the corresponding intermediate features, satisfying: ;
[0016] The boundary weights are calculated using convolution operations on the low-resolution intermediate features. : ;
[0017] The intermediate features are weighted based on the weight coefficients and boundary weights to obtain enhanced features at higher and lower levels: ; ; in, This represents element-wise multiplication; The enhanced high-resolution features are concatenated with the low-resolution features, and then fused using convolution to obtain the module output feature `out`. LBWA : ; Furthermore, let the low-level features be... High-level characteristics are C represents the number of channels, and H and W represent the feature map height and width, respectively. First, the high-level features are upsampled to match the spatial size: Then, through channel alignment mapping, we obtain... ,in These are the convolution weights.
[0018] Furthermore, the module employs a bidirectional weighted aggregation mechanism: ; in, This represents element-wise multiplication. It is the Sigmoid activation function. These are the learnable weighting coefficients.
[0019] Furthermore, the DecoderCup decoder mentioned in step S3 is used to implement multi-scale feature fusion and resolution restoration, including a head convolutional layer, four DecoderBlock modules, and a feature projection layer; the feature fusion process of the DecoderBlock module satisfies: Let the input high-resolution features be Low-resolution jump features are First of all Upsampling: ; like and Inconsistent resolution, for Interpolation alignment: ; Feature concatenation and convolution processing satisfy: ; ; BN stands for Batch Normalization.
[0020] Furthermore, the LKAT module enhances the context capture capability of tail features through large kernel convolution, input features After 1×1 convolution and GELU activation: ;Calculate the weighted attention to obtain The attention weights obtained Perform feature-weighted output: ; Furthermore, the Segmentation Head is used to output the final segmentation result, and its structure includes a 3×3 convolutional layer and an upsampling layer, satisfying: ,in For the output features of the Decodercup decoder, s This is the upsampling factor, and , .in , The feature resolution of the height and width of the decoder output image. , The resolution of the height and width of the original input image.
[0021] In step S4, the model training uses the cross-entropy loss function, and the loss calculation satisfies: Let the segmentation probability map output by the model be... The corresponding mask tag is Then the cross-entropy loss is: B stands for Batch, and H and W correspond to the height and width of the image. This means that the model predicts the true label at pixel (i,j) in the b-th sample. The probability; during training, the Adam optimizer is used, and the learning rate is adjusted through a cosine annealing strategy.
[0022] Furthermore, the specific training process is as follows: set the loss function, adopt the AdamW optimizer, set the initial learning rate and decay weights, and dynamically adjust them using a multinomial decay strategy.
[0023] Compared with the prior art, the beneficial effects of the present invention are as follows: 1. This invention relates to an effective method for segmenting gas diffusion layer fiber binder based on the fusion of global and local features. The neural network involved can improve the feature utilization rate of gas diffusion layer material images and accurately segment the target. 2. The image segmentation network for the gas diffusion layer involved proposes a global and local feature fusion module GLIB and a boundary weight learning feature interaction module LBWA; 3. Experiments have demonstrated the effectiveness of the proposed network in gas diffusion layer image segmentation, showing good generalization ability. Attached Figure Description
[0024] Figure 1 This is a schematic flowchart of the gas diffusion layer fiber adhesive segmentation method based on the fusion of global and local features in this invention.
[0025] Figure 2 This is a schematic diagram of the gas diffusion layer fiber binder segmentation network based on the fusion of global and local features in this invention.
[0026] Figure 3 This is a comparison chart of the visualization results obtained by segmentation in this invention. Detailed Implementation
[0027] To make the objectives, technical solutions, and beneficial effects of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments; it should be understood that these descriptions are merely exemplary and are not intended to limit the scope of the invention.
[0028] This invention proposes a gas diffusion layer fiber binder segmentation method based on the fusion of global and local features. It constructs a global and local feature aggregation module (GLIB), a high-low resolution feature interaction module (LBWA), and a large kernel convolutional attention (LKAT) module. Global features enhance the localization of fibers and binders, while local features help identify boundaries and small pieces of binder. The boundary features of fibers and binders are aggregated and weighted iteratively. A decoder is used to combine information at different scales, refine the information recovery, and improve segmentation quality. The following detailed description, in conjunction with the accompanying drawings and embodiments, further illustrates this method.
[0029] This embodiment provides a gas diffusion layer fiber binder segmentation method based on the fusion of global and local features. It uses the PyTorch deep learning framework by default, and its flowchart is shown below. Figure 1 As shown, the specific steps include: Step S1: Acquire SEM images of the gas diffusion layer, including multiple SEM images at 200x and 1000x magnification. Preprocess the acquired SEM images; manually annotate the processed SEM images using the grayscale histogram method to generate mask label images corresponding to the SEM images. Step S2: Data Augmentation: Perform random cropping, rotation, and flipping operations on the SEM images and their corresponding mask label images simultaneously to crop the images to 128*128 pixels, thus obtaining the final image dataset; The obtained dataset consists of 1564 training images and mask images, and 400 prediction images and mask images.
[0030] Step S3: Construct the improved Vision Transformer segmentation model: The model includes a Transformer encoder, a GLIB module, an LBWA module, a DecoderCup decoder, an LKAT module, and a SegmentationHead segmentation head; Step S4: Model Training and Inference: Divide the image dataset obtained in Step S3 into a training set and a test set, input the improved VisionTransformer segmentation model constructed in Step S3 for training, input the SEM image of the gas diffusion layer to be segmented after training, and output the segmentation results of fibers and binders.
[0031] The preprocessing process in step S1 specifically involves converting the original gas diffusion layer SEM image into an 8-bit bit-depth format and uniformly cropping the converted image to match the size of the cropped image with the input size of the improved segmentation model.
[0032] The data augmentation operations in step S2 include random rotation (rotation angle range of 0°-360°), horizontal / vertical flipping, and random sliding window cropping. The original images in the gas diffusion layer image dataset are cropped to the preset model input size. The cropped original images are converted into tensor types and normalized to serve as input images. The label images in the gas diffusion layer image dataset are cropped to the same size. The cropped label images are converted into tensor types and together with the input images constitute training samples.
[0033] Furthermore, the Transformer encoder described in step S3 is used to transform the input image into sequence features containing global context, including an embedding layer and an encoder layer. Furthermore, the Embedding layer segments the image into smaller pixel patches using the PatchEmbed module, transforms them into feature vectors through convolution, and then superimposes them with the learnable positional embedding vector PosEmbed to obtain the sequence features Embeddings = PatchEmbed(x) + PosEmbed; the Encoder layer consists of 12 stacked blocks, each containing an attention layer and an MLP layer, and enhances the flow of features through residual connections and LayerNorm. ; ; Where x is the input feature, x1 is the attention output, and x2 is the normalized input of the MLP layer. The MLP layer uses the GELU activation function to achieve feature mapping through two linear transformations: .
[0034] In this embodiment, the PatchEmbed module divides the input image into non-overlapping 16*16 patches. Each patch is linearly mapped to a length... The vector, if the input is a single channel, will be copied to the three channels first.
[0035] Furthermore, the GLIB module mentioned in step S3 is used to fuse global context and local detail features. Its structure includes a projection convolutional layer, a QKV convolutional layer, and a depthwise separable convolutional layer. The feature processing procedure is as follows: Let the input feature map be Where B is the batch size, C is the number of channels, and H and W are the image height and width, respectively, the projection features are obtained after processing by the projection convolutional layer. ; Will Based on channels, it is divided into global branch features. g Local branching features l , ; The global branch generates a query vector q, a key vector k, and a value vector v through a QKV convolutional layer, satisfying... , Based on the query vector With key vector Calculate attention weights and apply them to the value vector. Perform weighted summation to obtain the global output features. ; For the local branch features Depthwise separable convolution and point convolution are performed sequentially to obtain local output features. ; The global output features With local output features The features are concatenated and fused using convolution operations to obtain the module output features; Flatten and transpose q, k, and v to obtain sequence features. , , Attention calculation satisfies: ; Local branches are processed using depthwise separable convolutions and point convolutions, satisfying... ; The final fusion features satisfy .
[0036] This module uses a gating mechanism to adaptively balance global contextual information with local detail features at the feature level, enhancing the model's ability to perceive complex texture boundaries.
[0037] Furthermore, in the GLIB module, let the convolutional features be... The global features of Transformer are First, channel alignment and normalization were performed. , get and The importance of different features is dynamically adjusted by calculating channel attention weights, specifically as follows: ; in, For global average pooling, This represents vector concatenation. , For the weights of the fully connected layer, This is the Sigmoid activation function.
[0038] Finally, feature weighting and fusion are performed based on the weights. Feature reshaping is performed using 3×3 convolution. .
[0039] Furthermore, the LBWA module mentioned in step S3 is mainly used to realize the interactive fusion of high- and low-level features, with high-resolution features as input. With low-resolution features The processing procedure is as follows: Convolutional dimensionality reduction is performed on the high-resolution features and low-resolution features respectively to obtain intermediate features: ; Where H mid With L mid These are intermediate features for high-level and low-level structures, respectively. Weight coefficients for high-level and low-level layers are generated based on the corresponding intermediate features, satisfying: ; The boundary weights are calculated using convolution operations on the low-resolution intermediate features. : ; The intermediate features are weighted based on the weight coefficients and boundary weights to obtain enhanced features at higher and lower levels: ; ; in, This represents element-wise multiplication; The enhanced high-resolution features are concatenated with the low-resolution features, and then fused using convolution to obtain the module output feature `out`. LBWA : .
[0040] Furthermore, let the low-level features be... High-level characteristics are C represents the number of channels, and H and W represent the feature map height and width, respectively. First, the high-level features are upsampled to match the spatial size: Then, through channel alignment mapping, we obtain... ,in These are the convolution weights.
[0041] Furthermore, the LBWA module employs a bidirectional weighted aggregation mechanism: ;
[0042] in, This represents element-wise multiplication. It is the Sigmoid activation function. These are the learnable weighting coefficients.
[0043] Furthermore, the DecoderCup decoder mentioned in step S3 is used to implement multi-scale feature fusion and resolution restoration, including a head convolutional layer, four DecoderBlock modules, and a feature projection layer; the feature fusion process of the DecoderBlock module satisfies: Let the input high-resolution features be Low-resolution jump features are First of all Upsampling: ; like and Inconsistent resolution, for Interpolation alignment: ; Feature concatenation and convolution processing satisfy: ; ; BN stands for Batch Normalization.
[0044] Furthermore, the LKAT module enhances the context capture capability of tail features through large kernel convolution, input features After 1×1 convolution and GELU activation: ;Calculate the weighted attention to obtain The attention weights obtained Perform feature-weighted output: .
[0045] Furthermore, the Segmentation Head is used to output the final segmentation result, and its structure includes a 3×3 convolutional layer and an upsampling layer, satisfying: ,in For the output features of the Decodercup decoder, s This is the upsampling factor, and , .in , The feature resolution of the height and width of the decoder output image. , The resolution of the height and width of the original input image.
[0046] In step S4, the model training uses the cross-entropy loss function, and the loss calculation satisfies: Let the segmentation probability map output by the model be... The corresponding mask tag is Then the cross-entropy loss is: B stands for Batch, and H and W correspond to the height and width of the image. This means that the model predicts the true label at pixel (i,j) in the b-th sample. The probability; during training, the Adam optimizer is used, and the learning rate is adjusted through a cosine annealing strategy.
[0047] Furthermore, the specific training process is as follows: set the loss function, adopt the AdamW optimizer, set the initial learning rate and decay weights, and dynamically adjust them using a multinomial decay strategy.
[0048] In this embodiment, the structure of the gas diffusion layer fiber binder segmentation network that integrates global and local features is as follows: Figure 2 As shown, its specific implementation principle and process are as follows: The PatchEmbed module outputs a shape that is The token sequence is obtained by flattening or transposing: When inputting a 128*128 pixel image, the following is generated: The output encoding.
[0049] The TransformEncoder performs L-layer encoding on T0. The single-layer attention mechanism (multi-head) is computed as follows: , , ; ; The output is still The result after reshaping is .
[0050] Furthermore, a hybrid backbone is used to return multi-scale skip features: The high-level skip shape for C4 is (B, 512, 8, 8); the shape for C3 is (B, 512, 16, 16); and the shape for C2 is (B, 64, 32, 32). These skip features will be used in the Decoder and LBWA module. C1 is a low-level feature for channel expansion, containing rich texture details, with a shape of (B, 16, 128, 128).
[0051] Furthermore, regarding the GLIB module: The GLIB module aligns and adaptively fuses the global semantic information of the Transformer with the local texture information of the convolution in terms of spatial resolution and channel dimension, ensuring that boundary details and global consistency coexist.
[0052] The 2D feature map reconstructed from the input global token: Reshape to obtain .
[0053] Local convolution features In this embodiment, we take... Or other upstream features of the decoder to match the scale; assume the local feature size used for GLIB fusion is (B, 512, 8, 8).
[0054] First, align the channels with the scale, then normalize the channels individually to obtain the results. and .
[0055] To avoid information conflicts caused by simple addition, a gating fusion mechanism is adopted. Gating function ; in For Sigmoid, final fusion: , Output If the subsequent decoder requires a different resolution, it will interpolate to the target space as needed, for example, aligning to 32x32 in C2: .
[0056] GLIB can precisely guide the enhancement of local texture features. The gating mechanism ensures that global information is preferentially preserved in dense fiber areas and more global semantics are introduced in porous or large-scale structural areas, improving boundary integrity and consistency.
[0057] Furthermore, regarding the LBWA module: The module implements bidirectional weighted aggregation of high-level semantics and low-level boundary details on the multi-layer residual link path of the decoder, which enhances boundary localization and suppresses semantic misclassification.
[0058] The input consists of two sets of features, either from the encoder or from two levels of features in the previous decoder: High-level characteristics Low-level features ; Will Upsampling to match Spatial scale: ; If the number of channels is inconsistent, then perform a 1×1 projection. and .
[0059] Calculate the weighted graph of higher layers guiding lower layers and the weighted graph of lower layers guiding higher layers: Furthermore, the process of higher levels guiding lower levels is as follows: ; ; Weighting the lower layers: ; The process of lower-level units guiding higher-level units is as follows: ; Obtained through channel scaling ; in For Sigmoid, GlobalPool is used to generate channel descriptors using global average pooling, and Softmax is used to generate spatial attention distribution.
[0060] The two sets of information are fused and refined using convolution, followed by BN+ReLU: ; in input , Output after fusion .
[0061] To ensure training stability, residual connections are used. .
[0062] The results can be directly used as the concatenation input for a certain stage of the decoder or as the lower-level input for the next stage of LBWA, forming a series or parallel structure between layers.
[0063] After receiving the projection, DecoderCup maps the token to (B, 512, 8, 8), such as Figure 2 As shown, the original VITToken shape is (B, 768, H / 16, W / 16). From the original image, feature maps C1 to C4 are obtained through progressive convolution, with shapes C1(B, 16, H, W), C2(B, 64, H / 2, W / 2), C3(B, 256, H / 4, W / 4), and C4(B, 512, H / 8, W / 8), respectively. Since the image data used in this example is all 128*128 pixels, H=W=128. The token processed by the GLIB module is upsampled to DEC1, which is then concatenated with the GLIB-integrated C4 feature map to obtain DEC2. The C2 and C3 feature maps are input into the LBWA module for feature integration, resulting in C3_LBWA features, which are then concatenated with DEC2 and upsampled to DEC3. After fusing C2 and DEC3, DEC4 is obtained and combined with the lower-level C1 features to finally restore the size to 128*128, producing the segmentation result. The final output (4, 16, 128, 128) is output by SegHead as (4, 3, 128, 128).
[0064] Furthermore, step S4 requires setting a loss function for training, using a combination of Dice and cross-entropy CE: ; in, This is the final mixture loss value, where Y is the true label. The model's predicted output. , These are weighting coefficients, representing their respective contributions to the loss; It is the cross-entropy loss, which measures the difference between the distribution of predicted probabilities and the true labels. Dice is defined as: ;
[0065] Where, p i The predicted value of the i-th sample in the prediction results, g i The true value of the i-th sample in the true label. It is a very small constant used to improve computational stability.
[0066] Example of training hyperparameters: AdamW optimizer, initial learning rate Batch size The number of training rounds depends on the size of the dataset (e.g., 200 rounds); the learning rate uses a cosine annealing or step decay strategy.
[0067] Furthermore, the image of the gas diffusion layer to be segmented is cropped to a preset size and then input into the gas diffusion layer segmentation model, which outputs the segmentation result.
[0068] The performance of the above model is then tested using a test set to further illustrate the beneficial effects of the present invention.
[0069] Dice coefficient and IoU are used as evaluation metrics to obtain the corresponding model evaluation values. Dice coefficient is usually used to calculate the similarity between two true values and predictions, and its value ranges from 1 to 2. IoU is used to calculate the intersection-union ratio of the true value and the predicted value, and its value ranges from 1 to 2. For both, the closer to 1, the better the segmentation effect. Table 1 shows a comparison of the proposed model with U-Net and TransUNet for segmenting Dice and IoU.
[0070] Table 1 ; As shown in the table, the present invention demonstrates superior performance in Dice and IoU on the gas diffusion layer segmentation dataset. For the common TransUNet base model, the present invention achieves a 9.1% improvement in mDice and a 12.9% improvement in IoU. Compared to the UNet model used in most related studies, the present invention shows a significant 21.2% improvement in Dice and a substantial 26.8% increase in mIoU. In summary, these results demonstrate the effectiveness of the proposed gas diffusion layer fiber binder segmentation method based on the fusion of global and local features.
[0071] This invention also compares the visualization results obtained from various segmentation models. For example... Figure 3Input is the image of the gas diffusion layer to be segmented, and GT refers to the correct ground truth segmentation result. Visualization results show that the method proposed in this invention yields results closer to the true ground truth segmentation, achieving better segmentation performance compared to UNet and TransUNet.
[0072] The above description is merely a specific embodiment of the present invention. Any feature disclosed in this specification may be replaced by other equivalent or similar features unless otherwise specified. All disclosed features, or steps in all methods or processes, may be combined in any way except for mutually exclusive features and / or steps.
Claims
1. A method for segmenting gas diffusion layer fiber binders based on the fusion of global and local features, characterized in that, Includes the following steps: Step S1: Acquire SEM images of the gas diffusion layer and preprocess the acquired SEM images; manually annotate the SEM images after grayscale balancing to generate mask label images corresponding to the SEM images; Step S2: Data augmentation. Data augmentation is performed synchronously on the SEM image obtained in step S1 and the corresponding mask label image to finally obtain the image dataset. Step S3: Construct an improved Vision Transformer segmentation model, which includes a Transformer encoder, a GLIB module, an LBWA module, a DecoderCup decoder, an LKAT module, and a Segmentation Head. Step S4, Model Training and Inference: The image dataset obtained in Step S2 is divided into a training set and a test set according to a preset ratio. The training set is input into the improved VisionTransformer segmentation model constructed in Step S3 to carry out model training. After the model training converges and reaches the preset accuracy requirement, the SEM image of the gas diffusion layer to be segmented is input into the trained improved segmentation model, and the model outputs the image segmentation results of the fiber phase and binder phase in the gas diffusion layer.
2. The method according to claim 1, characterized in that, The preprocessing process in step S1 specifically involves converting the original gas diffusion layer SEM image into an 8-bit bit-depth format and uniformly cropping the converted image to match the size of the cropped image with the input size of the improved segmentation model.
3. The method according to claim 1, characterized in that, In step S2, the data augmentation operation includes random rotation, horizontal / vertical flipping, and random sliding window cropping. The original images in the gas diffusion layer image dataset are cropped to the preset model input size. The cropped original images are converted into tensor types and normalized to serve as input images. The label images in the gas diffusion layer image dataset are cropped to the same size. The cropped label images are converted into tensor types and together with the input images constitute training samples.
4. The method according to claim 1, characterized in that, The Transformer encoder described in step S3 includes an Embeddings layer and an Encoder layer. The Embeddings layer transforms the input image into sequence features, satisfying embeddings = PatchEmbed(x) + PosEmbed, where PatchEmbed(x) is the image block convolutional embedding with the kernel size matching the block size, and PosEmbed is a learnable positional embedding vector. The Encoder layer consists of multiple stacked blocks, each block including an attention layer and an MLP layer, satisfying the residual connection formula. ; ; Where x represents the input feature, x1 represents the normalized result, and x2 is the intermediate result after normalization in the MLP sublayer. The MLP layer uses the GELU activation function, which satisfies... Linear1 is a fully connected layer from the input channel to the intermediate channel, and Linear2 is a fully connected layer from the intermediate channel to the output channel.
5. The method according to claim 1, characterized in that, The GLIB (Global-Local Integration Block) module mentioned in step S3 is used to achieve global-local spatial feature aggregation. Its structure includes projection convolutional layers, QKV convolutional layers, depthwise separable convolutional layers, and fusion convolutional layers. The feature processing procedure is as follows: Obtaining the input feature map Where B is the batch size, C is the number of channels, and H and W correspond to the height and width of the image; the input feature map is subjected to projection convolution to obtain the projection features: ; The projected features are divided into global branch features along the channel dimension. Local branching features ,in: ; For the global branch features Generate query vectors using QKV convolution. Key vector Sum value vector And rearrange them into a sequence; Based on the query vector With key vector Calculate attention weights and apply them to the value vector. Perform weighted summation to obtain the global output features. ; For the local branch features Depthwise separable convolution and point convolution are performed sequentially to obtain local output features. ; The global output features With local output features The features are concatenated and fused using convolution operations to obtain the module output features.
6. The method according to claim 1, characterized in that, The LBWA module mentioned in step S3 is used to achieve interactive enhancement of high and low resolution features, and its input is high-resolution features. With low-resolution features The processing procedure is as follows: Convolutional dimensionality reduction is performed on the high-resolution and low-resolution features respectively to obtain intermediate features: ; Where H mid With L mid These are intermediate features for high-level and low-level structures, respectively. Weight coefficients for high-level and low-level layers are generated based on the corresponding intermediate features, satisfying: ; The boundary weights are calculated using convolution operations on the low-resolution intermediate features. : ; The intermediate features are weighted based on the weight coefficients and boundary weights to obtain enhanced features at higher and lower levels: ; ; in, This represents element-wise multiplication; The enhanced high-resolution features are concatenated with the low-resolution features, and then fused using convolution to obtain the module output feature `out`. LBWA : 。 7. The method according to claim 1, characterized in that, The DecoderCup decoder mentioned in step S3 is used to realize multi-scale feature fusion and resolution restoration, including a head convolutional layer, four Decoder Block modules, and a feature projection layer; the feature fusion process of the Decoder Block module is as follows: Let the input high-resolution features be Low-resolution jump features are ; right Upsampling: ; like and Inconsistent resolution, for Interpolation alignment, x skip,align These are intermediate variables of the skip connection features after size alignment: ; Feature concatenation and convolution processing satisfy: , The output result is: , BN stands for Batch Normalization.
8. The method according to claim 1, characterized in that, The LKAT module mentioned in step S3 is used to implement tail-large kernel convolutional attention enhancement. Its structure includes a 1×1 convolutional layer and a depthwise separable convolutional layer, wherein the depthwise separable convolutional layer includes a 7×7 convolutional kernel and a 9×9 dilated convolutional kernel. The feature processing process satisfies: Input features are First, we obtain the following through 1×1 convolution and GELU activation: Attention weights are calculated to satisfy: , Feature weighting and output satisfy: .
9. The method according to claim 1, characterized in that, The Segmentation Head mentioned in step S3 is used to output the final segmentation result. Its structure includes a 3×3 convolutional layer and an upsampling layer, satisfying the following: ,in For the output features of the Decodercup decoder, s This is the upsampling factor, and , ,in , The feature resolution of the height and width of the decoder output image. , The height and width resolution of the original input image.
10. The method according to claim 1, characterized in that, In step S4, the model training uses the cross-entropy loss function, and the loss calculation process is as follows: Let the segmentation probability map output by the model be... The corresponding mask tag is Then the cross-entropy loss is: B stands for Batch, and H and W correspond to the height and width of the image. This means that the model predicts the true label at pixel (i,j) in the b-th sample. The probability; during training, the Adam optimizer is used, and the learning rate is adjusted through a cosine annealing strategy.