A tongue image segmentation model based on an improved UCTransNet network
By using an improved UCTransNet network, an encoding/decoding architecture, and multi-level feature fusion technology, the problem of feature loss in tongue image segmentation is solved, achieving high-precision and robust tongue image segmentation results.
Patent Information
- Application Number
- CN202410086293.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-22
- Publication Date
- 2026-11-24
- Estimated Expiration
- 2044-01-22
AI Technical Summary
The existing UCTransNet network, through simple layer-by-layer convolution in tongue image segmentation, leads to the loss of meaningful features in the image, affecting the segmentation accuracy.
The system adopts an encoding and decoding architecture, including a multi-level feature fusion module, a feature matching module, an encoding module, and a decoding module. It obtains tongue image fusion feature maps through convolutional pooling layers, upsampling layers, and feature fusion layers, and uses multilayer perceptrons and cross-attention units for feature encoding and decoding to achieve multi-scale feature fusion and computation of related information.
It improves the accuracy of tongue image segmentation, enhances the robustness of the model, effectively suppresses background noise and irrelevant features, and achieves high-precision tongue image segmentation.
Smart Images

Figure CN117953214B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer vision technology, and more specifically, to a tongue image segmentation model based on an improved UCTransNet network. Background Technology
[0002] Tongue segmentation separates the tongue from a tongue image, providing a reliable auxiliary means for tongue diagnosis analysis. Traditional segmentation methods mainly separate the tongue through thresholding, filtering, and region growing. These methods are affected by various factors such as the operator and the operating environment, resulting in a certain degree of subjectivity and inaccuracy. Image processing techniques can automatically learn abstract representations and features from data, eliminating the need for manually designed feature extractors. For example, Convolutional Neural Networks (CNNs) can extract image features and are widely used in various tasks, such as FCN, U-Net, and SegNet.
[0003] Threshold-based tongue image segmentation is simple and easy to implement, but its drawbacks include sensitivity to lighting and noise, and difficulty in handling complex tongue images. Segmentation combined with edge detection can utilize the edge information of the tongue to obtain better results, but the filter selection is subjective. Region growing algorithms are suitable for situations where there are significant color or brightness differences between the tongue and the background, but they cannot effectively handle cases where the target is discontinuous.
[0004] U-Net's symmetric encoder and decoder structure is suitable for segmentation, but its skip connections have limitations; not every skip connection is effective, and some can negatively impact segmentation performance. Transformer models based on attention mechanisms can compute relationships between features, globally modeling input features in parallel computation. This parallelism effectively utilizes hardware resources, as seen in models like ViT, UNETR, and UCTransNet. UCTransNet redesigns the skip connections in U-Net by introducing a Transformer model and proposes a CTrans module, which includes two sub-modules: an encoder and a decoder. CTrans uses an attention mechanism to fuse information transfer between feature maps, replacing the original skip connections. However, UCTransNet still uses the traditional U-Net layer-by-layer convolutional modules before the skip connections. This simple layer-by-layer convolution leads to the loss of meaningful features in the image, resulting in decreased segmentation accuracy.
[0005] Traditional tongue image segmentation methods suffer from drawbacks including the subjectivity of filter selection and the significant impact of actual image quality on the segmentation results. UCTransNet's layer-by-layer convolutional modules are relatively simple, leading to insufficient information transfer between fused feature maps and affecting segmentation performance.
[0006] Therefore, this invention provides a tongue image segmentation model based on an improved UCTransNet network. Summary of the Invention
[0007] To overcome the problems in existing technologies, this invention proposes a tongue image segmentation model based on an improved UCTransNet network. This model addresses the issue that UCTransNet, through simple layer-by-layer convolution, leads to the loss of meaningful features in the image, resulting in decreased segmentation accuracy.
[0008] To address the aforementioned issues, the present invention provides the following technical solution: In a first aspect, the present invention provides a tongue image segmentation model based on an improved UCTransNet network, comprising a model employing an encoding / decoding architecture, a multi-level feature fusion module, a feature matching module, an encoding module, and a decoding module;
[0009] The multi-level feature fusion module includes a convolutional pooling layer, an upsampling layer, and a feature fusion layer. The convolutional pooling layer performs convolution and pooling on the tongue image to be processed to obtain tongue image feature maps at different levels. The tongue image feature maps are upsampled and linearly fused to obtain a tongue image fusion feature map with more texture and position information.
[0010] The feature matching module aligns with the input dimensions of the encoding module, performs feature matching on the tongue image fusion feature map to generate a target fusion feature map, and outputs the target fusion feature map.
[0011] The encoding module includes multiple parallel multilayer perceptrons, which encode the target fusion feature map to generate sequence features of a unified dimension.
[0012] The decoding module includes multiple cross-attention units, which calculate the association information between sequence features and the tongue image to be processed, and output the final segmentation result based on the association information.
[0013] As a preferred embodiment of the present invention, the logic for obtaining the tongue image fusion feature map is as follows:
[0014] The tongue image to be processed is first convolved to obtain tongue image feature maps at different levels. The tongue image feature maps capture various details and structural features at different scales and levels, and are then sent to a multi-level feature fusion module.
[0015] Tongue image feature maps from different levels and scales are integrated to extract tongue image fusion feature maps.
[0016] As a preferred embodiment of the present invention, the processing logic of the tongue image feature map is as follows:
[0017] The tongue image to be processed is processed through a convolutional pooling layer and then through a series of convolutional operations to obtain tongue image feature maps X1, X2, X3, X4 and X5 in sequence. Each convolution reduces the width and height to half of the previous level tongue image feature map and increases the number of channels to twice that of the previous level tongue image feature map.
[0018] As a preferred embodiment of the present invention, the multi-level feature fusion module includes the following steps:
[0019] The tongue image feature map X1, tongue image feature map X2 and tongue image feature map X3 are passed through the upsampling layer and then through step-by-step sampling operations to obtain intermediate feature maps F1, F2 and F3 in sequence.
[0020] The tongue image feature maps X1, X2, X3, X4, and X5 generated after each convolution operation are fused with intermediate feature maps F1, F2, and F3 at multiple levels to obtain the corresponding tongue image fusion feature map.
[0021] Based on tongue image feature map X5 and tongue image feature map X4, tongue image fusion feature map Y5 and tongue image fusion feature map Y4 are obtained through feature fusion layer respectively;
[0022] Tongue image feature map Y3 is obtained by fusing features from tongue image feature map X3 and tongue image feature map X4.
[0023] Tongue image fusion feature map Y2 is obtained by fusing tongue image fusion feature map Y3, tongue image feature map X2 and intermediate feature map F1;
[0024] Tongue image fusion feature map Y1 is obtained by fusing tongue image fusion feature map Y2, tongue image feature map X1 and intermediate feature map F3.
[0025] As a preferred embodiment of the present invention, the process of obtaining intermediate feature maps F1, F2, and F3 is as follows:
[0026] The tongue image feature image X3 is enlarged to obtain an enlarged tongue image feature image X3 with the same size as the tongue image feature image X2. The enlarged tongue image feature image X3 and the tongue image feature image X2 are superimposed to obtain the intermediate feature image F1.
[0027] Similarly, the tongue image feature map X2 is enlarged to obtain an enlarged tongue image feature map X2 with the same size as the tongue image feature map X1. The enlarged tongue image feature map X2 is superimposed with the tongue image feature map X1 to obtain the intermediate feature map F2.
[0028] The intermediate feature map F1 is enlarged to obtain an enlarged intermediate feature map F1 with the same size as the intermediate feature map F2. The enlarged intermediate feature map F1 and the intermediate feature map F2 are superimposed to obtain the intermediate feature map F3.
[0029] As a preferred embodiment of the present invention, the logic for obtaining the target fusion feature map is as follows:
[0030] In the feature matching module, the last layer of the input tongue image fusion feature map Y5 is upsampled and fused with the tongue image fusion feature map Y4 to obtain the target fusion feature map P4, which is then used as the last layer output of the feature matching module.
[0031] Then, the fused target fusion feature map P4 is fused with the input tongue image fusion feature map Y3 from the previous layer to obtain the target fusion feature map P3.
[0032] And so on; the target fusion feature maps after each stage of fusion are obtained, for a total of 4 layers;
[0033] An inverted feature pyramid network structure is adopted to adapt to input and output of different dimensions. Without losing feature information, the target fusion feature map P1, target fusion feature map P2, target fusion feature map P3 and target fusion feature map P4 are output.
[0034] As a preferred embodiment of the present invention, the encoding module includes multi-scale feature encoding, multi-head channel-level cross-attention, and multilayer perceptron (MLP);
[0035] The target fusion feature map output by the feature matching module includes target fusion feature map P1, target fusion feature map P2, target fusion feature map P3 and target fusion feature map P4;
[0036] The target fusion feature map is fused using the formula The patch sequence is reconstructed into a two-dimensional patch sequence to obtain a serialized patch feature sequence;
[0037] The serialized patch feature sequences are combined and used as keys and values to input into the multi-head channel-level cross-attention module;
[0038] The patch feature sequence is fed into a multilayer perceptron with residual structure. By utilizing the continuous regions of the tongue, the accurate perception of the tongue contour is obtained, and the target fusion feature map is encoded to generate a sequence feature of uniform dimension.
[0039] In a preferred embodiment of the present invention, the decoding module includes a fusion channel Transformer and a U-Net decoder.
[0040] A Transformer-based multi-head cross-attention module was added to the original network, which will then process the output Z of the Transformer in the i-th layer. i ∈R C×H×W Feature map R fused with the target of the decoder in layer i i ∈R C×H×W进 Row upsampling and average pooling, Z i and R i Represents the feature map, R C×H×W Represents a set of channel, height, and width;
[0041] After being combined with activation functions, as shown in the equation: M i =L1·G(Z) i )+L2·G(R i ), where L represents a linear layer, G represents average pooling, and M... i and Z i The result obtained by multiplication is σ, which represents the activation function, as shown in the equation: Z i-1 =σ(M i )·Z i ;
[0042] Feature fusion is performed on the encoder outputs R4 and Z4 to generate Z3; feature fusion is performed on the encoder outputs R3 and Z3 to generate Z2; feature fusion is performed on the encoder outputs R2 and Z2 to generate Z1; finally, feature fusion is performed on the encoder outputs R1 and Z1 to generate a segmentation map.
[0043] Secondly, this invention provides a tongue image segmentation method based on an improved UCTransNet network, which includes the following steps:
[0044] Step 1: Input image, and obtain fused feature maps at different levels through convolution;
[0045] Step 2: Perform feature matching on the fused feature map obtained from the multi-level feature fusion module, align the dimensions of the encoding module, and output the target fused feature map;
[0046] Step 3: Encode the target fusion feature map using a multilayer perceptron to generate sequence features of uniform dimension;
[0047] Step 4: Calculate the association information between the sequence features and the tongue image to be processed using cross-attention units, and output the final segmentation result based on the association information.
[0048] Thirdly, the present invention provides an electronic device, comprising:
[0049] At least one processor; and
[0050] A memory that is communicatively connected to the at least one processor;
[0051] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, cause the electronic device to perform a tongue segmentation model based on an improved UCTransNet network.
[0052] The technical effects and advantages of the tongue image segmentation model based on the improved UCTransNet network in this invention are as follows: Through multi-level feature fusion and attention mechanism, the model can capture rich features and details of the tongue image. Through multi-scale feature encoding and attention mechanism, the model can effectively suppress background noise and irrelevant features, showing good robustness. Furthermore, it adopts an encoding and decoding architecture and layer-by-layer convolutional pooling to achieve high-precision segmentation, enabling fast processing of tongue image images and achieving high-precision segmentation results. Attached Figure Description
[0053] Figure 1 This is a schematic diagram of the overall structure of the tongue image segmentation model of the present invention;
[0054] Figure 2 This is a schematic diagram of the multi-level feature fusion module of the tongue image segmentation model of the present invention;
[0055] Figure 3 This is a schematic diagram of the feature matching module of the tongue image segmentation model of the present invention;
[0056] Figure 4 This is a schematic diagram of the encoding module of the tongue image segmentation model of the present invention;
[0057] Figure 5 This is a schematic diagram of the decoding module of the tongue image segmentation model of the present invention. Detailed Implementation
[0058] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0059] Example 1
[0060] Please see Figure 1-2As shown in the figure, the tongue image segmentation model based on the improved UCTransNet network described in this embodiment adopts an encoding and decoding architecture, including: a multi-level feature fusion module, a feature matching module, an encoding module, and a decoding module; the above modules are connected through wired and / or wireless connections to realize data transmission between the modules;
[0061] The multi-level feature fusion module includes a convolutional pooling layer, an upsampling layer, and a feature fusion layer. The convolutional pooling layer performs convolution and pooling on the tongue image to be processed to obtain tongue image feature maps at different levels. The tongue image feature maps are upsampled and linearly fused to obtain a tongue image fusion feature map with more texture and position information.
[0062] The feature matching module aligns with the input dimensions of the encoding module, performs feature matching on the tongue image fusion feature map to generate a target fusion feature map, and outputs the target fusion feature map.
[0063] The encoding module includes multiple parallel multilayer perceptrons, which encode the target fusion feature map to generate sequence features of a unified dimension.
[0064] The decoding module includes multiple cross-attention units, which calculate the association information between sequence features and the tongue image to be processed, and output the final segmentation result based on the association information.
[0065] It should be noted that: the tongue image to be processed is a tongue image that needs to be processed by the tongue image segmentation model; the tongue image to be processed is first processed by convolution to obtain tongue image feature maps at different levels. The tongue image feature maps capture various details and structural features at different scales and levels, and are then sent to the multi-level feature fusion module; the tongue image feature maps from different levels and scales are integrated to extract richer and more comprehensive tongue image fusion feature maps, so that the tongue image segmentation model can better understand and analyze the input tongue image to be processed;
[0066] Secondly, feature matching is performed on the tongue image fusion feature map generated by the multi-level feature fusion module to ensure the alignment and consistency between different tongue image fusion feature maps, align the dimensions of the encoding module and output the fusion feature map;
[0067] It is then encoded as sequence features in the encoding module. The encoding module encodes the target fusion feature map and converts it into sequence features with a unified dimension. Sequence features are regarded as an abstract representation of the image, which contains important information and structure in the image.
[0068] The relevant information between the input data is calculated, then passed through a parallel multilayer perceptron, and output to the decoding module; finally, a cross-attention layer is used to calculate the relevant information between the input data and output the final segmentation result.
[0069] Multilayer perceptrons learn and abstract sequence features at a deeper level to extract more representative sequence features, improving the model's ability to understand and analyze images. The processed features then enter the decoding module. The decoding module decodes the sequence features obtained in the previous steps into a representation similar to the original image, but this representation already contains richer feature information learned by the multilayer perceptron.
[0070] The decoded data is processed using a cross-attention layer to calculate the correlation or relationship between the input data, thereby enhancing the model's ability to understand and analyze images, and finally outputting the segmentation result.
[0071] It should be noted that the entire process is complex and meticulous, utilizing techniques such as convolutional neural networks, feature fusion, perceptrons, decoders, and cross-attention to achieve in-depth analysis and understanding of images, ultimately outputting accurate segmentation results. This technology has broad application prospects in fields such as computer vision and image processing.
[0072] For example, during image preprocessing, the image size is marked and changed to a specified size, but no post-processing operations such as adding noise or adjusting brightness are performed.
[0073] The multi-level feature fusion module includes the following steps:
[0074] The tongue image to be processed is obtained, and the tongue image to be processed is passed through a convolutional pooling layer and then through a series of convolutional operations to obtain tongue image feature map X1, tongue image feature map X2, tongue image feature map X3, tongue image feature map X4 and tongue image feature map X5 in sequence. Each convolution reduces the width and height to half of the previous level tongue image feature map and increases the number of channels to twice that of the previous level tongue image feature map.
[0075] Specifically: the tongue image to be processed is processed through a convolutional neural network to obtain a tongue image feature map X1, which has a size of 224×224 and 64 channels. Each convolution reduces the width and height to half of the previous level tongue image feature map and doubles the number of channels. In the final convolution, only the width and height are halved, while the number of channels remains unchanged. That is, when convolving tongue image feature map X4 to generate tongue image feature map X5, only the width and height are halved, while the number of channels remains unchanged. Therefore, as the tongue image feature map obtained after each convolution operation gradually decreases in size, tongue image feature map X1 has the largest size, while tongue image feature map X5 has the smallest size.
[0076] The tongue image feature map X1, tongue image feature map X2 and tongue image feature map X3 are passed through the upsampling layer and then through step-by-step sampling operations to obtain intermediate feature maps F1, F2 and F3 in sequence.
[0077] The specific operation is as follows: the tongue image feature map X3 is enlarged to obtain an enlarged tongue image feature map X3 with the same size as the tongue image feature map X2. The enlarged tongue image feature map X3 and the tongue image feature map X2 are superimposed to obtain the intermediate feature map F1.
[0078] Similarly, the tongue image feature map X2 is enlarged to obtain an enlarged tongue image feature map X2 with the same size as the tongue image feature map X1. The enlarged tongue image feature map X2 is superimposed with the tongue image feature map X1 to obtain the intermediate feature map F2.
[0079] The intermediate feature map F1 is enlarged to obtain an enlarged intermediate feature map F2 with the same size. The enlarged intermediate feature map F1 and the intermediate feature map F2 are then superimposed to obtain the intermediate feature map F3. The intermediate feature maps F1, F2 and F3 play a role in connecting the preceding and following feature maps during the fusion process, enabling information to be gradually transferred and integrated.
[0080] The tongue image feature maps X1, X2, X3, X4, and X5 generated after each convolution operation are fused through multi-level feature fusion to obtain the corresponding tongue image fusion feature map.
[0081] The specific operation is as follows: Based on tongue image feature map X5 and tongue image feature map X4, tongue image fusion feature map Y5 and tongue image fusion feature map Y4 are obtained through feature fusion layer respectively; this means that they have the same or similar feature representations;
[0082] Tongue image feature map Y3 is obtained by fusing features from tongue image feature map X3 and tongue image feature map X4.
[0083] Tongue image fusion feature map Y2 is obtained by fusing tongue image fusion feature map Y3, tongue image feature map X2 and intermediate feature map F1;
[0084] The tongue image fusion feature map Y1 is obtained by fusing the tongue image fusion feature map Y2, the tongue image feature map X1, and the intermediate feature map F3.
[0085] In summary, through multi-layer feature fusion, each new fused feature map is obtained by fusing the feature maps from one or more previous layers. This hierarchical fusion method helps to gradually extract and integrate important features from the tongue image, thereby obtaining a richer and more accurate feature representation.
[0086] The goal of the multi-level feature fusion module is to leverage the complementarity of features from different levels to obtain richer semantic information and more discriminative feature representations. The fused shallow features contain edge features at different scales, reducing the impact of boundary blurring. Deeper fused feature maps learn abstract and high-level semantic information to effectively suppress the background. After fusion at different scales, the segmentation model can better distinguish between the target and the background, reducing background interference with the segmentation results. Furthermore, the fusion operation further improves the model's performance, making it more robust to complex scenes and varying lighting conditions. The multi-level feature fusion module, as shown below... Figure 2 As shown.
[0087] In the feature matching module, this invention employs an inverted feature pyramid network structure. First, the last layer of the input tongue image fusion feature map Y5 is upsampled and fused with the tongue image fusion feature map Y4 to obtain the target fusion feature map P4, which serves as the final output of the feature matching module. Then, the fused target fusion feature map P4 is fused with the previous layer's input tongue image fusion feature map Y3 to obtain the target fusion feature map P3, and so on. Finally, the target fusion feature maps after each stage of fusion are obtained, totaling four layers. The inverted feature pyramid network structure adapts to input and output of different dimensions, reducing the number of output target fusion feature maps without losing feature information, thus providing reliable feature information for subsequent inputs. The feature matching module is as follows: Figure 3 As shown.
[0088] The encoding module consists of three parts: multi-scale feature encoding, multi-head channel-level cross-attention, and multilayer perceptron (MLP). First, the outputs P1, P2, P3, and P4 of the feature matching module are processed using the formula... The sequence is reconstructed into a two-dimensional patch sequence. Then, the sequenced patch feature sequences are combined and input as keys and values into a multi-head channel-level cross-attention module. Finally, the sequence features are fed into a multilayer perceptron (MLP) with residual structures. The tongue is a continuous region, often located at the center of the image. For tongue images with continuous edges and located at the image center, the encoding module performs better than traditional skip connections in fusing local features. Through clever design, the encoding module can more effectively capture the continuity information of the tongue edges. Its central location in the tongue image introduces more context awareness, enabling the model to better understand the relationship between the tongue and its surrounding environment. This design not only helps improve the accurate perception of the tongue contour but also effectively reduces the edge blurring and information loss problems that may occur in traditional methods. The encoding module is as follows: Figure 4 As shown.
[0089] In the decoding module, to better integrate the semantically inconsistent features between the channel Transformer and the U-Net decoder, the model of this invention adds a Transformer-based multi-head cross-attention module to the original network. This module can reasonably utilize the information filtering features of the Transformer to eliminate ambiguity with the decoder features. First, the output Z of the i-th layer Transformer is... i ∈R C×H×W Feature map R fused with the target of the decoder in layer i i ∈R C×H×W Upsampling and average pooling are performed. Then, the activation functions are stacked together, as shown in the equation: M i =L1·G(Z) i )+L2·G(R i ), where L represents a linear layer and G represents average pooling. Finally, M... i and Z i The result obtained by multiplication is σ, which represents the activation function, as shown in the equation: Z i-1 =σ(M i )·Z i Tongue segmentation not only requires segmenting a continuous tongue body but also separating it from the background. The decoding module can reduce interference from background features, making the tongue segmentation results more accurate. The decoding module, for example... Figure 5 As shown, feature fusion is performed on the encoder outputs R4 and Z4 to generate Z3; feature fusion is performed on the encoder outputs R3 and Z3 to generate Z2; feature fusion is performed on the encoder outputs R2 and Z2 to generate Z1; finally, feature fusion is performed on the encoder outputs R1 and Z1 to generate a segmentation map.
[0090] Example 3
[0091] In an exemplary embodiment, a tongue image segmentation method based on an improved UCTransNet network is also provided. For details not described herein, please refer to the tongue image segmentation model based on an improved UCTransNet network disclosed in Embodiment 1, which includes the following steps:
[0092] Step 1: Input image, and obtain fused feature maps at different levels through convolution;
[0093] Step 2: Perform feature matching on the fused feature map obtained from the multi-level feature fusion module, align the dimensions of the encoding module, and output the target fused feature map;
[0094] Step 3: Encode the target fusion feature map using a multilayer perceptron to generate sequence features of uniform dimension;
[0095] Step 4: Calculate the association information between the sequence features and the tongue image to be processed using cross-attention units, and output the final segmentation result based on the association information.
[0096] As a preferred embodiment of the present invention, the logic for obtaining the tongue image fusion feature map is as follows:
[0097] The tongue image to be processed is first convolved to obtain tongue image feature maps at different levels. The tongue image feature maps capture various details and structural features at different scales and levels, and are then sent to a multi-level feature fusion module.
[0098] Tongue image feature maps from different levels and scales are integrated to extract tongue image fusion feature maps.
[0099] As a preferred embodiment of the present invention, the processing logic of the tongue image feature map is as follows:
[0100] The tongue image to be processed is processed through a convolutional pooling layer and then through a series of convolutional operations to obtain tongue image feature maps X1, X2, X3, X4 and X5 in sequence. Each convolution reduces the width and height to half of the previous level tongue image feature map and increases the number of channels to twice that of the previous level tongue image feature map.
[0101] As a preferred embodiment of the present invention, the multi-level feature fusion module includes the following steps:
[0102] The tongue image feature map X1, tongue image feature map X2 and tongue image feature map X3 are passed through the upsampling layer and then through step-by-step sampling operations to obtain intermediate feature maps F1, F2 and F3 in sequence.
[0103] The tongue image feature maps X1, X2, X3, X4, and X5 generated after each convolution operation are fused with intermediate feature maps F1, F2, and F3 at multiple levels to obtain the corresponding tongue image fusion feature map.
[0104] Based on tongue image feature map X5 and tongue image feature map X4, tongue image fusion feature map Y5 and tongue image fusion feature map Y4 are obtained through feature fusion layer respectively;
[0105] Tongue image feature map Y3 is obtained by fusing features from tongue image feature map X3 and tongue image feature map X4.
[0106] Tongue image fusion feature map Y2 is obtained by fusing tongue image fusion feature map Y3, tongue image feature map X2 and intermediate feature map F1;
[0107] Tongue image fusion feature map Y1 is obtained by fusing tongue image fusion feature map Y2, tongue image feature map X1 and intermediate feature map F3.
[0108] As a preferred embodiment of the present invention, the process of obtaining intermediate feature maps F1, F2, and F3 is as follows:
[0109] The tongue image feature image X3 is enlarged to obtain an enlarged tongue image feature image X3 with the same size as the tongue image feature image X2. The enlarged tongue image feature image X3 and the tongue image feature image X2 are superimposed to obtain the intermediate feature image F1.
[0110] Similarly, the tongue image feature map X2 is enlarged to obtain an enlarged tongue image feature map X2 with the same size as the tongue image feature map X1. The enlarged tongue image feature map X2 is superimposed with the tongue image feature map X1 to obtain the intermediate feature map F2.
[0111] The intermediate feature map F1 is enlarged to obtain an enlarged intermediate feature map F1 with the same size as the intermediate feature map F2. The enlarged intermediate feature map F1 and the intermediate feature map F2 are superimposed to obtain the intermediate feature map F3.
[0112] As a preferred embodiment of the present invention, the logic for obtaining the target fusion feature map is as follows:
[0113] In the feature matching module, the last layer of the input tongue image fusion feature map Y5 is upsampled and fused with the tongue image fusion feature map Y4 to obtain the target fusion feature map P4, which is then used as the last layer output of the feature matching module.
[0114] Then, the fused target fusion feature map P4 is fused with the input tongue image fusion feature map Y3 from the previous layer to obtain the target fusion feature map P3.
[0115] And so on; the target fusion feature maps after each stage of fusion are obtained, for a total of 4 layers;
[0116] An inverted feature pyramid network structure is adopted to adapt to input and output of different dimensions. Without losing feature information, the target fusion feature map P1, target fusion feature map P2, target fusion feature map P3 and target fusion feature map P4 are output.
[0117] As a preferred embodiment of the present invention, the encoding module includes multi-scale feature encoding, multi-head channel-level cross-attention, and multilayer perceptron (MLP);
[0118] The target fusion feature map output by the feature matching module includes target fusion feature map P1, target fusion feature map P2, target fusion feature map P3 and target fusion feature map P4;
[0119] The target fusion feature map is fused using the formula The patch sequence is reconstructed into a two-dimensional patch sequence to obtain a serialized patch feature sequence;
[0120] The serialized patch feature sequences are combined and used as keys and values to input into the multi-head channel-level cross-attention module;
[0121] The patch feature sequence is fed into a multilayer perceptron with residual structure. By utilizing the continuous regions of the tongue, the accurate perception of the tongue contour is obtained, and the target fusion feature map is encoded to generate a sequence feature of uniform dimension.
[0122] In a preferred embodiment of the present invention, the decoding module includes a fusion channel Transformer and a U-Net decoder.
[0123] A Transformer-based multi-head cross-attention module was added to the original network, which will then process the output Z of the Transformer in the i-th layer. i ∈R C×H×W Feature map R fused with the target of the decoder in layer i i ∈R C×H×W Perform upsampling and average pooling, Z i and R i Represents the feature map, R C×H×W Represents a set of channel, height, and width;
[0124] After being combined with activation functions, as shown in the equation: M i =L1·G(Z) i )+L2·G(R i ), where L represents a linear layer, G represents average pooling, and M... i and Z i The result obtained by multiplication is σ, which represents the activation function, as shown in the equation: Z i-1 =σ(M i )·Z i ;
[0125] Feature fusion is performed on the encoder outputs R4 and Z4 to generate Z3; feature fusion is performed on the encoder outputs R3 and Z3 to generate Z2; feature fusion is performed on the encoder outputs R2 and Z2 to generate Z1; finally, feature fusion is performed on the encoder outputs R1 and Z1 to generate a segmentation map.
[0126] Example 3
[0127] In an exemplary embodiment, an electronic device is also provided, comprising:
[0128] At least one processor; and
[0129] A memory that is communicatively connected to the at least one processor;
[0130] The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, cause the electronic device to perform a tongue segmentation model based on an improved UCTransNet network.
[0131] For example, computer-readable storage media can be read-only memory (ROM), random access memory (RAM), compact disc read-only memory (CD-ROM), magnetic tape, floppy disk, and optical data storage devices.
[0132] In an exemplary embodiment, a storage medium is also provided on which a computer program is stored, which, when executed by a processor, implements a tongue image segmentation model based on an improved UCTransNet network.
[0133] It should be understood that in the various embodiments of this application, the order of the above-mentioned processes does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of this application.
[0134] It should be understood that determining B based on A does not mean determining B solely based on A; it also means determining B based on A and / or other information.
[0135] Those skilled in the art will understand that all or part of the steps of the above embodiments can be implemented by hardware or by a program instructing related hardware. The program can be stored in a computer-readable storage medium, such as a read-only memory, a disk, or an optical disk.
[0136] The above description is only an optional embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
[0137] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only one method, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0138] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.
[0139] In conclusion, the above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A tongue image segmentation model based on an improved UCTransNet network, characterized in that, The model adopts an encoding and decoding architecture, consisting of a multi-level feature fusion module, feature matching module, encoding module, and decoding module; The multi-level feature fusion module includes a convolutional pooling layer, an upsampling layer, and a feature fusion layer. The convolutional pooling layer performs convolution and pooling on the tongue image to be processed to obtain tongue image feature maps at different levels. The tongue image to be processed is processed through the convolutional pooling layer and then undergoes a series of convolutional operations to obtain tongue image feature maps X1, X2, X3, X4, and X5. Each convolution reduces the width and height to half of the previous level tongue image feature map and increases the number of channels to twice that of the previous level tongue image feature map. The tongue image feature map is upsampled and linearly fused to obtain a tongue image fusion feature map with more texture and positional information, including the following steps: The tongue image feature map X1, tongue image feature map X2 and tongue image feature map X3 are passed through the upsampling layer and then through step-by-step sampling operations to obtain intermediate feature maps F1, F2 and F3 in sequence. The tongue image feature maps X1, X2, X3, X4, and X5 generated after each convolution operation are fused with intermediate feature maps F1, F2, and F3 at multiple levels to obtain the corresponding tongue image fusion feature map. Based on tongue image feature map X5 and tongue image feature map X4, tongue image fusion feature map Y5 and tongue image fusion feature map Y4 are obtained through feature fusion layer respectively; Tongue image feature map Y3 is obtained by fusing features from tongue image feature map X3 and tongue image feature map X4. Tongue image fusion feature map Y2 is obtained by fusing tongue image fusion feature map Y3, tongue image feature map X2 and intermediate feature map F1; The tongue image fusion feature map Y1 is obtained by fusing the tongue image fusion feature map Y2, the tongue image feature map X1 and the intermediate feature map F3. The tongue image feature map X3 is enlarged to obtain an enlarged tongue image feature map X3 with the same size as the tongue image feature map X2. The enlarged tongue image feature map X3 and the tongue image feature map X2 are superimposed to obtain the intermediate feature map F1. Similarly, the tongue image feature map X2 is enlarged to obtain an enlarged tongue image feature map X2 with the same size as the tongue image feature map X1. The enlarged tongue image feature map X2 is superimposed with the tongue image feature map X1 to obtain the intermediate feature map F2. The intermediate feature map F1 is enlarged to obtain an enlarged intermediate feature map F1 with the same size as the intermediate feature map F2. The enlarged intermediate feature map F1 and the intermediate feature map F2 are superimposed to obtain the intermediate feature map F3. The feature matching module aligns with the input dimensions of the encoding module, performs feature matching on the tongue image fusion feature map to generate a target fusion feature map, and outputs the target fusion feature map. The encoding module includes multiple parallel multilayer perceptrons, which encode the target fusion feature map to generate sequence features of a unified dimension. The decoding module includes multiple cross-attention units, which calculate the association information between sequence features and the tongue image to be processed, and output the final segmentation result based on the association information.
2. The tongue image segmentation model based on the improved UCTransNet network according to claim 1, wherein, The logic for obtaining the tongue image fusion feature map is as follows: The tongue image to be processed is first convolved to obtain tongue image feature maps at different levels. The tongue image feature maps capture various details and structural features at different scales and levels, and are then sent to a multi-level feature fusion module. Tongue image feature maps from different levels and scales are integrated to extract tongue image fusion feature maps.
3. The tongue image segmentation model based on an improved UCTransNet network according to claim 1, wherein, The logic for obtaining the target fusion feature map is as follows: In the feature matching module, the last layer of the input tongue image fusion feature map Y5 is upsampled and fused with the tongue image fusion feature map Y4 to obtain the target fusion feature map P4, which is then used as the last layer output of the feature matching module. Then, the fused target fusion feature map P4 is fused with the input tongue image fusion feature map Y3 from the previous layer to obtain the target fusion feature map P3. And so on; The target fusion feature map after each stage of fusion is obtained, with a total of 4 layers; An inverted feature pyramid network structure is adopted to adapt to input and output of different dimensions. Without losing feature information, the target fusion feature map P1, target fusion feature map P2, target fusion feature map P3 and target fusion feature map P4 are output.
4. The tongue image segmentation model based on the improved UCTransNet network according to claim 3, characterized in that, The encoding module includes multi-scale feature encoding, multi-head channel-level cross-attention, and multilayer perceptron (MLP). The target fusion feature map output by the feature matching module includes target fusion feature map P1, target fusion feature map P2, target fusion feature map P3 and target fusion feature map P4; The target fusion feature map is fused using the formula The patch sequence is reconstructed into a two-dimensional patch sequence to obtain a serialized patch feature sequence; The serialized patch feature sequences are combined and used as keys and values to input into the multi-head channel-level cross-attention module; The patch feature sequence is fed into a multilayer perceptron with residual structure. By utilizing the continuous regions of the tongue, the accurate perception of the tongue contour is obtained, and the target fusion feature map is encoded to generate a sequence feature of uniform dimension.
5. A tongue image segmentation model based on an improved UCTransNet network according to claim 4, characterized in that, The decoding module includes a fusion channel Transformer and a U-Net decoder. A Transformer-based multi-head cross-attention module was added to the original network to process the output of the Transformer in layer i. Feature map fused with the target of the decoder in layer i Perform upsampling and average pooling. and Representing feature maps, Represents a set of channel, height, and width; After being combined using activation functions, the results are shown in the following equation: , Indicates a linear layer. Indicates average pooling, and Multiply to get the result. The activation function is shown in the following equation: ; Feature fusion is performed on the encoder outputs R4 and Z4 to generate Z3; feature fusion is performed on the encoder outputs R3 and Z3 to generate Z2; feature fusion is performed on the encoder outputs R2 and Z2 to generate Z1; finally, feature fusion is performed on the encoder outputs R1 and Z1 to generate a segmentation map.
6. A tongue image segmentation method based on an improved UCTransNet network, based on the tongue image segmentation model based on an improved UCTransNet network as described in any one of claims 1-5, characterized in that, Includes the following steps: Step 1: Input image, and obtain fused feature maps at different levels through convolution; Step 2: Perform feature matching on the fused feature map obtained from the multi-level feature fusion module, align the dimensions of the encoding module, and output the target fused feature map; Step 3: Encode the target fusion feature map using a multilayer perceptron to generate sequence features of uniform dimension; Step 4: Calculate the association information between the sequence features and the tongue image to be processed using cross-attention units, and output the final segmentation result based on the association information.
7. An electronic device, characterized in that, include: At least one processor; as well as A memory that is communicatively connected to the at least one processor; The memory stores instructions that can be executed by the at least one processor, which, when executed by the at least one processor, cause the electronic device to perform a tongue segmentation model based on an improved UCTransNet network as described in any one of claims 1-5.
