Cornea conus element learning diagnosis method under unbalanced small sample condition

The keratoconus meta-learning diagnostic method, which optimizes balanced task sampling and joint loss, solves the problems of small sample size and class imbalance, and achieves high-precision early keratoconus identification and assisted diagnosis, thereby improving the diagnostic accuracy of the model.

CN121998903APending Publication Date: 2026-05-08FUJIAN NORMAL UNIV +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
FUJIAN NORMAL UNIV
Filing Date
2025-12-19
Publication Date
2026-05-08

AI Technical Summary

Technical Problem

Under imbalanced small sample conditions, existing AI models have difficulty effectively identifying early-stage keratoconus, resulting in a high misdiagnosis rate. Furthermore, the fragmentation of medical data and insufficient sample size affect the diagnostic performance of deep learning methods.

Method used

A keratoconus cell learning diagnostic method under imbalanced small sample conditions is adopted. Through balanced task sampling, Swin Transformer feature extraction, multi-prototype computation and joint loss function optimization, high-quality feature representation and diagnostic probability distribution are generated.

Benefits of technology

It improved the accuracy of early keratoconus identification, enhanced the model's classification performance under small sample conditions, and provided high-precision auxiliary diagnostic support.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121998903A_ABST
    Figure CN121998903A_ABST
Patent Text Reader

Abstract

The invention discloses a keratoconus element learning diagnosis method under an unbalanced small sample condition. The method comprises two parts of model training and auxiliary reasoning. According to the model training part, firstly, an acquired corneal topographic map is preprocessed and labeled, and then a meta-learning task ensuring complete categories is constructed by adopting a balance task sampler. And a pre-trained Swin Transform is used as a feature extractor to acquire the multi-scale depth features of the image. A plurality of prototypes are generated for early keratoconus categories with high diagnosis difficulty by using K-means clustering, and other categories are uniformly grouped. Classification is completed by calculating the distance between a query sample and a prototype and carrying out probability aggregation, and meta-learning optimization is carried out by adopting a joint loss function combining enhanced focus loss and contrast learning loss. And the auxiliary reasoning part is used for extracting input image features by using the trained model, comparing the input image features with the learned prototype, and outputting a diagnosis category and confidence. According to the method, the auxiliary diagnosis accuracy and generalization ability of the keratoconus are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of medical image analysis, and more particularly to a method for learning and diagnosing keratoconus under unbalanced small sample conditions. Background Technology

[0002] Keratoconus (KC) is a progressive, bilateral corneal ectasia characterized by a steepening of the cornea into a cone shape, irregular thinning of the stroma, and significant vision loss. The disease typically manifests in adolescence or early adulthood, with younger ages showing faster progression. Early symptoms of keratoconus are often subtle; patients may only experience mild blurred vision or astigmatism, making it easily overlooked during routine eye examinations. Statistics show that in developing countries, only about 30% of early cases are detected through routine screening, while the undiagnosed rate among refractive surgery candidates is as high as 17.5%. However, without intervention, early keratoconus exhibits significant progression. Studies show that early cases experience an average annual increase in corneal curvature (Kmax) of 0.65D and a decrease in corneal thickness at the thinnest point of 15μm. Approximately 20% of patients will develop severe keratoconus within 10 years, requiring corneal transplantation. With timely intervention, early treatment reduces the incidence of severe keratoconus by 83% and the need for corneal transplantation by 92%. Early diagnosis of keratoconus is of great clinical value for preventing iatrogenic corneal ectasia, implementing corneal collagen cross-linking therapy, and reducing the need for corneal transplantation.

[0003] However, medical data is fragmented due to privacy restrictions, with limited patient data from individual hospitals and small sample sizes for research, making it difficult to meet the demands of mainstream deep learning methods for large-scale labeled data. Furthermore, existing AI models often favor the majority class when dealing with imbalanced data, exhibiting weak ability to identify the minority class. In actual diagnosis, the number of patients with early-stage keratoconus is far less than the number of normal and keratoconus patients; this imbalance makes it difficult for models to learn the characteristic representations of early-stage keratoconus, leading to a high misdiagnosis rate. Summary of the Invention

[0004] The purpose of this invention is to provide a keratoconus cell learning diagnostic method under imbalanced small sample conditions, which solves the problem of small sample and class imbalance and improves the accuracy of early keratoconus identification.

[0005] The technical solution adopted in this invention is:

[0006] A model-based diagnostic method for keratoconus under imbalanced small sample conditions, comprising a model training part and an auxiliary inference part, including the following steps:

[0007] Model training section:

[0008] Step 1-1, Data Preprocessing: Pentacam HR corneal topography maps were collected and labeled by ophthalmologists as three types of samples: normal cornea, early keratoconus, and keratoconus. The images were then cropped, denoised, standardized, and sized to obtain a preprocessed dataset.

[0009] Step 1-2, Task Construction: Divide the preprocessed dataset into training set, validation set and test set according to the proportion. Use a balanced task sampler to construct a set of meta-learning tasks, where each task contains a support set and a query set. The support set and query set are used for prototype computation and model evaluation, respectively.

[0010] Steps 1-3, Feature Extraction: Using a pre-trained Swing Transformer as a feature extractor, multi-stage feature extraction is performed on the input image to output a 512-dimensional feature vector;

[0011] Steps 1-4, Multi-prototype computation: Based on the feature vectors extracted from the support set samples, K-means clustering algorithm is used to generate multiple prototype vectors for the early keratoconus category, and uniform grouping strategy is used to generate prototype vectors for the normal cornea and keratoconus categories; Steps 1-5, Classification decision: Calculate the Euclidean distance between the feature vectors of the query set samples and all prototype vectors, transform and normalize the Euclidean distance into a probability distribution through negative exponential transformation and softmax function, and use a category probability aggregation mechanism to aggregate the probabilities of multiple prototypes of the same category to obtain the final category probability distribution for categories with multiple prototypes;

[0012] Steps 1-6, Loss Optimization: Construct a joint loss function by combining the augmentation focus loss and the contrastive learning loss, and use the joint loss function to optimize the model;

[0013] Steps 1-7, Meta-learning update: The outer loop update mechanism is used to optimize the feature extractor parameters through multi-task learning. The average loss is calculated based on the query set loss of multiple tasks. The backpropagation algorithm is used to update the parameters of the feature extractor until the model converges and the trained meta-learning model is obtained.

[0014] Auxiliary reasoning section:

[0015] Step 2-1: Input the preprocessed corneal topography map to be used for assisted diagnosis;

[0016] Step 2-2: Use the feature extractor of the trained meta-learning model to extract the feature vector of the image;

[0017] Steps 2-3: Calculate the Euclidean distance between the corresponding feature vector and the prototype vector of each category, and aggregate the multi-prototype outputs using the softmax function to obtain the category probability distribution;

[0018] Steps 2-4: Output the auxiliary reasoning diagnosis result and corresponding confidence level based on the highest probability. The diagnosis categories include normal cornea, early keratoconus, or keratoconus.

[0019] Furthermore, in steps 1-2, the balanced task sampler adjusts the preset task configuration parameters and combines a multi-stage priority sampling strategy to ensure that each task includes all three diagnostic categories. At the same time, it prioritizes sampling without replacement and automatically switches to sampling with replacement when the number of category samples is insufficient, so that the generated meta-learning tasks achieve a balanced distribution in the categories.

[0020] Furthermore, the task construction formula in steps 1-2 is as follows:

[0021]

[0022] Among them, S i Let Q represent the support set for the i-th task. i Let N represent the query set for the i-th task; N represents the number of categories contained in the task; M represents the number of samples in each category of the support set; and Q represents the number of samples in each category of the support set.

[0023] Furthermore, the feature extraction process of the Swin Transformer in steps 1-3 includes:

[0024] Step 1-3-1: The input image is segmented into 4×4 pixel blocks by the Patch Embedding layer and mapped to a 96-dimensional feature space to generate an initial feature representation of 56×56×96.

[0025] Steps 1-3-2 involve feature extraction through multiple Swing Transformer blocks in four stages. Each Swing Transformer block includes window multi-head self-attention, moving window multi-head self-attention, and multilayer perceptron.

[0026] Step 1-3-3: The features extracted through the four stages are compressed into a 512-dimensional feature vector through global average pooling and linear projection layers.

[0027] Furthermore, the formula for calculating the feature representation using the moving window multi-head self-attention mechanism in step 1-3-2 is as follows:

[0028]

[0029] Where Q, K, and V represent query, key value, and numerical matrix, respectively, d represents feature dimension, and B represents relative position bias.

[0030] Furthermore, in steps 1-4, the K-means clustering algorithm is used to generate four prototypes:

[0031]

[0032] Two prototypes were generated using a uniform grouping strategy for normal cornea and keratoconus:

[0033]

[0034] Where f represents the sample feature vector in the dataset, and P represents the prototype; This represents the k-th cluster of the c-th class. This represents the l-th group of the c-th class.

[0035] Furthermore, in steps 1-5, for categories with multiple prototypes, a maximum value aggregation strategy is used to select the maximum probability among all prototypes of the corresponding category and the query sample as the final probability of the corresponding category.

[0036] Furthermore, the Euclidean distance between each query sample and all prototypes in steps 1-5 is calculated using the following formula:

[0037]

[0038] The expression for converting Euclidean distance into probability distributions and then clustering the multi-prototype probabilities of contract categories is as follows:

[0039]

[0040] Among them, f q Indicates the query sample; For the k-th prototype of class c; C represents the total number of classes; τ represents the temperature parameter, K c c represents the number of prototypes in class c; c′ is the index variable for all classes; K c′ This represents the number of prototypes of class c′; For the kth class of class c′ ′ A prototype.

[0041] Furthermore, steps 1-6 use the Adam optimizer and the ReduceLROnPlateau learning rate scheduling strategy to optimize the feature extractor parameters, and the expression for the joint loss function is as follows:

[0042] L total =L focal +λ contrastive ×L contrastive ;

[0043]

[0044] Among them, L focal To enhance focus loss; L contrastive To contrast the learning loss; λcontrastive The weighting coefficients for the learning loss are used for comparison; p represents the category weight. i The model predicts the probability that a sample belongs to the i-th class; γ represents the focus parameter; H represents the proportion of samples mined through hard negative samples; f q To query the feature vector of a sample, f s + Represents the query sample f q The feature vectors of support samples belonging to the same category, where τ is the temperature parameter, and f s - Represents the query sample f q Feature vectors of support samples belonging to different categories.

[0045] Furthermore, in steps 1-7, multiple meta-learning tasks are constructed in each iteration epoch, and the tasks are processed in batches. For each task, the model prototype is recalculated and distance metric classification is performed first, and then the joint loss function is calculated. The query set loss of all tasks is collected to calculate the average loss, and the parameters of the feature extractor are updated through the backpropagation algorithm.

[0046] This invention employs the above technical solution. Regarding model training, firstly, corneal topographic data is collected for diagnostic category labeling. The labeled dataset is then used to construct meta-learning training tasks through a balanced task sampler, ensuring that each task includes three categories: normal cornea, early keratoconus, and keratoconus. A category folding mechanism is used to enhance the representation of minority class samples. During training, the support set images of the task are input into a pre-trained Swin Transformer feature extractor to obtain 512-dimensional feature vectors. Based on these features, adaptive prototype recalculation is performed, assigning different numbers of prototype vectors to different categories. For example, early keratoconus uses K-means clustering to generate 4 prototypes, while normal cornea and keratoconus use uniform grouping to generate 2 prototypes. Secondly, feature extraction is performed on the query set samples, and the Euclidean distance between them and all prototypes is calculated to achieve distance-based classification. The distances are converted into probability distributions, and the probabilities of multiple prototypes of the same category are clustered to obtain the final prediction result. The training process calculates a joint loss function based on the prediction results and the true labels. This loss function consists of an enhancement focus loss and a contrastive learning loss. The focus loss addresses class imbalance by using the gamma parameter and class weights, while the contrastive learning loss enhances feature discriminativeness by using the temperature parameter and the proportion of hard negative samples. The two losses are weighted and combined to construct a total loss function. Backpropagation optimizes the feature extractor weights, and the ReduceLROnPlateau learning rate scheduling strategy is used to dynamically adjust the learning rate based on the validation performance, resulting in a converged task-adaptive prototype network model.

[0047] For intelligent diagnosis of keratoconus, the corneal topography map to be diagnosed is first input into the trained SwinTransformer feature extractor for feature extraction, obtaining a high-quality 512-dimensional feature representation. Then, the Euclidean distance is calculated between this feature vector and pre-calculated or dynamically recalculated prototype vectors for each category, and the diagnostic category of the sample is determined by a nearest neighbor classifier. Next, based on the distance distribution and probability aggregation mechanism, the probability distribution of the sample belonging to normal cornea, early keratoconus, and keratoconus is output, providing clinicians with quantitative confidence in the auxiliary diagnosis. Using a task-adaptive prototype network as the main body, combined with balanced task sampling and joint loss optimization, this approach overcomes the shortcomings of traditional deep learning methods in small-sample medical scenarios, achieving better auxiliary diagnostic results and improving the accuracy and clinical applicability of early keratoconus detection.

[0048] The beneficial effects of this invention are as follows: This invention effectively solves the problems of small sample learning and class imbalance faced by current medical image-assisted diagnostic systems, improving the classification performance and early detection capability of keratoconus auxiliary diagnostic models under limited sample conditions. This method uses balanced task sampling to construct training tasks, achieves rapid adaptation through task-adaptive prototype recomputation, and employs a joint loss function to optimize and enhance the model's feature representation quality and classification accuracy. Compared to traditional standard CNN classifiers and univariate learning methods, this method achieves better auxiliary diagnostic results. This invention effectively handles the class imbalance problem of medical data through a multi-prototype representation mechanism and achieves high-precision classification judgment under limited sample conditions through a meta-learning framework, providing effective technical support for the intelligent diagnosis of keratoconus and possessing significant clinical application value. Attached Figure Description

[0049] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments;

[0050] Figure 1 This is a schematic diagram of the model training process of the present invention;

[0051] Figure 2 This is a comparison diagram of the dataset before and after preprocessing in this invention;

[0052] Figure 3 This is a flowchart of the balanced task sampler of the present invention;

[0053] Figure 4 This is a schematic diagram of the Swing Transformer feature extractor process of the present invention. Detailed Implementation

[0054] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.

[0055] Meta-learning, as a high-level paradigm, extracts transferable knowledge by analyzing learning experiences from multiple tasks, enabling rapid adaptation to new tasks, and is particularly adept at solving the few-shot learning (FSL) problem. MAML is a model-agnostic meta-learning framework whose core goal is to learn a universal set of initialization parameters, allowing the model to quickly adapt to new tasks with only a small number of samples and gradient update steps. ProtoNet is a metric-based meta-learning algorithm whose core idea is to learn a metric space where the embedding vectors of similar samples are tightly clustered, while dissimilar samples are separated. Balanced task sampling strategies are a core technique for addressing uneven data distribution, aiming to improve the model's generalization ability to minority classes or complex tasks by adjusting the distribution of training data.

[0056] like Figures 1 to 4 As shown in one example, this invention discloses a keratoconus cell learning diagnostic method under imbalanced small sample conditions, which solves the problem of small sample and class imbalance and improves the accuracy of early keratoconus identification.

[0057] This invention discloses a method for keratoconus cell learning diagnosis under unbalanced small sample conditions. Figure 1 The specific steps for model training are as follows:

[0058] Step 1-1: Collect corneal topography data x∈R h×w×c Where h represents the image height, w represents the image width, and c represents the number of image channels, the corneal topography is categorized according to clinical diagnostic criteria, including three categories: normal cornea, early keratoconus (E-KC), and keratoconus (KC).

[0059] Specifically, the Pentacam HR corneal topography images were acquired using Scheimpflug rotating camera technology to obtain high-resolution images of the anterior and posterior corneal surfaces. Each image had a resolution of 2048×1536 pixels and included RGB three-channel information. Ophthalmologists categorized the images into three types of samples: normal cornea, early keratoconus (e-KC), and keratoconus (KC). The parameters on the left side of the corneal topography were removed, retaining only the right side. Numerical values ​​on the topography were also removed, and the images underwent cropping, noise reduction, standardization, and size normalization.

[0060] Steps 1-2 involve using stratified random sampling to divide the dataset into training, validation, and test sets in a 7:1.5:1.5 ratio, ensuring consistent distribution of each category across different datasets. A balanced task sampling strategy is then implemented on the training set, such as... Figure 3As shown, an N-way K-shot meta-learning task is constructed, where N=3 indicates that each task contains 3 classes, K=5 indicates that each class in the support set contains 5 samples, and each class in the query set contains 15 samples. The task construction formula is shown below:

[0061]

[0062] Where S i Let Q represent the support set for the i-th task. i This represents the query set for the i-th task.

[0063] Steps 1-3 involve inputting the meta-learning task constructed in Steps 1-2 into the pre-trained Swin Transformer feature extractor for feature extraction. The feature extraction process begins by inputting a 224×224×3 corneal topography map into the Patch Embedding layer. This layer divides the image into 4×4 pixel patches, each of which is linearly projected onto a 96-dimensional feature space, generating an initial feature representation of 56×56×96. This fine-grained patch division captures subtle changes on the corneal surface, preserving important spatial relationship information. Subsequently, the feature map is processed sequentially through four stages of Swin Transformer blocks. Each stage contains multiple Swin Transformer blocks, each consisting of Window Multi-Head Self-Attention (W-MSA), Moving Window Multi-Head Self-Attention (SW-MSA), and a Multilayer Perceptron (MLP). The first stage maintains a resolution of 56×56 with 96 channels and a window size of 7×7, primarily capturing local irregularities and texture features. The second stage reduces the resolution to 28×28 and increases the number of channels to 192, capturing medium-scale morphological features. The third stage further reduces the resolution to 14×14 and increases the number of channels to 384, identifying complex pathological patterns. The fourth stage reduces the resolution to 7×7 and increases the number of channels to 768, integrating global corneal morphological information. After feature extraction in these four stages, global average pooling and a linear projection layer compress the features into a 512-dimensional feature vector (FEATURE_DIM = 512).

[0064] like Figure 4 As shown, the Swin Transformer employs a hierarchical window attention mechanism, progressively extracting multi-scale feature representations from fine-grained to global levels through four stages. For the input image x, it first performs patch partitioning to obtain serialized tokens, and then calculates the feature representation through a moving window multi-head self-attention mechanism:

[0065]

[0066] Where Q, K, and V represent the query, key, and numerical matrix, respectively, d represents the feature dimension, and B represents the relative position bias. After four stages of feature extraction, a 512-dimensional global feature vector f(x)∈R is obtained. 512 .

[0067] Steps 1-4 involve adaptive prototype recomputation of tasks based on support set features. For each task T... i First, feature representations of the support set samples are extracted. Then, features are separated by category, and a differentiated prototype generation strategy is adopted. For the early keratoconus category (c=1), due to its complex pathological variations, four prototypes are generated using the K-means clustering algorithm:

[0068]

[0069] For the normal cornea and keratoconus categories, a uniform grouping strategy was used to generate two prototypes:

[0070]

[0071] Where f represents the sample feature vector in the dataset, and P represents the prototype; This represents the k-th cluster of the c-th class. This represents the l-th group of the c-th class.

[0072] Specifically, in steps 1-4, the model first processes the support set samples using a feature extractor with fixed parameters to obtain the 512-dimensional feature representation obtained in steps 1-3. Then, based on these features, an intelligent multi-prototype computation strategy is implemented, assigning different numbers of prototype vectors to different diagnostic categories. For the early-stage keratoconus category, which is complex and difficult to diagnose, multiple prototypes are generated using the K-means clustering algorithm. In practice, the feature vectors of the support set for this category are transferred to the CPU for clustering computation. The K-means algorithm is applied to group the features, and then the centroid of each cluster is calculated as the prototype vector. For the normal cornea and keratoconus categories, a uniform grouping strategy is used to generate prototypes. Specifically, the support set samples for each category are randomly and uniformly divided into two groups, and the mean of the features in each group is calculated as the prototype vector. After the prototype recalculation is completed, the model creates a new instance and sets the newly calculated prototype vector for subsequent classification decisions.

[0073] Steps 1-5 employ a distance-based classification mechanism, comparing the query sample with the calculated prototype vectors to simulate the diagnostic thought process of a clinician, making decisions based on similarity comparisons. For each sample in the query set, a 512-dimensional feature vector is first obtained using a feature extractor. Then, the Euclidean distance between this feature vector and all prototype vectors is calculated. After distance calculation, a negative exponential transformation is used to convert the distance into a similarity score, which is then normalized to a probability distribution using a softmax function. For categories with multiple prototypes, a category probability aggregation mechanism is used to aggregate the probabilities of multiple prototypes within the same category, resulting in the final category probability distribution. Specifically, a maximum value aggregation strategy is used, selecting the highest probability among all prototypes of the category for the query sample as the final probability for that category. Finally, the model selects the category with the highest probability as the diagnostic result.

[0074] Classify the query set samples using a distance metric. Extract query set features and calculate the Euclidean distance between each query sample and all prototypes:

[0075]

[0076] Convert distances into probability distributions and cluster the probabilities of multiple prototypes of the same category:

[0077]

[0078] Among them, f q Indicates the query sample; For the k-th prototype of class c; C represents the total number of classes; τ represents the temperature parameter, K c c represents the number of prototypes in class c; c′ is the index variable for all classes; K c′ This represents the number of prototypes of class c′; For the kth class of class c′ ′ A prototype.

[0079] Steps 1-6 utilize a joint loss function, combining Enhanced Focal Loss and Contrastive Learning Loss, to comprehensively optimize the model's classification performance and feature representation quality. Enhanced Focal Loss improves upon standard cross-entropy loss by handling class imbalance and difficult / easy sample issues through modulation factors and class weights. Contrastive Learning Loss enhances the discriminative power of the feature space by bringing features of similar samples closer together and distancing features of samples from different classes. The joint loss function consists of Enhanced Focal Loss and Contrastive Learning Loss.

[0080] L total =L focal +λ contrastive ×L contrastive ;

[0081] Enhanced focus loss addresses class imbalance by using class weights and easy / difficult sample weights:

[0082]

[0083] Where w0, w1, and w2 represent the weights of the three categories, and γ represents the focus parameter.

[0084] Among them, L focal To enhance focus loss; L contrastive To contrast the learning loss; λ contrastive The weighting coefficients for the comparative learning loss; w yi p represents the category weight. i γ represents the probability that the model predicts a sample belongs to the i-th category; γ represents the focus parameter.

[0085] Contrastive learning loss improves feature discriminativeness through hard negative sample mining:

[0086]

[0087] Where H represents the set of difficult negative samples selected by a hard negative sample mining ratio ρ = 0.7. q To query the feature vector of a sample, f s + Represents the query sample f q The feature vectors of support samples belonging to the same category, where τ is the temperature parameter, and f s - Represents the query sample f q Feature vectors of support samples belonging to different categories. The feature extractor parameters θ are optimized using the Adam optimizer and the ReduceLROnPlateau learning rate scheduling strategy. The learning rate starts at 0.00025 and decreases by 0.5 times when the validation loss does not improve for two consecutive epochs, until the model converges.

[0088] Steps 1-7: A meta-learning outer loop update mechanism is employed. Feature extractor parameters are optimized through multi-task learning, with unified updates based on the performance of multiple tasks within the outer loop. Each epoch constructs a training task, which is then processed in multiple batches. For each task, the model first performs prototype recalculation in steps 1-4 and distance metric classification in steps 1-5, then calculates the joint loss function in steps 1-6. The outer loop collects the query set loss for all tasks, calculates the average loss, and updates the feature extractor parameters using backpropagation. Parameters are continuously optimized until the model converges.

[0089] like Figure 2As shown, this sample is a partial corneal topography image, and the diagnostic categories include normal cornea, early keratoconus, and keratoconus. The first row shows the three types of raw corneal topography images, and the second row shows the results after image preprocessing. The specific implementation process of the method of this invention is as follows: for small-sample intelligent diagnostic tasks of corneal topography.

[0090] Model Training Process: A dataset containing 462 corneal topographic maps was used, including 235 normal corneas, 38 early keratoconus images, and 189 keratoconus images. When training the task-adaptive prototype network, a meta-learning task was first constructed using a balanced task sampler. Each task contained 3 classes, with 5 samples per class in the support set and 15 samples per class in the query set. A class folding mechanism was used, setting the folding for early keratoconus samples to 2.0 and for keratoconus samples to 3.0 to ensure sufficient representation of key classes in each task. When training the feature extractor, a pre-trained Swin Transformer was used as the backbone network, with a 224×224×3 corneal topographic map as input. A 512-dimensional feature vector was extracted using a 4-stage hierarchical window attention mechanism. When training the prototype computation module, 4 prototypes were assigned to early keratoconus and generated using K-means clustering, while 2 prototypes were assigned to normal corneas and keratoconus images each and generated using uniform grouping. The prototype vector dimension remained consistent with the feature vector at 512 dimensions. During training loss optimization, the joint loss function consists of an enhancement focus loss and a contrastive learning loss, with a weight ratio of 1:0.5. The category weights for the focus loss are set to 1.0 for normal cornea, 9.0 for early keratoconus, and 4.8 for keratoconus, with a gamma parameter of 2.0. The temperature parameter for the contrastive learning loss is set to 0.07, and the hard negative sample mining ratio is set to 0.7.

[0091] Model Testing Process: Independent test sets were used to construct test tasks, each containing support and query sets for three categories. For each test task, the trained Swin Transformer was first used to extract feature representations for the support and query sets. Then, prototype vectors for each category were recalculated based on the support set features. Next, the Euclidean distance between the query set samples and all prototypes was calculated. The final classification was achieved through distance metrics and probability aggregation. The model achieved an overall accuracy of 96.94% on the test set, with 97.50% accuracy for normal cornea, 96.67% accuracy for early keratoconus, and 96.67% accuracy for keratoconus. Performance across all categories was balanced and significantly superior to traditional deep learning methods.

[0092] Auxiliary reasoning section:

[0093] Step 2-1: Input the preprocessed corneal topography map into the trained meta-learning model.

[0094] Step 2-2: Use Swing Transformer to extract image features, calculate the Euclidean distance between them and various prototypes, and use softmax to aggregate the multi-prototype output to obtain the category probability distribution.

[0095] Steps 2-3: Output auxiliary reasoning diagnosis results. Output auxiliary reasoning diagnosis results based on the highest probability, including normal cornea, early keratoconus, or keratoconus, and output the corresponding confidence level.

[0096] This invention employs the above technical solution. Regarding model training, firstly, corneal topographic data is collected for diagnostic category labeling. The labeled dataset is then used to construct meta-learning training tasks through a balanced task sampler, ensuring that each task includes three categories: normal cornea, early keratoconus, and keratoconus. A category folding mechanism is used to enhance the representation of minority class samples. During training, the support set images of the task are input into a pre-trained Swin Transformer feature extractor to obtain 512-dimensional feature vectors. Based on these features, adaptive prototype recalculation is performed, assigning different numbers of prototype vectors to different categories. For example, early keratoconus uses K-means clustering to generate 4 prototypes, while normal cornea and keratoconus use uniform grouping to generate 2 prototypes. Secondly, feature extraction is performed on the query set samples, and the Euclidean distance between them and all prototypes is calculated to achieve distance-based classification. The distances are converted into probability distributions, and the probabilities of multiple prototypes of the same category are clustered to obtain the final prediction result. The training process calculates a joint loss function based on the prediction results and the true labels. This loss function consists of an enhancement focus loss and a contrastive learning loss. The focus loss addresses class imbalance by using the gamma parameter and class weights, while the contrastive learning loss enhances feature discriminativeness by using the temperature parameter and the proportion of hard negative samples. The two losses are weighted and combined to construct a total loss function. Backpropagation optimizes the feature extractor weights, and the ReduceLROnPlateau learning rate scheduling strategy is used to dynamically adjust the learning rate based on the validation performance, resulting in a converged task-adaptive prototype network model.

[0097] For intelligent diagnosis of keratoconus, the corneal topography map to be diagnosed is first input into the trained SwinTransformer feature extractor for feature extraction, obtaining a high-quality 512-dimensional feature representation. Then, the Euclidean distance is calculated between this feature vector and pre-calculated or dynamically recalculated prototype vectors for each category, and the diagnostic category of the sample is determined by a nearest neighbor classifier. Next, based on the distance distribution and probability aggregation mechanism, the probability distribution of the sample belonging to normal cornea, early keratoconus, and keratoconus is output, providing clinicians with quantitative confidence in the auxiliary diagnosis. Using a task-adaptive prototype network as the main body, combined with balanced task sampling and joint loss optimization, this approach overcomes the shortcomings of traditional deep learning methods in small-sample medical scenarios, achieving better auxiliary diagnostic results and improving the accuracy and clinical applicability of early keratoconus detection.

[0098] The beneficial effects of this invention are as follows: This invention effectively solves the problems of small sample learning and class imbalance faced by current medical image-assisted diagnostic systems, improving the classification performance and early detection capability of keratoconus auxiliary diagnostic models under limited sample conditions. This method uses balanced task sampling to construct training tasks, achieves rapid adaptation through task-adaptive prototype recomputation, and employs a joint loss function to optimize and enhance the model's feature representation quality and classification accuracy. Compared to traditional standard CNN classifiers and univariate learning methods, this method achieves better auxiliary diagnostic results. This invention effectively handles the class imbalance problem of medical data through a multi-prototype representation mechanism and achieves high-precision classification judgment under limited sample conditions through a meta-learning framework, providing effective technical support for the intelligent diagnosis of keratoconus and possessing significant clinical application value.

[0099] Obviously, the described embodiments are only a part of the embodiments of this application, not all of them. Without conflict, the embodiments and features in the embodiments of this application can be combined with each other. The components of the embodiments of this application described and illustrated herein can generally be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of this application is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of this application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.

Claims

1. A method for keratoconus cell learning diagnosis under unbalanced small sample conditions, characterized in that: It includes a model training part and an auxiliary inference part, including the following steps: Model training section: Step 1-1, Data Preprocessing: Pentacam HR corneal topography maps were collected and labeled by ophthalmologists as three types of samples: normal cornea, early keratoconus, and keratoconus. The images were then cropped, denoised, standardized, and sized to obtain a preprocessed dataset. Step 1-2, Task Construction: Divide the preprocessed dataset into training set, validation set and test set according to the proportion. Use a balanced task sampler to construct a set of meta-learning tasks, where each task contains a support set and a query set. The support set and query set are used for prototype computation and model evaluation, respectively. Steps 1-3, Feature Extraction: Using a pre-trained Swing Transformer as a feature extractor, multi-stage feature extraction is performed on the input image to output a 512-dimensional feature vector; Steps 1-4, Multi-prototype computation: Based on the feature vectors extracted from the support set samples, K-means clustering algorithm is used to generate multiple prototype vectors for the early keratoconus category, and uniform grouping strategy is used to generate prototype vectors for the normal cornea and keratoconus categories; Steps 1-5, Classification decision: Calculate the Euclidean distance between the feature vectors of the query set samples and all prototype vectors, transform and normalize the Euclidean distance into a probability distribution through negative exponential transformation and softmax function, and use a category probability aggregation mechanism to aggregate the probabilities of multiple prototypes of the same category to obtain the final category probability distribution for categories with multiple prototypes; Steps 1-6, Loss Optimization: Construct a joint loss function by combining the augmentation focus loss and the contrastive learning loss, and use the joint loss function to optimize the model; Steps 1-7, Meta-learning update: The outer loop update mechanism is used to optimize the feature extractor parameters through multi-task learning. The average loss is calculated based on the query set loss of multiple tasks. The backpropagation algorithm is used to update the parameters of the feature extractor until the model converges and the trained meta-learning model is obtained. Auxiliary reasoning section: Step 2-1: Input the preprocessed corneal topography map to be used for assisted diagnosis; Step 2-2: Use the feature extractor of the trained meta-learning model to extract the feature vector of the image; Steps 2-3: Calculate the Euclidean distance between the corresponding feature vector and the prototype vector of each category, and aggregate the multi-prototype outputs using the softmax function to obtain the category probability distribution; Steps 2-4: Output the auxiliary reasoning diagnosis result and corresponding confidence level based on the highest probability. The diagnosis categories include normal cornea, early keratoconus, or keratoconus.

2. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: In steps 1-2, the balanced task sampler adjusts the preset task configuration parameters and uses a multi-stage priority sampling strategy to ensure that each task includes all three diagnostic categories. At the same time, it prioritizes sampling without replacement and automatically switches to sampling with replacement when the number of category samples is insufficient, so that the generated meta-learning tasks achieve a balanced distribution of categories.

3. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: The task construction formula in steps 1-2 is shown below: Among them, S i Let Q represent the support set for the i-th task. i Let represent the query set for the i-th task; N represents the number of categories contained in the task; M represents the number of samples contained in each category in the support set; and Q represents the number of samples contained in each category in the support set.

4. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: The feature extraction process of the Swing Transformer in steps 1-3 includes: Step 1-3-1: The input image is segmented into 4×4 pixel blocks by the Patch Embedding layer and mapped to a 96-dimensional feature space to generate an initial feature representation of 56×56×96. Steps 1-3-2 involve feature extraction through multiple Swing Transformer blocks in four stages. Each Swing Transformer block includes window multi-head self-attention, moving window multi-head self-attention, and multilayer perceptron. Step 1-3-3: The features extracted through the four stages are compressed into a 512-dimensional feature vector through global average pooling and linear projection layers.

5. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 4, characterized in that: The formula for calculating the feature representation using the moving window multi-head self-attention mechanism in step 1-3-2 is as follows: Where Q, K, and V represent query, key value, and numerical matrix, respectively, d represents feature dimension, and B represents relative position bias.

6. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: Steps 1-4 use the K-means clustering algorithm to generate four prototypes: Two prototypes were generated using a uniform grouping strategy for normal cornea and keratoconus: Where f represents the sample feature vector in the dataset, and P represents the prototype; This represents the k-th cluster of the c-th class. This represents the l-th group of the c-th class.

7. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: In steps 1-5, for categories with multiple prototypes, a maximum value aggregation strategy is used to select the maximum probability among all prototypes of the corresponding category for the query sample as the final probability of the corresponding category.

8. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: The Euclidean distance between each query sample and all prototypes in steps 1-5 is calculated using the following formula: The expression for converting Euclidean distance into probability distributions and then clustering the multi-prototype probabilities of contract categories is as follows: Among them, f q Indicates the query sample; For the k-th prototype of class c; C represents the total number of classes; τ represents the temperature parameter, K c c represents the number of prototypes in class c; c′ is the index variable for all classes; K c′ This represents the number of prototypes of class c′; For the kth class of class c′ ′ A prototype.

9. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: Steps 1-6 use the Adam optimizer and the ReduceLROnPlateau learning rate scheduling strategy to optimize the feature extractor parameters, and the expression of the joint loss function is as follows: L total =L focal +λ contrastive ×L contrastive ; Among them, L focal To enhance focus loss; L contrastive To contrast the learning loss; λ contrastive The weighting coefficients for the learning loss are used for comparison; p represents the category weight. i The model predicts the probability that a sample belongs to the i-th class; γ represents the focus parameter; H represents the proportion of samples mined through hard negative samples; f q To query the feature vector of a sample, Represents the query sample f q The feature vectors of support samples belonging to the same category, where τ is the temperature parameter. Represents the query sample f q Feature vectors of support samples belonging to different categories.

10. The method for keratoconus cell learning diagnosis under unbalanced small sample conditions according to claim 1, characterized in that: In steps 1-7, multiple meta-learning tasks are constructed in each iteration round and the tasks are processed in batches. For each task, the model prototype is recalculated and the distance metric is classified first, and then the joint loss function is calculated. The query set loss of all tasks is collected to calculate the average loss, and the parameters of the feature extractor are updated through the backpropagation algorithm.