Medical image semantic segmentation method and system based on channel and space attention mechanism
By introducing the bridge channel and spatial attention module into the U-Net model, combined with data enhancement and hybrid loss functions, the problem of background interference and noise in medical image segmentation is solved, the segmentation accuracy and stability are improved, and the model's performance is enhanced. Generalization ability.
Patent Information
- Application Number
- CN202410871458.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-01
- Publication Date
- 2024-10-22
AI Technical Summary
Existing medical image semantic segmentation technology is prone to background interference and difficulty in recognition when processing medical images. Channel information redundancy and noise are greatly affected, and model generalization capabilities are limited. In particular, there are inaccuracies, blurs, or breaks when segmenting details and boundary areas. problem.
The CSAB-UNet model based on the U-Net model is adopted. By introducing the bridge channel attention module and the bridge spatial attention module, combined with data enhancement technology, the hybrid loss function Bce_Dice_Loss is used for optimization to enhance the receptive field and robustness of the model. , improve the segmentation accuracy of medical images.
It improves the accuracy and stability of semantic segmentation of medical images, enhances the generalization ability of the model, can more effectively screen important channel and spatial information, reduces noise interference, and improves detail and boundary segmentation effects.
Smart Images

Figure CN118823344A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical fields of convolutional neural networks, neuroscience, computers, and more particularly to a medical image semantic segmentation method and system based on channel and spatial attention mechanisms. Background Art
[0002] The accuracy of medical image semantic segmentation algorithms is of great significance for clinical diagnosis and treatment decisions, early disease detection and prediction, scientific research and knowledge discovery, and automated and intelligent medical applications. The accuracy of medical image semantic segmentation algorithms is directly related to clinicians' diagnosis and treatment decisions for patients. Accurate segmentation results can provide more comprehensive, detailed and reliable information, helping doctors better understand pathological changes and disease progression, thereby formulating more accurate and individualized treatment plans. Highly accurate algorithms can reduce human errors and improve doctors' ability to interpret and understand medical images.
[0003] The accuracy of medical image semantic segmentation algorithms is also of great significance for early detection and prediction of diseases. By accurately segmenting the lesion area, it can help doctors find tiny lesions or abnormal signals, thereby achieving early diagnosis and intervention of the disease. In addition, accurate segmentation results can also provide valuable information for the progression and prognosis of the disease, which helps to formulate personalized treatment plans and predict the development trend of the patient's disease.
[0004] At the same time, by accurately segmenting tissue structures, organ regions or lesion areas in medical images, it can help researchers gain a deeper understanding of the pathological characteristics, physiological processes and treatment effects of the disease. Accurate segmentation results can be used to build quantitative anatomical and pathological feature models, thereby promoting the in-depth and progress of medical research. The accuracy of medical image semantic segmentation algorithms is the basis for realizing automated and intelligent medical applications.
[0005] In summary, the research on the accuracy of medical image semantic segmentation algorithms is of great significance. By continuously improving the accuracy of the algorithm, the reliability and efficiency of medical image processing can be improved, providing better support for medical practice and patient health.
[0006] Although the existing semantic segmentation technology for medical images has achieved some success, it still has some shortcomings: tumors, tissues, and organs in medical images may be difficult to identify due to background interference. Some channels of these medical images may carry more task-related information, while other channels may contain useless noise or redundant information. Secondly, the generalization ability of the model is limited. Due to the diversity and complexity of medical images, the generalization ability of existing models is limited when dealing with new data sets or different types of diseases. It is difficult to handle details and boundaries. Existing technologies still face challenges in handling subtle structures and boundary areas, and are prone to inaccurate, blurred, or broken segmentation. Summary of the invention
[0007] In view of the above problems, the present invention provides a medical image semantic segmentation method based on channel and spatial attention mechanism, the method comprising:
[0008] S1. Collect historical medical image datasets and preprocess the datasets;
[0009] S2. Build a CSAB-UNet model based on the U-Net model, and use the preprocessed data set to train the CSAB-UNet model. The CSAB-UNet model is as follows: use the convolution layer of the U-Net network and the pooling layer of the U-Net network to perform feature extraction and downsampling operations on the preprocessed data to obtain a feature map with modified size and number of channels; use the deconvolution layer of the U-Net network to upsample the feature map, restore the size and number of channels of the feature map, and use the bridge channel attention module and the bridge spatial attention module to retain the required semantic information for the downsampled feature map corresponding to the size of the upsampled feature map;
[0010] S3. Use the hybrid loss function to optimize the trained CSAB-UNet model, and use the optimized CSAB-UNet model to perform semantic segmentation on real-time medical images to obtain segmentation results.
[0011] Optionally, in S1, the preprocessing method specifically includes:
[0012] The collected historical medical image datasets are cleaned and annotated. The data cleaning and annotation process specifically includes:
[0013] Performing image format conversion, size adjustment, and color correction on the collected historical medical image datasets so that the format, resolution, and size of the historical medical image datasets are consistent;
[0014] Based on the adjusted historical medical image dataset, noisy and incomplete images are removed to obtain basic metadata information;
[0015] Using a labeling tool to label the basic metadata information;
[0016] The labeled data is enhanced to obtain data enhancement information, and the data enhancement information is stored to obtain preprocessed data.
[0017] Optionally, in S2, the bridge channel attention module includes a feature map compression module, a feature map conversion module and a feature map recalibration module; the bridge spatial attention module includes a compression splicing module, a tough attention weight activation extraction module and a spatial pixel weighting module.
[0018] Optionally, in S3, the mixed loss function is:
[0019]
[0020]
[0021] Bce_Dice_Loss=Loss_BCE+Loss_Dice
[0022] Among them, A is the predicted segmentation result, B is the actual segmentation result, p is the probability that a sample is predicted to be 1, and y is the actual label classification value.
[0023] The present invention also discloses a medical image semantic segmentation system based on channel and spatial attention mechanism, the system comprising a data collection module, a model building module and a semantic segmentation module;
[0024] The data collection module is used to collect historical medical image data sets and preprocess the data sets;
[0025] The model building module is used to build a CSAB-UNet model based on the U-Net model, and use the preprocessed data set to train the CSAB-UNet model;
[0026] The semantic segmentation module is used to optimize the trained CSAB-UNet model using a hybrid loss function, and use the optimized CSAB-UNet model to perform semantic segmentation on real-time medical images to obtain segmentation results.
[0027] Optionally, the preprocessing process of the data collection module includes:
[0028] The collected historical medical image datasets are cleaned and annotated. The data cleaning and annotation process specifically includes:
[0029] Performing image format conversion, size adjustment, and color correction on the collected historical medical image datasets so that the format, resolution, and size of the historical medical image datasets are consistent;
[0030] Based on the adjusted historical medical image dataset, noisy and incomplete images are removed to obtain basic metadata information;
[0031] Using a labeling tool to label the basic metadata information;
[0032] The labeled data is enhanced to obtain data enhancement information, and the data enhancement information is stored to obtain preprocessed data.
[0033] Optionally, the bridge channel attention module of the model building module includes a feature map compression module, a feature map conversion module and a feature map recalibration module; the bridge spatial attention module includes a compression splicing module, a tough attention weight activation extraction module and a spatial pixel weighting module.
[0034] Optionally, the hybrid loss function of the semantic segmentation module is:
[0035]
[0036]
[0037] Bce_Dice_Loss=Loss_BCE+LLoss_Dice
[0038] Among them, A is the predicted segmentation result, B is the actual segmentation result, p is the probability that a sample is predicted to be 1, and y is the actual label classification value.
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] This network model uses U-Net as the basic framework, and replaces the original jump connections with bridge channel attention modules and bridge spatial attention modules, so that the network can adaptively obtain rich receptive field information, and obtain the channel and spatial information concerned by the segmentation task by fusing new features, which facilitates the importance screening of new features. In addition, the experiment also uses a variety of data enhancement methods to increase the amount of training data and make the network more robust; the mixed loss function Bce_Dice Loss is used during training to enhance the model analysis and optimization capabilities. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solution of the present invention, the following briefly introduces the drawings required for use in the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0042] Figure 1 This is the overall structure diagram of CSAB-UNet according to an embodiment of the present invention;
[0043] Figure 2 This is a structural diagram of a bridge channel attention module according to an embodiment of the present invention;
[0044] Figure 3 This is a structural diagram of the bridge spatial attention module according to an embodiment of the present invention. DETAILED DESCRIPTION
[0045] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.
[0046] Embodiment 1
[0047] The present invention provides a medical image semantic segmentation method based on channel and spatial attention mechanism, such as Figure 1 As shown, the method includes:
[0048] S1. Collect historical medical image datasets and preprocess the datasets. This includes data cleaning, labeling and other operations. (1) Data collection and preprocessing: Collect the required medical image datasets, such as CT, MRI, X-rays, etc. Check the data quality, ensure the consistency of image format, resolution, size, etc., and perform preprocessing operations such as format conversion, size adjustment, and color correction on the images; (2) Data cleaning: Eliminate blurry, noisy, and severely occluded images, repair or eliminate incomplete and incorrectly labeled images, and ensure that each image has clear and accurate metadata information; (3) Data labeling: According to the specific task, label the target area of interest, lesion type, etc. for the image. Professional labeling tools can be used. The labeling process needs to unify the labeling rules to ensure labeling consistency; (4) Data enhancement: Increase the amount of training data through transformations such as rotation, flipping, and scaling to improve the generalization ability of the model; (5) Data partitioning: Divide the dataset into training set, validation set, and test set, ensuring that there is no overlap between the three sets and that the distribution is as even as possible; (6) Data storage and management: Save the data in an appropriate file format, establish a data directory structure, and record data information.
[0049] S2. Build a CSAB-UNet model based on the U-Net model, and use the preprocessed data set to train the CSAB-UNet model. The CSAB-UNet model is as follows: use the convolution layer of the U-Net network and the pooling layer of the U-Net network to perform feature extraction and downsampling operations on the preprocessed data to obtain a feature map with modified size and number of channels; use the deconvolution layer of the U-Net network to upsample the feature map, restore the size and number of channels of the feature map, and use the bridge channel attention module and the bridge spatial attention module to retain the required semantic information of the downsampled feature map corresponding to the size of the upsampled feature map.
[0050] The U-Net network structure includes: Encoder: Use convolutional layers and pooling layers to perform feature extraction and downsampling operations, gradually reducing the size and number of channels of the feature map. Decoder: Use deconvolutional layers and skip connections to perform upsampling operations, gradually restoring the size and number of channels of the feature map. Connect the feature map of the corresponding size in the encoder with the feature map in the decoder to retain more semantic information.
[0051] This embodiment replaces the original jump connections with bridge channel attention modules and bridge spatial attention modules, so that the network can adaptively obtain rich receptive field information, fuse the five-layer intermediate features of different scales in the expansion path into new features, and obtain the channel and spatial information concerned by the segmentation task, so as to facilitate the importance screening of new features.
[0052] like Figure 2 As shown in the figure, the bridge channel attention module consists of three parts: feature map compression, feature map conversion, and feature map recalibration. This module introduces a mechanism that can adaptively adjust channel attention in different scenarios. The function of the feature map compression part is to reduce the amount of calculation and provide a basis for subsequent feature map conversion and recalibration.
[0053] The compression part of the feature map compresses the length and width dimensions of the input feature map to 1×1 through a global pooling operation, ignores the length and width dimension information to reduce the amount of computation, and concatenates all feature maps that have undergone global average pooling in the channel dimension.
[0054] The conversion part of the feature map is to convert the global feature vector obtained by feature map compression into an intermediate representation. This intermediate representation will be used for subsequent channel weight calculations. In the conversion part of the feature map, a one-dimensional convolution is introduced to achieve feature conversion, which has the following effects:
[0055] (1) Parameter sharing: The same parameters are used to process pixels at different positions in the input feature map. This parameter sharing feature makes the one-dimensional convolution have fewer parameters.
[0056] (2) Local correlation: Capturing the local correlation of the input sequence. In feature map conversion, one-dimensional convolution helps the model learn the local relationship between channels, thereby better modeling channel attention.
[0057] (3) Translation invariance: The input is translation invariant. This means that if the input feature is translated in position, the feature map obtained after one-dimensional convolution still maintains the corresponding translation. This property makes one-dimensional convolution insensitive to input position information and focuses more on feature content information.
[0058] (4) Multi-scale modeling: One-dimensional convolution kernels of different sizes are used to model the input in different receptive fields. This multi-scale modeling capability enables one-dimensional convolution to capture different scale features of the input image.
[0059] This layer maps the global feature vector to a higher-dimensional or lower-dimensional intermediate representation to enhance the model’s expressiveness. This intermediate representation will contain more information about the relationship between channels and will be used for subsequent channel weight calculations.
[0060] The recalibration part of the feature map is the process of adjusting or converting the original feature map to change the representation or attribute of the feature. Recalibration can be achieved through different methods and techniques, depending on the task and goal. The present invention uses a one-dimensional convolution layer and a fully connected layer to establish a global association between features, which can consider the global information between features, so that it can better model complex channel relationships. By applying the activation function Sigmoid, a nonlinear relationship is introduced to control the channel weight range between [0,1]. The obtained feature map is split according to the channel dimension required by the output feature map of each layer, and then the channel weight is multiplied and weighted with the input feature map. This action recalibrates the weights of each channel. Finally, inspired by the idea of residual connection, the present invention superimposes the feature map obtained after recalibrating the weights of each channel with the original image to enhance the accuracy and stability of the model.
[0061] like Figure 3 As shown in the figure, the bridge spatial attention module can adaptively obtain the feature information of different receptive fields according to the size of tumors, tissues, and organs in medical images, extract useful tumor, tissue, and organ information from complex medical images, and suppress irrelevant background information and noise. The module consists of three parts: compression splicing, spatial attention weight activation extraction, and spatial pixel weighting. The module fuses multi-stage and multi-scale information on the spatial axis to generate attention maps for each stage. Use the validation set to evaluate the trained model, calculate indicators such as accuracy, recall, and F1 score, and evaluate the performance of the model.
[0062] The module consists of three parts - compression splicing, spatial attention weight activation extraction, and spatial pixel weighting.
[0063] Compression splicing. As shown in the figure, the five input feature maps are respectively subjected to maximum and average pooling operations, and the spliced output tensors are obtained by obtaining a two-channel tensor. The width and height remain unchanged in the pooling operation. This operation can achieve the following effects:
[0064] (1) Enriching feature representation: Max pooling and average pooling operations can capture different types of features. The feature representation is enriched by cascading max pooling and average pooling operations.
[0065] (2) Enhanced robustness: Max pooling is more sensitive to noise and changes, while average pooling is relatively insensitive to noise and changes. By connecting max pooling and average pooling in series, the robustness of the model is enhanced, making it better adaptable to different types of inputs.
[0066] (3) Improve feature diversity: The obtained two-channel feature maps capture the maximum and average feature information respectively. This diversity helps to provide more information to distinguish different feature patterns.
[0067] Spatial attention weight activation extraction. Using dilated convolution operations, this operation process has the following effects:
[0068] (1) Reduce the number of parameters: Share convolution kernel weights. This is very beneficial for large networks and resource-constrained scenarios, while preventing overfitting.
[0069] (2) Enhanced feature representation: Expanding the convolution kernel’s perception range better captures image details. The shared dilated convolution operation can extract the same feature representation on the feature map by sharing the convolution kernel at different locations, thus enhancing the consistency and reusability of the features.
[0070] (3) Maintaining spatial resolution: The receptive field can be increased while maintaining the spatial resolution of the input and output. This is particularly important for tasks that require preserving details and location information, such as object detection and segmentation.
[0071] Spatial pixel weighting: Spatial pixel weighting is used to weight each pixel in an image to enhance or adjust its influence in the image. In spatial pixel weighting, each pixel is assigned a weight that determines the contribution of the pixel to the final processing result. Pixel weights are calculated based on their position or features in the image.
[0072] S3. Use the hybrid loss function to optimize the trained CSAB-UNet model, and use the optimized CSAB-UNet model to perform semantic segmentation on real-time medical images to obtain segmentation results.
[0073] In S3, the mixed loss function is:
[0074]
[0075]
[0076] Bce_Dice_Loss=Loss_BCE+Loss_Dice
[0077] Among them, A is the predicted segmentation result, B is the actual segmentation result, p is the probability that a sample is predicted to be 1, and y is the actual label classification value (this experiment is binary classification).
[0078] This embodiment uses a mixed loss function Bce_Dice Loss during training to increase the model's analysis and optimization capabilities. The model addresses the problem of too large a proportion of background pixels in the image, and considering the advantages and disadvantages of BCE and Dice Loss, the new loss function after integrating the two is Bce_Dice_Loss. This improves the accuracy of the model's prediction results. In the experiment, a variety of data enhancement methods were also used to increase the amount of training data to make the network more robust.
[0079] Embodiment 2
[0080] A medical image semantic segmentation system based on channel and spatial attention mechanism, the system comprises: the system comprises a data collection module, a model building module and a semantic segmentation module;
[0081] The data collection module is used to collect historical medical image data sets and preprocess the data sets. This includes operations such as data cleaning and labeling. The collected historical medical image data sets are cleaned and labeled, and the data cleaning and labeling process specifically includes: performing image format conversion, size adjustment and color correction on the collected historical medical image data sets to make the format, resolution and size of the historical medical image data sets consistent; based on the adjusted historical medical image data sets, eliminating noisy and incomplete images to obtain basic metadata information; using labeling tools to label the basic metadata information; performing data enhancement on the labeled data to obtain data enhancement information, and storing the data enhancement information to obtain preprocessed data.
[0082] In this embodiment, the bridge channel attention module used has similarities but differences with the ordinary channel attention module.
[0083] The similarities are:
[0084] (1) The feature compression method is the same: Both compress each channel feature map into a single pixel value. Assuming that the input feature dimension is (H, W, C), where H represents height, W represents width, and C represents the number of channels, the feature map dimension before and after the transformation is transformed from (H, W, C) to (1, 1, C), and then the attention weight of each channel is extracted.
[0085] (2) The weighting method is the same: the weight is multiplied by the original channel feature map information for weighting.
[0086] The differences are:
[0087] (1) Different sources of feature information: The input of the original channel attention module SE-Net only comes from feature map information of the same dimension, while the input of the bridge channel attention module comes from five sets of feature map information of different dimensions of U-Net.
[0088] (2) The channel attention weight extraction method is different: the original channel attention module SE-Net extracts the channel attention weight by passing the feature map with dimension (1, 1, C) after feature compression through two fully connected layers, while the bridge channel attention module concatenates the features of the five layers of feature map dimensional information of U-Net with different dimensions through global average pooling GAP, which acts as a "bridge" for feature map information. The concatenated feature map is then passed through a one-dimensional convolution layer and a fully connected layer to extract the channel attention weight.
[0089] (3) The feature information is recalibrated in different ways: the original channel attention module SE-Net simply multiplies the extracted channel attention weights and the original feature map, while the bridge channel attention module multiplies the extracted channel attention weights and the original feature map and superimposes them with the original feature map. This can avoid overfitting, reduce the interference of source feature map noise, and effectively improve the stability of the module during training.
[0090] Specifically, the module consists of three parts: compression of feature maps, conversion of feature maps, and recalibration of feature maps.
[0091] The compression part of the feature map compresses the length and width dimensions of the input feature map to 1×1 through a global pooling operation, ignores the length and width dimension information to reduce the amount of computation, and concatenates all feature maps that have undergone global average pooling in the channel dimension.
[0092] The conversion part of the feature map is to convert the global feature vector obtained by feature map compression into an intermediate representation. This intermediate representation will be used for subsequent channel weight calculations. In the conversion part of the feature map, a one-dimensional convolution is introduced to achieve feature conversion, which has the following effects:
[0093] (1) Parameter sharing: The same parameters are used to process pixels at different positions in the input feature map. This parameter sharing feature makes the one-dimensional convolution have fewer parameters.
[0094] (2) Local correlation: Capturing the local correlation of the input sequence. In feature map conversion, one-dimensional convolution helps the model learn the local relationship between channels, thereby better modeling channel attention.
[0095] (3) Translation invariance: The input is translation invariant. This means that if the input feature is translated in position, the feature map obtained after one-dimensional convolution still maintains the corresponding translation. This property makes one-dimensional convolution insensitive to input position information and focuses more on feature content information.
[0096] (4) Multi-scale modeling: One-dimensional convolution kernels of different sizes are used to model the input in different receptive fields. This multi-scale modeling capability enables one-dimensional convolution to capture different scale features of the input image.
[0097] This layer maps the global feature vector to a higher-dimensional or lower-dimensional intermediate representation to enhance the model’s expressiveness. This intermediate representation will contain more information about the relationship between channels and will be used for subsequent channel weight calculations.
[0098] The recalibration part of the feature map is the process of adjusting or converting the original feature map to change the representation or attribute of the feature. Recalibration can be achieved through different methods and techniques, depending on the task and goal. The present invention uses a one-dimensional convolution layer and a fully connected layer to establish a global association between features, which can consider the global information between features, so that it can better model complex channel relationships. By applying the activation function Sigmoid, a nonlinear relationship is introduced to control the channel weight range between [0,1]. The obtained feature map is split according to the channel dimension required by the output feature map of each layer, and then the channel weight is multiplied and weighted with the input feature map. This action recalibrates the weights of each channel. Finally, inspired by the idea of residual connection, the present invention superimposes the feature map obtained after recalibrating the weights of each channel with the original image to enhance the accuracy and stability of the model.
[0099] The bridging spatial attention module used in the present invention has similarities but differences with the spatial attention module.
[0100] The similarities are:
[0101] (1) The channel compression method is the same: Both methods compress each feature map into a single channel feature map. Assuming that the input feature dimension is (H, W, C), where H represents height, W represents width, and C represents the number of channels, the feature map dimension before and after the transformation is transformed from (H, W, C) to (H, W, 1). The feature representation of the single channel feature map is enriched by serializing the maximum pooling and average pooling operations.
[0102] (2) The weighting method is the same: the weight is multiplied by the original feature map pixel for weighting.
[0103] The differences are:
[0104] (1) Different sources of feature information: The input of the spatial attention module in the original CABM only comes from the feature map information of the same dimension, while the input of the bridged spatial attention module comes from the feature map information of five groups of different dimensions of U-Net.
[0105] (2) Different methods of extracting spatial attention weights: The spatial attention module in the original CABM extracts spatial attention weights by passing the feature map with dimension (H, W, 1) after feature compression through two fully connected layers, while the bridging spatial attention module concatenates the five layers of feature map dimensional information of U-Net with different dimensions through maximum pooling and average pooling respectively, which acts as a "bridge" for feature map information. The concatenated feature map is then passed through a shared expanded two-dimensional convolutional layer to extract the spatial attention weights.
[0106] (3) The feature information is recalibrated in different ways: the spatial attention module in the original CABM simply multiplies the extracted spatial attention weights and the original feature map, while the bridged spatial attention module multiplies the extracted spatial attention weights and the original feature map and superimposes them with the original feature map. This can avoid overfitting, reduce the interference of source feature map noise, and effectively improve the stability of the module during training.
[0107] Specifically, the module consists of three parts: compression splicing, spatial attention weight activation extraction, and spatial pixel weighting.
[0108] Compression splicing. As shown in the figure, the five input feature maps are respectively subjected to maximum and average pooling operations, and the spliced output tensors are obtained by obtaining a two-channel tensor. The width and height remain unchanged in the pooling operation. This operation can achieve the following effects:
[0109] (1) Enriching feature representation: Max pooling and average pooling operations can capture different types of features. The feature representation is enriched by cascading max pooling and average pooling operations.
[0110] (2) Enhanced robustness: Max pooling is more sensitive to noise and changes, while average pooling is relatively insensitive to noise and changes. By connecting max pooling and average pooling in series, the robustness of the model is enhanced, making it better adaptable to different types of inputs.
[0111] (3) Improve feature diversity: The obtained two-channel feature maps capture the maximum and average feature information respectively. This diversity helps to provide more information to distinguish different feature patterns.
[0112] Spatial attention weight activation extraction. Using dilated convolution operations, this operation process has the following effects:
[0113] (1) Reduce the number of parameters: Share convolution kernel weights. This is very beneficial for large networks and resource-constrained scenarios, while preventing overfitting.
[0114] (2) Enhanced feature representation: Expanding the convolution kernel’s perceptual range better captures image details. The shared dilated convolution operation can extract the same feature representation on the feature map by sharing the convolution kernel at different locations, thus enhancing the consistency and reusability of the features.
[0115] (3) Maintaining spatial resolution: The receptive field can be increased while maintaining the spatial resolution of the input and output. This is particularly important for tasks that require preserving details and location information, such as object detection and segmentation.
[0116] Spatial pixel weighting: Spatial pixel weighting is used to weight each pixel in an image to enhance or adjust its influence in the image. In spatial pixel weighting, each pixel is assigned a weight that determines the contribution of the pixel to the final processing result. Pixel weights are calculated based on their position or features in the image.
[0117] The model building module is used to build a CSAB-UNet model based on the U-Net model, and use the preprocessed data set to train the CSAB-UNet model.
[0118] The CSAB-UNet model is as follows: the convolution layer of the U-Net network and the pooling layer of the U-Net network are used to perform feature extraction and downsampling operations on the preprocessed data to obtain a feature map with modified size and number of channels; the deconvolution layer of the U-Net network, the bridge channel attention module and the bridge spatial attention module are used to upsample the feature map to restore the size and number of channels of the feature map.
[0119] The V-Net network structure includes: Encoder: Use convolutional layers and pooling layers to perform feature extraction and downsampling operations, gradually reducing the size and number of channels of the feature map. Decoder: Use deconvolutional layers and skip connections to perform upsampling operations, gradually restoring the size and number of channels of the feature map. Connect the feature map of the corresponding size in the encoder with the feature map in the decoder to retain more semantic information.
[0120] This embodiment replaces the original jump connections with bridge channel attention modules and bridge spatial attention modules, so that the network can adaptively obtain rich receptive field information, fuse the five-layer intermediate features of different scales in the expansion path into new features, and obtain the channel and spatial information concerned by the segmentation task, so as to facilitate the importance screening of new features.
[0121] The bridge channel attention module consists of three parts: feature map compression, feature map conversion, and feature map recalibration. This module introduces a mechanism that can adaptively adjust channel attention in different scenarios. The function of the feature map compression part is to reduce the amount of calculation and provide a basis for subsequent feature map conversion and recalibration.
[0122] The bridge spatial attention module can adaptively obtain feature information of different receptive fields according to the size of tumors, tissues, and organs in medical images, extract useful tumor, tissue, and organ information from complex medical images, and suppress irrelevant background information and noise. The module consists of three parts: compression splicing, spatial attention weight activation extraction, and spatial pixel weighting. The module fuses multi-stage and multi-scale information on the spatial axis to generate attention maps for each stage.
[0123] The semantic segmentation module is used to optimize the trained CSAB-UNet model using a hybrid loss function, and use the optimized CSAB-UNet model to perform semantic segmentation on real-time medical images to obtain segmentation results.
[0124] The mixed loss function is:
[0125]
[0126]
[0127] Bce_Dice_Loss=Loss_BCE+Loss_Dice
[0128] Among them, A is the predicted segmentation result, B is the actual segmentation result, p is the probability that a sample is predicted to be 1, and y is the actual label classification value (this experiment is binary classification).
[0129] In summary, the specific implementation steps of this embodiment are as follows: 1. Dataset selection: Select the medical image semantic segmentation datasets ISIC2017, ISIC2018, BreCaHAD, which contain original medical images and corresponding labels.
[0130] 2. Model selection: Based on the U-Net model, the bridge channel attention module and the bridge spatial attention module are used to replace the skip connection.
[0131] 3. Model selection: Preprocess the input image, including resizing, normalization, data augmentation, etc. Use data augmentation techniques such as random cropping, flipping, and rotation to improve the generalization ability of the model.
[0132] 4. Model training: Use the training set to train the selected model. During the training process, GT_BceDiceLoss is used to measure the difference between the model output and the true label. Considering the balance between convergence speed and learning ability, the initial learning rate defaults to 1e-3, the batch size (the number of samples used in each training) is 8, the epoch is set to 300, and the optimization algorithm AdamW is used to update the model parameters.
[0133] 5. Model evaluation: Use the test set to evaluate the trained model.
[0134] 6. Hyperparameter adjustment: According to the evaluation results of the model, adjust the model hyperparameters, such as learning rate, batch size, regularization parameters, etc., to further improve the model performance.
[0135] 7. Visualization results: Perform visual analysis on the model and compare the semantic segmentation results predicted by the model with the true labels to check the model accuracy and boundary details.
[0136] 8. Model deployment: Apply the trained model to the medical image test set for inference and generate semantic segmentation results.
[0137] Ablation experiments were conducted to verify the effectiveness of the designed bridge channel attention module and bridge spatial attention module. The control variable method was used to conduct 4 groups of experiments: the first group was: using the U-Net network; the second group was: using the U-Net network, replacing the jump connection with the bridge channel attention module; the third group was: using the U-Net network, replacing the jump connection with the bridge spatial attention module; the fourth group was: using the U-Net network, replacing the jump connection with the bridge channel attention module, and adding the bridge spatial attention module. The experimental results verified that the bridge channel attention module can select channel information that is more important for the segmentation task, thereby improving the model segmentation ability.
[0138] This embodiment uses a mixed loss function Bce_Dice Loss during training to increase the model's analysis and optimization capabilities. The model addresses the problem of too large a proportion of background pixels in the image, and considering the advantages and disadvantages of BCE and Dice Loss, the new loss function after integrating the two is Bce_Dice_Loss. This improves the accuracy of the model's prediction results. In the experiment, a variety of data enhancement methods were also used to increase the amount of training data to make the network more robust.
[0139] The embodiments described above are only descriptions of the preferred embodiments of the present invention and are not intended to limit the scope of the present invention. Without departing from the design spirit of the present invention, various modifications and improvements made to the technical solutions of the present invention by ordinary technicians in this field should all fall within the protection scope determined by the claims of the present invention.
Claims
1. A medical image semantic segmentation method based on channel and spatial attention mechanism, characterized in that: The method comprises: S1. Collect historical medical image datasets and preprocess the datasets; S2. Build a CSAB-UNet model based on the U-Net model, and use the preprocessed data set to train the CSAB-UNet model. The CSAB-UNet model is as follows: use the convolution layer of the U-Net network and the pooling layer of the U-Net network to perform feature extraction and downsampling operations on the preprocessed data to obtain a feature map with modified size and number of channels; use the deconvolution layer of the U-Net network to upsample the feature map, restore the size and number of channels of the feature map, and use the bridge channel attention module and the bridge spatial attention module to retain the required semantic information for the downsampled feature map corresponding to the size of the upsampled feature map; S3. Use the hybrid loss function to optimize the trained CSAB-UNet model, and use the optimized CSAB-UNet model to perform semantic segmentation on real-time medical images to obtain segmentation results.
2. The method for semantic segmentation of medical images based on channel and spatial attention mechanism according to claim 1, characterized in that: In S1, the preprocessing method specifically includes: The collected historical medical image datasets are cleaned and annotated. The data cleaning and annotation process specifically includes: Performing image format conversion, size adjustment, and color correction on the collected historical medical image datasets so that the format, resolution, and size of the historical medical image datasets are consistent; Based on the adjusted historical medical image dataset, noisy and incomplete images are removed to obtain basic metadata information; Using a labeling tool to label the basic metadata information; The labeled data is enhanced to obtain data enhancement information, and the data enhancement information is stored to obtain preprocessed data.
3. The method for semantic segmentation of medical images based on channel and spatial attention mechanism according to claim 1, characterized in that: In S2, the bridge channel attention module includes a feature map compression module, a feature map conversion module and a feature map recalibration module; the bridge spatial attention module includes a compression splicing module, a tough attention weight activation extraction module and a spatial pixel weighting module.
4. The method for semantic segmentation of medical images based on channel and spatial attention mechanism according to claim 1, characterized in that: In S3, the mixed loss function is: Bce_Dice_LossLoss_BCE+Loss_Dice Among them, A is the predicted segmentation result, B is the actual segmentation result, p is the probability that a sample is predicted to be 1, and y is the actual label classification value.
5. A medical image semantic segmentation system based on channel and spatial attention mechanism, the system is used to implement the medical image semantic segmentation method according to any one of claims 1 to 4, characterized in that: The system includes: data collection module, model building module and semantic segmentation module; The data collection module is used to collect historical medical image data sets and preprocess the data sets; The model building module is used to build a CSAB-UNet model based on the U-Net model, and use the preprocessed data set to train the CSAB-UNet model; The semantic segmentation module is used to optimize the trained CSAB-UNet model using a hybrid loss function, and use the optimized CSAB-UNet model to perform semantic segmentation on real-time medical images to obtain segmentation results.
6. The medical image semantic segmentation system based on channel and spatial attention mechanism according to claim 5, characterized in that: The preprocessing process of the data collection module includes: The collected historical medical image datasets are cleaned and annotated. The data cleaning and annotation process specifically includes: Performing image format conversion, size adjustment, and color correction on the collected historical medical image datasets so that the format, resolution, and size of the historical medical image datasets are consistent; Based on the adjusted historical medical image dataset, noisy and incomplete images are removed to obtain basic metadata information; Using a labeling tool to label the basic metadata information; The labeled data is enhanced to obtain data enhancement information, and the data enhancement information is stored to obtain preprocessed data.
7. The medical image semantic segmentation system based on channel and spatial attention mechanism according to claim 5, characterized in that: The bridge channel attention module of the model building module includes a feature map compression module, a feature map conversion module and a feature map recalibration module; the bridge spatial attention module includes a compression splicing module, a difficult-to-solve attention weight activation extraction module and a spatial pixel weighting module.
8. The medical image semantic segmentation system based on channel and spatial attention mechanism according to claim 5, characterized in that: The hybrid loss function of the semantic segmentation module is: Bce_Dice_LosSLoss_BCE+LoSs_Dice Among them, A is the predicted segmentation result, B is the actual segmentation result, p is the probability that a sample is predicted to be 1, and y is the actual label classification value.
Citation Information
Patent Citations
Medical image segmentation method based on multi-scale cross-layer attention fusion network
CN117152433A
Method for accurately segmenting medical image
CN117994517A
Medical image segmentation model based on lightweight attention module and training method of model
CN118212417A
Medical image segmentation method based on u-net
US20220309674A1
Cited By
Bone tumor medical image segmentation method based on improved mixed attention mechanism and TransUnet model
CN119579897A
Medical image data segmentation method and system
CN119963567A
A medical imaging data segmentation method and system
CN119963567B
Method, system and equipment for estimating eye muscle area and backfat thickness of live pig based on deep learning
CN122289214A
