Fundus image segmentation method and device based on multi-scale cross-fusion attention
By introducing a multi-scale cross-fusion attention mechanism into the fundus image segmentation model, combined with Transformer and convolution modules, the problem of multi-scale information capture and semantic gap in the existing technology is solved, significantly improving the fundus image segmentation performance and achieving more accurate Optic cup and optic disc segmentation.
Patent Information
- Application Number
- CN202411111147.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-14
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-08-14
AI Technical Summary
Existing fundus image segmentation models are difficult to effectively capture multi-scale information when dealing with complex scale changes, resulting in limited improvements in the model's fundus image segmentation performance, especially because the serialization processing of the ViT network ignores image channel and position features, and U- The semantic gap problem in the net network is difficult to completely solve.
A fundus image segmentation model based on multi-scale cross-fusion attention is adopted. By constructing a segmentation network including a Transformer and convolution joint module and a dual-path attention module, it combines multi-head self-attention, position attention, channel attention and multi-head cross attention. Powerful, a multi-scale dual attention module is introduced to fuse global features and image-specific spatial and channel features to reduce the semantic gap between the encoder and the decoder.
It achieves better optic cup and optic disc segmentation performance, improves the model's ability to perceive multi-scale information, enhances feature extraction and discriminability, and ensures more accurate feature reconstruction and segmentation results.
Smart Images

Figure CN118644679B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to image processing technology, and in particular to a fundus image segmentation method and device based on multi-scale cross-fusion attention. Background Art
[0002] Fundus image segmentation is to segment the optic disc (OD) and optic cup (OC) areas of the fundus image, which can effectively assist in the diagnosis of glaucoma. The ViT (Vision Transformer) network has been used for fundus image segmentation. However, the ViT network often processes images by converting them into sequences. Therefore, this operation ignores the influence of channel and specific position features in the image, thereby limiting the improvement of the image segmentation model performance. The researchers integrated the window self-attention method in Swin-Transformer with the U-net network structure, and solved the above problems to a certain extent by using relative position encoding and sliding windows. These methods have made progress in combining the Transformer module with the U-type network structure, but there are still some defects, such as the accumulation of a large number of self-attention modules leading to a sharp increase in the number of model parameters.
[0003] In addition, the core of the design of the U-net network structure is to realize feature extraction and feature restoration respectively by constructing an encoder and a decoder, and designing a jump connection module to pass the initial features to the decoder, thereby bridging the semantic gap between the encoder and the decoder. One of the main challenges of the ordinary jump connection module is the semantic gap between multi-scale feature encoders and between the encoder and the decoder. In order to reduce the above semantic gap, a large number of methods based on dense jump connections instead of ordinary jump connections have been proposed, such as Unet++, Unet3+, etc. These methods effectively narrow the semantic gap between the encoder and decoder sub-networks by introducing dense jump connections in a series of convolution operations, achieving better segmentation performance. However, different tissues and lesions in fundus images are often displayed at different feature scales. In order to enhance the model's perception of complex scenes, it is usually necessary to introduce multi-scale features. Therefore, capturing multi-scale information is crucial to solving complex scale changes in fundus images. Although past research has achieved certain results, there are still challenges, such as the inability to effectively obtain sufficient multi-scale information from the global scale. Summary of the invention
[0004] Based on this, the present invention provides a fundus image segmentation method and device based on multi-scale cross-fusion attention, which at least solves one problem in the prior art.
[0005] In a first aspect, the present invention provides a fundus image segmentation model training method based on multi-scale cross-fusion attention, which comprises the following steps:
[0006] Constructing a segmentation network including an encoder, a skip connection module and a decoder, wherein the encoder includes a Transformer and convolution joint module and a dual-path attention module; the skip connection module includes a multi-scale dual attention module;
[0007] The segmentation network is trained using a training set containing fundus images, wherein in the Transformer and convolution joint module, multi-head self-attention is applied to the feature map of the fundus image, and depth-separable convolution is performed; in the dual-path attention module, position attention is applied to the feature map output by the Transformer and convolution joint module, and channel attention is applied; in the multi-scale dual attention module, channel fusion attention is applied to the feature map output by the encoder, and multi-head cross attention is applied;
[0008] The loss of the segmentation network is calculated, and the parameters of the segmentation network are updated according to the loss.
[0009] In some optional embodiments, applying multi-head self-attention includes:
[0010] Apply multi-head self-attention after linear transformation on the feature map of the fundus image, as shown in equations (1) and (2);
[0011]
[0012] in, LN represents the linear normalization operation, X represents the input feature map, W Q , W K , W V They represent the projection weight matrix, Q , K , V Represent the query vectors of multi-head self-attention respectively ( query ), key vector ( key ) and numeric vectors ( value ); represents the softmax function, T represents the transpose of the feature matrix, Conv (·) represents the convolution operation, represents approximate normalization, X atten Represents the feature map of multi-head self-attention restored in linear space.
[0013] In some optional embodiments, applying position attention includes:
[0014] Extracting a local feature map from the feature map output by the Transformer and convolutional joint module A , through the convolution layer, the local feature map A Feature Map P , feature map Q and feature map O , the feature map P and feature map Q Reshape into , and the feature map Q and feature map P The transpose of is used for matrix multiplication, and then the Softmax layer is used to calculate the spatial feature weights S , as shown in formula (3);
[0015] Reshape the feature map O into And with the spatial feature weight S Perform matrix multiplication and then reconstruct it into The size and parameters α Multiply and then with the local feature map A Perform element-by-element summation to get the output E , as shown in formula (4);
[0016]
[0017] in, , C Indicates the channel, H Indicates height, W Indicates width; N represents the number of pixels, and N = H × W ; Indicates i Position to j The weight matrix of the influence of each position; exp(·) represents the power of the natural constant e.
[0018] In some optional embodiments, applying channel attention includes:
[0019] The local feature map A Reshape into And with the local feature map A The transpose of is used for matrix multiplication, and then the Softmax layer is used to calculate the channel feature weights , as shown in formula (5);
[0020] The channel feature weights The transpose and local feature map of APerform matrix multiplication and then reconstruct it into The size and parameters β Multiply and then with the local feature map A Perform element-by-element summation to get the output E , as shown in formula (6);
[0021]
[0022] in, Indicates i Channel pair j The weight matrix of the influence of each channel.
[0023] In some optional embodiments, applying channel fusion attention includes:
[0024] The feature map output by the encoder is Convolution, global average pooling, channel combination and normalization operations are performed to obtain a global feature expression, which is then combined with The feature maps obtained by convolution are multiplied, and the number of channels is restored through the convolution operation. Finally, the feature map with the restored number of channels and the feature map output by the encoder are added, as shown in equations (7) to (10);
[0025]
[0026] in, X i represents the feature map output by the encoder, Conv represents the convolution operation, D i express Feature map obtained by convolution; GAP represents global average pooling, F Represents the feature map obtained by global average pooling; Concat (·) indicates channel combination operation, represents the sigmoid function, G Represents global feature expression; represents element-wise product; Represents the output feature map.
[0027] In some optional embodiments, applying multi-head cross attention includes:
[0028] The feature map output by the encoder is embedded and linearly transformed, and then multi-head cross attention is applied, as shown in equations (11) to (14);
[0029]
[0030] in, Embedding Indicates reducing the feature map to a fixed size; W Q , W K , W V They represent the weight matrices of self-attention, W Q , W K , W V ; Q i , K i , V i Respectively represent the query vectors obtained from the features of different stages ( query ), key vector ( key ) and numeric vectors ( value ); , Representing different stages K i , V i The result of splicing; represents approximate normalization, Represents the output feature map.
[0031] In some optional embodiments, the loss of the segmentation network is calculated by equation (17):
[0032]
[0033] In formula (17), Loss Dice represents the Dice loss function, calculated by formula (15); Loss CE represents the cross entropy loss function, calculated by formula (16);
[0034]
[0035] in, and Respectively represent i The actual category and predicted category of pixels, and Respectively represent i Pixels belong to c Actual and predicted probabilities of classes; C Indicates the pixel category.
[0036] In a second aspect, the present invention provides a fundus image segmentation model training device, comprising:
[0037] at least one processor;
[0038] and a memory communicatively coupled to the at least one processor;
[0039] Wherein, the memory stores instructions, and when the instructions are executed by the at least one processor, the fundus image segmentation model training method based on multi-scale cross-fusion attention is implemented.
[0040] In a third aspect, the present invention provides a fundus image segmentation method, which comprises the following steps: inputting the fundus image into the fundus image segmentation model obtained by the fundus image segmentation model training method based on multi-scale cross-fusion attention, and outputting the target image by the fundus image segmentation model.
[0041] In a fourth aspect, the present invention provides a fundus image segmentation device, comprising:
[0042] at least one processor;
[0043] and a memory communicatively coupled to the at least one processor;
[0044] The memory stores instructions, and when the instructions are executed by the at least one processor, the fundus image segmentation method is implemented.
[0045] Due to the adoption of the above technical solution, the embodiments of the present invention have at least the following beneficial effects:
[0046] (1) The optic cup and optic disc segmentation network combines convolutional attention and Transformer self-attention. The network effectively combines global features with image-specific spatial and channel features to achieve better segmentation performance;
[0047] (2) The introduction of a dual-path attention module in the encoder improves the encoder’s ability to extract and filter specific image features, thereby increasing the discriminability of the learned features;
[0048] (3) The introduction of a multi-scale dual attention module in the skip connection module not only effectively integrates the global features with the spatial and channel features in the image to achieve multi-scale semantic information extraction, but also facilitates the decoder to achieve accurate feature reconstruction. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 Schematic diagram of the framework of the fundus image segmentation network in one embodiment of the present invention.
[0050] Figure 2Schematic diagram of the structure of the Transformer and convolution joint module in one embodiment of the present invention.
[0051] Figure 3 Schematic diagram of the structure of a dual-path attention module in one embodiment of the present invention.
[0052] Figure 4 Schematic diagram of the structure of a multi-scale dual attention module (MDAM) in one embodiment of the present invention.
[0053] Figure 5 The images and masks of some images in the Drishti-GS1 dataset after data augmentation in one embodiment of the present invention are shown, wherein (a) is the fundus image after data augmentation, (b) is the OD original mask, (c) is the OC original mask, (d) is the fundus image after ROI extraction, (e) is the OD mask extracted by ROI, and (f) is the OC mask extracted by ROI.
[0054] Figure 6 Figure 2 shows images and masks of some images in the REFUGE dataset after data amplification in one embodiment of the present invention, where (a) is the original image, with the first row showing images of patients with glaucoma and the second row showing normal fundus images; (b) is the original OD and OC masks; (c) is the fundus image after ROI extraction; and (d) is the mask after ROI extraction.
[0055] Figure 7 The figure shows the joint optic disc and optic cup segmentation results of different models on the Drishti-GS1 dataset in one embodiment of the present invention, wherein (a) is a color fundus image, (b) is a true mask, (c) is the segmentation result of model I, (d) is the segmentation result of model II, (e) is the segmentation result of model III, and (f) is the segmentation result of MCA-Unet.
[0056] Figure 8 The figure shows the joint optic disc and optic cup segmentation results of different models on the REFUGE dataset in one embodiment of the present invention, where (a) is the color fundus image, (b) is the true mask, (c) is the segmentation result of model I, (d) is the segmentation result of model II, (e) is the segmentation result of model III, and (f) is the segmentation result of MCA-Unet.
[0057] Fig. 9 The figure shows the ROC curve and AUC value of MCA-Unet for glaucoma screening on the Drishti_GS1 dataset in one embodiment of the present invention.
[0058] Fig.10The figure shows the ROC curve and AUC value of MCA-Unet for glaucoma screening on the REFUGE dataset in one embodiment of the present invention. DETAILED DESCRIPTION
[0059] The following is a clear and complete description of the concept of the present invention and the technical effects produced, so as to fully explain the purpose, scheme and effect of the present invention.
[0060] Figure 1 The schematic diagram of the framework of the fundus image segmentation network in one embodiment of the present invention is shown in Figure 1. For ease of representation, the fundus image segmentation network is represented by MCA-Unet (Multi-scale cross-fusion attention U-net). MCA-Unet consists of an encoder, a skip connection module, and a decoder, wherein the encoder and the decoder include a Transformer and a convolution joint module (Trans-conv Joint Module), and a feature enhancement module, a dual-attention module, is added to the encoder, and the skip connection module includes a multi-scale dual attention module (MDAM).
[0061] The Transformer and convolutional joint module is the basic module of the encoder and decoder. In this embodiment, the structure of the Transformer and convolutional joint module is as follows: Figure 2 As shown in the figure. Since ViT has a high computational complexity and does not design an extraction structure based on hierarchical features, its application in pixel-intensive tasks is limited. The Transformer and convolutional joint module first uses low-rank projection to reduce the computational complexity of large feature maps; secondly, it strengthens the local feature extraction capability while further reducing the computational complexity through hierarchical feature extraction structure and depthwise separable convolution.
[0062] The encoder consists of four stages to extract hierarchical features, each of which includes a different number of Transformer and convolutional joint modules (3, 4, 9, and 3 respectively). First, the original image X 0 is input into the network and converted into X 1. Then, each layer of feature maps is processed by the Transformer and convolution joint module and input into the dual-path attention module for further image position and channel feature enhancement. Then, the feature map is input into the jump connection module and the next layer feature extractor. The Transformer and convolution joint module includes a linear space multi-head self-attention module and a convolution module. The linear space multi-head self-attention module is used to apply multi-head self-attention to the feature map of the fundus image, and the convolution module is used to perform depth-separable convolution.
[0063] Linear spatial multi-head self-attention module: Before the multi-head self-attention calculation, a convolution operation is first performed to reduce K and V The spatial resolution between , thereby reducing the computational cost, the process can be expressed as:
[0064]
[0065] in, LN represents the linear normalization operation, AP represents average pooling, X As the input feature map, W Q , W K , W V They represent the projection weight matrix, Q , K , V Represent the query vectors of multi-head self-attention respectively ( query ), key vector ( key ) and numeric vectors ( value ); represents the softmax function, T represents the transpose of the feature matrix, Conv (·) represents the convolution operation, represents approximate normalization; X atten Represents the feature map of multi-head self-attention restored in linear space.
[0066] Convolutional module: Layer normalization, fully connected layers, depthwise separable convolution (DWconv), and GELU activation functions are incorporated into the convolutional module. Layer normalization converts the input features into features with a mean of 0 and a variance of 1. Fully connected layers, also known as linear layers, perform linear transformations on the input data. At the same time, DWconv is introduced to improve the network's ability to extract local information without significantly increasing the computational cost.
[0067] In order to solve the problem of position and channel information loss caused by the serialization operation of the image by the Transformer and convolutional joint module, the Dual-Attention Block is used to extract and utilize the specific position and channel features of the image.
[0068] As a feature extraction module, the dual-path attention module integrates the image-specific features of position and channel, thereby extracting the position and channel features of the image and passing them to the next layer of the network to achieve feature enhancement. Especially in the U-shaped architecture, the feature extraction capability of the dual-path attention module is crucial. Although Transformer is good at using the self-attention mechanism to extract global features, its way of converting images into sequences for processing ignores the channel and position features contained in the image. In contrast, the dual-path attention module can realize feature extraction based on position and channel, thereby enhancing the transformer's ability to extract and filter specific image features. Figure 3 As shown in the figure. The dual-path attention module consists of two main parts: one is the position attention module (PAM) and the other is the channel attention module (CAM). When the feature map is input into the dual-path attention module, the number of channels is first scaled to 1 / 16 through a convolution to reduce the calculation parameters. Subsequently, the scaled features are input into the PAM and CAM modules respectively to obtain the position and channel enhanced features. After another convolution operation, the two are accumulated and summed, and the number of channels is restored in the last convolution operation to obtain the enhanced and extracted features.
[0069] Position Attention Module (PAM): Figure 3 As shown in , PAM can capture the spatial dependency between any two positions in the feature map and update specific features by the weighted sum of all position features. The weight is determined by the feature similarity between the two positions. Therefore, PAM can effectively extract meaningful spatial features. The calculation process is shown in equations (3) and (4). PAM first extracts a local feature map, represented as ( C Indicates the channel, H Indicates height, W Indicates width); then, A Input the convolutional layer and get three new feature maps, namely P , Q and O , the size of each feature map is ; and P and Q Reshape into ,in, N represents the number of pixels, and N = H × W ; Then, in Q and P , and then use the Softmax layer to calculate the spatial feature weights. .
[0070]
[0071] in, Indicates i Position to j The weight matrix of the influence of each position, exp(·) represents the power of the natural constant e.
[0072] Next, the feature map O Reshape into ; Spatial feature weight S and O After matrix multiplication, it is reconstructed into The size of the α Multiply, finally S With the original feature map A Perform element-by-element summation to get the final output In this embodiment, the parameter α Initialized to 0, and then gradually learned iteratively. E It is generated by the weighted sum of all position features and original features, so it has global context features and can aggregate context according to the spatial attention map, which makes PAM have strong spatial feature extraction capabilities and effectively extracts and strengthens position features.
[0073] Channel Attention Module (CAM): Figure 3 As shown in Figure 2, unlike PAM, CAM is better at extracting channel features of images. Reshape The size of A Perform matrix multiplication between and its transpose, and pass through the softmax layer to obtain the channel feature weights :
[0074]
[0075] in, Indicates i Channel pair j The weight matrix of the channel influence. Then, X The transpose of A Perform matrix multiplication between them and reshape the result into The result is then multiplied by the learnable parameter β , and A Perform element-by-element summation to get the final output Similar to PAM, when extracting channel features in CAM, the final features of each channel are generated by the weighted sum of the original features of all channels. The final generated probability feature map represents the enhanced channel features, and then operations such as element multiplication are performed to filter out the feature map enhanced by channel features.
[0076] In order to alleviate the semantic gap between low-level features and high-level features, and between encoders and decoders, and to fuse the multi-scale features in the encoder to improve the sparse coding features and help the decoder to reconstruct the feature map more accurately, a multi-scale dual attention module (MDAM) is used in the skip connection to eliminate the semantic gap between multi-level features. Figure 4 As shown in the figure, MDAM contains a channel fusion attention (CFA) module and a channel fusion Transformer (CFT) module, which jointly guide the adaptive fusion of multi-scale features to capture effective information and suppress irrelevant noise.
[0077] The main structure of the CFA module is as follows Figure 4 As shown below, it can adaptively learn the weights of channel features at different stages from a global perspective, allowing the network to focus on the channel features of interest and suppress the influence of irrelevant areas. First, the module accepts features extracted from encoders at different layers. As the original input, input In the convolutional layer, the channel dimensions are unified; then global average pooling is performed to obtain feature representations at different stages ; All phase features The global feature expression is obtained by combining the Concat operation and then normalizing it. G ; Then express the global features G With each stage The convolutional features are multiplied and the convolution operation is used to restore each feature to its original number of channels. ; Finally, the original features are taken as the residual and added to the channel-enhanced features to obtain the final output; the above process can be expressed as follows:
[0078]
[0079] in, Conv represents the convolution operation, GAP represents global average pooling, Concat (·) indicates channel combination operation, represents the sigmoid function, represents element-wise product, Represents the final output of the CFA module.
[0080] The channel fusion transformer (CFT) module is another component of the MDAM module. It implements multi-level feature cross-fusion in three steps to achieve the global perception ability of the model. First, similar to CFA, the features of different stages of the encoder are The spatial resolution of feature maps of different sizes is reduced to the same size through the embedding operation, and then obtained by linear transformation Q , K , V ; then from four different stages and They are connected and merged separately and input into the multi-head cross attention (MHCA) module; the self-attention operation of the MHCA module is mainly performed along the channel dimension rather than on the spatial dimension; finally, the result is input into the multi-layer perceptron, and two linear transformation operations are applied to provide nonlinear activation for the module; the above process can be described as follows:
[0081]
[0082] in, Embedding Indicates that feature maps of different sizes are uniformly reduced to size; W Q , W K , W V They represent the weight matrices of self-attention, W Q , W K , W V ; Q i , K i , V i Represents the query vectors obtained from the features at different stages ( query ), key vector ( key ) and numeric vectors ( value ); , Representing different stages K i , V i The result of splicing; represents approximate normalization; Indicates the result after the MHCA module operation.
[0083] Finally, the output results of each stage of CFA and CFT are added and input into the corresponding stage of the decoder. The skip connection module can effectively combine multi-scale global features with image-specific spatial and channel features, reduce the semantic gap between different layers, and enhance the feature restoration process of the decoder.
[0084] The decoder receives features from the jump connection module and performs feature concatenation to alleviate the semantic gap between the encoder and decoder, thereby achieving efficient feature expression. The decoder includes a Transformer and a convolutional joint module. The underlying features of the jump connection are first extracted by the Transformer and convolutional joint module, and the features of the same layer are concatenated with the feature map. The concatenated result is then upsampled and convolved to obtain the next layer of features and repeat the above operation. The final feature map is passed through Softmax to obtain the final optic cup and optic disc segmentation result.
[0085] Traditional segmentation tasks often use the cross entropy loss function for training deep learning models. However, when dealing with more precise OC segmentation in the optic cup and optic disc segmentation task, since OC occupies a smaller area of the overall image, the loss function often has obvious class imbalance problems, which is not conducive to OC segmentation. Therefore, a loss function that integrates Dice loss and cross entropy loss is used in MCA-Unet to utilize the fast convergence of the cross entropy loss function while using the Dice loss function to overcome the class imbalance problem. The Dice loss function is specifically expressed as follows:
[0086]
[0087] in, and Respectively represent i The actual and predicted categories of pixels.
[0088] The specific definition of the cross entropy loss function is as follows:
[0089]
[0090] in, and Respectively represent i Pixels belong to c Actual and predicted probabilities of classes; C Represents the pixel category. There are three types of pixel categories: background, optic cup and optic disc.
[0091] The final loss function is as follows:
[0092]
[0093] Among them, λ is used as a hyperparameter and the best results are obtained when it is set to 0.5.
[0094] Experiments are conducted using the publicly available optic cup and optic disc segmentation data Drishti-GS1 and the REFUGE set to verify the performance of MCA-Unet.
[0095] In order to reduce the interference of irrelevant noise on the performance of the model, the circular Hough transform-based method was used to preprocess the data and extract the region of interest (ROI). The DRISHTI-GS1 dataset contains 50 training sets and 51 fundus images as test sets. The REFUGE dataset contains 400 test sets, 400 validation sets, and 400 test sets, totaling 1,200 fundus images. Table 1 shows the specific information of the datasets used.
[0096] Table 1 Detailed information of DRISHTI-GS1 and REFUGE datasets
[0097]
[0098] Since the annotation of medical image data is time-consuming and costly, the number of training images in the Drishti-GS1 dataset is relatively small. In order to prevent overfitting, the target dataset randomly rotates images in the range of (-45, 45) and scales images in the range of (0.01, 0.1). After data augmentation, the number of training images in the Drishti-GS1 dataset reaches 1050. Figure 5 and Figure 6 Some images from the two datasets are shown.
[0099] In the experiment, the hardware environment for training and testing is as follows: the CPU type is Intel® Core™ i9-12900K Processor, memory 64G, GPU is Nvidia GeForce RTX 3090, video memory 24G; the integrated development environment is PyCharm, the programming language is Python (Version=3.7.13), the deep learning framework is PyTorch (torch==1.12), the versions of Cuda and cuDNN are 11.3 and 8.3 respectively, and the CUDA driver version is 456.89. During the experiment, Adamw is used as the optimizer, the learning rate is set to 5e-5, and the training batch size is 4.
[0100] The Dice coefficient (DC) and the vertical cup to disc ratio (CDR) are used to evaluate the performance of the model. The Dice coefficient is a commonly used evaluation indicator in standard segmentation tasks, which is used to evaluate the similarity between the model prediction results and the true mask. CDR is an important measurement indicator in clinical screening for glaucoma. Therefore, the mean absolute error between the model prediction results and the true mask CDR is calculated to measure the difference. The specific formula is as follows:
[0101]
[0102] in, TP Represents the number of positive samples correctly predicted by the model; FP Represents the number of samples that the model incorrectly predicts to be positive; FN represents false negatives, that is, the number of samples that the model incorrectly predicts as negative. Dice Coefficient and IoU The value range is between 0 and 1. The closer the model prediction result is to 1, the better the model performance is. and Represent the vertical diameters of the optic cup and optic disc, and Represent the CDR value predicted by the model and the actual CDR value, respectively. It indicates a better segmentation prediction effect.
[0103] In order to make the network converge quickly and obtain better training results, this experiment tested three different loss functions and finally selected a hybrid loss function composed of the Dice loss function and the cross entropy loss function. Experimental comparisons were conducted on the Drishti-GS1 and REFUGE datasets. The experimental results are shown in Table 2, which proves that the hybrid loss function Loss More suitable for precise optic cup and optic disc segmentation tasks.
[0104] Table 2 Segmentation results of different loss functions on Drishti-GS1 and REFUGE datasets
[0105]
[0106] A series of ablation experiments were conducted on the Drishti-GS1 and REFUGE datasets. The specific combination strategies are as follows:
[0107] Model I (Baseline+TJM): uses the data with enhancement and feature extraction as input, and uses the Transformer and Convolution Joint Module (TJM) to replace the original convolution module in the baseline network;
[0108] Model II (Baseline + TJM + MDAM): Based on Model I, the features of the encoder and decoder are concatenated with the multi-scale dual attention module (MDAM) to achieve multi-scale feature fusion;
[0109] Model III (Baseline + TJM + MDAM + CAM): represents adding a channel attention module to the encoder based on Model II;
[0110] Model IV (Baseline+ TJM + MDAM + Dual-Attention, MCA-Unet): Introduces a dual-path attention module based on Model III.
[0111] A series of ablation experiments use U-Net as the original baseline structure. The specific experimental results are shown in Table 3.
[0112] Table 3 Ablation test results of different model modules
[0113]
[0114] When Transformer and convolutional joint modules, MDAM, CAM, and Dual-Attention are added to the model in sequence, the performance evaluation indicators are gradually improved, proving that these modules can fully improve the performance of the optic cup and optic disc segmentation task model. In order to more intuitively demonstrate the effectiveness of MCA-Unet, Figure 7-Figure 8 The segmentation effect of target data under different module combination strategies is demonstrated.
[0115] like Figure 7 As shown in the figure, the segmentation result of model I only obtains certain contours, and there is still a big difference between the segmentation effect and the real mask. When the proposed modules are gradually added to the model, the segmentation accuracy of the model is gradually improved. The OD segmentation result is closer to the real mask, and the edge is gradually smoother. In the more difficult OC segmentation, MCA-Unet shows a result that is more similar to the real mask.
[0116] Figure 8 The results of the ablation experiment on the REFUGE dataset are shown. Obviously, the segmentation results of Model I are imperfect and have obvious rough boundaries. When MDMA is added as a skip connection, the segmentation results are significantly improved, but the segmentation boundaries are still different from the true mask. Under the joint action of channel attention and position attention, MCA-Unet can capture more information and make the segmentation results smoother.
[0117] It can be seen that the gradually added modules significantly improve the segmentation performance of MCA-Unet in segmenting OD and OC, thus proving its effectiveness, and it has made more significant progress in the more difficult OC task.
[0118] MCA-Unet is compared with the current mainstream advanced methods for fundus image segmentation performance on the Drishti GS1 and REFUGE datasets. Table 4 shows the segmentation performance on the Drishti-GS1 dataset. The IoU and Dice results obtained by MCA-Unet for optic disc segmentation are 0.9538 and 0.9762, respectively. In the optic cup segmentation task, MCA-Unet showed more advanced performance, with IoU and Dice values of 0.8445 and 0.9132, respectively. Compared with the Unet network, MCA-Unet greatly improves the performance and is significantly better than other methods.
[0119] Table 4 Comparison results with the current mainstream model performance on the Drishti-GS1 dataset
[0120]
[0121] The experimental results on the REFUGE dataset are shown in Table 5. In the optic disc segmentation task, MCA-Unet obtained IoU and Dice results of 0.9294 and 0.9631 respectively; in the optic cup segmentation task, MCA-Unet obtained IoU and Dice coefficient results of 0.8312 and 0.9092 respectively. Compared with the SOTA method, the average Dice coefficient of MCA-Unet segmentation has been improved by 0.96%, and the Dice coefficient of the optic cup task has been improved by 0.72%, indicating that MCA-Unet has better performance in the fine target segmentation task.
[0122] Table 5 Performance comparison results with current mainstream models on the REFUGE dataset
[0123]
[0124] The optic cup and disc segmentation results obtained by MCA-Unet are used to calculate the evaluation index CDR of glaucoma and compare it with the current most advanced methods. The comparison results are shown in Table 6. MCA-Unet achieves the best performance results in terms of the average performance of the two datasets, thus verifying the effectiveness of MCA-Unet in glaucoma diagnosis.
[0125] Table 6 Comparison of CDR values with current mainstream methods on two datasets
[0126]
[0127] According to the segmentation results, the ROC curve and ROC curve area (AUC) were used to evaluate the diagnostic performance of the model. Fig. 9 and Fig.10As shown in the figure, the AUC scores of MCA-Unet on the Drishti_GS1 and REFUGE datasets are 0.9749 and 0.9520, respectively. Compared with the NENet method, the AUC scores of MCA-Unet on the Drishti_GS1 and REFUGE datasets are 0.8968 and 0.9644, respectively. The results show that MCA-Unet performs well in diagnosing glaucoma and can assist doctors in clinical diagnosis.
[0128] The above is only a preferred embodiment of the present invention. The present invention is not limited to the above implementation. As long as the technical effect of the present invention is achieved by the same or equivalent means, it should belong to the protection scope of the present invention. Within the protection scope of the present invention, its technical scheme and / or implementation method can have various modifications and changes.
Claims
1. A fundus image segmentation model training method based on multi-scale cross-fusion attention, characterized in that: The following steps are involved: Constructing a segmentation network including an encoder, a skip connection module and a decoder, wherein the encoder includes a Transformer and convolution joint module and a dual-path attention module; the skip connection module includes a multi-scale dual attention module; The segmentation network is trained using a training set containing fundus images, wherein in the Transformer and convolution joint module, multi-head self-attention is applied to the feature map of the fundus image, and depth-separable convolution is performed; in the dual-path attention module, position attention is applied to the feature map output by the Transformer and convolution joint module, and channel attention is applied; in the multi-scale dual attention module, channel fusion attention is applied to the feature map output by the encoder, and multi-head cross attention is applied; Calculating the loss of the segmentation network, and updating the parameters of the segmentation network according to the loss; Wherein, applying multi-head self-attention includes: Apply multi-head self-attention after linear transformation on the feature map of the fundus image, as shown in equations (1) and (2); in, LN represents the linear normalization operation, X represents the input feature map, W Q , W K , W V They represent the projection weight matrix, Q , K , V Represent the query vector, key vector and value vector of multi-head self-attention respectively; represents the softmax function, T represents the transpose of the feature matrix, Conv (·) represents the convolution operation, represents approximate normalization, X atten Represents the feature map of multi-head self-attention restored in linear space; Applying position attention includes: Extracting a local feature map from the feature map output by the Transformer and convolutional joint module A , through the convolution layer, the local feature map A Feature Map P , feature map Q and feature map O , the feature map P and feature map Q Reshape into , and the feature map Q and feature map P The transpose of is used for matrix multiplication, and then the Softmax layer is used to calculate the spatial feature weights S , as shown in formula (3); Reshape the feature map O into And with the spatial feature weight S Perform matrix multiplication and then reconstruct it into The size and parameters α Multiply and then with the local feature map A Perform element-by-element summation to get the output E , as shown in formula (4); in, , C Indicates the channel, H Indicates height, W Indicates width; N represents the number of pixels, and N = H × W ; Indicates i Position to j The weight matrix of the influence of each position; exp(·) represents the power of the natural constant e; Applying channel attention includes: The local feature map A Reshape into And with the local feature map A The transpose of is used for matrix multiplication, and then the Softmax layer is used to calculate the channel feature weights , as shown in formula (5); The channel feature weights The transpose and local feature map of A Perform matrix multiplication and then reconstruct it into The size and parameters β Multiply and then with the local feature map A Perform element-by-element summation to get the output E , as shown in formula (6); in, Indicates i Channel pair j The weight matrix of the influence of each channel; Applying channel fusion attention includes: The feature map output by the encoder is Convolution, global average pooling, channel combination and normalization operations are performed to obtain a global feature expression, which is then combined with The feature maps obtained by convolution are multiplied, and the number of channels is restored through the convolution operation. Finally, the feature map with the restored number of channels and the feature map output by the encoder are added, as shown in equations (7) to (10); in, X i represents the feature map output by the encoder, Conv represents the convolution operation, D i express Feature map obtained by convolution; GAP represents global average pooling, F Represents the feature map obtained by global average pooling; Concat (·) indicates channel combination operation, represents the sigmoid function, G Represents global feature expression; represents element-wise product; represents the output feature map; Applying multi-head cross attention includes: The feature map output by the encoder is embedded and linearly transformed, and then multi-head cross attention is applied, as shown in equations (11) to (14); in, Embedding Indicates reducing the feature map to a fixed size; W Q , W K , W V They represent the weight matrices of self-attention, W Q , W K , W V ; Q i , K i , V i They represent the query vector, key vector and numerical vector obtained from the features at different stages respectively; , Representing different stages K i , V i The result of splicing; represents approximate normalization, Represents the output feature map.
2. The method according to claim 1, characterized in that: The loss of the segmentation network is calculated by formula (17): In formula (17), Loss Dice represents the Dice loss function, calculated by formula (15); Loss CE represents the cross entropy loss function, calculated by formula (16); in, and Respectively represent i The actual category and predicted category of pixels, and Respectively represent i Pixels belong to c Actual and predicted probabilities of classes; C Indicates the pixel category.
3. A fundus image segmentation model training device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; Wherein, the memory stores instructions, which, when executed by the at least one processor, implement the fundus image segmentation model training method based on multi-scale cross-fusion attention as described in any one of claims 1-2.
4. A fundus image segmentation method, characterized in that: The following steps are involved: The fundus image is input into the fundus image segmentation model obtained by the fundus image segmentation model training method based on multi-scale cross-fusion attention as described in any one of claims 1-2, and the fundus image segmentation model outputs the target image.
5. A fundus image segmentation device, characterized in that: include: at least one processor; and a memory communicatively coupled to the at least one processor; Wherein, the memory stores instructions, and when the instructions are executed by the at least one processor, the fundus image segmentation method of claim 4 is implemented.
