Image recognition model training method and system based on small sample learning
By using data preprocessing, meta-enhancement and Episodic training in image recognition model training, the problem of model training in small samples is solved, and the model's rapid learning and high generalization ability in a small number of samples is achieved.
Patent Information
- Application Number
- CN202510300917.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-14
- Publication Date
- 2025-06-13
AI Technical Summary
In the case of small samples with insufficient sample size, how to effectively train the image recognition model to ensure the accuracy and generalization ability of the model in different scenarios.
Through data preprocessing and meta-enhancement, meta-training task models are generated, and Episodic training method is used to simulate scenarios to force the model to generalize quickly. At the same time, through model construction and feature extraction, the model scale is adjusted and space is embedded to achieve feature extraction and training.
The model can quickly learn new tasks in a small number of samples, effectively deal with the problem of insufficient sample size in small sample learning, and improve the generalization ability and recognition accuracy of the model.
Smart Images

Figure CN120147783A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to an image recognition model training method and system based on few-shot learning. Background Art
[0002] Image recognition is applied in most fields. Different application scenarios have an urgent need for accurate image recognition and classification, including but not limited to the field of crop pest monitoring and control. Accurately identifying and classifying images is of great significance for the management and control of agricultural production, intelligent monitoring systems, medical diagnosis and other fields. Deep learning has been widely applied in various fields to solve various problems, and in the case of image recognition problems, it can often achieve a very high accuracy rate. However, deep learning is a "data-hungry" technology that requires a large number of labeled samples to play a role. With the emergence of more application scenarios, we are increasingly facing the problem of insufficient sample quantity. Therefore, we are faced with the problem of how to train an image recognition model under the premise of insufficient sample quantity, that is, few-shot. Summary of the Invention
[0003] Object of the Invention: The object of the present invention is to provide an image recognition model training method and system based on few-shot learning, which can solve the problem of training an image recognition model under the premise of insufficient sample quantity, that is, few-shot.
[0004] Technical Solution: To solve the above technical problems, according to one aspect of the present invention, more specifically, it is an image recognition model training method based on few-shot learning, which specifically includes the following steps: S1. Data preparation and data preprocessing: Obtain the graphic data that needs to be used for training the recognition model, and randomly divide the data into multiple training sets, validation sets, and test sets, and perform preprocessing data augmentation on each image; S2. Generate a meta-training task model: Define task parameters, and generate a corresponding meta-training task model according to the task parameters; S3. Model construction and feature extraction: Use the training model as a feature extractor, adjust the model scale according to the task complexity, and embed spatial optimization; S4. Train the image recognition model: Based on the preprocessed training set and test set, train the image recognition model, calculate the cross-entropy loss between the prediction result of the query set and the true label, and update the training parameters in real time; S5. Verification and testing of the image recognition model: Based on the validation set, verify the trained image recognition model, and perform testing through the test set; S6. Image Recognition Model Tracking and Feedback: Track and evaluate the usage of the image recognition model after training is completed, and feedback it to the image recognition model training system. Based on the feedback results, adjust the image recognition model training system.
[0005] Furthermore, in step S1, the training set contains 64 categories, the validation set contains 16 categories, the test set contains 20 categories, and the validation set and the test set are mutually exclusive with the training set.
[0006] Furthermore, in step S1, the methods for preprocessing data augmentation include: rotating, flipping, cropping, color transformation, etc. of the images to expand the sample diversity, and generating new samples through GAN for meta-augmentation.
[0007] Furthermore, in step S2, the parameter definitions for the tasks include but are not limited to that each task contains 20 categories, each category contains 5 samples in the support set, and each category has 15 samples in the query set.
[0008] Furthermore, in step S2, the generation process of the task model is: randomly select 20 categories from 64 categories, randomly collect 5 samples for each category as the support set, and then collect 15 samples for each category as the query set, and ensure that the samples in the support set and the query set do not overlap.
[0009] Furthermore, in step S3, use one of the training models ResNet-12, ResNet-18, VisionTransformer as the feature extractor, map the images to the embedding space at the same time, and optimize the feature space through overlearning.
[0010] Furthermore, in step S4, the training method is to input an Episode: 100 images in the support set and 300 images in the query set; the backbone network processes all the images to obtain the support set features and the query set features; take the average of the support set features for each class to obtain 100 prototype vectors; calculate the matrix of each query sample and 100 prototypes; calculate the cross-entropy loss between the query set prediction result and the true label, and directly update the model parameters; batch generate multiple Episodes, each batch contains multiple independent small sample tasks, and learn the generalization ability through a large number of tasks.
[0011] Furthermore, in step S5, the methods for validation and testing are: randomly sample tasks from 16 categories in the validation set, calculate the average classification accuracy of the query set, construct tasks on 20 new categories in the test set, and report the average precision and standard deviation.
[0012] Further, in step S6, when tracking and feedback is performed on the trained and used graphic recognition model, the usage times of each image recognition model, the number of images recognized by each image recognition model each time, the images that cannot be correctly recognized in the images recognized by each graphic recognition model each time, and the duration of each image recognition are collected, and the above-collected data is comprehensively analyzed to obtain the optimization index of this image recognition model training method. At the same time, the optimization index of this image recognition model training method is compared with the preset threshold of the optimization index in real time. When the optimization index of this image recognition model training method reaches the preset threshold of the optimization index of this image recognition model training method, the optimization and improvement of this image recognition model training method are performed.
[0013] According to another aspect of the present invention, there is provided an image recognition model training system based on few-shot learning, which is used to implement the above-mentioned image recognition model training method based on few-shot learning, and includes a data acquisition module, a data preprocessing module, a training task model generation module, a model construction and feature extraction module, a model verification and testing module, an intelligent analysis module, and a warning and reminder module; Data acquisition module: used to collect various data required for the image recognition model training system; Data preprocessing module: used to perform preprocessing data augmentation on the image data collected by the data acquisition module; Training task model generation module: used to define task parameters and generate corresponding meta-training task models according to the task parameters; Model construction and feature extraction module: used to adjust the model scale according to the task complexity with the training model as a feature extractor, and embed spatial optimization; Model training module: used to train the image recognition model based on the preprocessed training set and test set, calculate the cross-entropy loss between the prediction result of the query set and the true label, and update the training parameters in real time; Model verification and testing module: used to verify the trained image recognition model based on the validation set and test it through the test set; Intelligent analysis module: used to analyze and process the relevant data during the use of the trained and used image recognition model to obtain the optimization index of this image recognition model training method; Warning and reminder module: used to set the threshold of the optimization index of this image recognition model training method, and send a warning reminder for the optimization and improvement of this image recognition model training method when the optimization index of this image recognition model training method reaches the preset threshold of the optimization index of this image recognition model training method.
[0014] Beneficial effects: Through the above steps, the model can quickly learn new tasks from a small number of samples. Episodic training simulates scenarios, forcing the model to master the meta-ability of rapid generalization, which can effectively address the problem of insufficient sample quantity encountered in few-shot learning. Task-driven training forces the model to learn to generalize quickly from a small number of samples instead of relying on a large amount of data. When tracking and providing feedback on the trained graphic recognition model during use, the usage times of each image recognition model, the number of images recognized by each image recognition model each time, the images that cannot be correctly recognized in the images recognized by each graphic recognition model each time, and the duration of each image recognition are collected, and the above-collected data is comprehensively analyzed to obtain the optimization index of this image recognition model training method. At the same time, the optimization index of this image recognition model training method is compared in real time with the threshold of the pre-set optimization index. When the optimization index of this image recognition model training method reaches the threshold of the pre-set optimization index of this image recognition model training method, the optimization and improvement of this image recognition model training method are carried out, which can effectively track and evaluate the training method in real time, so as to ensure that the technical discovery training method is insufficient and needs to be optimized and improved. Brief Description of the Drawings
[0015] Figure 1 is a schematic diagram of the method flow; Figure 2 is a schematic diagram of the system principle. Detailed Embodiments
[0016] To make the technical solutions of the present invention clearer, the following further describes the present invention in detail with reference to the accompanying drawings and specific embodiments.
[0017] Embodiment 1 First step, data preparation and data preprocessing: Obtain the graphic data required for training the recognition model through the data acquisition module, and perform operations such as rotation, flipping, cropping, and color transformation on the images through the data preprocessing module to expand sample diversity. At the same time, generate new samples through GAN for meta-augmentation, and randomly divide the data into a training set of 64 categories, a validation set of 16 categories, and a test set of 20 categories.
[0018] Second step, generate a meta-training task model: Define task parameters through the training task model generation module. Each task contains 20 categories, each category contains 5 samples in the support set, and each category has 15 samples in the query set. Randomly select 20 categories from 64 categories, and randomly collect 5 samples for each category as the support set, and then collect 15 samples for each category as the query set, and ensure that the samples in the support set and the query set do not overlap. Generate the corresponding meta-training task model according to the above task parameters.
[0019] Step 3, Model Construction and Feature Extraction: Use one of ResNet-12, ResNet-18, and Vision Transformer in the model construction and feature extraction module as the feature extractor, adjust the model scale according to the task complexity, map the image to the embedding space at the same time, and optimize the feature space through overlearning.
[0020] Step 4, Train the Image Recognition Model: Use the model training module to train the image recognition model based on the preprocessed training set and test set. The training method is to input an Episode: 100 images in the support set and 300 images in the query set; the backbone network processes all images to obtain the support set features and query set features; take the average of the support set features for each class to obtain 100 prototype vectors; calculate the matrix of each query sample and 100 prototypes; calculate the cross-entropy loss between the query set prediction result and the true label, and directly update the model parameters; batch generate multiple Episodes, each batch contains multiple independent few-shot tasks, learn the generalization ability through a large number of tasks, calculate the cross-entropy loss between the query set prediction result and the true label, and update the training parameters in real time.
[0021] Step 5, Validate and Test the Image Recognition Model: Use the model validation and testing module to validate the trained image recognition model based on the validation set and test it through the test set. Randomly sample tasks from 16 classes in the validation set, calculate the average classification accuracy of the query set, construct tasks on 20 new classes in the test set, and report the average precision and standard deviation.
[0022] Step 6, Image Recognition Model Tracking and Feedback: Track and evaluate the usage of the trained image recognition model, and feedback it to the image recognition model training system. Use the feedback result as the basis for adjusting the image recognition model training system. Collect the number of times each image recognition model is used, the number of images recognized by each image recognition model each time, the images that cannot be correctly recognized in the images recognized by each image recognition model each time, and the duration of each image recognition through the data collection module. Obtain the optimization index of this image recognition model training method through comprehensive analysis of the collected data by the intelligent analysis module. At the same time, set the threshold of the optimization index of this image recognition model training method through the warning reminder module, and compare the optimization index of this image recognition model training method with the preset threshold of the optimization index in real time. When the optimization index of this image recognition model training method reaches the preset threshold of the optimization index of this image recognition model training method, a warning reminder for optimizing and improving this image recognition model training method will be sent through the warning reminder module.
[0023] The above-described embodiments merely represent several implementation manners of the present invention. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the patent for the present invention. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can still be made, and these all fall within the protection scope of the present invention. Therefore, the protection scope of the patent for the present invention shall be subject to the appended claims.
Claims
1. A method for training an image recognition model based on small sample learning, characterized in that: The specific steps include: S1. Data preparation and data preprocessing: Obtain the graphic data required for recognition model training, randomly divide the data into multiple training sets, validation sets, and test sets, and perform preprocessing data enhancement on each image; S2. Generate meta-training task model: define task parameters and generate corresponding meta-training task model according to the task parameters; S3, model construction and feature extraction: use the trained model as a feature extractor to adjust the model size according to the complexity of the task and embed space optimization; S4. Training the image recognition model: The image recognition model is trained based on the preprocessed training set and test set, and the cross entropy loss between the query set prediction result and the true label is calculated, and the training parameters are updated in real time; S5. Verification and testing of image recognition model: Verify the trained image recognition model based on the validation set and test it with the test set; S6. Image recognition model tracking and feedback: Track and evaluate the usage of the image recognition model after training, and feedback it to the recognition model training system. The image recognition model training system is adjusted based on the feedback results.
2. The image recognition model training method based on small sample learning according to claim 1, characterized in that: In step S1, the training set contains 64 categories, the validation set contains 16 categories, and the test set contains 20 categories, and both the validation set and the test set are mutually exclusive with the training set.
3. The image recognition model training method based on small sample learning according to claim 1, characterized in that: In step S1, the method for preprocessing data enhancement includes: rotating, flipping, cropping, color changing, etc. the image to expand sample diversity, and generating new samples through GAN for meta-enhancement.
4. The image recognition model training method based on small sample learning according to claim 2, characterized in that: In step S2, the parameter definition of the task includes but is not limited to that each task contains 20 categories, each category contains 5 samples in the support set, and each category has 15 samples in the query set.
5. The image recognition model training method based on small sample learning according to claim 4, characterized in that: In step S2, the generation process of the task model is as follows: 20 categories are randomly selected from the 64 categories, and 5 samples are randomly collected from each category as a support set, and 15 samples are collected from each category as a query set, and it is ensured that the samples of the support set and the query set do not overlap.
6. The image recognition model training method based on small sample learning according to claim 1, characterized in that: In step S3, one of the training models ResNet-12, ResNet-18, and Vision Transformer is used as a feature extractor, and the image is mapped to the embedding space, and the feature space is optimized by over-learning.
7. The image recognition model training method based on small sample learning according to claim 1, characterized in that: In step S4, the training method is to input an Episode: 100 images in the support set and 300 images in the query set; the backbone network processes all images to obtain support set features and query set features; The support set features of each class are averaged to obtain 100 prototype vectors; the matrix of each query sample and 100 prototypes is calculated; the cross entropy loss between the query set prediction results and the true labels is calculated, and the model parameters are directly updated; multiple Episodes are generated in batches, each batch contains multiple independent small sample tasks, and generalization capabilities are learned through a large number of tasks.
8. The image recognition model training method based on small sample learning according to claim 1, characterized in that: In step S5, the verification and testing method is: randomly sampling tasks from the 16 categories of the verification set, calculating the average classification accuracy of the query set, constructing tasks on the 20 new categories of the test set, and reporting the average accuracy and standard deviation.
9. The image recognition model training method based on small sample learning according to claim 1, characterized in that: In step S6, when tracking feedback on the graphic recognition model that has been trained and used, the number of times each image recognition model is used, the number of images recognized by each image recognition model each time, the images that each image recognition model fails to correctly recognize in each recognition, and the duration of each image recognition are collected, and the above collected data are comprehensively analyzed to obtain the optimization index of the image recognition model training method. At the same time, the optimization index of the image recognition model training method is compared with a preset optimization index threshold in real time. When the optimization index of the image recognition model training method reaches the preset optimization index threshold of the image recognition model training method, the image recognition model training method is optimized and improved.
10. A small sample learning-based image recognition model training system, used to implement the small sample learning-based image recognition model training method according to any one of claims 1 to 9, characterized in that: It includes data acquisition module, data preprocessing module, training task model generation module, model construction and feature extraction module, model training module, model verification and testing module, intelligent analysis module and warning reminder module; Data acquisition module: used to collect various data required for the image recognition model training system; Data preprocessing module: used to perform preprocessing data enhancement on the image data collected by the data acquisition module; Training task model generation module: used to define task parameters and generate corresponding meta-training task models based on the task parameters; Model building and feature extraction module: used to use the trained model as a feature extractor to adjust the model size according to the complexity of the task and embed space optimization; Model training module: used to train the image recognition model based on the preprocessed training set and test set, calculate the cross entropy loss between the query set prediction results and the true labels, and update the training parameters in real time; Model verification test module: used to verify the trained image recognition model based on the verification set and test it through the test set; Intelligent analysis module: used to analyze and process the relevant data of the image recognition model that has been trained and used during use to obtain the optimization index of the image recognition model training method; Warning reminder module: used to set the threshold of the optimization index of the image recognition model training method, and issue a warning reminder for optimizing and improving the image recognition model training method when the optimization index of the image recognition model training method reaches the preset threshold of the optimization index of the image recognition model training method.
Citation Information
Cited By
Electric power customer service model optimization method and system based on artificial intelligence
CN120764689A