Image classification model training method, device and electronic equipment
By using knowledge distillation and data enhancement technology in the image classification model and adjusting the parameters of the target backbone network model, the problem of low image classification efficiency is solved and efficient image classification is achieved.
Patent Information
- Application Number
- CN202210658888.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-09
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2042-06-09
AI Technical Summary
In computer vision tasks based on deep learning, image classification efficiency is low, and it is difficult to effectively improve the efficiency of image classification with existing technology.
By obtaining the target image sample set, input it into the target backbone network model and teacher model respectively, calculate and determine the loss function, adjust the parameters of the target backbone network model based on the loss function, and use knowledge distillation technology and data enhancement methods to optimize the model.
It improves the classification accuracy and efficiency of the image classification model, maintains the high-speed processing speed of the lightweight model, and reduces the cost of sample labeling.
Smart Images

Figure CN114972877B
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to an image classification model training method, device, and electronic device in the field of deep learning and computer vision technology. Background Art
[0002] In computer vision tasks based on deep learning, such as image classification, workers are required to adjust the parameters of the image processing model according to different scenarios and tasks, resulting in low efficiency of image classification; therefore, improving the efficiency of image classification has been a goal pursued in the field of computer vision. Summary of the invention
[0003] The present invention provides an image classification model training method, device and electronic device.
[0004] According to a first aspect of the present disclosure, there is provided an image classification model training method, comprising:
[0005] Obtain a target image sample set;
[0006] Input each image sample in the target image sample set into the target backbone network model and the first teacher model respectively, to obtain a first classification probability output by the target backbone network model and a second classification probability output by the first teacher model;
[0007] determining a loss function based on the first classification probability and the second classification probability;
[0008] Adjusting parameters of the target backbone network model based on the loss function;
[0009] The target backbone network model is used to determine the category of the image input to the target backbone network model, and the initial parameters of the target backbone network model are determined based on the second student model.
[0010] According to a second aspect of the present disclosure, there is provided an image classification model training device, the image classification model training device comprising:
[0011] A sample set acquisition module is used to acquire a target image sample set;
[0012] A classification probability determination module, used to input each image sample in the target image sample set into a target backbone network model and a first teacher model respectively, to obtain a first classification probability output by the target backbone network model and a second classification probability output by the first teacher model;
[0013] A loss function determination module, configured to determine a loss function based on the first classification probability and the second classification probability;
[0014] A model training module, used for adjusting the parameters of the target backbone network model based on the loss function;
[0015] The target backbone network model is used to determine the category of the image input to the target backbone network model, and the initial parameters of the target backbone network model are determined based on the second student model.
[0016] According to a third aspect of the present disclosure, there is provided an electronic device, including:
[0017] at least one processor; and a memory in communication with the at least one processor; wherein,
[0018] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can perform the above-mentioned image classification model training method.
[0019] According to a fourth aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the above-mentioned image classification model training method.
[0020] According to a fifth aspect of the present disclosure, a computer program product is provided, comprising a computer program / instruction, which implements the above-mentioned image classification model training method when executed by a processor.
[0021] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.
[0023] Figure 1 This is a schematic diagram of an optional processing flow of the image classification model training method provided by the embodiment of the present disclosure;
[0024] Figure 2 This is a schematic diagram of an optional processing flow for obtaining a target image sample set provided by an embodiment of the present disclosure;
[0025] Figure 3 is a schematic diagram of an initial image sample provided by an embodiment of the present disclosure;
[0026] Figure 4 is a schematic diagram of an image sample obtained by cropping an initial image sample provided by an embodiment of the present disclosure;
[0027] Figure 5 is a schematic diagram of an image sample obtained by performing image transformation on the cropped image sample provided by an embodiment of the present disclosure;
[0028] Figure 6 is a schematic diagram of an image sample obtained by performing data enhancement on a cropped image sample provided by an embodiment of the present disclosure;
[0029] Figure 7 is a schematic diagram of an image sample obtained by erasing the cropped image sample provided by an embodiment of the present disclosure;
[0030] Figure 8 It is a schematic diagram of an optional detailed processing flow of the image classification model training method provided by the embodiment of the present disclosure;
[0031] Fig. 9 is a schematic diagram of an optional processing flow for training a second student model provided in an embodiment of the present disclosure;
[0032] Fig.10 is a schematic diagram of an optional processing flow for determining a target backbone network model provided by an embodiment of the present disclosure;
[0033] Fig.11 It is a schematic diagram of the overall process of the image classification model training method provided by the embodiment of the present disclosure;
[0034] Fig.12 It is a schematic diagram of the composition structure of the image classification model training device provided by an embodiment of the present disclosure;
[0035] Fig.13 It is a block diagram of an electronic device used to implement the image classification model training method of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0037] In the following description, reference is made to “some embodiments”, which describe a subset of all possible embodiments, but it can be understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0038] In the following description, the terms "first\second\third" involved are merely used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that "first\second\third" can be interchanged with a specific order or sequence where permitted, so that the embodiments of the present disclosure described herein can be implemented in an order other than that illustrated or described herein.
[0039] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which the present disclosure belongs. The terms used herein are only for the purpose of describing the embodiments of the present disclosure and are not intended to limit the present disclosure.
[0040] Before describing the embodiments of the present disclosure in detail, relevant terms involved in the present disclosure are explained.
[0041] 1) Artificial Intelligence (AI): It is the theory, method, technology and application system that uses digital computers or digital computer control to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results. Machine Learning (ML) is the core of artificial intelligence, which specializes in how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance.
[0042] 2) Knowledge distillation is to build a lightweight small model and use the supervision information of the larger model with better performance to train the small model in order to achieve better performance and accuracy. The large model is called the teacher model, and the small model is called the student model. The supervision information output from the teacher model is called knowledge, and the process of the student model learning to transfer the supervision information from the teacher model is called distillation.
[0043] 3) Backbone network, also known as backbone, is used for feature extraction. The backbone network is a convolutional neural network with pre-trained parameters based on large datasets (such as ImageNet|COCO, etc.), such as ResNet-50, Darknet53, etc.
[0044] 4) Loss function: An operational function used to measure the difference between the model's predicted value and the true value. It is a non-negative real-valued function. The smaller the loss function, the better the robustness of the model.
[0045] Figure 1This is an optional processing flow diagram of the image classification model training method provided by the present disclosure. The image classification model training method may at least include the following steps:
[0046] Step S101, obtaining a target image sample set.
[0047] In some optional embodiments, the target image sample set is used to train the target backbone network model, and the target image sample set includes at least one image. Each target image sample in the target image sample set includes an annotated image sample and an unannotated image sample; wherein the annotated image sample is annotated with the image category corresponding to the image sample; for example, the image category corresponding to the image sample is food, or scenery, or building, or person, etc.
[0048] Step S102, input each image sample in the target image sample set into the target backbone network model and the first teacher model respectively, to obtain a first classification probability output by the target backbone network model and a second classification probability output by the first teacher model.
[0049] In some optional embodiments, the image samples input to the target backbone network model are exactly the same as the image samples input to the first teacher model.
[0050] In some optional embodiments, the initial parameters of the target backbone network model are determined based on the second student model, and the second student model is obtained by distillation training based on the second teacher model. In this way, the target backbone network model has excellent classification accuracy for various image classification tasks.
[0051] In some optional embodiments, the target backbone network model can use PP-LCNet as a basic model, which is a lightweight backbone network model optimized for CPU and has strong robustness. Running the target backbone network model on the CPU makes the target backbone network model have higher prediction accuracy and prediction efficiency.
[0052] In some optional embodiments, the first teacher model can be obtained by pre-training a classification neural network model using a labeled sample set.
[0053] Step S103: determining a loss function based on the first classification probability and the second classification probability.
[0054] In some optional embodiments, the loss function may characterize the difference between the first classification probability and the second classification probability.
[0055] Step S104: adjusting the parameters of the target backbone network model based on the loss function.
[0056] In some optional embodiments, the loss function may be back-propagated based on gradient descent to adjust the parameters of the target backbone network model.
[0057] In the specific implementation, for each round of iterative training, it can be determined whether the loss function calculated in the round of iterative training is minimized. If the loss function is minimized, it indicates that the target backbone network model has converged and the training of the target backbone network model is completed. If the loss function is not minimized, it indicates that the target backbone network model has not yet converged. The loss function can be back-propagated based on gradient descent, and the parameters of the target backbone network model can be adjusted to perform the next round of iterative training. It should be noted that the more rounds of iterative training, the higher the accuracy of the trained target backbone network model for image classification.
[0058] In some optional embodiments, the trained target backbone network model is capable of classifying images input to the target backbone network model to determine the category of the image.
[0059] The following are Figure 1 Each step in the image classification model training method shown is described in detail.
[0060] For step S101, an optional processing flow for obtaining a target image sample set is as follows: Figure 2 As shown, at least the following steps may be included:
[0061] Step S201, obtaining an initial image sample set.
[0062] In some embodiments, the initial image sample set may adopt an existing image set, such as the ImageNet-1k image dataset, or may be an image set collected from existing images and including a certain number of images. The initial image sample set includes at least one image. Each initial image sample in the initial image sample set includes annotated image samples and unannotated image samples; wherein the annotated image samples are annotated with the image category corresponding to the image sample; for example, the image category corresponding to the image sample is food, or scenery, or building, or person, etc.
[0063] Step S202: performing data enhancement processing on each initial image sample in the initial image sample set to obtain a candidate image sample set.
[0064] In some optional embodiments, performing data enhancement processing on each initial image sample in the initial image sample set may include: performing at least one of the following processing on each initial image sample in the initial image sample set: image transformation, image cropping, image erasing and image aliasing.
[0065] In some optional embodiments, for example Figure 3The initial image sample shown in FIG. 1 can be subjected to image cropping (RandomCrop) to obtain the following Figure 4 The image sample shown. Figure 4 The image sample shown is transformed (RandomFlip) to obtain Figure 5 The image sample shown in FIG. 1 is a graph showing an image sample; wherein image transformation can also be called image flipping. Figure 4 The image samples shown in the figure are subjected to data augmentation (AutoAugment) to obtain the following Figure 6 The image sample shown. You can also Figure 4 The image sample shown is erased to obtain Figure 7 The image sample shown. In the specific implementation, for Figure 4 The probability of image transformation or data enhancement of the image shown can be flexibly set according to the actual application scenario. The above only takes the three combined processing methods of image cropping and image transformation, image cropping and data enhancement, and image cropping and image erasing as examples for the initial image sample; in specific implementation, the initial image sample can be processed by any one or a combination of image cropping, image transformation, image erasing and image aliasing. Among them, image aliasing is the partial overlap of two or more images according to the upper and lower relationship.
[0066] Step S203: determining an image sample set consisting of the initial image sample set and the candidate image sample set as the target image sample set.
[0067] In some optional embodiments, the target image sample set includes an initial image sample set and a candidate image sample set.
[0068] In the disclosed embodiment, by performing data enhancement processing on image samples in the initial image sample set, the robustness of the target backbone network model can be increased.
[0069] For step S102, each image sample in the target image sample set is input into the target backbone network model and the first teacher model respectively to obtain the first classification probability and the second classification probability output by the target backbone network model and the first teacher model for the same image sample.
[0070] In some optional embodiments, the first teacher model and the target backbone network model correspond to the teacher model and the student model in the knowledge distillation technology, respectively.
[0071] For step S103, in some optional embodiments, the loss function may be a cross entropy loss function, or a perceptual loss function, or any other type of loss function, the learning rate adopted may be a cosine descent strategy, and the optimizer adopted may be a momentum gradient descent optimizer.
[0072] Since the target backbone network model is a lightweight model, although the lightweight model has the advantage of fast data processing speed, the number of parameters and the amount of calculation of the lightweight model are far less than those of the large model. Through the knowledge distillation scheme adopted in steps S102 to S104, the lightweight model has similar accuracy to the large model while maintaining a high processing speed.
[0073] An optional detailed processing flow diagram of the image classification model training method provided in the present disclosure is as follows: Figure 8 As shown, at least the following steps may be included:
[0074] Step S301, training the second student model.
[0075] In some optional embodiments, an optional process flow for training the second student model is as follows: Fig. 9 As shown, at least the following steps may be included:
[0076] Step S301a: obtaining a first image sample set.
[0077] In some embodiments, the first image sample set may adopt an existing image set, such as the ImageNet-1k image dataset, or may be an image set collected from existing images and including a certain number of images.
[0078] Step S301b: input each image in the first image sample set into the second teacher model respectively to obtain the image category distribution probability output by the second teacher model.
[0079] In some optional embodiments, the second teacher model can be obtained by pre-training a classification neural network model using a labeled sample set; therefore, the second teacher model has the performance of determining the image category distribution probability of the image input to the second teacher model.
[0080] In some embodiments, multiple image categories may be included, and for an image input to the second teacher model, the second teacher model can output an image category distribution probability, which can represent the probability that the image belongs to each image category.
[0081] Step S301c: use each image in the first image sample set as the input of the second student model, use the image category distribution probability as the output of the second student model, and train the second student model.
[0082] In some optional embodiments, the second student model can be any neural network model used for classification; the second student model can be a pre-trained neural network model or an untrained, initial neural network model. Compared with the second teacher model, the second student model has lower model complexity and is more concise.
[0083] In the disclosed embodiment, the image category distribution probability output by the second teacher model is used as the label of the corresponding image. There is no need to pay attention to the actual label of the image, and supervised training is performed on the second student model. This makes the process of training the second student model independent of labeled samples, and can make full use of unlabeled samples to improve the accuracy of the second student model and reduce the sample labeling cost in image classification.
[0084] In the disclosed embodiment, since the image category distribution probability may also include information about the relationship between different categories, using the category distribution probability instead of the true label of the image can improve the accuracy of training the second student model.
[0085] Step S302, determining the target backbone network model.
[0086] In some optional embodiments, an optional process flow for determining a target backbone network model is as follows: Fig.10 As shown, at least the following steps may be included:
[0087] Step S302a, obtaining a second image sample set, a predicted image sample set, and an initial backbone network model set.
[0088] In some optional embodiments, the second image sample set is used to train the initial backbone network model in the initial backbone network model set, and the second image set includes at least one image. The second image sample set can adopt an existing image set, such as the ImageNet-1k image data set, or it can be an image set collected from existing images and including a certain number of images, which is not specifically limited in this embodiment. The prediction image sample set includes at least one image, and the trained backbone network model can predict the images in the prediction image sample set. And the initial backbone network model set includes at least one initial backbone network model, and the initial backbone network model can be an existing backbone network model, or it can be a backbone network model obtained through training, which is not specifically limited in this embodiment.
[0089] Step S302b, for each initial backbone network model in the initial backbone network model set, use the second image sample set and the predicted image sample set to train the initial backbone network model and perform image classification prediction, and obtain the prediction time and prediction accuracy of the trained initial backbone network model in the image classification prediction process.
[0090] In some embodiments, the initial backbone network model is trained using the second image sample set to obtain a trained backbone network model; and then the trained backbone model is used to predict the images in the prediction image sample set, thereby obtaining the prediction time and prediction accuracy of the trained backbone network model in the prediction process. Since the prediction image sample set may include at least one image, when the prediction image sample set contains only one image, the time used to predict the above image using the trained backbone network model and the accuracy of the prediction result are used as the prediction time and prediction accuracy of the trained backbone network model in the prediction process; and when the prediction image sample set contains multiple images, the prediction time and the accuracy of the prediction result used to predict each of the above images using the trained backbone network model are recorded, and then the prediction time of all images and the prediction accuracy of all images are averaged, and the result is used as the prediction time and prediction accuracy of the trained backbone network model in the prediction process.
[0091] Step S302c, determining a basic backbone network model based on the prediction time and prediction accuracy of each trained initial backbone network model in the image classification prediction process.
[0092] In some optional embodiments, the basic backbone network model is a backbone network model with low prediction time and high prediction accuracy among the above-mentioned trained backbone network models, that is, the backbone network model with the best effect in the initial backbone network model set.
[0093] In some optional embodiments, the backbone network model with smaller prediction time and higher prediction accuracy is better; or when the prediction time is the same, the backbone network model with higher prediction accuracy is better; or when the prediction accuracy is the same, the backbone network model with smaller prediction time is better; and when the prediction time and prediction accuracy of different backbone network models are different, the basic backbone network model can be determined based on the proportional relationship between the prediction time and the prediction accuracy.
[0094] Step S302d: determining a target backbone network model based on the basic backbone network model.
[0095] In some optional embodiments, when determining the target backbone network model, the target network model may be first obtained; wherein the target network model may be a pre-built network model that can further improve the prediction accuracy of the basic backbone network model but hardly affect the prediction time consumption of the basic backbone network model, and the target network model may include at least one of the following: an activation function and a fully connected layer. Then, the target network model is added to the basic backbone network model to obtain the target backbone network model.
[0096] Step S303, determining the target backbone network model based on the parameters of the second student model.
[0097] In some embodiments, the parameters of the second student model are used as initial parameters of the target backbone network model.
[0098] Step S304, obtaining a target image sample set.
[0099] Step S305, input each image sample in the target image sample set into the target backbone network model and the first teacher model respectively, to obtain the first classification probability output by the target backbone network model and the second classification probability output by the first teacher model.
[0100] Step S306: determine a loss function based on the first classification probability and the second classification probability.
[0101] Step S307: adjusting the parameters of the target backbone network model based on the loss function.
[0102] It should be noted that the specific processing procedures of step S304 to step S307 may be the same as the specific processing procedures of step S101 to step S104, and will not be repeated here.
[0103] Step S308, for the first hyperparameter in the target backbone network model, traverse the hyperparameter values corresponding to the first hyperparameter, and determine the optimal target backbone network model among the target backbone network models corresponding to all the hyperparameter values.
[0104] In some optional embodiments, the first hyperparameter may be any hyperparameter in the target backbone network model. For each hyperparameter, there may be multiple hyperparameter values corresponding to the hyperparameter; all hyperparameter values corresponding to the hyperparameter are traversed, and the optimal target backbone network model among the target backbone network models corresponding to all hyperparameter values is selected.
[0105] In some optional embodiments, the first hyperparameter may include at least one of the following: learning rate (LearningRate), input resolution of the image (Input Resolution), staged learning rate multiplier (Stagelrmult), random erasure probability (RE ratio), random data enhancement probability (RA ratio) and first teacher model (Distillteacher) selection. Among them, the learning rate is a parameter in the training process of the target backbone network model, which is used to control the speed of iteration of the target backbone network model. The input resolution is used to control the size of the input image, such as processing the initial image according to the input resolution to obtain an image that meets the input resolution. The staged learning rate multiplier is a coefficient used to multiply the learning rate in each stage within the target backbone network model. The random erasure probability represents the probability of randomly selecting an area on an image for erasure. The selection of the teacher model is a parameter used to select the best teacher model from multiple teacher models.
[0106] In the disclosed embodiment, by traversing the hyperparameter values corresponding to some hyperparameters, the search for these hyperparameters is implemented, which reduces the dependence on the search of all hyperparameters and reduces the amount of calculation; by searching some hyperparameters, the training accuracy of the target backbone network model can be guaranteed.
[0107] Step S309: Determine that the hyperparameter value corresponding to the optimal target backbone network model is the hyperparameter value corresponding to the first hyperparameter.
[0108] As an example, the first hyperparameter is the learning rate, and the learning rate has N learning rate values; the first learning rate value to the Nth learning rate value correspond to a target backbone network model respectively, and the optimal target backbone network model among the N target backbone network models is determined. The learning rate value corresponding to the optimal target backbone network model is used as the value of the learning rate.
[0109] Above Figures 1 to 10 The overall flow chart of the image classification model training method can be shown as follows: Fig.11As shown, the initial sample set is processed to obtain a target image sample set; the image samples in the target image sample set can be annotated images. The knowledge distillation technology is used to train the second student model based on the knowledge learning of the second teacher model, and the parameters of the second student model are used as the initial parameters of the target backbone network model; the loss function between the first classification probability and the second classification probability output by the pre-trained first teacher model and the target backbone network model for the same input image is calculated, and the target backbone network model is adjusted based on the loss function to achieve the training of the target backbone network model. After the target backbone network model is trained, the hyperparameter values corresponding to each hyperparameter are traversed based on the greedy algorithm, and the hyperparameters of the target backbone network model are updated to obtain the target backbone network model for classifying images.
[0110] based on Figures 1 to 11 The image classification model training method shown in the figure, the embodiment of the present disclosure also provides an image classification method, the image classification model used in the image classification method is based on Figures 1 to 11 The image classification model shown in is trained. In the specific implementation, the image to be classified is input based on Figures 1 to 11 The target backbone network model (also referred to as an image classification model) trained by the image classification model training method shown, the target backbone network model outputs the classification probability of the image to be classified in multiple image categories.
[0111] The present disclosure also provides a graph classification model training device, the composition structure of the graph classification model training device is as follows: Fig.12 As shown, including:
[0112] The sample set acquisition module 401 is used to acquire a target image sample set;
[0113] A classification probability determination module 402 is used to input each image sample in the target image sample set into a target backbone network model and a first teacher model respectively, to obtain a first classification probability output by the target backbone network model and a second classification probability output by the first teacher model;
[0114] A loss function determination module 403, configured to determine a loss function based on the first classification probability and the second classification probability;
[0115] A model training module 404, used to adjust the parameters of the target backbone network model based on the loss function;
[0116] The target backbone network model is used to determine the category of the image input to the target backbone network model, and the initial parameters of the target backbone network model are determined based on the second student model. In some optional embodiments, the sample set acquisition module 401 is used to acquire an initial image sample set;
[0117] Performing data enhancement processing on each initial image sample in the initial image sample set to obtain a candidate image sample set;
[0118] An image sample set consisting of the initial image sample set and the candidate image sample set is determined as the target image sample set.
[0119] In some optional embodiments, the sample set acquisition module 401 is configured to perform at least one of the following processing on each initial image sample in the initial image sample set: image transformation, image cropping, and image erasing.
[0120] In some optional embodiments, the model training module 404 is further used to obtain a first image sample set;
[0121] Inputting each image in the first image sample set into a second teacher model respectively to obtain the image category distribution probability output by the second teacher model;
[0122] The second student model is trained by using each image in the first image sample set as an input of the second student model and using the image category distribution probability as an output of the second student model.
[0123] In some optional embodiments, the model training module 404 is further used to determine the parameters of the trained second student model as the initial parameters of the target backbone network model.
[0124] In some optional embodiments, the model training module 404 is further used to traverse the hyperparameter values corresponding to the first hyperparameter in the target backbone network model, and determine the optimal target backbone network model among the target backbone network models corresponding to all the hyperparameter values;
[0125] Determine that the hyperparameter value corresponding to the optimal target backbone network model is the hyperparameter value corresponding to the first hyperparameter.
[0126] In some optional embodiments, the first hyperparameter includes at least one of the following:
[0127] learning rate, input resolution of images, stage-by-stage learning rate multiplier, random erasure probability, random data augmentation probability, and first teacher model selection.
[0128] In some optional embodiments, the model training module 404 is used to obtain a second image sample set, a predicted image sample set, and an initial backbone network model set;
[0129] For each initial backbone network model in the initial backbone network model set, the initial backbone network model is trained and image classification prediction is performed using the second image sample set and the predicted image sample set to obtain prediction time and prediction accuracy of the trained initial backbone network model in the image classification prediction process;
[0130] Determine the basic backbone network model based on the prediction time and prediction accuracy of each trained initial backbone network model in the image classification prediction process;
[0131] A target backbone network model is determined based on the basic backbone network model.
[0132] In some optional embodiments, the model training module 404 is used to obtain a target network model, wherein the target network model includes at least one of the following: an activation function and a fully connected layer;
[0133] The target network model is added to the basic backbone network model to obtain the target backbone network model.
[0134] It should be noted that the acquisition, storage and application of user personal information involved in the technical solution of the present disclosure are in compliance with the provisions of relevant laws and regulations and do not violate public order and good morals.
[0135] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.
[0136] Fig.13 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. In some optional embodiments, the electronic device 800 can be a terminal device or a server. In some optional embodiments, the electronic device 800 can implement the image classification model training method provided in the embodiment of the present application by running a computer program. For example, the computer program can be a native program or software module in the operating system; it can be a native application (Application, APP), that is, a program that needs to be installed in the operating system to run; it can also be a small program, that is, a program that can be run only by downloading it to a browser environment; it can also be a small program that can be embedded in any APP. In short, the above-mentioned computer program can be an application, module or plug-in in any form.
[0137] In practical applications, the electronic device 800 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms, where cloud technology refers to a hosting technology that unifies hardware, software, network and other resources in a wide area network or local area network to achieve data computing, storage, processing and sharing. The electronic device 800 can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a smart speaker, a smart TV, a smart watch, etc., but is not limited thereto.
[0138] Electronic devices are intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. Electronic devices may also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, vehicle-mounted terminals, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.
[0139] like Fig.13 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.
[0140] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the electronic device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0141] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the image classification model training method. For example, in some optional embodiments, the image classification model training method may be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as a storage unit 808. In some optional embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the image classification model training method described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured as an image classification model training method in any other appropriate manner (e.g., by means of firmware).
[0142] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0143] The program code for implementing the image classification model training method disclosed herein can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code can be executed entirely on the machine, partially on the machine, partially on the machine as a stand-alone software package and partially on a remote machine, or entirely on a remote machine or server.
[0144] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0145] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0146] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.
[0147] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship with each other. The server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0148] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.
[0149] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A method for training an image classification model, include: Acquire a first image sample set; Inputting each image in the first image sample set into a second teacher model respectively to obtain the image category distribution probability output by the second teacher model; Using each image in the first image sample set as an input of the second student model, using the image category distribution probability as an output of the second student model, and training the second student model; Obtain a target image sample set; Input each image sample in the target image sample set into the target backbone network model and the first teacher model respectively, to obtain a first classification probability output by the target backbone network model and a second classification probability output by the first teacher model; determining a loss function based on the first classification probability and the second classification probability; Adjusting parameters of the target backbone network model based on the loss function; Among them, the target backbone network model is used to determine the category of the image input to the target backbone network model, the initial parameters of the target backbone network model are determined based on the second student model, and the target backbone network model is a lightweight backbone network model using PP-LCNet as the basic model.
2. The method according to claim 1, in, The acquiring of the target image sample set comprises: Obtain an initial image sample set; Performing data enhancement processing on each initial image sample in the initial image sample set to obtain a candidate image sample set; An image sample set consisting of the initial image sample set and the candidate image sample set is determined as the target image sample set.
3. The method according to claim 2, in, The performing data enhancement processing on each initial image sample in the initial image sample set includes: Perform at least one of the following processing on each initial image sample in the initial image sample set: Image transformation, image cropping, and image erasing.
4. The method according to claim 1, in, The method further comprises: Determine the parameters of the second student model that has completed training as the initial parameters of the target backbone network model.
5. The method according to claim 1, in, The method further comprises: For a first hyperparameter in the target backbone network model, traverse the hyperparameter values corresponding to the first hyperparameter, and determine the optimal target backbone network model among the target backbone network models corresponding to all the hyperparameter values; Determine that the hyperparameter value corresponding to the optimal target backbone network model is the hyperparameter value corresponding to the first hyperparameter.
6. The method according to claim 5, in, The first hyperparameter includes at least one of the following: learning rate, input resolution of images, stage-by-stage learning rate multiplier, random erasure probability, random data augmentation probability, and first teacher model selection.
7. The method according to claim 1, in, The method further comprises: Obtaining a second image sample set, a predicted image sample set, and an initial backbone network model set; For each initial backbone network model in the initial backbone network model set, the initial backbone network model is trained and image classification prediction is performed using the second image sample set and the predicted image sample set to obtain prediction time and prediction accuracy of the trained initial backbone network model in the image classification prediction process; Determine the basic backbone network model based on the prediction time and prediction accuracy of each trained initial backbone network model in the image classification prediction process; A target backbone network model is determined based on the basic backbone network model.
8. The method according to claim 7, in, The determining of the target backbone network model based on the basic backbone network model includes: Acquire a target network model, wherein the target network model includes at least one of the following: an activation function and a fully connected layer; The target network model is added to the basic backbone network model to obtain the target backbone network model.
9. An image classification model training device, the image classification model training device include: A model training module, used for acquiring a first image sample set; Input each image in the first image sample set into a second teacher model respectively, and obtain the image category distribution probability output by the second teacher model; use each image in the first image sample set as the input of the second student model, use the image category distribution probability as the output of the second student model, and train the second student model; A sample set acquisition module is used to acquire a target image sample set; A classification probability determination module, used to input each image sample in the target image sample set into a target backbone network model and a first teacher model respectively, to obtain a first classification probability output by the target backbone network model and a second classification probability output by the first teacher model; A loss function determination module, configured to determine a loss function based on the first classification probability and the second classification probability; The model training module is further used to adjust the parameters of the target backbone network model based on the loss function; Among them, the target backbone network model is used to determine the category of the image input to the target backbone network model, the initial parameters of the target backbone network model are determined based on the second student model, and the target backbone network model is a lightweight backbone network model using PP-LCNet as the basic model.
10. An electronic device, include: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 8.
11. A non-transitory computer-readable storage medium storing computer instructions, in, The computer instructions are used to cause the computer to execute the method according to any one of claims 1 to 8.
12. A computer program product, comprising a computer program / instructions, which implement the method according to any one of claims 1 to 8 when executed by a processor.
