A Few-Shot Data Classification Method and System

By determining the data augmentation strategy for supporting sets and query sets based on classification task requirements and data characteristics, and using a variety of data augmentation algorithms and configuration parameter strategies, the problem of insufficient classification accuracy of small sample data in the existing technology is solved, and higher classification performance and accuracy are achieved.

CN119807857BActive Publication Date: 2025-05-30UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510283820.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-11
Publication Date
2025-05-30
Estimated Expiration
2045-03-11

AI Technical Summary

Technical Problem

The existing data classification method with few samples is relatively simple in data enhancement and cannot effectively match the classification task requirements of the model, resulting in insufficient classification accuracy in the case of few samples.

Method used

By obtaining the specific requirements and characteristics of the classification model and data set, data enhancement strategies that support sets and query sets are determined separately, including matching of sample number, data quality and sample distribution, enhancement algorithms such as geometric transformation, color transformation, region transformation and noise addition are adopted, and conservative and radical classes are distinguished according to the scope of configuration parameters.

Benefits of technology

Effectively improve the performance and accuracy of classification models with few samples, ensuring that the models perform better in specific fields and can better adapt to new categories and unknown data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807857B_ABST
    Figure CN119807857B_ABST
Patent Text Reader

Abstract

The present invention provides a few-shot data classification method and system, which relates to the technical field of data processing. The method includes: obtaining a classification model and an image data set participating in training, where the image data set includes a support set and a query set; obtaining the classification task requirements of the classification model and the data characteristics of the data set, and the data characteristics include the number of sample data, data quality, and sample distribution; respectively determining data augmentation strategies for the support set and the query set according to the classification task requirements and the data characteristics; respectively performing data augmentation on the support set and the query set according to the data augmentation strategies; training the classification model using the data-augmented support set and query set; and performing data classification through the trained classification model. This solution can generate a data augmentation strategy that is more matched to the requirements according to the classification task requirements and the specific situation of the data set, can effectively improve the performance of the classification model for the current demand scenario, and improve the classification accuracy in the few-shot case.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular, to a few-shot data classification method and system. Background Art

[0002] Few-shot learning is a machine learning method that focuses on how to use a small number of samples for effective model training and classification. This method is particularly suitable for scenarios where it is difficult to obtain a large amount of labeled data.

[0003] Currently, there is a shortage of data in many fields, such as emerging diseases in the medical field, telecommunications fraud, modified dangerous goods in the security field, and defective samples in the detection field. How to improve the performance of the model in a specific field with limited data has become a hot research issue.

[0004] In few-shot learning, data augmentation is an effective method for increasing the diversity of support images and query images, thereby improving the generalization ability and robustness of the model. Through appropriate data augmentation techniques, even in the case of limited samples, more diverse training instances can be created to help the model better learn features and adapt to new categories. However, the existing data augmentation algorithms are relatively simple and cannot well meet the classification task requirements of the model. Summary of the Invention

[0005] In view of the above problems, the present invention provides a few-shot data classification method and system, which can effectively improve the performance of the classification model for the current demand scenario and improve the classification accuracy in the case of few samples.

[0006] In a first aspect, the present invention provides a few-shot data classification method, the method comprising:

[0007] Obtain a classification model and an image data set participating in training, the image data set including a support set and a query set, obtain the classification task requirements of the classification model and the data characteristics of the data set, the data characteristics including the number of sample data, data quality, and sample distribution;

[0008] Determine the data augmentation strategies for the support set and the query set respectively according to the classification task requirements and the data characteristics;

[0009] Perform data augmentation on the support set and the query set respectively according to the data augmentation strategies;

[0010] Train the classification model using the data-augmented support set and query set;

[0011] Perform data classification through the trained classification model.

[0012] Optionally, the method for determining the data augmentation strategy of the support set according to the classification task requirements and the data characteristics includes:

[0013] Judge whether the number of samples in each category of the support set reaches the support set sample quantity requirement corresponding to the classification task requirements;

[0014] For the categories that do not reach the support set sample quantity requirement, determine that the number of samples needs to be augmented;

[0015] Judge whether the data quality of the support set reaches the data quality requirement corresponding to the classification task requirements;

[0016] If not, select a conservative type of augmentation algorithm; if so, select an aggressive type of augmentation algorithm;

[0017] Judge whether the sample distribution of the support set matches the real scenario corresponding to the classification task requirements. If not, for the categories with insufficient sample proportion, determine that the number of samples needs to be augmented.

[0018] Optionally, the method for determining the data augmentation strategy of the query set according to the classification task requirements and the data characteristics includes:

[0019] Judge whether the number of samples in each category of the query set reaches the query set sample quantity requirement corresponding to the classification task requirements;

[0020] For the categories that reach the query set sample quantity requirement, select two or more augmentation algorithms; for the categories that do not reach the query set sample quantity requirement, select one augmentation algorithm;

[0021] Judge whether the data quality of the query set reaches the data quality requirement corresponding to the classification task requirements;

[0022] If not, select a conservative type of augmentation algorithm; if so, select an aggressive type of augmentation algorithm;

[0023] Judge whether the sample distribution of the query set matches the real scenario corresponding to the classification task requirements;

[0024] If not, for the categories with insufficient sample proportion, determine that the number of samples needs to be augmented; for the categories with excessive sample proportion, randomly select samples according to the excess proportion value to reduce the number of samples.

[0025] Optionally, the enhancement algorithm includes geometric transformation, color transformation, region transformation, and noise addition. The conservative class and the radical class are distinguished by the range of configuration parameters when the enhancement algorithm is executed. When the configuration parameter is greater than the preset threshold standard, it is classified as the radical class, and when the configuration parameter is less than the preset threshold standard, it is classified as the conservative class.

[0026] Optionally, the method further includes:

[0027] After determining to select the radical or conservative enhancement algorithm according to the data quality, based on the gap between the data quality and the data quality requirement, determine the range of configuration parameters when the enhancement algorithm is executed.

[0028] Optionally, when selecting the radical enhancement algorithm, select two or more enhancement algorithms and sort and use the selected enhancement algorithms in a preset order.

[0029] Optionally, when the data quality does not meet the data quality requirement corresponding to the classification task requirement, the method further includes:

[0030] Preprocess the sample data that does not meet the data quality requirement;

[0031] Recalculate the data quality for the preprocessed sample data.

[0032] Optionally, after determining the data augmentation strategy, the method further includes:

[0033] Calculate the number of samples in the support set and the query set after data augmentation respectively according to the data augmentation strategy;

[0034] Judge whether the ratio of the number of samples in the calculated support set and query set matches the sample number ratio requirement corresponding to the classification task requirement;

[0035] If not, adjust the data augmentation strategy for the query set so that the ratio of the number of samples in the adjusted support set and query set matches the sample number ratio requirement.

[0036] Optionally, after data augmentation, the method further includes:

[0037] Calculate the number of positive support samples and negative support samples for each category in the support set respectively;

[0038] For the classification where the ratio of the number of negative support samples to the number of positive support samples does not reach the positive and negative support sample ratio requirement corresponding to the classification task requirement, judge whether it is possible to extract the number of negative support samples that meet the positive and negative support sample ratio requirement from the sample data of other classifications;

[0039] If possible, randomly select the required number of negative support samples that meet the positive-negative support sample ratio requirement from the sample data of other categories. If not, adjust the data augmentation strategy for the support set so that the ratio of the number of negative support samples to the number of positive support samples for each category in the adjusted support set can reach the positive-negative support sample ratio requirement.

[0040] In a second aspect of the present invention, a few-shot data classification system is provided, including:

[0041] A data acquisition unit, configured to acquire a classification model and an image data set participating in training. The image data set includes a support set and a query set, acquire the classification task requirements of the classification model and the data characteristics of the data set. The data characteristics include the number of sample data, data quality, and sample distribution;

[0042] A strategy determination unit, configured to determine the data augmentation strategies for the support set and the query set respectively according to the classification task requirements and the data characteristics;

[0043] A data augmentation unit, configured to perform data augmentation on the support set and the query set respectively according to the data augmentation strategies;

[0044] A model training unit, configured to train the classification model using the data-augmented support set and query set;

[0045] A data classification unit, configured to perform data classification through the trained classification model.

[0046] In summary, the present invention provides a few-shot data classification method and system, which can generate a data augmentation strategy that better matches the requirements according to the specific classification task requirements and the specific situation of the data set participating in training, and then use the data set augmented by this data augmentation strategy to perform targeted training on the classification model, which can effectively improve the performance of the classification model for the current required scenario and improve the classification accuracy in the few-shot case. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0048] Figure 1 It is a flowchart of a few-shot data classification method provided by an embodiment of the present invention;

[0049] Figure 2It is a structural block diagram of a few-shot data classification system provided by an embodiment of the present invention.

[0050] Explanation of reference numerals: 110 - data acquisition unit; 120 - strategy determination unit; 130 - data augmentation unit; 140 - model training unit; 150 - data classification unit. Detailed implementation manners

[0051] Next, the technical solutions in the embodiments of the present invention will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only a part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present invention.

[0052] Currently, there is a situation of data scarcity in many fields, such as emerging diseases in the medical field, telecommunications fraud, modified dangerous goods in the security field, defective samples in the detection field, etc. How to improve the performance of the model in a specific field with the support of a small amount of data has become a hot research issue at present.

[0053] In few-shot learning, data augmentation is an effective method for increasing the diversity of support images and query images, thereby improving the generalization ability and robustness of the model. Through appropriate data augmentation techniques, even in the case of limited samples, more diverse training instances can be created to help the model better learn features and adapt to new categories. However, the existing data augmentation algorithms are relatively simple and cannot well match the classification task requirements of the model.

[0054] Therefore, how to provide a few-shot data classification method with higher classification accuracy is an urgent problem to be solved at present.

[0055] In view of this, the present invention provides a few-shot data classification method and system.

[0056] Next, a few-shot data classification method provided by this embodiment will be specifically described.

[0057] As Figure 1 shown, a few-shot data classification method provided by the present invention includes:

[0058] Step S101, obtain a classification model and an image data set participating in training. The image data set includes a support set and a query set. Obtain the classification task requirements of the classification model and the data characteristics of the data set. The data characteristics include the number of sample data, data quality, and sample distribution.

[0059] In few-shot learning, the support set and the query set play crucial roles. They each have different functions and characteristics, jointly constituting the structure of an episode or task, which is used to simulate how the model can quickly adapt to new tasks and perform classification.

[0060] In each episode, the classification model needs to quickly adapt to a new classification task based on the small number of samples provided by the support set. This requires the model to have strong generalization ability and be able to make correct classification judgments with only a small amount of data. Classification models include Vision Transfomer (ViT) and graph neural networks GNNs. The support set is the basis for the classification model to build a preliminary understanding of each new category. By comparing the sample features in the support set, the model can learn the key attributes that distinguish different categories and adjust its internal parameters or generate decision rules accordingly. The support set contains samples with clear labels, and these samples represent all the categories in the current task. The number of samples for each category is very limited, usually in the form of 1-shot (1 sample per category), 5-shot (5 samples per category), etc. In the few-shot case, the number of samples for each category in the support set is very limited, usually in the form of 1-shot (1 sample per category), 5-shot (5 samples per category), etc. Due to the limited number of samples, the support set may not be able to fully cover all the variation cases under that category.

[0061] The query set consists of unlabeled or partially labeled samples and is used to evaluate whether the classification model can correctly assign newly encountered instances to the corresponding categories. Therefore, the query set should cover as widely as possible various situations in the target category, including different poses, lighting conditions, backgrounds, etc., to ensure that the evaluation results are statistically significant. By using the query set, the performance of the model when facing unknown data can be tested, thereby verifying its generalization ability and robustness.

[0062] It can be seen that both the support set and the query set hope to improve the generalization ability of the classification model through data augmentation, enabling the classification model to better handle unseen data. Considering their respective roles in model training and their positions in few-shot learning tasks, when performing data augmentation, it is necessary to select appropriate data augmentation according to the specific sample data conditions in the obtained support set and query set to match the requirements of the current classification task.

[0063] In this embodiment, data characteristics are taken as specific considerations. The data characteristics specifically include the number of samples, data quality, and sample distribution. Among them, the number of samples corresponds to the specific number of samples included in the support set and the query set; the data quality corresponds to the data quality of the sample data in the support set and the query set, which can be measured by the signal-to-noise ratio or other parameters; the sample distribution corresponds to the distribution ratio of various types of samples in the support set and the query set. Generally, the closer the distribution ratio is to the ratio of the actual scenario, the better.

[0064] In different classification scenarios, different classification task requirements are set. Different classification task requirements also have corresponding requirements for the data characteristics of the support set and the query set used for training. When the degree of matching between the data characteristics and the classification task requirements is higher, the subsequent training effect will be better.

[0065] It should be noted that in this embodiment, the obtained classification model is a model that has been fully exposed to the base class and has completed part of the training based on the base class.

[0066] As other implementation manners of the embodiments of the present invention, when considering data characteristics, in addition to selecting the number of samples, data quality, and sample distribution as specific considerations, computing resources, computing efficiency, response speed, etc. can also be taken as considerations to facilitate more targeted data augmentation.

[0067] Step S102: Determine the data augmentation strategies for the support set and the query set respectively according to the classification task requirements and the data characteristics.

[0068] Since the requirements for data augmentation of the support set and the query set are different, it is necessary to determine the data augmentation strategies for the support set and the query set respectively based on the data characteristics of both and the different requirements of the classification task requirements.

[0069] When determining the data augmentation strategies for the support set and the query set, it is necessary to consider both their similarities and differences in requirements. Both hope to improve the generalization ability of the model through data augmentation so that the model can better handle unseen data. Whether it is the support set or the query set, when performing data augmentation, it is necessary to try to maintain the true distribution characteristics of the data and avoid generating samples that are too unnatural or completely inconsistent with the actual scenario. Since the number of samples for each category in the support set is very limited, more aggressive augmentation techniques can be applied; in contrast, the query set pays more attention to maintaining the authenticity of the samples and usually only applies relatively conservative augmentation means. The support set directly participates in the model's learning process and serves as the basis for the model to adjust parameters and construct classification rules; the query set is mainly used to test and verify the model performance and is not directly used for training. Therefore, its augmentation should focus on simulating the diversity and challenges of the real world rather than helping the model learn. All augmentation operations on the support set are based on known labels, aiming to enable the model to better understand specific categories; the query set is usually unlabeled data, and the augmentation does not rely on label information. The key lies in how to enable the model to make correct predictions in unknown situations. The augmented samples of the support set will be added to the training process and may need to be saved for multiple uses; the augmented samples of the query set are only used for evaluation and generally do not need to be saved for a long time and can be generated immediately before each evaluation. Appropriate data augmentation in the support set can help alleviate the overfitting problem caused by insufficient samples; the query set does not need to pay special attention to the overfitting problem. More importantly, it is necessary to ensure that the augmentation does not introduce bias and affect the fairness of the evaluation.

[0070] Therefore, for the support set, various augmentation techniques can be boldly tried in the exploration stage, but it is necessary to ensure that there is no excessive augmentation when finally determining the solution; for the query set, it should be more cautious and preferably choose simple augmentation methods that do not significantly change the image content. Although the support set and the query set have a common goal in data augmentation, that is, to improve the generalization ability and robustness of the model, due to their different roles in the task, there are also significant differences in the specific implementation of augmentation. Reasonably distinguishing and handling the data augmentation requirements of these two sets is the key to successful few-shot learning.

[0071] For the above reasons, specifically, as a preferred implementation manner, the method for determining the data augmentation strategy of the support set according to the classification task requirements and the data characteristics includes:

[0072] Judge whether the number of samples for each category in the support set reaches the support set sample number requirement corresponding to the classification task requirement;

[0073] For the categories that do not reach the support set sample number requirement, determine that the number of samples needs to be augmented;

[0074] Determine whether the data quality of the support set meets the data quality requirements corresponding to the classification task requirements;

[0075] If not, select an enhancement algorithm of the conservative type; if so, select an enhancement algorithm of the radical type;

[0076] Determine whether the sample distribution of the support set matches the real scenario corresponding to the classification task requirements. If not, for the categories with insufficient sample proportion, determine that the sample quantity needs to be enhanced.

[0077] Specifically, as a preferred implementation, the method for determining the data enhancement strategy of the query set according to the classification task requirements and the data characteristics includes:

[0078] Determine whether the sample quantity of each category in the query set meets the query set sample quantity requirements corresponding to the classification task requirements;

[0079] For the categories that meet the query set sample quantity requirements, select two or more enhancement algorithms; for the categories that do not meet the query set sample quantity requirements, select one enhancement algorithm;

[0080] Determine whether the data quality of the query set meets the data quality requirements corresponding to the classification task requirements;

[0081] If not, select an enhancement algorithm of the conservative type; if so, select an enhancement algorithm of the radical type;

[0082] Determine whether the sample distribution of the query set matches the real scenario corresponding to the classification task requirements;

[0083] If not, for the categories with insufficient sample proportion, determine that the sample quantity needs to be enhanced; for the categories with excessive sample proportion, randomly select according to the excess proportion value to reduce the sample quantity.

[0084] For different classification task requirements, the corresponding support set sample quantity requirements, query set sample quantity requirements, data quality requirements, and sample distribution of the corresponding real scenario are different. Therefore, it is necessary to make judgments based on the obtained classification task requirements. Different classification task requirements include high classification accuracy requirements, requirements for robustness to specific transformations, handling new categories or unknown categories, cross-modal recognition requirements, etc. By analyzing the quantity, quality, distribution of the existing support set and query set sample data, and whether there are special structural features, etc., to determine which data enhancement methods are most suitable for the current scenario.

[0085] When determining the data augmentation strategy for the support set, since the number of samples for each category in the support set is very limited (such as 1-shot or 5-shot), multiple augmentation techniques should be used to maximize the information content of each sample of data. For example, geometric transformations (rotation, flipping, scaling), color adjustments (changes in brightness, contrast), etc. can significantly increase the diversity of the data. When generating new samples, consider using advanced generative models such as GANs to synthesize new training samples from a small number of support samples. This method can help the model better understand the category features, but it is necessary to ensure that the generated samples still conform to the real-world distribution. It should be noted that when performing any augmentation operation, the consistency of the labels must be guaranteed, that is, the augmented sample data still belongs to the original category. If the quality of the sample data in the support set is very high (clear, noise-free), more aggressive data augmentation methods can be adopted, such as geometric transformations in a larger range or complex mixing methods (Mixup, Cutmix). This can provide more diverse training signals for the model without compromising the data quality. If the sample distribution in the support set is uneven and the number of samples for some categories in the support set is small, oversampling can be performed on them through appropriate data augmentation techniques to balance the difference in the number of samples between categories. This helps prevent the model from being biased towards the majority category.

[0086] When determining the data augmentation strategy for the query set, since the number of samples in the query set is large, a wider range of data augmentation techniques can be applied, such as random cropping, rotation, color jittering, etc., to simulate the actual situation under different conditions. This helps evaluate the true generalization ability of the model. As a preferred implementation method, to improve flexibility and efficiency, the data augmentation of the query set is usually performed immediately during evaluation, rather than generating and saving a large number of augmented samples in advance. This not only saves storage space but also allows for flexible adjustment of the augmentation strategy according to needs. On the other hand, if the data quality in the query set is poor (there are problems such as noise, blurring, etc.), a more conservative augmentation method should be selected to avoid introducing too much bias. For example, slight color adjustment or small-angle rotation may be better choices. The query set should reflect the sample distribution in the actual application scenario as much as possible. Therefore, its sample distribution should be close to the actual application scenario. When performing data augmentation, it is necessary to ensure that the transformations and techniques used can truly reproduce the common changes in the target domain, such as lighting conditions, background interference, etc.

[0087] When analyzing the above data characteristics, it is also necessary to adjust the focus of the augmentation strategy in combination with the requirements of the classification task. For example, if the task requires the classification model to have high robustness, extensive augmentation should be performed on the support set; if more attention is paid to quickly adapting to new categories, the diversity and representativeness of the query set need to be ensured.

[0088] Specifically, the enhancement algorithm includes geometric transformation, color transformation, region transformation, and noise addition. The conservative class and the aggressive class are distinguished by the range of configuration parameters when the enhancement algorithm is executed. When the configuration parameters are greater than the preset threshold standard, it is classified as the aggressive class, and when the configuration parameters are less than the preset threshold standard, it is classified as the conservative class. For example, for geometric transformation, the configuration parameters for its execution include rotation amplitude, scaling range and ratio, translation distance, etc. For color transformation, the configuration parameters for its execution include brightness / contrast adjustment, hue shift, saturation adjustment. For region transformation, the configuration parameters for its execution include cropping region, number of crops. For noise addition, the configuration parameters for its execution include noise type, noise ratio. Specifically, taking the rotation amplitude as an example, the threshold standard is set at 90 degrees. If it is greater than 90 degrees, it is the aggressive class, and if the rotation amplitude is less than 90 degrees, it is the conservative class.

[0089] It should be noted that aggressive methods usually involve large-scale or intense changes, aiming to provide the model with as diverse training signals as possible to help it learn a wider range of feature representations. These methods may significantly change the appearance of the image, and sometimes it is even difficult to recognize the original object. Therefore, they are suitable for tasks that are not sensitive to the original data form. They are more suitable for occasions where the data volume is sufficient and the model requires high robustness, such as natural scene recognition, autonomous driving and other fields, where the model needs to handle inputs under various complex conditions. Conservative methods tend to perform relatively minor transformations, aiming to maintain the main features and semantic information of the image while introducing a certain degree of change to improve the generalization ability of the model. These methods minimize the damage to the original data, ensuring that the enhanced image can still accurately reflect the characteristics of the original object, and are suitable for tasks that rely on the original data form. They are particularly suitable for situations where the data quality is poor or the sample quantity is limited, as well as fields such as medical imaging and face recognition that have high requirements for the accuracy of the original data, where maintaining the authenticity and details of the image is crucial.

[0090] On the basis of the above scheme, in addition to selecting the type of enhancement algorithm, the available range of configuration parameters when the enhancement algorithm is executed should also be considered to further meet the requirements of the actual application scenario.

[0091] Specifically, the method further includes:

[0092] After determining to select an aggressive or conservative enhancement algorithm according to the data quality, based on the gap between the data quality and the data quality requirements, determine the available range of configuration parameters when the enhancement algorithm is executed.

[0093] When specifically determining, the mapping relationship between the gap and the available range should be determined according to the type of enhancement algorithm selected. Taking the rotation amplitude as an example, the threshold standard is set at 90 degrees. Values greater than 90 degrees belong to the aggressive category, and values less than 90 degrees belong to the conservative category. When the data quality requirements are not met and the gap between the data quality and the data quality requirements is large, the set value of the rotation amplitude should be much less than 90 degrees and the available range of the value is small; when the data quality requirements are not met and the gap between the data quality and the data quality requirements is small, the set value of the rotation amplitude should be in a relatively large range between 0 and 90 degrees; when the data quality requirements are met and the gap between the data quality and the data quality requirements is large, the set value of the rotation amplitude should be in a relatively large range between 90 and 180 degrees; when the data quality requirements are met and the gap between the data quality and the data quality requirements is small, the set value of the rotation amplitude should be slightly greater than 90 degrees and the available range of the value is small.

[0094] Specifically, as a preferred implementation, when selecting an aggressive enhancement algorithm, two or more enhancement algorithms are selected, and the selected enhancement algorithms are sorted and used in a preset order.

[0095] When selecting an aggressive enhancement algorithm, a multi-step enhancement method can be adopted, combining multiple enhancement techniques, such as first performing elastic deformation and then color jittering to form a complex transformation effect.

[0096] When the data quality does not meet the data quality requirements corresponding to the classification task requirements, the method further includes:

[0097] Preprocessing the sample data that does not meet the data quality requirements;

[0098] Recalculating the data quality for the preprocessed sample data.

[0099] For sample data with low data quality, the sample data can be processed through preprocessing methods to improve its sample quality, and then the data enhancement strategy can be determined according to the improved situation. The preprocessing includes image denoising, color standardization, and image cropping.

[0100] It should be noted that after determining the data enhancement strategy, the method further includes:

[0101] Calculating the number of samples in the support set and the query set after data enhancement respectively according to the data enhancement strategy;

[0102] Judging whether the ratio of the number of samples in the support set and the query set matches the sample number ratio requirement corresponding to the classification task requirement;

[0103] If there is no match, adjust the data augmentation strategy for the query set so that the ratio of the number of samples in the adjusted support set to the number of samples in the query set matches the required sample number ratio.

[0104] As a preferred implementation, after determining the data augmentation strategy, data augmentation is not immediately performed. Considering that in some special classification task requirement scenarios, there are also requirements for the ratio of the number of positive support samples to the number of negative support samples in the support set and the query set. At this time, the number of samples in the support set and the query set after data augmentation can be calculated based on the determined data augmentation strategy. If the result does not match the required sample number ratio, it is necessary to adjust the data augmentation strategy of the original query set so that the ratio of the number of samples in the adjusted support set to the number of samples in the query set matches the required sample number ratio.

[0105] Through the above process, after finally determining the data augmentation strategies for the support set and the query set, the support set and the query set can be respectively data-augmented.

[0106] Step S103, respectively perform data augmentation on the support set and the query set according to the data augmentation strategy.

[0107] It should be noted that considering that in some special classification task requirement scenarios, there are also certain requirements for the ratio of the number of positive support samples to the number of negative support samples for each category in the support set. Therefore, further consideration is required on this basis.

[0108] Specifically, after performing data augmentation, the method further includes:

[0109] Respectively calculate the number of positive support samples and the number of negative support samples for each category in the support set;

[0110] For a classification where the ratio of the number of negative support samples to the number of positive support samples does not reach the required positive and negative support sample ratio corresponding to the classification task requirements, determine whether negative support samples with a quantity that meets the required positive and negative support sample ratio can be extracted from the sample data of other classifications;

[0111] If yes, randomly extract negative support samples with a quantity that meets the required positive and negative support sample ratio from the sample data of other classifications. If not, adjust the data augmentation strategy of the support set so that each category in the adjusted support set can reach the required positive and negative support sample ratio.

[0112] Since negative support samples can be drawn from the sample data of other classifications, when the number of negative support samples is insufficient, it is necessary to first determine whether they can be drawn from the sample data of other classifications to meet the requirements. If not, then consider adjusting the data augmentation strategy for the support set so that each category in the adjusted support set can meet the positive-negative support sample ratio requirement.

[0113] Step S104, use the augmented support set and query set to train the classification model.

[0114] Step S105, perform data classification through the trained classification model.

[0115] Through the above process, the data augmentation of the support set and query set is completed, and the augmented support set and query set are applied to train the classification model. Finally, use the trained classification model to complete the data classification under the current classification task requirements.

[0116] The following is illustrated by a specific case:

[0117] Scenario requirement description:

[0118] Suppose a plant disease recognition system is being developed, aiming to help farmers quickly and accurately identify different diseases (new classes) and healthy states (base classes) on crops. The system will utilize few-shot learning techniques to adapt to new disease types through a limited support set and use the query set for evaluation.

[0119] The method is executed as follows:

[0120] 1. Clarify the classification task requirements:

[0121] Task objectives:

[0122] Quickly adapt to and identify new plant disease types.

[0123] Improve the generalization ability and robustness of the model to different types of diseases.

[0124] Evaluation criteria:

[0125] Indicators such as classification accuracy, recall rate, and F1 score.

[0126] 2. Analyze the data characteristics of the support set and query set:

[0127] Support set characteristics:

[0128] Number of samples: The number of samples for each new class is very limited (such as 1-shot or 5-shot).

[0129] Data quality: High-quality images, with good shooting conditions, but there may be slight lighting variations.

[0130] Sample distribution: The number of samples between categories may not be uniform, and there are fewer samples for some disease types.

[0131] Query set characteristics:

[0132] Number of samples: Relatively large, covering a variety of different disease conditions and healthy plants.

[0133] Data quality: Data collected from the field has problems such as noise and fuzziness to varying degrees.

[0134] Sample distribution: Try to reflect the diversity in the actual application scenario, but may not be completely uniform.

[0135] 3. Develop a data augmentation strategy for the support set:

[0136] Positive support images (confirmed cases):

[0137] Diverse geometric transformations:

[0138] Rotation: Small-angle rotation of ±10 degrees, keeping the disease characteristics unchanged.

[0139] Flipping: Horizontal flipping, applicable to diseases with strong symmetry.

[0140] Scaling and translation: Slight scaling (90% - 110%) and translation operations to simulate the disease manifestations from different perspectives.

[0141] Color adjustment:

[0142] Brightness / contrast adjustment: Moderate adjustment to simulate different lighting conditions.

[0143] Color jitter: Slightly change the RGB channel values to introduce some color changes without distortion.

[0144] Add slight noise:

[0145] Low-level Gaussian noise: Add a small number of random noise points to simulate slight interference in the real world.

[0146] Label consistency check:

[0147] Ensure that all augmentation operations do not change the category label to which the image belongs.

[0148] Negative support images (non-confirmed cases):

[0149] Extreme geometric transformations:

[0150] Large-scale rotation: Such as 90 degrees or more to create a greater visual difference between negative and positive examples.

[0151] Large-scale translation or elastic deformation: Significantly change the image structure to ensure that negative examples are clearly different from positive examples.

[0152] Significant color change:

[0153] Hue shift: Change the overall color tone of the image to make it clearly different from positive examples.

[0154] Saturation adjustment: Adjust the color saturation to extremely low or high levels, affecting the color richness of the image.

[0155] Complex mixing methods:

[0156] Mixup and Cutmix: Create new synthetic samples to further expand the differences between classes.

[0157] Style Transfer: Combine the styles of other plant pictures to generate new images with different visual styles.

[0158] Generative Adversarial Networks (GANs):

[0159] Use GANs to generate challenging negative example samples to test the generalization ability of the model.

[0160] 4. Develop a data augmentation strategy for the query set:

[0161] A large number of samples:

[0162] Diverse augmentation:

[0163] Widely use a variety of techniques: Apply a wide range of geometric transformations (such as rotation, flipping, scaling), color adjustments (brightness, contrast changes), random cropping, etc. to increase the diversity of the data.

[0164] Immediate augmentation: To improve flexibility and efficiency, augmented samples can be generated immediately during evaluation instead of pre-saving a large number of augmented images.

[0165] Uneven data quality:

[0166] Conservative augmentation:

[0167] Simplify augmentation operations: Select relatively conservative augmentation methods, such as slight color adjustments or small-angle rotations, to avoid further degrading the data quality.

[0168] Fix noise: If possible, preprocess low-quality data first, such as improving the image quality through a noise reduction algorithm, and then perform moderate data augmentation.

[0169] Uneven sample distribution:

[0170] Balance class proportions:

[0171] Oversampling the Minority Class: Appropriately oversample and enhance the class with a smaller number of samples to balance the difference in the number of samples between classes.

[0172] Undersampling the Majority Class: If there are too many samples in certain classes, it is also possible to randomly select some samples from these classes for evaluation to ensure that all classes can be fully tested.

[0173] 5. Comprehensive Consideration and Implementation:

[0174] Task Requirements:

[0175] Adjust the focus of the enhancement strategy according to the specific classification task requirements. For example, if the task requires the model to have high robustness, extensive enhancement should be performed on the support set; if more attention is paid to quickly adapting to new classes, the diversity and representativeness of the query set need to be ensured.

[0176] Computing Resource Management:

[0177] Reasonably plan computing resources, especially when dealing with large-scale query sets, avoid unnecessary complex operations, and ensure the evaluation process is efficient and accurate.

[0178] Continuous Evaluation and Adjustment:

[0179] Regularly check the performance of the model and adjust the enhancement strategy according to the actual situation to find the optimal solution.

[0180] On the above basis, as other embodiments of the present invention, when performing data enhancement on the support set, positive support samples and negative support samples can be distinguished, and different enhancement strategies can be applied respectively.

[0181] Specifically, for the data augmentation of positive support samples, through appropriate data augmentation, the positive support images can exhibit more diverse features, helping the model better understand the core attributes of this category. The adopted augmentation strategies specifically include diverse geometric transformations: such as rotation, flipping, scaling, etc., but within a reasonable range to ensure that the image can still accurately reflect the category features; color adjustment: moderately adjusting brightness, contrast, etc. to simulate the situation under different lighting conditions; adding slight noise: adding a small amount of Gaussian noise or performing slight blurring to simulate interference factors in the real world. For the data augmentation of negative support samples, it can provide more negative example information for the model, helping it more clearly define the category boundary and avoid confusion. Appropriate negative example augmentation can make the model more sensitive to abnormal situations and improve its robustness when facing unknown or uncommon samples. The adopted augmentation strategies specifically include extreme geometric transformations: for example, large-scale rotation, large-range translation, or elastic deformation to create a greater visual difference between negative and positive examples; significant color changes: such as hue shift, saturation adjustment, etc. to change the overall color tone of the image and make it significantly different from positive examples; complex mixing methods: using techniques such as Mixup and Cutmix to create new negative example samples to further expand the difference between categories; generative adversarial networks (GANs): using GANs to generate challenging negative example samples to test the generalization ability of the model.

[0182] The following is illustrated by a specific example. Suppose the demand scenario is a medical imaging diagnosis system, and a rare disease is identified through a classification model:

[0183] Positive support images (confirmed cases):

[0184] Use methods such as geometric transformation and color adjustment to enhance the imaging data of confirmed cases to help the model better learn and identify the characteristics of these diseases.

[0185] Negative support images (non-confirmed cases):

[0186] For non-confirmed cases, more aggressive augmentation methods, such as extreme geometric transformation and significant color change, can be used to create more challenging negative example samples to ensure that the model can still make correct classification decisions in the face of various interference factors.

[0187] In summary, the present invention provides a few-shot data classification method, which can generate a data augmentation strategy that better matches the requirements according to the specific classification task requirements and the specific situation of the training data set involved, and then use the data set augmented by this data augmentation strategy for targeted training of the classification model, which can effectively improve the performance of the classification model for the current demand scenario and improve the classification accuracy in the few-shot situation.

[0188] Such as Figure 2As shown in the figure, the few-shot data classification system provided by the present invention includes:

[0189] A data acquisition unit 110, configured to acquire a classification model and an image data set participating in training. The image data set includes a support set and a query set, acquire the classification task requirements of the classification model and the data characteristics of the data set. The data characteristics include the number of sample data, data quality, and sample distribution;

[0190] A strategy determination unit 120, configured to determine data augmentation strategies for the support set and the query set respectively according to the classification task requirements and the data characteristics;

[0191] A data augmentation unit 130, configured to perform data augmentation on the support set and the query set respectively according to the data augmentation strategies;

[0192] A model training unit 140, configured to train the classification model using the support set and the query set after data augmentation;

[0193] A data classification unit 150, configured to perform data classification through the trained classification model.

[0194] The few-shot data classification system provided by the embodiments of the present invention is used to implement the above few-shot data classification method. Therefore, the specific implementation manners are the same as those of the above method and will not be elaborated here.

[0195] In summary, the present invention provides a few-shot data classification method and system, which can generate a data augmentation strategy that better matches the requirements according to the specific classification task requirements and the specific situation of the training data set, and then use the data set augmented by this data augmentation strategy to perform targeted training on the classification model, which can effectively improve the performance of the classification model for the current demand scenario and improve the classification accuracy in the few-shot case.

[0196] In several embodiments disclosed in the present application, it should be understood that the disclosed devices and methods can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and a module, a program segment, or a part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, as well as the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0197] In addition, in each embodiment of the present application, the various functional modules may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.

[0198] If the above functions are implemented in the form of software functional modules and sold or used as an independent product, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The aforementioned storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.

Claims

1. A method for classifying small sample data, characterized in that: The method comprises: Obtaining a classification model and an image dataset involved in training, the image dataset including a support set and a query set, obtaining the classification task requirements of the classification model and data characteristics of the dataset, the data characteristics including the sample quantity, data quality and sample distribution of the sample data; Determine the data enhancement strategies for the support set and the query set respectively according to the classification task requirements and the data characteristics; Performing data enhancement on the support set and the query set respectively according to the data enhancement strategy; Training the classification model using the data-augmented support set and query set; Classify data using a trained classification model; Wherein, determining the data enhancement strategy of the support set according to the classification task requirements and the data characteristics includes: judging whether the number of samples of each category in the support set meets the support set sample number requirement corresponding to the classification task requirements, and determining the need for sample number enhancement for categories that do not meet the support set sample number requirement; judging whether the data quality of the support set meets the data quality requirement corresponding to the classification task requirements, if not, selecting an enhancement algorithm of the conservative class, and if so, selecting an enhancement algorithm of the radical class; judging whether the sample distribution of the support set matches the real scene corresponding to the classification task requirements, and if not, determining the need for sample number enhancement for categories with insufficient sample proportion; Determine the data enhancement strategy of the query set according to the classification task requirements and the data characteristics, including: judging whether the number of samples of each category in the query set meets the query set sample number requirement corresponding to the classification task requirements, selecting two or more enhancement algorithms for categories that meet the query set sample number requirement, and selecting one enhancement algorithm for categories that do not meet the query set sample number requirement; judging whether the data quality of the query set meets the data quality requirement corresponding to the classification task requirements, if not, selecting a conservative enhancement algorithm, if so, selecting an aggressive enhancement algorithm; judging whether the sample distribution of the query set matches the real scene corresponding to the classification task requirements, if not, determining that the sample number needs to be enhanced for categories with insufficient sample proportions, and for categories with too high sample proportions, performing random sampling according to the value exceeding the proportion to reduce the sample number.

2. The method for classifying small sample data according to claim 1, characterized in that: The enhancement algorithm includes geometric transformation, color transformation, area transformation, and noise addition. The conservative class and the radical class are distinguished by the range of configuration parameters when the enhancement algorithm is executed. When the configuration parameter is greater than a preset threshold standard, it is distinguished as the radical class, and when the configuration parameter is less than the preset threshold standard, it is distinguished as the conservative class.

3. The method for classifying small sample data according to claim 1, characterized in that: The method further comprises: After selecting an aggressive or conservative enhancement algorithm according to the data quality, a range of configuration parameters when executing the enhancement algorithm is determined based on the gap between the data quality and the data quality requirement.

4. The method for classifying small sample data according to claim 3, characterized in that: When selecting an aggressive enhancement algorithm, two or more enhancement algorithms are selected, and the selected enhancement algorithms are sorted and used in a preset order.

5. The method for classifying small sample data according to claim 3, characterized in that: When the data quality does not meet the data quality requirement corresponding to the classification task requirement, the method further includes: Preprocess the sample data that does not meet the data quality requirements; Recalculate data quality for preprocessed sample data.

6. The method for classifying small sample data according to any one of claims 1 to 4, characterized in that: After determining the data enhancement strategy, the method further includes: According to the data enhancement strategy, the number of samples of the support set and the query set after data enhancement is calculated respectively; Determine whether the calculated sample quantity ratio of the support set and the query set matches the sample quantity ratio requirement corresponding to the classification task requirement; If they do not match, the data augmentation strategy for the query set is adjusted so that the ratio of the number of samples in the adjusted support set and query set matches the required number of samples.

7. The method for classifying small sample data according to any one of claims 1 to 4, characterized in that: After performing data enhancement, the method further includes: Calculate the number of positive support samples and negative support samples for each category in the support set respectively; For a classification whose ratio of the number of negative support samples to the number of positive support samples does not meet the positive-to-negative support sample ratio requirement corresponding to the classification task requirement, determine whether a number of negative support samples that meets the positive-to-negative support sample ratio requirement can be extracted from sample data of other classifications; If possible, then randomly extract negative support samples of a number that meets the positive-to-negative support sample ratio requirement from sample data of other categories; if not, then adjust the data enhancement strategy of the support set so that the ratio of the number of negative support samples to the number of positive support samples of each category in the adjusted support set can meet the positive-to-negative support sample ratio requirement.

8. A few-sample data classification system, characterized in that: The system includes a data acquisition unit, a strategy determination unit, a data enhancement unit, a model training unit and a data classification unit, and is used to execute the few-sample data classification method as described in any one of claims 1-7.

Citation Information

Patent Citations

  • Data enhancement method and device, model training method and device and electronic equipment

    CN118228044A

  • Fine-tuning of transductive few-shot learning methods using margin-based uncertainty weighting and probability regularization

    WO2024091317A2