Image classification method and device, computer equipment, storage medium and program product
By segmenting and feature extraction of original cell images, combining and spatial reconstruction feature training using information weights and non-information weights, the problems of insufficient generalization ability and limited GCN parameters of ViT model under data scarcity are solved, and efficient Image classification and recognition.
Patent Information
- Application Number
- CN202411107373.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-13
- Publication Date
- 2024-11-29
- Estimated Expiration
- 2044-08-13
AI Technical Summary
In image classification tasks, especially when data is scarce or expensive, the ViT model has limited generalization ability, which is prone to overfitting risks, and the GCN parameters are limited and the generalization ability is insufficient.
By acquiring and segmenting the original cell images, extracting multiple image blocks, performing feature extraction and weight separation processing, generating information weights and non-information weights, combining and performing spatial reconstruction feature training, improving the generalization ability and classification accuracy of the model sex.
Effectively use limited data to train the model, improve the accuracy and efficiency of image classification, reduce the influence of noise and redundant information, enhance the model's spatial information utilization of images, and improve the generalization ability and recognition effect of classifiers.
Smart Images

Figure CN119049044A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of image processing technology, and in particular to an image classification method, device, computer equipment, storage medium and program product. Background Art
[0002] In image classification tasks, deep learning models extract features by fusing graph convolutional networks (GCN) and convolutional neural networks (CNN), aiming to improve classification performance by using prior knowledge. GCN can effectively transmit information between nodes and learn global features and topological relationships, but its parameters are limited and its generalization ability is limited, especially in different tasks. Replacing deep learning models with texture information branches may lead to excessive human intervention, affecting classification results and multi-level task completion.
[0003] In order to overcome the limitations of GCN and maintain the ability to extract spatial relationships and global dependencies, the visual neural network architecture (Vision Transformer, ViT) was introduced. ViT has demonstrated excellent classification performance on large-scale image datasets such as ImageNet. However, Transformer lacks the inductive bias of CNN and is highly dependent on data, especially in areas such as medical cell images with limited data, which is prone to overfitting risks. Summary of the invention
[0004] In view of this, the present invention provides an image classification method, apparatus, computer device, storage medium and program product to solve the problem of how to effectively use limited data to train the ViT model and improve its generalization ability when data is scarce or costly.
[0005] In a first aspect, the present invention provides an image classification method, comprising: acquiring an original cell image; segmenting the original cell image to obtain a plurality of image blocks; extracting a corresponding first image feature from the original cell image, and extracting a corresponding second image feature from the plurality of image blocks; performing weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the part of the image feature containing the target space content, and the non-information weight is used to characterize the part of the image feature without the target space content or the proportion of the target space content part is less than a preset value; creating a first target feature using the first image feature, the first information weight and the first non-information weight; and creating a second target feature using the second image feature, the second information weight and the second non-information weight; merging the first target feature and the second target feature to obtain a merged feature; and spatially reconstructing the merged feature to obtain a spatially reconstructed feature; training a classifier according to the spatially reconstructed feature; and acquiring a target cell image, inputting the target cell image into the trained classifier, and obtaining a classification result corresponding to the target cell image.
[0006] The image classification method provided by the embodiment of the present invention can extract multiple image blocks by acquiring the original cell image and segmenting it, which is helpful for processing large-scale data and improving processing efficiency. Extracting image features from the original cell image and its segmented image blocks can capture visual information of different scales and levels, which is conducive to subsequent analysis and processing. Weight separation of image features and separate processing of information weights and non-information weights can help reduce the influence of noise and redundant information, improve the expressiveness of features and the accuracy of classification. Using information weights and non-information weights to create target features and merge target features from different sources can comprehensively utilize information of different levels and types to improve the effect of classification and recognition. Training the classifier through spatial reconstruction features can make full use of the spatial information of the image and improve the generalization ability and accuracy of the classifier for target cell images. Applying the trained classifier to the target cell image can achieve rapid classification and recognition of unknown cell image data, and can effectively improve the accuracy and efficiency of cell image classification and recognition tasks.
[0007] In an optional embodiment, a weight separation process is performed on the first image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, including: normalizing the first image feature to obtain a corresponding first standard feature; weighting the first standard feature to obtain a corresponding first standard weight; mapping the first standard weight to a preset interval through a preset function to obtain a corresponding first mapping weight; obtaining a preset threshold; and determining the weights in the first mapping weights that are higher than the preset threshold as the first information weights, and determining the weights in the first mapping weights that are lower than the preset threshold as the first non-information weights.
[0008] The image classification method provided by the embodiment of the present invention can make the first image feature have a unified scale and range through normalization processing, which is helpful for subsequent weighting and mapping processing and improves the consistency and comparability of feature processing. Weighted processing is performed on the normalized features, and the features can be adjusted according to their importance, strengthening or weakening the influence of specific features, which helps to improve the expressiveness and discrimination of the features. The weighted feature weights are mapped to a preset interval so that the weights are interpretable and standardized, which is convenient for subsequent threshold processing and information extraction steps. Setting a preset threshold and dividing the weights into information weights and non-information weights according to the threshold can effectively screen out feature parts with significant information content, reduce the interference of useless information, and improve the effectiveness of the features and the accuracy of the classifier.
[0009] In an optional embodiment, the first target feature includes a first information feature and a first non-information feature; the first target feature is created using the first image feature, the first information weight and the first non-information weight, including: multiplying the first image feature by the first information weight to obtain the first information feature, and multiplying the first image feature by the first non-information weight to obtain the first non-information feature.
[0010] The image classification method provided by the embodiment of the present invention can strengthen and highlight the parts of the image features with important information by multiplying the information weight, so that these parts get more weight and influence in the final target features. This helps to more accurately identify and classify the target cell images in the subsequent classifier training process. By multiplying the non-information weight, the influence of those parts in the image features that may be noise or insignificant can be reduced or suppressed. Doing so helps to improve the cleanliness and purity of the features, so that the final target features more accurately reflect the real features and patterns in the image. Integrating information weights and non-information weights can make full use of the differences between the two, thereby more accurately characterizing various aspects of image features. This comprehensive utilization helps to optimize the quality of features and the performance of classifiers, making the overall image analysis and classification tasks more efficient and reliable.
[0011] In an optional embodiment, extracting corresponding second image features from multiple image blocks includes: obtaining position coding vectors corresponding to the multiple image blocks, and linearly projecting the multiple image blocks to obtain projection vectors corresponding to the multiple image blocks; adding the projection vector and the position coding vector to obtain second image features corresponding to the multiple image blocks.
[0012] The image classification method provided by the embodiment of the present invention can effectively embed the position information of each image block into the feature vector by introducing the position coding vector. This helps the model to distinguish the spatial positions of image blocks when processing them, so as to more accurately understand the structure and content of the image. Through linear projection, the original features of each image block can be mapped to a higher dimensional space. This helps to increase the diversity and expressiveness of the features, so as to better capture the key information and patterns in the image blocks. By adding the projection vector and the position coding vector, feature fusion is achieved. This fusion can effectively combine the spatial position information and the content features of the image block to generate a richer and more meaningful second image feature. The feature vector after integrating the position coding not only increases the model's ability to understand the image content and structure, but also improves the generalization ability and classification accuracy of the model in complex scenes.
[0013] In an optional embodiment, the second image feature is weight-separated to obtain a second information weight and a second non-information weight corresponding to the second image feature, including: processing the second image feature according to a multi-head self-attention mechanism to obtain a multi-head feature vector; wherein the multi-head feature vector is used to characterize the information of the second image feature at different focus points; normalizing the multi-head feature vector to obtain a corresponding second standard feature; weighting the second standard feature to obtain a corresponding second standard weight; mapping the second standard weight to a preset interval through a preset function to obtain a corresponding second mapping weight; determining the weights in the second mapping weights that are higher than a preset threshold as second information weights, and determining the weights in the second mapping weights that are lower than the preset threshold as second non-information weights.
[0014] In the image classification method provided by the embodiment of the present invention, the multi-head self-attention mechanism can simultaneously focus on the importance of different positions in the image features. This mechanism effectively captures the complex relationship between different parts of the image by calculating the attention weight between each position and other positions. The multi-head feature vector can characterize the information of the second image feature at different focus points, which means that it can treat the image features from multiple angles, thereby more comprehensively capturing the content and contextual information of the image. Normalizing the multi-head feature vector helps to maintain the stability and comparability of the feature vector. Scaling the feature vector to a similar numerical range avoids training instability or convergence difficulties caused by different numerical ranges. By adjusting the second standard feature by weighting, the influence of a specific part can be strengthened or weakened according to different tasks or requirements. The mapping process of the preset function can further optimize the distribution of weights to make it more in line with the needs and goals of specific applications. By setting a threshold, the second mapping weight can be divided into information weights and non-information weights. This helps the model to more effectively screen and utilize key information in subsequent processing, thereby improving the accuracy and efficiency of the task.
[0015] In an optional embodiment, the second image features are processed according to a multi-head self-attention mechanism to obtain a multi-head feature vector, including: obtaining a pre-set query weight matrix, key weight matrix and value weight matrix; multiplying the second image features with the query weight matrix, key weight matrix and value weight matrix respectively to obtain the corresponding query vector, key vector and value vector; calculating the dot product of the query vector and the key vector, and determining the dot product as the attention score; performing weighted summation on the attention scores to obtain a single-head feature vector corresponding to each attention head; merging the single-head feature vectors, and performing a linear transformation on the merged feature vector to obtain a multi-head feature vector corresponding to multiple attention heads.
[0016] In the image classification method provided by the embodiment of the present invention, the self-attention mechanism allows the model to calculate the query, key, and value vectors of each position in parallel, so that the information of each part of the image can be processed simultaneously without being restricted by the position order. This global attention capability helps the model to understand the image content without being affected by the position distance, thereby improving the global consistency and accuracy of feature extraction. By calculating the dot product of the query vector and the key vector and applying the weighted sum, the attention weight can be dynamically adjusted according to the importance of each position. This flexibility enables the model to focus on key information more effectively when processing complex image scenes, improving the accuracy and robustness of feature extraction. The feature vectors generated by a single attention head are merged and linearly transformed to obtain a multi-head feature vector. These multi-head feature vectors cover different focus points and perspectives, so that the model can comprehensively utilize multiple attention heads to perform a more in-depth and comprehensive analysis of image features. Through the multi-head self-attention mechanism, the model can more effectively extract and express complex relationships and structures in image features. This enhanced feature representation capability helps to improve the performance of the model in visual tasks. The self-attention mechanism has a certain anti-interference ability when processing image features, and can effectively deal with interference and noise in local areas of the image, thereby improving the robustness and generalization ability of the model in complex backgrounds.
[0017] In an optional embodiment, the second target feature includes a second information feature and a second non-information feature; the second target feature is created using the second image feature, the second information weight and the second non-information weight, including: multiplying the second image feature by the second information weight to obtain the second information feature, and multiplying the second image feature by the second non-information weight to obtain the second non-information feature.
[0018] The image classification method provided by the embodiment of the present invention can effectively screen and distinguish important information and non-important information in the image by multiplying the second image feature with the information weight and the non-information weight. This operation helps the model focus on processing the most meaningful information part of the current cell image, thereby improving the efficiency and performance of the model. Distinguishing between the second information feature and the second non-information feature allows the model to more finely control the amount and quality of information processed. After generating the second information feature and the second non-information feature, the model can more effectively adapt to specific task requirements. By effectively processing these two types of information, the performance and generalization ability of the model in various visual tasks can be significantly improved. By separating the information features and non-information features, the model can be more efficient when processing large-scale image data. This optimization helps to reduce the computational burden and resource consumption of the model, and improve the overall processing speed and real-time performance.
[0019] In an optional embodiment, the first target feature and the second target feature are merged to obtain a merged feature, including: using a convolution layer to perform feature fusion on the first information feature and the second information feature to obtain a first fused feature; and performing feature fusion on the first non-information feature and the second non-information feature to obtain a second fused feature; merging the first fused feature and the second fused feature, and performing convolution processing on the merged feature to obtain a merged feature.
[0020] The image classification method provided by the embodiment of the present invention can effectively integrate feature information of different sources and properties by fusing the first information feature and the second information feature through a convolution layer, and fusing the first non-information feature and the second non-information feature. This fusion helps to comprehensively utilize the advantages of multiple feature sources and improve the model's ability to express and analyze complex image information. The first fused feature and the second fused feature are merged, and the merged feature is obtained through convolution processing, so that the model can express image features in a rich way from multiple aspects. This information complementarity and richness helps to reduce information loss and error propagation, and improves the model's comprehensive understanding and processing capabilities of image content. By processing the spliced features through a convolution layer, the spatial information of the features can be effectively extracted and enhanced. The convolution operation has local perception capabilities and parameter sharing characteristics, which can effectively reduce the number of parameters and computational complexity, while improving the accuracy and stability of feature representation.
[0021] In an optional embodiment, spatially reconstructing the merged features to obtain spatially reconstructed features includes: performing weight separation processing on the merged features to obtain a third information weight and a third non-information weight corresponding to the merged features; multiplying the merged features by the third information weight to obtain a third information feature, and multiplying the merged features by the third non-information weight to obtain a third non-information feature; splitting the third information feature into a first information sub-feature and a second information sub-feature, and splitting the third non-information feature into a third information sub-feature and a fourth information sub-feature; adding the first information sub-feature and the fourth information sub-feature element by element to obtain a first cross feature; and adding the second information sub-feature and the third information sub-feature element by element to obtain a second cross feature; merging the first cross feature and the second cross feature to obtain a spatially reconstructed feature.
[0022] The image classification method provided by the embodiment of the present invention can finely control the influence of different types of features in subsequent processing by weight separation processing of the merged features to generate the third information weight and the third non-information weight respectively. This refined feature weighting helps the model to more effectively distinguish and utilize important information and non-important information in the image, thereby improving the performance and robustness of the model when processing complex visual tasks. The merged features are multiplied by the third information weight and the third non-information weight respectively to generate the third information feature and the third non-information feature, and they are further split into multiple information sub-features and non-information sub-features, which can enhance the model's ability to understand different levels and angles of image content, so that the model can more comprehensively analyze and process input data. By adding the first information sub-feature and the fourth information sub-feature element by element, and adding the second information sub-feature and the third information sub-feature element by element, a first cross feature and a second cross feature are generated. This cross feature generation can capture the interaction and correlation between different information subsets, which helps to improve the performance and generalization capabilities of the model in complex scenes. The first cross feature and the second cross feature are combined to generate a spatial reconstruction feature, which integrates information from different information sub-features and cross features to form a more comprehensive and comprehensive feature representation. This spatial reconstruction feature helps improve the model's ability to understand the overall structure and spatial layout of the image, thereby improving the model's effectiveness and accuracy in image processing tasks.
[0023] In a second aspect, the present invention provides an image classification device, comprising: an acquisition module for acquiring an original cell image; and segmenting the original cell image to obtain a plurality of image blocks; an extraction module for extracting a corresponding first image feature from the original cell image, and extracting a corresponding second image feature from the plurality of image blocks; a processing module for performing weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the portion of the image feature that contains the target space content, and the non-information weight is used to characterize the image feature. The image feature has no target space content part or the proportion of the target space content part is less than a preset value; a creation module is used to create a first target feature using a first image feature, a first information weight and a first non-information weight; and create a second target feature using a second image feature, a second information weight and a second non-information weight; a merging module is used to merge the first target feature and the second target feature to obtain a merged feature; and spatially reconstruct the merged feature to obtain a spatially reconstructed feature; a classification module is used to train a classifier according to the spatially reconstructed feature; and obtain a target cell image, input the target cell image into the trained classifier, and obtain a classification result corresponding to the target cell image.
[0024] In a third aspect, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the image classification method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0025] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the image classification method of the first aspect or any corresponding embodiment thereof.
[0026] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the image classification method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0028] Figure 1 is a schematic diagram of a flow chart of an image classification method according to an embodiment of the present invention;
[0029] Figure 2 is a flowchart of another image classification method according to an embodiment of the present invention;
[0030] Figure 3 is a flowchart of another image classification method according to an embodiment of the present invention;
[0031] Figure 4 is a flowchart of yet another image classification method according to an embodiment of the present invention;
[0032] Figure 5 is a structural block diagram of an image classification device according to an embodiment of the present invention;
[0033] Figure 6 It is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings 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 those skilled in the art without creative work are within the scope of protection of the present invention.
[0035] In the network structure that integrates GCN and CNN for classification, although the GCN branch effectively transmits information between nodes, allowing the model to learn richer global features and topological relationships between cells, it has fewer learnable parameters, which limits its generalization ability in different tasks. On the other hand, directly replacing the original deep learning model with the texture information branch may lead to excessive human intervention and affect the model's adaptability to classification tasks at different levels.
[0036] In order to overcome the limitations of GCN and retain the ability to extract spatial relationships and global dependencies, the ViT structure is introduced in related technologies. ViT effectively captures the global dependencies in the image through the self-attention mechanism, and even distant regions can influence each other, which makes ViT have an advantage in understanding the overall context of the image. In contrast, although GCN can handle the global relationship between nodes, its ability to understand the global context of regular image data may not be as direct as ViT.
[0037] In addition, the ViT model is not restricted by a specific data structure and can more flexibly handle images of different resolutions and multi-scale analysis. The scalability of the Transformer architecture enables performance to be effectively improved by increasing the depth or width of the model, while GCN is affected by the characteristics of the graph structure and its scalability is relatively limited.
[0038] Although ViT demonstrates excellent classification performance on large-scale datasets such as ImageNet, due to the lack of the inductive biases of CNNs such as locality and translation invariance in Transformer, ViT may face the risk of overfitting in specific domain applications such as small datasets such as medical images.
[0039] In view of this, in order to improve the classification accuracy of the model and achieve balanced classification performance between different categories, the technical solution of the present invention firstly adopts a hybrid method of traditional data enhancement method and texture filter amplification to preprocess the image. Especially in the data set with fewer categories, a variety of filter sizes and amplifications at different angles are used to balance the number of samples in each category as much as possible. Secondly, a dual-branch classification network is constructed. Among them, the self-attention mechanism of the ViT model is used to highlight the important cell areas and global dependencies in the learning image. Through the channel retelling module, the features learned from ViT and EfficientNet backbone networks are fused to enhance the representation ability and classification effect of the features. These improvements retain the advantages of EfficientNet as the backbone network and avoid the challenge of large-scale data set training required for direct use of the ViT model. At the same time, by introducing the self-attention mechanism and position encoding of ViT, the learning of spatial information and global dependencies is effectively combined, further improving the classification performance of the model. Finally, the overall classification performance is improved, and a better balance and classification accuracy are achieved between different categories.
[0040] According to an embodiment of the present invention, an embodiment of an image classification method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0041] In this embodiment, an image classification method is provided, which can be used in computer devices, such as desktop computers, notebook computers, etc. Figure 1 is a flowchart of an image classification method according to an embodiment of the present invention. Figure 1 As shown, the process includes the following steps:
[0042] Step S101, obtaining an original cell image; and segmenting the original cell image to obtain a plurality of image blocks.
[0043] Raw cell images refer to unprocessed images obtained from biological samples, such as those obtained using a microscope or other equipment. Specifically, in a laboratory or clinical setting, researchers or doctors collect cell samples, such as those obtained from tissue sections or cell cultures. These samples are captured into images using a microscope or other equipment for subsequent analysis and research.
[0044] Multiple image blocks refer to dividing the entire original cell into multiple small areas or sub-images. These image blocks can appear in the form of squares or rectangles, and each image block contains local information of the cell image. Specifically, experts or researchers can manually draw boundaries or areas to divide the image into different parts according to the cell's morphology, color and other characteristics; or they can use computer vision technology and algorithms for automatic segmentation, such as threshold-based, edge detection, region growing, deep learning and other methods. These methods can automatically segment multiple image blocks according to the characteristics and requirements of the original cell image, which are not limited here.
[0045] Step S102: extracting corresponding first image features from the original cell image, and extracting corresponding second image features from the plurality of image blocks.
[0046] The first image feature refers to a set of features extracted from the entire original cell image to describe the overall content and characteristics of the image, such as overall color distribution, shape characteristics, texture information, etc. Specifically, tools such as image processing libraries (such as OpenCV), machine learning libraries (such as scikit-learn), or deep learning libraries (such as TensorFlow, PyTorch) can be used to calculate the feature values of the original cell image, and the calculated feature values are expressed in vectors or other numerical forms for subsequent analysis and processing.
[0047] The second image feature refers to a feature set extracted from each image block to describe local features. Specifically, for each image block, local features such as color histogram, texture descriptor, etc. are extracted, and the local features of each image block are combined into a vector or feature set to represent the visual information of the image block. The feature vectors of all image blocks are then connected or aggregated to form a second image feature representation of the entire original cell image.
[0048] Step S103, performing weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the part of the image feature that contains the target space content, and the non-information weight is used to characterize the part of the image feature that does not contain the target space content or the proportion of the target space content part is less than a preset value.
[0049] The target spatial content part is used to characterize the useful and expressive spatial content part, such as the key parts such as the nucleus and cytoplasm in the cell image. It can be understood that the information weight is used to characterize the useful target spatial content part in the image feature, and the non-information weight is used to characterize the spatial content part that contains less or no information in the image feature, or the part whose proportion is less than the preset value, such as the background, noise, irrelevant structure or low contrast area in the cell image. Among them, the preset value is a threshold or limiting condition used to determine which spatial content parts are regarded as information content or non-information content.
[0050] The first information weight is used to characterize the weight of the spatial content part containing useful and expressive power in the first image feature, wherein the first information weight mainly captures the important informative features in the first image, and helps to distinguish or describe the key content of the original cell image. The first non-informative weight is used to characterize the weight of the spatial content part containing less or no information in the first image feature, wherein the first non-informative weight mainly covers the noise, redundancy or irrelevant information in the first image. The second information weight is used to characterize the weight of the spatial content part containing useful and expressive power in the second image feature. The second non-informative weight is used to characterize the weight of the spatial content part containing less or no information in the second image feature. Specifically, a model or objective function can be predefined to distinguish the informative part from the non-informative part in the first image feature and the second image feature. Through the training or optimization process, the model parameters or the weights of the objective function are adjusted so that the informative weight and the non-informative weight can be reasonably separated.
[0051] Step S104, creating a first target feature using the first image feature, the first information weight and the first non-information weight; and creating a second target feature using the second image feature, the second information weight and the second non-information weight.
[0052] The first target feature is a feature obtained by weighting the first image feature according to the corresponding first information weight and the first non-information weight. Specifically, the first information weight is used to weight the important information part of the first image feature, and the first non-information weight is used to weight the non-information part of the first image feature. The weighted important information part and the non-information part are combined to obtain the first target feature.
[0053] The second target feature is a feature obtained by weighting the second image feature according to the corresponding second information weight and second non-information weight. Specifically, the second information weight is used to weight the important information part of the second image feature, and the second non-information weight is used to weight the non-information part of the second image feature. The weighted important information part and non-information part are combined to obtain the second target feature.
[0054] Step S105: merge the first target feature and the second target feature to obtain a merged feature; and spatially reconstruct the merged feature to obtain a spatially reconstructed feature.
[0055] Merging features means combining the first target feature and the second target feature to form a unified feature representation. Specifically, the first target feature and the second target feature can be connected into a longer vector in a preset order to obtain a merged feature; or the two feature maps can be merged into a new feature map using methods such as attention mechanism and neural network structure, which are not limited here.
[0056] Spatial reconstruction features refer to the process of converting the abstract feature map back to the space of the original data through reconstruction technology based on the merged features, for example, the original image space corresponding to the original cell image. Specifically, the merged features are used as input, and the selected spatial reconstruction technology, such as a decoder network, inverse convolution or depooling, is used to generate spatial reconstruction features to restore the structure and characteristics of the original cell image data as much as possible.
[0057] Step S106, training the classifier according to the spatial reconstruction features; and acquiring the target cell image, inputting the target cell image into the trained classifier, and obtaining the classification result corresponding to the target cell image.
[0058] Before training the classifier according to the spatial reconstruction features, it is necessary to obtain the correct classification labels corresponding to each original cell image sample, which can be manually annotated or obtained by other methods. Specifically, all the spatial reconstruction features and corresponding labels obtained above are combined into a training set, and each sample consists of a spatial reconstruction feature vector and its corresponding classification label. Select a classifier model suitable for the task, such as a support vector machine (SVM), a deep neural network (DNN) or a random forest. Input the prepared training set into the selected classifier model for training. During the training process, the classifier model adjusts its internal parameters according to the spatial reconstruction features and the corresponding labels so that it can correctly classify unseen data. Furthermore, after the training is completed, the model can be evaluated using the validation set to evaluate its classification accuracy, generalization ability and other indicators. This helps to determine whether the model can effectively process new data and check whether there are overfitting or underfitting problems.
[0059] The target cell image refers to the cell image sample to be classified, which can be new and previously unseen data. Specifically, the target cell image of unknown classification is obtained from the actual application scenario, and the target cell image is converted into a form suitable for the classifier input, that is, the target cell image is converted into a feature representation similar to the spatial reconstruction feature used in training. The converted features are input into the trained classifier model. The classifier will predict which classification category the target cell image belongs to based on its trained model parameters. The classification result output by the classifier is obtained, that is, the category label or classification probability to which the target cell image belongs.
[0060] The image classification method provided by the embodiment of the present invention can extract multiple image blocks by acquiring the original cell image and segmenting it, which is helpful for processing large-scale data and improving processing efficiency. Extracting image features from the original cell image and its segmented image blocks can capture visual information of different scales and levels, which is conducive to subsequent analysis and processing. Weight separation of image features and separate processing of information weights and non-information weights can help reduce the influence of noise and redundant information, improve the expressiveness of features and the accuracy of classification. Using information weights and non-information weights to create target features and merge target features from different sources can comprehensively utilize information of different levels and types to improve the effect of classification and recognition. Training the classifier through spatial reconstruction features can make full use of the spatial information of the image and improve the generalization ability and accuracy of the classifier for target cell images. Applying the trained classifier to the target cell image can achieve rapid classification and recognition of unknown cell image data, and can effectively improve the accuracy and efficiency of cell image classification and recognition tasks.
[0061] In this embodiment, an image classification method is provided, which can be used in computer devices, such as desktop computers, notebook computers, etc. Figure 2 is a flowchart of an image classification method according to an embodiment of the present invention. Figure 2 As shown, the process includes the following steps:
[0062] Step S201, obtaining an original cell image; and segmenting the original cell image to obtain multiple image blocks. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0063] Step S202: extract the corresponding first image features from the original cell image, and extract the corresponding second image features from the multiple image blocks. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0064] Step S203, performing weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the spatial content part containing useful and expressive power in the image feature, and the non-information weight is used to characterize the spatial content part containing less or no information in the image feature.
[0065] Specifically, the above step S203 includes:
[0066] Step S2031, normalize the first image feature to obtain a corresponding first standard feature.
[0067] The first standard feature is a feature obtained by normalizing the first image feature. Specifically, a group normalization (GN) layer is used to normalize the first image feature to obtain the first standard feature after group normalization and weighting.
[0068] For example, the above normalization process can be achieved by It is represented by, where F is the first image feature, GN(F) is the group normalization operation on the first image feature, μ is the mean of the first image feature, σ is the standard deviation of the first image feature, ε is a small constant used to avoid division by zero, α and β are trainable weight parameters used to adjust the normalized features, F OUT It is the first standard feature.
[0069] Step S2032, weighting the first standard feature to obtain a corresponding first standard weight.
[0070] The first standard weight is used to characterize the importance or information content of each position in the first standard feature. Specifically, the first standard feature is weighted using the pre-established formula W=Gate(Sigmoid(Wα(GN(x)))) where Wα=Gate(Sigmoid(Wα(GN(F OUT )))) is the normalization operation GN(F OUT ) is the first standard weight calculated.
[0071] Step S2033: Map the first standard weight to a preset interval through a preset function to obtain a corresponding first mapping weight.
[0072] The preset function is used to adjust the numerical range and distribution of the first standard weight to adapt it to the specific algorithm or task requirements. For example, the first standard weight can be limited to a preset interval by a Sigmoid function to improve the stability and efficiency of the algorithm.
[0073] The preset interval determines the numerical range of the first standard weight, for example, it can be a range of (0, 1). A suitable preset interval can ensure that the numerical value of the first standard weight is within a processable range and avoid numerical overflow or instability problems.
[0074] The first mapping weight is the result of the first standard weight being processed by a preset function. Specifically, the first standard weight is mapped to a preset interval by a Sigmoid function or other designed functions to obtain a first mapping weight, which represents the weight value after standardization and mapping processing.
[0075] Step S2034, obtaining a preset threshold; and determining the weights in the first mapping weights that are higher than the preset threshold as first information weights, and determining the weights in the first mapping weights that are lower than the preset threshold as first non-information weights.
[0076] The preset threshold is obtained based on previous experiments or hyperparameter adjustment. This threshold is used to distinguish which weights are regarded as useful information weights and which are regarded as useless redundant weights. Specifically, the first mapping weights are classified according to the preset threshold.
[0077] The first information weight is the part of the first mapping weight that is higher than the preset threshold, that is, the weight containing useful and expressive spatial content. The first non-information weight is the part of the first mapping weight that is lower than the preset threshold, that is, the weight containing less or no information and spatial redundancy. Specifically, the gating function constrains the first mapping weight within a preset interval according to the output of the Sigmoid function. The gating function can be simply expressed as a threshold function, such as a Gate function, which sets the part of the first mapping weight that is greater than the preset threshold to 1 to form the first information weight; the part that is less than the preset threshold is set to 0 to form the first non-information weight.
[0078] Step S2035: Perform weight separation processing on the second image feature to obtain a second information weight and a second non-information weight corresponding to the second image feature. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0079] The image classification method provided by the embodiment of the present invention can make the first image feature have a unified scale and range through normalization processing, which is helpful for subsequent weighting and mapping processing and improves the consistency and comparability of feature processing. Weighted processing is performed on the normalized features, and the features can be adjusted according to their importance, strengthening or weakening the influence of specific features, which helps to improve the expressiveness and discrimination of the features. The weighted feature weights are mapped to a preset interval so that the weights are interpretable and standardized, which is convenient for subsequent threshold processing and information extraction steps. Setting a preset threshold and dividing the weights into information weights and non-information weights according to the threshold can effectively screen out feature parts with significant information content, reduce the interference of useless information, and improve the effectiveness of the features and the accuracy of the classifier.
[0080] Step S204: creating a first target feature using the first image feature, the first information weight and the first non-information weight; and creating a second target feature using the second image feature, the second information weight and the second non-information weight.
[0081] Specifically, the above step S204 includes:
[0082] Step S2041, multiplying the first image feature by the first information weight to obtain the first information feature, and multiplying the first image feature by the first non-information weight to obtain the first non-information feature.
[0083] The first target feature includes a first information feature and a first non-information feature. Specifically, the first image feature is multiplied by the first information weight, and the information-valued portion selected by the first information weight is extracted from the first image feature. The first image feature is multiplied by the first non-information weight, and the non-information portion selected by the first non-information weight is extracted from the first image feature.
[0084] Step S2042: Create a second target feature using the second image feature, the second information weight and the second non-information weight. Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.
[0085] Step S205: merge the first target feature and the second target feature to obtain a merged feature; and spatially reconstruct the merged feature to obtain a spatially reconstructed feature. Figure 1 Step S105 of the illustrated embodiment will not be described in detail here.
[0086] Step S206, training the classifier according to the spatial reconstruction features; and obtaining the target cell image, inputting the target cell image into the trained classifier, and obtaining the classification result corresponding to the target cell image. Figure 1 Step S106 of the illustrated embodiment will not be described in detail here.
[0087] The image classification method provided by the embodiment of the present invention can strengthen and highlight the parts of the image features with important information by multiplying the information weight, so that these parts get more weight and influence in the final target features. This helps to more accurately identify and classify the target cell images in the subsequent classifier training process. By multiplying the non-information weight, the influence of those parts in the image features that may be noise or insignificant can be reduced or suppressed. Doing so helps to improve the cleanliness and purity of the features, so that the final target features more accurately reflect the real features and patterns in the image. Integrating information weights and non-information weights can make full use of the differences between the two, thereby more accurately characterizing various aspects of image features. This comprehensive utilization helps to optimize the quality of features and the performance of classifiers, making the overall image analysis and classification tasks more efficient and reliable.
[0088] In this embodiment, an image classification method is provided, which can be used in computer devices, such as desktop computers, notebook computers, etc. Figure 3 is a flowchart of an image classification method according to an embodiment of the present invention. Figure 3 As shown, the process includes the following steps:
[0089] Step S301, obtaining an original cell image; and segmenting the original cell image to obtain multiple image blocks. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0090] Step S302: extracting corresponding first image features from the original cell image, and extracting corresponding second image features from the plurality of image blocks.
[0091] Specifically, the above step S302 includes:
[0092] Step S3021, extracting the corresponding first image feature from the original cell image. Figure 1 Step S102 of the illustrated embodiment will not be described in detail here.
[0093] Step S3022, obtaining position encoding vectors corresponding to the multiple image blocks, and performing linear projection on the multiple image blocks to obtain projection vectors corresponding to the multiple image blocks.
[0094] The position encoding vector is used to represent the relative position information of each image block in the entire image, and each image block corresponds to a position encoding vector. Specifically, the position encoding vector can be predefined or obtained through model learning.
[0095] Linear projection is performed on the features of each image block, which can be understood as mapping the feature vector of each image block to a higher-dimensional or lower-dimensional vector space. Specifically, linear projection can be implemented using matrix multiplication to obtain projection vectors corresponding to multiple image blocks, where the projection matrix is a learnable parameter used to adjust the expression of image block features.
[0096] Step S3023: Add the projection vector and the position encoding vector to obtain second image features corresponding to the multiple image blocks.
[0097] The projection vector of each image block obtained above is added to the corresponding position coding vector element by element. The spatial information of each image block (through the position coding vector) and its feature information (through the projection vector) are integrated to obtain the second image features corresponding to multiple image blocks, thereby enhancing the model's ability to represent image block features. For example, according to formula z i =x i +x i *σ(DWConv(x i )) is represented by i is the second image feature, x i It represents the vector representation of each image block after transformation through the linear projection layer, i = 1, 2, ..., N, DWConv(x i ) is a depthwise separable convolution operation, which performs convolution on x channel by channel. i Perform spatial convolution operation.
[0098] The image classification method provided by the embodiment of the present invention can effectively embed the position information of each image block into the feature vector by introducing the position coding vector. This helps the model to distinguish the spatial positions of image blocks when processing them, so as to more accurately understand the structure and content of the image. Through linear projection, the original features of each image block can be mapped to a higher dimensional space. This helps to increase the diversity and expressiveness of the features, so as to better capture the key information and patterns in the image blocks. By adding the projection vector and the position coding vector, feature fusion is achieved. This fusion can effectively combine the spatial position information and the content features of the image block to generate a richer and more meaningful second image feature. The feature vector after integrating the position coding not only increases the model's ability to understand the image content and structure, but also improves the generalization ability and classification accuracy of the model in complex scenes.
[0099] Step S303, performing weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the spatial content part containing useful and expressive power in the image feature, and the non-information weight is used to characterize the spatial content part containing less or no information in the image feature.
[0100] Specifically, the above step S303 includes:
[0101] Step S3031: Perform weight separation processing on the first image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature. Figure 1 Step S103 of the illustrated embodiment will not be described in detail here.
[0102] Step S3032, processing the second image feature according to the multi-head self-attention mechanism to obtain a multi-head feature vector; wherein the multi-head feature vector is used to characterize the information of the second image feature at different focus points.
[0103] The multi-head feature vector contains the relationship information learned in different spaces by different attention heads. Each head can focus on different points of interest, such as local features, global features, or features of different scales. Specifically, the input second image features are processed by query, key, and value, and the importance of each position or area is obtained by weighted calculation using the attention mechanism. Finally, the outputs of multiple heads are combined to form a multi-head feature vector to represent the information of the image at different points of interest.
[0104] In some optional implementations, the above step S3032 includes:
[0105] Step a1, obtaining a preset query weight matrix, a key weight matrix and a value weight matrix.
[0106] The query weight matrix maps the input second image features to a query vector (Q), the key weight matrix maps the input second image features to a key vector (K), and the value weight matrix maps the input second image features to a value vector (V). Specifically, three sets of predefined weight matrices are obtained to map the second image features to the vector space of the query, key, and value.
[0107] Step a2: multiply the second image feature with the query weight matrix, the key weight matrix and the value weight matrix respectively to obtain the corresponding query vector, key vector and value vector.
[0108] The second image feature is multiplied with the pre-defined query weight matrix, key weight matrix, and value weight matrix to generate the corresponding query vector, key vector, and value vector, which will be used for subsequent attention mechanism calculations.
[0109] Step a3, calculate the dot product of the query vector and the key vector, and determine the dot product as the attention score.
[0110] The attention score is used to characterize the similarity or correlation between the query vector and the key vector. Specifically, for each attention head h, the dot product of the query vector and the key vector is calculated, which can be expressed as Attention Score = QK T , the attention score determines how much attention to give to each part of the input sequence when generating each output element.
[0111] Step a4: perform weighted summation of the attention scores to obtain the single-head feature vector corresponding to each attention head.
[0112] The single-head feature vector is used to represent the integration and expression of each attention head on the input sequence (attention score) under a given query vector. Each attention head h will calculate an attention weight vector, which is used to weighted sum the value vector to obtain the single-head feature vector head i Specifically, for each head, the attention weight vector is calculated. The softmax function can be used to normalize the attention score, and the attention weight is used to perform weighted summation on the value vector to obtain the single head feature vector head i , that is, head i =Attention(QW i Q , W i K , VW i V ), where W i Q , W i K , W i V is the weight matrix corresponding to each head.
[0113] Step a5: merge the single-head feature vectors and perform linear transformation on the merged feature vectors to obtain multi-head feature vectors corresponding to multiple attention heads.
[0114] The single-head feature vectors of each attention head are concatenated to obtain a multi-head feature vector. The multi-head feature vector is converted into the final multi-head feature vector through linear transformation. Specifically, it can be obtained by MultiHead(Q, K, V) = Concat(head1, head2, ..., headh)WO To express, W O is the weight matrix of the output linear transformation.
[0115] In the above implementation, the self-attention mechanism allows the model to calculate the query, key, and value vectors for each position in parallel, so that the information of each part of the image can be processed simultaneously without being restricted by the position order. This global attention capability helps the model understand the image content without being affected by the position distance, thereby improving the global consistency and accuracy of feature extraction. By calculating the dot product of the query vector and the key vector and applying the weighted sum, the attention weight can be dynamically adjusted according to the importance of each position. This flexibility enables the model to focus on key information more effectively when processing complex image scenes, improving the accuracy and robustness of feature extraction. Multi-head feature vectors can be obtained by merging and linearly transforming the feature vectors generated by a single attention head. These multi-head feature vectors cover different focus points and perspectives, allowing the model to comprehensively utilize multiple attention heads for a deeper and more comprehensive analysis of image features. Through the multi-head self-attention mechanism, the model can more effectively extract and express the complex relationships and structures in image features. This enhanced feature representation capability helps to improve the performance of the model in visual tasks. The self-attention mechanism has a certain anti-interference ability when processing image features, and can effectively deal with interference and noise in local areas of the image, thereby improving the robustness and generalization ability of the model in complex backgrounds.
[0116] Step S3033, normalize the multi-head feature vector to obtain the corresponding second standard feature.
[0117] The second standard feature is a feature after the multi-head feature vector is normalized. Specifically, a group normalization (GN) layer is used to normalize the multi-head feature vector to obtain the second standard feature after group normalization and weighting.
[0118] Step S3034, weighting the second standard feature to obtain a corresponding second standard weight.
[0119] The second standard weight is used to characterize the importance or information content of each position in the second standard feature. Specifically, using the pre-established formula The second standard feature is weighted, where is the second standard weight calculated by the normalization operation.
[0120] Step S3035: Map the second standard weight to a preset interval through a preset function to obtain a corresponding second mapping weight.
[0121] The second mapping weight is the result of the second standard weight being processed by a preset function. Specifically, the second standard weight is mapped to a preset interval by a Sigmoid function or other designed functions to obtain a second mapping weight, which represents the weight value after standardization and mapping processing.
[0122] Step S3036: Determine the weights in the second mapping weights that are higher than the preset threshold as second information weights, and determine the weights in the second mapping weights that are lower than the preset threshold as second non-information weights.
[0123] The second information weight is the part of the second mapping weight that is higher than the preset threshold, that is, the weight containing useful and expressive spatial content. The second non-information weight is the part of the second mapping weight that is lower than the preset threshold, that is, the weight containing less or no information and spatial redundancy. Specifically, the gating function constrains the second mapping weight within a preset interval according to the output of the Sigmoid function. The gating function can be simply expressed as a threshold function, such as a Gate function, which sets the part of the second mapping weight that is greater than the preset threshold to 1 to form a second information weight; the part that is less than the preset threshold is set to 0 to form a second non-information weight.
[0124] In the image classification method provided by the embodiment of the present invention, the multi-head self-attention mechanism can simultaneously focus on the importance of different positions in the image features. This mechanism effectively captures the complex relationship between different parts of the image by calculating the attention weight between each position and other positions. The multi-head feature vector can characterize the information of the second image feature at different focus points, which means that it can treat the image features from multiple angles, thereby more comprehensively capturing the content and contextual information of the image. Normalizing the multi-head feature vector helps to maintain the stability and comparability of the feature vector. Scaling the feature vector to a similar numerical range avoids training instability or convergence difficulties caused by different numerical ranges. By adjusting the second standard feature by weighting, the influence of a specific part can be strengthened or weakened according to different tasks or requirements. The mapping process of the preset function can further optimize the distribution of weights to make it more in line with the needs and goals of specific applications. By setting a threshold, the second mapping weight can be divided into information weights and non-information weights. This helps the model to more effectively screen and utilize key information in subsequent processing, thereby improving the accuracy and efficiency of the task.
[0125] Step S304: creating a first target feature using the first image feature, the first information weight and the first non-information weight; and creating a second target feature using the second image feature, the second information weight and the second non-information weight.
[0126] Specifically, the above step S304 includes:
[0127] Step S3041: Create a first target feature using the first image feature, the first information weight, and the first non-information weight. Figure 1 Step S104 of the illustrated embodiment will not be described in detail here.
[0128] Step S3042: multiply the second image feature by the second information weight to obtain a second information feature, and multiply the second image feature by the second non-information weight to obtain a second non-information feature.
[0129] The second target feature includes a second information feature and a second non-information feature. Specifically, the second image feature is multiplied by the second information weight, and the information-valued portion selected by the second information weight is extracted from the second image feature. The second image feature is multiplied by the second non-information weight, and the non-information portion selected by the second non-information weight is extracted from the second image feature.
[0130] Step S305: merge the first target feature and the second target feature to obtain a merged feature; and spatially reconstruct the merged feature to obtain a spatially reconstructed feature. Figure 1 Step S105 of the illustrated embodiment will not be described in detail here.
[0131] Step S306, training the classifier according to the spatial reconstruction features; and obtaining the target cell image, inputting the target cell image into the trained classifier, and obtaining the classification result corresponding to the target cell image. Figure 1 Step S106 of the illustrated embodiment will not be described in detail here.
[0132] The image classification method provided by the embodiment of the present invention can effectively screen and distinguish important information and non-important information in the image by multiplying the second image feature with the information weight and the non-information weight. This operation helps the model focus on processing the most meaningful information part of the current cell image, thereby improving the efficiency and performance of the model. Distinguishing between the second information feature and the second non-information feature allows the model to more finely control the amount and quality of information processed. After generating the second information feature and the second non-information feature, the model can more effectively adapt to specific task requirements. By effectively processing these two types of information, the performance and generalization ability of the model in various visual tasks can be significantly improved. By separating the information features and non-information features, the model can be more efficient when processing large-scale image data. This optimization helps to reduce the computational burden and resource consumption of the model, and improve the overall processing speed and real-time performance.
[0133] In this embodiment, an image classification method is provided, which can be used in computer devices, such as desktop computers, notebook computers, etc. Figure 4 is a flowchart of an image classification method according to an embodiment of the present invention. Figure 4 As shown, the process includes the following steps:
[0134] Step S401, obtaining an original cell image; and segmenting the original cell image to obtain multiple image blocks. Figure 1 Step S101 of the illustrated embodiment will not be described in detail here.
[0135] Step S402: extract the corresponding first image features from the original cell image, and extract the corresponding second image features from the multiple image blocks. Figure 3 Step S302 of the illustrated embodiment will not be described in detail here.
[0136] Step S403, weight separation processing is performed on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the spatial content part containing useful and strong expression in the image feature, and the non-information weight is used to characterize the spatial content part containing less or no information in the image feature. For details, please refer to Figure 2 Step S203 of the illustrated embodiment and Figure 3 Step S303 of the illustrated embodiment will not be described in detail here.
[0137] Step S404: Create a first target feature using the first image feature, the first information weight and the first non-information weight; and create a second target feature using the second image feature, the second information weight and the second non-information weight. Figure 2 Step S204 of the illustrated embodiment and Figure 3 Step S304 of the illustrated embodiment will not be described in detail here.
[0138] Step S405: merge the first target feature and the second target feature to obtain a merged feature; and spatially reconstruct the merged feature to obtain a spatially reconstructed feature.
[0139] Specifically, the above step S405 includes:
[0140] Step S4051, using a convolutional layer to perform feature fusion on the first information feature and the second information feature to obtain a first fused feature; and perform feature fusion on the first non-information feature and the second non-information feature to obtain a second fused feature.
[0141] The first fused feature contains the comprehensive information of the first information feature and the second information feature. Specifically, the first information feature and the second information feature are fused using a convolutional layer to obtain the first fused feature. The convolutional layer can be regarded as a tool for combining two features, and its parameters are learnable weights.
[0142] The second fused feature includes comprehensive information of the first non-information feature and the second non-information feature. Specifically, the first non-information feature and the second non-information feature are fused using a convolutional layer to obtain the second fused feature.
[0143] Step S4052, merge the first fusion feature and the second fusion feature, and perform convolution processing on the merged feature to obtain a merged feature.
[0144] The first fusion feature and the second fusion feature are merged, and the first fusion feature and the second fusion feature are connected in the channel dimension to form a larger feature map. The merged feature map is convolved. The convolution operation includes selecting the appropriate convolution kernel size, stride, padding method and activation function to effectively extract and integrate feature information. The final merged feature is the result obtained after the convolution process. It integrates the information in the first fusion feature and the second fusion feature, and is a more abstract and advanced feature representation.
[0145] Step S4053, performing weight separation processing on the merged feature to obtain a third information weight and a third non-information weight corresponding to the merged feature.
[0146] The merged features are normalized to obtain the corresponding third standard features. The third standard features are weighted to obtain the corresponding third standard weights. The third standard weights are mapped to the preset intervals through a preset function to obtain the corresponding third mapping weights. The weights in the third mapping weights that are higher than the preset threshold are determined as the third information weights, and the weights in the third mapping weights that are lower than the preset threshold are determined as the third non-information weights. That is, the third information weights are the parts of the third mapping weights that are higher than the preset threshold, that is, the weights that contain useful and expressive spatial content. The third non-information weights are the parts of the third mapping weights that are lower than the preset threshold, that is, the weights that contain less or no information and spatial redundancy.
[0147] Step S4054: multiply the combined feature by the third information weight to obtain a third information feature, and multiply the combined feature by the third non-information weight to obtain a third non-information feature.
[0148] Multiply the combined feature by the third information weight to obtain the third information feature That is, it can be understood as extracting the information-valued part of the combined feature selected by the third information weight. Multiply the combined feature by the third non-information weight to obtain the third non-information feature It can also be understood as extracting the non-information part selected by the third non-information weight in the combined feature.
[0149] Step S4055: split the third information feature into a first information sub-feature and a second information sub-feature, and split the third non-information feature into a third information sub-feature and a fourth information sub-feature.
[0150] First information sub-feature From the third information feature This part of the feature can contain information of a specific type or attribute, such as certain visual features of a specific object. From the third information feature Another part separated from the first information sub-feature, which can contain information of different types or attributes, can be Complement or supplement to some extent.
[0151] The third information sub-feature is from the third non-informative feature Although it comes from the non-information part, it can still contain some useful information or a part with smaller error due to the splitting. is from the third non-informative feature This part of the features can contain another type of useless information, such as noise, background or other content irrelevant to the task.
[0152] Step S4056, adding the first information sub-feature and the fourth information sub-feature element by element to obtain a first cross-feature; and adding the second information sub-feature and the third information sub-feature element by element to obtain a second cross-feature.
[0153] The first cross feature combines information from different subsets of the third information feature and the third non-information feature by element-by-element addition. Specifically, the first information sub-feature and the fourth information sub-feature are added element-by-element to obtain the first cross feature.
[0154] The second cross feature also combines information from different subsets of the third information feature and the third non-information feature by element-by-element addition. Specifically, the corresponding elements in the second information sub-feature and the third information sub-feature are added to obtain the second cross feature.
[0155] Step S4057: merge the first cross feature and the second cross feature to obtain a spatial reconstruction feature.
[0156] The first cross feature and the second cross feature are spliced to form the final spatial reconstruction feature. To express.
[0157] Step S406, training the classifier according to the spatial reconstruction features; and obtaining the target cell image, inputting the target cell image into the trained classifier, and obtaining the classification result corresponding to the target cell image. Figure 1 Step S106 of the illustrated embodiment will not be described in detail here.
[0158] The image classification method provided by the embodiment of the present invention can effectively integrate feature information of different sources and properties by fusing the first information feature and the second information feature through the convolution layer, and fusing the first non-information feature and the second non-information feature. This fusion helps to comprehensively utilize the advantages of multiple feature sources and improve the model's ability to express and analyze complex image information. The first fused feature and the second fused feature are merged and the merged feature is obtained through convolution processing, so that the model can express image features in a rich way from multiple aspects. This information complementarity and richness help reduce information loss and error propagation, and improve the model's comprehensive understanding and processing capabilities of image content. By processing the spliced features through the convolution layer, the spatial information of the features can be effectively extracted and enhanced. The convolution operation has local perception ability and parameter sharing characteristics, which can effectively reduce the number of parameters and computational complexity, while improving the accuracy and stability of feature representation. By performing weight separation processing on the merged features, the third information weight and the third non-information weight are generated respectively, and the influence of different types of features in subsequent processing can be finely controlled. This refined feature weighting helps the model to more effectively distinguish and utilize important and non-important information in the image, thereby improving the performance and robustness of the model in processing complex visual tasks. The merged feature is multiplied by the third information weight and the third non-information weight respectively to generate the third information feature and the third non-information feature, and they are further split into multiple information sub-features and non-information sub-features, which can enhance the model's ability to understand different levels and angles of image content, enabling the model to more comprehensively analyze and process input data. The first information sub-feature and the fourth information sub-feature are added element by element, and the second information sub-feature and the third information sub-feature are added element by element to generate the first cross feature and the second cross feature. This cross feature generation can capture the interaction and correlation between different information subsets, which helps to improve the performance and generalization ability of the model in complex scenes. The first cross feature and the second cross feature are merged to generate a spatial reconstruction feature, which integrates information from different information sub-features and cross features to form a more comprehensive and comprehensive feature representation. This spatial reconstruction feature helps to improve the model's ability to understand the overall structure and spatial layout of the image, thereby improving the effect and accuracy of the model in image processing tasks.
[0159] In this embodiment, an image classification device is also provided, which is used to implement the above-mentioned embodiments and preferred implementation modes, and the descriptions that have been made will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and conceivable.
[0160] This embodiment provides an image classification device, such as Figure 5 As shown, including:
[0161] The acquisition module 501 is used to acquire the original cell image; and segment the original cell image to obtain multiple image blocks.
[0162] The extraction module 502 is used to extract the corresponding first image features from the original cell image, and to extract the corresponding second image features from the plurality of image blocks.
[0163] Processing module 503 is used to perform weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize the part of the image feature that contains the target space content, and the non-information weight is used to characterize the part of the image feature that does not contain the target space content or the proportion of the target space content is less than a preset value.
[0164] The creation module 504 is used to create a first target feature using the first image feature, the first information weight and the first non-information weight; and to create a second target feature using the second image feature, the second information weight and the second non-information weight.
[0165] The merging module 505 is used to merge the first target feature and the second target feature to obtain a merged feature; and to spatially reconstruct the merged feature to obtain a spatially reconstructed feature.
[0166] The classification module 506 is used to train the classifier according to the spatial reconstruction features; and obtain the target cell image, input the target cell image into the trained classifier, and obtain the classification result corresponding to the target cell image.
[0167] In some optional implementations, the processing module 503 includes:
[0168] The first normalization submodule is used to perform normalization processing on the first image feature to obtain a corresponding first standard feature.
[0169] The first weighting submodule is used to weight the first standard feature to obtain a corresponding first standard weight.
[0170] The first mapping submodule is used to map the first standard weight to a preset interval through a preset function to obtain a corresponding first mapping weight.
[0171] The first determination submodule is used to obtain a preset threshold; and determine the weights in the first mapping weights that are higher than the preset threshold as first information weights, and determine the weights in the first mapping weights that are lower than the preset threshold as first non-information weights.
[0172] In some optional implementations, the first target feature includes a first information feature and a first non-information feature; the creation module 504 includes:
[0173] The first calculation submodule is used to obtain a first information feature by multiplying the first image feature by the first information weight, and to obtain a first non-information feature by multiplying the first image feature by the first non-information weight.
[0174] In some optional implementations, the extraction module 502 includes:
[0175] The acquisition submodule is used to acquire position encoding vectors corresponding to multiple image blocks, and perform linear projection on the multiple image blocks to obtain projection vectors corresponding to the multiple image blocks.
[0176] The calculation submodule is used to add the projection vector and the position encoding vector to obtain second image features corresponding to the multiple image blocks.
[0177] In some optional implementations, the processing module 503 further includes:
[0178] The first processing submodule is used to process the second image feature according to the multi-head self-attention mechanism to obtain a multi-head feature vector; wherein the multi-head feature vector is used to characterize the information of the second image feature at different focus points.
[0179] The second normalization submodule is used to normalize the multi-head feature vector to obtain the corresponding second standard feature.
[0180] The second weighting submodule is used to weight the second standard feature to obtain a corresponding second standard weight.
[0181] The second mapping submodule is used to map the second standard weight to a preset interval through a preset function to obtain a corresponding second mapping weight.
[0182] The second determining submodule is used to determine the weights in the second mapping weights that are higher than a preset threshold as second information weights, and to determine the weights in the second mapping weights that are lower than the preset threshold as second non-information weights.
[0183] In some optional implementations, the processing submodule includes:
[0184] The acquisition unit is used to acquire a preset query weight matrix, a key weight matrix, and a value weight matrix.
[0185] The first calculation unit is used to multiply the second image feature with the query weight matrix, the key weight matrix and the value weight matrix respectively to obtain the corresponding query vector, key vector and value vector.
[0186] The second computing unit is configured to compute a dot product between the query vector and the key vector, and determine the dot product as an attention score.
[0187] The third computing unit is used to perform weighted summation of the attention scores to obtain a single-head feature vector corresponding to each attention head.
[0188] The merging unit is used to merge the single-head feature vectors and perform linear transformation on the merged feature vectors to obtain multi-head feature vectors corresponding to multiple attention heads.
[0189] In some optional implementations, the second target feature includes a second information feature and a second non-information feature; the creation module 504 further includes:
[0190] The second calculation submodule is used to obtain a second information feature by multiplying the second image feature by the second information weight, and to obtain a second non-information feature by multiplying the second image feature by the second non-information weight.
[0191] In some optional implementations, the merging module 505 includes:
[0192] The fusion submodule is used to use the convolution layer to perform feature fusion on the first information feature and the second information feature to obtain a first fused feature; and to perform feature fusion on the first non-information feature and the second non-information feature to obtain a second fused feature.
[0193] The first merging submodule is used to merge the first fusion feature and the second fusion feature, and perform convolution processing on the merged feature to obtain a merged feature.
[0194] In some optional implementations, the merging module 505 further includes:
[0195] The second processing submodule is used to perform weight separation processing on the merged features to obtain a third information weight and a third non-information weight corresponding to the merged features.
[0196] The third calculation submodule is used to obtain a third information feature by multiplying the combined feature with the third information weight, and to obtain a third non-information feature by multiplying the combined feature with the third non-information weight.
[0197] A splitting submodule, used to split the third information feature into a first information sub-feature and a second information sub-feature, and split the third non-information feature into a third information sub-feature and a fourth information sub-feature;
[0198] The fourth calculation submodule is used to add the first information sub-feature and the fourth information sub-feature element by element to obtain a first cross-feature; and to add the second information sub-feature and the third information sub-feature element by element to obtain a second cross-feature.
[0199] The second merging submodule is used to merge the first cross feature and the second cross feature to obtain a spatial reconstruction feature.
[0200] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0201] The image classification device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0202] The image classification device provided by the embodiment of the present invention can extract multiple image blocks by acquiring the original cell image and segmenting it, which is helpful for processing large-scale data and improving processing efficiency. Extracting image features from the original cell image and its segmented image blocks can capture visual information of different scales and levels, which is conducive to subsequent analysis and processing. Weight separation of image features and separate processing of information weights and non-information weights can help reduce the influence of noise and redundant information, improve the expressiveness of features and the accuracy of classification. Using information weights and non-information weights to create target features and merge target features from different sources can comprehensively utilize information of different levels and types to improve the effect of classification and recognition. Training the classifier through spatial reconstruction features can make full use of the spatial information of the image and improve the generalization ability and accuracy of the classifier for target cell images. Applying the trained classifier to the target cell image can achieve rapid classification and recognition of unknown cell image data, and can effectively improve the accuracy and efficiency of cell image classification and recognition tasks.
[0203] The embodiment of the present invention also provides a computer device having the above Figure 5 The image classification device shown.
[0204] See also Figure 6 , Figure 6 is a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, such as Figure 6As shown, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. Various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process the instructions executed in the computer device, including instructions stored in or on the memory to display the graphical information of the GUI on an external input / output device (such as, a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 6 A processor 10 is taken as an example.
[0205] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0206] The memory 20 stores instructions executable by at least one processor 10, so that the at least one processor 10 executes the method shown in the above embodiment.
[0207] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0208] The memory 20 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 20 may also include a combination of the above types of memory.
[0209] The computer device also includes an input device 30 and an output device 40. The processor 10, the memory 20, the input device 30 and the output device 40 may be connected via a bus or other means. Figure 6 The example of connecting through bus is taken in the following.
[0210] The input device 30 can receive input digital or character information, and generate key signal input related to the user settings and function control of the computer device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 40 may include a display device, an auxiliary lighting device (e.g., an LED) and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display and a plasma display. In some optional embodiments, the display device can be a touch screen.
[0211] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0212] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0213] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the appended claims.
Claims
1. An image classification method, It is characterized in that The method comprises: Acquiring an original cell image; and segmenting the original cell image to obtain a plurality of image blocks; Extracting a corresponding first image feature from the original cell image, and extracting a corresponding second image feature from the plurality of image blocks; The first image feature and the second image feature are subjected to weight separation processing to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize that the image feature contains a target space content portion, and the non-information weight is used to characterize that the image feature does not contain the target space content portion or the proportion of the target space content portion is less than a preset value; Creating a first target feature using the first image feature, the first information weight, and the first non-information weight; and creating a second target feature using the second image feature, the second information weight, and the second non-information weight; Merging the first target feature and the second target feature to obtain a merged feature; and spatially reconstructing the merged feature to obtain a spatially reconstructed feature; The classifier is trained according to the spatial reconstruction feature; and a target cell image is acquired, and the target cell image is input into the trained classifier to obtain a classification result corresponding to the target cell image.
2. The method according to claim 1, It is characterized in that Performing weight separation processing on the first image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature includes: Normalizing the first image feature to obtain a corresponding first standard feature; weighting the first standard feature to obtain a corresponding first standard weight; Mapping the first standard weight to a preset interval through a preset function to obtain a corresponding first mapping weight; Obtaining a preset threshold; and determining the weights of the first mapping weights that are higher than the preset threshold as the first information weights, and determining the weights of the first mapping weights that are lower than the preset threshold as the first non-information weights.
3. The method according to claim 2, It is characterized in that The first target feature includes a first information feature and a first non-information feature; Creating a first target feature using the first image feature, the first information weight, and the first non-information weight includes: The first information feature is obtained by multiplying the first image feature by a first information weight, and the first non-information feature is obtained by multiplying the first image feature by a first non-information weight.
4. The method according to claim 1, It is characterized in that Extracting corresponding second image features from the multiple image blocks includes: Obtaining position encoding vectors corresponding to the multiple image blocks, and performing linear projection on the multiple image blocks to obtain projection vectors corresponding to the multiple image blocks; The projection vector and the position encoding vector are added to obtain the second image features corresponding to the multiple image blocks.
5. The method according to claim 4, It is characterized in that Performing weight separation processing on the second image feature to obtain a second information weight and a second non-information weight corresponding to the second image feature includes: Processing the second image feature according to the multi-head self-attention mechanism to obtain a multi-head feature vector; wherein the multi-head feature vector is used to represent information of the second image feature at different focus points; Normalizing the multi-head feature vector to obtain a corresponding second standard feature; weighting the second standard feature to obtain a corresponding second standard weight; Mapping the second standard weight to a preset interval through a preset function to obtain a corresponding second mapping weight; The weights of the second mapping weights that are higher than a preset threshold are determined as the second information weights, and the weights of the second mapping weights that are lower than the preset threshold are determined as the second non-information weights.
6. The method according to claim 5, It is characterized in that The processing of the second image feature according to the multi-head self-attention mechanism to obtain a multi-head feature vector includes: Obtaining a preset query weight matrix, a key weight matrix, and a value weight matrix; Multiplying the second image feature with the query weight matrix, the key weight matrix and the value weight matrix respectively to obtain a corresponding query vector, a key vector and a value vector; Calculating a dot product of the query vector and the key vector, and determining the dot product as an attention score; Performing weighted summation on the attention scores to obtain a single-head feature vector corresponding to each attention head; The single-head feature vectors are merged, and the merged feature vectors are linearly transformed to obtain the multi-head feature vectors corresponding to the multiple attention heads.
7. The method according to claim 6, It is characterized in that The second target feature includes a second information feature and a second non-information feature; Creating a second target feature using the second image feature, the second information weight, and the second non-information weight includes: The second information feature is obtained by multiplying the second image feature by the second information weight, and the second non-information feature is obtained by multiplying the second image feature by the second non-information weight.
8. The method according to claim 3 or 7, It is characterized in that The first target feature and the second target feature are combined to obtain a combined feature, including: Using a convolutional layer to perform feature fusion on the first information feature and the second information feature to obtain a first fused feature; and performing feature fusion on the first non-information feature and the second non-information feature to obtain a second fused feature; The first fusion feature and the second fusion feature are merged, and convolution processing is performed on the merged feature to obtain a merged feature.
9. The method according to claim 8, It is characterized in that The combined features are spatially reconstructed to obtain spatially reconstructed features, including: Performing weight separation processing on the combined feature to obtain a third information weight and a third non-information weight corresponding to the combined feature; The third information feature is obtained by multiplying the combined feature by the third information weight, and the third non-information feature is obtained by multiplying the combined feature by the third non-information weight; Splitting the third information feature into a first information sub-feature and a second information sub-feature, and splitting the third non-information feature into a third information sub-feature and a fourth information sub-feature; Adding the first information sub-feature and the fourth information sub-feature element by element to obtain a first cross-feature; and adding the second information sub-feature and the third information sub-feature element by element to obtain a second cross-feature; The first intersection feature and the second intersection feature are combined to obtain the spatial reconstruction feature.
10. An image classification device, It is characterized in that The device comprises: An acquisition module, used for acquiring an original cell image; and segmenting the original cell image to obtain a plurality of image blocks; An extraction module, configured to extract a corresponding first image feature from the original cell image, and to extract a corresponding second image feature from the plurality of image blocks; a processing module, configured to perform weight separation processing on the first image feature and the second image feature to obtain a first information weight and a first non-information weight corresponding to the first image feature, and a second information weight and a second non-information weight corresponding to the second image feature; wherein the information weight is used to characterize that the image feature contains a target space content portion, and the non-information weight is used to characterize that the image feature does not contain the target space content portion or the proportion of the target space content portion is less than a preset value; A creation module, configured to create a first target feature using the first image feature, the first information weight, and the first non-information weight; and to create a second target feature using the second image feature, the second information weight, and the second non-information weight; A merging module, configured to merge the first target feature and the second target feature to obtain a merged feature; and spatially reconstruct the merged feature to obtain a spatially reconstructed feature; The classification module is used to train a classifier according to the spatial reconstruction features; and obtain a target cell image, input the target cell image into the trained classifier, and obtain a classification result corresponding to the target cell image.
11. A computer device, It is characterized in that include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the image classification method according to any one of claims 1 to 9 by executing the computer instructions.
12. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the image classification method according to any one of claims 1 to 9.
13. A computer program product, It is characterized in that The method comprises computer instructions for causing a computer to execute the image classification method according to any one of claims 1 to 9.
Citation Information
Patent Citations
Classification method and device, electronic equipment, computer storage medium and program
CN108229341A
Pathological images classification method based on deep neural network and pathological images classification device based on deep neural network
CN108647732A
Pathological image processing method and device, storage medium and processor
CN112017162A
Classification model training method, image-based classification method and related device
CN113159085A
Weak supervision cervical cell image analysis method fusing global and local information
CN113378792A
