Method, device and medium for lesion segmentation

By using convolutional neural network and transformer structure attention module in lesion segmentation, combined with unified labels and pseudo-labels, the problem of difficult-to-learn characteristics in lesion segmentation is solved, and the accurate segmentation and diagnosis of diabetic retinal lesions is achieved.

CN114287879BActive Publication Date: 2025-04-25CHONGQING INNOVATION CENTER OF BEIJING INSTITUTE OF TECHNOLOGY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111670565.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-31
Publication Date
2025-04-25
Estimated Expiration
2041-12-31

AI Technical Summary

Technical Problem

The prior art is difficult to learn the standard characteristics of the lesions in lesion segmentation, and the morphology between different lesions is similar, resulting in missegment and missegmentation.

Method used

A convolutional neural network is used to build a feature extraction model, combined with the global and feature attention module of transformer structure, and the accurate segmentation of diabetic retinal lesions through unified labels and pseudo-labels of multi-lesion segmentation and vascular segmentation.

Benefits of technology

Simultaneous segmentation of multiple DR lesions is achieved, the problem of pixel points imbalance in the anterior and posterior scene is overcome, detailed information and recessive pathological associations between the lesions and blood vessels are obtained, and the accuracy of diagnosis is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114287879B_ABST
    Figure CN114287879B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and medium for lesion segmentation, belonging to the field of computer vision, including a global attention module based on a transformer structure and a feature attention module based on a transformer structure, as well as the use of a weighted cross entropy loss function based on the above modules; the present invention can not only obtain detailed information of lesions and blood vessels and make full use of rich fundus prior information contained in vascular distribution, but also obtain the dependency relationship between different lesions in the image and the implicit pathological association between lesions and blood vessels, and can more accurately achieve simultaneous segmentation of multiple DR lesions, so that the problem of imbalance of foreground and background pixels is overcome, and the simultaneous and accurate segmentation of multiple lesions, which is difficult and important in actual medical diagnosis, is achieved, and the technical problems that the segmentation model in the prior art is difficult to learn the standard features of the lesions and there are mis-segmentation and wrong segmentation are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer vision, and more specifically, to a method, device and medium for lesion segmentation. Background Art

[0002] The existing technical solutions for lesion segmentation have the following technical problems: 1. The same lesion has great differences in different stages of disease development, making it difficult for the segmentation model to learn the standard features of the lesion; 2. There is a certain degree of morphological similarity between different lesions, such as hard exudates and soft exudates, which causes the model to mis-segment and wrong segmentation. The following example is diabetic retinopathy (DR) for illustration, but it is not limited to diabetes.

[0003] Diabetic retinopathy (DR) is a common complication caused by long-term diabetes. Increased blood sugar levels affect retinal blood vessels. In the early stage, it is mainly manifested by the appearance of microaneurysms in retinal blood vessels. In the middle stage, with the rupture of microaneurysms, local retinal ischemia occurs, and obvious cotton wool spots can be observed by the human eye. In the later stage, microvessels continue to proliferate, the pressure of new blood vessels continues to increase, and even rupture, the blood vessel wall adheres to the surrounding tissue, the retina ruptures, and finally blindness occurs.

[0004] It is generally believed that the most effective treatment for DR is to intervene in the early stages of the disease, such as laser photocoagulation. Therefore, early screening and diagnosis of diabetic patients are particularly important. In clinical diagnosis, DR screening mainly relies on ophthalmologists to examine color fundus images. However, the shortage of professional ophthalmologists and the poor medical environment in remote areas have seriously restricted the screening and diagnosis process, and manual real-time analysis is even more difficult. Summary of the invention

[0005] The purpose of the present invention is to overcome the deficiencies of the prior art and provide a method, device and medium for lesion segmentation, which solve the technical problems raised in the background.

[0006] The object of the present invention is achieved through the following solutions:

[0007] A method for lesion segmentation comprises the steps of:

[0008] S1, screen the data set and write the data interface required by the convolutional neural network according to the data characteristics of the data set;

[0009] S2, make dataset labels;

[0010] S3, build training set and test set;

[0011] S4, the construction of convolutional neural network, the establishment of feature extraction model, the input of image into convolutional neural network, and the segmentation results of multiple lesions were obtained respectively.

[0012] Further, in step S1, the data set includes an IDRiD data set and a DDR data set, and the data features include lesion segmentation labels and image resolutions of the data set IDRiD and the data set DDR.

[0013] Furthermore, in step S2, the sub-steps are included:

[0014] S21, construct unified labels for multi-lesion segmentation;

[0015] S22, create pseudo labels for blood vessels: use the DRIVE and STARE datasets with pixel-level annotations for blood vessels to pre-train a segmentation model, and obtain pseudo labels for blood vessels in the IDRiD and DDR datasets based on this model.

[0016] Furthermore, in step S3, the sub-steps are included: in the process of constructing the training set and the test set, the sub-steps are included: segmenting the data set, processing the data set into multiple equal parts.

[0017] Furthermore, in step S4, when the image input is a color fundus image, the segmentation results of multiple lesions of diabetic retinopathy and blood vessels are obtained respectively, and sub-step S40 is included: selecting a backbone network for feature extraction, constructing a global attention module based on a transformer structure, and obtaining preliminary features of blood vessels and lesions respectively through two global attention modules; constructing a feature attention module based on a transformer structure, and the input of the module includes two parts: lesion features and blood vessel features; and obtaining the segmentation results of lesions and blood vessels through the feature attention module.

[0018] Furthermore, step S40 includes sub-steps:

[0019] S401, selecting a backbone network for feature extraction, using a densenet-161 structure, the initialization parameters of which are set to the final parameters that have been fully trained on the ImageNet dataset in advance; integrating it into the convolution block of the U-type network, and using the U-type network to achieve effective feature extraction of the input image;

[0020] S402, construct a global attention module based on the transformer structure, including 3 first convolutional layers, 1 pooling layer and an activation function layer; the 3 first convolutional layers are used as generators to obtain indexes, key values ​​and content respectively, and the results of matrix multiplication of indexes and key values ​​are passed through an activation function layer to obtain an attention distribution map; the attention distribution map acts on the content in the form of element addition; the weighted content is abstracted through a first convolutional layer and added to the original input element through a short-circuit connection; when the input and output dimensions of the short-circuit connection are inconsistent, a second convolutional layer is used to increase the dimension of the input;

[0021] S403, construct a feature attention module based on the transformer structure, the input of which includes two parts: lesion features and vascular features; the lesion features are indexed through a first convolution layer and connected to the output end as a short-circuit connection; the vascular features are respectively passed through two first convolution layers to obtain key values ​​and content; the key value is first multiplied with the index matrix and then formed into an attention distribution map through an activation function; the attention distribution map acts on the content in the form of element addition; the weighted content is abstracted through a first convolution layer and added to the original input element through a short-circuit connection; when the input and output dimensions of the short-circuit connection are inconsistent, a second convolution layer is used to increase the dimension of the input.

[0022] Further, after step S403, the method includes the following steps:

[0023] S404, set training parameters and loss function strategy, select network optimizer, set initial learning rate, use cosine annealing function to decay learning rate, set training period and batch size, select activation function; the loss function used for multi-lesion segmentation and vascular segmentation results is weighted cross entropy loss function, which are respectively , ;

[0024] The total loss function L is expressed as follows:

[0025]

[0026] is the ratio of the two loss functions for network training and network testing; the network is tested using the test set to obtain multi-lesion segmentation and vascular segmentation results.

[0027] Furthermore, the first convolution layer is a 3x3 convolution layer, the second convolution layer is a 1*1 convolution layer, the network optimizer is an SGD optimizer, the initial learning rate is set to 0.001, the training period is set to 300, the batch size is 16, the activation function is a softmax function, and the network training and network testing are specifically performed using a leave-one-out cross-validation method for network training and network testing.

[0028] A device for lesion segmentation comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is loaded by the processor, the method described in any one of the above items is executed.

[0029] A readable storage medium stores a computer program, wherein the computer program is loaded by a processor and executes any of the above methods.

[0030] The beneficial effects of the present invention include:

[0031] The present invention solves the technical problems raised in the background and the technical problems existing in the segmentation of diabetic retinopathy (DR) lesions, and can obtain the dependency relationship between different lesions in the image and the implicit pathological association between lesions and blood vessels, so that the overall model can more accurately achieve the simultaneous segmentation of multiple DR lesions. At the same time, the use of the weighted cross entropy loss function overcomes the problem of imbalanced foreground and background pixels.

[0032] The present invention can not only obtain detailed information of lesions and blood vessels and make full use of the rich fundus prior information contained in the blood vessel distribution, but also obtain the dependency relationship between different lesions in the image and the implicit pathological association between lesions and blood vessels, and can more accurately achieve the simultaneous segmentation of multiple DR lesions, so that the problem of imbalance of foreground and background pixels is overcome, and the simultaneous and accurate segmentation of multiple lesions, which is more difficult and more important in actual medical diagnosis, is achieved, and the technical problems that the segmentation model in the prior art is difficult to learn the standard features of lesions and there are mis-segmentations and wrong segmentations. BRIEF DESCRIPTION OF THE DRAWINGS

[0033] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. 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.

[0034] Figure 1 is an overall flow chart of an embodiment of the present invention;

[0035] Figure 2 A schematic diagram of the overall network structure used in the embodiment of the present invention;

[0036] Figure 3 is a detailed schematic diagram of a global attention module in a network structure in an embodiment of the present invention;

[0037] Figure 4 Detailed schematic diagram of the feature attention module in the network structure in an embodiment of the present invention. DETAILED DESCRIPTION

[0038] All features disclosed in all embodiments in this specification, or steps in all methods or processes implicitly disclosed, except for mutually exclusive features and / or steps, can be combined and / or expanded or replaced in any manner.

[0039] The following is based on the attached Figure 1~Figure 4 , further detailed and comprehensive explanation is given to the technical problems solved by the present invention, technical concepts, working principles, working processes and beneficial effects.

[0040] In order to solve the problems raised in the background technology, the present invention believes that it is necessary to introduce computer-assisted treatment to reduce the burden on ophthalmologists, shorten the examination time, and reduce the time and labor cost of disease screening.

[0041] In the process of solving the above problems, the present invention found that deep learning algorithms are currently the most commonly used automatic medical image processing methods. Convolutional neural networks (CNNs) are a method for feature extraction in an end-to-end manner in deep learning algorithms. They have been widely used not only in target detection and semantic segmentation, but also in the medical field. The Transformer structure is an emerging network structure in the field of deep learning in recent years. It is widely used in various fields such as natural language processing, pattern recognition, and computer vision because it can model the dependencies of input and output sequences without considering their distance in the sequence. Therefore, the Transformer structure is used to effectively explore the relationship between different lesions in the input image, improve network performance, and achieve DR lesion segmentation in an automated manner to obtain accurate and reliable results, solve various complex problems encountered in manual screening, and make medical diagnosis more scientific, automated, and accurate. This will also become the main trend in the development of medical image processing.

[0042] The present invention has also found the following technical problems: Most existing methods do not take into account the intrinsic relationship between the development of DR and the appearance of different lesions, and pay too much attention to the design of network structure and the solution to common problems such as small samples. At the same time, for complex fundus structures such as optic nerve, optic disc, blood vessels, etc., only the emphasis is on avoiding their adverse effects while ignoring the rich fundus prior information they contain.

[0043] In view of the above technical problems, the design idea of ​​the embodiment of the present invention is as follows: to provide a technical solution for lesion segmentation, including corresponding methods, equipment and media. In specific implementation, a method for automatic segmentation of diabetic retinopathy lesions based on a transformer structure can be provided. Specifically, after feature extraction, a global attention module based on a transformer structure is further designed to obtain detailed information of lesions and blood vessels. Using the above lesion and blood vessel information, the embodiment of the present invention proposes another feature attention module based on a transformer structure. This module can obtain the dependency relationship between different lesions in the image and the implicit pathological association between lesions and blood vessels, so that the overall model can more accurately achieve the simultaneous segmentation of multiple DR lesions. At the same time, the use of a weighted cross entropy loss function overcomes the problem of imbalance between foreground and background pixels.

[0044] The specific implementation includes the following steps:

[0045] Step A: Filter the dataset. According to the data features such as lesion segmentation labels and image resolution of the public datasets IDRiD and DDR, write the data interface required by the convolutional neural network. The first step is to filter the dataset. Among them, the IDRiD (Indian Diabetic Retinal Lesion Image Dataset) dataset is part of the "Diabetic Retinal Lesion: Segmentation and Grading Challenge" competition jointly organized by the 2018 IEEE International Symposium on Biomedical Imaging. It has 81 4288×2848 color fundus images and their corresponding four types of lesion segmentation pixel-level: microaneurysm, hemorrhage, soft exudate, and hard exudate. The DDR (Diabetic Retinal Lesion Image Dataset) dataset is one of the public datasets of the 2019 Eye Disease Intelligent Recognition Competition (ODIR-2019). It contains 13,673 fundus images from 147 hospitals in 23 provinces in China, of which 757 provide pixel-level label annotations for the above four types of lesions.

[0046] Step B: Create dataset labels. The specific implementation is as follows:

[0047] Construct unified labels for multi-lesion segmentation: Since different categories have different annotation labels, to achieve multi-category simultaneous segmentation, it is necessary to unify the different labels into the same label, and use 0 to 4 to represent the background and four types of lesions respectively. Make pseudo labels for blood vessels: Due to the high cost of medical image annotation, images with lesion annotations generally do not have pixel-level annotations of blood vessels at the same time. The embodiment of the present invention uses the DRIVE and STARE datasets with pixel-level annotations of blood vessels to pre-train a segmentation model, and obtains pseudo labels for blood vessels of the IDRiD and DDR datasets based on this model. Step C, construct a training set and a test set, split the dataset, and divide the dataset into ten equal parts to implement network training and network testing using the leave-one-out cross-validation method in the subsequent training process.

[0048] Step D: Convolutional neural network construction, establish a feature extraction model, input the color fundus image into the convolutional neural network, and obtain the segmentation results of diabetic retinopathy lesions and blood vessels respectively. The specific steps are as follows:

[0049] 1. Select the backbone network for feature extraction. Considering the effective retention of the underlying detail information, the present invention adopts the densenet-161 structure, and the initialization parameters of the structure are set to the final parameters that are fully trained on the ImageNet dataset in advance. It is integrated into the convolution block of the U-type network, and the U-type network is used to realize effective feature extraction of the input image.

[0050] 2. Construct a global attention module based on the transformer structure. The module consists of a transformer-like module, including three 3x3 convolutional layers, one pooling layer and an activation function layer. The three convolutional layers are used as generators to obtain the index, key value and content respectively. The index and key value are multiplied by the matrix and then passed through an activation function layer to obtain the attention distribution map. The attention distribution map acts on the content in the form of element addition. The weighted content is abstracted through a 3x3 convolutional layer and added to the original input element through a short-circuit connection. When the input and output dimensions of the short-circuit connection are inconsistent, a 1*1 convolutional layer is used to increase the dimension of the input.

[0051] 3. Construct a feature attention module based on the transformer structure. The input of the module consists of two parts: lesion features and vascular features. The lesion features are indexed through a 3x3 convolution layer and connected to the output end as a short-circuit connection. The vascular features are respectively passed through two 3x3 convolution layers to obtain the key value and content. The key value is first multiplied by the index matrix and then formed into an attention distribution map through the activation function. The attention distribution map acts on the content in the form of element-wise addition. The weighted content is abstracted through a 3x3 convolution layer and added to the original input element through a short-circuit connection. When the input and output dimensions of the short-circuit connection are inconsistent, a 1*1 convolution layer is used to increase the dimension of the input.

[0052] 4. Set the training parameters and loss function strategy. The network optimizer selects the SGD optimizer, the initial learning rate is 0.001, the cosine annealing function is used to decay the learning rate, the training period is set to 300, the batch size is 16, and the activation function is the softmax function. The loss function used for the multi-lesion segmentation and vascular segmentation results is the weighted cross entropy loss function, which are respectively , .

[0053] The total loss function expression is as follows:

[0054]

[0055] The leave-one-out cross-validation method was used for network training and network testing. The test set was used for network testing to obtain multi-lesion segmentation and vascular segmentation results.

[0056] Embodiment 1: A method for lesion segmentation, comprising the steps of:

[0057] S1, screen the data set and write the data interface required by the convolutional neural network according to the data characteristics of the data set;

[0058] S2, make dataset labels;

[0059] S3, build training set and test set;

[0060] S4, the construction of convolutional neural network, the establishment of feature extraction model, the input of image into convolutional neural network, and the segmentation results of multiple lesions were obtained respectively.

[0061] Example 2: Based on Example 1, in step S1, the data set includes an IDRiD data set and a DDR data set, and the data features include lesion segmentation labels and image resolutions of the data set IDRiD and the data set DDR.

[0062] Embodiment 3: Based on Embodiment 1, in step S2, the following sub-steps are included:

[0063] S21, construct a unified label for multi-lesion segmentation: Since different categories have different annotation labels, to achieve multi-category simultaneous segmentation, it is necessary to unify different labels into the same label, using 0 to 4 to represent the background and four types of lesions respectively;

[0064] S22, generate pseudo labels for blood vessels: Due to the high cost of medical image annotation, images with lesion annotations generally do not have pixel-level annotations for blood vessels. In this embodiment of the present invention, a segmentation model is pre-trained using the DRIVE and STARE datasets with pixel-level annotations for blood vessels, and pseudo labels for blood vessels of the IDRiD and DDR datasets are obtained based on this model.

[0065] Embodiment 4: Based on Embodiment 1, in step S3, the sub-steps are included: in the process of constructing the training set and the test set, the data set is segmented and the data set is processed into multiple equal parts. Specifically, the data set is processed into ten equal parts, and the network training and network testing are performed using the leave-one-out cross-validation method in the subsequent training process.

[0066] Example 5: On the basis of Example 1, in step S4, when the image input is a color fundus image, the segmentation results of diabetic retinopathy multiple lesions and blood vessels are obtained respectively, and sub-step S40 is included: selecting a backbone network for feature extraction, constructing a global attention module based on a transformer structure, and obtaining preliminary features of blood vessels and lesions respectively through two global attention modules; constructing a feature attention module based on a transformer structure, and the input of the module includes two parts: lesion features and blood vessel features; and obtaining the segmentation results of lesions and blood vessels through the feature attention module.

[0067] Embodiment 6: Based on Embodiment 5, in step S40, the following sub-steps are included:

[0068] S401, selecting a backbone network for feature extraction. Considering the effective retention of underlying detail information, the embodiment of the present invention adopts a densenet-161 structure, the initialization parameters of which are set to the final parameters that are fully trained on the ImageNet dataset in advance; integrating it into the convolution block of the U-type network, and using the U-type network to achieve effective feature extraction of the input image;

[0069] S402, construct a global attention module based on a transformer structure, the module is composed of a transformer-like module, including three first convolutional layers, one pooling layer and an activation function layer; the three first convolutional layers are used as generators to obtain indexes, key values ​​and content respectively, and the results of matrix multiplication of indexes and key values ​​are passed through an activation function layer to obtain an attention distribution map; the attention distribution map acts on the content in the form of element addition; the weighted content is abstracted through a first convolutional layer and added to the original input element through a short-circuit connection; when the input and output dimensions of the short-circuit connection are inconsistent, a second convolutional layer is used to increase the dimension of the input;

[0070] S403, construct a feature attention module based on the transformer structure, the input of the module includes two parts: lesion features and blood vessel features; the lesion features are indexed through a first convolution layer and connected to the output end as a short-circuit connection; the blood vessel features are respectively passed through two first convolution layers to obtain key values ​​and content; the key value is first multiplied with the index matrix, and then an attention distribution map is formed through an activation function; the attention distribution map acts on the content in the form of element addition; the weighted content is abstracted through a first convolution layer and added to the original input element through a short-circuit connection; when the input and output dimensions of the short-circuit connection are inconsistent, a second convolution layer is used to increase the dimension of the input;

[0071] Embodiment 7: Based on Embodiment 6, after step S403, the following steps are included:

[0072] S404, set training parameters and loss function strategy, select network optimizer, set initial learning rate, use cosine annealing function to decay learning rate, set training period and batch size, select activation function; the loss function used for multi-lesion segmentation and vascular segmentation results is weighted cross entropy loss function, which are respectively , ;

[0073] The total loss function L is expressed as follows:

[0074]

[0075] is the ratio of the two loss functions for network training and network testing; the network is tested using the test set to obtain multi-lesion segmentation and vascular segmentation results.

[0076] Embodiment 8: Based on Embodiment 7, the first convolution layer is a 3x3 convolution layer, and the second convolution layer is a 1*1 convolution layer. The network optimizer is an SGD optimizer, the initial learning rate is set to 0.001, the training period is set to 300, the batch size is 16, and the activation function is a softmax function. The network training and network testing are specifically performed using a leave-one-out cross-validation method.

[0077] Embodiment 9: A device for lesion segmentation includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is loaded by the processor, the method described in any one of Embodiments 1 to 8 is executed. For example, in a specific application, the following functional modules are provided:

[0078] The data interface module is used to write the data interface required by the convolutional neural network according to the data characteristics of the filtered data set;

[0079] The label making module is used to construct unified labels for multi-lesion segmentation and to make pseudo labels for blood vessels;

[0080] Training set and test set construction modules for network training and network testing;

[0081] The convolutional neural network building module is used to build the convolutional neural network, establish a feature extraction model, input the color fundus image into the convolutional neural network, and obtain the segmentation results of diabetic retinopathy multiple lesions and blood vessels respectively; among them, the backbone network for feature extraction is selected as a U-shaped network with a densenet-161 structure, and a global attention module based on the transformer structure is constructed. The preliminary features of blood vessels and lesions are obtained respectively through two global attention modules; a feature attention module based on the transformer structure is constructed, and the input of the module includes two parts: lesion features and blood vessel features; the segmentation results of lesions and blood vessels are obtained through the feature attention module.

[0082] Embodiment 10: A readable storage medium stores a computer program, wherein the computer program is loaded by a processor and executes the method described in any one of Embodiments 1 to 8.

[0083] The parts not involved in the present invention are the same as the prior art or can be implemented by using the prior art.

[0084] The above technical solution is only one implementation mode of the present invention. For those skilled in the art, it is easy to make various types of improvements or modifications based on the application methods and principles disclosed in the present invention, and it is not limited to the method described in the above specific implementation mode of the present invention. Therefore, the method described above is only preferred and does not have a restrictive meaning.

[0085] In addition to the above examples, those skilled in the art may obtain other embodiments based on the above disclosure or by using the knowledge or technology in the relevant field to make changes. The features of each embodiment may be interchangeable or replaced. The changes and modifications made by those skilled in the art do not depart from the spirit and scope of the present invention and should be within the scope of protection of the claims attached to the present invention.

Claims

1. A method for lesion segmentation, characterized in that: Includes steps: S1, screen the data set and write the data interface required by the convolutional neural network according to the data characteristics of the data set; S2, make dataset labels; S3, build training set and test set; S4, the construction of convolutional neural network, the establishment of feature extraction model, the input of images into the convolutional neural network, and the segmentation results of multiple lesions were obtained respectively; In step S4, when the image input is a color fundus image, segmentation results of diabetic retinopathy multiple lesions and blood vessels are obtained respectively, and sub-step S40 is included: selecting a backbone network for feature extraction, constructing a global attention module based on a transformer structure, and obtaining preliminary features of blood vessels and lesions respectively through two global attention modules; constructing a feature attention module based on a transformer structure, and the input of the feature attention module based on the transformer structure includes two parts: lesion features and blood vessel features; obtaining the segmentation results of the lesions through the feature attention module; step S40 includes sub-steps: S401, selecting a backbone network for feature extraction, using a densenet-161 structure, and setting initialization parameters of the densenet-161 structure to final parameters fully trained on the ImageNet dataset in advance; Integrate it into the convolution block of the U-type network and use the U-type network to achieve effective feature extraction of the input image; S402, construct a global attention module based on the transformer structure, including 3 first convolutional layers, 1 pooling layer and an activation function layer; the 3 first convolutional layers are used as generators to obtain indexes, key values ​​and content respectively, and the results of matrix multiplication of indexes and key values ​​are passed through an activation function layer to obtain an attention distribution map; the attention distribution map acts on the content in the form of element addition; the weighted content is abstracted through a first convolutional layer and added to the original input element through a short-circuit connection; when the input and output dimensions of the short-circuit connection are inconsistent, a second convolutional layer is used to increase the dimension of the input; S403, construct a feature attention module based on a transformer structure, the input of the feature attention module based on the transformer structure includes two parts: lesion features and blood vessel features; the lesion features are indexed through a first convolution layer and connected to the output end as a short-circuit connection; the blood vessel features are respectively passed through two first convolution layers to obtain key values ​​and content; the key value is first multiplied with the index matrix, and then an attention distribution map is formed through an activation function; the attention distribution map acts on the content in the form of element addition; the weighted content is abstracted through a first convolution layer and added to the original input element through a short-circuit connection; when the input and output dimensions of the short-circuit connection are inconsistent, a second convolution layer is used to increase the dimension of the input.

2. The method for lesion segmentation according to claim 1, characterized in that: In step S1, the data set includes an IDRiD data set and a DDR data set, and the data features include lesion segmentation labels and image resolutions of the data set IDRiD and the data set DDR.

3. The method for lesion segmentation according to claim 1, characterized in that: In step S2, the sub-steps are included: S21, construct unified labels for multi-lesion segmentation; S22, create pseudo labels for blood vessels: use the DRIVE and STARE datasets with pixel-level annotations for blood vessels to pre-train a segmentation model, and obtain pseudo labels for blood vessels in the IDRiD and DDR datasets based on this model.

4. The method for lesion segmentation according to claim 1, characterized in that: In step S3, the sub-steps are included: in the process of constructing the training set and the test set, the sub-steps are included: dividing the data set, and processing the data set into multiple equal parts.

5. The method for lesion segmentation according to claim 1, characterized in that: After step S403, the following steps are included: S404, set training parameters and loss function strategy, select network optimizer, set initial learning rate, use cosine annealing function to decay learning rate, set training period and batch size, select activation function; the loss function used for multi-lesion segmentation and vascular segmentation results is weighted cross entropy loss function, which are respectively , ; The total loss function L is expressed as follows: is the ratio of the two loss functions for network training and network testing; the network is tested using the test set to obtain multi-lesion segmentation and vascular segmentation results.

6. The method for lesion segmentation according to claim 5, characterized in that: The first convolution layer is a 3x3 convolution layer, the second convolution layer is a 1*1 convolution layer, the network optimizer is an SGD optimizer, the initial learning rate is set to 0.001, the training period is set to 300, the batch size is 16, the activation function is a softmax function, and the network training and network testing are specifically performed using a leave-one-out cross-validation method.

7. A device for lesion segmentation, characterized in that: The method comprises a processor and a memory, wherein a computer program is stored in the memory, and when the computer program is loaded by the processor, the method for lesion segmentation according to any one of claims 1 to 6 is executed.

8. A readable storage medium, characterized in that: A computer program is stored in a readable storage medium, and the computer program is loaded by a processor to execute the method for lesion segmentation according to any one of claims 1 to 6.