A multi-task classification system for histopathological images based on cue learning

Through a system based on cue learning, the correlation between tissue pathology images is explicitly identified and utilized, which significantly improves the performance of multi-task classification, solves the problem of poor performance caused by existing models that ignore correlation, and achieves more efficient multi-task adaptation. ability.

CN117422912BActive Publication Date: 2024-08-23HARBIN INST OF TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311366790.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-20
Publication Date
2024-08-23
Estimated Expiration
2043-10-20

AI Technical Summary

Technical Problem

Existing multi-task learning models ignore the potential correlation between histopathological images, resulting in poor multi-task classification performance of histopathological images.

Method used

A system based on prompt learning is adopted to design task-specific tasks through the image acquisition module, task-related prompt initialization module, sub-image patch feature extraction module, task correlation learning module, task shared knowledge representation module, task prompt module and task-related knowledge representation module. Hints and learning modules explicitly identify and exploit correlations between tasks and comprehensively fine-tune neural networks.

Benefits of technology

It significantly improves the performance and computational efficiency of multi-task classification of histopathological images, enhances the model's adaptability to multiple tasks, and solves the limitations of existing methods in processing complex histopathological images.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117422912B
    Figure CN117422912B
Patent Text Reader

Abstract

A multi-task classification system for histopathological images based on prompt learning, which belongs to the technical field of medical image analysis. The present invention solves the problem that the existing multi-task learning model ignores the potential correlation between tasks, resulting in poor performance of the existing methods for multi-task classification of histopathological images. The present invention can explicitly identify and utilize the potential correlation between various tasks by designing task-specific prompts for each task and introducing a task-relevance learning module. In addition, the present invention comprehensively fine-tunes the entire neural network model during training so that each task promotes each other. This strategy not only significantly improves its computational efficiency and performance relative to training multiple single-task models, but also enhances the model's adaptability to a variety of different tasks, thereby improving the performance of the method of the present invention in multi-task classification of histopathological images. The present invention can be applied to medical image analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of medical image analysis, and in particular relates to a multi-task classification system for tissue pathology images based on prompt learning. Background Art

[0002] Histopathology images are widely regarded as the gold standard for medical diagnosis and are of indispensable importance in the medical field. When faced with complex pathological slice analysis, doctors often need to make multi-faceted diagnoses, including but not limited to tumor classification and grading. However, most of the current deep learning-based histopathology image classification methods are still limited to image classification for a single diagnostic task. Although some methods attempt to use multi-task learning models, these models mainly focus on learning task-specific information and task-generic information, but often ignore the potential correlation or interdependence between tasks (cross-task correlation).

[0003] Prompt Learning is a new learning paradigm that was initially used to optimize downstream tasks of pre-trained models in Natural Language Processing (NLP). Unlike traditional model fine-tuning methods, prompt learning aims to enable pre-trained models to adapt to various downstream tasks faster and more efficiently by adding and fine-tuning specific learnable "prompts" without fine-tuning a large number of model parameters. Recently, this method has been gradually applied to computer vision tasks. However, existing research and applications are still mainly limited to processing single or independent visual tasks, and their effectiveness and applicability in dealing with multi-task classification environments of ultra-large-scale tissue pathology images have not been deeply explored.

[0004] In summary, since the existing multi-task learning models ignore the potential correlation between tasks, the performance of existing methods for multi-task classification of tissue pathology images is still poor. Improving the performance of multi-task classification of tissue pathology images is an urgent problem that needs to be solved. Summary of the invention

[0005] The purpose of the present invention is to solve the problem that the existing multi-task learning model ignores the potential correlation between tasks, resulting in poor performance of the existing methods for multi-task classification of tissue pathology images, and propose a multi-task classification system for tissue pathology images based on prompt learning.

[0006] The technical solution adopted by the present invention to solve the above technical problems is: a multi-task classification system of tissue pathology images based on prompt learning, the system includes an image acquisition module, a task-related prompt initialization module, a sub-image patch feature extraction module, a task-related learning module, a task-shared knowledge representation module, a task prompt module and a task-related knowledge representation module, wherein:

[0007] The image acquisition module is used to acquire the tissue pathology image to be classified;

[0008] The task-related prompt initialization module is used to encode the name of each classification task of the classified tissue pathology image to obtain the task prompt T' is the number of classification tasks, D is the dimension of the encoding result obtained by encoding the name of each classification task, is a real number;

[0009] The sub-image patch feature extraction module is used to extract the feature vector of the tissue pathology image to be classified.

[0010] The task relevance learning module is used to Process and obtain the processed features

[0011] The task sharing knowledge representation module is used to represent the feature vector Process and obtain the processed features

[0012] The task prompt module is used to and Obtain task-related knowledge representation X cls , and X cls Split into vectors corresponding to each classification task;

[0013] The task-related knowledge representation module is used to set a classifier for each classification task, each classifier includes a linear layer and a RELU activation function;

[0014] And the vector corresponding to each classification task is input into the corresponding classifier to obtain the prediction result of each classification task.

[0015] Furthermore, the task-related prompt initialization module uses a pre-trained CLIP model for encoding.

[0016] Furthermore, the working process of the sub-image patch feature extraction module is as follows:

[0017] The foreground tissue area of ​​the pathological image to be classified is extracted using the Otsu method, and then the foreground tissue area image is segmented into several sub-image patches using the gridding method;

[0018] The pre-trained ResNet or ViT model is used to encode each sub-image patch into a feature vector, and then the feature vectors corresponding to each sub-image patch are concatenated into a feature vector of the pathological image to be classified. The concatenated feature vector is recorded as N is the number of sub-image patches into which the image is segmented.

[0019] Furthermore, the task relevance learning module includes L t Units, the working process of each unit is:

[0020]

[0021]

[0022]

[0023] Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, is the output of the lth unit, l=0,…,L t -1.

[0024] Furthermore, the multi-head self-attention includes multiple single-head self-attentions, and the calculation method of the multi-head self-attention is:

[0025] For the input of multi-head self-attention Will Project them into the Query, Key, and Value spaces respectively, and perform normalization operations as follows:

[0026]

[0027]

[0028] Among them, K is the projection and normalization result of the Key space, V is the projection and normalization result of the Value space, and Q is the projection and normalization result of the Query space;

[0029] Divide K, V and Q into g parts in D dimension respectively, then the dimension d of each part is D / h. For any part K′ of K, the corresponding part of K′ on V is recorded as V′, and the corresponding part of K′ on Q is recorded as Q′. Perform single-head self-attention calculation on K′, V′ and Q′ to obtain the attention weight:

[0030]

[0031] Among them, A′ is the attention weight, K′ T is the transpose of K′, Q′K′ T Q′ and K′ T The dot product between them, Softmax(·) is the Softmax function;

[0032] Then calculate according to A′

[0033]

[0034] in, It is the feature corresponding to the K′, V′, and Q′ parts;

[0035] Similarly, each segmented part is processed separately, and the features of each processed part are merged to obtain the D-dimensional feature

[0036] Furthermore, the task sharing knowledge representation module includes L p Units, the working process of each unit is:

[0037]

[0038]

[0039]

[0040] Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, is the output of the lth unit, l=0,…,L p -1.

[0041] Furthermore, the working process of the task prompt module is as follows:

[0042]

[0043]

[0044]

[0045] Among them, MCA is multi-head cross attention, LN is layer normalization, and MLP is linear layer;

[0046] Then Decompose it into vectors corresponding to each classification task, and record the vector corresponding to the jth classification task as

[0047] Furthermore, the multi-head cross attention includes h single-head cross attentions, and the calculation method of the multi-head cross attention is:

[0048] Will Projected into the Query space, Project it into the Key and Value space and perform normalization as follows:

[0049]

[0050]

[0051]

[0052] Among them, K is the projection and normalization result of the Key space, V is the projection and normalization result of the Value space, and Q is the projection and normalization result of the Query space;

[0053] Divide K, V and Q into h parts in D dimension respectively, then the dimension d of each part is D / h. For any part K″ of K, the corresponding part of K″ on V is recorded as V″, and the corresponding part of K″ on Q is recorded as Q″. Perform single-head cross attention calculation on K″, V″ and Q″ to obtain the attention weight:

[0054]

[0055] Among them, A″ is the attention weight, K″ T is the transpose of K″, Q″K″ T For Q″ and K″ T The dot product between them, Softmax(·) is the Softmax function;

[0056] Then calculate according to A″

[0057]

[0058] in, are the features corresponding to K″, V″, and Q″;

[0059] Similarly, each segmented part is processed separately, and the features of each processed part are merged to obtain the D-dimensional feature

[0060] Furthermore, the working process of the task-related knowledge representation module is as follows:

[0061] Classification by classifier:

[0062]

[0063] Among them, RELU is the activation function, MLP is the linear layer, is the prediction result of the j-th classification task.

[0064] Furthermore, the training process of the multi-task classification system for histopathological images is as follows:

[0065] Collect a tissue pathology sample image dataset, each of which contains T′ class task labels;

[0066] For any tissue pathology sample image, the jth classification task label of the sample image is denoted as y (j) , j = 1, ..., T ′; label y (j) One-hot encoding corresponding to the actual category of the j-th classification task;

[0067] The collected tissue pathology sample image dataset is divided into training set D train , validation set D valid and the test set D test Three parts:

[0068]

[0069]

[0070]

[0071] Among them, M train 、M valid and M test are the number of sample images in the training set, validation set, and test set respectively; x i is the i-th sample image in the training set, are the first, second, and T'th classification task labels of the i-th sample image in the training set; x i’ is the i'th sample image in the validation set, are the first, second, and T'th classification task labels of the i'th sample image in the validation set; x i” is the i'th sample image in the test set, They are the 1st, 2nd, and T'th classification task labels of the i'th sample image in the test set;

[0072] Using the training set D train The system is trained iteratively and at the end of each epoch, the validation set D valid The total loss function value is calculated on the validation set D until the maximum epoch is reached or the validation set D validStop training when the total loss function value on stops decreasing;

[0073] In the test set D test Test the system on

[0074] The total loss function value is:

[0075]

[0076] Among them, L j is the prediction of the jth classification task and the true label y (j) The loss between j is the weight of the loss of the j-th classification task;

[0077]

[0078] in, is the probability that the i'th sample belongs to the kth category in the jth classification task, C is the number of categories in the jth classification task, is the predicted probability corresponding to the true category of the i'th sample in the jth classification task, exp(x) is the exponential function of x, and M is the size of the dataset.

[0079] The beneficial effects of the present invention are:

[0080] The present invention is based on prompt learning and solves the problem that existing methods ignore the modeling of inter-task correlation. By designing task-specific prompts for each task and introducing a task correlation learning module, the potential correlation between various tasks can be explicitly identified and utilized. In addition, the present invention comprehensively fine-tunes the entire neural network model during training. This strategy not only significantly improves its computational efficiency and performance relative to the single-task model, but also enhances the model's adaptability to a variety of different tasks, thereby improving the performance of the method of the present invention in multi-task classification of tissue pathology images. The present invention can solve the limitations of existing multi-task learning methods in processing complex tissue pathology images and has a wider application potential. BRIEF DESCRIPTION OF THE DRAWINGS

[0081] Figure 1 This is an architecture diagram of a multi-task classification system for tissue pathology images based on prompt learning of the present invention. DETAILED DESCRIPTION

[0082] Specific implementation method 1. Combination Figure 1The present embodiment is described as a multi-task classification system for pathological images based on prompt learning, the system comprising an image acquisition module, a task-related prompt initialization module, a sub-image patch feature extraction module, a task-related learning module, a task-shared knowledge representation module, a task prompt module and a task-related knowledge representation module, wherein:

[0083] The image acquisition module is used to acquire the tissue pathology image to be classified;

[0084] The task-related prompt initialization module is used to encode the name of each classification task of the classified tissue pathology image to obtain the task prompt T' is the number of classification tasks, D is the dimension of the encoding result obtained by encoding the name of each classification task, is a real number;

[0085] The sub-image patch feature extraction module is used to extract the feature vector of the tissue pathology image to be classified.

[0086] The task relevance learning module is used to Process and obtain the processed features

[0087] The task sharing knowledge representation module is used to represent the feature vector Process and obtain the processed features

[0088] The task prompt module is used to and Obtain task-related knowledge representation X cls , and X cls Split into vectors corresponding to each classification task;

[0089] The task-related knowledge representation module is used to set a classifier for each classification task, each classifier includes a linear layer and a RELU activation function;

[0090] And the vector corresponding to each classification task is input into the corresponding classifier to obtain the prediction result of each classification task.

[0091] Specific implementation method 2: This implementation method is different from specific implementation method 1 in that the task-related prompt initialization module uses a pre-trained CLIP model for encoding.

[0092] The task-related prompt initialization module can use random initialization or other initialization methods, such as Xavier initialization, Kaiming initialization, etc.

[0093] The other steps and parameters are the same as those in the first embodiment.

[0094] Specific implementation method three: This implementation method is different from specific implementation methods one or two in that the working process of the sub-image patch feature extraction module is as follows:

[0095] The foreground tissue area of ​​the pathological image to be classified is extracted using the Otsu method, and then the foreground tissue area image is segmented into several sub-image patches by the gridding method (gridding refers to dividing the foreground tissue area in the slice into small image blocks with a certain step length and size);

[0096] A pre-trained ResNet or ViT model (pre-trained using histopathological images and contrastive learning methods) is used to encode each sub-image patch into a high-dimensional feature vector, and then the high-dimensional feature vectors corresponding to each sub-image patch are concatenated into a feature vector of the histopathological image to be classified (by concatenating in 0 dimension). The concatenated feature vector is recorded as N is the number of sub-image patches into which the image is segmented.

[0097] The other steps and parameters are the same as those in the first or second embodiment.

[0098] Specific implementation method 4: This implementation method is different from any one of the specific implementation methods 1 to 3 in that the task relevance learning module includes L t Units, the working process of each unit is:

[0099]

[0100]

[0101]

[0102] Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, is the output of the lth unit, l=0,…,L t -1.

[0103] The other steps and parameters are the same as those in Specific Embodiments 1 to 3.

[0104] Specific implementation method five: This implementation method is different from any one of the specific implementation methods one to four in that the multi-head self-attention (MSA) includes multiple single-head self-attentions (SSA), and the calculation method of the multi-head self-attention is:

[0105] For the input of multi-head self-attention Will They are projected into the Query (Q), Key (K) and Value (V) spaces respectively, and normalized using LayerNorm as follows:

[0106]

[0107]

[0108]

[0109] Among them, K is the projection of the Key space and the normalized result, V is the projection and normalization result of the Value space. Q is the projection of the query space and the normalized result.

[0110] Divide K, V and Q into h parts in D dimension respectively, then the dimension d of each part is D / h. For any part K′ of K, The corresponding part of K′ on V is denoted as V′. The corresponding part of K′ on Q is recorded as Q′. Perform single-head self-attention calculation on K′, V′ and Q′ to obtain the attention weights:

[0111]

[0112] Among them, A′ is the attention weight, K′ T is the transpose of K′, Q′K′ T Q′ and K′ T The dot product between , Softmax(·) is the Softmax function;

[0113] Then calculate according to A′

[0114]

[0115] in, It is the feature corresponding to the K′, V′, and Q′ parts;

[0116] Similarly, each segmented part is processed separately, and the features of each processed part are merged to obtain the D-dimensional feature

[0117] The other steps and parameters are the same as those in Specific Embodiments 1 to 4.

[0118] After K, V and Q are divided into h parts in D dimension respectively, single-head self-attention calculation is performed on the first part of K, the first part of V and the first part of Q. Similarly, after single-head self-attention calculation is performed on the h-th part of K, the h-th part of V and the h-th part of Q, the results of each single-head self-attention calculation are merged to obtain the D-dimensional feature

[0119] Specific implementation method 6: This implementation method is different from any one of the specific implementation methods 1 to 5 in that the task sharing knowledge representation module includes L p Units, the working process of each unit is:

[0120]

[0121]

[0122]

[0123] Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, is the output of the lth unit, l=0,…,L p -1.

[0124] The other steps and parameters are the same as those in Specific Implementation Methods 1 to 5.

[0125] Specific implementation method 7: This implementation method is different from the specific implementation methods 1 to 6 in that the working process of the task prompt module is as follows:

[0126]

[0127]

[0128]

[0129] Among them, MCA is multi-head cross attention, LN is layer normalization, and MLP is linear layer;

[0130] Then Decompose it into vectors corresponding to each classification task, and record the vector corresponding to the jth classification task as

[0131] The other steps and parameters are the same as those in Specific Embodiments 1 to 6.

[0132] Specific implementation eight: This implementation is different from any one of the specific implementations one to seven in that the multi-head cross-attention (MCA) includes h single-head cross-attentions (SCA), and the calculation method of the multi-head cross-attention is:

[0133] Will Projected into the Query (Q) space, Project it into the Key (K) and Value (V) space and use LayerNorm to normalize it as follows:

[0134]

[0135]

[0136]

[0137] Among them, K is the projection of the Key space and the normalized result, V is the projection and normalization result of the Value space. Q is the projection of the query space and the normalized result. Divide K, V and Q into h parts in D dimension respectively, then the dimension d of each part is D / h. For any part K″ of K, The part of K″ on V is denoted as V″. The corresponding part of K″ on Q is recorded as Q″. Perform single-head cross attention calculation on K″, V″ and Q″ to obtain the attention weights:

[0138]

[0139] Among them, A″ is the attention weight, K″ T is the transpose of K″, Q″K″ T For Q″ and K″ T The dot product between them, Softmax(·) is the Softmax function;

[0140] Then calculate according to A″

[0141]

[0142] in, are the features corresponding to K″, V″, and Q″;

[0143] Similarly, each segmented part is processed separately, and the features of each processed part are merged to obtain the D-dimensional feature

[0144] The other steps and parameters are the same as those in Specific Embodiments 1 to 7.

[0145] After K″, V″ and Q″ are divided into h parts in D dimension respectively, single-head cross attention calculation is performed on the first part of K″, the first part of V″ and the first part of Q″. Similarly, after single-head cross attention calculation is performed on the h-th part of K″, the h-th part of V″ and the h-th part of Q″, the results of each single-head cross attention calculation are merged to obtain the D-dimensional feature

[0146] Specific implementation method 9: This implementation method is different from specific implementation methods 1 to 8 in that the working process of the task-related knowledge representation module is as follows:

[0147] Classification by classifier:

[0148]

[0149] Among them, RELU is the activation function, MLP is the linear layer, the input and output feature dimensions of the first linear layer are D, the second output feature dimension is D, and the output dimension is the classification category C of the j-th classification task (j) , is the prediction result of the j-th classification task.

[0150] The other steps and parameters are the same as those in Specific Embodiments 1 to 8.

[0151] Specific implementation example ten: This implementation example is different from any one of specific implementation examples one to nine in that the training process of the multi-task classification system for tissue pathology images is as follows:

[0152] Collect a tissue pathology sample image dataset, each of which contains T′ class task labels;

[0153] For any tissue pathology sample image, the jth classification task label of the sample image is denoted as y (j) , j = 1, ..., T ′; label y (j) One-hot encoding corresponding to the actual category of the j-th classification task;

[0154] The collected tissue pathology sample image dataset is divided into training set D train , validation set D valid and the test set D test Three parts:

[0155]

[0156]

[0157]

[0158] Among them, M train 、M valid and M test are the number of sample images in the training set, validation set, and test set respectively; x i is the i-th sample image in the training set, are the first, second, and T'th classification task labels of the i-th sample image in the training set; x i’ is the i'th sample image in the validation set, are the first, second, and T'th classification task labels of the i'th sample image in the validation set; x i” is the i'th sample image in the test set, They are the 1st, 2nd, and T'th classification task labels of the i'th sample image in the test set;

[0159] Using the training set D train The system is trained iteratively and at the end of each epoch, the validation set D valid The total loss function value is calculated on the validation set D until the maximum epoch is reached or the validation set D valid Stop training when the total loss function value on stops decreasing;

[0160] In the test set D test Test the system on

[0161] The total loss function value is:

[0162]

[0163] Among them, L j is the prediction of the jth classification task and the true label y (j) The loss between j is the weight of the loss of the j-th classification task;

[0164]

[0165] in, is the probability that the i'th sample belongs to the kth category in the jth classification task, C is the number of categories in the jth classification task, is the predicted probability corresponding to the true category of the i'th sample in the jth classification task, exp(x) is the exponential function of x, and M is the size of the dataset.

[0166] The other steps and parameters are the same as those in Specific Embodiments 1 to 9.

[0167] Example

[0168] This example uses a TCGA Uterine Corpus Endometrial Carcinoma dataset, which includes three classification tasks: tumor type classification, molecular subtype classification, and microsatellite instability classification, with 4, 2, and 2 classification categories respectively.

[0169] Combination Figure 1 This embodiment is described. This embodiment is a multi-task classification system for pathological images based on prompt learning, which includes a task-related prompt initialization module, a sub-image patch feature extraction module, a task-related learning module, a task-shared knowledge representation module, a task prompt module, and a task-related knowledge representation module:

[0170] The task-related prompt initialization module is connected to the task-related learning module, the sub-image patch feature extraction module is connected to the task-shared knowledge representation module, the task prompt module is connected to the task-related learning module and the task-shared knowledge representation module, and the task-related knowledge representation module is connected to the task prompt module;

[0171] a) a task-related prompt initialization module, which is used to initialize each task-related prompt into a feature vector and input these feature vectors into the task-related learning module;

[0172] b) a sub-image patch feature extraction module, which is used to extract features of the tissue pathology image sub-image and input these feature vectors into the task sharing knowledge representation module;

[0173] c) a task relevance learning module, which is used to learn the correlation between various tasks. The output of the task relevance learning module will be used as part of the input of the task prompt module; and is used to receive the gradient returned by the task prompt module;

[0174] d) a task-shared knowledge representation module, which is used to learn the shared knowledge representation of each task. The output of the task-shared knowledge representation module will be used as another part of the input of the task prompt module; and is used to receive the gradient returned by the task prompt module;

[0175] e) Task prompt module, used to generate task-related prompts based on task prompts and task shared knowledge representation. This module adopts a cross-attention mechanism, where the task prompt is used as the query, the shared knowledge representation is used as the key and value, and the output is the task-related knowledge representation; and is used to receive the gradient returned by the task-related knowledge representation module.

[0176] f) Task-related knowledge representation module, which is used to classify specific tasks based on task-related knowledge representation. This module consists of multiple independent classification modules, and the output of each classification module is the classification prediction result of the task; and is used to receive the gradient returned by the loss function.

[0177] The following is a detailed description:

[0178] The task-related prompt initialization module uses the Text Encoder of the pre-trained CLIP model to encode the English names of each classification task to obtain the task feature vector. The English names of the three tasks are: Tumor Type Classification, Molecular Subtype Classification, and MSI Status Detection.

[0179] The sub-image patch feature extraction module first uses the Otsu method to extract the foreground tissue area of ​​the histopathology image, then divides the histopathology image into small sub-image patches, and then uses the CTransPath model (a fusion CNN and Transformer model pre-trained using contrastive learning) to encode each sub-image patch into a feature vector;

[0180] Both the task relevance learning module and the task shared knowledge representation module adopt a two-layer multi-head self-attention mechanism, with the inputs being Key, Query, and Value, and the output being features of the same dimension;

[0181] The task prompt module adopts a 1-layer multi-head cross attention mechanism and its variants. The task prompt is used as the query in the input, the shared knowledge representation is used as the key and value, and the output is the features of the same dimension as the task prompt.

[0182] The task-related knowledge representation module sets a separate classification module for each classification task. Each module consists of 1 linear layer, a RELU activation function and 1 linear layer.

[0183] The classification training method of this embodiment includes the following steps:

[0184] S1. Collect a multi-task tissue pathology image dataset, where each sample contains 3 task labels, and each input tissue pathology image x corresponds to 3 task labels y (j), j = 1, 2, 3;

[0185] S2. Divide the data into training set, validation set and test set:

[0186]

[0187]

[0188]

[0189] Among them, M train 、M valid and M test are the number of images in the training set, validation set, and test set, respectively, and each task label y (j) They are all one-hot codes corresponding to the classification category C of task j;

[0190] S3, each tissue pathology section x i Preprocess and extract features with a feature dimension of 1024 to obtain image features The number of sub-images N obtained for each tissue pathology section is different;

[0191] S4. Use the pre-trained CLIP model’s Text Encoder to encode the name of each task, with an encoding feature dimension of 1024, to obtain task prompts.

[0192] S5. Knowledge representation of computing tasks:

[0193]

[0194]

[0195]

[0196] Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, l=0,1 is the number of layers of this module;

[0197] S6. Perform task-related learning:

[0198]

[0199]

[0200]

[0201] Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, l=0,1 is the number of layers of this module;

[0202] S7. Use multi-head cross attention to obtain task-related knowledge representation based on task prompts:

[0203]

[0204]

[0205]

[0206] Among them, MCA is multi-head cross attention, LN is layer normalization, and MLP is linear layer;

[0207] S8. Decomposed into 3 task-related vectors And each task related vector Enter its task-related classification module for classification:

[0208]

[0209] Among them, RELU is the activation function, MLP is the linear layer, the input and output feature dimensions of the first linear layer are both 1024, the output feature dimension of the second linear layer is 1024, and the output dimension is the classification category C of the task (j) (4, 2, 2 respectively), is the prediction result of the jth task;

[0210] S9. Calculate the prediction for each task j and the true label y (j) The loss between j , and calculate the total loss:

[0211]

[0212] The loss weight ω for each task j Both

[0213] S10, in D train The model is trained iteratively from S3 to S9, and at the end of each epoch, the D valid Calculate the loss for each validation set sample data according to S3 to S9. If the validation set loss does not decrease within the specified 10 epochs or reaches 100 epochs, stop training.

[0214] Step S11: test The model is tested according to S3 to S9.

[0215] In this embodiment, the multi-head self-attention (MSA) in steps S5 and S6 is composed of multiple single-head self-attention (SSA), and the calculation method of single-head cross attention SSA is:

[0216] Q = MLP(LN(X))

[0217] K=MLP(LN(X))

[0218] V=MLP(LN(S))

[0219]

[0220] S′=AV

[0221] Where X is or When calculating the multi-head cross attention mechanism, it is necessary to divide the 1024 of dimension 1 into 8 parts, that is, each head is 128 dimensions, perform the above single-head cross attention calculations separately, and finally merge back to 1024 on dimension 1.

[0222] In this embodiment, the multi-head cross-attention (MCA) in step S7 is composed of multiple single-head cross-attention (SCA), and the calculation method of the single-head cross-attention SCA is:

[0223]

[0224]

[0225]

[0226]

[0227] X cls =AV

[0228] in For L t The output of the layer task-related learning module, For L p The output of the layer-task shared knowledge representation module, when calculating the multi-head cross attention mechanism, it is necessary to divide the 1024 of dimension 1 into 8 parts, that is, each head is 128 dimensions, and perform the above single-head cross attention calculations separately, and finally merge back to 1024 on dimension 1.

[0229] In this embodiment, the loss function in step S9 adopts the following cross entropy loss function:

[0230]

[0231] in, is the probability that the i'th sample belongs to the kth category in the jth classification task, C is the number of categories in the jth classification task, is the predicted probability corresponding to the true category of the i'th sample in the jth classification task, exp(x) is the exponential function of x, and M is the size of the dataset.

[0232] The above calculation examples of the present invention are only used to explain the calculation model and calculation process of the present invention in detail, and are not intended to limit the implementation methods of the present invention. For ordinary technicians in the relevant field, other different forms of changes or modifications can be made based on the above description. It is impossible to list all the implementation methods here. All obvious changes or modifications derived from the technical solution of the present invention are still within the scope of protection of the present invention.

Claims

1. A multi-task classification system for histopathological images based on prompt learning, characterized in that: The system includes an image acquisition module, a task-related prompt initialization module, a sub-image patch feature extraction module, a task-related learning module, a task-shared knowledge representation module, a task prompt module and a task-related knowledge representation module, wherein: The image acquisition module is used to acquire the tissue pathology image to be classified; The task-related prompt initialization module is used to encode the name of each classification task of the classified tissue pathology image to obtain the task prompt T' is the number of classification tasks, D is the dimension of the encoding result obtained by encoding the name of each classification task, is a real number; The sub-image patch feature extraction module is used to extract the feature vector of the tissue pathology image to be classified. N is the number of sub-image patches into which the image is segmented; The task relevance learning module is used to Process and obtain the processed features The task relevance learning module includes L t Units, the working process of each unit is: Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, is the output of the lth unit, l=0,…,L t -1; The task sharing knowledge representation module is used to represent the feature vector Process and obtain the processed features The task sharing knowledge representation module includes L p Units, the working process of each unit is: Among them, MSA is multi-head self-attention, LN is layer normalization, MLP is linear layer, is the output of the lth unit, l=0,…,L p -1; The task prompt module is used to and Obtain task-related knowledge representation X cls , and X cls Split into vectors corresponding to each classification task; The task-related knowledge representation module is used to set a classifier for each classification task, each classifier includes a linear layer and a RELU activation function; And the vector corresponding to each classification task is input into the corresponding classifier to obtain the prediction result of each classification task.

2. The multi-task classification system for pathological images based on prompt learning according to claim 1, characterized in that: The task-related prompt initialization module uses a pre-trained CLIP model for encoding.

3. The multi-task classification system for pathological images based on prompt learning according to claim 1, characterized in that: The working process of the sub-image patch feature extraction module is as follows: The foreground tissue area of ​​the pathological image to be classified is extracted using the Otsu method, and then the foreground tissue area image is segmented into several sub-image patches using the gridding method; The pre-trained ResNet or ViT model is used to encode each sub-image patch into a feature vector, and then the feature vectors corresponding to each sub-image patch are concatenated into a feature vector of the pathological image to be classified. The concatenated feature vector is recorded as N is the number of sub-image patches into which the image is segmented.

4. The multi-task classification system for pathological images based on prompt learning according to claim 1, characterized in that: The multi-head self-attention includes multiple single-head self-attentions, and the calculation method of the multi-head self-attention is: For the input of multi-head self-attention Will Project them into the Query, Key, and Value spaces respectively, and perform normalization operations as follows: Among them, K is the projection and normalization result of the Key space, V is the projection and normalization result of the Value space, and Q is the projection and normalization result of the Query space; Divide K, V and Q into h parts in D dimension respectively, then the dimension d of each part is D / h. For any part K′ of K, the corresponding part of K′ on V is recorded as V′, and the corresponding part of K′ on Q is recorded as Q′. Perform single-head self-attention calculation on K′, V′ and Q′ to obtain the attention weight: Among them, A′ is the attention weight, K′ T is the transpose of K′, Q′K′ T Q′ and K′ T The dot product between , Softmax(·) is the Softmax function; Then calculate according to A′ in, It is the feature corresponding to the K′, V′, and Q′ parts; Similarly, each segmented part is processed separately, and the features of each processed part are merged to obtain the D-dimensional feature 5. The multi-task classification system for pathological images based on prompt learning according to claim 1, characterized in that: The working process of the task prompt module is as follows: Among them, MCA is multi-head cross attention, LN is layer normalization, and MLP is linear layer; Then Decompose it into vectors corresponding to each classification task, and record the vector corresponding to the jth classification task as 6. The multi-task classification system for pathological images based on prompt learning according to claim 5, characterized in that: The multi-head cross attention includes h single-head cross attentions, and the calculation method of the multi-head cross attention is: Will Projected into the Query space, Project it into the Key and Value space and perform normalization as follows: Among them, K is the projection and normalization result of the Key space, V is the projection and normalization result of the Value space, and Q is the projection and normalization result of the Query space; Divide K, V and Q into h parts in D dimension respectively, then the dimension d of each part is D / h. For any part K″ of K, the corresponding part of K″ on V is recorded as V″, and the corresponding part of K″ on Q is recorded as Q″. Perform single-head cross attention calculation on K″, V″ and Q″ to obtain the attention weight: Among them, A″ is the attention weight, K″ T is the transpose of K″, Q″K″ T For Q″ and K″ T The dot product between , Softmax(·) is the Softmax function; Then calculate according to A″ in, are the features corresponding to K″, V″, and Q″; Similarly, each segmented part is processed separately, and the features of each processed part are merged to obtain the D-dimensional feature 7. The multi-task classification system for pathological images based on prompt learning according to claim 6, characterized in that: The working process of the task-related knowledge representation module is as follows: Classification by classifier: Among them, RELU is the activation function, MLP is the linear layer, is the prediction result of the j-th classification task.

8. The multi-task classification system for pathological images based on prompt learning according to claim 1, characterized in that: The training process of the multi-task classification system for histopathological images is as follows: Collect a tissue pathology sample image dataset, each of which contains T′ class task labels; For any tissue pathology sample image, the jth classification task label of the sample image is denoted as y (j) , j = 1, ..., T ′; label y (j) One-hot encoding corresponding to the actual category of the j-th classification task; The collected tissue pathology sample image dataset is divided into training set D train , validation set D valid and the test set D test Three parts: Among them, M train 、M valid and M test are the number of sample images in the training set, validation set, and test set respectively; x i is the i-th sample image in the training set, are the first, second, and T'th classification task labels of the i-th sample image in the training set; x i’ is the i'th sample image in the validation set, are the first, second, and T'th classification task labels of the i'th sample image in the validation set; x i” is the i'th sample image in the test set, They are the 1st, 2nd, and T'th classification task labels of the i'th sample image in the test set; Using the training set D train The system is trained iteratively and at the end of each epoch, the validation set D valid The total loss function value is calculated on the validation set D until the maximum epoch is reached or the validation set D valid Stop training when the total loss function value on stops decreasing; In the test set D test Test the system on The total loss function value is: Among them, L j is the prediction of the jth classification task and the true label y (j) The loss between j is the weight of the loss of the j-th classification task; in, is the probability that the i'th sample belongs to the kth category in the jth classification task, C is the number of categories in the jth classification task, is the predicted probability corresponding to the true category of the i'th sample in the jth classification task, exp(x) is the exponential function of x, and M is the size of the dataset.