Few-sample data classification method and system

By determining the data augmentation strategy of support sets and query sets based on classification task requirements and data characteristics, the problem that data augmentation algorithm in the prior art cannot effectively match the model requirements, and improves the accuracy and performance of data classification with few samples.

CN119807857AActive Publication Date: 2025-04-11UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 4 Cites 0 Cited by

Patent Information

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

AI Technical Summary

Technical Problem

Existing data augmentation algorithms cannot effectively match the classification task requirements of the model in the classification of small samples, resulting in insufficient classification accuracy.

Method used

By acquiring the 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, and enhancement algorithms such as geometric transformation, color transformation, region transformation and noise addition are used.

Benefits of technology

The performance and accuracy of the classification model in the case of few samples are improved, and it can better adapt to specific classification task requirements and data characteristics.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119807857A_ABST
    Figure CN119807857A_ABST
Patent Text Reader

Abstract

The invention provides a few-sample data classification method and system, and relates to the technical field of data processing.The method comprises the steps that a classification model and an image data set participating in training are obtained, the image data set comprises a support set and a query set, and classification task requirements of the classification model and data characteristics of the data set are obtained; the data characteristics comprise the sample number, the data quality and the sample distribution condition of the sample data; respectively determining data enhancement strategies of the support set and the query set according to classification task requirements and data characteristics; performing data enhancement on the support set and the query set according to a data enhancement strategy; training a classification model by using the support set and the query set after data enhancement; and performing data classification through the trained classification model. According to the scheme, the data enhancement strategy better matched with the requirement can be generated according to the classification task requirement and the specific condition of the data set, the performance of the classification model for the current requirement scene can be effectively improved, and the classification accuracy under the condition of few samples is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data processing technology, and in particular to a method and system for classifying small sample data. 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, data is scarce 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 models in specific fields with the support of a small amount of data has become a hot topic in current research.

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

[0005] In response to the above problems, the present invention provides a method and system for classifying data with a small number of samples, which can effectively improve the performance of the classification model for the current demand scenario and improve the classification accuracy in the case of a small number of samples.

[0006] In a first aspect, the present invention provides a method for classifying small sample data, the method comprising:

[0007] 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;

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

[0009] Performing data enhancement on the support set and the query set respectively according to the data enhancement strategy;

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

[0011] Data classification is performed using the trained classification model.

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

[0013] Determine whether the number of samples of each category in the support set meets the support set sample number requirement corresponding to the classification task requirement;

[0014] For categories that do not meet the sample size requirement of the support set, determine the need to increase the sample size;

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

[0016] If it is not achieved, a conservative enhancement algorithm is selected; if it is achieved, an aggressive enhancement algorithm is selected;

[0017] It is determined whether the sample distribution of the support set matches the real scene corresponding to the classification task requirement. If not, it is determined that the number of samples needs to be increased for the category with insufficient sample proportion.

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

[0019] Determine whether the number of samples in each category in the query set meets the query set sample number requirement corresponding to the classification task requirement;

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

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

[0022] If it is not achieved, a conservative enhancement algorithm is selected; if it is achieved, an aggressive enhancement algorithm is selected;

[0023] Determine whether the sample distribution of the query set matches the real scene corresponding to the classification task requirement;

[0024] If there is a mismatch, the category with insufficient sample proportion will be determined to require sample quantity enhancement. For the category with excessive sample proportion, random sampling will be performed based on the value exceeding the proportion to reduce the sample quantity.

[0025] Optionally, 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 a preset threshold standard, it is distinguished as the conservative class.

[0026] Optionally, the method further comprises:

[0027] After the selection of an aggressive or conservative enhancement algorithm is determined according to the data quality, a range of configuration parameters when the enhancement algorithm is executed is determined based on the gap between the data quality and the data quality requirement.

[0028] Optionally, 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.

[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 requirements;

[0031] Recalculate data quality for preprocessed sample data.

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

[0033] According to the data enhancement strategy, the number of samples of the support set and the query set after data enhancement is calculated respectively;

[0034] 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;

[0035] 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.

[0036] Optionally, after performing data enhancement, 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 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;

[0039] 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.

[0040] A second aspect of the present invention provides a small sample data classification system, comprising:

[0041] A data acquisition unit is used to acquire a classification model and an image data set involved in training, wherein the image data set includes a support set and a query set, and to acquire the classification task requirements of the classification model and data characteristics of the data set, wherein the data characteristics include the sample quantity, data quality and sample distribution of the sample data;

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

[0043] A data enhancement unit, used to perform data enhancement on the support set and the query set respectively according to the data enhancement strategy;

[0044] A model training unit, used to train the classification model using the support set and query set after data enhancement;

[0045] The data classification unit is used to classify data using a trained classification model.

[0046] In summary, the present invention provides a method and system for classifying data with a small number of samples, which can generate a data enhancement strategy that better matches the requirements according to the requirements of the specific classification task to be performed and the specific circumstances of the data set involved in the training, and then use the data set enhanced by the data enhancement strategy to perform 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 case of a small number of samples. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0048] Figure 1 A flowchart of a method for classifying small sample data provided by an embodiment of the present invention;

[0049] Figure 2A structural block diagram of a small sample data classification system provided in an embodiment of the present invention.

[0050] Explanation of the accompanying drawings: 110 - data acquisition unit; 120 - strategy determination unit; 130 - data enhancement unit; 140 - model training unit; 150 - data classification unit. DETAILED DESCRIPTION

[0051] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0052] Currently, data is scarce 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 models in specific fields with the support of a small amount of data has become a hot topic in current research.

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

[0054] Therefore, how to provide a small number of sample data classification method with higher classification accuracy is a problem that needs to be solved urgently.

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

[0056] A small sample data classification method provided in this embodiment will be described in detail below.

[0057] like Figure 1 As shown, the present invention provides a small sample data classification method, comprising:

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

[0059] In Few-Shot Learning, Support Set and Query Set play a vital role. They each have different functions and characteristics, and together constitute 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 the 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 Transformer (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 that represent all categories in the current task. The number of samples in each category is very limited, usually in the form of 1-shot (1 sample per class), 5-shot (5 samples per class), etc. In the case of few samples, the number of samples in each category in the support set is very limited, usually in the form of 1-shot (1 sample per class), 5-shot (5 samples per class), etc. Due to the limited number of samples, the support set may not fully cover all changes in the 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 various situations in the target category as widely as possible, including different postures, lighting conditions, backgrounds, etc., to ensure that the evaluation results are statistically significant. By using the query set, the performance of the model in the face of 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, so that the classification model can better handle unseen data. Considering their respective roles in model training and their positions in the few-shot learning task, when performing data augmentation, it is necessary to select appropriate data augmentation based on the specific sample data in the obtained support set and query set to match the current classification task requirements.

[0063] In this embodiment, data characteristics are taken as specific considerations, and the data characteristics specifically include the number of samples, data quality and sample distribution. The number of samples corresponds to the number of samples specifically included in the support set and the query set; the data quality corresponds to the 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 each type of samples in the support set and the query set. Generally, the closer the distribution ratio is to 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 query set used in training. When the degree of match between the data characteristics and the classification task requirements is higher, the effect of subsequent training will be better.

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

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

[0067] Step S102, determining data enhancement strategies for the support set and the query set respectively according to the classification task requirements and the data characteristics.

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

[0069] When determining the data augmentation strategies for the support set and query set, we should consider both the similarities and differences in their needs. 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, it is necessary to try to maintain the true distribution characteristics of the data when performing data augmentation to avoid generating samples that are too unnatural or completely inconsistent with the actual scenario. Since the number of samples in each category in the support set is very limited, the augmentation technology can be applied more aggressively; in contrast, the query set pays more attention to maintaining the authenticity of the samples and usually only applies more conservative augmentation methods. The support set directly participates in the learning process of the model as the basis for the model to adjust parameters and build classification rules; the query set is mainly used to test and verify the performance of the model, not directly for training, so its augmentation should focus on simulating the diversity and challenges of the real world, rather than helping the model learn. All augmentation operations of the support set are based on known labels, with the purpose of allowing the model to better understand specific categories; the query set is usually unlabeled data, and augmentation does not rely on label information, and the focus is on how to make the model make correct predictions in unknown situations. The samples after support set augmentation will be added to the training process and may need to be saved for multiple uses; the samples after query set augmentation 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, and what is more important is to ensure that the augmentation does not introduce bias and affect the fairness of the evaluation.

[0070] Therefore, for the support set, you can boldly try a variety of enhancement techniques in the exploration phase, but make sure not to over-enhance when finalizing the solution; for the query set, you should be more cautious and give priority to simple enhancement methods that do not significantly change the image content. Although the support set and the query set have a common goal in data enhancement - that is, to improve the generalization ability and robustness of the model, due to their different roles in the task, there are significant differences in the specific implementation of the enhancement. Reasonably distinguishing and handling the data enhancement needs of these two sets is the key to successful few-shot learning.

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

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

[0073] For categories that do not meet the sample size requirement of the support set, determine the need to increase the sample size;

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

[0075] If it is not achieved, a conservative enhancement algorithm is selected; if it is achieved, an aggressive enhancement algorithm is selected;

[0076] It is determined whether the sample distribution of the support set matches the real scene corresponding to the classification task requirement. If not, it is determined that the number of samples needs to be increased for the category with insufficient sample proportion.

[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 number of samples in each category in the query set meets the query set sample number requirement corresponding to the classification task requirement;

[0079] For categories that meet the query set sample quantity requirement, select two or more enhancement algorithms, and for categories that do not meet the query set sample quantity requirement, 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 it is not achieved, a conservative enhancement algorithm is selected; if it is achieved, an aggressive enhancement algorithm is selected;

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

[0083] If there is a mismatch, the category with insufficient sample proportion will be determined to require sample quantity enhancement. For the category with excessive sample proportion, random sampling will be performed based on the value exceeding the proportion 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 scene are different, so judgments should be made based on the obtained classification task requirements. Different classification task requirements include high classification accuracy requirements, requirements for robustness to specific transformations, handling of new or unknown categories, and cross-modal recognition requirements. By analyzing the quantity, quality, distribution of existing support set and query set sample data, and whether there are special structural features, we can decide which data augmentation 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), a variety of augmentation techniques should be used to maximize the amount of information in each sample data. For example, geometric transformations (rotation, flipping, scaling), color adjustments (brightness, contrast changes), 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 approach can help the model understand the category characteristics more fully, but it is necessary to ensure that the generated samples still conform to the distribution of the real world. It should be noted that when performing any augmentation operation, the consistency of the label must be guaranteed, that is, the enhanced sample data still belongs to the original category. If the sample data quality of the support set is very high (clear, noise-free), more aggressive data augmentation methods can be used, such as a larger range of geometric transformations or complex mixing methods (Mixup, Cutmix). This can provide the model with more diverse training signals without compromising data quality. If the distribution of samples in the support set is uneven, and some categories have fewer samples in the support set, they can be oversampled 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 enhancement strategy for the query set, since the number of query set samples is large, a wide range of data enhancement techniques can be applied, such as random cropping, rotation, color jitter, etc., to simulate the actual situation under different conditions. This helps to evaluate the true generalization ability of the model. As a preferred embodiment, in order to improve flexibility and efficiency, the data enhancement of the query set is usually performed immediately during the evaluation, rather than pre-generating and saving a large number of enhanced samples. This not only saves storage space, but also allows the enhancement strategy to be flexibly adjusted as needed. On the other hand, if the data quality in the query set is poor (there are problems such as noise and blur), a more conservative enhancement method should be selected to avoid introducing too much deviation. For example, a slight color adjustment or a small angle rotation may be a better choice. 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 enhancement, it is necessary to ensure that the transformations and techniques used can truly reproduce common changes in the target field, such as lighting conditions, background interference, etc.

[0087] When analyzing the above data characteristics, we should also adjust the focus of the enhancement strategy in combination with the classification task requirements. For example, if the task requires the classification model to be highly robust, extensive enhancements should be made on the support set; if the focus is more on quickly adapting to new categories, the diversity and representativeness of the query set should be ensured.

[0088] Specifically, 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 the 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. For example, for geometric transformation, the configuration parameters executed include rotation amplitude, zoom range and zoom ratio, translation distance, etc. For color transformation, the configuration parameters executed include brightness / contrast adjustment, hue shift, and saturation adjustment. For area transformation, the configuration parameters executed include cropping area and cropping quantity. For noise addition, the configuration parameters executed include noise type and noise ratio. Taking the rotation amplitude as an example, the threshold standard is set to 90 degrees. A rotation amplitude greater than 90 degrees is a radical class, and a rotation amplitude less than 90 degrees is a conservative class.

[0089] It should be noted that aggressive methods usually involve changes in a larger range or intensity, 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 even make it difficult to recognize the original object, so they are suitable for tasks that are not sensitive to the shape of the original data. They are more suitable for occasions where there is sufficient data and the model needs to be highly robust, such as natural scene recognition, autonomous driving, and other fields, where the model needs to cope with inputs under various complex conditions. Conservative methods tend to make 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 shape of the original data. They are particularly suitable for situations where the data quality is poor or the number of samples is limited, as well as fields such as medical imaging and facial recognition that require high accuracy of the original data, where maintaining the authenticity and details of the image is crucial.

[0090] Based on the above scheme, in addition to selecting the type of enhancement algorithm, it is also necessary to consider the available range of configuration parameters when the enhancement algorithm is executed to further meet the needs of the actual reference scenario.

[0091] Specifically, the method further includes:

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

[0093] When making specific determinations, 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 to 90 degrees. A value greater than 90 degrees is an aggressive class, and a value less than 90 degrees is a conservative class. When the data quality requirements are not met and the gap between the data quality and the data quality requirements is large, the setting value of the rotation amplitude should be much smaller than 90 degrees and the available range of values ​​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 setting value of the rotation amplitude should be a larger range between 0-90 degrees; when the data quality requirements are met and the gap between the data quality and the data quality requirements is large, the setting value of the rotation amplitude should be a larger range between 90-180 degrees; when the data quality requirements are met and the gap between the data quality and the data quality requirements is small, the setting value of the rotation amplitude should be slightly larger than 90 degrees and the available range of values ​​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 choosing an aggressive enhancement algorithm, you can use a multi-step enhancement approach, combining multiple enhancement techniques, such as performing elastic deformation first and then color jittering, to form a complex transformation effect.

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

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

[0098] Recalculate data quality for preprocessed sample data.

[0099] For sample data with low data quality, the sample data can be processed first through preprocessing to improve its sample quality, and then the data enhancement strategy can be determined based on 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] According to the data enhancement strategy, the number of samples of the support set and the query set after data enhancement is calculated respectively;

[0102] Determine whether the sample quantity ratio of the support set and the query set matches the sample quantity ratio requirement corresponding to the classification task requirement;

[0103] 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.

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

[0105] After the data enhancement strategies for the support set and the query set are finally determined through the above process, data enhancement can be performed on the support set and the query set respectively.

[0106] Step S103: performing data enhancement on the support set and the query set respectively according to the data enhancement strategy.

[0107] It should be noted that, considering the requirements of some special classification tasks, there are 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 needed on this basis.

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

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

[0110] 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;

[0111] 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 each category in the adjusted support set can meet the positive-to-negative support sample ratio requirement.

[0112] Since negative support samples can be extracted from sample data of other categories, when the number of negative support samples is insufficient, it is necessary to first determine whether they can be extracted from sample data of other categories to meet the demand. If not, consider adjusting the data enhancement strategy of the support set so that each category in the adjusted support set can meet the positive and negative support sample ratio requirement.

[0113] Step S104: training the classification model using the support set and query set after data enhancement.

[0114] Step S105, classify the data using the trained classification model.

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

[0116] The following is an example of a specific case:

[0117] Scenario requirements description:

[0118] Suppose a plant disease recognition system is being developed to help farmers quickly and accurately identify different diseases (new classes) and health states (base classes) on crops. The system will use few-shot learning techniques to adapt to new disease types with a limited support set and evaluate using a query set.

[0119] The method is executed as follows:

[0120] 1. Clarify the classification task requirements:

[0121] Mission objectives:

[0122] Quickly adapt and identify new types of plant diseases.

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

[0124] Evaluation criteria:

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

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

[0127] Support set features:

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

[0129] Data Quality: High quality images, captured in good conditions, but there may be slight lighting variations.

[0130] Sample distribution: The number of samples between categories may be uneven, with fewer samples for some disease types.

[0131] QuerySet Features:

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

[0133] Data quality: Data collected from the wild have varying degrees of noise, blur and other issues.

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

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

[0136] Positive supporting images (confirmed cases):

[0137] Diverse geometric transformations:

[0138] Rotation: Small angle rotation of ±10 degrees to keep the disease characteristics unchanged.

[0139] Flip: Horizontal flip, suitable for diseases with strong symmetry.

[0140] Zoom and Pan: Slight zoom (90%-110%) and pan operations to simulate the disease performance from different perspectives.

[0141] Color Adjustment:

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

[0143] Color dithering: Slightly change the RGB channel values ​​to introduce some color variation without distortion.

[0144] Slight noise added:

[0145] Low-level Gaussian noise: Adds a small amount of random noise points to simulate slight disturbances in the real world.

[0146] Label consistency check:

[0147] Make sure that all augmentation operations do not change the class label of the image.

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

[0149] Extreme geometric transformations:

[0150] Large rotations: 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 an image to make it noticeably different from the positive example.

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

[0155] Complex hybrid methods:

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

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

[0158] Generative Adversarial Networks (GANs):

[0159] GANs are used to generate challenging negative examples to test the generalization ability of the model.

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

[0161] Large number of samples:

[0162] Diversification enhancement:

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

[0164] On-the-fly enhancement: To improve flexibility and efficiency, enhanced samples can be generated on-the-fly during evaluation rather than saving a large number of enhanced images in advance.

[0165] Data quality varies:

[0166] Conservative enhancement:

[0167] Simplify enhancement operations: Choose more conservative enhancement methods, such as slight color adjustments or small angle rotations, to avoid further degrading the data quality.

[0168] Fix noise: When possible, pre-process low-quality data, such as improving image quality through noise reduction algorithms, and then perform moderate data augmentation.

[0169] The sample distribution is uneven:

[0170] Balanced category ratio:

[0171] Oversampling minority categories: Appropriate oversampling enhancement is performed on categories with fewer samples to balance the difference in sample numbers between categories.

[0172] Undersampling the majority class: If some classes have too many samples, you can also consider randomly sampling 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 be highly robust, extensive enhancements should be made on the support set; if the focus is more on quickly adapting to new categories, the query set should be diverse and representative.

[0176] Computing Resource Management:

[0177] Properly plan computing resources, especially when processing large query sets, to avoid unnecessary complex calculations and ensure that 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 based on actual conditions to find the most optimized solution.

[0180] On the basis of the above, as another implementation of the present invention, when performing data enhancement on the support set, positive support samples and negative support samples may be distinguished, and different enhancement strategies may be applied to each of them.

[0181] Specifically, data enhancement for positive support samples can make positive support images show more diverse features through appropriate data enhancement, helping the model to better understand the core attributes of the category. The enhancement strategies adopted specifically include diversified geometric transformations: such as rotation, flipping, scaling, etc., but kept within a reasonable range to ensure that the image can still accurately reflect the category characteristics; color adjustment: moderately adjust brightness, contrast, etc. to simulate the situation under different lighting conditions; slight noise addition: add a small amount of Gaussian noise or perform slight blurring to simulate interference factors in the real world. Data enhancement for negative support samples can provide the model with more negative example information, help it define the category boundaries more clearly, and avoid confusion. Appropriate negative example enhancement can make the model more sensitive to abnormal situations and improve its robustness when facing unknown or uncommon samples. The enhancement strategies adopted specifically include extreme geometric transformations: such as large rotations, large-scale translations, or elastic deformations, to create greater visual differences between negative and positive examples. Significant color changes: such as hue shifts, saturation adjustments, etc., change the overall color tone of the image to make it significantly different from the positive example. Complex hybrid methods: Use Mixup, Cutmix and other techniques to create new negative examples to further expand the differences between categories. Generative adversarial networks (GANs): Use GANs to generate challenging negative examples to test the generalization ability of the model.

[0182] The following is a specific example, assuming that the demand scenario is a medical imaging diagnosis system that identifies rare diseases through a classification model:

[0183] Positive supporting images (confirmed cases):

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

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

[0186] For unconfirmed cases, more aggressive enhancement methods, such as extreme geometric transformations, significant color changes, etc., can be used to create more challenging negative 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 method for classifying data with a small number of samples, which can generate a data enhancement strategy that better matches the requirements according to the requirements of the specific classification task to be performed and the specific circumstances of the data set involved in the training, and then use the data set enhanced by the data enhancement strategy to perform 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 case of a small number of samples.

[0188] like Figure 2As shown, the few-sample data classification system provided by the present invention includes:

[0189] A data acquisition unit 110 is used to acquire a classification model and an image data set involved in training, wherein the image data set includes a support set and a query set, and to acquire the classification task requirements of the classification model and data characteristics of the data set, wherein the data characteristics include the sample quantity, data quality, and sample distribution of the sample data;

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

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

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

[0193] The data classification unit 150 is used to classify data using a trained classification model.

[0194] The few-sample data classification system provided in the embodiment of the present invention is used to implement the few-sample data classification method mentioned above, so the specific implementation method is the same as the above method and will not be repeated here.

[0195] In summary, the present invention provides a method and system for classifying data with a small number of samples, which can generate a data enhancement strategy that better matches the requirements according to the requirements of the specific classification task to be performed and the specific circumstances of the data set involved in the training, and then use the data set enhanced by the data enhancement strategy to perform 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 case of a small number of samples.

[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 schematic. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the devices, methods and computer program products according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of the code, and a module, a program segment or a part of the code contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.

[0197] In addition, the functional modules in the various embodiments of the present application 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 functions are implemented in the form of software function modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

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; Data is classified using the trained classification model.

2. The method for classifying small sample data according to claim 1, characterized in that: Determining a data augmentation strategy for a support set according to the classification task requirements and the data characteristics includes: Determine whether the number of samples of each category in the support set meets the support set sample number requirement corresponding to the classification task requirement; For categories that do not meet the sample size requirement of the support set, determine the need to increase the sample size; Determine whether the data quality of the support set meets the data quality requirement corresponding to the classification task requirement; If it is not achieved, a conservative enhancement algorithm is selected; if it is achieved, an aggressive enhancement algorithm is selected; It is determined whether the sample distribution of the support set matches the real scene corresponding to the classification task requirement. If not, it is determined that the number of samples needs to be increased for the category with insufficient sample proportion.

3. The method for classifying small sample data according to claim 2, characterized in that: Determining a data enhancement strategy for a query set according to the classification task requirements and the data characteristics includes: Determine whether the number of samples in each category in the query set meets the query set sample number requirement corresponding to the classification task requirement; For categories that meet the query set sample quantity requirement, select two or more enhancement algorithms, and for categories that do not meet the query set sample quantity requirement, select one enhancement algorithm; Determine whether the data quality of the query set meets the data quality requirements corresponding to the classification task requirements; If it is not achieved, a conservative enhancement algorithm is selected; if it is achieved, an aggressive enhancement algorithm is selected; Determine whether the sample distribution of the query set matches the real scene corresponding to the classification task requirement; If there is a mismatch, the category with insufficient sample proportion will be determined to require sample quantity enhancement. For the category with excessive sample proportion, random sampling will be performed based on the value exceeding the proportion to reduce the sample quantity.

4. The method for classifying small sample data according to claim 3, 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.

5. The method for classifying small sample data according to claim 4, 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.

6. The method for classifying small sample data according to claim 5, 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.

7. The method for classifying small sample data according to claim 5, 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.

8. The method for classifying small sample data according to any one of claims 1 to 6, 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.

9. The method for classifying small sample data according to any one of claims 1 to 6, 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.

10. A small 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-9.

Citation Information

Patent Citations

  • Sample generation method and device and storage medium

    CN117689979A

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

    CN118228044A

  • Small sample medical image classification method and system and storage medium

    CN118429724A

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

    WO2024091317A2