CT image segmentation method and system based on improved Swin-Unet
By introducing a multi-head self-attention mechanism and convolutional attention module in Swin-Unet, the shortcomings of Swin-Unet in capturing local details and handling complex morphological changes are solved, and the accuracy and robustness of CT image segmentation of abdominal organs are significantly improved.
Patent Information
- Application Number
- CN202411629609.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-15
- Publication Date
- 2025-03-21
- Estimated Expiration
- 2044-11-15
AI Technical Summary
The existing Swin-Unet is not fine enough in capturing local details and handling complex organ morphological changes, resulting in insufficient segmentation accuracy and robustness in abdominal organ CT image segmentation.
Replace traditional jump connections by introducing a multi-head self-attention mechanism (EMSA) in Swin-Unet and adding a convolutional attention module (CBAM) after the decoder output to enhance feature delivery and representation of important features.
The adaptability and segmentation accuracy of the model when facing abdominal organs with blurred boundaries or uneven morphology is improved, and the robustness and segmentation effect of the model are significantly improved.
Smart Images

Figure CN119151963B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of computer vision, and in particular relates to a CT image segmentation method and system based on improved Swin-Unet. Background Art
[0002] The main purpose of abdominal organ CT image segmentation is to improve the accuracy of disease diagnosis and treatment. In traditional methods, the segmentation of abdominal organ CT images usually relies on manual annotation and classic image processing technology. Although these methods can provide a certain degree of accuracy, they often have problems such as high labor intensity, long time consumption, and strong dependence on doctor experience. With the development of computer vision and deep learning technology, automated image segmentation methods have gradually become a research hotspot.
[0003] Convolutional neural network (CNN)-based methods, such as U-Net and its variants, have been widely used in the field of medical image segmentation. For example, Swin-Unet extracts features globally through the self-attention mechanism, which enhances the model's perception of the global information of the image.
[0004] However, Swin-Unet is not fine enough in capturing local details, especially in the transition area between organs and surrounding tissues, where the boundaries may not be obvious enough; in addition, abnormal conditions such as lesions or tumors may cause changes in organ morphology and density, which puts higher requirements on the segmentation algorithm. Therefore, Swin-Unet still needs to be further optimized and improved in dealing with complex local details and morphological changes. Summary of the invention
[0005] In order to overcome the shortcomings of the above-mentioned prior art, the present invention provides a CT image segmentation method and system based on an improved Swin-Unet, which utilizes a multi-head self-attention mechanism to replace the traditional skip connection, and enhances the network's expression ability in the feature transmission process through multi-scale information fusion and dynamic weight allocation, so that the model has better adaptability when facing boundary models or abdominal organs with uneven morphology.
[0006] To achieve the above objectives, one or more embodiments of the present invention provide the following technical solutions:
[0007] A first aspect of the present invention provides a CT image segmentation method based on improved Swin-Unet.
[0008] The CT image segmentation method based on the improved Swin-Unet includes:
[0009] Acquire CT image data and perform preprocessing;
[0010] The preprocessed CT image data is input into the improved Swin-Unet model. In the down / up sampling of each stage of the encoder and decoder, two consecutive shifted window layered transformer modules are used for feature extraction. The outputs of the shifted window layered transformer modules of the corresponding layers of the encoder and decoder are concatenated using a multi-head self-attention connection module to finally obtain the output convolution of the decoder.
[0011] The decoder output convolution is input into the convolutional attention module to obtain the final output feature map based on the channel and spatial attention mechanism;
[0012] Based on the final output feature map, the CT image is segmented.
[0013] The second aspect of the present invention provides a CT image segmentation system based on improved Swin-Unet.
[0014] CT image segmentation system based on improved Swin-Unet, including:
[0015] The data acquisition module is configured to: acquire CT image data and perform preprocessing;
[0016] The encoder and decoder data processing modules are configured to: input the preprocessed CT image data into the improved Swin-Unet model, use two consecutive shifted window layered transformer modules for feature extraction in the down / up sampling of each stage of the encoder and decoder, and use the multi-head self-attention connection module to perform feature splicing on the outputs of the shifted window layered transformer modules of the corresponding layers of the encoder and decoder, and finally obtain the output convolution of the decoder;
[0017] The convolutional attention data processing module is configured to: convolve the output of the decoder into the convolutional attention module, and obtain the final output feature map based on the channel and spatial attention mechanism;
[0018] The segmentation module is configured to segment the CT image based on the final output feature map.
[0019] One or more of the above technical solutions have the following beneficial effects:
[0020] (1) Traditional skip connections usually copy the feature map in the encoder directly to the decoder and add it to the feature map of the decoder. The present invention uses the multi-head self-attention mechanism EMSA to replace the traditional skip connection. The EMSA mechanism enhances the network's expression ability in the feature transfer process through multi-scale information fusion and dynamic weight allocation, making the model more adaptable when facing boundary models or abdominal organs with uneven morphology, thereby improving the segmentation accuracy and robustness of the model.
[0021] (2) After the final output convolution of the decoder, the integrated combined attention module CBAM of the present invention strengthens the representation of important features through channel attention and spatial attention mechanisms, significantly improving the accuracy of the model in the task of abdominal organ CT image segmentation, especially in boundary and detail recognition.
[0022] (3) The abdominal organ CT image segmentation model of the present invention adopts a symmetrical dual-branch encoding and decoding structure. The dual-branch structure allows the model to extract features of abdominal organ CT images from different angles and depths, thereby increasing the diversity and richness of features.
[0023] Advantages of additional aspects of the present invention will be given in part in the following description, and in part will become obvious from the following description, or will be learned through practice of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] The accompanying drawings in the specification, which constitute a part of the present invention, are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.
[0025] Figure 1 This is a flow chart of a CT image segmentation method based on improved Swin-Unet in the first embodiment.
[0026] Figure 2 This is a structural diagram of the abdominal organ CT image segmentation model of the first embodiment.
[0027] Figure 3 It is the module structure diagram of Swin Transformer Block of the first embodiment.
[0028] Figure 4 This is the structural diagram of the convolutional attention module of the first embodiment.
[0029] Figure 5 This is a structural diagram of the channel attention module of the first embodiment.
[0030] Figure 6 This is a structural diagram of the spatial attention module of the first embodiment.
[0031] Figure 7 This is a structural diagram of the multi-head attention module of the first embodiment. DETAILED DESCRIPTION
[0032] Embodiment 1
[0033] like Figure 1 As shown, this embodiment discloses a CT image segmentation method based on improved Swin-Unet, including:
[0034] Step 1: Obtain abdominal organ CT image data, perform data preprocessing, and divide the obtained data set into a training set and a test set;
[0035] Step 2: Construct an abdominal organ CT image segmentation model and initialize the model parameters;
[0036] Step 3: Use the training set to train the abdominal organ CT image segmentation model to obtain an optimized abdominal organ CT image segmentation model;
[0037] Step 4: Input the test set into the optimized abdominal organ CT image segmentation model. The data passes through the shifted window layered transformer module, the multi-head self-attention connection module, the bottleneck module, and the convolutional attention module in turn to obtain the final abdominal organ CT image segmentation result.
[0038] Step 1 includes, Step 101: Data Collection
[0039] This embodiment uses the publicly available data set Synapse provided by the TransUNet model, which includes 3779 axial abdominal clinical CT images of 30 cases and 9 abdominal organs (aorta, gallbladder, spleen, left kidney, right kidney, liver, pancreas, spleen, stomach).
[0040] Step 102: Data preprocessing
[0041] (1) Call the numpy module and PIL module in Python to perform random rotation and flip operations on the Synapse dataset to obtain the Synapse_first dataset;
[0042] (2) Call the cv2 module and numpy module in Python to perform random color space conversion on the data set Synapse_first to obtain the data set Synapse_second;
[0043] (3) Call the numpy module, cv2 module, PIL module, etc. in Python to generate random noise with a specific distribution and add it to the data set Synapse_second to obtain the data set Synapse_third;
[0044] (4) Call the cv2 module, PIL module, numpy module, etc. in Python to perform image filtering and transformation operations on the data set Synapse_third. The transformation operations include blurring and sharpening to obtain the final data set Data.
[0045] Step 103: Dataset Partitioning
[0046] Divide the dataset Data into a training set and a test set in a ratio of 9:1. Save the training set data in the Data / train_npz directory and the test set data in the Data / test_vol_h5 directory.
[0047] In step 2, the abdominal organ CT image segmentation model is an improved Swin-Unet model;
[0048] like Figure 2 As shown in the figure, the improved Swin-Unet model adopts a symmetrical dual-branch encoder and decoder structure, uses a multi-head self-attention module to replace the jump connection between the corresponding layers of the traditional encoder and decoder to splice shallow features and deep features, and adds a convolutional attention module at the output of the decoder to strengthen the representation of important features.
[0049] Specifically, an improved Swin-Unet model is constructed, including:
[0050] Step 201: Construct a shifted window hierarchical transformer block (Swin Transformer Block).
[0051] Among them, the representation of Swin Transformer is calculated using a shifted window. The shifted window scheme limits the self-attention calculation to non-overlapping local windows while allowing cross-window connections, thereby improving efficiency.
[0052] Two consecutive Swin TransformerBlocks (i.e., Swin Transformer Block*2) are required in each stage of down / up sampling in the encoder and decoder; the Swin Transformer Block is constructed by replacing the standard multi-head self-attention (MSA) module in the Transformer block with a shift window-based MSA module, and the other layers remain unchanged.
[0053] like Figure 3 As shown in Figure 1, two consecutive Swin Transformer blocks are shown. Each Swin Transformer block consists of a layer normalization (LayerNorm, LN), a multi-head self-attention module (multi-head self-attention, MSA), a residual connection, and a multilayer perceptron (Multilayer Perceptron, MLP) connected in sequence. A LN layer is applied before each MSA module and each MLP module, and a residual connection is applied after each module.
[0054] Among them, the multilayer perceptron MLP is a 2-layer MLP with a GELU nonlinear activation function in the middle; the multi-head self-attention modules (MSA) in two consecutive Swin Transformer blocks use the window-based multi-head self-attention (W-MSA) module and the shifted window-based multi-head self-attention (SW-MSA) module respectively.
[0055] Step 202: Construct encoder and decoder structures.
[0056] The encoder and decoder are constructed hierarchically using a three-level pyramid structure. The encoder is similar to Swin-Unet, which includes three sequentially connected (i.e., three consecutively repeated) blocks consisting of a Swin Transformer module and a Patch Merging layer (feature merging layer).
[0057] Inspired by U-Net and Swin-Unet, the present invention designs a decoder based on a symmetric encoder; the decoder includes three blocks consisting of Patch Merging layers and Swin Transformer modules connected in sequence; the Swin Transformer Blocks corresponding to the encoder and decoder are connected through a multi-head self-attention module (EMSA).
[0058] Step 203: Construct a bottleneck module (Bottleneck).
[0059] The last Patch Merging layer in the encoder and the first Patch Merging layer in the decoder are connected through a Bottleneck module; the Bottleneck module includes two sequentially connected Swin Transformer Block blocks. When the input feature map passes through the Bottleneck module, the feature dimension and resolution remain unchanged.
[0060] Step 204: Construct a convolutional block attention module (CBAM) after the final output convolution of the Swin-Unet model. This module is a module that combines spatial and channel attention mechanisms.
[0061] like Figure 4 As shown in the figure, the module will send the input feature map (input) into a channel attention module (ChannelAttention Module) and a spatial attention module (SpatialAttention Module), and finally get the output feature map (output).
[0062] Channel attention module: The channel dimension remains unchanged and the spatial dimension is compressed; this module focuses on the meaningful information in the input feature map.
[0063] Spatial attention module: The spatial dimension remains unchanged and the channel dimension is compressed; this module focuses on the location information of the target.
[0064] Therefore, by adding a convolutional attention module, the model focuses on key information, thereby improving segmentation accuracy.
[0065] Specifically: The convolutional attention module CBAM includes a channel attention module and a spatial attention module connected in sequence, such as Figure 5 As shown in the figure, the channel attention module first uses two parallel branches to perform global maximum pooling downsampling (Maxpool) and global average pooling downsampling (AvgPool) on the input feature map (input F), and converts the feature map F of size H*W*C (H and W are the height and width of the image, C is the number of channels) into two feature maps of size 1*1*C; then the feature maps output by the two parallel branches are input into the shared network (Shared MLP) to generate channel attention weights, and two feature maps of size 1*1*C are obtained; finally, the two feature maps output by the shared network are added and their values are limited to between 0 and 1 through the sigmoid activation function, and finally the output feature map output is obtained. ;
[0066] The shared network (Shared MLP) consists of a multi-layer perceptron (MLP) and two fully connected layers. The feature maps obtained after downsampling through two parallel branches will pass through a shared multi-layer perceptron respectively. The multi-layer perceptron processes the obtained features through maximum pooling (MaxPool) and average pooling (AvgPool) to generate channel attention weights. The feature map output by the multi-layer perceptron first passes through two fully connected layers for dimension adjustment.
[0067] Specifically: Use the first fully connected layer to map the input features to a hidden layer, and use the second fully connected layer to map the features of the hidden layer back to the original channel dimension.
[0068] The feature map output by the channel attention module is output , whose size is 1*1*C, and the output of the channel attention module Multiply it with the input feature map F to get a feature map of size H*W*C , which is used as the input of the spatial attention module.
[0069] like Figure 6 As shown, the spatial attention module inputs a feature map of size H*W*C After performing global maximum pooling downsampling and global average pooling downsampling in sequence, two feature maps of size H*W*1 are obtained; the two feature maps are spliced in the channel dimension to obtain a spliced feature map of size H*W*2;
[0070] The concatenated feature map undergoes a convolution to reduce the channel number, that is, the feature map with a size of H*W*2 is reduced to a feature map of H*W*1; finally, the sigmoid activation function is used to generate the spatial attention feature, that is, the output feature map is obtained. ; Its size is H*W*1; The output feature map With the input feature map After multiplication, the final feature map of size H*W*C is obtained.
[0071] Step 205: Construct an Efficient Multi-scale Self-attention (EMSA) module.
[0072] The traditional model uses skip connection to fuse the multi-scale features and up-sampled features from the encoder. The present invention uses the multi-head self-attention connection module EMSA to replace the traditional skip connection, which can splice the shallow features and the deep features together to reduce the spatial information loss caused by downsampling and ensure that the dimension of the connection feature remains the same as the dimension of the up-sampled feature.
[0073] like Figure 7 As shown, the present invention proposes an efficient multi-head self-attention module EMSA, which can capture and fuse features of different scales. It no longer simply copies feature maps, but dynamically selects important features by calculating attention weights.
[0074] First, a set of linear projections (Liner) are applied to the input feature map to obtain the query Q. At the same time, a deep convolution (DWConv) is applied to the input feature map, and then two sets of projections (Liner) are performed to obtain the key K and value V.
[0075] Next, the query Q and the key K are matrix multiplied (MatMul), and the result is scaled by a scaling factor (Scale) to prevent the gradient from vanishing.
[0076] Then, the EMSA (Q, K, V) attention function is used to calculate the interactions between different heads, as shown in formula (1); finally, the output value of each head is concatenated and linearly projected, and then added to the original input feature map through a residual connection to form the final output.
[0077] (1)
[0078] Formula (1) is the attention function used to calculate the query Q, K and value V; where softmax(•) is the soft attention mechanism, IN(•) is the element-wise multiplication; Conv(·) is a standard 1×1 convolution operation, which simulates the interaction between different heads. Each group of projections is composed of Linear layers (i.e., heads) are composed of (channel)-dimensional input is mapped to dimensional space, where is the head dimension. Therefore, the attention function of each head can depend on all keys K and queries Q, but this will weaken the ability of MSA to jointly process information from different representation subsets at different positions; in order to restore this diversity capability, the present invention adds element-wise multiplication IN(·) after Softmax.
[0079] Step 3 includes, step 301: inputting the training set into the abdominal organ CT image segmentation model to obtain a segmentation result, including:
[0080] Step 3011: Input the i-th image image in the training set train_npz in the data set Data obtained in step 1, referred to as image_i_input, into the abdominal organ CT image segmentation model, downsample through the Patch Partition layer and the Linear Embedding layer, and reduce the image to the size of H / 4*W / 4*C by calling the os module and the cv2 module in Python to obtain the output image and name it image_down1_1; where H and W are the height and width of the original image, and C is the number of channels;
[0081] Step 3012: image_down1_1 is input into the first two Swin TransformerBlock blocks in the encoder of the model. The Swin Transformer Block has a linear computational complexity related to the image size. By constructing a hierarchical feature map, an output image is obtained and named image_down1_2.
[0082] Step 3013: input image_down1_2 into the EMSA multi-head self-attention connection module constructed in step 204, replacing the traditional skip connection, splicing the shallow features and deep features together, while reducing the spatial information loss caused by downsampling, ensuring that the dimension of the connection feature is the same as the dimension of the upsampled feature, and obtaining the output image and naming it image_down1;
[0083] Step 3014: input image_down1_2 to the first Patch Merging layer (feature merging layer) in the encoder for downsampling, and the image size is reduced from W / 4*H / 4*C to W / 8*H / 8*2C, and the output image is obtained and named image_down2_1;
[0084] Step 3015: input image_down2_1 into the middle two Swin TransformerBlock blocks in the encoder for feature extraction, and obtain an output image named image_down2_2;
[0085] Step 3016: input image_down2_2 into the EMSA multi-head self-attention connection module to reduce the spatial information loss caused by downsampling, obtain the output image and name it image_down2;
[0086] Step 3017: input image_down2_2 to the second Patch Merging layer in the encoder for downsampling, and the image size is reduced from W / 8*H / 8*2C to W / 16*H / 16*4C, and the output image is obtained and named image_down3_1;
[0087] Step 3018: input image_down3_1 to the last two Swin Transformer Blocks in the encoder for feature extraction, and obtain an output image named image_down3_2;
[0088] Step 3019: Input image_down3_2 into the EMSA multi-head self-attention connection module to reduce the spatial information loss caused by downsampling, obtain the output image and name it image_down3;
[0089] Step 30110: input image_down3_2 to the third Patch Merging layer in the encoder for downsampling, and the image size is reduced from W / 16*H / 16*4C to W / 32*H / 32*8C, and the output image is obtained and named image_down4_1;
[0090] Step 30111: input image_down4_1 into the Bottleneck module constructed in step 203, and pass through two consecutive identical Swin Transformer Block blocks, with the feature dimension and resolution remaining unchanged, to obtain the output image and name it image_down5;
[0091] Step 30112: input image_down5 to the decoder part, and upsample it through the first Patch Expanding layer. By calling the os module and cv2 module in Python, the image is expanded from the original size W / 32*H / 32*8C to the size H / 16*W / 16*4C, and the output image is named image_up1_1.
[0092] Step 30113: add image_up1_1 to image_down3 obtained in step 3019, and then input it into the first two Swin Transformer Blocks in the decoder for feature extraction to obtain an output image named image_up1;
[0093] Step 30114: input image_up1 to the second Patch Expanding layer in the decoder for upsampling, and the image size is expanded from H / 16*W / 16*4C to H / 8*W / 8*2C, and the output image is obtained and named image_up2_1;
[0094] Step 30115: add image_up2_1 to image_down2 obtained in step 3016, and then input it into the middle two Swin Transformer Block blocks in the decoder for feature extraction to obtain the output image and name it image_up2;
[0095] Step 30116: input image_up2 to the third Patch Expanding layer in the decoder for upsampling, and the image size is expanded from H / 8*W / 8*2C to H / 4*W / 4*C, and the output image is obtained and named image_up3_1;
[0096] Step 30117: add image_up3_1 to image_down1 obtained in step 3013, and then input it into the last two Swin Transformer Blocks in the decoder for feature extraction to obtain the output image and name it image_up3;
[0097] Step 30118: input image_up3 to the fourth Patch Expanding layer in the decoder for upsampling, and the image size is expanded from H / 4*W / 4*C to H*W*C, and the output image is obtained and named image_up4;
[0098] Step 30119: input image_up4 into the convolutional attention mechanism module CBAM constructed in step 204, and enhance the characteristic representation of the abdominal organ CT image segmentation model by combining channel-space dual attention, while improving the segmentation accuracy, and obtain the output image and name it image_up5;
[0099] Step 30120: Input the image image_up5 processed by the convolutional attention module CBAM into the linear classification layer (Linear Projection), convert the image into H*W*CLASS, where CLASS is the number of classification categories, and obtain the output of the final abdominal organ CT image segmentation model and name it image_i_output.
[0100] Step 302: Using the training set to train the abdominal organ CT image segmentation model, including:
[0101] Step 3021: The total loss function of the abdominal organ CT image segmentation model consists of two parts: the cross-entropy loss function and the Dice loss function. The sum of the cross-entropy loss function and the Dice loss function is used as the total loss during segmentation network training, as shown in formula (2):
[0102] (2)
[0103] In the formula, and are weight values, and ; In this embodiment, select , .
[0104] Step 3022: In the abdominal organ CT image segmentation model training phase, the maximum epoch is 150, the training batch size batch_size is 24, and the image patch size img_size of the specified network input is 224.
[0105] The Adam optimizer is used to optimize the model parameters, and the model parameters are updated using back propagation and gradient descent until the set number of iterations is reached.
[0106] In the Adam optimizer, the weight decay weight_decay is set to 0.0001, the learning rate lr is set to the basic learning rate 0.05, and the learning rate is set to decay according to the current iteration number iter_num and the maximum iteration number max_iterations; after the training, the optimized abdominal organ CT image segmentation model is obtained.
[0107] In step 4, the abdominal organ CT image segmentation model is tested using the test set, including:
[0108] Step 401: In order to evaluate the performance of the proposed abdominal organ CT image segmentation model, the present invention uses the average probability similarity coefficient (DSC) and the average Hausdorff distance (average Hausdorff distance, HD) as evaluation indicators.
[0109] Formally, the predictions can be divided into true positive (TP), false positive (FP), true negative (TN) and false negative (FN), then the calculation formula of DSC is shown in formula (3);
[0110] (3)
[0111] The calculation formula of HD is shown in formula (4);
[0112] (4)
[0113] Where Y and Y' are the ground truth mask and the predicted segmentation map respectively; d(y,y') represents the Euclidean distance between points y and y'; when the DSC value is high, it means that the overlap between the predicted area and the true area is high. When the HD value is small, it means that the overall distance between the two point sets is closer and the matching degree is higher;
[0114] Step 402: Input the test set test_vol_h5 in the data set Data obtained in step 1 into the optimized abdominal organ CT image segmentation model network to obtain the final abdominal organ CT image segmentation result image, and name it image_end.
[0115] Embodiment 2
[0116] This embodiment discloses a CT image segmentation system based on improved Swin-Unet.
[0117] CT image segmentation system based on improved Swin-Unet, including:
[0118] The data acquisition module is configured to: acquire CT image data and perform preprocessing;
[0119] The encoder and decoder data processing modules are configured to: input the preprocessed CT image data into the improved Swin-Unet model, use two consecutive shifted window layered transformer modules for feature extraction in the down / up sampling of each stage of the encoder and decoder, and use the multi-head self-attention connection module to perform feature splicing on the outputs of the shifted window layered transformer modules of the corresponding layers of the encoder and decoder, and finally obtain the output convolution of the decoder;
[0120] The convolutional attention data processing module is configured to: convolve the output of the decoder into the convolutional attention module, and obtain the final output feature map based on the channel and spatial attention mechanism;
[0121] The segmentation module is configured to segment the CT image based on the final output feature map.
[0122] Those skilled in the art should understand that the modules or steps of the present invention described above can be implemented by a general-purpose computer device, or alternatively, they can be implemented by a program code executable by a computing device, so that they can be stored in a storage device and executed by the computing device, or they can be made into individual integrated circuit modules, or multiple modules or steps therein can be made into a single integrated circuit module for implementation. The present invention is not limited to any specific combination of hardware and software.
[0123] Although the above describes the specific implementation mode of the present invention in conjunction with the accompanying drawings, it is not intended to limit the scope of protection of the present invention. Those skilled in the art should understand that various modifications or variations that can be made by those skilled in the art on the basis of the technical solution of the present invention without creative work are still within the scope of protection of the present invention.
Claims
1. A CT image segmentation method based on improved Swin-Unet, characterized in that: include: Acquire CT image data and perform preprocessing; The preprocessed CT image data is input into the improved Swin-Unet model. In the down / up sampling of each stage of the encoder and decoder, two consecutive shifted window layered transformer modules are used for feature extraction. The outputs of the shifted window layered transformer modules of the corresponding layers of the encoder and decoder are concatenated using a multi-head self-attention connection module to finally obtain the output convolution of the decoder. The improved Swin-Unet model includes: a shift window layered transformer module Swin Transformer Block, an encoder and decoder structure, a bottleneck module, a convolutional attention module, and a multi-head self-attention connection module; The two consecutive shift window layered transformer modules Swin Transformer Block include sequentially connected layer normalization LN, multi-head self-attention modules MSA, residual connections and multi-layer perceptrons MLP; an LN layer is applied before each MSA module and each MLP module, and a residual connection is applied after each module; the multi-head self-attention modules MSA in the two consecutive shift window layered transformer modules respectively adopt a window-based multi-head self-attention W-MSA module and a shift window-based multi-head self-attention SW-MSA module; The decoder output convolution is input into the convolutional attention module to obtain the final output feature map based on the channel and spatial attention mechanism; Based on the final output feature map, the CT image is segmented.
2. The CT image segmentation method based on improved Swin-Unet according to claim 1, characterized in that: The preprocessing includes random rotation and flipping operations, random color space conversion operations, adding random noise, and image filtering and transformation operations.
3. The CT image segmentation method based on improved Swin-Unet according to claim 1, characterized in that: Two consecutive shifted window layered transformer modules are used for feature extraction, including: The down / upsampled CT image is input into the first shifted window hierarchical transformer module, and the output of the first shifted window hierarchical transformer module is obtained after layer normalization, multi-head self-attention module, residual connection and multi-layer perceptron processing in sequence; The output of the first shifted window hierarchical transformer module is used as the input of the second shifted window hierarchical transformer module, and feature extraction is performed again to obtain the output of the second shifted window hierarchical transformer module; The multi-head self-attention modules of the first shifted window layered transformer module and the second shifted window layered transformer module respectively adopt a window-based multi-head self-attention module and a shifted window-based multi-head self-attention module.
4. The CT image segmentation method based on improved Swin-Unet according to claim 3, characterized in that: The outputs of the shifted window hierarchical transformer modules of the corresponding layers of the encoder and decoder are feature concatenated using a multi-head self-attention connection module, including: The output of the second shifted window hierarchical transformer module in the encoder is fed into the multi-head self-attention connection module to calculate the query Q, key K, and value V; Apply the attention function formula to the query Q, key K and value V, calculate the attention weights and dynamically select important features to get the output of the multi-head self-attention connection module; The output of the multi-head self-attention connection module is feature concatenated with the output of the second shift window hierarchical transformer module of the corresponding layer of the decoder to complete the connection between the corresponding layers of the encoder and decoder.
5. The CT image segmentation method based on improved Swin-Unet according to claim 4, characterized in that: The attention function formula is specifically: ; in, is the attention function for computing the query Q, key K and value V; softmax(•) is the soft attention mechanism, IN(•) is the element-wise multiplication; Conv(·) is the convolution operation; For the head dimension.
6. The CT image segmentation method based on improved Swin-Unet according to claim 1, characterized in that: The decoder output convolution is input into the convolutional attention module, and the final output feature map is obtained based on the channel and spatial attention mechanism, including: The decoder output convolution is input into the channel attention module of the convolutional attention module, keeping the channel dimension unchanged and compressing the spatial dimension to obtain the output of the channel attention module; Convolve the output of the channel attention module with the output of the decoder to obtain the feature map after the first multiplication; The feature map obtained after the first multiplication is input into the spatial attention module, keeping the spatial dimension unchanged and compressing the channel dimension to obtain the output of the spatial attention module; The output of the spatial attention module is multiplied again with the feature map obtained after the first multiplication to obtain the final output feature map.
7. The CT image segmentation method based on improved Swin-Unet according to claim 1, characterized in that: The encoder includes a plurality of shift window hierarchical transformer modules and feature merging layers that are alternately connected in sequence; the decoder includes a plurality of block expansion layers and shift window hierarchical transformer modules that are alternately connected in sequence.
8. The CT image segmentation method based on improved Swin-Unet according to claim 7, characterized in that: The last feature merging layer in the encoder and the first block expansion layer in the decoder are connected via a bottleneck module, and the bottleneck module includes two sequentially connected shifted window hierarchical transformer modules.
9. The CT image segmentation method based on improved Swin-Unet according to claim 1, characterized in that: The total loss function of the improved Swin-Unet model is the sum of the cross entropy loss function and the Dyss loss function; In the training process of the improved Swin-Unet model, the Adam optimizer is used to optimize the model parameters, and the back propagation and gradient descent methods are used to update the model parameters until the set number of iterations is reached; In the training process of the improved Swin-Unet model, the average probability similarity coefficient and the average Hausdorff distance are used as evaluation indicators of the model.
10. The CT image segmentation system based on improved Swin-Unet is characterized by: include: The data acquisition module is configured to: acquire CT image data and perform preprocessing; The encoder and decoder data processing modules are configured to: input the preprocessed CT image data into the improved Swin-Unet model, use two consecutive shifted window layered transformer modules for feature extraction in the down / up sampling of each stage of the encoder and decoder, and use the multi-head self-attention connection module to perform feature splicing on the outputs of the shifted window layered transformer modules of the corresponding layers of the encoder and decoder, and finally obtain the output convolution of the decoder; The improved Swin-Unet model includes: a shift window layered transformer module Swin Transformer Block, an encoder and decoder structure, a bottleneck module, a convolutional attention module, and a multi-head self-attention connection module; The two consecutive shift window layered transformer modules Swin Transformer Block include sequentially connected layer normalization LN, multi-head self-attention modules MSA, residual connections and multi-layer perceptrons MLP; an LN layer is applied before each MSA module and each MLP module, and a residual connection is applied after each module; the multi-head self-attention modules MSA in the two consecutive shift window layered transformer modules respectively adopt a window-based multi-head self-attention W-MSA module and a shift window-based multi-head self-attention SW-MSA module; The convolutional attention data processing module is configured to: convolve the output of the decoder into the convolutional attention module, and obtain the final output feature map based on the channel and spatial attention mechanism; The segmentation module is configured to segment the CT image based on the final output feature map.
Citation Information
Patent Citations
U-shaped self-adaptive EST unmanned aerial vehicle remote sensing image segmentation method and system
CN115035131A
Medical image segmentation method and system based on double-branch embedded attention mechanism
CN116309650A