A knowledge distillation method and system based on attention correction features and boundary constraints

Through the knowledge distillation method based on attention correction features and boundary constraints, the problem of difficulty in obtaining lightweight student models in the existing technology is solved, and medical image segmentation with higher performance and accuracy is achieved, which is suitable for clinical diagnosis applications.

CN117973500BActive Publication Date: 2024-09-03JIANGXI UNIV OF SCI & TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202410105437.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-01-25
Publication Date
2024-09-03
Estimated Expiration
2044-01-25

AI Technical Summary

Technical Problem

In the existing technology, it is difficult to obtain a lightweight image segmentation student model by introducing auxiliary modules to teachers or using hard boundary distillation methods, and the performance and accuracy of the trained student model are insufficient.

Method used

Using a knowledge distillation method based on attention correction features and boundary constraints, the residual correction factors and attention correction factors of teachers and students are obtained through non-negative matrix decomposition, and the hard boundary and soft boundary distillation losses are combined to comprehensively obtain the overall loss, and in Perform knowledge distillation without introducing auxiliary modules to improve the performance and accuracy of student models.

Benefits of technology

A lightweight medical image segmentation student model is achieved, which improves the performance and accuracy of the student model and can more accurately segment target areas in medical images. It is suitable for deployment in embedded devices for clinical diagnosis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117973500B
    Figure CN117973500B
Patent Text Reader

Abstract

The present application proposes a knowledge distillation method and system based on attention correction features and boundary constraints, the method includes attention correction feature distillation method and boundary constraint distillation method, wherein the attention correction feature distillation method mainly includes: without introducing auxiliary modules in the teacher, using correction factor distillation to give the student's attention correction factor the ability to imitate the teacher's residual correction factor, using attention-based feature distillation to guide students to learn attention correction features by imitating the teacher's residual correction features; the boundary constraint distillation method mainly combines hard boundary distillation and soft boundary distillation. The present application can solve the problem in the prior art that it is difficult to obtain a lightweight image segmentation student model by introducing auxiliary modules to the teacher or using hard boundary distillation methods, and the performance and accuracy of the student models trained by the two methods are insufficient.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of medical image processing, and in particular to a knowledge distillation method and system based on attention correction features and boundary constraints for medical image segmentation. Background Art

[0002] Medical image segmentation is a complex and critical step in the field of medical image processing and analysis. Its purpose is to segment parts of medical images with certain special meanings and extract relevant features to provide a reliable basis for clinical diagnosis and pathological research, and to assist doctors in making more accurate diagnoses.

[0003] Knowledge distillation is a common method for model compression. Different from pruning and quantization in model compression, knowledge distillation is to build a lightweight small model and use the supervision information of a large model with better performance to train the small model in order to achieve better performance and accuracy. The large model is called Teacher and the small model is called Student. The supervision information output from the Teacher model is called knowledge, and the process of Student learning to transfer the supervision information from the Teacher is called distillation.

[0004] At present, in the existing technology, the first one is: feature-based knowledge distillation usually requires the introduction of auxiliary modules in the teacher network to promote knowledge transfer. The second one is: using hard boundary distillation (Hard HD), obtaining boundaries according to the boundary detection algorithm, applying boundary filters to the vector (logits) layer of the teacher and the student to obtain boundary logits features, and distilling the boundary logits features of the teacher to the student through boundary loss, thereby obtaining excellent segmentation results.

[0005] However, the first prior art introduces an auxiliary module to the teacher, which requires re-pretraining the teacher network, greatly limiting the application of feature-based knowledge distillation in medical image segmentation. Although the second prior art hard boundary distillation can effectively improve the student's boundary perception ability, it is worth noting that it is also susceptible to noise interference, which limits the maximum extent to which the student network can be improved. Therefore, in the prior art, it is difficult to obtain a lightweight image segmentation student model by introducing an auxiliary module to the teacher or using the hard boundary distillation method, and the performance and accuracy of the student models trained by the two methods are insufficient. Summary of the invention

[0006] Based on this, the present application proposes a knowledge distillation method and system based on attention correction features and boundary constraints, aiming to solve the problem in the prior art that it is difficult to obtain a lightweight image segmentation student model by introducing auxiliary modules to the teacher or adopting a hard boundary distillation method, and the performance and accuracy of the student models trained by the two methods are insufficient.

[0007] A first aspect of the embodiment provides a knowledge distillation method based on attention correction features and boundary constraints, the method comprising:

[0008] Acquire a medical image dataset and construct a teacher model and a student model respectively, input the medical image dataset into the teacher model and the student model respectively, and extract the intermediate features of the teacher and the intermediate features of the student;

[0009] According to the principle of non-negative matrix decomposition, a residual correction factor of the teacher and an attention correction factor of the student are obtained, a residual correction feature of the teacher is obtained according to the residual correction factor and the intermediate feature of the teacher, and an attention correction feature of the student is obtained according to the attention correction factor and the intermediate feature of the student;

[0010] The loss obtained by imitating the residual correction factor of the teacher by the student's attention correction factor is defined as the correction factor distillation loss, the loss obtained by the student imitating the residual correction feature of the teacher to guide the student to learn the attention correction feature is defined as the attention-based feature distillation loss, and the correction factor distillation loss and the attention-based feature distillation loss are combined to obtain the fusion loss;

[0011] Constructing a hard boundary distillation model and a soft boundary distillation model respectively, and inputting the medical image dataset into the hard boundary distillation model and the soft boundary distillation model respectively to obtain a hard boundary distillation loss and a soft boundary distillation loss;

[0012] The fusion loss, hard boundary distillation loss, and soft boundary distillation loss are combined to obtain the overall loss;

[0013] When the overall loss reaches a preset minimum value, the cycle training is terminated to obtain a lightweight medical image segmentation student model.

[0014] As an optional implementation of the first aspect, the step of obtaining the teacher's residual correction factor and the student's attention correction factor according to the principle of non-negative matrix decomposition includes:

[0015] According to the principle of non-negative matrix decomposition, a correspondence relationship between the additive correction applied by the residual connection and the multiplicative correction applied by the attention mechanism is constructed for the input image features, and the residual connection is converted into the attention mechanism through the correspondence relationship;

[0016] The additive correction applied through the residual connection is expressed as:

[0017] ,

[0018] Get the residual correction factor ,

[0019]

[0020] in, represents the updated input features of the lth layer, represents the input features of the lth layer, represents the learning rate, Indicates the error, represents feature transformation, represents the input features of the l+1th layer, represents the network weight of the lth layer, and + represents element-by-element addition;

[0021] The multiplicative correction applied by the attention mechanism is expressed as:

[0022] ,

[0023] Get the attention correction factor ,

[0024] in, Represents element-wise multiplication.

[0025] As an optional implementation of the first aspect, the residual correction feature of the teacher is expressed as:

[0026] ,

[0027] in, represents the residual correction characteristics of the teacher, Indicates the intermediate characteristics of teachers;

[0028] The expression of the student's attention correction feature is:

[0029] ,

[0030] in, represents the attention correction characteristics of students, Represents the middle characteristics of students.

[0031] As an optional implementation manner of the first aspect, the functional expression of the correction factor distillation loss is:

[0032] ,

[0033] in, represents the correction factor for distillation losses, represents AT loss, represents the conversion of the attention correction factor into the residual correction factor;

[0034] The functional expression of the attention-based feature distillation loss is:

[0035] ,

[0036] in, represents the attention-based feature distillation loss;

[0037] The functional expression of the fusion loss is:

[0038] ,

[0039] in, represents the fusion loss.

[0040] As an optional implementation manner of the first aspect, the functional expression of the hard boundary distillation loss is:

[0041]

[0042] in, represents the hard boundary distillation loss, B represents the batch size, C represents the number of categories, k represents the sample, and c represents the category. represents the KL divergence, represents the softmax function, τ represents the distillation temperature, , Represent the boundary logits of each category c in teachers and students respectively;

[0043] The functional expression of the soft boundary distillation loss is:

[0044] ,

[0045] in, represents the soft boundary distillation loss, represents the student prediction boundary, represents the teacher prediction boundary, represents the Hadamard product, represents the set of all pixels, represents the unsigned distance from any pixel in the distance map to the teacher's predicted boundary, represents the unsigned distance from any pixel in the distance map to the student prediction boundary, Represents the penalty for segmentation error.

[0046] As an optional implementation manner of the first aspect, the functional expression of the overall loss is:

[0047] ,

[0048] in, represents the overall loss, is a linear decreasing function.

[0049] As an optional implementation manner of the first aspect, the step of ending the periodic training when the overall loss reaches a preset minimum value to obtain a lightweight medical image segmentation student model includes:

[0050] At the beginning of training, γ = 1, and it decreases linearly with each training cycle until the training ends when γ = 0.5.

[0051] A second aspect of an embodiment of the present application provides a knowledge distillation system based on attention correction features and boundary constraints, including:

[0052] A feature acquisition module is used to acquire a medical image dataset and construct a teacher model and a student model respectively, input the medical image dataset into the teacher model and the student model respectively, and extract the intermediate features of the teacher and the intermediate features of the student;

[0053] A feature correction module, used to obtain a residual correction factor of a teacher and an attention correction factor of a student according to the principle of non-negative matrix decomposition, obtain a residual correction feature of the teacher according to the residual correction factor and the intermediate feature of the teacher, and obtain an attention correction feature of the student according to the attention correction factor and the intermediate feature of the student;

[0054] A feature loss module, used to define the loss obtained by imitating the residual correction factor of the teacher by the student's attention correction factor as a correction factor distillation loss, define the loss obtained by the student imitating the residual correction feature of the teacher to guide the student to learn the attention correction feature as an attention-based feature distillation loss, and combine the correction factor distillation loss and the attention-based feature distillation loss to obtain a fusion loss;

[0055] A boundary loss module, used to construct a hard boundary distillation model and a soft boundary distillation model respectively, and input the medical image data set into the hard boundary distillation model and the soft boundary distillation model respectively to obtain a hard boundary distillation loss and a soft boundary distillation loss;

[0056] The overall loss module is used to combine the fusion loss, hard boundary distillation loss and soft boundary distillation loss to obtain the overall loss;

[0057] The model training module is used to end the cycle training when the overall loss reaches a preset minimum value to obtain a lightweight medical image segmentation student model.

[0058] A third aspect of an embodiment of the present application provides a storage medium, which stores one or more programs, which, when executed by a processor, implements the above-mentioned knowledge distillation method based on attention correction features and boundary constraints.

[0059] A fourth aspect of an embodiment of the present application provides a computer device, wherein the memory is used to store a computer program, and the processor is used to execute the computer program stored in the memory to implement the above-mentioned knowledge distillation method based on attention correction features and boundary constraints.

[0060] Compared with the prior art, the present application provides a knowledge distillation method and system based on attention correction features and boundary constraints, which includes an attention correction feature distillation method and a boundary constraint distillation method. The attention correction feature distillation method mainly includes: by analyzing the non-negative matrix decomposition, it is found that there is a corresponding relationship between the additive correction of the input features through the residual connection and the multiplicative correction through the attention mechanism, and the conversion of the attention correction factor to the residual correction factor can be realized. This discovery can perform knowledge distillation based on the correction features without introducing an auxiliary module in the teacher, and directly transfer the residual-corrected features in the teacher to the attention-corrected features in the student, and introduce a learnable attention correction factor in the student to make up for the knowledge gap between the teacher and the student; the boundary constraint distillation method mainly includes: by combining hard boundary distillation and soft boundary distillation, the effect of class-by-class boundary logits distillation can be improved. Compared with the problem of being easily interfered by noise when only using hard boundary distillation, the target area in the medical image can be segmented more accurately. The losses obtained by the attention correction feature distillation method and the boundary constraint distillation method are weighted and summed to obtain the overall loss. When the overall loss is minimized, the model training is terminated to obtain a lightweight medical image segmentation student model, which can be deployed in embedded devices to promote the application of medical image segmentation models in clinical diagnosis. Therefore, the present application can solve the problem in the prior art that it is difficult to obtain a lightweight image segmentation student model by introducing an auxiliary module to the teacher or using a hard boundary distillation method, and the performance and accuracy of the student models trained by the two methods are insufficient.

[0061] Additional aspects and advantages of the present application will be given in part in the following description, and in part will become apparent from the following description, or will be understood through the embodiments of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0062] Figure 1A flowchart of a knowledge distillation method based on attention correction features and boundary constraints proposed in one embodiment of the present application;

[0063] Figure 2 The overall framework diagram of the attention correction feature and boundary constraint knowledge distillation (ACF-BCKD) proposed in one embodiment of the present application;

[0064] Figure 3 This is an experimental flow chart of a knowledge distillation method based on attention correction features and boundary constraints in a pair of ratios in this application;

[0065] Figure 4 This is the original CT image in a pair of ratios in this application;

[0066] Figure 5 The segmented CT image in a pair of ratios in this application;

[0067] Figure 6 A real segmented CT image in a pair of ratios in this application;

[0068] Figure 7 A schematic diagram of the structure of a knowledge distillation system based on attention correction features and boundary constraints proposed in one embodiment of the present application.

[0069] The following specific implementation methods will further illustrate the present application in conjunction with the above-mentioned drawings. DETAILED DESCRIPTION

[0070] In order to facilitate understanding of the present application, the present application will be described more fully below with reference to the relevant drawings. Several embodiments of the present application are provided in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the disclosure of the present application more thorough and comprehensive.

[0071] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application. The term "and / or" used herein includes any and all combinations of one or more of the related listed items.

[0072] In order to illustrate the technical solution described in this application, a specific embodiment is provided below for illustration.

[0073] See also Figure 1 , which is a flow chart of a knowledge distillation method based on attention correction features and boundary constraints in one embodiment of the present application, and the method is described in detail as follows:

[0074] Step S1: Obtain a medical image dataset and construct a teacher model and a student model respectively, input the medical image dataset into the teacher model and the student model respectively, and extract the intermediate features of the teacher and the intermediate features of the student.

[0075] Image data processing is widely used in medicine. Medical images mainly involve edge extraction, image enhancement, microscopic image stitching, image segmentation, stereo reconstruction and other technologies of CT and MRI images.

[0076] Knowledge distillation adopts a teacher-student model: a complex and large model is used as a teacher, and the student model structure is relatively simple. The teacher is used to assist the student model in training. The teacher has strong learning ability and can transfer the knowledge it has learned to the student model with relatively weak learning ability, thereby enhancing the generalization ability of the student model.

[0077] In this application, the same batch of medical image datasets are put into two models at the same time, the predicted output of the teacher model is used as the soft label, and the true label is used as the hard label. The two losses of the student model are calculated separately, and finally the two losses are weighted summed as the final overall loss to update the network parameters. When predicting, only the student model is used.

[0078] Knowledge distillation can transfer the feature representation ability of a strong teacher to a lightweight student, thereby improving the student segmentation performance. Therefore, promoting effective feature distillation between teachers and students is crucial for developing a strong lightweight student network.

[0079] Step S2: According to the principle of non-negative matrix decomposition, the teacher's residual correction factor and the student's attention correction factor are obtained, the teacher's residual correction feature is obtained according to the residual correction factor and the teacher's intermediate feature, and the student's attention correction feature is obtained according to the attention correction factor and the student's intermediate feature.

[0080] It should be noted that non-negative matrix factorization (NMF) is to find a non-negative matrix N (base matrix) and a non-negative matrix H (coefficient matrix) for any given non-negative matrix V, satisfying the condition V = NH, thereby decomposing a non-negative matrix into the product of the left and right non-negative matrices. Each column in the V matrix represents an observation, and each row represents a feature.

[0081] There are two theoretical solutions for NMF when optimizing low-rank basis matrices and coefficient matrices. The first solution is to optimize the reconstruction loss by calculating the update step size determined by the gradient and the learning rate, and finally correct the basis matrix or coefficient matrix by adding the step size. The second solution is to calculate the correction factor derived from the update step size, and finally correct the basis matrix or coefficient matrix by multiplying the correction factor. By analyzing NMF, this application determines the correspondence between the additive correction applied by the residual connection to the input features and the multiplicative correction applied by the attention mechanism to the input features.

[0082] Specifically, according to the stochastic gradient descent algorithm (SGD), the minimum loss function The optimization process of updating N and H through NMF is formalized as:

[0083] ,

[0084] ,

[0085] Among them, N represents the basis matrix, H represents the coefficient matrix, and V represents the target matrix. and Represent the learning rates when optimizing N and H respectively.

[0086] ,

[0087] ,

[0088] The above formula involves calculating the step size To update N, by calculating the step size The form of H is updated to optimize the reconstruction loss. Finally, the basis matrix N or the coefficient matrix H can be corrected in an element-by-element addition manner.

[0089] Give the learning rate and Assign values ​​to , , the above formula can be converted into:

[0090] ,

[0091] ,

[0092] in, Represents element-wise multiplication.

[0093] It is worth noting that by deriving the above formula, we can get the optimized loss function Another solution.

[0094] Specifically, through To update the basis matrix N, To update the coefficient matrix H. This application only focuses on the update of the input feature F, and regards N as the input feature F in CNN.

[0095] The additive correction applied to the input image features through the residual connection is expressed as:

[0096] ,

[0097] Right now ,

[0098] Get the residual correction factor ,

[0099]

[0100] in, represents the updated input features of the lth layer, represents the input features of the lth layer, represents the learning rate, Indicates the error, represents feature transformation, represents the input features of the l+1th layer, Represents the network weight of the lth layer, and + represents element-by-element addition.

[0101] The multiplicative correction applied by the attention mechanism is expressed as:

[0102] ,

[0103] Get the attention correction factor ,

[0104] in, Represents element-wise multiplication.

[0105] According to the above analysis from NMF theory, both residual connection and attention mechanism are corrections to the input feature F. At the same time, it is theoretically feasible to convert residual connection into attention mechanism. This application introduces a 1×1×1conv to convert the attention correction factor into the residual correction factor.

[0106] Step S3: The loss obtained by imitating the teacher's residual correction factor of the student's attention correction factor is defined as the correction factor distillation loss, and the loss obtained by imitating the teacher's residual correction feature to guide the student to learn the attention correction feature is defined as the attention-based feature distillation loss. The correction factor distillation loss and the attention-based feature distillation loss are combined to obtain the fusion loss.

[0107] It should be noted that in order to promote effective knowledge transfer, students are required to imitate the intermediate characteristics of teachers, which helps to minimize To improve the performance of feature-based knowledge distillation:

[0108] ,

[0109] in, represents the attention-based distillation loss (AT loss), represents the feature-based knowledge distillation loss, represents the middle characteristics of teachers, Indicates the middle characteristics of students;

[0110] AT uses activation or gradient-based strategies to obtain spatial attention maps. However, AT is limited by the huge knowledge gap between teachers and students. In order to better bridge the knowledge gap between teachers and students, this application introduces a learnable attention correction factor , to extract the learnable attention map of the student.

[0111] The expression of the student's attention correction feature is:

[0112] ,

[0113] in, Indicates the attention correction characteristics of students;

[0114] then, .

[0115] The residual-corrected features maintain strong representation in the teacher, which provides a clue for knowledge distillation based on the corrected features, that is, feature-based knowledge distillation can be performed without introducing additional auxiliary modules for the teacher. The functional expression of the attention-based feature distillation loss proposed in this application is:

[0116] ,

[0117] in, represents the attention-based feature distillation loss;

[0118] The expression of the teacher's residual correction feature is:

[0119] ,

[0120] in, represents the residual correction characteristics of the teacher;

[0121] At the same time, we can also add the attention correction factor and residual correction factor The knowledge distillation based on AT is further applied, and the functional expression of the correction factor distillation loss proposed in this application is:

[0122] ,

[0123] in, represents the correction factor for distillation losses, Indicates the conversion of the attention correction factor into a residual correction factor, that is, 1×1×1conv;

[0124] Therefore, the functional expression of the fusion loss is:

[0125] ,

[0126] in, represents the fusion loss.

[0127] Step S4: construct a hard boundary distillation model and a soft boundary distillation model respectively, and input the medical image dataset into the hard boundary distillation model and the soft boundary distillation model respectively to obtain a hard boundary distillation loss and a soft boundary distillation loss.

[0128] It should be noted that medical images usually have low contrast and fuzzy segmentation boundaries. Introducing boundary perception ability in students is crucial to improving the accuracy of medical image segmentation.

[0129] This application uses a 3×3×3 conv with weight equal to 1 to extract the boundary to obtain the true label. The output logits of the teacher are expressed as , assuming that the student's output logits have the same shape as the teacher's output logits, that is The true label is represented as , where B represents the batch size, C represents the number of categories, H, W, D represent the height, width, and depth respectively, and HWD represents the image size. For a sample k in a batch, its true label is expressed as The boundary mask extracted for each category c in this application is expressed as ,in , the position marked as 1 represents the boundary of class c. The teacher logtis of sample k is expressed as , the Student logtis of sample k is expressed as This application performs element-by-element multiplication on the boundary mask and logits to obtain the boundary logits for each category c in the teacher and the student. , :

[0130] ,

[0131] Among them, the boundary of each category c in the teacher and the student , the boundary mask extracted for each category c is expressed as , Represents element-wise multiplication.

[0132] By performing softmax operation and KL divergence, we get and The probability distribution of , we get the hard boundary distillation loss, whose function expression is:

[0133]

[0134] in, represents the hard edge distillation loss, represents the softmax function, and τ represents the distillation temperature.

[0135] Since hard boundary distillation is susceptible to noise, which limits the maximum extent to which the student network can be improved, soft boundary distillation is proposed, which estimates the Hausdorff distance HD by using the distance transform DT of the segmentation boundary:

[0136] ,

[0137] in, represents the Hadamard product, Indicates the true boundary, the foreground is marked as 1 and the background is marked as 0. represents the boundary prediction, Represents the unsigned distance from any pixel in the distance map to the boundary. Represents the unsigned distance from any pixel in the distance map to the predicted boundary. Represents the penalty for segmentation error.

[0138] In order to incorporate DT into the knowledge distillation framework proposed in this application, the true boundary P is replaced by the label predicted by the teacher , and replace the predicted boundary q with the student's predicted In order to ensure the stability of the distillation loss, a logarithmic function is used to adjust the size of the loss. The function expression of the soft boundary distillation loss is:

[0139] ,

[0140] in, represents the soft boundary distillation loss, represents the student prediction boundary, represents the teacher prediction boundary, represents the set of all pixels, represents the unsigned distance from any pixel in the distance map to the teacher's predicted boundary, Represents the unsigned distance from any pixel in the distance map to the student prediction boundary.

[0141] Soft boundary distillation can reduce the impact of noise interference on hard boundary distillation. By integrating hard boundary distillation and soft boundary distillation, the proposed boundary constraint distillation can improve the effect of class-by-class boundary logits distillation and achieve more accurate target area segmentation.

[0142] Step S5: The fusion loss, hard boundary distillation loss and soft boundary distillation loss are combined to obtain the overall loss.

[0143] The functional expression of the overall loss is:

[0144] ,

[0145] in, represents the overall loss, is a linear decreasing function.

[0146] Step S6: When the overall loss reaches a preset minimum value, the cycle training is terminated to obtain a lightweight medical image segmentation student model.

[0147] The step of ending the periodic training when the overall loss reaches a preset minimum value and obtaining a lightweight medical image segmentation student model comprises:

[0148] At the beginning of training, γ = 1, and it decreases linearly with each training cycle until the training ends when γ = 0.5.

[0149] For example, Figure 2 As shown in the figure, it is the overall framework diagram of the attention correction feature and boundary constraint knowledge distillation (ACF-BCKD) proposed in this application. Its purpose is to perform soft boundary distillation (Soft BD) after learning stable hard boundary distillation (Hard BD). Finally, the attention correction feature distillation method (ACFD) of this application can realize knowledge distillation based on correction features in medical image segmentation, while the boundary constraint distillation method (BCD) can effectively improve the transfer of class-by-class boundary logits knowledge.

[0150] In summary, the present application provides a knowledge distillation method and system based on attention correction features and boundary constraints, which includes attention correction feature distillation method and boundary constraint distillation method, wherein the attention correction feature distillation method is mainly: by analyzing the non-negative matrix decomposition, it is found that there is a corresponding relationship between the additive correction of the input features through the residual connection and the multiplication correction through the attention mechanism, and the conversion of the attention correction factor to the residual correction factor can be realized. This discovery can perform knowledge distillation based on correction features without introducing an auxiliary module in the teacher, and directly pass the residual-corrected features in the teacher to the attention-corrected features in the student, and introduce a learnable attention correction factor in the student to make up for the knowledge gap between the teacher and the student; the boundary constraint distillation method is mainly: by combining hard boundary distillation and soft boundary distillation, the effect of class-by-class boundary logits distillation can be improved, and compared with the problem that only hard boundary distillation is easily interfered by noise, the target area in the medical image can be segmented more accurately. Then the losses obtained by the attention correction feature distillation method and the boundary constraint distillation method are weighted and summed to obtain the overall loss, and the training model is terminated when the overall loss is minimized to obtain a lightweight medical image segmentation student model.

[0151] See also Figure 3 , shown is an experimental flow chart of a knowledge distillation method based on attention correction features and boundary constraints in a pair of ratios of this application, as follows:

[0152] Step S01: Acquire a CT original image.

[0153] Step S02: inputting the original CT image into the "lightweight CT image segmentation student model" to obtain a segmented CT image.

[0154] Specifically, Figure 4 The original CT image is shown as Figure 5 The CT image after segmentation is shown as Figure 6 Shown is the actual segmented CT image.

[0155] Step S03: comparing the difference between the segmented CT image and the real segmented CT image.

[0156] Step S04: When the difference between the segmented CT image and the real segmented CT image reaches the target minimum difference, the lightweight model is deployed to the embedded device.

[0157] See also Figure 7 , which is a schematic diagram of the structure of a knowledge distillation system based on attention correction features and boundary constraints in one embodiment of the present application, and the system includes:

[0158] A feature acquisition module 10 is used to acquire a medical image data set and construct a teacher model and a student model respectively, input the medical image data set into the teacher model and the student model respectively, and extract the intermediate features of the teacher and the intermediate features of the student;

[0159] The feature correction module 20 is used to obtain the residual correction factor of the teacher and the attention correction factor of the student according to the principle of non-negative matrix decomposition, obtain the residual correction feature of the teacher according to the residual correction factor and the intermediate feature of the teacher, and obtain the attention correction feature of the student according to the attention correction factor and the intermediate feature of the student;

[0160] A feature loss module 30 is used to define the loss obtained by imitating the residual correction factor of the teacher by the student's attention correction factor as a correction factor distillation loss, define the loss obtained by the student imitating the residual correction feature of the teacher to guide the student to learn the attention correction feature as an attention-based feature distillation loss, and combine the correction factor distillation loss and the attention-based feature distillation loss to obtain a fusion loss;

[0161] A boundary loss module 40 is used to construct a hard boundary distillation model and a soft boundary distillation model respectively, and input the medical image data set into the hard boundary distillation model and the soft boundary distillation model respectively to obtain a hard boundary distillation loss and a soft boundary distillation loss;

[0162] An overall loss module 50, for integrating the fusion loss, the hard boundary distillation loss and the soft boundary distillation loss to obtain an overall loss;

[0163] The model training module 60 is used to end the periodic training when the overall loss reaches a preset minimum value, thereby obtaining a lightweight medical image segmentation student model.

[0164] On the other hand, the present application also provides a storage medium, which stores one or more programs, which, when executed by a processor, implement the above-mentioned knowledge distillation method based on attention correction features and boundary constraints.

[0165] On the other hand, the present application also proposes a computer device, including a memory and a processor, wherein the memory is used to store a computer program, and the processor is used to implement the above-mentioned knowledge distillation method based on attention correction features and boundary constraints when executing the computer program stored in the memory.

[0166] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.

[0167] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A knowledge distillation method based on attention correction features and boundary constraints, characterized in that: The method comprises: Acquire a medical image dataset and construct a teacher model and a student model respectively, input the medical image dataset into the teacher model and the student model respectively, and extract the intermediate features of the teacher and the intermediate features of the student; According to the principle of non-negative matrix decomposition, a residual correction factor of the teacher and an attention correction factor of the student are obtained, a residual correction feature of the teacher is obtained according to the residual correction factor and the intermediate feature of the teacher, and an attention correction feature of the student is obtained according to the attention correction factor and the intermediate feature of the student; The step of obtaining the teacher's residual correction factor and the student's attention correction factor according to the principle of non-negative matrix decomposition includes: constructing a correspondence between the additive correction applied by the residual connection and the multiplicative correction applied by the attention mechanism to the input image features according to the principle of non-negative matrix decomposition, and converting the residual connection into the attention mechanism through the correspondence; The additive correction applied through the residual connection is expressed as: , Get the residual correction factor , in, represents the updated input features of the lth layer, represents the input features of the lth layer, represents the learning rate, Indicates the error, represents feature transformation, represents the input features of the l+1th layer, represents the network weight of the lth layer, and + represents element-by-element addition; The multiplicative correction applied by the attention mechanism is expressed as: , Get the attention correction factor , in, Represents element-wise multiplication; The expression of the teacher's residual correction feature is: , in, represents the residual correction characteristics of the teacher, represents the intermediate characteristics of teachers; The expression of the student's attention correction feature is: , in, represents the attention correction characteristics of students, Indicates the intermediate characteristics of students; The loss obtained by imitating the residual correction factor of the teacher by the student's attention correction factor is defined as the correction factor distillation loss, the loss obtained by the student imitating the residual correction feature of the teacher to guide the student to learn the attention correction feature is defined as the attention-based feature distillation loss, and the correction factor distillation loss and the attention-based feature distillation loss are combined to obtain the fusion loss; The functional expression of the correction factor distillation loss is: , in, represents the correction factor for distillation losses, represents AT loss, represents the conversion of the attention correction factor into the residual correction factor; The functional expression of the attention-based feature distillation loss is: , in, represents the attention-based feature distillation loss; The functional expression of the fusion loss is: , in, represents the fusion loss; Constructing a hard boundary distillation model and a soft boundary distillation model respectively, and inputting the medical image dataset into the hard boundary distillation model and the soft boundary distillation model respectively to obtain a hard boundary distillation loss and a soft boundary distillation loss; The fusion loss, hard boundary distillation loss, and soft boundary distillation loss are combined to obtain the overall loss; When the overall loss reaches a preset minimum value, the cycle training is terminated to obtain a lightweight medical image segmentation student model.

2. The method according to claim 1, characterized in that: The functional expression of the hard boundary distillation loss is: in, represents the hard boundary distillation loss, B represents the batch size, C represents the number of categories, k represents the sample, and c represents the category. represents the KL divergence, represents the softmax function, τ represents the distillation temperature, , Represent the boundary logits of each category c in teachers and students respectively; The functional expression of the soft boundary distillation loss is: , in, represents the soft boundary distillation loss, represents the student prediction boundary, represents the teacher prediction boundary, represents the Hadamard product, represents the set of all pixels, represents the unsigned distance from any pixel in the distance map to the teacher's predicted boundary, represents the unsigned distance from any pixel in the distance map to the student prediction boundary, Represents the penalty for segmentation error.

3. The method according to claim 2, characterized in that: The functional expression of the overall loss is: , in, represents the overall loss, is a linear decreasing function.

4. The method according to claim 3, characterized in that: The step of ending the periodic training when the overall loss reaches a preset minimum value and obtaining a lightweight medical image segmentation student model comprises: At the beginning of training, γ = 1, and it decreases linearly with each training cycle until the training ends when γ = 0.

5.

5. A knowledge distillation system based on attention correction features and boundary constraints, characterized in that: The system comprises: A feature acquisition module is used to acquire a medical image dataset and construct a teacher model and a student model respectively, input the medical image dataset into the teacher model and the student model respectively, and extract the intermediate features of the teacher and the intermediate features of the student; A feature correction module, used to obtain a residual correction factor of a teacher and an attention correction factor of a student according to the principle of non-negative matrix decomposition, obtain a residual correction feature of the teacher according to the residual correction factor and the intermediate feature of the teacher, and obtain an attention correction feature of the student according to the attention correction factor and the intermediate feature of the student; The step of obtaining the teacher's residual correction factor and the student's attention correction factor according to the principle of non-negative matrix decomposition includes: constructing a correspondence between the additive correction applied by the residual connection and the multiplicative correction applied by the attention mechanism to the input image features according to the principle of non-negative matrix decomposition, and converting the residual connection into the attention mechanism through the correspondence; The additive correction applied through the residual connection is expressed as: , Get the residual correction factor , in, represents the updated input features of the lth layer, represents the input features of the lth layer, represents the learning rate, Indicates the error, represents feature transformation, represents the input features of the l+1th layer, represents the network weight of the lth layer, and + represents element-by-element addition; The multiplicative correction applied by the attention mechanism is expressed as: , Get the attention correction factor , in, Represents element-wise multiplication; The expression of the teacher's residual correction feature is: , in, represents the residual correction characteristics of the teacher, represents the intermediate characteristics of teachers; The expression of the student's attention correction feature is: , in, represents the attention correction characteristics of students, Indicates the intermediate characteristics of students; A feature loss module, used to define the loss obtained by imitating the residual correction factor of the teacher by the student's attention correction factor as a correction factor distillation loss, define the loss obtained by the student imitating the residual correction feature of the teacher to guide the student to learn the attention correction feature as an attention-based feature distillation loss, and combine the correction factor distillation loss and the attention-based feature distillation loss to obtain a fusion loss; The functional expression of the correction factor distillation loss is: , in, represents the correction factor for distillation losses, represents AT loss, represents the conversion of the attention correction factor into the residual correction factor; The functional expression of the attention-based feature distillation loss is: , in, represents the attention-based feature distillation loss; The functional expression of the fusion loss is: , in, represents the fusion loss; A boundary loss module, used to construct a hard boundary distillation model and a soft boundary distillation model respectively, and input the medical image data set into the hard boundary distillation model and the soft boundary distillation model respectively to obtain a hard boundary distillation loss and a soft boundary distillation loss; The overall loss module is used to combine the fusion loss, hard boundary distillation loss and soft boundary distillation loss to obtain the overall loss; The model training module is used to end the cycle training when the overall loss reaches a preset minimum value to obtain a lightweight medical image segmentation student model.

6. A computer device, characterized in that: The computer device comprises a memory and a processor, wherein: The memory is used to store computer programs; When the processor is used to execute the computer program stored in the memory, it implements a knowledge distillation method based on attention correction features and boundary constraints as described in any one of claims 1-4.

7. A storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, it implements a knowledge distillation method based on attention correction features and boundary constraints as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Rock category prediction method based on multi-teacher knowledge distillation and normalized attention

    CN115393671A

  • Root cause analysis of process cycle images based on deep learning

    CN115812223A

  • New coronavirus CT image segmentation method based on transfer learning and attention mechanism

    CN116258848A

  • Medical image organ segmentation method based on decoupling 3D self-attention network

    CN117036704A

  • Hybrid model and system for predicting quality and identifying features and entities of risk controls

    US20230376833A1