Lightweight medical image segmentation method, electronic equipment and storage medium

By preprocessing medical images and improving U-Net network, introducing self-attention mechanisms and conditional random fields, the problems of noise interference and category imbalance are solved, and efficient and accurate segmentation of medical images is achieved, suitable for real-time clinical diagnosis.

CN120451546APending Publication Date: 2025-08-08ANHUI UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510538882.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-27
Publication Date
2025-08-08

AI Technical Summary

Technical Problem

Existing U-Net networks are affected by noise interference and category imbalance problems in medical image segmentation, resulting in low segmentation accuracy and poor performance.

Method used

By preprocessing medical images, the U-Net network is improved to introduce self-attention mechanisms and conditional random fields, combining multi-stage data augmentation and feature optimization, optimize model structure and balance category proportions.

Benefits of technology

It improves the accuracy and stability of medical image segmentation, reduces computing resource consumption, and meets the needs of clinical real-time diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120451546A_ABST
    Figure CN120451546A_ABST
Patent Text Reader

Abstract

The invention provides a lightweight medical image segmentation method, electronic equipment and a storage medium. The method comprises the following steps: acquiring a to-be-processed medical image; preprocessing the medical image to obtain a first image suitable for network input; processing the first image by using a trained improved U-Net network to obtain a segmented second image to distinguish a lesion area from a non-lesion area, the improved U-Net network being a U-Net network based on a self-attention mechanism; and post-processing the second image by using a conditional random field so as to optimize the segmentation boundary and obtain a final segmentation result. The medical image is preprocessed to weaken the influence of noise, the U-Net network is improved based on the self-attention mechanism to obtain the improved U-Net network, and accurate segmentation of the medical image can be realized by training the network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a lightweight medical image segmentation method, electronic equipment, and storage medium. Background Art

[0002] Medical image segmentation technology is an important research area in medical image processing and computer vision, widely used in tasks such as tumor detection, organ segmentation, and lesion region annotation. Early medical image segmentation methods mainly included threshold-based methods, region growing, edge detection, and active contour models. These traditional methods are effective for simple images but exhibit significant shortcomings when dealing with complex medical images, especially when dealing with noise and complex backgrounds.

[0003] With the development of deep learning, convolutional neural networks (CNNs) have been introduced to the field of medical image segmentation. As a classic deep learning model, the U-Net network, with its encoder-decoder structure and skip connection mechanism, is able to capture global features while preserving local details. It has achieved remarkable results in medical image segmentation tasks and has become one of the current mainstream methods.

[0004] Although the U-Net network has made significant progress in medical image segmentation, there are still some shortcomings and challenges. First, there is the problem of noise interference: medical images are often accompanied by noise, which may come from the limitations of the imaging equipment, the movement of the patient, or other external interference. When faced with these noises, the segmentation accuracy of the existing U-Net network will be significantly affected, resulting in a decrease in the ability to identify the lesion area; second, there is the problem of class imbalance: in medical images, the lesion area usually occupies a small part of the image, while the normal tissue area occupies the majority; this class imbalance problem makes the model more biased towards the normal tissue area during training, resulting in poor segmentation performance of the lesion area. Summary of the Invention

[0005] In view of the above-mentioned deficiencies in the prior art, the present invention provides a lightweight medical image segmentation method, electronic device, and storage medium to solve the technical problems of low accuracy and poor segmentation performance in the prior art of medical image segmentation.

[0006] To achieve the above-mentioned objectives and other related objectives, the present invention provides a lightweight medical image segmentation method, comprising: obtaining a medical image to be processed; preprocessing the medical image to obtain a first image suitable for network input; processing the first image using a trained improved U-Net network to obtain a segmented second image to distinguish between lesion areas and non-lesion areas, wherein the improved U-Net network is a U-Net network based on a self-attention mechanism; and post-processing the second image using a conditional random field to optimize the segmentation boundary to obtain a final segmentation result.

[0007] In one embodiment of the present invention, the medical image is preprocessed to obtain a first image suitable for network input, including: resizing the medical image to adjust the size of the medical image; normalizing the resized image to map pixel values to the interval [0, 1]; and using an adaptive median filter to remove noise in the normalized image to obtain the first image.

[0008] In one embodiment of the present invention, the improved U-Net network is based on the U-Net network, and the jump connection is modified as follows: the features of the encoder layer i output are weighted optimized by the following formula: S′ skip =σ(W skip *S skip )+α*S skip , where S skip is the feature output by the encoder layer i, S′ skip is the weighted optimized feature, σ is the Sigmoid function, W skip is a learnable weight matrix, α is a learnable parameter; the features output by the decoder i-1 layer are self-attention weighted by the following formula: F attention =Attention(F input , F input ) where F input is the feature output by the decoder layer i-1, Attention is the attention operation, F attention is the feature after self-attention weighting; the weighted optimized feature and the self-attention weighted feature are concatenated and input into the i-th layer decoder.

[0009] In one embodiment of the present invention, the improved U-Net network is trained according to the following steps: obtaining medical images containing multiple lesion types and their annotated images; preprocessing the medical images containing multiple lesion types and their annotated images to obtain a first data set suitable for network input; performing data enhancement processing on the first data set to obtain a second data set; constructing an improved U-Net network; using the second data set to train the improved U-Net network to obtain a preliminary training model; and optimizing the preliminary training model to obtain the trained improved U-Net network.

[0010] In one embodiment of the present invention, data enhancement processing is performed on the first data set to obtain a second data set, including: rotating, flipping, and scaling the first data set to obtain a first enhanced data set; adding Gaussian noise to the first data set to obtain a second enhanced data set; using a generative adversarial network to process the first enhanced data set and the second enhanced data set to obtain a third enhanced data set; the first data set, the first enhanced data set, the second enhanced data set, and the third enhanced data set constitute the second data set.

[0011] In one embodiment of the present invention, the improved U-Net network is trained using the second data set to obtain a preliminary training model, including: using the second data set and the first loss function to perform self-supervised pre-training on the improved U-Net network; using the second data set and the second loss function to perform end-to-end training on the pre-trained improved U-Net network to obtain the preliminary training model.

[0012] In one embodiment of the present invention, the first loss function is contrastive learning loss, and the second loss function is obtained by weighting Dice coefficient loss, cross entropy loss, and contrastive learning loss.

[0013] In one embodiment of the present invention, the preliminary training model is optimized to obtain the trained improved U-Net network, including: using model pruning technology to remove redundant network connections in the preliminary training model to obtain a first optimization model; using quantization technology to convert the floating-point weights in the first optimization model into a low-precision representation to obtain a second optimization model; and performing model adaptation and optimization on the second optimization model according to the parameters of the hardware platform to obtain the trained improved U-Net network.

[0014] To achieve the above-mentioned purpose and other related purposes, the present invention also provides an electronic device, including a processor, a memory and a communication bus; the communication bus is used to connect the processor and the memory; the processor is used to execute the computer program stored in the memory to implement the method provided in any one of the above embodiments.

[0015] To achieve the above-mentioned object and other related objects, the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is used to enable a computer to execute the method provided in any one of the above-mentioned embodiments.

[0016] Beneficial effects of the present invention: The present invention proposes a lightweight medical image segmentation method, electronic device, and storage medium. The method preprocesses medical images to weaken the influence of noise, and improves the U-Net network based on the self-attention mechanism to obtain an improved U-Net network. By training the network, accurate segmentation of medical images can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. 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 any creative work.

[0018] Figure 1 A flowchart of a medical image segmentation method provided by one embodiment of the present invention;

[0019] Figure 2 A flowchart of medical image preprocessing provided by one embodiment of the present invention;

[0020] Figure 3 A flowchart of the U-Net network improvement provided by one embodiment of the present invention;

[0021] Figure 4 An improved U-Net network structure diagram provided by one embodiment of the present invention;

[0022] Figure 5 An improved U-Net network training flow chart provided by one embodiment of the present invention;

[0023] Figure 6 A flowchart of data enhancement provided by an embodiment of the present invention;

[0024] Figure 7 A detailed flowchart of step S350 provided in one embodiment of the present invention;

[0025] Figure 8 A detailed flowchart of step S360 provided in one embodiment of the present invention;

[0026] Figure 9 A schematic structural diagram of an electronic device provided by an embodiment of the present invention.

[0027] Description of the accompanying drawings: 101, processor; 102, memory. DETAILED DESCRIPTION

[0028] The following describes the embodiments of the present invention through specific embodiments. Those skilled in the art can easily understand other advantages and effects of the present invention from the contents disclosed in this specification. It should be noted that the following embodiments and the features in the embodiments can be combined with each other unless they conflict. In addition to the specific methods, equipment, and materials used in the embodiments, based on the understanding of the prior art by those skilled in the art and the description of the present invention, any methods, equipment, and materials of the prior art that are similar or equivalent to the methods, equipment, and materials in the embodiments of the present invention can also be used to implement the present invention.

[0029] It should be understood that the terms used in the examples of the present invention are for describing specific embodiments rather than for limiting the scope of protection of the present invention. Unless otherwise defined, all technical and scientific terms used in the present invention have the same meaning as those generally understood by those skilled in the art.

[0030] In the following description, numerous details are discussed to provide a more thorough explanation of the embodiments of the present invention. However, it is obvious to those skilled in the art that the embodiments of the present invention can be implemented without these specific details. In some of the embodiments, well-known structures and devices are shown in block diagram form rather than in detail to avoid obscuring the embodiments of the present invention.

[0031] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functions and operations that may be implemented by the methods and computer program products of various embodiments disclosed in the present invention. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in an order different from that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.

[0032] See Figure 1 , Figure 1 A lightweight medical image segmentation method provided by an embodiment of the present invention includes steps S100 to S400.

[0033] Step S100: Obtain a medical image to be processed. Medical images refer to visual data of the human body's internal structure, function, or metabolism, obtained through non-invasive or minimally invasive physical or chemical means. These images are used for disease diagnosis, treatment planning, surgical navigation, and efficacy evaluation, and are one of the core tools of modern medicine. Medical images can be obtained, for example, through computed tomography (CT), magnetic resonance imaging (MRI), X-ray imaging, and the like.

[0034] Step S200: Preprocess the medical image to obtain a first image suitable for network input. Medical images are acquired using different technologies, equipment, or methods, and therefore may be non-uniform in size, format, and other aspects, or contain noise. Therefore, preprocessing is necessary to improve the uniformity of data input, the stability of training, and ensure the quality of input data.

[0035] See Figure 2 In a specific embodiment of the present invention, step S200 includes: S201, resizing the medical image to adjust the size of the medical image, for example, the size of the medical image can be adjusted to 256*256 pixels; S202, normalizing the resized image to map pixel values to the [0,1] interval; S203, using an adaptive median filter to remove noise in the normalized image to obtain a first image.

[0036] In a specific embodiment of the present invention, in step S103, an adaptive median filter M is used to remove noise, and its expression is as follows:

[0037] M(x,y)=median{I(x',y')|(x'-x) 2 +(y′-y) 2 ≤r 2},

[0038] Where I(x',y') represents the image before denoising, M(x,y) is the output after filtering, and r is the filter window radius. Filtering removes noise from the image, preserving the effective structure in the image and ensuring the accuracy of subsequent segmentation. To quantify the filtering effect, this example calculates the peak signal-to-noise ratio (PSNR) of the image before and after filtering. The results show that the PSNR of the filtered image increases from 28.5dB to 32.1dB, indicating that the filtering operation effectively removes noise and preserves image details.

[0039] Step S300: Process the first image using a trained improved U-Net network to obtain a segmented second image, distinguishing between lesioned and non-lesioned areas. The improved U-Net network is based on a self-attention mechanism. This is the key point of the present invention. By improving and training the U-Net network, the first image can then be directly input into the model, and the model output is the segmented second image.

[0040] See Figure 3 In a specific embodiment of the present invention, the U-Net network is improved by the following steps S301 to S303 to obtain the improved U-Net network in step S300. The improved U-Net network structure is as follows: Figure 4 shown.

[0041] Step S301: Perform weighted optimization on the features output by the encoder layer i using the following formula:

[0042] S′ skip =σ(W skip *S skip )+α*S skip ,

[0043] Where S skip is the feature output by the encoder layer i, S′ skip is the weighted optimized feature, σ is the Sigmoid function, W skip is a learnable weight matrix, α is a learnable parameter whose initial value can be set to 0.5, for example, and constrained to be between 0 and 1. * denotes a convolution operation. An adaptive weighting mechanism is introduced to optimize skip connections, enabling more precise fusion of low-level and high-level features. Adaptive weighted skip connections can also be replaced with other feature fusion methods, such as gating mechanisms or dynamic convolution, as long as they ensure effective fusion of low-level and high-level features.

[0044] Step S302: The features output by the decoder layer i-1 are weighted by self-attention using the following formula:

[0045] F attention =Attention(F input , F input ),

[0046] Where, F input is the feature output by the decoder layer i-1, Attention is the attention operation, F attentionThe self-attention weighted features are weighted by the attention mechanism. In this step, the features are weighted using the attention mechanism, focusing on areas that contribute most to segmentation accuracy. The self-attention mechanism in this step can be replaced by other attention mechanisms, such as channel attention or spatial attention, as long as they can effectively weight the features in key areas.

[0047] To quantify the effectiveness of the self-attention mechanism, this example calculated the variance of the feature maps before and after attention weighting. The results showed that the variance of the weighted feature maps increased by 15%, demonstrating that the self-attention mechanism can effectively focus on key areas. To verify the effectiveness of the self-attention mechanism, this example compared the segmentation results with and without the self-attention mechanism. The results showed that the Dice coefficient increased by 3% after the self-attention mechanism was used.

[0048] Step S303: concatenate the weighted optimized features and the self-attention weighted features and input them into the i-th layer decoder.

[0049] The improved U-Net network is similar to the original U-Net network structure, including encoder and decoder, and also includes the final fully connected layer. The final feature map F obtained by the decoder final Input the fully connected layer to perform medical image segmentation prediction and obtain the segmentation result, which is expressed as follows: T pred =σ(W T *F final ), where W T is the weight matrix of the fully connected layer, and σ is the Sigmoid activation function.

[0050] See Figure 5 In a specific embodiment of the present invention, the improved U-Net network is trained according to steps S310 to S360.

[0051] Step S310, obtain medical images containing multiple lesion types and their annotated images. Collect medical image datasets containing multiple lesion types. These datasets can use public or private medical imaging datasets, such as TCIA, BraTS, etc., just ensure that the dataset contains sufficient lesion types and annotation information and meets the requirements of model training. The dataset includes annotations of lesion areas, normal tissue areas and other key anatomical structure areas to ensure data integrity and accuracy. All annotations are performed by experienced medical experts. The annotated image can be understood as a binary image of the same size as the original medical image, which includes lesion areas and non-lesion areas.

[0052] Step S320: Preprocess the medical images containing multiple lesion types and their annotated images to obtain a first data set suitable for network input. The preprocessing in this step is the same as the preprocessing process for the medical images to be processed.

[0053] Step S330: Perform data enhancement processing on the first data set to obtain a second data set. Data enhancement processing can increase the diversity of the data set and improve the generalization ability of the model.

[0054] See Figure 6 In a specific embodiment of the present invention, step S330 includes steps S331 to S334.

[0055] Step S331: Rotate, flip, and scale the first data set to obtain a first enhanced data set. The rotation angle range can be, for example, -30° to 30°. The rotation angle is randomly generated to ensure the rotation diversity of the data set, so as to enhance the adaptability of the model to images in different orientations. Each image is rotated once during the enhancement process. Each image is horizontally flipped with a probability of 50%. The flipping operation increases the diversity of the data by swapping the left and right sides of the image. The flipping process is random to ensure the unpredictability of the enhancement. For each image, a horizontal flip is performed at most once during the enhancement process. For the scaling operation, the scaling ratio is randomly selected between 0.8 and 1.2, for example. Through the scaling operation, the image will be enlarged or reduced, but its original aspect ratio remains unchanged. This operation can increase the model's ability to resolve targets of different sizes.

[0056] Step S332: Add Gaussian noise to the first data set to obtain a second enhanced data set. The noise enhancement operation is implemented by the following formula: new(x,y) =I(x,y)+N(0,σ 2 ). Among them, N(0,σ 2 ) has a mean of 0 and a variance of σ 2 Gaussian noise, I(x,y) is the image before adding noise, I new(x,y) This is the image after adding noise. When adding noise, each image is noised with a probability of 50%. Noise enhancement helps improve the robustness of the model, enabling the model to better segment in imperfect images.

[0057] Step S333: Use a generative adversarial network to process the first enhanced data set and the second enhanced data set to obtain a third enhanced data set.

[0058] Since medical image datasets are relatively small, if the dataset is still small after the aforementioned rotation, inversion, scaling, and noise addition, a generative adversarial network can be used to generate medical images to expand the training dataset. For example, a GAN network can be used for generation. The GAN network consists of a generator G and a discriminator D. The generator G generates images using random noise, and the discriminator D determines the authenticity of the image. The generator G and the discriminator D are optimized using the following loss function:

[0059] L G =-E z~pz [logD(G(z))];

[0060] L D =-E x~pdata [logD(x)]-E z~pz [log(1-D(G(z)))];

[0061] Here, G(z) is the image generated by the generator, and D(x) is the probability of the discriminator judging the real image. To quantify the quality of the generated images, this example calculates the Fréchet Inception Distance (FID) score between the generated and real images. The results show that the FID score of the generated images is 25.3, indicating high authenticity and diversity. In addition, other generative models can also be used, such as conditional generative adversarial networks or diffusion models, as long as the generated synthetic images can effectively expand the training dataset and improve the model's generalization ability.

[0062] Through these data enhancement operations, the diversity of image data has been significantly improved, and the model training process can be exposed to more diverse images, thereby improving its generalization ability and segmentation accuracy. In order to evaluate the impact of data enhancement on model performance, the present invention records the scale changes of the data set before and after enhancement. After enhancement, the training set size can be expanded from 20 images to about 1,000 images, significantly increasing the diversity of the data. In order to evaluate the effects of different data enhancement strategies, the present invention compares combinations such as rotation only, flipping only, and rotation + flipping. The results show that after combining rotation and flipping enhancement, the Dice coefficient of the model is increased from 0.86 to 0.89, indicating that multi-strategy combination enhancement has a significant improvement in model performance.

[0063] In step S334, the first dataset, the first enhanced dataset, the second enhanced dataset, and the third enhanced dataset constitute a second dataset. The datasets obtained through various enhancement methods are used as the second dataset to train the network. It is understood that the second dataset can be divided into a training set, a validation set, and a test set according to a certain ratio.

[0064] Step S340: Build an improved U-Net network. Specifically, the improved U-Net network can be built according to the method in steps S301 to S303 above.

[0065] Step S350: Use the second data set to train the improved U-Net network to obtain a preliminary training model.

[0066] See Figure 7 In a specific embodiment of the present invention, a two-step training method is adopted. Specifically, step S350 includes step S351 and step S352.

[0067] Step S351, using the second data set and the first loss function, perform self-supervised pre-training on the improved U-Net network. In this step, the self-supervised task is first used to guide the network to perform feature learning, which promotes more accurate identification of key features. When performing self-supervised pre-training, the first loss function is the contrastive learning loss. The reason for using self-supervised pre-training is that the cost of medical image annotation is high. Self-supervised pre-training only uses processed medical images and does not require annotated images. Therefore, unlabeled data can be fully utilized. Through self-supervised pre-training, common features such as edges, textures, etc. can be learned to improve the generalization of the model. This self-supervised contrastive learning can be replaced by other self-supervised learning methods, such as mask-based image modeling or cluster contrastive learning, as long as it can effectively guide the network to learn key features.

[0068] Step S352: Using the second data set and the second loss function, perform end-to-end training on the pre-trained improved U-Net network to obtain a preliminary training model. In this step, the second loss function is obtained by weighting the Dice coefficient loss, cross entropy loss, and contrastive learning loss, and its calculation formula is as follows:

[0069] L=λ1*L Dice +λ2*L CE +λ3*L contrast ;

[0070] Where, L Dice is the Dice coefficient loss, L CE is the cross entropy loss, L contrast is the contrastive learning loss, and λ1, λ2, and λ3 are weight coefficients used to balance Dice loss, cross entropy loss, and contrastive loss. Other loss function combinations can also be used, such as Focal Loss combined with Dice Loss, or Tversky Loss combined with cross entropy loss, as long as they effectively optimize the segmentation accuracy and stability of the model.

[0071] In step S352, the model can be trained using the Adam optimizer, for example, with an initial learning rate of 0.001. Training lasts for 30 epochs, and after each epoch, the model performance is evaluated using the validation set. Experimental results show that as training progresses, the validation loss gradually decreases and the Dice coefficient gradually improves. Ultimately, the validation loss decreases from 0.8 to 0.39, and the Dice coefficient increases from 0.75 to 0.89. The steady decrease in validation loss and increase in the Dice coefficient during training demonstrate the model's good convergence and stability.

[0072] Step S360: Optimize the preliminary training model to obtain a trained improved U-Net network. After the model training is completed, the model can be further optimized to achieve better segmentation effect or wider applicability.

[0073] See Figure 7 , step S360 includes steps S361 to S363.

[0074] Step S361: Use model pruning technology to remove redundant network connections in the initial training model to obtain the first optimized model. This step can reduce the complexity and computational requirements of the model. The pruning operation calculates the importance of each parameter and prunes the connections with smaller weights, which is defined as:

[0075] w′ ij =w ij *I(|w ij |>θ)

[0076] Among them, w′ ij is the weight after pruning, w ij is the original weight, I is the indicator function, and θ is the pruning threshold. By combining repeated pruning with training, the model structure is gradually optimized, significantly reducing the computational effort while maintaining accuracy. In this step, model pruning can be replaced by other model compression methods, such as knowledge distillation or low-rank decomposition, ensuring that segmentation accuracy is maintained while reducing model complexity.

[0077] Step S362: Using quantization technology, convert the floating point weights in the first optimization model into low-precision representation to obtain the second optimization model. This step can reduce storage and computing overhead. The quantized weights can be expressed as W q , and its calculation formula is:

[0078]

[0079] Where W is the floating-point weight, corresponding to the weight after the pruning operation in step S361, Δ is the quantization step size, and round indicates rounding. The quantization process reduces the model's memory usage and accelerates inference by reducing the number of bits required for representation. In this step, quantization can be replaced by other low-precision computation methods, such as binarization or ternaryization, as long as they reduce storage and computational overhead.

[0080] Step S363: The second optimization model is adapted and optimized according to the parameters of the hardware platform to obtain a trained improved U-Net network. The hardware platform can be, for example, a GPU, FPGA, etc. For the GPU platform, the floating-point weight parameter W is quantized to FP16 format, and the tensor core is used to accelerate matrix operations and optimize model reasoning. The formula is as follows: A = B × C; where A is the result matrix, B and C are the matrices to be multiplied. The use of tensor cores can greatly improve the efficiency of matrix operations and reduce inference time. The quantization process reduces the memory usage by reducing the number of parameter storage bits (from 32-bit to 16-bit) while retaining 98% of the original accuracy.

[0081] For the FPGA platform, the sparsity is increased to 60% by combining pruning technology, and the absolute value of the tree with a value less than the threshold θ = 1×10 -3 The redundant parameter w ij , and uses 4-bit block coding to adapt to the pipeline parallel architecture. This process reduces the number of model parameters by 50% and computational energy consumption by 40%. At the same time, dynamic gradient monitoring is used to restore important connections (weights with gradient absolute values greater than 0.01 are retained), ensuring the expressiveness of key features.

[0082] In addition to targeting GPUs and FPGAs, other hardware acceleration methods can also be used instead, such as optimization for ASICs or TPUs. Just ensure that the model's inference efficiency on different hardware platforms can be improved.

[0083] To evaluate the effectiveness of inference acceleration, this example records the model's inference time and precision loss before and after quantization. The results show that after quantization, inference time is reduced from 0.15 seconds to 0.1 seconds, while the precision loss is only 1%, demonstrating that quantization technology significantly improves inference speed while maintaining accuracy. On an FPGA platform, the model's inference time is only 0.1 seconds, meeting the requirements of real-time diagnosis. Furthermore, this example also tests the model's inference performance on both CPUs and GPUs, with the results showing that inference time on the GPU is 50% faster than on the CPU.

[0084] When adapting and optimizing the model, the inference speed and computing resource usage can be verified by repeated inference tests to ensure that the inference time and resource consumption meet the clinical real-time diagnosis requirements. infer The calculation formula is:

[0085] T infer =∑ i (T i *N i );

[0086] Among them, T i is the single time consumption of the i-th inference step, which is directly affected by the parameter accuracy (such as FP16 quantization speeds up the single-step matrix multiplication by 2 times) and sparsity (the convolutional layer FLOPs is reduced by 50% after pruning). i By evaluating the execution time of each inference step, the optimization strategy can be adjusted to make the overall inference time meet the clinical real-time diagnosis requirements.

[0087] Step S400: Post-process the second image using a conditional random field to optimize the segmentation boundary and obtain the final segmentation result. In order to further improve the accuracy of the segmentation result, the present invention applies a conditional random field (CRF) for post-processing to optimize the segmentation boundary and improve the accuracy. The specific calculation formula is:

[0088]

[0089] Where L is the adjacency matrix of the image, is the pixel-level prediction of the segmentation model for the input image, is the preliminary segmentation result. This is the refined segmentation result after optimization. In this step, the conditional random field can be replaced by other post-processing methods, such as graph cuts or Markov random fields, as long as they can optimize the segmentation boundaries and improve accuracy.

[0090] It should be noted that the step division of the various methods above is only for the purpose of clear description. During implementation, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they contain the same logical relationship, they are all within the scope of protection of this application; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.

[0091] See Figure 9 , Figure 9 An electronic device provided in one embodiment of the present invention includes a processor 101, a memory 102 and a communication bus; the communication bus is used to connect the processor 101 and the memory 102; the processor 101 is used to execute a computer program stored in the memory 102 to implement the above-mentioned medical image segmentation method.

[0092] An embodiment of the present invention further provides a computer-readable storage medium storing a computer program, wherein the computer program is used to enable a computer to execute the above-mentioned medical image segmentation method.

[0093] In summary, this paper aims to address the challenges of low training efficiency, sensitivity to class imbalance, and high computational complexity in medical image segmentation. Through innovative multi-stage data augmentation, feature optimization, and multimodal feature fusion, this method improves the accuracy and stability of medical image segmentation while reducing computational resource consumption.

[0094] The present invention can solve the following problems: (1) Noise interference problem: Medical images are often accompanied by noise, which may come from imaging equipment, patient movement or external interference. The segmentation accuracy of existing U-Net networks often decreases when faced with these noises. The present invention effectively reduces noise interference and improves the quality of input data through data preprocessing technologies such as Gaussian blur, median filtering and wavelet denoising, thereby improving the accuracy of segmentation. (2) Category imbalance problem: In medical images, the proportion of lesion areas is usually very small, while the proportion of normal tissue is very large. This category imbalance will cause the model to be more inclined to identify normal tissue, resulting in poor segmentation effect. The present invention balances the category ratio in the training data through methods such as data enhancement, resampling, designing special loss functions and utilizing generative adversarial networks, thereby improving the model's ability to recognize lesion areas.

[0095] The medical image segmentation method of the present invention has a wide range of application prospects, including but not limited to the following fields: (1) Tumor detection: In tumor detection, accurate segmentation of the tumor area is crucial for early diagnosis and treatment plan formulation. The algorithm of the present invention can effectively distinguish tumor tissue from normal tissue, improve the accuracy of detection, and assist doctors in making accurate diagnoses. (2) Organ segmentation: In medical image analysis, accurately segmenting the contours and structures of each organ is of great significance for surgical navigation and treatment plan formulation; the present invention can provide clearer and more accurate organ segmentation results through improved data preprocessing and category balancing technology. (3) Lesion area labeling: For the labeling of various lesions (such as lesions, lesion tissues, etc.), the algorithm of the present invention can accurately identify and segment the lesion area under complex background and noise interference, thereby improving the reliability of clinical diagnosis. (4) Image-guided surgery: In image-guided surgery, accurate image segmentation can provide real-time navigation for surgery, reduce surgical risks, and improve the success rate of surgery; the algorithm of the present invention can provide high-quality segmentation results before and during surgery, assisting doctors in performing precise operations. (5) Clinical research: In clinical research, accurate image segmentation is of great significance for studying disease progression, evaluating therapeutic efficacy, and developing new therapies. The high-precision segmentation results provided by the algorithm of the present invention can provide researchers with reliable data support.

[0096] The above embodiments are merely illustrative of the principles and effects of the present invention and are not intended to limit the present invention. Anyone skilled in the art may modify or alter the above embodiments without departing from the spirit and scope of the present invention. Therefore, all equivalent modifications or alterations made by one of ordinary skill in the art without departing from the spirit and technical principles disclosed herein are intended to be covered by the claims of the present invention.

Claims

1. A lightweight medical image segmentation method, characterized in that: include: Acquiring a medical image to be processed; Preprocessing the medical image to obtain a first image suitable for network input; Processing the first image using a trained improved U-Net network to obtain a segmented second image to distinguish between lesion areas and non-lesion areas, wherein the improved U-Net network is a U-Net network based on a self-attention mechanism; The second image is post-processed using a conditional random field to optimize the segmentation boundary to obtain a final segmentation result.

2. The lightweight medical image segmentation method according to claim 1, characterized in that: Preprocessing the medical image to obtain a first image suitable for network input includes: resizing the medical image to adjust the size of the medical image; Normalize the resized image to map pixel values to the interval [0,1]. An adaptive median filter is used to remove noise from the normalized image to obtain the first image.

3. The lightweight medical image segmentation method according to claim 1, characterized in that: The improved U-Net network is based on the U-Net network, and the jump connection is modified as follows: The features output by the encoder layer i are weighted and optimized using the following formula: S′ skip =σ(W skip *S skip )+α*S skip , Where S skip is the feature output by the encoder layer i, S′ skip is the weighted optimized feature, σ is the Sigmoid function, W skip is a learnable weight matrix, and α is a learnable parameter; The features output by the decoder layer i-1 are weighted by self-attention using the following formula: F attention =Attention(F input ,F input ), Where, F input is the feature output by the decoder layer i-1, Attention is the attention operation, F attention is the feature after self-attention weighting; The weighted optimized features and the self-attention weighted features are concatenated and input into the i-th layer decoder.

4. The lightweight medical image segmentation method according to claim 1, characterized in that: The improved U-Net network is trained according to the following steps: Obtain medical images containing multiple lesion types and their annotated images; Preprocessing the medical images containing multiple lesion types and the annotated images thereof to obtain a first data set suitable for network input; Performing data enhancement processing on the first data set to obtain a second data set; Build an improved U-Net network; Using the second data set to train the improved U-Net network to obtain a preliminary training model; The preliminary training model is optimized to obtain the trained improved U-Net network.

5. The lightweight medical image segmentation method according to claim 4, characterized in that: Performing data enhancement processing on the first data set to obtain a second data set includes: Performing rotation, flipping, and scaling operations on the first data set to obtain a first enhanced data set; Adding Gaussian noise to the first data set to obtain a second enhanced data set; Processing the first enhanced dataset and the second enhanced dataset using a generative adversarial network to obtain a third enhanced dataset; The first data set, the first enhanced data set, the second enhanced data set, and the third enhanced data set constitute the second data set.

6. The lightweight medical image segmentation method according to claim 4, characterized in that: The improved U-Net network is trained using the second data set to obtain a preliminary training model, including: Performing self-supervised pre-training on the improved U-Net network using the second data set and the first loss function; The pre-trained improved U-Net network is end-to-end trained using the second data set and the second loss function to obtain the preliminary training model.

7. The lightweight medical image segmentation method according to claim 6, characterized in that: The first loss function is contrastive learning loss, and the second loss function is obtained by weighting Dice coefficient loss, cross entropy loss, and contrastive learning loss.

8. The lightweight medical image segmentation method according to claim 4, characterized in that: Optimizing the preliminary training model to obtain the trained improved U-Net network includes: Using model pruning technology to remove redundant network connections in the preliminary training model to obtain a first optimized model; Using quantization technology, converting the floating-point weights in the first optimization model into low-precision representation to obtain a second optimization model; The second optimization model is adapted and optimized according to the parameters of the hardware platform to obtain the trained improved U-Net network.

9. An electronic device, characterized in that: The system comprises a processor, a memory and a communication bus; the communication bus is used to connect the processor and the memory; the processor is used to execute the computer program stored in the memory to implement the method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that A computer program is stored thereon, and the computer program is used to enable a computer to execute the method according to any one of claims 1 to 8.