Universal multi-class cell detection method and device based on prompt learning

Through a hint-based learning method, the data set name and category name are used as hints to guide the model to iteratively train and generate multi-scale enhanced hint features, which solves the problem of unifying different cytopathological image data sets and improves the accuracy of cell detection and classification. and model training efficiency.

CN117854066BActive Publication Date: 2024-09-10SHENZHEN RES INST OF BIG DATA
View PDF 0 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing technology is difficult to effectively unify different cytopathological image data sets, resulting in low accuracy of cell detection models in detection and classification, low transfer learning efficiency, and large model capacity.

Method used

Adopting a method based on hint learning, by acquiring multiple cytopathological image data sets, and using the names of the data sets and category names as hints, the model is guided to iterative training, multi-scale enhanced hint features are generated, and the self-attention mechanism is combined for classification detection. Reduce the amount of calculation and increase the speed of network fitting.

Benefits of technology

It achieves the unification of multiple different data sets, improves the accuracy of cell detection and classification, and improves model training efficiency, which is better than the detection and classification effects of traditional methods on multiple data sets.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117854066B
    Figure CN117854066B
Patent Text Reader

Abstract

The present invention discloses a general multi-class cell detection method and device based on prompt learning, and the method includes: obtaining multiple cytopathology image data sets each including a number of cytopathology images with real labels, and preprocessing each cytopathology image respectively, the cytopathology image data set including a data set name and a category name; inputting the preprocessed cytopathology image, data set name and category name into the original cell detection classification model, using the data set name and category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cytopathology image; when the training result meets the preset convergence condition, a trained target cell detection classification model is obtained, so as to detect and classify the cytopathology image to be detected through the target cell detection classification model. The present application adopts a dynamic prompt method to merge different data sets and improve the model prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of cell detection and classification, and in particular to a universal multi-category cell detection method, device, computer equipment and storage medium based on prompt learning. Background Art

[0002] With the development of medical technology, the identification of various types of cells in pathological slice images plays an important role in medical treatment. Therefore, various cell detection models have been widely used because they can classify and detect cell pathology images.

[0003] However, the cell detection model needs to be trained with a large amount of sample data. Different public pathology image datasets contain different categories. Some datasets have 3 major categories, some datasets are further divided into 6 minor categories, and some datasets have several additional categories. Therefore, it is impossible to simply combine them together to train a cell detection model. This affects the accuracy of the cell detection model in detecting and classifying cell pathology images.

[0004] To solve the above problems, currently, the categories in different data sets are usually treated as different categories, but this method does not consider the inclusion relationship between categories; or transfer learning is adopted to migrate the model trained on one data set to the new data set for retraining, but this method requires multiple repeated training and is inefficient; or multiple different encoders are used to learn different data sets, but this method will bring a large number of additional parameters and make the model capacity larger. Therefore, how to unify the data of multiple data sets to improve the accuracy of cell detection and classification in pathological images has become an urgent problem to be solved. Summary of the invention

[0005] Based on this, it is necessary to provide a universal multi-type cell detection method, device, computer equipment and storage medium based on prompt learning to address the above technical problems, so as to solve at least one problem existing in the above-mentioned prior art.

[0006] In a first aspect, the embodiment of the present application is implemented by providing a general multi-type cell detection method based on prompt learning, comprising the following steps:

[0007] Acquire multiple cytopathology image data sets each including a plurality of cytopathology images with real labels, and preprocess each of the cytopathology images, wherein the cytopathology image data sets include a data set name and a category name;

[0008] Inputting the preprocessed cell pathology image, the data set name, and the category name into the original cell detection classification model, and using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image;

[0009] When the training result meets the preset convergence condition, a trained target cell detection and classification model is obtained, so as to detect and classify the cell pathology image to be detected through the target cell detection and classification model.

[0010] In one embodiment, the preprocessed cell pathology image, the data set name, and the category name are input into the original cell detection classification model, and the data set name and the category name are used as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image, including:

[0011] Based on the preprocessed cell pathology image, the data set name, and the category name, a multi-scale enhanced prompt feature is obtained;

[0012] Inputting the multi-scale enhanced prompt feature into the first stage detection and classification head in the original cell detection and classification model for classification and detection to obtain a first classification detection result;

[0013] Based on the first classification detection result and the multi-scale enhancement prompt feature, a decoding candidate vector is obtained, and the decoding candidate vector is input into the second stage detection classification head in the original cell detection classification model for classification processing to obtain a second classification detection result;

[0014] A loss value is calculated based on the second classification detection result and the true label, and the original cell detection classification model is iteratively trained using the loss value.

[0015] In one embodiment, the multi-scale enhanced prompt feature is obtained based on the pre-processed cell pathology image, the data set name and the category name, including:

[0016] Extracting features from the preprocessed cell pathology image, and encoding the extracted features to obtain multi-scale feature encoding;

[0017] The data set name and the category name are processed respectively according to preset processing rules to obtain a data set prompt and a category prompt;

[0018] Based on the multi-scale feature encoding, the data set prompt and the category prompt, a multi-scale enhanced prompt feature is obtained.

[0019] In one embodiment, the processing of the data set name and the category name according to a preset processing rule to obtain a data set prompt and a category prompt includes:

[0020] Performing byte pair encoding processing on the data set name and the category name respectively to obtain a data set name vector and a category vector;

[0021] Adding preset learnable parameters to the data set name vector and the category vector respectively to obtain a data set text sequence and a category text sequence;

[0022] The data set text sequence and the category text sequence are respectively segmented to obtain data set prompts and category prompts.

[0023] In one embodiment, obtaining a multi-scale enhanced hint feature based on the multi-scale feature encoding, the data set hint, and the category hint includes:

[0024] The data set prompt is used as a first query matrix, the category prompt is used as a first key value matrix and a first value matrix, and is input into a first self-attention module for attention calculation to obtain a data set and category combination prompt;

[0025] The data set is concatenated with the category combination prompt and the category prompt as a second key value matrix and a second value matrix, the multi-scale encoding feature is used as a second query matrix, and is input into a second self-attention module for attention calculation to obtain the multi-scale enhanced prompt feature.

[0026] In one embodiment, the data set prompt is used as a first query matrix, the category prompt is used as a first key value matrix and a first value matrix, and is input into a first self-attention module for attention calculation to obtain a data set and category combination prompt, including:

[0027] Create an attention mask that masks the categories outside the current cytopathology image dataset;

[0028] A self-attention calculation is performed based on the attention mask, the first query matrix, the first key-value matrix, and the first value matrix to obtain the dataset and category combination prompt.

[0029] In one embodiment, the step of extracting features from the preprocessed cell pathology image and encoding the extracted features to obtain multi-scale feature encoding includes:

[0030] Inputting the preprocessed cell pathology image into the feature extraction backbone network in the original cell detection and classification model to perform multi-stage feature extraction to obtain multi-scale features;

[0031] The multi-scale features are input into the feature encoding network in the primitive cell detection and classification model for encoding to obtain the multi-scale feature encoding.

[0032] In one embodiment, obtaining a decoding candidate vector based on the first classification detection result and the multi-scale enhancement hint feature includes:

[0033] Position encoding is performed on the detection classification results whose confidence is greater than a preset threshold in the first classification detection results, and the results are added to the learnable vector generated by random initialization to form a third query matrix;

[0034] Using the multi-scale enhanced prompt features as a third key value matrix and a third value matrix;

[0035] The third query matrix, the third key-value matrix, and the third value matrix are input into the feature decoding network of the original cell detection and classification model to calculate the cross attention, so as to obtain the decoding candidate vector.

[0036] In a second aspect, a general multi-class cell detection device based on prompt learning is provided, comprising:

[0037] A training data acquisition unit, used to acquire a plurality of cytopathology image data sets each including a plurality of cytopathology images with real labels, and preprocess each of the cytopathology images, wherein the cytopathology image data sets include a data set name and a category name;

[0038] A model training unit, used for inputting the preprocessed cell pathology image, the data set name and the category name into the original cell detection classification model, and using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image;

[0039] The detection and classification unit is used to obtain a trained target cell detection and classification model when the training result meets the preset convergence condition, so as to detect and classify the cell pathology image to be detected through the target cell detection and classification model.

[0040] In a third aspect, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor, wherein when the processor executes the computer-readable instructions, the steps of the general multi-class cell detection method based on prompt learning as described above are implemented.

[0041] In a fourth aspect, a readable storage medium is provided, wherein the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the general multi-class cell detection method based on prompt learning as described above are implemented.

[0042] The above-mentioned general multi-class cell detection method, device, computer equipment and storage medium based on prompt learning, the method is implemented, including: obtaining multiple cytopathology image data sets each including a number of cytopathology images with real labels, and preprocessing each of the cytopathology images respectively, the cytopathology image data set including a data set name and a category name; inputting the preprocessed cytopathology images, the data set name and the category name into the original cell detection classification model, using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cytopathology images; when the training results meet the preset convergence conditions, a trained target cell detection classification model is obtained, so that the cytopathology images to be detected are detected and classified by the target cell detection classification model. In the embodiment of the present application, cell pathology images in multiple different data sets are used as training data, and prompt learning is performed based on the name of each data set and the category name, so that the unification of multiple different data sets can be achieved, and the accuracy of cell detection and classification can be improved. At the same time, in the model training process, some learnable recommendation points are proposed through a deformable attention mechanism. During the calculation, only the features of the recommended point positions are calculated, which can reduce the amount of calculation, increase the network fitting speed, and improve the model training efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0044] Figure 1 is a flow chart for implementing a general multi-type cell detection method based on prompt learning in one embodiment of the present invention;

[0045] Figure 2 is a training flow chart of a primitive cell detection and classification model provided in one embodiment of the present invention;

[0046] Figure 3 is an overall architecture diagram of a dynamic prompt module provided in one embodiment of the present invention;

[0047] Figure 4is a schematic structural diagram of a universal multi-type cell detection device based on prompt learning in one embodiment of the present invention;

[0048] Figure 5 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0050] In one embodiment, if Figure 1 As shown, a general multi-class cell detection method based on prompt learning is provided, comprising the following steps:

[0051] In step S110, a plurality of cytopathology image data sets including a plurality of cytopathology images with real labels are obtained, and each of the cytopathology images is preprocessed respectively, wherein the cytopathology image data sets include a data set name and a category name;

[0052] In an embodiment of the present application, the cytopathology image dataset may include datasets collected from multiple different data sources, for example, CoNSeP, BRCA-M2C, MoNuSAC, Lizard, PanNuke and other datasets, each of which may include different categories. For example, the categories included in the CoNSeP dataset may include inflammation, epithelial, stromal, etc.; the categories included in the BRCA-M2C dataset may include inflammation, epithelial, stromal, etc.; the categories included in the Lizard dataset may include epithelial, lymphatic, etc. The categories in the MoNuSAC dataset may include epithelial, lymphatic, neutrophils, macrophages; and the categories in the PanNuke dataset may include neoplastic, inflammatory, connective, dead, epithelial, etc. It can be seen that different public pathology image datasets contain different categories.

[0053] Among them, CoNSeP, BRCA-M2C, MoNuSAC, Lizard, PanNuke, etc. can be the names of the data sets. Taking CoNSeP as an example, the inflammation (Inflammatory), epithelial (Epithelial), and stroma (Stromal) can be the category names.

[0054] In an embodiment of the present application, preprocessing each cytopathology image may be specifically performed by preprocessing the cytopathology images in each data set after obtaining several cytopathology image data sets of cytopathology images with real labels. Since different data sets provide different coordinate dimensions, such as centroid coordinates and bounding box coordinates, all annotations may be unified through preprocessing. For example, all annotations, such as cell nucleus masks and cell nucleus bounding boxes, may be converted into cell centroid coordinates, thereby reducing interference during the training process.

[0055] The cell pathology image may be annotated in advance by a doctor in terms of cell location and category to form the true label.

[0056] In step S120, the preprocessed cell pathology image, the data set name, and the category name are input into the original cell detection classification model, and the data set name and the category name are used as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image;

[0057] In an embodiment of the present application, the original cell detection and classification model may specifically include a backbone feature extraction network, a feature encoding network, a dynamic prompt module, a detection classification head, and a feature decoding network. Among them, the backbone feature extraction network can use the SwinTransformer-Base model to extract the pre-processed cell pathology image features, or other backbone feature extraction networks that can be used to extract feature vectors can also be used. The feature encoding network may include a multi-layer deformable network layer, and the deformable network layer mainly includes a deformable self-attention mechanism for calculating self-attention. Through the deformable attention mechanism, some learnable recommendation points are proposed. When calculating attention, each feature will only be calculated and learned with the features of the recommended point position, reducing the amount of calculation and improving the network fitting speed. The dynamic prompt module can process the data set name and category name as dynamic learning prompts to guide the model to be trained. The detection and classification head may include a first-stage detection and classification head and a second-stage detection and classification head. The first-stage detection and classification head may classify and detect the multi-scale enhanced prompt features obtained by the dynamic prompt module to obtain a first detection and classification result, and input the multi-scale enhanced prompt features into the feature decoding network together. The feature decoding network also includes multiple layers of deformable network layers. The features obtained after the decoding processing are input into the second-stage detection and classification head for classification processing, thereby obtaining the final detection and classification result.

[0058] In step S130, when the training result meets the preset convergence condition, a trained target cell detection and classification model is obtained, so as to detect and classify the pathological cell image to be detected through the target cell detection and classification model.

[0059] In an embodiment of the present application, after obtaining the detection result output by the second classification detection head, that is, the training result, the loss value can be calculated according to the preset loss function, such as the cross entropy loss function, the logarithmic loss function, etc., based on the real label and the training result. When the loss value reaches a preset threshold, such as 80%, it can be considered that it meets the preset convergence condition, or when the number of training times reaches a preset number of times, such as 100 times, it can be considered that it meets the preset convergence condition, and the trained target cell detection classification model can be obtained. At this time, the actual cell pathology image to be detected can be obtained, and the target cell detection classification model can be used for classification detection to obtain the actual classification detection result.

[0060] In the examples of the present application, a comparison data table of different cell classification detection methods for different data sets and classification detection by this solution is provided, as shown in Table 1 below:

[0061] Table 1: Classification detection results of different data sets using different classification detection methods and different data set merging methods.

[0062]

[0063] Among them, CoNSeP, MoNuSAC, Lizard, and OCELOT represent four datasets, HoverNet, Cellpose, Omnipose, and UperNet ConvNeXt represent different detection methods, and * and + represent different dataset merging schemes. * means training on each dataset separately without merging training sets, and + means merging all datasets and their categories, that is, for example, each dataset has 3 categories, and finally a 12-category classification is performed. UniCell represents this scheme, which can effectively improve the prediction accuracy of the model by merging different datasets using dynamic prompts.

[0064] As can be seen from Table 1 above, this experiment mainly compares two indicators, classification indicators And the detection index F d , detection index F d Refers to the evaluation of predicted cell positions and true cell positions. Specifically, it can be understood as pairing all true cell positions with all predicted cell positions through Hungarian matching, and then first comparing the pairing results. If the distance between the two positions in the pairing is less than a certain range (for example, r = 6 pixels), it is considered to be the correctly predicted cell position result, which is regarded as TP; cells outside these ranges and unpaired cells in the predicted cell results are regarded as over-prediction results, which are regarded as FP; unpaired results in the true cell position are regarded as missing prediction results, that is, FN, then:

[0065] final

[0066] Similarly, only the predictions for each category in the pairing results with correct predictions for all positions are calculated, where the correctly predicted category is considered TP, the predicted category but not actually the category is considered FP, and the predicted category not actually the category is considered FN.

[0067] From the final classification results and detection results obtained by using different merging methods through different detection methods, it can be seen that the classification and detection of different data sets by this scheme can achieve the best results on four data sets (CoNSeP, MoNuSAc, Lizard, OCELOT) compared with other methods, and is superior to other methods in both indicators.

[0068] In an embodiment of the present application, a general multi-class cell detection method based on prompt learning is provided, including: obtaining multiple cytopathology image data sets each including several cytopathology images with real labels, and preprocessing each of the cytopathology images, wherein the cytopathology image data set includes a data set name and a category name; inputting the preprocessed cytopathology image, the data set name and the category name into the original cell detection classification model, using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cytopathology image; when the training result meets the preset convergence condition, a trained target cell detection classification model is obtained, so as to detect and classify the cytopathology image to be detected through the target cell detection classification model. In an embodiment of the present application, by using cytopathology images in multiple different data sets as training data, and performing prompt learning based on the name and category name of each data set, the unification of multiple different data sets can be achieved, and the accuracy of cell detection and classification can be improved. At the same time, in the process of model training, some learnable recommendation points are proposed through a deformable attention mechanism, and only the features of the recommended point positions are calculated during calculation, which can reduce the amount of calculation, improve the network fitting speed, and improve the model training efficiency.

[0069] See also Figure 2 In one embodiment of the present application, the preprocessed cell pathology image, the data set name, and the category name are input into the original cell detection and classification model, and the data set name and the category name are used as prompts to guide the original cell detection and classification model to perform iterative training based on the preprocessed cell pathology image, including:

[0070] Based on the preprocessed cell pathology image, the data set name, and the category name, a multi-scale enhanced prompt feature is obtained;

[0071] Inputting the multi-scale enhanced prompt feature into the first stage detection and classification head in the original cell detection and classification model for classification and detection to obtain a first classification detection result;

[0072] Based on the first classification detection result and the multi-scale enhancement prompt feature, a decoding candidate vector is obtained, and the decoding candidate vector is input into the second stage detection classification head in the original cell detection classification model for classification processing to obtain a second classification detection result;

[0073] A loss value is calculated based on the second classification detection result and the true label, and the original cell detection classification model is iteratively trained using the loss value.

[0074] Specifically, the preprocessed cell pathology image is first input into the backbone feature extraction network of the original cell detection classification model for feature extraction. The backbone feature extraction network may include multiple feature extraction stages, so that multi-scale features can be obtained. After the multi-scale features are encoded by the feature encoding network, multi-scale encoding features can be obtained. Then, the data set name and the category name are processed by the dynamic prompt module to obtain a data set and category combined prompt, and multi-scale enhanced features are obtained after self-attention calculation with the multi-scale encoding features. After the first stage classification detection of the detection classification head, the multi-scale enhanced prompt feature is obtained, and then the decoding candidate vector is obtained after processing by the feature decoding network. After the second stage classification detection of the detection classification head, the classification detection result is obtained. Based on the loss between the classification detection result and the true label, the original cell detection classification model is continuously updated to achieve iterative training. During the training process, the names and categories of different data sets are used as prompts to guide the network for training through the dynamic prompt module. During the training process, the data of the above different data sets can be fully utilized to improve the prediction effect of the final model.

[0075] The backbone feature extraction network may be a SwinTransformer-Base model. The second, third and fourth stage features extracted therefrom and the fifth stage features obtained by convolutionally sampling the fourth stage features and reducing the resolution thereof may all be used as multi-scale features.

[0076] Among them, the feature encoding network can be composed of multiple deformable network layers, such as three layers, four layers, etc. The deformable network layer mainly includes a deformable self-attention mechanism for calculating self-attention, thereby obtaining multi-scale feature encoding.

[0077] Among them, the dynamic prompt module may include multiple self-attention modules, which take the multi-scale feature code, data set name and category name as input, encode the data set name and category name, add learnable parameters, and perform word segmentation operations, and then perform self-attention calculation of the self-attention module again to obtain a prompt combining the data set and category, and then perform self-attention calculation again with the multi-scale feature code to obtain multi-scale enhanced features.

[0078] Among them, the feature decoding network can be composed of multiple deformable network layers, such as three layers, four layers, etc. The deformable network layer mainly includes a deformable self-attention mechanism for calculating the cross-self-attention of multi-scale enhanced features and the first-stage classification results to obtain candidate feature vectors.

[0079] Among them, the detection and classification head can include a first-stage detection and classification head and a second-stage detection and classification head respectively. The first-stage detection and classification head can be used to detect and classify the multi-scale enhanced features, and the second-stage detection and classification head can classify and detect the candidate feature vector to obtain the final detection result.

[0080] In one embodiment of the present application, the multi-scale enhanced prompt feature is obtained based on the pre-processed cell pathology image, the data set name and the category name, including:

[0081] Extracting features from the preprocessed cell pathology image, and encoding the extracted features to obtain multi-scale feature encoding;

[0082] The data set name and the category name are processed respectively according to preset processing rules to obtain a data set prompt and a category prompt;

[0083] Based on the multi-scale feature encoding, the data set prompt and the category prompt, a multi-scale enhanced prompt feature is obtained.

[0084] Specifically, the preprocessed cell pathology image is first input into the backbone feature extraction network of the original cell detection classification model for feature extraction. The backbone feature extraction network may include multiple feature extraction stages, so that multi-scale features can be obtained. After the multi-scale features are encoded by the feature encoding network, multi-scale encoding features can be obtained. The multi-scale encoding features and the data set name and category name are input into the dynamic prompt module. After the data set name and category name are processed by the dynamic prompt module, a data set and category combination prompt can be obtained. Then, the data set and category combination prompt can be spliced ​​with the category prompt and input into the new self-attention module as a key value matrix and a value matrix, and the input multi-scale encoding features are input into the new self-attention module as a query matrix for self-attention operation, and finally a multi-scale enhanced feature is obtained.

[0085] In an embodiment of the present application, the data set name and the category name are processed according to a preset processing rule to obtain a data set prompt and a category prompt, including:

[0086] Performing byte pair encoding processing on the data set name and the category name respectively to obtain a data set name vector and a category vector;

[0087] Adding preset learnable parameters to the data set name vector and the category vector respectively to obtain a data set text sequence and a category text sequence;

[0088] The data set text sequence and the category text sequence are respectively segmented to obtain data set prompts and category prompts.

[0089] Specifically, see Figure 3 The overall architecture of the dynamic prompt module is shown. First, the multi-scale encoding features, dataset name and category name are input into the dynamic prompt module. Assuming that there are D datasets, which contain a total of C categories, the names of the D datasets can be encoded by byte pairs to generate the corresponding vector Dataset i , and add T learnable parameters in front of the vector, the final data set text sequence is represented as:

[0090]

[0091] in, represents T learnable parameters.

[0092] Similarly, the category name can also be obtained through the above method to obtain the category text sequence, which can be specifically expressed as:

[0093]

[0094] Then, the dataset prompt can be obtained by tokenizing the dataset text sequence, and the category prompt can be obtained by tokenizing the category text sequence.

[0095] Further, based on the multi-scale feature encoding, the data set prompt and the category prompt, a multi-scale enhanced prompt feature is obtained, including:

[0096] The data set prompt is used as a first query matrix, the category prompt is used as a first key value matrix and a first value matrix, and is input into a first self-attention module for attention calculation to obtain a data set and category combination prompt;

[0097] The data set is concatenated with the category combination prompt and the category prompt as a second key value matrix and a second value matrix, the multi-scale encoding feature is used as a second query matrix, and is input into a second self-attention module for attention calculation to obtain the multi-scale enhanced prompt feature.

[0098] Specifically, the data set prompt is used as the first query matrix Q, the category prompt is used as the first key value matrix K and the first value matrix V, and is input into the self-attention module, that is, in the first self-attention module, each self-attention module has L self-attention layers. After the self-attention calculation is performed by the self-attention module, the data set and category combination prompt can be obtained. The data set and category combination prompt can be calculated by the following formula:

[0099] Q l+1 =FFN(LN(CA(Q l ,K l ,V l ,M)))+Q l ;

[0100] Among them, l represents the l-th self-attention layer, LN(·) represents layer normalization, FFN(·) represents feed-forward neural network, and M represents attention mask.

[0101] The CA(·) represents the self-attention operation combined with the attention mask. The specific formula is as follows:

[0102]

[0103] After performing self-attention calculation through the above-mentioned self-attention module, a data set and a category combination prompt can be obtained, and then the data set and the category combination prompt are concatenated with the category prompt as a second key value matrix and a second value matrix, and the multi-scale encoding feature is used as a second query matrix and input into a new self-attention module, that is, the second self-attention module for attention calculation to obtain the multi-scale enhanced prompt feature.

[0104] The data set and the category combination prompt are concatenated with the category prompt. The concatenation operation here usually refers to concatenating two or more tensors (arrays, matrices, etc.) on a certain axis. For example, the dimension of the data set and the category combination prompt is BxLxC, and the dimension of the category prompt is BxMxC. After concatenation, a tensor of Bx(L+M)xC is obtained.

[0105] In one embodiment of the present application, the data set prompt is used as a first query matrix, the category prompt is used as a first key value matrix and a first value matrix, and is input into a first self-attention module for attention calculation to obtain a data set and category combination prompt, including:

[0106] Create an attention mask that masks the categories outside the current cytopathology image dataset;

[0107] A self-attention calculation is performed based on the attention mask, the first query matrix, the first key-value matrix, and the first value matrix to obtain the dataset and category combination prompt.

[0108] Specifically, an attention mask can be created It is used to mask out categories outside the current dataset. For example, if there are categories that are not in the current dataset, such as Plasma, Neutrophils, and Eosinophil in Lizard, which are not in the CoNSeP dataset, the redundant categories can be masked to prevent the model from confusing the information introduced into other datasets and affecting the classification results of the current dataset.

[0109] Among them, when the current data set contains a certain analogy, the attention mask of this category is 0, and when it does not contain this category, the attention mask of this category is -∞. The formula is expressed as:

[0110]

[0111] Where L S is the length of the input text sequence, I d is the category index in the dth dataset.

[0112] Then, the attention mask M can be brought into the calculation formula of the above self-attention module to obtain the combination prompt of the data set and category.

[0113] In one embodiment of the present application, the step of extracting features from the preprocessed cell pathology image and encoding the extracted features to obtain multi-scale feature encoding includes:

[0114] Inputting the preprocessed cell pathology image into the feature extraction backbone network in the original cell detection and classification model to perform multi-stage feature extraction to obtain multi-scale features;

[0115] The multi-scale features are input into the feature encoding network in the primitive cell detection and classification model for encoding to obtain the multi-scale feature encoding.

[0116] Specifically, the preprocessed cytopathology image can be input into a backbone feature extraction network for feature extraction, and the backbone feature extraction network can be a SwinTransformer-Base model. The second, third and fourth stage features extracted therefrom and the fifth stage features obtained by convolution sampling and reducing the resolution of the fourth stage features can all be used as multi-scale features.

[0117] Furthermore, the extracted multi-scale features are input into the feature encoding network, which may be composed of multiple deformable network layers, such as three layers, four layers, etc. The deformable network layers mainly include a deformable self-attention mechanism for calculating self-attention. The multi-scale features are self-attention calculated in turn through multiple network layers to obtain multi-scale feature encoding.

[0118] In an embodiment of the present application, obtaining a decoding candidate vector based on the first classification detection result and the multi-scale enhancement prompt feature includes:

[0119] Position encoding is performed on the detection classification results whose confidence is greater than a preset threshold in the first classification detection results, and the results are added to the learnable vector generated by random initialization to form a third query matrix;

[0120] Using the multi-scale enhanced prompt features as a third key value matrix and a third value matrix;

[0121] The third query matrix, the third key-value matrix, and the third value matrix are input into the feature decoding network of the original cell detection and classification model to calculate the cross attention, so as to obtain the decoding candidate vector.

[0122] Specifically, the classification detection head may include a first-stage classification detection head and a second-stage classification detection head. The multi-scale enhanced prompt features output by the dynamic prompt module can be divided into two paths. One path is to input it into the first-stage classification detection head. The first-stage classification detection head is composed of d independent fully connected layers, representing d data sets. The multi-scale enhanced features obtained by each corresponding data set image will be input into the corresponding detection classification head to obtain the cell position and category in the image, which is called the first detection classification result. The K detection results with the highest confidence in the first detection classification result can be position-encoded, and then added to the learnable vector generated by random initialization as the third query matrix and input into the feature decoding network. The other path is to directly input the multi-scale enhanced prompt features as the third key matrix and the third value matrix into the feature decoding network to calculate the cross attention to obtain the decoding candidate vector, that is, the decoded query matrix.

[0123] Among them, position encoding can be understood as expressing a position, such as the 5th position in the 2nd row, 3rd column, as (2, 3, 5), that is, encoding it into a vector containing, for example, 128 elements.

[0124] Among them, the learnable vector, like the parameters of the neural network, can be updated through gradient backpropagation and updated to a value more suitable for the network as the network learns.

[0125] Among them, the second-stage classification detection head can also be composed of d independent fully connected layers, representing d data sets. The multi-scale enhanced features obtained from each corresponding data set image will be input into the corresponding detection classification head to obtain the cell position and category in the image.

[0126] The learnable vectors usually refer to the weights and biases in the network, which are parameters that are gradually adjusted through the learning process to optimize network performance. For example, using nn.Parameters(size) in pytorch for initialization

[0127] In an embodiment of the present application, the method further includes:

[0128] Initializing a plurality of contrast denoising vectors, and inputting the contrast denoising vectors as fourth query means into a feature decoding network to obtain two decoding results;

[0129] A positive label and a negative label are generated based on the true label, and the decoding result is supervised by the positive label and the negative label.

[0130] Among them, the contrast denoising vector can also be understood as a learnable vector, which can be updated through gradient backpropagation and updated to a value more suitable for the network as the network learns.

[0131] Specifically, in order to accelerate network convergence, a contrastive denoising scheme is adopted. First, a series of contrastive denoising vectors can be initialized and independently input into the feature decoding network as a query matrix. The decoded contrastive denoising vector will generate two results, generating positive labels and negative labels based on the true labels to supervise these two results and accelerate network convergence during training. It can be understood that the contrastive denoising vector will only be used during the training process and is not needed in the inference test phase.

[0132] In the embodiment of the present application, cell pathology images in multiple different data sets are used as training data, and prompt learning is performed based on the name of each data set and the category name, so that the unification of multiple different data sets can be achieved, and the accuracy of cell detection and classification can be improved. At the same time, in the model training process, some learnable recommendation points are proposed through a deformable attention mechanism. During the calculation, only the features of the recommended point positions are calculated, which can reduce the amount of calculation, increase the network fitting speed, and improve the model training efficiency.

[0133] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0134] In one embodiment, a general multi-type cell detection device based on prompt learning is provided, and the general multi-type cell detection device based on prompt learning corresponds one-to-one with the general multi-type cell detection method based on prompt learning in the above embodiment. Figure 4 As shown, the universal multi-class cell detection device based on prompt learning includes a training data acquisition unit 10, a model training unit 20, and a detection and classification unit 30. The functional modules are described in detail as follows:

[0135] A training data acquisition unit 10 is used to acquire a plurality of cytopathology image data sets each including a plurality of cytopathology images with real labels, and preprocess each of the cytopathology images, wherein the cytopathology image data sets include a data set name and a category name;

[0136] A model training unit 20, for inputting the preprocessed cell pathology image, the data set name and the category name into the original cell detection classification model, and using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image;

[0137] The detection and classification unit 30 is used to obtain a trained target cell detection and classification model when the training result meets the preset convergence condition, so as to detect and classify the cell pathology image to be detected through the target cell detection and classification model.

[0138] In one embodiment of the present application, the model training unit 20 is further used to:

[0139] Based on the preprocessed cell pathology image, the data set name, and the category name, a multi-scale enhanced prompt feature is obtained;

[0140] Inputting the multi-scale enhanced prompt feature into the first stage detection and classification head in the original cell detection and classification model for classification and detection to obtain a first classification detection result;

[0141] Based on the first classification detection result and the multi-scale enhancement prompt feature, a decoding candidate vector is obtained, and the decoding candidate vector is input into the second stage detection classification head in the original cell detection classification model for classification processing to obtain a second classification detection result;

[0142] A loss value is calculated based on the second classification detection result and the true label, and the original cell detection classification model is iteratively trained using the loss value.

[0143] In one embodiment of the present application, the model training unit 20 is further used to:

[0144] Extracting features from the preprocessed cell pathology image, and encoding the extracted features to obtain multi-scale feature encoding;

[0145] The data set name and the category name are processed respectively according to preset processing rules to obtain a data set prompt and a category prompt;

[0146] Based on the multi-scale feature encoding, the data set prompt and the category prompt, a multi-scale enhanced prompt feature is obtained.

[0147] In one embodiment of the present application, the model training unit 20 is further used to:

[0148] Performing byte pair encoding processing on the data set name and the category name respectively to obtain a data set name vector and a category vector;

[0149] Adding preset learnable parameters to the data set name vector and the category vector respectively to obtain a data set text sequence and a category text sequence;

[0150] The data set text sequence and the category text sequence are respectively segmented to obtain data set prompts and category prompts.

[0151] In one embodiment of the present application, the model training unit 20 is further used to:

[0152] The data set prompt is used as a first query matrix, the category prompt is used as a first key value matrix and a first value matrix, and is input into a first self-attention module for attention calculation to obtain a data set and category combination prompt;

[0153] The data set is concatenated with the category combination prompt and the category prompt as a second key value matrix and a second value matrix, the multi-scale encoding feature is used as a second query matrix, and is input into a second self-attention module for attention calculation to obtain the multi-scale enhanced prompt feature.

[0154] In one embodiment of the present application, the model training unit 20 is further used to:

[0155] Create an attention mask that masks the categories outside the current cytopathology image dataset;

[0156] A self-attention calculation is performed based on the attention mask, the first query matrix, the first key-value matrix, and the first value matrix to obtain the dataset and category combination prompt.

[0157] In one embodiment of the present application, the model training unit 20 is further used to:

[0158] Inputting the preprocessed cell pathology image into the feature extraction backbone network in the original cell detection and classification model to perform multi-stage feature extraction to obtain multi-scale features;

[0159] The multi-scale features are input into the feature encoding network in the primitive cell detection and classification model for encoding to obtain the multi-scale feature encoding.

[0160] In one embodiment of the present application, the model training unit 20 is further used to:

[0161] Position encoding is performed on the detection classification results whose confidence is greater than a preset threshold in the first classification detection results, and the results are added to the learnable vector generated by random initialization to form a third query matrix;

[0162] Using the multi-scale enhanced prompt features as a third key value matrix and a third value matrix;

[0163] The third query matrix, the third key-value matrix, and the third value matrix are input into the feature decoding network of the original cell detection and classification model to calculate the cross attention, so as to obtain the decoding candidate vector.

[0164] In one embodiment of the present application, the device further includes: a contrast noise reduction unit, configured to:

[0165] Initializing a plurality of contrast denoising vectors, and inputting the contrast denoising vectors as fourth query means into a feature decoding network to obtain two decoding results;

[0166] A positive label and a negative label are generated based on the true label, and the decoding result is supervised by the positive label and the negative label.

[0167] In the embodiment of the present application, cell pathology images in multiple different data sets are used as training data, and prompt learning is performed based on the name of each data set and the category name, so that the unification of multiple different data sets can be achieved, and the accuracy of cell detection and classification can be improved. At the same time, in the model training process, some learnable recommendation points are proposed through a deformable attention mechanism. During the calculation, only the features of the recommended point positions are calculated, which can reduce the amount of calculation, increase the network fitting speed, and improve the model training efficiency.

[0168] For the specific definition of the universal multi-type cell detection device based on prompt learning, please refer to the definition of the universal multi-type cell detection method based on prompt learning above, which will not be repeated here. Each module in the above-mentioned universal multi-type cell detection device based on prompt learning can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0169] In one embodiment, a computer device is provided. The computer device may be a terminal device, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a readable storage medium. The readable storage medium stores computer-readable instructions. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer-readable instructions are executed by the processor, a general multi-class cell detection method based on prompt learning is implemented. The readable storage medium provided in this embodiment includes a non-volatile readable storage medium and a volatile readable storage medium.

[0170] In an embodiment of the present application, a computer device is provided, comprising a memory, a processor, and computer-readable instructions stored in the memory and executable on the processor. When the processor executes the computer-readable instructions, the steps of the general multi-class cell detection method based on prompt learning as described above are implemented.

[0171] In an embodiment of the application, a readable storage medium is provided, wherein the readable storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by a processor, the steps of the general multi-class cell detection method based on prompt learning as described above are implemented.

[0172] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they may include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0173] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0174] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A general multi-class cell detection method based on prompt learning, characterized in that: The method comprises: Acquire multiple cytopathology image data sets each including a plurality of cytopathology images with real labels, and preprocess each of the cytopathology images, wherein the cytopathology image data sets include a data set name and a category name; Inputting the preprocessed cell pathology image, the data set name, and the category name into the original cell detection classification model, and using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image; When the training result meets the preset convergence condition, a trained target cell detection and classification model is obtained, so as to detect and classify the cell pathology image to be detected through the target cell detection and classification model; The step of inputting the preprocessed cell pathology image, the data set name, and the category name into the original cell detection and classification model, and using the data set name and the category name as prompts to guide the original cell detection and classification model to perform iterative training based on the preprocessed cell pathology image includes: Based on the preprocessed cell pathology image, the data set name, and the category name, a multi-scale enhanced prompt feature is obtained; Inputting the multi-scale enhanced prompt feature into the first stage detection and classification head in the original cell detection and classification model for classification and detection to obtain a first classification detection result; Based on the first classification detection result and the multi-scale enhancement prompt feature, a decoding candidate vector is obtained, and the decoding candidate vector is input into the second stage detection classification head in the original cell detection classification model for classification processing to obtain a second classification detection result; A loss value is calculated based on the second classification detection result and the true label, and the original cell detection classification model is iteratively trained using the loss value.

2. The universal multi-class cell detection method based on prompt learning as claimed in claim 1, characterized in that: The multi-scale enhancement prompt feature is obtained based on the pre-processed cell pathology image, the data set name and the category name, including: Extracting features from the preprocessed cell pathology image, and encoding the extracted features to obtain multi-scale feature encoding; The data set name and the category name are processed respectively according to preset processing rules to obtain a data set prompt and a category prompt; Based on the multi-scale feature encoding, the data set prompt and the category prompt, a multi-scale enhanced prompt feature is obtained.

3. The universal multi-class cell detection method based on prompt learning as claimed in claim 2, characterized in that: The processing of the data set name and the category name according to the preset processing rules to obtain the data set prompt and the category prompt includes: Performing byte pair encoding processing on the data set name and the category name respectively to obtain a data set name vector and a category vector; Adding preset learnable parameters to the data set name vector and the category vector respectively to obtain a data set text sequence and a category text sequence; The data set text sequence and the category text sequence are respectively segmented to obtain data set prompts and category prompts.

4. The universal multi-class cell detection method based on prompt learning as claimed in claim 3, characterized in that: The obtaining of a multi-scale enhanced prompt feature based on the multi-scale feature encoding, the data set prompt and the category prompt comprises: The data set prompt is used as a first query matrix, the category prompt is used as a first key value matrix and a first value matrix, and is input into a first self-attention module for attention calculation to obtain a data set and category combination prompt; The data set is concatenated with the category combination prompt and the category prompt as a second key value matrix and a second value matrix, the multi-scale feature encoding is used as a second query matrix, and is input into a second self-attention module for attention calculation to obtain the multi-scale enhanced prompt feature.

5. The universal multi-class cell detection method based on prompt learning as claimed in claim 4, characterized in that: The step of using the data set prompt as a first query matrix, using the category prompt as a first key value matrix and a first value matrix, and inputting the prompts into a first self-attention module for attention calculation to obtain a data set and category combination prompt, includes: Create an attention mask that masks the categories outside the current cytopathology image dataset; A self-attention calculation is performed based on the attention mask, the first query matrix, the first key-value matrix, and the first value matrix to obtain the dataset and category combination prompt.

6. The universal multi-class cell detection method based on prompt learning as claimed in claim 2, characterized in that: The step of extracting features from the preprocessed cell pathology image and encoding the extracted features to obtain multi-scale feature encoding includes: Inputting the preprocessed cell pathology image into the feature extraction backbone network in the original cell detection and classification model to perform multi-stage feature extraction to obtain multi-scale features; The multi-scale features are input into the feature encoding network in the primitive cell detection and classification model for encoding to obtain the multi-scale feature encoding.

7. The universal multi-class cell detection method based on prompt learning as claimed in claim 1, characterized in that: The obtaining of a decoding candidate vector based on the first classification detection result and the multi-scale enhancement prompt feature includes: Position encoding is performed on the detection classification results whose confidence is greater than a preset threshold in the first classification detection results, and the results are added to the learnable vector generated by random initialization to form a third query matrix; Using the multi-scale enhanced prompt features as a third key value matrix and a third value matrix; The third query matrix, the third key-value matrix, and the third value matrix are input into the feature decoding network of the original cell detection and classification model to calculate the cross attention, so as to obtain the decoding candidate vector.

8. The universal multi-class cell detection method based on prompt learning as claimed in claim 6, characterized in that: The method further comprises: Initializing a plurality of contrast denoising vectors, and inputting the contrast denoising vectors as fourth query means into a feature decoding network to obtain two decoding results; A positive label and a negative label are generated based on the true label, and the decoding result is supervised by the positive label and the negative label.

9. A universal multi-type cell detection device based on prompt learning, characterized in that: The device comprises: A training data acquisition unit, used to acquire a plurality of cytopathology image data sets each including a plurality of cytopathology images with real labels, and preprocess each of the cytopathology images, wherein the cytopathology image data sets include a data set name and a category name; A model training unit, used for inputting the preprocessed cell pathology image, the data set name and the category name into the original cell detection classification model, and using the data set name and the category name as prompts to guide the original cell detection classification model to perform iterative training based on the preprocessed cell pathology image; A detection and classification unit, used to obtain a trained target cell detection and classification model when the training result meets the preset convergence condition, so as to detect and classify the cell pathology image to be detected through the target cell detection and classification model; The model training unit is further used for: Based on the preprocessed cell pathology image, the data set name, and the category name, a multi-scale enhanced prompt feature is obtained; Inputting the multi-scale enhanced prompt feature into the first stage detection and classification head in the original cell detection and classification model for classification and detection to obtain a first classification detection result; Based on the first classification detection result and the multi-scale enhancement prompt feature, a decoding candidate vector is obtained, and the decoding candidate vector is input into the second stage detection classification head in the original cell detection classification model for classification processing to obtain a second classification detection result; A loss value is calculated based on the second classification detection result and the true label, and the original cell detection classification model is iteratively trained using the loss value.