A method and system for tongue appearance constitution classification based on an improved ResNet18 model

By refactoring and optimizing the ResNet18 model with a lightweight approach, the problems of overfitting and gradient explosion in tongue constitution classification are solved, achieving high-precision and stable tongue constitution classification, which is suitable for TCM constitution diagnosis of small to medium-sized tongue datasets.

CN122176408APending Publication Date: 2026-06-09KUNMING UNIV OF SCI & TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
KUNMING UNIV OF SCI & TECH
Filing Date
2026-03-26
Publication Date
2026-06-09

AI Technical Summary

Technical Problem

In existing technologies, tongue constitution classification methods based on the ResNet18 model suffer from overfitting, gradient explosion, and low classification accuracy, making it difficult to meet the requirements of automation, standardization, and high precision in TCM constitution identification.

Method used

By refactoring the ResNet18 model in a lightweight manner, the parameters of the backbone network except for layer 4 and the fully connected layer are frozen. Dropout regularization, BatchNorm1d normalization, and small-scale weight initialization are introduced into the fully connected layer. The model is trained by using the label smooth cross-entropy loss function, combined with gradient clipping, cosine annealing learning rate scheduling, and early stopping strategy.

Benefits of technology

It solves the problems of gradient explosion and overfitting in the model training process, improves classification accuracy and generalization ability, is suitable for practical applications of small and medium-sized tongue image datasets, and achieves high-precision classification of tongue image constitution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122176408A_ABST
    Figure CN122176408A_ABST
Patent Text Reader

Abstract

This invention relates to a tongue constitution classification method and system based on an improved ResNet18 model, belonging to the field of tongue constitution classification technology. The method includes: normalizing, augmenting, and standardizing the original tongue image to obtain a standardized tongue image; performing lightweight reconstruction on the original ResNet18 model to obtain an improved ResNet18 model; wherein the lightweight reconstruction involves freezing all parameters of the backbone network except for layer 4 and the fully connected layers, and reconstructing the fully connected layers; training the improved ResNet18 model using label-smoothed cross-entropy loss, combined with gradient clipping, cosine annealing learning rate scheduling, and early stopping strategies; inputting the standardized tongue image into the trained improved ResNet18 model to extract tongue color and texture features, which are then converted into a probability distribution of tongue constitution using a softmax function, thereby obtaining the tongue constitution classification result. This aims to solve the technical problems of overfitting, gradient explosion, and low classification accuracy in existing tongue classification tasks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a tongue appearance constitution classification method and system based on an improved ResNet18 model, belonging to the field of tongue appearance constitution classification technology. Background Technology

[0002] In Traditional Chinese Medicine (TCM) diagnosis, tongue appearance is a core basis for constitution identification. Traditional tongue constitution classification relies on manual judgment by TCM practitioners, which is highly subjective, inefficient, and difficult to meet the needs of large-scale, standardized clinical diagnosis. Current deep learning-based tongue constitution classification methods mostly employ convolutional neural network (CNN) models, such as ResNet18. While these models improve the automation level of classification to some extent, they suffer from numerous adaptability issues and cannot fully meet the actual needs of tongue constitution classification.

[0003] The fully connected layers of the native ResNet18 are designed for general image classification scenarios like ImageNet (a large-scale image object recognition database), and are not specifically optimized for tongue image data. When directly used for tongue image classification, the lack of normalization and regularization of core features such as tongue color and texture can easily lead to anomalies in the distribution of the model's output logits, thus affecting the accuracy of classification. At the same time, tongue image datasets generally have inherent characteristics such as small sample size and uneven class distribution. Directly using the native ResNet18 for training can easily lead to overfitting, resulting in low validation set accuracy and insufficient generalization ability. In addition, the model is prone to numerical instability issues such as gradient explosion and NaN loss during training, often leading to training interruptions and affecting the continuity and stability of model training. Furthermore, the inherent defects of the traditional cross-entropy loss function can easily lead to the model's over-reliance on the training set labels, further exacerbating the overfitting problem and causing the model to perform poorly on unseen tongue image samples.

[0004] Currently, some studies have attempted to improve the ResNet18 model to adapt it for tongue image classification. However, most of these studies simply adjust the number of network layers or training parameters, failing to systematically optimize from multiple dimensions such as data adaptation, network structure, loss function, and training strategy. This is especially true in tongue image classification, which features complex color and texture characteristics and uneven sample distribution; a balance between training stability, high classification accuracy, and model practicality has not yet been achieved. Therefore, there is an urgent need for a deep learning method that adapts to the characteristics of tongue image data, is stable in training, and has high classification accuracy to meet the practical needs of TCM constitution identification for automation, standardization, and high precision. Summary of the Invention

[0005] The purpose of this invention is to provide a tongue image constitution classification method and system based on an improved ResNet18 model, aiming to solve the technical problems of overfitting, gradient explosion, and low classification accuracy in existing technologies for tongue image classification tasks.

[0006] To achieve the above objectives, the technical solution of the present invention is: a tongue appearance constitution classification method based on an improved ResNet18 model, comprising the following steps: S1: Perform size normalization, data augmentation, and standardization on the original tongue image to obtain a standardized tongue image; S2: Perform lightweight reconstruction on the original ResNet18 model to obtain an improved ResNet18 model; wherein, the lightweight reconstruction involves freezing all parameters of the backbone network except for layer 4 and the fully connected layer, and reconstructing the fully connected layer; S3: Train the improved ResNet18 model; wherein the training adopts label smooth cross-entropy loss, combined with gradient pruning, cosine annealing learning rate scheduling and early stopping strategy; S4: Input the standardized tongue image into the trained improved ResNet18 model, extract the tongue color and texture features, and then convert them into the probability distribution of tongue constitution through the softmax function to obtain the tongue constitution classification result.

[0007] Optionally, the improved ResNet18 model obtained is specifically as follows: Load the pre-trained native ResNet18 model and freeze all network parameters except for layer 4 and the fully connected layer; Common low-level visual features are extracted through shallow and mid-level convolutional layers; High-order semantic features are extracted using layer 4. By reconstructing the fully connected layer, general low-order visual features and high-order semantic features are mapped to the category space.

[0008] Optionally, the reconstructed fully connected layer involves sequentially introducing Dropout regularization, BatchNorm1d normalization, and small-scale weight initialization into the fully connected layer, specifically as follows: The reconstructed fully connected layers are, in order: a Dropout layer with a probability of 0.3, a linear layer with an input dimension of 512 and an output dimension of 256, a BatchNorm1d layer, a ReLU activation layer, a Dropout layer with a probability of 0.2, and a linear layer with an input dimension of 256 and an output dimension of 8.

[0009] Optionally, training the improved ResNet18 model specifically involves: The label smoothing cross-entropy loss function is set with a smoothing coefficient of 0.1, and the true label confidence is reduced and the remaining confidence is evenly distributed to other categories; Gradient clipping sets the maximum norm to 1.0 and imposes norm constraints on the backpropagation gradient; The cosine annealing learning rate scheduling period is set to 50 rounds, with a minimum learning rate of 1e-6, and the learning rate is adaptively decayed according to the cosine curve. The early stop strategy has a patience value of 10 rounds. The training is terminated when the accuracy of the validation set fails to improve after 10 consecutive rounds.

[0010] To achieve the above objectives, this application also proposes a tongue appearance constitution classification system based on an improved ResNet18 model, comprising: Preprocessing module: used for resizing, random horizontal flipping, and normalization of the original tongue image; Model building module: includes layer freezing unit and fully connected layer reconstruction unit to achieve the initialization of the improved ResNet18 model; Training optimization module: includes loss calculation unit, gradient optimization unit and early stopping unit, to realize model training; Classification Decision Module: Includes feature extraction unit, probability calculation unit and visualization unit, to realize tongue appearance constitution classification and result display.

[0011] Optionally, the layer freezing unit only unfreezes the parameters of layer 4 and fully connected layers of ResNet18, and the fully connected layer reconstruction unit supports dynamic adaptation for 8 and 9 types of tongue appearance classification; wherein, the dynamic adaptation is to adjust the output dimension using the reconstructed linear layer of the output layer, without changing the overall structure of the model, only needing to adjust the output dimension to 8 or 9.

[0012] Optionally, the probability calculation unit performs probabilistic mapping on the unnormalized logits output by the model using the softmax function, and finally outputs the confidence probability of each category of tongue appearance.

[0013] The beneficial effects of this invention are: 1. This invention solves the problems of gradient explosion, abnormal loss, and overfitting in the training of native ResNet18 by gradient clipping, NaN loss filtering and early stopping strategy, thereby accelerating the model convergence speed and ensuring the stability of the training process. 2. This invention has excellent classification performance in the tongue image constitution classification task, and its generalization ability is significantly better than that of the native ResNet18, effectively solving the core technical problem of low classification accuracy of existing methods; 3. This invention optimizes the expression of tongue image color and texture features by normalizing and regularizing the fully connected layer and standardizing the tongue image specific color, thereby solving the problems of abnormal logits distribution and inaccurate extraction of core features and fundamentally improving classification accuracy. 4. This invention only unfreezes the last two layers of ResNet18, which greatly reduces the number of parameters and improves training efficiency. It is suitable for practical application scenarios of small and medium-sized tongue image datasets, balancing training efficiency and classification performance. Attached Figure Description

[0014] Figure 1 This is a system architecture block diagram of the present invention; Figure 2 This is a schematic diagram of the FixedResNet18 fully connected layer structure of the present invention; Figure 3 This is a schematic diagram of the training process of the StableTrainOptimizer of the present invention; Figure 4 This is a graph showing the changes in loss and accuracy during the training process of this invention. Figure 5 This is a schematic diagram of the confusion matrix for the classification of eight types of tongue appearance constitutions in this invention; Figure 6 This is a flowchart of the steps of the present invention. Detailed Implementation

[0015] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0016] Example 1: As Figure 6 As shown, a tongue appearance constitution classification method based on an improved ResNet18 model includes the following steps: S1: Perform size normalization, data augmentation, and standardization on the original tongue image to obtain a standardized tongue image; Optionally, obtaining the standardized tongue image specifically involves: The original tongue images were uniformly scaled to 224×224 pixels. The training set data augmentation was performed by random horizontal flipping (probability 0.3). The RGB channels were normalized with mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225] to avoid introducing additional noise that would affect the accuracy of the tongue image features.

[0017] S2: Perform lightweight reconstruction on the original ResNet18 model to obtain an improved ResNet18 model; wherein, the lightweight reconstruction involves freezing all parameters of the backbone network except for layer 4 and the fully connected layer, and reconstructing the fully connected layer; Optionally, the improved ResNet18 model obtained is specifically as follows: Load the native ResNet18 model pre-trained on the ImageNet dataset and freeze all network parameters except for layer 4 and the fully connected layer; Since the pre-trained native ResNet18 model already has the advantage of sufficient representational power, this advantage can be reused and the amount of computation can be reduced after freezing. Therefore, only shallow and medium convolutional layers are needed to extract general low-order visual features. Since tongue appearance diagnosis relies on high-level medical features specific to tongue appearance, it is only necessary to extract high-level semantic features through layer 4. By reconstructing the fully connected layer, general low-order visual features and high-order semantic features are mapped to the category space; It is important to understand that layer 4 and the fully connected layer need to retain trainability to adapt to the tongue image data distribution, and unfreezing only these two layers can significantly reduce the number of parameters and avoid overfitting to small sample tongue image datasets.

[0018] Optionally, the reconstructed fully connected layer involves sequentially introducing Dropout regularization, BatchNorm1d normalization, and small-scale weight initialization into the fully connected layer, specifically as follows: The reconstructed fully connected layers are, in order: a Dropout layer with a probability of 0.3, a linear layer with an input dimension of 512 and an output dimension of 256, a BatchNorm1d layer, a ReLU activation layer, a Dropout layer with a probability of 0.2, and a linear layer with an input dimension of 256 and an output dimension of 8.

[0019] It is understandable that this embodiment reconstructs the fully connected layers of the original ResNet18 model, uses Dropout layers to suppress redundant features and overfitting, uses linear layers to achieve feature dimensionality reduction and retain core features, uses BatchNorm1d layers to stabilize feature distribution, and uses ReLU activation layers to enhance feature expression capabilities. This solves the problems that the original fully connected layers are not adapted to tongue image features, lack normalization and regularization, and are prone to abnormal feature distribution and insufficient discrimination.

[0020] S3: Train the improved ResNet18 model; wherein the training adopts label smooth cross-entropy loss, combined with gradient pruning, cosine annealing learning rate scheduling and early stopping strategy; Optionally, the parameter settings are specifically adapted for the tongue image classification scenario. The training of the improved ResNet18 model specifically involves: The label smoothing cross-entropy loss function is set with a smoothing coefficient of 0.1, and the confidence of the true label is reduced and the remaining confidence is evenly distributed to other categories to reduce the model's over-reliance on the training labels and adapt to the subjective differences in tongue image label annotation. Gradient clipping sets the maximum norm to 1.0 and imposes norm constraints on the backpropagation gradients to suppress gradient explosion at its source, avoid numerical oscillations during training, and ensure training stability. The cosine annealing learning rate scheduling period is set to 50 rounds, and the minimum learning rate is 1e-6. By adaptively decaying the learning rate according to the cosine curve, it achieves rapid convergence in the early stage and fine-tuning in the later stage, which is adapted to the training convergence rhythm of the tongue image model. The early stopping strategy sets the patience value to 10 rounds. By monitoring the accuracy of the validation set, training is terminated when there is no improvement after 10 consecutive rounds, thus avoiding overfitting caused by ineffective training while preserving the optimal model performance.

[0021] S4: Input the standardized tongue image into the trained improved ResNet18 model, extract the tongue color and texture features, and then convert them into the probability distribution of tongue constitution through the softmax function to obtain the tongue constitution classification result.

[0022] Furthermore, this embodiment provides a tongue appearance constitution classification system based on an improved ResNet18 model, comprising: Preprocessing module: used for resizing, random horizontal flipping, and normalization of the original tongue image; Model building module: includes layer freezing unit and fully connected layer reconstruction unit to achieve the initialization of the improved ResNet18 model; Optionally, the layer freezing unit only unfreezes the parameters of layer 4 and fully connected layers of ResNet18, and the fully connected layer reconstruction unit supports dynamic adaptation for 8 and 9 types of tongue appearance constitution classification. The dynamic adaptation is to adjust the output dimension using the reconstructed linear layer of the output layer without changing the overall structure of the model. Only the output dimension needs to be adjusted to 8 or 9 to adapt to the tongue appearance constitution classification requirements in different scenarios.

[0023] It is important to understand that the nine types of tongue appearance constitution classification are an additional sub-type based on the eight types. They are not completely different classification systems. The core classification logic and feature extraction methods are the same. Therefore, there is no need to design a separate model structure. You only need to dynamically adjust the output dimension to achieve adaptation.

[0024] Training optimization module: includes loss calculation unit, gradient optimization unit and early stopping unit, to realize model training; Classification Decision Module: Includes feature extraction unit, probability calculation unit and visualization unit, to realize tongue appearance constitution classification and result display.

[0025] Optionally, the probability calculation unit performs probabilistic mapping on the unnormalized logits output by the model using the softmax function, and finally outputs the confidence probability of each category of tongue appearance.

[0026] Optionally, the visualization unit is displayed in the form of a probability visualization chart, which includes the original tongue image and a category probability level bar chart. The probability value corresponding to each category in the bar chart is accurate to one decimal place, which intuitively shows the model's confidence in judging the constitution of each category of tongue image.

[0027] Specifically, such as Figure 1The diagram shows the system architecture, illustrating the signal flow relationships between the four main modules: preprocessing, model building, training optimization, and classification decision. This invention's classification system utilizes the collaborative work of these four modules to complete the entire process of tongue constitution classification. The specific implementation process is as follows: First, the acquired tongue images are input into the preprocessing module. After standardization and data augmentation, a standardized image suitable for model input is obtained. Second, the standardized image is split into two paths: one path is input into the improved ResNet18 model building module to complete model initialization and structural adaptation; the other path, combined with training labels, is input into the training optimization module to complete model training and optimal weight saving. Finally, the preprocessed tongue images are input into the trained optimal model. The classification decision module performs feature extraction, probability calculation, and result visualization, ultimately outputting the tongue constitution classification result.

[0028] Optionally, the preprocessing module adopts a self-developed TongueImagePreprocess structure for standardized processing and data augmentation of tongue images. This addresses the problem that existing general image preprocessing methods are not adapted to the color and texture features of tongue images, leading to distorted feature extraction and low classification accuracy in subsequent steps. Specifically, it includes: Size normalization unit: Resizes tongue images to 224×224 pixels to match the input dimension of the ResNet18 model and avoids feature extraction deviations caused by inconsistent image sizes; Data augmentation unit: Introduces random horizontal flipping (trigger probability 0.3) into the training set to simulate the tongue image morphology under different shooting angles, effectively improving the model's generalization ability and solving the problems of model overfitting and poor adaptability to new samples in small sample tongue image datasets; Standardized Units: The RGB channels are normalized using ImageNet pre-trained mean [0.485, 0.456, 0.406] and standard deviation [0.229, 0.224, 0.225], which effectively eliminates color scale differences in tongue images, adapts to the accurate extraction of tongue color features (such as red or pale tongue body, thick or thin white tongue coating, etc.), and avoids classification errors caused by color interference.

[0029] Furthermore, this embodiment improves the adaptability of the ResNet18 model to tongue image features by modifying the fully connected layer structure. The specific structural implementation is as follows: Figure 2 The diagram shown is a self-created FixedResNet18 fully connected layer structure, demonstrating the connection methods of Dropout, BatchNorm1d, and linear layers. It is a design to address the problem that the native ResNet18 fully connected layer is not adapted to tongue image features and is prone to abnormal feature distribution.

[0030] The specific implementation steps are as follows: First, load the ImageNet1K_V1 (ImageNet data 1K version 1) pre-trained ResNet18 model. Freeze all parameters except layer 4 and the fully connected layer using the layer freezing unit to reuse the general low-order visual feature extraction capability of the pre-trained model while reducing computational cost. Then, reconstruct the original fully connected layer using the fully connected layer reconstruction unit to adapt it to tongue image features. The reconstructed fully connected layer takes the 512-dimensional features output by ResNet18avgpool as input and sequentially connects to Dropout. The system consists of a random deactivation layer (probability 0.3), a linear layer (input dimension 512, output dimension 256), a BatchNorm1d (one-dimensional batch normalization) layer, a ReLU activation layer, a Dropout layer (probability 0.2), and a linear layer (input dimension 256, output dimension 8), adapting to the classification requirements of 8 types of tongue appearance constitution. Finally, the system initializes the weights of the last linear layer to a normal distribution with a mean of 0.0 and a standard deviation of 0.01, and initializes the bias to 0.0 to avoid abnormal distribution of output logits and ensure stable feature mapping.

[0031] Furthermore, to address the issues of gradient explosion, abnormal loss, and overfitting during the training of the native ResNet18, this invention designs the StableTrainOptimizer structure. The specific training process is implemented as follows: Figure 3 The diagram shows the training process of StableTrainOptimizer, which includes loss calculation, gradient pruning, learning rate scheduling, and early stopping logic. Each step works together to achieve stable training of the model.

[0032] The specific implementation steps are as follows: First, through the loss calculation unit, the label smoothing cross-entropy loss function (smoothing coefficient 0.1) is adopted to reduce the model's excessive dependence on training set labels and adapt to the subjective differences in tongue image label annotation. Second, through the gradient optimization unit, gradient clipping (maximum norm 1.0) is introduced to constrain the norm of the backpropagation gradient to prevent gradient explosion. At the same time, the AdamW optimizer (learning rate 5e-4, weight decay 1e-4) is adopted to improve training stability. Third, through the learning rate scheduling unit, a cosine annealing learning rate scheduler is adopted with a period of 50 rounds and a minimum learning rate of 1e-6 to achieve adaptive decay of the learning rate, balancing rapid model convergence and fine-tuning. Fourth, through the early stopping unit, a patience value of 10 rounds is set to monitor the validation set accuracy in real time. When there is no improvement for 10 consecutive rounds, training is terminated to save the optimal model weights, avoid overfitting, and ensure the model's generalization ability.

[0033] To verify the effectiveness of this invention, targeted experiments were conducted in this embodiment. The experiments used eight types of tongue appearance constitution datasets (covering Qi deficiency, Qi stagnation, damp heat, phlegm dampness, special constitution, blood stasis, Yang deficiency, and Yin deficiency), and divided the training set and validation set in a 7:3 ratio. The performance of the original ResNet18 model and the improved ResNet18 model of this invention were compared with the evaluation indicators of accuracy, precision, recall, and F1 score.

[0034] like Figure 4 The curves showing the changes in training loss and accuracy demonstrate the convergence of the model during training. As can be seen from the curves, both the training loss and validation loss of this invention exhibit a steady downward trend without significant oscillations. They decrease rapidly in the early stages of training (1-10 rounds) and stabilize in the later stages (after 30 rounds), indicating stable model training. Simultaneously, the training accuracy and validation accuracy increase synchronously, converging to a relatively high level after 30 rounds, with no significant overfitting (the difference between training accuracy and validation accuracy is small). This proves that the training optimization strategy of this invention effectively solves the problems of instability and overfitting in the original model training, achieving rapid and stable model convergence.

[0035] like Figure 5 The diagram shows a confusion matrix for classifying eight types of tongue appearance constitutions, illustrating the distribution of classification precision and recall for each category. Rows in the confusion matrix represent the true categories, columns represent the predicted categories, and the element values ​​represent the classification accuracy (after normalization) for that category. The confusion matrix reveals that the classification accuracy for Qi deficiency, Qi stagnation, special constitution, blood stasis, and Yin deficiency all reach 100%, achieving complete and accurate identification. While there are a few misclassifications for damp-heat, phlegm-dampness, and Yang deficiency constitutions (mainly due to the high similarity in color and texture features between these two types of tongue appearances), their classification accuracy remains above 88%, demonstrating excellent overall classification performance. This indicates that the improved model of this invention can effectively extract core tongue appearance features and possesses strong category discrimination capabilities.

[0036] To further quantify the model's classification performance, the experiment was conducted on a dataset containing samples of eight different physical constitutions. Cross-validation was used to evaluate the model's generalization ability, and the precision, recall, F1 score, and overall metrics for each category were statistically analyzed. The experimental results are shown in Tables 1 and 2.

[0037] Table 1. Detailed Indicators for Tongue Appearance and Physical Constitution Classification

[0038] Table 2 Summary of Overall Indicators

[0039] Table 1 details the precision, recall, and F1 score for each of the eight tongue appearance constitutions. It can be seen that the precision, recall, and F1 score for the five constitutions of Qi deficiency, Qi stagnation, special constitution, blood stasis, and Yin deficiency are all 1.0000. The F1 scores for damp-heat, phlegm-dampness, and Yang deficiency are 0.9922, 0.9706, and 0.9143, respectively. All indicators for each category are at a high level, demonstrating the excellent classification accuracy of the model for various tongue appearance constitutions.

[0040] Table 2 summarizes the overall classification metrics of the model, with an overall accuracy of 0.9854, an overall macro-average precision of 0.9855, an overall macro-average recall of 0.9842, and an overall macro-average F1 score of 0.9846. All overall metrics exceed 98%, significantly outperforming the native ResNet18 model. The experimental data above fully demonstrate that this invention, through the collaborative design of preprocessing, model improvement, and training optimization, effectively solves the problems of low accuracy and poor generalization ability in existing tongue appearance classification methods, exhibiting extremely high classification accuracy and stability.

[0041] Furthermore, the classification decision module, as the output stage of this invention, specifically implements the following steps: The preprocessed tongue image to be classified is input into the trained, optimally improved ResNet18 model. The feature extraction unit extracts the core features of tongue color and texture. Then, the probability calculation unit uses the softmax function to convert the model's output logits into a probability distribution of eight tongue constitution types, ensuring the interpretability of the classification results. Finally, the visualization unit outputs a horizontal bar chart of the original tongue image and category probabilities, visually displaying the probability distribution of each category for easy viewing of the classification results. Simultaneously, the anomaly monitoring unit monitors the mean and standard deviation of logits in real time during training, filtering out NaN loss batches to ensure training continuity and the reliability of the classification decision results.

[0042] In summary, this invention first performs standardized preprocessing on the original tongue image, obtaining a tongue image tensor adapted to the model input through size normalization, targeted data augmentation, and color channel normalization. Second, it performs lightweight reconstruction of the original ResNet18 model, freezing all parameters of the backbone network except for layer 4 and the fully connected layers. Simultaneously, it introduces Dropout regularization, BatchNorm1d normalization, and small-scale weight initialization sequentially into the fully connected layers to optimize the normalized representation of tongue image features. Third, it employs a label-smooth cross-entropy loss function to reduce the risk of overfitting the model to the training labels. Combined with gradient clipping, cosine annealing learning rate scheduling, and early stopping strategies, it constructs a stable training framework to address training instability issues such as gradient explosion and abnormal loss. Finally, it inputs the preprocessed tongue image into the trained improved ResNet18 model, outputting the probability distribution of multiple tongue image constitutions through the softmax function to obtain the final classification result. Meanwhile, this invention also proposes a tongue constitution classification system based on an improved ResNet18 model. Through the self-created TongueImagePreprocess preprocessing structure, FixedResNet18 model structure, and StableTrainOptimizer training structure, it specifically solves many problems of the native ResNet18 model in tongue constitution classification. Experimental results show that the model is stable in training, has high classification accuracy, and strong generalization ability, making it suitable for practical applications of small to medium-sized tongue image datasets (such as rapid diagnosis of TCM constitution). It can effectively achieve automated and accurate classification of tongue constitution.

[0043] The specific embodiments of the present invention have been described in detail above with reference to the accompanying drawings. However, the present invention is not limited to the above embodiments. Within the scope of knowledge possessed by those skilled in the art, various changes can be made without departing from the spirit of the present invention.

Claims

1. A tongue appearance constitution classification method based on an improved ResNet18 model, characterized in that, The method includes the following steps: S1: Perform size normalization, data augmentation, and standardization on the original tongue image to obtain a standardized tongue image; S2: Perform lightweight reconstruction on the original ResNet18 model to obtain an improved ResNet18 model; wherein, the lightweight reconstruction involves freezing all parameters of the backbone network except for layer 4 and the fully connected layer, and reconstructing the fully connected layer; S3: Train the improved ResNet18 model; wherein the training adopts label smooth cross-entropy loss, combined with gradient pruning, cosine annealing learning rate scheduling and early stopping strategy; S4: Input the standardized tongue image into the trained improved ResNet18 model, extract the tongue color and texture features, and then convert them into the probability distribution of tongue constitution through the softmax function to obtain the tongue constitution classification result.

2. The tongue appearance constitution classification method based on the improved ResNet18 model according to claim 1, characterized in that, The improved ResNet18 model obtained is specifically as follows: Load the pre-trained native ResNet18 model and freeze all network parameters except for layer 4 and the fully connected layer; Common low-level visual features are extracted through shallow and mid-level convolutional layers; High-order semantic features are extracted using layer 4. By reconstructing the fully connected layer, general low-order visual features and high-order semantic features are mapped to the category space.

3. The tongue appearance constitution classification method based on the improved ResNet18 model according to claim 2, characterized in that, The reconstructed fully connected layer involves sequentially introducing Dropout regularization, BatchNorm1d normalization, and small-scale weight initialization into the fully connected layer. Specifically... The reconstructed fully connected layers are, in order: a Dropout layer with a probability of 0.3, a linear layer with an input dimension of 512 and an output dimension of 256, a BatchNorm1d layer, a ReLU activation layer, a Dropout layer with a probability of 0.2, and a linear layer with an input dimension of 256 and an output dimension of 8.

4. The tongue appearance constitution classification method based on the improved ResNet18 model according to claim 1, characterized in that, The specific steps for training the improved ResNet18 model are as follows: The label smoothing cross-entropy loss function is set with a smoothing coefficient of 0.1, and the true label confidence is reduced and the remaining confidence is evenly distributed to other categories; Gradient clipping sets the maximum norm to 1.0 and imposes norm constraints on the backpropagation gradient; The cosine annealing learning rate scheduling period is set to 50 rounds, with a minimum learning rate of 1e-6, and the learning rate is adaptively decayed according to the cosine curve. The early stop strategy has a patience value of 10 rounds. The training is terminated when the accuracy of the validation set fails to improve after 10 consecutive rounds.

5. A tongue appearance constitution classification system based on an improved ResNet18 model, characterized in that, include: Preprocessing module: used for resizing, random horizontal flipping, and normalization of the original tongue image; Model building module: includes layer freezing unit and fully connected layer reconstruction unit to achieve the initialization of the improved ResNet18 model; Training optimization module: includes loss calculation unit, gradient optimization unit and early stopping unit, to realize model training; Classification Decision Module: Includes feature extraction unit, probability calculation unit and visualization unit, to realize tongue appearance constitution classification and result display.

6. A tongue appearance constitution classification system based on an improved ResNet18 model according to claim 5, characterized in that, The layer freezing unit only unfreezes the parameters of ResNet18's layer 4 and fully connected layers. The fully connected layer reconstruction unit supports dynamic adaptation for 8 and 9 types of tongue appearance classification. The dynamic adaptation uses the reconstructed linear output layer to adjust the output dimension without changing the overall model structure; only the output dimension needs to be adjusted to 8 or 9.

7. A tongue constitution classification system based on an improved ResNet18 model according to claim 5, characterized in that, The probability calculation unit performs probabilistic mapping on the unnormalized logits output by the model using the softmax function, and finally outputs the confidence probability of each category of tongue appearance.