A method, apparatus and medium for classifying image data
By constructing a diffusion model generator to replace the original dataset, the dependency on the dataset in model distillation is solved, achieving efficient image classification and model compression, and improving the quality of the generated images.
Patent Information
- Application Number
- CN202211411839.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-11
- Publication Date
- 2025-12-05
- Estimated Expiration
- 2042-11-11
AI Technical Summary
Existing technologies require the original dataset to participate in the model distillation process in image classification, which makes it difficult to implement in real-world scenarios, affecting the model distillation effect and failing to guarantee the image classification effect.
By constructing a diffusion model as an image generator, high-quality image training data is generated to replace the original dataset in the model distillation process. The generated data is then used to train an image classification model, resulting in the distilled target model.
While maintaining the accuracy of model distillation, the model size was effectively compressed, the quality of the generated images was improved, the scale of generated images required for model distillation was reduced, and the image classification effect was guaranteed.
Smart Images

Figure CN115620074B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of model distillation technology, and in particular to a method, apparatus and medium for classifying image data. Background Technology
[0002] With the rapid development and application of artificial intelligence and deep neural network models, deploying AI classification models to edge computing (such as in-vehicle systems and mobile devices) often requires smaller and more efficient models. Therefore, effectively simplifying and compressing models while preserving their performance has become an important issue. Model distillation is a crucial method for compressing classification models. Model distillation refers to the process of training and optimizing an existing pre-trained model (Teacher) and a randomly initialized target small model (Student) using a designed joint loss function, thereby obtaining a target small model (Student) with performance comparable to the existing pre-trained model (Teacher). For example, in image classification scenarios, the original model may be too large to be applied to certain special scenarios, necessitating model distillation.
[0003] However, the standard model distillation training process requires the participation of the original dataset used for training the existing model, which is often difficult to achieve in real-world scenarios due to reasons such as data privacy and the excessive size of the original dataset. Without the participation of the original dataset, the model distillation will result in poor performance, leading to an unsuitable target model and thus failing to guarantee the image classification effect.
[0004] Therefore, ensuring the effectiveness of image classification is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] The purpose of this application is to provide a method, apparatus, and medium for classifying image data to ensure the effectiveness of image classification.
[0006] To address the aforementioned technical problems, this application provides a method for classifying image data, comprising:
[0007] Obtain the image data to be classified;
[0008] The distilled target model is invoked; wherein, obtaining the target model includes: pre-constructing a diffusion model and training an image generator using the original dataset; generating image training data using the image generator; and using the image training data generated by the image generator as parameters to train an image classification model to obtain the distilled target model.
[0009] The distilled target model is used to classify the image data to be classified.
[0010] Preferably, the step of using the image training data generated by the image generator as parameters to train the image classification model to obtain the distilled target model includes:
[0011] The image classification model is trained for a preset number of iterations to obtain the distilled target model.
[0012] Preferably, after using the image training data generated by the image generator as parameters to train the image classification model to obtain the distilled target model, the method further includes:
[0013] The target model obtained by distillation was then validated.
[0014] Preferably, the verification of the target model obtained by distillation includes:
[0015] Obtain the accuracy of the target model;
[0016] Determine whether the accuracy decline of the target model is within an acceptable range;
[0017] If so, the target model is determined to have been successfully distilled.
[0018] Preferably, the image generator obtained by training the pre-built diffusion model using the original dataset includes:
[0019] The pre-built diffusion model is trained using the ImageNet dataset as the training set to obtain the image generator.
[0020] Preferably, obtaining the accuracy of the target model includes:
[0021] The accuracy of the target model is obtained using the ImageNet validation set.
[0022] Preferably, the weights of the target model are initialized with random numbers.
[0023] To address the aforementioned technical problems, this application also provides an image data classification apparatus, comprising:
[0024] The acquisition module is used to acquire the image data to be classified.
[0025] The calling module is used to call the distilled target model; wherein, the acquisition of the target model includes: pre-constructing a diffusion model and training it with the original dataset to obtain an image generator; using the image generator to generate image training data; using the image training data generated by the image generator as parameters to train an image classification model to obtain the distilled target model;
[0026] The classification module is used to classify the image data to be classified using the distilled target model.
[0027] Preferably, the image data classification device further includes: a verification module, used to verify the distilled target model after the image data generated by the image generator is used as parameters to train the image classification model to obtain the distilled target model.
[0028] To address the aforementioned technical problems, this application also provides an image data classification device, comprising: a memory for storing a computer program;
[0029] A processor is used to implement the steps of the image data classification method described above when executing a computer program.
[0030] To address the aforementioned technical problems, this application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the image data classification method described above.
[0031] This application provides an image data classification method that pre-constructs a diffusion model and trains an image generator using the original dataset. Then, the image generator, based on the diffusion model, generates image data, and a model distillation framework is constructed to obtain the image classification model to be distilled. After completing model construction and obtaining the parameters required for training, the image data generated by the image generator is used as parameters to train the image classification model to obtain the distilled target model. After obtaining the target model, it is called to classify the image data to be classified, ensuring the image classification effect. This scheme first constructs and trains a diffusion model as an image generation module based on the original dataset. This module is responsible for generating a high-quality image dataset of the same size as the original training set. Then, during the model distillation training process, these generated data are used to replace the original dataset, realizing the model distillation from Teacher to Student, effectively compressing the model size while maintaining high accuracy, ensuring the normal operation of the model distillation process. Applying the diffusion model to the model distillation mechanism replaces the original dataset required in traditional model distillation, significantly improving the quality of the generated images and further reducing the size of the generated images required for model distillation while maintaining the accuracy of model distillation.
[0032] This application also provides an image data classification device and medium, which correspond to the above method and therefore have the same beneficial effects as the above method. Attached Figure Description
[0033] To more clearly illustrate the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0034] Figure 1 A flowchart illustrating an image data classification method provided in this application embodiment;
[0035] Figure 2 A schematic diagram of an image classification model distillation method based on a diffusion model provided in this application embodiment;
[0036] Figure 3 This is a structural diagram of an image data classification device provided in another embodiment of this application. Detailed Implementation
[0037] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the protection scope of this application.
[0038] The core of this application is to provide a method, apparatus, and medium for classifying image data to ensure the effectiveness of image classification.
[0039] To enable those skilled in the art to better understand the present application, the present application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0040] Model distillation is an important technique for compressing classification models. Model distillation refers to the process of training and optimizing an existing pre-trained model (Teacher) and a randomly initialized target mini-model (Student) using a designed joint loss function, thereby obtaining a target mini-model (Student) with performance comparable to the existing pre-trained model (Teacher). Given a trained model p... T and dataset The goal is to find the weight parameters W of the target small model (i.e., the target model) that satisfy the following formula. S .
[0041]
[0042] Here, KL(·) refers to the Kullback-Leibler divergence (which can be understood as a loss function), p T (·) and pS (·) represent the distribution functions of the outputs of the Teacher and Student models, respectively. The training process of standard model distillation requires the participation of the original dataset used for training existing models, which is often difficult to achieve in real-world scenarios due to reasons such as data privacy and the excessive size of the original dataset. Therefore, how to solve the problem of "the original dataset must be involved" in model distillation has become one of the research focuses in this field, and this application proposes a new solution to this problem.
[0043] Figure 1 A flowchart illustrating an image data classification method provided in this application embodiment; as shown Figure 1 As shown, the image data classification method provided in this embodiment includes the following steps:
[0044] S10: Obtain the image data to be classified.
[0045] S11: Call the distilled target model.
[0046] S12: Use the distilled target model to classify the image data to be classified.
[0047] The acquisition of the target model includes: pre-constructing a diffusion model and training an image generator using the original dataset; generating image training data using the image generator; and using the image training data generated by the image generator as parameters to train an image classification model to obtain the distilled target model. Here, we specifically select the distillation process of a ResNet50 model trained on ImageNet as an example to describe the new method steps provided in this application embodiment, but in actual applications, the steps are not limited to those provided in this embodiment.
[0048] Step 1: Construct a diffusion model for ImageNet, defining its input and output as 224*224 images and any category defined by the ImageNet dataset, where the input image is a noisy image and the output image is the target generated image.
[0049] Step 2: Based on the above description of the diffusion model training process, use the ImageNet dataset as the training set to train the diffusion model defined in Step 1. After training, a high-quality image generator is obtained.
[0050] Step 3: Using an image generator based on a diffusion model, image data is generated to prepare for the model distillation below. Noisy images are initialized, and categories are randomly selected from ImageNet categories and input into the image generator to generate high-quality image samples that are similar to the original ImageNet images.
[0051] Step 4: Repeat step 3 iteratively to obtain a considerable number of generated images, such as 50,000, to form a high-quality generated dataset.
[0052] Step 5: Construct the model distillation framework to obtain the high-accuracy image classification model to be distilled, namely the Teacher model (this model is a pre-trained image classification model trained on the ImageNet dataset, such as the ResNet50 classification model, with a 224*224 image as input and a class number as output), initialize the target model for distillation, namely the Student model (this model should also be a model for ImageNet image classification, with a 224*224 image as input and a class number as output, and the model weights should be initialized with random numbers), construct the joint loss function for model distillation, and initialize the model distillation parameters, such as T.
[0053] Step 6: Use the high-quality generated image dataset obtained in Step 4 as the parameters of the model distillation framework initialized in Step 5, and start training the model distillation.
[0054] Step 7: Repeat step 6 iteratively to complete the training according to the set number of iterations (e.g., epoch=200), and finally obtain the distilled Student model.
[0055] Step 8: Validate the Student model obtained by distillation. Use the ImageNet validation set to obtain the accuracy of the Student model and determine whether the decrease in accuracy is within an acceptable range (e.g., within 3%).
[0056] Figure 2 A schematic diagram of an image classification model distillation method based on a diffusion model provided in this application embodiment; as follows: Figure 2 As shown, the basic idea of this application is to first construct and train a diffusion model as an image generation module based on the original dataset. This module is responsible for generating a high-quality image dataset of the same size as the original training set. Then, during the training process of model distillation, these generated data are used to replace the original dataset, realizing the distillation of the model from Teacher to Student, that is, effectively compressing the model size while retaining high accuracy.
[0057] To address the dependency of traditional image classification models on the original dataset during distillation training, this application proposes a classification model distillation method using a diffusion model as the sample image generator. The generative model built upon the diffusion model provides high-quality sample image generation performance. The generated image sample set can replace the original dataset during model distillation training, enabling model distillation in scenarios without original data and achieving excellent performance. As a cutting-edge generative model, the diffusion model possesses superior image generation quality. The model distillation method incorporating this technology can effectively improve the quality and efficiency of model distillation. Based on this embodiment, the diffusion model can be further analyzed and decomposed, integrating it more efficiently into the model distillation framework.
[0058] This application provides an image data classification method that pre-constructs a diffusion model and trains an image generator using the original dataset. Then, the image generator, based on the diffusion model, generates image data, and a model distillation framework is constructed to obtain an image classification model to be distilled. After completing model construction and obtaining the parameters required for training, the image data generated by the image generator is used as parameters to train the image classification model to obtain the distilled target model. After obtaining the target model, it is used to classify the image data to be classified, ensuring the image classification effect. This scheme first constructs and trains a diffusion model as an image generation module based on the original dataset. This module is responsible for generating a high-quality image dataset of the same size as the original training set. Then, during the model distillation training process, these generated data are used to replace the original dataset, realizing the model distillation from Teacher to Student. That is, while maintaining high accuracy, the model size is effectively compressed, ensuring the normal progress of the model distillation process. By applying the diffusion model to the model distillation mechanism, replacing the original dataset required in traditional model distillation, the quality of the generated images is significantly improved, and the scale of the generated images required for model distillation is further reduced while maintaining the accuracy of model distillation.
[0059] This embodiment explains the diffusion model, a novel model in the field of deep learning image generation. The diffusion model differs from the structures of Generative Adversarial Networks (GANs), Variational Autoencoders (VAEs), and Flow Models, and effectively avoids problems associated with these three generative models, such as training instability, poor diversity, and the design of alternative loss functions.
[0060] Inspired by nonequilibrium thermodynamics, diffusion models first define a Markov chain of diffusion steps, gradually adding random noise to the data, and then learning the reverse diffusion process to construct the desired data sample from the noise. Unlike VAEs or flow models, diffusion models are learned using a fixed procedure, and the latent variables have high dimensionality (the same as the original data).
[0061] The diffusion model first requires defining a forward process, where data points x0 are sampled from the real data distribution following a distribution q(x). As t gradually increases to T, a small amount of Gaussian noise is added to the samples at each step, thus generating a series of noise samples x1, ..., x2. T The diffusion intensity at each step is determined by the variance. The distribution of each layer is controlled to satisfy the following formula:
[0062]
[0063] As the step size t gradually increases, it gradually loses its recognizable features, and eventually, when T approaches infinity, x... T It becomes a general Gaussian distribution (random noise).
[0064] Having constructed the forward diffusion process, the reverse diffusion process is the process from random noise to real image data. Looking at the conditional probability distribution of each step, q(x) t-1 |x t It is generally difficult to estimate because it requires the entire dataset to be obtained; therefore, we need to learn a model p. θ We approximate these conditional probabilities in order to run the backdiffusion process.
[0065] p here θ The joint probability distribution of t from 0 to T is:
[0066]
[0067]
[0068] Where μ θ and ∑ θ Here, the parameterized mean and variance are given. When x0 is a condition, the inverse conditional probability can be easily obtained:
[0069]
[0070] in After simplification through derivation using Bayes' theorem, we obtain:
[0071]
[0072]
[0073] Where, α t =1-β t
[0074] The reasoning process of the diffusion model can be summarized as follows: 1) At each time step, through x t And t to predict Gaussian noise z θ (x t ,t), and then according to the above formula, we get 2) Obtain an approximate variance by... 3) Based on the formula (4) above, we can obtain q(x) t-1 |x t Then we get x t-1 .
[0075] Training process of diffusion model:
[0076] The training process involves finding μ that can represent the training dataset. θ (x t ,t) and ∑ θ (x t Therefore, a reasonable loss function needs to be designed for iterative optimization. By integrating the sum of cross-entropy and multiple KL divergences, and through the approximation and derivation of the variational lower bound method and Jensen's inequality, the target loss function is obtained:
[0077]
[0078] L T =D KL (q(x T |x0)||p θ (x T ))
[0079] L t =D KL (q(x t |x t-1 ,x0)||p θ (x t |x t+1 )); 1≤t≤T-1
[0080] L0 = -log p θ (x0|x1). (8)
[0081] Where L T It can be ignored as a constant, while L t After derivation, it can be simplified to:
[0082]
[0083] Based on the loss function above, the training process of the diffusion model can be viewed as follows: For each training sample image x0, 1) after obtaining the input, randomly sample a t from 1…T; 2) sample a noise from a Gaussian distribution. 3) Minimize:
[0084]
[0085] By constructing and training the diffusion model through the above process, a high-quality image generation model can be obtained.
[0086] As mentioned in the above embodiments, the final distilled target model is obtained by training according to the set number of iterations. Specifically, training the image classification model using the image data generated by the image generator as parameters to obtain the distilled target model includes: training the image classification model for a preset number of iterations to obtain the distilled target model. The specific number of iterations is not limited and can be set to 200. In practical applications, it can also be adjusted according to the distilled model and other parameters.
[0087] Furthermore, after model distillation is complete, it's necessary to verify whether the target model meets the requirements. Therefore, the target model needs to be validated. This involves using the image data generated by the image generator as parameters to train an image classification model to obtain the distilled target model, and then validating the distilled target model. The specific method for validating the distilled target model is not limited; one can obtain the accuracy of the target model and then determine whether the accuracy decrease is within an acceptable range. If so, the target model distillation is considered successful. Specifically, a pre-built diffusion model can be trained using the ImageNet dataset as the training set to obtain the image generator. Then, the accuracy of the target model obtained from the ImageNet validation set can be used to determine whether the accuracy decrease is within an acceptable range (e.g., within 3%).
[0088] Regarding the issue of "the original dataset must be involved" in model distillation, there are currently two approaches: The first approach starts from a pre-trained model and attempts to directly generate high-quality samples to replace the original dataset, thus completing the model distillation process. The advantage of this method is that it can completely deviate from the original dataset, generating data samples and then performing model distillation solely from the pre-trained model. However, its disadvantages are also significant: 1. The generated data samples are essentially adversarial examples, resulting in poor reproduction of the original dataset and low image quality. 2. The Deep Inversion method, which achieves slightly better generation results, has stringent requirements for the pre-trained model, requiring it to be a convolutional neural network model with batch normalization (BN) layers. 3. It requires several times more generated samples than the original dataset to participate in model distillation training. The second approach combines a generative model trained on the original dataset with model distillation. A representative example of this approach is GAN+KD, which uses a generative model (GAN) trained on the original dataset to generate a sample dataset, and then uses the generated dataset to participate in model distillation training. The advantage of this type of method is that the generated model performs much better than the method in the first approach, and the number of generated samples required for model distillation training is relatively small. However, it also has disadvantages: the inherent nature of GAN methods determines their poor generation diversity, and the method's performance on large-size images is not ideal. Based on this approach, this patent proposes a new method that effectively solves these problems.
[0089] The solution provided in this application applies a diffusion model to the model distillation mechanism, replacing the original dataset required in traditional model distillation and the generator based on the GAN model in current methods. Compared to GAN-based model distillation, the image data classification method proposed in this application overcomes the diversity issues in GAN image generators and significantly improves the quality of generated images. While maintaining the accuracy of model distillation, it further reduces the size of the generated images required for model distillation.
[0090] In the above embodiments, the image data classification method has been described in detail. This application also provides embodiments corresponding to the image data classification device. It should be noted that this application describes the embodiments of the device part from two perspectives: one is based on the functional module, and the other is based on the hardware.
[0091] From the perspective of functional modules, this embodiment provides an image data classification device, which includes:
[0092] The acquisition module is used to acquire the image data to be classified.
[0093] The calling module is used to call the distilled target model; the acquisition of the target model includes: pre-building a diffusion model and training an image generator using the original dataset; using the image generator to generate image training data; and using the image training data generated by the image generator as parameters to train an image classification model to obtain the distilled target model.
[0094] The classification module is used to classify the image data to be classified using the distilled target model.
[0095] Since the embodiments of the apparatus and the embodiments of the method correspond to each other, please refer to the description of the embodiments of the method for the embodiments of the apparatus, which will not be repeated here.
[0096] In a preferred embodiment, the image data classification apparatus further includes a verification module for verifying the distilled target model after training an image classification model with image data generated by an image generator as parameters to obtain a distilled target model.
[0097] The image data classification device provided in this embodiment pre-constructs a diffusion model and trains an image generator using the original dataset. Then, it uses the image generator based on the diffusion model to generate image data and constructs a model distillation framework to obtain the image classification model to be distilled. After completing model construction and obtaining the parameters required for training, the image data generated by the image generator is used as parameters to train the image classification model to obtain the distilled target model. After obtaining the target model, it is used to classify the image data to be classified, ensuring the image classification effect. This scheme first constructs and trains a diffusion model as an image generation module based on the original dataset. This module is responsible for generating a high-quality image dataset of the same size as the original training set. Then, during the training process of model distillation, these generated data are used to replace the original dataset, realizing the model distillation from Teacher to Student. That is, while maintaining high accuracy, the model size is effectively compressed, ensuring the normal progress of the model distillation process. By applying the diffusion model to the model distillation mechanism, replacing the original dataset required in traditional model distillation, the quality of the generated images is significantly improved, and the scale of the generated images required for model distillation is further reduced while maintaining the accuracy of model distillation.
[0098] From a hardware perspective, this embodiment provides another image data classification device. Figure 3 A structural diagram of an image data classification device provided in another embodiment of this application is shown below. Figure 3 As shown, the image data classification device includes: a memory 20 for storing computer programs;
[0099] The processor 21 is used to execute a computer program to implement the steps of the image data classification method mentioned in the above embodiments.
[0100] The processor 21 may include one or more processing cores, such as a quad-core processor or an octa-core processor. The processor 21 may be implemented using at least one of the following hardware forms: Digital Signal Processor (DSP), Field-Programmable Gate Array (FPGA), or Programmable Logic Array (PLA). The processor 21 may also include a main processor and a coprocessor. The main processor, also known as the Central Processing Unit (CPU), is used to process data in the wake-up state; the coprocessor is a low-power processor used to process data in the standby state. In some embodiments, the processor 21 may integrate a Graphics Processing Unit (GPU), which is responsible for rendering and drawing the content to be displayed on the screen. In some embodiments, the processor 21 may also include an Artificial Intelligence (AI) processor, which is used to handle computational operations related to machine learning.
[0101] The memory 20 may include one or more computer-readable storage media, which may be non-transitory. The memory 20 may also include high-speed random access memory and non-volatile memory, such as one or more disk storage devices or flash memory devices. In this embodiment, the memory 20 is used to store at least the following computer program 201, which, after being loaded and executed by the processor 21, is capable of implementing the relevant steps of the image data classification method disclosed in any of the foregoing embodiments. In addition, the resources stored in the memory 20 may also include an operating system 202 and data 203, and the storage method may be temporary or permanent storage. The operating system 202 may include Windows, Unix, Linux, etc. The data 203 may include, but is not limited to, data involved in the image data classification method.
[0102] In some embodiments, the image data classification device may further include a display screen 22, an input / output interface 23, a communication interface 24, a power supply 25, and a communication bus 26.
[0103] Those skilled in the art will understand that the structure shown in the figure does not constitute a limitation on the image data classification device and may include more or fewer components than shown.
[0104] The image data classification apparatus provided in this application includes a memory and a processor. When the processor executes the program stored in the memory, it can implement the following method: image data classification method.
[0105] The image data classification device provided in this embodiment pre-constructs a diffusion model and trains an image generator using the original dataset. Then, it uses the image generator based on the diffusion model to generate image data and constructs a model distillation framework to obtain the image classification model to be distilled. After completing model construction and obtaining the parameters required for training, the image data generated by the image generator is used as parameters to train the image classification model to obtain the distilled target model. After obtaining the target model, it is used to classify the image data to be classified, ensuring the image classification effect. This scheme first constructs and trains a diffusion model as an image generation module based on the original dataset. This module is responsible for generating a high-quality image dataset of the same size as the original training set. Then, during the training process of model distillation, these generated data are used to replace the original dataset, realizing the model distillation from Teacher to Student. That is, while maintaining high accuracy, the model size is effectively compressed, ensuring the normal progress of the model distillation process. By applying the diffusion model to the model distillation mechanism, replacing the original dataset required in traditional model distillation, the quality of the generated images is significantly improved, and the scale of the generated images required for model distillation is further reduced while maintaining the accuracy of model distillation.
[0106] Finally, this application also provides an embodiment corresponding to a computer-readable storage medium. The computer-readable storage medium stores a computer program, which, when executed by a processor, implements the steps described in the above method embodiments.
[0107] It is understood that if the methods in the above embodiments are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and executes all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0108] The computer-readable storage medium provided in this embodiment corresponds to the method described above, and therefore has the same beneficial effects as the method described above.
[0109] The foregoing has provided a detailed description of an image data classification method, apparatus, and medium provided in this application. The various embodiments in the specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section. It should be noted that those skilled in the art can make several improvements and modifications to this application without departing from the principles of this application, and these improvements and modifications also fall within the protection scope of the claims of this application.
[0110] It should also be noted that, in this specification, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes the aforementioned element.
Claims
1. A method of classifying image data, characterized by, The method comprises the following steps: obtaining image data to be classified; calling a distilled target model; wherein the obtaining of the target model comprises: obtaining an image generator by training an original data set after a diffusion model is constructed in advance; generating image training data of the same size as the original data set to replace the original data set by using the image generator; constructing a model distillation framework to obtain a Teacher model to be distilled, which is a pre-trained image classification model obtained by training an ImageNet data set; initializing the target model, wherein the weights of the target model are initialized by random numbers, and the model is an image classification model for ImageNet; constructing a joint loss function of model distillation and initializing model distillation parameters; taking the image training data generated by the image generator as the parameters of the model distillation framework to start the training of model distillation; completing the training of the image classification model according to a preset iteration number to realize model distillation in a scene without original data, so as to obtain the distilled target model; wherein after the image training data generated by the image generator is taken as the parameters to train the image classification model to obtain the distilled target model, the method further comprises: obtaining the accuracy of the target model by using an ImageNet validation set; determining whether the accuracy drop range of the target model is within an acceptable range; if yes, it is determined that the target model distillation is successful; using the distilled target model to perform image classification on the image data to be classified.
2. An apparatus for classifying image data, characterized by The method comprises the following steps: an obtaining module is configured to obtain image data to be classified; a calling module is configured to call a distilled target model; wherein the obtaining of the target model comprises: obtaining an image generator by training an original data set after a diffusion model is constructed in advance; generating image training data of the same size as the original data set to replace the original data set by using the image generator; constructing a model distillation framework to obtain a Teacher model to be distilled, which is a pre-trained image classification model obtained by training an ImageNet data set; initializing the target model, wherein the weights of the target model are initialized by random numbers, and the model is an image classification model for ImageNet; constructing a joint loss function of model distillation and initializing model distillation parameters; taking the image training data generated by the image generator as the parameters of the model distillation framework to start the training of model distillation; completing the training of the image classification model according to a preset iteration number to realize model distillation in a scene without original data, so as to obtain the distilled target model; wherein after the image training data generated by the image generator is taken as the parameters to train the image classification model to obtain the distilled target model, the method further comprises: obtaining the accuracy of the target model by using an ImageNet validation set; determining whether the accuracy drop range of the target model is within an acceptable range; if yes, it is determined that the target model distillation is successful; a classification module is configured to use the distilled target model to perform image classification on the image data to be classified.
3. An apparatus for classifying image data, characterized by The computer program is stored in the memory and comprises program elements for implementing the steps of the method when being executed by the processor. The computer program is stored in the memory and comprises program elements for implementing the steps of the method when being executed by the processor.
4. A computer-readable storage medium, characterized in that, The computer program is stored in the memory and comprises program elements for implementing the steps of the method when being executed by the processor.
Citation Information
Patent Citations
Method and system for training a neural network model using adversarial learning and knowledge distillation
WO2022051856A1