Medical image classification method and system based on global and local information fusion
The dual-focused attention Vision Transformer network model extracts global and local features in medical image classification, solving the problem of existing methods ignoring local information and achieving efficient medical image classification.
Patent Information
- Application Number
- CN202410686067.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-30
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2044-05-30
AI Technical Summary
Existing medical image classification methods ignore fine-grained local information when capturing global semantic information, and due to the large number of parameters and high complexity, it is difficult to achieve efficient computational medical image classification.
The dual-focus attention Vision Transformer network model is used to extract global and local features through the dual-stream method and the re-focus attention mechanism, and fuse them by channel to form a global-local fusion feature map.
It improves the accuracy of medical image classification, reduces the amount of calculation, and achieves efficient medical image classification.
Smart Images

Figure CN118691875A
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image classification, and more particularly to a medical image classification method and system based on global and local information fusion. Background Art
[0002] Medical image classification tasks remain challenging due to the high similarity and detail diversity of medical images in imaging methods, which leads to significant intra-class differences and inter-class similarities. Existing medical image classification methods can be divided into two directions, one is the model based on convolutional neural networks, and the other is the model based on visual Transformer. The multi-head self-attention mechanism can capture long-range dependencies and model global semantic information of images. At the same time, it provides a built-in saliency that can provide insight into what the model focuses on.
[0003] However, some existing models based on visual Transformer ignore fine-grained local information and have high parameter count and complexity. At the same time, since the attention mechanism lacks the local bias inherent in the convolutional network, it is easy to lose local key information. Some methods try to introduce convolution into the Transformer to solve this problem, but ignore the inherent prior information of the attention operation itself. Although the dual network combines CNN and Transformer for local and global feature extraction, the parallel framework leads to a large number of parameters and an overly complex network. Therefore, how to provide a medical image classification method that can be both efficient and computationally low is an urgent problem that technicians in this field need to solve. Summary of the invention
[0004] In view of this, the present invention provides a medical image classification method and system based on global and local information fusion, which overcomes the above-mentioned defects.
[0005] In order to achieve the above object, the present invention adopts the following technical solution:
[0006] A medical image classification method based on global and local information fusion, the specific steps are:
[0007] Acquiring a medical image to be classified, and preprocessing the medical image to be classified to obtain a preprocessed image;
[0008] Inputting the preprocessed image into a medical image classification model to obtain category information of the preprocessed image; the medical image classification model includes a feature extraction module and a prediction module, and the feature extraction module adopts a dual-focus attention Vision Transformer network model;
[0009] The category information is output.
[0010] Optionally, the steps of constructing the medical image classification model are:
[0011] Collecting medical images and constructing a data set based on the medical images;
[0012] Constructing an initial medical image classification model including the feature extraction module and the prediction module, wherein the feature extraction module adopts a dual-focus attention Vision Transformer network model;
[0013] The initial medical image classification model is iteratively trained using the medical images in the data set until an iteration stop condition is reached, and the medical image classification model is output.
[0014] Optionally, the feature extraction step is:
[0015] Extracting features from the preprocessed image according to preset dimensions and depths to obtain an initial feature image;
[0016] Extracting features from the initial feature image using a dual-stream method to obtain a first initial feature map and a second initial feature map;
[0017] Downsampling and projecting the first initial feature map to obtain downsampled mapping features, and inputting the downsampled mapping features into a standard attention mechanism to obtain a global feature matrix;
[0018] Applying the global feature matrix to the second initial feature map to obtain a routing index matrix;
[0019] Obtaining a key value Key and a weight value Value of the refocusing area according to the routing index matrix, and inputting the key value Key and the weight value Value of the refocusing area into a refocusing attention mechanism to extract fine-grained local features;
[0020] The fine-grained local features and the global features are fused by channel to obtain a global-local fused feature map.
[0021] Optionally, the routing index matrix is expressed as:
[0022] I = topkIndex(A, k);
[0023] Where I represents the routing index matrix, A represents the global feature matrix, k represents the number of refocused regions, and topkIndex(·) represents the index value of the region with a higher value in the global feature map.
[0024] Optionally, the expression of the fine-grained local feature is:
[0025] Y'=Attention(Qy ,K g ,V g );
[0026] In the formula, K g ,V g Respectively represent the key value Key and weight value Value of the refocus area, Q y Represents the query value Query of the global feature matrix A.
[0027] A medical image classification system based on global and local information fusion, comprising:
[0028] An image acquisition module, used for acquiring a medical image to be classified, and preprocessing the medical image to be classified to obtain a preprocessed image;
[0029] An image classification module, used for inputting the preprocessed image into a medical image classification model to obtain category information of the preprocessed image; the medical image classification model includes a feature extraction module and a prediction module, and the feature extraction module adopts a dual-focus attention VisionTransformer network model;
[0030] An image output module is used to output the category information.
[0031] Optionally, the image classification module includes a medical image classification model training module, and the medical image classification model training module includes:
[0032] A data set construction module, used for collecting medical images and constructing a data set based on the medical images;
[0033] A classification model building module, used to build an initial medical image classification model including a feature extraction module and a prediction module, wherein the feature extraction module adopts a dual-focus attention Vision Transformer network model;
[0034] The classification model training module is used to iteratively train the initial medical image classification model using the medical images in the data set until an iteration stop condition is reached, and output the medical image classification model.
[0035] Optionally, the feature extraction module includes multiple groups of position embedding modules and dual focus attention modules;
[0036] The position embedding module is used to change the dimension of the feature and deepen the depth of the feature extraction network;
[0037] The dual focus attention module is used to obtain an inter-layer-intra-layer fusion feature map based on a multi-head self-attention operation.
[0038] Optionally, the dual-focus attention module includes a global feature extraction module, a refocused fine-grained local feature extraction module and a feature fusion module;
[0039] The global feature extraction module is used to obtain global features based on downsampling, projection and standard attention mechanism;
[0040] The refocusing fine-grained local feature extraction module is used to obtain the key value Key and the weight value Value of the refocusing area according to the routing index matrix of the refocusing area, and input the key value Key and the weight value Value of the refocusing area into the refocusing attention mechanism to extract fine-grained local features;
[0041] The feature fusion module is used to fuse the fine-grained local feature information and the global feature by channel to obtain a global-local fusion feature map.
[0042] Optionally, the feature fusion module includes deep convolution and point convolution, the deep convolution is used to fuse the fine-grained local feature information and the global features in any channel; the point convolution is used to fuse the fine-grained local feature information and the global features between different channels.
[0043] It can be seen from the above technical solution that compared with the prior art, the present invention discloses a medical image classification method and system based on global and local information fusion, which effectively captures and fuses the global features and local features in the image by constructing a dual-focus attention Vision Transformer network model, thereby improving the accuracy of medical image classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0045] Figure 1 It is a schematic diagram of the method flow of the present invention;
[0046] Figure 2 It is a structural schematic diagram of the extraction module of the present invention;
[0047] Figure 3 It is a schematic diagram of the structure of the dual-focus attention module of the present invention. DETAILED DESCRIPTION
[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0049] On the one hand, an embodiment of the present invention discloses a medical image classification method based on global and local information fusion, the steps are as follows: Figure 1 As shown, specifically:
[0050] Step 1, obtaining a medical image to be classified, and preprocessing the medical image to be classified to obtain a preprocessed image;
[0051] Step 2: Input the preprocessed image into the medical image classification model to obtain the category information of the preprocessed image; the medical image classification model includes a feature extraction module and a prediction module, and the feature extraction module adopts a dual-focus attention VisionTransformer network model;
[0052] Step 3: Output the category information.
[0053] In one embodiment, the steps of constructing a medical image classification model are:
[0054] Step 211: collect medical images and construct a data set based on the medical images;
[0055] Step 212: construct an initial medical image classification model including a feature extraction module and a prediction module, wherein the feature extraction module adopts a dual-focus attention Vision Transformer network model;
[0056] Step 213: Iteratively train the initial medical image classification model using the medical images in the data set until the iteration stop condition is reached, and output the medical image classification model.
[0057] Furthermore, the medical images were preprocessed when constructing the dataset, that is, the size of the medical images was adjusted to 224 pixels × 224 pixels.
[0058] Furthermore, during iterative training, the prediction results are evaluated by the cross entropy loss function, and the dual-focus attention Vision Transformer network model is trained to obtain a trained medical image classification model.
[0059] In one embodiment, the steps of extracting features by the feature extraction module are as follows:
[0060] Step 221, extracting features from the preprocessed image according to preset dimensions and depths to obtain an initial feature image;
[0061] Step 222, extracting features from the initial feature image using a dual-stream method to obtain a first initial feature map and a second initial feature map;
[0062] Step 223: downsample and project the first initial feature map to obtain downsampled mapping features, and input the downsampled mapping features into the standard attention mechanism to obtain a global feature matrix;
[0063] Step 224: Apply the global feature matrix to the second initial feature map to obtain a routing index matrix;
[0064] Step 225: Obtain the key value Key and the weight value Value of the refocusing area according to the routing index matrix, and input the key value Key and the weight value Value of the refocusing area into the refocusing attention mechanism to extract fine-grained local features;
[0065] Step 226: Fuse the fine-grained local features and the global features by channel to obtain a global-local fused feature map.
[0066] Further, in step 222, the dual-stream method is: copying the initial feature image to obtain two identical feature maps, which are defined as a first initial feature map and a second initial feature map respectively;
[0067] Step 223 is specifically as follows: for any one of the feature maps, a downsampled feature map is obtained by window downsampling, and then a global stream attention operation is performed; the expression of the global stream attention operation is:
[0068] X'=Attention(Q x ,K x ,V x );
[0069] Among them, X' represents the extracted global features, Attention(·) represents the standard attention mechanism, and Q x ,K x ,V x They respectively represent the query value Query, key value Key and weight value Value corresponding to the downsampled feature map;
[0070] In step 224, the global feature matrix of the global stream attention operation is applied to another feature map to obtain a routing index matrix with high correlation between regions to facilitate re-focusing; the expression of the routing index matrix is:
[0071] I = topkIndex(A, k);
[0072] Where I represents the routing index matrix, A represents the feature matrix (i.e., the global feature matrix) obtained by performing similarity operations on the query value Query and the key value Value in the standard attention mechanism, which contains the correlation information value between regions, k represents the number of refocused regions, and topkIndex(·) represents obtaining the region index value with a higher value in the global feature matrix A;
[0073] In step 225, according to the index matrix of the refocused area, the key value Key and the weight value Value corresponding to the refocused area are obtained, and input into the refocused attention mechanism to extract fine-grained local features; the fine-grained extraction process expression is:
[0074] K g =gather(K y ,I),V g =gather(V y ,I);
[0075] Among them, K g ,V g represents the key value Key and weight value Value corresponding to the refocusing area respectively, gather(·) represents the aggregation operation of the key value Key and weight value Value corresponding to the refocusing area according to the routing index matrix, K y ,V y They respectively represent the key value Key and weight value Value corresponding to the original input feature map;
[0076] Y'=Attention(Q y ,K g ,V g );
[0077] Among them, Y' represents the extracted fine-grained local features, Q y Indicates the query value Query corresponding to the original input feature map.
[0078] Furthermore, the specific process of the feature extraction module includes: constructing a dual-focus attention VisionTransformer network model, which adopts a pyramid structure, successively halves the size of the input feature map and doubles the channels, to obtain multi-scale feature maps T1, T2, T3 and T4 of different depths, and uses feature map T4 as the output of the feature extraction module.
[0079] In one embodiment, the specific process of the feature fusion module is as follows:
[0080] The global feature information is sequentially subjected to upsampling operations and deep convolution operations to align feature dimensions and organizational features;
[0081] The fine-grained local feature information and the global feature map are added channel by channel, and the two streams are merged by applying depthwise convolution and pointwise convolution to integrate the information.
[0082] In one embodiment, the generated fusion feature map is input into a prediction module, and the final classification category information of the image is obtained according to the prediction score result.
[0083] In one embodiment, an evaluation training module is also included, which uses a total loss function to evaluate the obtained prediction results and train the network model.
[0084] On the other hand, this embodiment also discloses a medical image classification system based on global and local information fusion, including:
[0085] An image acquisition module is used to acquire the medical image to be classified and preprocess the medical image to be classified to obtain a preprocessed image;
[0086] An image classification module is used to input the preprocessed image into a medical image classification model to obtain category information of the preprocessed image; the medical image classification model includes a feature extraction module and a prediction module, and the feature extraction module adopts a dual-focus attention Vision Transformer network model;
[0087] Image output module, used to output category information.
[0088] In one embodiment, the image classification module further includes a medical image classification model training module, and the medical image classification model training module includes:
[0089] A data set construction module, used for collecting medical images and constructing a data set based on the medical images;
[0090] The classification model building module is used to build an initial medical image classification model including a feature extraction module and a prediction module. The feature extraction module adopts a dual-focus attention Vision Transformer network model;
[0091] The classification model training module is used to iteratively train the initial medical image classification model using the medical images in the data set; until the iteration stop condition is reached, the medical image classification model is output.
[0092] In one embodiment, if Figure 2 As shown, the feature extraction module includes multiple groups of position embedding modules and dual focus attention modules;
[0093] Position embedding module, used to embed position information, change the dimension of features and deepen the depth of feature extraction network;
[0094] A dual-focus attention module is used to obtain inter-layer-intra-layer fused feature maps based on multi-head self-attention operations.
[0095] In one embodiment, if Figure 3 As shown, the dual-focus attention module includes a global feature extraction module, a refocused fine-grained local feature extraction module, and a feature fusion module;
[0096] The global feature extraction module is used to obtain global features based on downsampling, projection, and standard attention mechanism;
[0097] A refocusing fine-grained local feature extraction module is used to obtain the key value Key and the weight value Value of the refocusing area according to the routing index matrix of the refocusing area, and input the key value Key and the weight value Value of the refocusing area into the refocusing attention mechanism to extract fine-grained local features;
[0098] The feature fusion module is used to fuse the fine-grained local feature information and the global features by channel to obtain a global-local fusion feature map.
[0099] In one embodiment, the feature fusion module includes deep convolution and point convolution. The deep convolution is used to fuse the fine-grained local feature information and the global features in any channel; the point convolution is used to fuse the fine-grained local feature information and the global features between different channels.
[0100] In this embodiment, Figure 2 The dashed boxes in the middle represent multi-scale feature extraction modules of different depths. Each module includes an image position embedding module and a feature extraction fusion block. Figure 3 Down-sampling represents the downsampling operation of the image; the ordinary attention module is used to extract the global feature information of the image; the refocusing attention module is used to extract the fine-grained local feature information of the image; the feature fusion module includes deep convolution and point convolution operations, deep convolution is used to integrate the information within the channel, and point convolution is used to integrate the information between different channels, thereby integrating global features and local feature information.
[0101] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0102] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present invention. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention will not be limited to the embodiments shown herein, but rather to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A medical image classification method based on global and local information fusion, characterized in that: The specific steps are: Acquiring a medical image to be classified, and preprocessing the medical image to be classified to obtain a preprocessed image; Inputting the preprocessed image into a medical image classification model to obtain category information of the preprocessed image; the medical image classification model includes a feature extraction module and a prediction module, and the feature extraction module adopts a dual-focus attention Vision Transformer network model; The category information is output.
2. A medical image classification method based on global and local information fusion according to claim 1, characterized in that: The steps of constructing the medical image classification model are: Collecting medical images and constructing a data set based on the medical images; Constructing an initial medical image classification model including the feature extraction module and the prediction module, wherein the feature extraction module adopts a dual-focus attention Vision Transformer network model; The initial medical image classification model is iteratively trained using the medical images in the data set until an iteration stop condition is reached, and the medical image classification model is output.
3. The medical image classification method based on global and local information fusion according to claim 1, characterized in that: The feature extraction steps are: Extracting features from the preprocessed image according to preset dimensions and depths to obtain an initial feature image; Extracting features from the initial feature image using a dual-stream method to obtain a first initial feature map and a second initial feature map; Downsampling and projecting the first initial feature map to obtain downsampled mapping features, and inputting the downsampled mapping features into a standard attention mechanism to obtain a global feature matrix; Applying the global feature matrix to the second initial feature map to obtain a routing index matrix; Obtaining a key value Key and a weight value Value of the refocusing area according to the routing index matrix, and inputting the key value Key and the weight value Value of the refocusing area into a refocusing attention mechanism to extract fine-grained local features; The fine-grained local features and global features are fused by channel to obtain a global-local fused feature map.
4. The medical image classification method based on global and local information fusion according to claim 3, characterized in that: The expression of the routing index matrix is: I = topkIndex(A, k); Where I represents the routing index matrix, A represents the global feature matrix, k represents the number of refocused regions, and topkIndex(·) represents the region index value with a higher value in the global feature matrix A.
5. The medical image classification method based on global and local information fusion according to claim 3, characterized in that: The expression of the fine-grained local feature is: Y'=Attention(Q y ,K g ,V g ); In the formula, K g ,V g Respectively represent the key value Key and weight value Value of the refocus area, Q y Represents the query value Query of the global feature matrix A.
6. A medical image classification system based on global and local information fusion, characterized in that: include: An image acquisition module, used for acquiring a medical image to be classified, and preprocessing the medical image to be classified to obtain a preprocessed image; An image classification module, used for inputting the preprocessed image into a medical image classification model to obtain category information of the preprocessed image; the medical image classification model includes a feature extraction module and a prediction module, and the feature extraction module adopts a dual-focus attention VisionTransformer network model; An image output module is used to output the category information.
7. A medical image classification system based on global and local information fusion according to claim 6, characterized in that: The image classification module includes a medical image classification model training module, and the medical image classification model training module includes: A data set construction module, used for collecting medical images and constructing a data set based on the medical images; A classification model building module, used to build an initial medical image classification model including a feature extraction module and a prediction module, wherein the feature extraction module adopts a dual-focus attention VisionTransformer network model; The classification model training module is used to iteratively train the initial medical image classification model using the medical images in the data set until an iteration stop condition is reached, and output the medical image classification model.
8. A medical image classification system based on global and local information fusion according to claim 6, characterized in that: The feature extraction module includes multiple position embedding modules and a dual focus attention module; The position embedding module is used to change the dimension of the feature and deepen the depth of the feature extraction network; The dual focus attention module is used to obtain an inter-layer-intra-layer fusion feature map based on a multi-head self-attention operation.
9. A medical image classification system based on global and local information fusion according to claim 8, characterized in that: The dual-focus attention module includes a global feature extraction module, a refocused fine-grained local feature extraction module and a feature fusion module; The global feature extraction module is used to obtain global features based on downsampling, projection and standard attention mechanism; The refocusing fine-grained local feature extraction module is used to obtain the key value Key and the weight value Value of the refocusing area according to the routing index matrix of the refocusing area, and input the key value Key and the weight value Value of the refocusing area into the refocusing attention mechanism to extract fine-grained local features; The feature fusion module is used to fuse the fine-grained local feature information and the global feature by channel to obtain a global-local fusion feature map.
10. A medical image classification system based on global and local information fusion according to claim 9, characterized in that: The feature fusion module includes deep convolution and point convolution; the deep convolution is used to fuse the fine-grained local feature information and the global features in any channel; the point convolution is used to fuse the fine-grained local feature information and the global features between different channels.
Citation Information
Patent Citations
Fine-grained image classification method based on multilayer focusing attention network
CN112686242A
Target detection method based on Transform global and local attention interaction
CN114743017A
Image segmentation method of global context attention network based on multi-scale fusion
CN115375711A
Monocular 3D target detection method fusing double attention mechanisms
CN115909266A
Concrete crack detection research method and system based on double-flow fusion characteristics
CN116468670A
Cited By
Fabric printing and dyeing on-line detection system and method
CN120431442A
