Training optimization method and device for segmenting all models and computer readable storage medium
By generating synthetic images and using low-rank decomposition technology, we solve the problem of difficulty in obtaining annotation data in medical images, realize the method of using a small amount of data to train and segment all models, and improve the training efficiency of the model and the segmentation accuracy of small tissues.
Patent Information
- Application Number
- CN202410818277.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2024-10-29
AI Technical Summary
In medical image analysis, obtaining large amounts of annotated image data to train segmentation everything models (SAMs) is difficult, especially in the medical field due to the need for expertise and legal restrictions on patient privacy protection.
By obtaining example images and background images, synthetic images are generated and input into the segmentation model. Image transformation and low-rank decomposition technology are used to reduce trainable parameters and improve the training efficiency and accuracy of the model.
It can use a small amount of labeled image data to train and segment all models, reduce resource consumption, and improve the segmentation accuracy of small tissues such as blood vessels.
Smart Images

Figure CN118864518A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of medical image processing, and in particular to a training optimization method, device and computer-readable storage medium for segmenting all models. Background Art
[0002] In the field of medical image analysis, image segmentation technology is a basic and critical part, which involves segmenting the pixels in digital images into multiple parts or regions representing different tissue structures. This technology is extremely important for the diagnosis, treatment and medical research of diseases. With accurate vascular image segmentation, doctors can better plan surgery or interventional treatments, such as coronary artery bypass surgery or intravascular stent placement. In addition, vascular segmentation can also be used to evaluate the effects of treatment, such as blood flow recovery and changes in vascular lesions.
[0003] Traditional image segmentation methods include thresholding, region growing, and edge detection, but these methods often rely on clear boundaries and high contrast. In practical applications, medical images are often difficult to process due to noise, blur, and low contrast between tissues. With the development of technology, machine learning-based methods, especially deep learning technology, have become a research hotspot for medical image segmentation.
[0004] The Segment Anything Model (SAM) is an advanced image segmentation model that can generate high-quality object masks based on input prompts and can be used to generate masks for all objects in an image. In the training of the Segment Anything Model, a large amount of annotated image data is required to ensure that the model learns enough features and achieves generalization capabilities. However, in the medical field, it is extremely challenging to obtain such image data because the annotation of medical images not only requires a high degree of expertise and a lot of manpower, but also must consider the legal protection of patient privacy. Summary of the invention
[0005] In order to overcome the above-mentioned technical defects, the purpose of the present invention is to provide a training optimization method, device and computer-readable storage medium for a segmentation model, which can use a small amount of labeled image data to train the segmentation model and significantly improve the training effect.
[0006] The present invention discloses a training optimization method for segmenting all models, comprising the following steps:
[0007] Acquire a sample image and a background image, wherein the sample image includes a plurality of organs, the background image does not include an organ, and the size of the sample image is equal to the size of the background image;
[0008] Acquire multiple local images based on multiple organs in the example image, wherein any of the local images contains an organ located in the example image, and a size of any of the local images is equal to a size of the example image;
[0009] Performing image transformation processing on the plurality of partial images respectively, and collage them into the background image to obtain a composite image;
[0010] The example image and the synthesized image are input into the image encoder module in the segmentation model.
[0011] Preferably, the step of acquiring local images based on the multiple organs in the example image comprises:
[0012] An organ mask of any organ in the example image is obtained, and the organ mask of the organ is multiplied pixel by pixel with the example image to obtain a local image containing the organ.
[0013] Preferably, the step of performing image transformation processing on the plurality of partial images respectively comprises:
[0014] Randomly perform one or more operations of blurring, brightness adjustment, scaling, flipping and rotating on any of the partial images.
[0015] Preferably, the method further comprises the following steps:
[0016] randomly selecting a foreground class in the synthetic image, and determining whether the foreground class exists in the synthetic image;
[0017] When the foreground class exists in the synthetic image, a pixel point is randomly selected in the image region containing the foreground class in the synthetic image as a positive prompt point; when the foreground class does not exist in the synthetic image, a pixel point is randomly selected in the synthetic image as a negative prompt point;
[0018] The positive cue point or the negative cue point is input into a cue encoder module in the segmentation model, so that the cue encoder module obtains the cue embedding of the positive cue point or the negative cue point.
[0019] Preferably, the cue embedding of the positive cue point or the negative cue point is expressed as the sum of the learnable vector of the positive cue point or the negative cue point and the position embedding of the positive cue point or the negative cue point.
[0020] Preferably, the method further comprises the following steps:
[0021] A query weight matrix and a value weight matrix of the image encoder module are low-rank decomposed.
[0022] Preferably, the method further comprises the following steps:
[0023] The query weight matrix and the value weight matrix of the mask decoder module in the split-everything model are low-rank decomposed.
[0024] Preferably, the method further comprises the following steps:
[0025] Converting the low-resolution prediction mask output by the mask decoder into an intermediate-size prediction mask by an interpolation method, and inputting the intermediate-size prediction mask into the optimized decoder in the segmentation model;
[0026] The optimized decoder performs a cross-attention operation on the intermediate size prediction mask and the feature map of the synthesized image, and outputs an original size prediction mask, where the size of the original size prediction mask is equal to the size of the synthesized image.
[0027] The present invention also discloses an electronic device, which includes a memory storing computer executable instructions and a processor. When the instructions are executed by the processor, the electronic device implements the training optimization method as described above.
[0028] The present invention also discloses a computer-readable storage medium on which a computer program is stored. When the computer program is run on a computer, the computer executes the training optimization method as described above.
[0029] Compared with the existing technology, the above technical solution has the following beneficial effects: it can use a small amount of labeled image data to train all segmentation models, reducing the pressure of obtaining training data; introduce low-rank fine-tuning methods to reduce trainable parameters and reduce resource consumption; additional encoding of the output mask to enhance details helps to improve the segmentation accuracy of small tissues such as blood vessels. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 This is a schematic diagram of the split everything model described in the present invention;
[0031] Figure 2 is a schematic diagram of a composite image according to the present invention;
[0032] Figure 3 The schematic diagram of the optimized decoder of the present invention is shown in FIG. DETAILED DESCRIPTION
[0033] The advantages of the present invention are further described below in conjunction with the accompanying drawings and specific embodiments.
[0034] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0035] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0036] It should be understood that although the terms first, second, third, etc. may be used in the present disclosure to describe various information, such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present disclosure, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".
[0037] In the description of the present invention, it is necessary to understand that the terms "longitudinal", "lateral", "up", "down", "front", "back", "left", "right", "vertical", "horizontal", "top", "bottom", "inside", "outside", etc., indicating the orientation or position relationship, are based on the orientation or position relationship shown in the accompanying drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0038] In the description of the present invention, unless otherwise specified and limited, it should be noted that the terms "installed", "connected" and "connected" should be understood in a broad sense. For example, it can be a mechanical connection or an electrical connection, or it can be the internal connection between two components. It can be a direct connection or an indirect connection through an intermediate medium. For ordinary technicians in this field, the specific meanings of the above terms can be understood according to the specific circumstances.
[0039] In the following description, the suffixes such as "module", "component" or "unit" used to represent elements are only used to facilitate the description of the present invention, and have no specific meanings. Therefore, "module" and "component" can be used interchangeably.
[0040] The present invention discloses a training optimization method for segmenting all models, comprising the following steps:
[0041] S100, obtaining a sample image and a background image, wherein the sample image includes a plurality of organs, the background image does not include an organ, and the size of the sample image is equal to that of the background image.
[0042] Specifically, the example image represents a medical image containing multiple organs, such as an image slice showing multiple organs obtained by CT scanning or PET scanning. It is understandable that the organs described in the present invention can be the original tissue structure units in the human body (such as the heart, blood vessels), or additionally grown diseased tissues (such as tumors). In addition, for the example image, the position and shape of each organ in the example image are respectively marked in the form of an organ mask, and each organ corresponds to an organ mask. The organ mask is also in the form of an image, and its size is the same as the size of the example image. The pixel value of the image area corresponding to the organ in the organ mask is set to 1, and the pixel value of other image areas is set to 0. The organ mask is also called the real mask in the subsequent training step, which is used to compare with the prediction model output by the segmentation model and calculate the error. The background image represents a medical image that does not contain any organ, such as an image slice that does not show any organ obtained by CT scanning or PET scanning. The size of the example image is equal to that of the background image.
[0043] S200, acquiring a plurality of partial images based on a plurality of organs in the example image, wherein any of the partial images includes an organ located in the example image, and a size of any of the partial images is equal to a size of the example image.
[0044] Specifically, multiple local images can be acquired based on a sample image, any local image displays an organ in the sample image, the size of the local image is equal to the size of the sample image, and the relative position of the organ displayed in the local image is the same as the relative position of the organ displayed in the sample image.
[0045] Further, step S200 includes:
[0046] An organ mask of any organ in the example image is obtained, and the organ mask of the organ is multiplied pixel by pixel with the example image to obtain a local image containing the organ.
[0047] It can be understood that the positions and shapes of various organs in the example images have been marked in the form of organ masks, and each organ corresponds to an organ mask. Therefore, after the organ mask of any organ is multiplied pixel by pixel with the example image, the pixel value of the image area that does not contain the organ will become 0, and a local image containing the organ will be obtained, and the relative position of the organ displayed in the local image is the same as the relative position of the organ displayed in the example image.
[0048] S300, performing image transformation processing on the plurality of partial images respectively, and collage them into the background image to obtain a composite image.
[0049] Specifically, multiple local images obtained based on a sample image are transformed separately and then pasted one by one into the same background image to obtain a composite image, so that the composite image and the sample image contain the same organs, but each organ has undergone image transformation processing, and the display effect (such as shape, brightness) will be different.
[0050] Further, step S300 includes:
[0051] Randomly perform one or more operations of blurring, brightness adjustment, scaling, flipping and rotating on any of the partial images.
[0052] Furthermore, multiple local images can be subjected to multiple different image transformation processes and collages, so that multiple composite images can be obtained based on one example image. Figure 2 As shown, Figure 2 The leftmost column in the figure is a plurality of example images, and other images located in the same row as any example image are composite images obtained based on the example image.
[0053] S400, inputting the example image and the synthesized image into the image encoder module in the segmentation model.
[0054] The structure of the split everything model described in the present invention is as follows Figure 1As shown, it includes an image encoder module, a hint encoder module and a mask decoder module. The image encoder module usually uses a mask autoencoder (MAE) or a pre-trained visual transformer (ViT) to generate a one-time image embedding. This component is responsible for converting the input image into an image embedding vector of a fixed size. The hint encoder module encodes hints (such as points) indicating the segmented object (i.e., a certain organ) into hint embedding vectors. The mask decoder module maps the image embedding, hint embedding, and output token to the predicted mask, using immediate self-attention and cross-attention mechanisms in two directions: from the hint embedding vector to the image embedding vector, and then from the image embedding vector back to the hint embedding vector. When training the segmentation model, the predicted mask output for any segmented object in the training image and the true mask of the segmented object are passed into the loss function to calculate the loss and update the parameters through the optimizer.
[0055] This method can generate a large number of synthetic images based on a small number of example images to train all segmentation models, solving the problem of difficulty in obtaining a large amount of medical imaging data.
[0056] Preferably, the method further comprises the following steps:
[0057] S500: randomly select a foreground class in the synthetic image, and determine whether the foreground class exists in the synthetic image.
[0058] Specifically, the foreground class refers to any organ.
[0059] S600. When the foreground class exists in the composite image, randomly select a pixel point in the image area containing the foreground class in the composite image as a positive prompt point; when the foreground class does not exist in the composite image, randomly select a pixel point in the composite image as a negative prompt point.
[0060] S700, inputting the positive cue point or the negative cue point into a cue encoder module in the segmentation model, so that the cue encoder module obtains a cue embedding of the positive cue point or the negative cue point.
[0061] Furthermore, the cue embedding of the positive cue point or the negative cue point is expressed as the sum of the learnable vector of the positive cue point or the negative cue point and the position embedding of the positive cue point or the negative cue point.
[0062] Specifically, firstly, the normalized coordinates of the positive or negative prompt point [x t ,y t] is multiplied by a random matrix G consisting of elements from a standard normal distribution, expanding the dimension from 2 to half the prompt embedding dimension (n), and then applying sine and cosine functions. The random matrix G can be expressed in the form:
[0063]
[0064] where g i,j ~N(0,1).
[0065] The position embedding of the t-th point can be expressed as follows:
[0066] [sin([x t ,y t ]×G),cos([x t ,y t ]×G)].
[0067] Preferably, the method further comprises the following steps:
[0068] S810: Perform low-rank decomposition on the query weight matrix and the value weight matrix of the image encoder module.
[0069] Preferably, the method further comprises the following steps:
[0070] S820. Perform low-rank decomposition on the query weight matrix and the value weight matrix of the mask decoder module in the segmentation model.
[0071] Specifically, in the image encoder module and the mask decoder module, the query weight matrix Wq and the value weight matrix Wv are both added with LoRA (Low-Rank Adaptation, low-rank decomposition) structures, and the query weight matrix Wq and the value weight matrix Wv are respectively decomposed into the product form of low-rank matrices. When training the segmentation model of the present invention, only the parameters of the low-rank matrix are updated, which can save computing resources and memory.
[0072] Preferably, the method further comprises the following steps:
[0073] S900: Convert the low-resolution prediction mask output by the mask decoder into an intermediate-size prediction mask by an interpolation method, and input the intermediate-size prediction mask into the optimized decoder in the segmentation model.
[0074] S1000. The optimized decoder performs a cross-attention operation on the intermediate size prediction mask and the feature map of the synthesized image, and outputs an original size prediction mask, where the size of the original size prediction mask is equal to the size of the synthesized image.
[0075] Specifically, in the existing segmentation models, the predicted mask directly output by the mask decoder has a low resolution and is usually converted into a predicted mask of the original size through bilinear interpolation. However, this method may not be able to accurately capture the details, and subtle vascular structures are difficult to restore even after interpolation. Figure 3 As shown, the present invention adds an additional optimization decoder on the basis of the original mask decoder, and improves the segmentation accuracy of small blood vessels by iteratively improving the resolution and details of the mask. The method first deforms the low-resolution prediction mask into an intermediate-size (e.g., 4096×256) prediction mask, and then the optimization decoder performs a deeper cross-attention operation on the intermediate-size prediction mask and the image feature map that has been processed by the cue point cross-attention. Through this cross-attention mechanism, the optimization decoder can focus more carefully on specific areas of the image, especially those small and complex vascular structures, thereby improving the accuracy of segmentation. Subsequently, the mask will be deformed back to its original size (e.g., 1024×1024). In this process, the model uses the information of all previous steps to restore the details of small blood vessels. Finally, the output is adjusted and optimized through a convolutional layer to make the output more accurate and smooth. The optimization decoder simultaneously uses the low-resolution prediction mask M output by the mask decoder and the original size mask FM output by the optimization decoder as optimization targets, and the loss function is:
[0076]
[0077] Among them, GT represents the true mask for the same segmented object, CE represents the cross-entropy loss (Cross-Entropy Loss), and D ice represents the D ice loss function (D ice Loss).
[0078] The present invention also discloses an electronic device, which includes a memory storing computer executable instructions and a processor. When the instructions are executed by the processor, the electronic device implements the training optimization method as described above.
[0079] The present invention also discloses a computer-readable storage medium on which a computer program is stored. When the computer program is run on a computer, the computer executes the training optimization method as described above.
[0080] Compared with the existing technology, the above technical solution has the following beneficial effects: it can use a small amount of labeled image data to train all segmentation models, reducing the pressure of obtaining training data; introduce low-rank fine-tuning methods to reduce trainable parameters and reduce resource consumption; additional encoding of the output mask to enhance details helps to improve the segmentation accuracy of small tissues such as blood vessels.
[0081] It should be noted that the embodiments of the present invention have better practicability and do not impose any form of limitation on the present invention. Any technician familiar with the field may use the technical content disclosed above to change or modify it into an equivalent effective embodiment. However, any modification or equivalent changes and modifications made to the above embodiments based on the technical essence of the present invention without departing from the content of the technical solution of the present invention are still within the scope of the technical solution of the present invention.
Claims
1. A training optimization method for segmenting all models, characterized in that: The following steps are included: Acquire a sample image and a background image, wherein the sample image includes a plurality of organs, the background image does not include an organ, and the size of the sample image is equal to the size of the background image; Acquire multiple local images based on multiple organs in the example image, wherein any of the local images contains an organ located in the example image, and the size of any of the local images is equal to the size of the example image; perform image transformation processing on the multiple local images respectively, and collage them into the background image to obtain a composite image; The example image and the synthesized image are input into the image encoder module in the segmentation model.
2. The training optimization method according to claim 1, characterized in that: The step of acquiring local images based on the multiple organs in the example image, include, An organ mask of any organ in the example image is obtained, and the organ mask of the organ is multiplied pixel by pixel with the example image to obtain a local image containing the organ.
3. The training optimization method according to claim 1, characterized in that: The step of performing image transformation processing on the plurality of partial images respectively comprises: Randomly perform one or more operations of blurring, brightness adjustment, scaling, flipping and rotating on any of the partial images.
4. The training optimization method according to claim 1, characterized in that: The following steps are also included: A foreground class is randomly selected in the synthetic image, and it is determined whether the foreground class exists in the synthetic image; when the foreground class exists in the synthetic image, a pixel point is randomly selected in the image region containing the foreground class in the synthetic image as a positive prompt point, and when the foreground class does not exist in the synthetic image, a pixel point is randomly selected in the synthetic image as a negative prompt point; The positive cue point or the negative cue point is input into a cue encoder module in the segmentation model, so that the cue encoder module obtains the cue embedding of the positive cue point or the negative cue point.
5. The training optimization method according to claim 4, characterized in that: The cue embedding of the positive cue point or the negative cue point is expressed as the sum of the learnable vector of the positive cue point or the negative cue point and the position embedding of the positive cue point or the negative cue point.
6. The training optimization method according to claim 1, characterized in that: The following steps are also included: A query weight matrix and a value weight matrix of the image encoder module are low-rank decomposed.
7. The training optimization method according to claim 1, characterized in that: The following steps are also included: The query weight matrix and the value weight matrix of the mask decoder module in the split-everything model are low-rank decomposed.
8. The training optimization method according to claim 1, characterized in that: The following steps are also included: Converting the low-resolution prediction mask output by the mask decoder into an intermediate-size prediction mask by an interpolation method, and inputting the intermediate-size prediction mask into the optimized decoder in the segmentation model; The optimized decoder performs a cross-attention operation on the intermediate size prediction mask and the feature map of the synthesized image, and outputs an original size prediction mask, where the size of the original size prediction mask is equal to the size of the synthesized image.
9. An electronic device, characterized in that: The electronic device comprises a memory storing computer executable instructions and a processor. When the instructions are executed by the processor, the electronic device implements the training optimization method according to any one of claims 1 to 8.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed on a computer, the computer is enabled to perform the training optimization method according to any one of claims 1 to 8.
