Training method and device of image recognition classification model, equipment and medium
By using the feature layer output of the high-complexity reference model as a supervision signal, the low-complexity model to be trained is solved, and the problem of low model performance in resource-constrained environments is achieved, and a good balance of performance and efficiency is achieved.
Patent Information
- Application Number
- CN202411542195.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-31
- Publication Date
- 2025-02-14
AI Technical Summary
In pedestrian recognition and face recognition tasks, although high-complexity models can extract rich features, they have high computational costs and long running time, making it difficult to deploy in resource-constrained environments; while low-complexity models are simple Under training with data tag supervision, effective feature representation cannot be fully learned, resulting in lower performance.
By selecting the trained high-complexity image recognition classification model as the reference model, using the image features output from its feature layer as the supervision feature, combining the data label to train and supervise the low-complexity model to be trained and supervised, and a corresponding supervision loss function is constructed. To achieve effective training of the model.
While maintaining low computing resource requirements, low-complexity models can learn more effective feature representations, achieving a good balance of performance and efficiency, and are suitable for resource-constrained environments, improving the efficiency and accuracy of image recognition tasks .
Smart Images

Figure CN119445240A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer vision, and in particular to a training method, device, equipment and medium for an image recognition classification model Background Art
[0002] In pedestrian re-identification and face recognition tasks, although high-complexity models can extract rich features and have high accuracy, they often have high computational costs, long running times, and high demand for computing resources. In practical applications, especially in resource-constrained environments such as mobile devices or embedded systems, this may lead to deployment difficulties and poor real-time performance. Although low-complexity models are computationally efficient, they cannot fully learn effective feature representations when trained using only data label supervision, resulting in relatively low performance. Summary of the invention
[0003] In view of this, the purpose of the present invention is to provide a training method, device, equipment and medium for an image recognition classification model, which can train a model with lower computing resource requirements and learn more effective feature representation under resource-constrained conditions, thereby achieving a good balance between performance and efficiency and efficiently performing image recognition tasks. The specific scheme is as follows:
[0004] In a first aspect, the present application discloses a method for training an image recognition classification model, comprising:
[0005] Selecting a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters;
[0006] Constructing a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; wherein the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model;
[0007] Input the target label data training set into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervision features, and use the supervision features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained, and construct a corresponding supervision loss function;
[0008] When the function convergence result in the supervised loss function meets the preset convergence condition, the model training is stopped, and the current image recognition classification model is used as the trained target image recognition classification model.
[0009] Optionally, before inputting the target label data training set into the reference model and the image recognition classification model to be trained respectively, the method further includes:
[0010] Dynamic data enhancement processing is performed on a label data set used for human feature recognition training according to a preset data enhancement method to obtain a target label data training set; wherein the preset data enhancement method includes any one or more of data mirroring, data rotation, and data cropping.
[0011] Optionally, the target label data training set is input into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervision features, and the supervision features and data labels are used to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained, and a corresponding supervision loss function is constructed, including:
[0012] Inputting the target label data training set into the reference model, so as to perform image segmentation and image encoding on the target label data in the target label data training set based on each trained image processing layer by the reference model, and extracting image features from the encoded image by the feature layer of the reference model, so as to use the image features as supervision features;
[0013] The target label data training set and the supervisory features are input into the image recognition and classification model to be trained, so as to use the supervisory features to perform training supervision on the feature layer output in the model training process of the image recognition and classification model to be trained, and use the data label of the target label data to perform training supervision on the output of the multi-classification head output layer in the model training process of the image recognition and classification model to be trained, and construct a corresponding supervisory loss function.
[0014] Optionally, constructing a corresponding supervised loss function includes:
[0015] Acquire the supervisory features of the target label data output by the feature layer of the reference model and the process features of the feature layer output by the image recognition classification model to be trained when the same target label data is used for training;
[0016] Normalizing the supervisory features and the process features respectively to obtain target supervisory features and target process features in the same scale range;
[0017] Constructing a feature layer supervision loss function based on the target supervision feature and the target process feature;
[0018] Obtaining the data label of the target label data and the predicted probability distribution result output by the multi-classification head output layer of the image recognition classification model to be trained when the same target label data is used for training;
[0019] Constructing a data label supervision loss function based on the data label and the predicted probability distribution result;
[0020] A corresponding supervision loss function is constructed according to the feature layer supervision loss function and the data label supervision loss function.
[0021] Optionally, constructing a feature layer supervision loss function based on the target supervision feature and the target process feature includes:
[0022] Subtract each pair of the target supervision feature and the target process feature, square each difference result and then sum them up to obtain the corresponding feature layer output loss information;
[0023] A feature layer supervision loss function is constructed according to the feature layer output loss information and the feature dimension output by the reference model.
[0024] Optionally, constructing a data label supervision loss function based on the data label and the predicted probability distribution result includes:
[0025] A predicted probability value corresponding to the data label is determined from the predicted probability distribution result, and a data label supervision loss function is constructed based on the logarithmic information of the predicted probability value and the data label to characterize the degree of difference between the probability distribution predicted by the model and the data label.
[0026] Optionally, constructing a corresponding supervision loss function according to the feature layer supervision loss function and the data label supervision loss function includes:
[0027] A corresponding supervised loss function is constructed according to the feature layer supervised loss function, the first loss weight, the data label supervised loss function, and the second loss weight.
[0028] In a second aspect, the present application discloses a training device for an image recognition classification model, comprising:
[0029] A model selection module, used to select a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters;
[0030] A model building module, used to build a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; wherein the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model;
[0031] A model training module, used to input the target label data training set into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervision features, and use the supervision features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained, and construct a corresponding supervision loss function;
[0032] The training stop module is used to stop model training when the function convergence result in the supervised loss function meets the preset convergence condition, and use the current image recognition classification model as the trained target image recognition classification model.
[0033] In a third aspect, the present application discloses an electronic device, comprising:
[0034] Memory, used to store computer programs;
[0035] A processor is used to execute the computer program to implement the steps of the training method of the image recognition classification model disclosed above.
[0036] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the steps of the training method of the image recognition classification model disclosed above are implemented.
[0037] It can be seen that the present invention discloses a training method for an image recognition classification model, comprising: selecting a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters; constructing a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; inputting the target label data training set into the reference model and the image recognition classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervisory features, and using the supervisory features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition classification model to be trained, and constructing a corresponding supervisory loss function; when the function convergence result in the supervisory loss function meets the preset convergence condition, the model training is stopped, and the current image recognition classification model is used as the trained target image recognition classification model. It can be seen that by using a high-complexity reference model as a guide, a low-complexity model to be trained can learn more effective feature representations while maintaining low computing resource requirements, thereby achieving a good balance between performance and efficiency. This enables efficient image recognition tasks to be performed even in resource-constrained environments. After training, low-complexity models can approach the performance of high-complexity models, which not only meets the accuracy requirements of practical applications, but also does not affect the response speed and scalability of the system due to excessively high computational costs. The feature layer output of the reference model is introduced as a supervisory feature to enrich the source of information in the training process. Compared with training that relies solely on data labels, it guides the model to be trained to learn more discriminative and robust features, fully utilizes limited labeled data, and improves data utilization efficiency. At the same time, supervised training is performed on the feature layer output and the multi-classification head output layer of the model to be trained, and the model can be optimized from different levels. The supervision of the feature layer helps the model learn a more appropriate intermediate feature representation, while the supervision of the multi-classification head output layer ensures that the model can accurately perform classification predictions, improving the overall performance of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] 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 only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.
[0039] Figure 1 A flow chart of a training method for an image recognition classification model disclosed in this application;
[0040] Figure 2 A flowchart of a specific training method for an image recognition classification model disclosed in this application;
[0041] Figure 3 A schematic diagram of the structure of a training device for an image recognition classification model disclosed in this application;
[0042] Figure 4 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION
[0043] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. 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 making creative work are within the scope of protection of the present invention.
[0044] In pedestrian re-identification and face recognition tasks, although high-complexity models can extract rich features and have high accuracy, they often have high computational costs, long running times, and high demand for computing resources. In practical applications, especially in resource-constrained environments such as mobile devices or embedded systems, this may lead to deployment difficulties and poor real-time performance. Although low-complexity models are computationally efficient, they cannot fully learn effective feature representations when trained using only data label supervision, resulting in relatively low performance.
[0045] To this end, the present invention provides a training scheme for an image recognition classification model, which can train a model with lower computing resource requirements under resource-constrained conditions and can learn a more effective feature representation, thereby achieving a good balance between performance and efficiency and efficiently performing image recognition tasks.
[0046] Reference Figure 1 As shown, an embodiment of the present invention discloses a training method for an image recognition classification model, comprising:
[0047] Step S11: Selecting a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters.
[0048] In this embodiment, the first image recognition and classification model that has been trained is selected as the reference model. The model has a high complexity and has been fully trained with a large amount of data, and has excellent performance in feature extraction and classification capabilities. Among them, in terms of pedestrian re-identification, the reference model can accurately capture the unique features of pedestrians, such as: pedestrian appearance features, pedestrian gait features, and features of items carried, so that the same pedestrian can be accurately identified even under different viewing angles, lighting conditions, and complex background environments. In the field of face recognition, the reference model can accurately identify faces with different expressions, ages, and postures. Whether it is a clear frontal photo or a face image with a certain angle or partial occlusion, the reference model can quickly extract key features for face recognition, such as: facial geometry features, facial texture features, and facial color features. In this way, efficient recognition and classification can be performed. It can be widely used in scenes such as access control systems, mobile phone unlocking, and security monitoring, bringing great convenience to people's lives and work. In addition, when the reference model is selected as an important basis for guiding the training of a low-complexity model, its model parameters are in a frozen state. This means that during the subsequent training process of the model to be trained, the reference model will not change its own parameters due to the input of new data, but will stably output its carefully trained feature representation, providing a reliable supervision signal for the model to be trained.
[0049] In this embodiment, the first image recognition classification model can be a high-complexity image recognition model pre-trained after completing training for image recognition field tasks in different scenarios. Therefore, the pre-trained Vision-Transformer model is selected as the reference model M in the present invention.
[0050] Step S12: construct a second image recognition classification model for performing image recognition tasks and which is different from the reference model architecture as the image recognition classification model to be trained; wherein the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model.
[0051] In this embodiment, based on the selected reference model M, a second image recognition model for performing image recognition tasks and having an overall architecture different from that of the reference model M is further constructed as the image recognition model to be trained. It should be noted that the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model. In this way, the current computational complexity of the image recognition model to be trained is low, and the requirements for computing resources are also low, so as to enable rapid reasoning and deployment in actual task scenarios. Therefore, the present invention selects the ResNet model as the image recognition model to be trained m. In this way, models with different architectures (reference model and image recognition model to be trained) have different advantages and characteristics. The reference model M usually has strong advantages in feature extraction and expression capabilities, but has high computational costs and long running times. The image recognition model m to be trained can perform well in terms of computational efficiency due to its different architecture, and can quickly process data and perform reasoning. By limiting the architecture differences of the two models in the initial stage, the two models can be combined during subsequent training, which can achieve performance complementarity and improve the system's operating speed and efficiency while ensuring a certain accuracy rate. At the same time, if the image recognition model m to be trained has the same architecture as the reference model M, then during the training process, the image recognition model m to be trained will be overly dependent on the reference model M, which is prone to overfitting. Different architectures can enable the image recognition model m to be trained to learn different feature representations and decision rules, increase the diversity of the model, and thus reduce the risk of overfitting.
[0052] Step S13: Input the target label data training set into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervisory features, and use the supervisory features and data labels to supervise the feature layer output and multi-classification head output layer of the training process of the image recognition and classification model to be trained, and construct a corresponding supervisory loss function.
[0053] In this embodiment, before the target label data training set is input into the reference model and the image recognition classification model to be trained, it also includes: dynamically enhancing the label data set used for human feature recognition training according to a preset data enhancement method to obtain the target label data training set; wherein the preset data enhancement method includes any one or more of data mirroring, data rotation, and data cropping. The label data set used in the present invention is a labeled image data set selected for a specific image recognition task, wherein if the image recognition task is a task in the field of pedestrian re-identification, the label data set is a data set in the field of pedestrian re-identification, and if the image recognition task is a task in the field of face recognition, the label data set is a data set in the field of face recognition. Before model training, the label data set is preprocessed. Specifically, human feature recognition tasks, whether in the fields of face recognition or pedestrian re-identification, are faced with the challenges of limited data and diversity of actual scenarios. In order to better improve the generalization ability and robustness of the model, it is necessary to perform data enhancement processing on the label data set. Among them, the preset data enhancement method includes but is not limited to any one or more of data mirroring, data rotation, and data cropping. Among them, if the data mirroring method is adopted, the original image in the label data set can be mirrored and flipped horizontally or vertically, thereby effectively increasing the diversity of the data. For example, in the face recognition task, after the front image of a person is horizontally mirrored, the facial features observed from different angles can be simulated, so that the model can better adapt to various possible perspective changes in the actual scene. If the data rotation method is adopted, by rotating the original image at different angles, different shooting angles and head postures can be simulated. For pedestrian re-identification, pedestrians may be in different directions during walking. Data rotation can help the model learn the characteristics of pedestrians in different directions and improve the recognition ability of various postures. If the data cropping method is adopted, sub-images of different sizes and positions are randomly cropped from the original image. This method can simulate partial occlusion and different observation ranges in actual scenes. In face recognition, the face may be partially occluded. Through data cropping, the model can learn the ability to accurately recognize under partial occlusion. In pedestrian re-identification, the cropped image can highlight the characteristics of different parts of the pedestrian, so that the model pays more attention to detail information and improves the accuracy of recognition. Through these preset data enhancement methods, more diverse training samples can be generated from limited original labeled data sets, providing a richer data source for subsequent model training, thereby improving the performance of the model in practical applications.
[0054] The present invention takes the face recognition data set WebFace260m as an example. After data preprocessing, a corresponding target label data training set is obtained, and the target label data training set is further used to train the model. Specifically, the target label data training set is input into the reference model, so that the reference model is used to perform image segmentation and image encoding on the target label data in the target label data training set based on each trained image processing layer, and the image feature is extracted from the encoded image through the feature layer of the reference model to use the image feature as a supervisory feature; the target label data training set and the supervisory feature are input into the image recognition and classification model to be trained, so that the supervisory feature is used to perform training supervision on the feature layer output of the image recognition and classification model to be trained in the model training process, and the data label of the target label data is used to perform training supervision on the output of the multi-classification head output layer of the image recognition and classification model to be trained in the model training process, and a corresponding supervisory loss function is constructed. It can be understood that the data after data enhancement is input into the reference model M and the image recognition classification model m to be trained at the same time, wherein the reference model M is in a parameter freezing state; the feature layer output and data label of the reference model M are used to supervise the feature layer output and the final multi-classification head output of the image recognition classification model m to be trained, respectively, to form a supervision loss function, and to supervise the training of the image recognition classification model m to be trained. Specifically, when the target label data after data enhancement is input into the reference model M, the reference model M performs feature extraction in accordance with its pre-trained method. The reference model M is composed of multiple Transformer modules. First, the target label data is divided into patches, and then these patches are encoded through a multi-head self-attention mechanism and a feedforward neural network, and high-level image features are gradually extracted as supervision features. It should be noted that the supervision feature is the result of the output of the middle layer or the module close to the middle of the reference model M. Specifically, it is the output of a certain layer after passing through multiple Transformer modules but before reaching the final classification layer. The output of this layer contains rich image feature information and can be used as a supervision signal for the image recognition classification model to be trained.
[0055] At the same time, the target label data training set and the supervised features are input into the image recognition classification model m to be trained so as to extract features through each residual block, wherein ResNet is composed of multiple residual blocks, each of which contains a convolution layer, a batch normalization layer, and an activation function. When the image after data enhancement is input into ResNet, the image is sequentially extracted through these layers. It should be noted that in the process of feature extraction, each layer of the image recognition classification model m to be trained is supervised by the data label and guided by the supervised features. Specifically, in the training process of the image recognition classification model m, the feature representation extracted by the middle layer of ResNet will be supervised by the supervised features. During supervision, the features of the image recognition classification model m to be trained are gradually approached to the features of the reference model M by minimizing the feature layer supervised model loss function (MSE). Further, the classification result is obtained by the last fully connected layer of ResNet. This output classification result will be compared with the data label, and the model parameters of the image recognition classification model m to be trained will be adjusted by minimizing the final output data label supervised loss function (cross entropy CE) so that the model can correctly classify the input image.
[0056] In this embodiment, constructing a corresponding supervision loss function includes: obtaining the supervision features of the target label data output by the feature layer of the reference model and the process features output by the feature layer of the image recognition classification model to be trained when using the same target label data for training; normalizing the supervision features and the process features respectively to obtain the target supervision features and target process features under the same scale range; constructing a feature layer supervision loss function based on the target supervision features and the target process features; obtaining the data labels of the target label data and the predicted probability distribution results output by the multi-classification head output layer of the image recognition classification model to be trained when using the same target label data for training; constructing a data label supervision loss function based on the data labels and the predicted probability distribution results; constructing a corresponding supervision loss function according to the feature layer supervision loss function and the data label supervision loss function. It can be understood that the supervision features and process features are normalized, wherein the process features are the results output by a certain intermediate layer or a specific module in ResNet, and are the output of a certain layer after passing through several residual blocks. The output of this layer also represents a certain degree of image features, and needs to be supervised by the feature layer output of the reference model M to improve its own feature expression capabilities. Therefore, in order to make the supervision feature supervise the extraction process feature, that is, to make the two features comparable, they need to be normalized to the same scale range to obtain the target supervision feature and the target process feature.
[0057] Furthermore, each pair of the target supervision feature and the target process feature is subtracted, and each subtraction result is squared and then summed to obtain the corresponding feature layer output loss information; a feature layer supervision loss function is constructed according to the feature layer output loss information and the feature dimension of the reference model output. It can be understood that according to , construct the feature layer supervision loss function, where Indicates The target supervision features of the data, Indicates The target process characteristics of the data, represents the feature dimension, Represents the feature layer supervision loss function.
[0058] In this embodiment, the predicted probability value corresponding to the data label is determined from the predicted probability distribution result, and a data label supervision loss function is constructed based on the logarithmic information of the predicted probability value and the data label to characterize the degree of difference between the probability distribution predicted by the model and the data label. It can be understood that for the output data label part, since the data samples in the target label data training set have category labels, that is, data labels, the final multi-classification head output of the image recognition classification model m to be trained is a predicted probability distribution result P, and the dimension is the number of categories C. The cross entropy loss function measures the difference between the predicted probability distribution and the actual data label. For a single sample, the cross entropy loss is defined as: ,in, Indicates the real data label The value of the class (usually 0 or 1), The model m predicts The probability of the class. In the entire target label data training set, the cross entropy loss of all samples can be averaged to obtain the final output data label supervision loss function.
[0059] In this embodiment, a corresponding supervision loss function is constructed according to the feature layer supervision loss function, the first loss weight, the data label supervision loss function, and the second loss weight. It can be understood that the supervision loss function (Union-Loss) is composed of the weighted combination of the feature layer supervision loss function and the final output data label supervision loss function, that is, ,in, represents the first loss weight, represents the second loss weight, and The loss weight is used to balance the importance of feature layer supervision and data label supervision.
[0060] Step S14: When the function convergence result in the supervised loss function meets the preset convergence condition, the model training is stopped, and the current image recognition classification model is used as the trained target image recognition classification model.
[0061] In this embodiment, according to the above training steps, the image recognition classification model m to be trained is subjected to multiple rounds of iterative training until the function convergence result in the supervision loss function satisfies the preset convergence condition, which may be reaching a preset number of iterations or reaching a certain convergence value, and is not specifically limited thereto. Then, the current model parameters of the current image recognition classification model are frozen to obtain the trained target image recognition classification model.
[0062] Reference Figure 2As shown, a method for training an image recognition classification model is disclosed. First, a trained high-complexity model M is obtained from a public channel or a self-owned model library as a reference model M. Next, a low-complexity model m is constructed as the image recognition classification model m to be trained, and the model m has a different architecture from the high-complexity model M. Then, a labeled data set D is prepared for training, and this data set can be used in the fields of pedestrian re-identification and face recognition. The data in the data set D is dynamically enhanced, such as data mirroring, rotation, and cropping, to increase the diversity of the data and the generalization ability of the model. The dynamically enhanced data is input into the high-complexity model M and the low-complexity model m at the same time. At this time, the high-complexity model M is in a parameter freezing state, that is, the parameters will not be updated in this process. The feature layer output of the high-complexity model M is used as a supervisory signal to supervise the feature layer output of the low-complexity model m. At the same time, the data label of the high-complexity model M also supervises the final multi-classification head output of the low-complexity model m. The training of the low-complexity model m is supervised by weighting the feature layer supervision model loss function (such as MSE) and the final output data label loss function (such as cross entropy CE) to form a joint loss function, that is, a supervision loss function. Finally, the low-complexity model m is trained for multiple rounds using the dataset D, and the model parameters are continuously adjusted until the loss function of the model m converges, thereby obtaining a highly efficient and high-performance model m. In this way, by utilizing the high-complexity model M's superb ability to extract data features, a strong supervision signal is provided to the feature layer of the low-complexity model m, guiding the low-complexity model m to imitate the feature extraction method of the high-complexity model M, forming a clearer representation of the data features, so that the low-complexity model m has better representation capabilities than simple label supervision training, thereby obtaining better performance on the specified task. Moreover, compared with the traditional distillation method, the present invention adopts feature layer consistency supervision signals and uses supervision signals brought by different architectures rather than label-level supervision signals. The resulting supervision effect is deeper and has a greater impact on the training of low-complexity models. It can perform pedestrian recognition in the images to be recognized in the pedestrian re-identification task or perform face recognition in the images to be recognized in the face recognition task.
[0063] It can be seen that the present invention discloses a training method for an image recognition classification model, comprising: selecting a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters; constructing a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; inputting the target label data training set into the reference model and the image recognition classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervisory features, and using the supervisory features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition classification model to be trained, and constructing a corresponding supervisory loss function; when the function convergence result in the supervisory loss function meets the preset convergence condition, the model training is stopped, and the current image recognition classification model is used as the trained target image recognition classification model. It can be seen that by using a high-complexity reference model as a guide, a low-complexity model to be trained can learn more effective feature representations while maintaining low computing resource requirements, thereby achieving a good balance between performance and efficiency. This enables efficient image recognition tasks to be performed even in resource-constrained environments. After training, low-complexity models can approach the performance of high-complexity models, which not only meets the accuracy requirements of practical applications, but also does not affect the response speed and scalability of the system due to excessively high computational costs. The feature layer output of the reference model is introduced as a supervisory feature to enrich the source of information in the training process. Compared with training that relies solely on data labels, it guides the model to be trained to learn more discriminative and robust features, fully utilizes limited labeled data, and improves data utilization efficiency. At the same time, supervised training is performed on the feature layer output and the multi-classification head output layer of the model to be trained, and the model can be optimized from different levels. The supervision of the feature layer helps the model learn a more appropriate intermediate feature representation, while the supervision of the multi-classification head output layer ensures that the model can accurately perform classification predictions, improving the overall performance of the model.
[0064] Reference Figure 3 As shown, the present invention also discloses a training device for an image recognition classification model, including:
[0065] A model selection module 11 is used to select a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters;
[0066] A model building module 12, used to build a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; wherein the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model;
[0067] The model training module 13 is used to input the target label data training set into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervision features, and use the supervision features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained, and construct a corresponding supervision loss function;
[0068] The training stop module 14 is used to stop model training when the function convergence result in the supervised loss function meets the preset convergence condition, and use the current image recognition classification model as the trained target image recognition classification model.
[0069] It can be seen that the present invention discloses selecting a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters; constructing a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; inputting the target label data training set into the reference model and the image recognition classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervisory features, and using the supervisory features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition classification model to be trained, and constructing a corresponding supervisory loss function; when the function convergence result in the supervisory loss function meets the preset convergence condition, the model training is stopped, and the current image recognition classification model is used as the trained target image recognition classification model. It can be seen that by using a high-complexity reference model as a guide, a low-complexity model to be trained can learn more effective feature representations while maintaining low computing resource requirements, thereby achieving a good balance between performance and efficiency. This enables efficient image recognition tasks to be performed even in resource-constrained environments. After training, low-complexity models can approach the performance of high-complexity models, which not only meets the accuracy requirements of practical applications, but also does not affect the response speed and scalability of the system due to excessively high computational costs. The feature layer output of the reference model is introduced as a supervisory feature to enrich the source of information in the training process. Compared with training that relies solely on data labels, it guides the model to be trained to learn more discriminative and robust features, fully utilizes limited labeled data, and improves data utilization efficiency. At the same time, supervised training is performed on the feature layer output and the multi-classification head output layer of the model to be trained, and the model can be optimized from different levels. The supervision of the feature layer helps the model learn a more appropriate intermediate feature representation, while the supervision of the multi-classification head output layer ensures that the model can accurately perform classification predictions, improving the overall performance of the model.
[0070] Furthermore, the present application also discloses an electronic device. Figure 4This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content in the diagram cannot be regarded as any limitation on the scope of use of the present application.
[0071] Figure 4 A schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the training method of the image recognition classification model disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be an electronic computer.
[0072] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.
[0073] Among them, the processor 21 may include one or more processing cores, such as a 4-core processor, an 8-core processor, etc. The processor 21 can be implemented in at least one hardware form of DSP (Digital Signal Processing), FPGA (Field-Programmable Gate Array), and PLA (Programmable Logic Array). The processor 21 may also include a main processor and a coprocessor. The main processor is a processor for processing data in the awake state, also known as a CPU (Central Processing Unit); the coprocessor is a low-power processor for processing data in the standby state. In some embodiments, the processor 21 may be integrated with a GPU (Graphics Processing Unit), which is responsible for rendering and drawing the content to be displayed on the display screen. In some embodiments, the processor 21 may also include an AI (Artificial Intelligence) processor, which is used to process computing operations related to machine learning.
[0074] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon can include an operating system 221, a computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0075] Among them, the operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the processor 21 on the massive data 223 in the memory 22, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the training method of the image recognition classification model performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks. In addition to data transmitted from an external device received by the electronic device, the data 223 can also include data collected by its own input and output interface 25.
[0076] Furthermore, the present application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, the training method of the image recognition classification model disclosed above is implemented. For the specific steps of the method, reference can be made to the corresponding contents disclosed in the above embodiments, and no further description will be given here.
[0077] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0078] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented with electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application. The steps of the method or algorithm described in conjunction with the embodiments disclosed herein can be implemented directly with hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory RAM (Random Access Memory), memory, read-only memory ROM (Read Only Memory), electrically programmable EPROM (Electrically Programmable Read Only Memory), electrically erasable programmable EEPROM (ElectricErasable Programmable Read Only Memory), register, hard disk, removable disk, CD-ROM (CompactDisc-Read Only Memory), or any other form of storage medium known in the technical field.
[0079] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0080] The scheme provided by the present invention is introduced in detail above. Specific examples are used in this article to illustrate the principle and implementation mode of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation mode and application scope. In summary, the content of this specification should not be understood as limiting the present invention.
Claims
1. A training method for an image recognition classification model, characterized in that: include: Selecting a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters; Constructing a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; wherein the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model; Input the target label data training set into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervision features, and use the supervision features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained, and construct a corresponding supervision loss function; When the function convergence result in the supervised loss function meets the preset convergence condition, the model training is stopped, and the current image recognition classification model is used as the trained target image recognition classification model.
2. The training method of the image recognition classification model according to claim 1, characterized in that: Before inputting the target label data training set into the reference model and the image recognition classification model to be trained respectively, the method further includes: Dynamic data enhancement processing is performed on a label data set used for human feature recognition training according to a preset data enhancement method to obtain a target label data training set; wherein the preset data enhancement method includes any one or more of data mirroring, data rotation, and data cropping.
3. The training method of the image recognition classification model according to claim 1, characterized in that: The target label data training set is respectively input into the reference model and the image recognition and classification model to be trained, so as to use the image features output by the feature layer of the reference model as supervision features, and the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained are supervised by using the supervision features and data labels, and a corresponding supervision loss function is constructed, including: Inputting the target label data training set into the reference model, so as to perform image segmentation and image encoding on the target label data in the target label data training set based on each trained image processing layer by the reference model, and extracting image features from the encoded image by the feature layer of the reference model, so as to use the image features as supervision features; The target label data training set and the supervisory features are input into the image recognition and classification model to be trained, so as to use the supervisory features to perform training supervision on the feature layer output in the model training process of the image recognition and classification model to be trained, and use the data label of the target label data to perform training supervision on the output of the multi-classification head output layer in the model training process of the image recognition and classification model to be trained, and construct a corresponding supervisory loss function.
4. The training method of the image recognition classification model according to claim 1, characterized in that: The construction of the corresponding supervision loss function includes: Acquire the supervisory features of the target label data output by the feature layer of the reference model and the process features of the feature layer output by the image recognition classification model to be trained when the same target label data is used for training; Normalizing the supervisory features and the process features respectively to obtain target supervisory features and target process features in the same scale range; Constructing a feature layer supervision loss function based on the target supervision feature and the target process feature; Obtaining the data label of the target label data and the predicted probability distribution result output by the multi-classification head output layer of the image recognition classification model to be trained when the same target label data is used for training; Constructing a data label supervision loss function based on the data label and the predicted probability distribution result; A corresponding supervision loss function is constructed according to the feature layer supervision loss function and the data label supervision loss function.
5. The training method of the image recognition classification model according to claim 4, characterized in that: The constructing a feature layer supervision loss function based on the target supervision feature and the target process feature includes: Subtract each pair of the target supervision feature and the target process feature, square each difference result and then sum them up to obtain the corresponding feature layer output loss information; A feature layer supervision loss function is constructed according to the feature layer output loss information and the feature dimension output by the reference model.
6. The training method of the image recognition classification model according to claim 4, characterized in that: The constructing of a data label supervision loss function based on the data label and the predicted probability distribution result includes: A predicted probability value corresponding to the data label is determined from the predicted probability distribution result, and a data label supervision loss function is constructed based on the logarithmic information of the predicted probability value and the data label to characterize the degree of difference between the probability distribution predicted by the model and the data label.
7. The training method of the image recognition classification model according to claim 4, characterized in that: The constructing a corresponding supervision loss function according to the feature layer supervision loss function and the data label supervision loss function includes: A corresponding supervised loss function is constructed according to the feature layer supervised loss function, the first loss weight, the data label supervised loss function, and the second loss weight.
8. A training device for an image recognition classification model, characterized in that: include: A model selection module, used to select a first image recognition classification model that has been trained as a reference model; wherein the reference model is an image recognition classification model with frozen model parameters; A model building module, used to build a second image recognition classification model for performing image recognition tasks and having a different architecture from the reference model as the image recognition classification model to be trained; wherein the model complexity of the second image recognition classification model is lower than that of the first image recognition classification model; A model training module, used to input the target label data training set into the reference model and the image recognition and classification model to be trained respectively, so as to use the image features output by the feature layer of the reference model as supervision features, and use the supervision features and data labels to supervise the feature layer output and the multi-classification head output layer of the training process of the image recognition and classification model to be trained, and construct a corresponding supervision loss function; The training stop module is used to stop model training when the function convergence result in the supervised loss function meets the preset convergence condition, and use the current image recognition classification model as the trained target image recognition classification model.
9. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, configured to execute the computer program to implement the steps of the training method for the image recognition classification model as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein, when the computer program is executed by a processor, the steps of the training method of the image recognition classification model as described in any one of claims 1 to 7 are implemented.