WO2021013095A1 - Image classification method and apparatus, and method and apparatus for training image classification model - Google Patents
Image classification method and apparatus, and method and apparatus for training image classification model Download PDFInfo
- Publication number
- WO2021013095A1 WO2021013095A1 PCT/CN2020/102741 CN2020102741W WO2021013095A1 WO 2021013095 A1 WO2021013095 A1 WO 2021013095A1 CN 2020102741 W CN2020102741 W CN 2020102741W WO 2021013095 A1 WO2021013095 A1 WO 2021013095A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- training
- image
- category
- images
- feature
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Ceased
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F18/00—Pattern recognition
- G06F18/20—Analysing
- G06F18/24—Classification techniques
- G06F18/241—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches
- G06F18/2413—Classification techniques relating to the classification model, e.g. parametric or non-parametric approaches based on distances to training or reference patterns
- G06F18/24147—Distances to closest patterns, e.g. nearest neighbour classification
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/0464—Convolutional networks [CNN, ConvNet]
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
- G06N3/09—Supervised learning
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/77—Processing image or video features in feature spaces; using data integration or data reduction, e.g. principal component analysis [PCA] or independent component analysis [ICA] or self-organising maps [SOM]; Blind source separation
- G06V10/774—Generating sets of training patterns; Bootstrap methods, e.g. bagging or boosting
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06V—IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING
- G06V10/00—Arrangements for image or video recognition or understanding
- G06V10/70—Arrangements for image or video recognition or understanding using pattern recognition or machine learning
- G06V10/82—Arrangements for image or video recognition or understanding using pattern recognition or machine learning using neural networks
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/044—Recurrent networks, e.g. Hopfield networks
Definitions
- This application relates to the field of artificial intelligence, and more specifically, to image classification methods, image classification model training methods and devices.
- Computer vision is an inseparable part of various intelligent/autonomous systems in various application fields, such as manufacturing, inspection, document analysis, medical diagnosis, and military. It is about how to use cameras/video cameras and computers to obtain What we need is the knowledge of the data and information of the subject. Vividly speaking, it is to install eyes (camera/camcorder) and brain (algorithm) on the computer to replace the human eye to identify, track and measure the target, so that the computer can perceive the environment. Because perception can be seen as extracting information from sensory signals, computer vision can also be seen as a science that studies how to make artificial systems "perceive" from images or multi-dimensional data.
- computer vision is to use various imaging systems to replace the visual organs to obtain input information, and then the computer replaces the brain to complete the processing and interpretation of the input information.
- the ultimate research goal of computer vision is to enable computers to observe and understand the world through vision like humans, and have the ability to adapt to the environment autonomously.
- This application provides an image classification method, an image classification model training method and a device thereof, which can better classify images.
- an image classification method comprising: obtaining an image to be processed; and classifying the image to be processed according to preset global category characteristics to obtain a classification result of the image to be processed, wherein,
- the global category features include multiple category features trained according to multiple training images in the training set, and multiple category features in the global category features are used to indicate visual features of all categories in the training set. All categories in the set are categories to which all training images in the training set belong, and the training set includes images in the base class and images in the new class.
- the above-mentioned base class can be understood as a large-scale training image set.
- the above-mentioned base class usually includes a large number of annotated images used for model training.
- the images in the base class can be annotated images.
- annotated images can refer to those that have been annotated with the category of the image. image.
- the aforementioned new class usually includes a small number of labeled samples, and the images in the new class may also be labeled images. That is to say, in this embodiment of the present application, the new class is a small sample, that is, the new class includes a small number of images that have been labeled with the category.
- the base category includes 100 categories, each category includes 1000 training images, the new category includes 5 categories, and each category includes 5 training images.
- the global category features are obtained by training multiple training images in the training set.
- the global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set.
- the global The training set used in the category training process includes the images in the base category and the images in the new category, which can prevent the global category features from being overfitted to the images in the base category, so that images in the new category can be identified more accurately.
- the image classification model in this application may be trained based on a multi-stage training (episodic training) strategy.
- the model training process can be divided into multiple training stages (training episodes). In each training stage, several categories in the training set can be randomly selected to train the model. Finally, after multiple training stages, the model is completed training.
- the global category features can be updated, so that the global category features obtained by training can have better consistency.
- the training set includes the base class
- the images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
- the classifying the to-be-processed image according to preset global category features to obtain the classification result of the to-be-processed image includes: extracting the The feature vector of the image to be processed; according to the feature vector of the image to be processed, the confidence that the image to be processed belongs to a candidate category is determined, the candidate category being one or more of the multiple categories indicated by the global category feature A; According to the confidence, the classification result of the image to be processed is determined from the candidate category.
- the method before the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed, the method further includes: The support set of the image to be processed determines the local category feature of the image to be processed; the candidate category is determined according to the local category feature of the image to be processed and the global category feature; wherein, the image to be processed The support set of includes multiple images, and the category to which the multiple images belong is one or more of the multiple categories indicated by the global category feature.
- the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed includes: Feature vector, determining the distance between the feature vector of the image to be processed and the feature vector corresponding to each of the candidate categories; determining the confidence that the image to be processed belongs to the candidate category according to the distance .
- the determining the classification result of the image to be processed from the candidate category according to the confidence level includes: The category with the greatest confidence is determined as the classification result of the image to be processed.
- the global category feature is obtained by training based on a classification error, and the classification error is based on the classification result of the training image in the query set and the query set
- the training image is determined by a pre-labeled label, the label is used to indicate the category to which the training image belongs, and the query set includes part of the training images in the partial categories in the training set.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
- the classification error of the current training stage can be used to update the global category features.
- the training set includes images in the base class and images in the new class.
- the effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can avoid the overfitting of the trained image classification model to the base class.
- the image to be processed can be classified, which can get better The result of image classification.
- the global category feature is obtained by training based on classification error and registration error, and the classification error is based on the classification result and the result of the training image in the query set.
- the pre-labeled training image in the question set is determined, the label is used to indicate the category to which the training image belongs, the question set includes some training images in some categories in the training set, and the configuration
- the quasi-error is determined based on the local category feature of the training image and multiple category features in the global category feature.
- the local category feature of the training image includes multiple category features determined from multiple training images in the support set.
- the multiple category features in the local category features of the training image are used to indicate the visual features of all categories in the support set, and the support set includes part of the training images in the partial categories in the training set.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
- the classification error and registration error of the current training stage can be used to update the global category features.
- the training set includes the images in the base category and the new category.
- the effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can prevent the image classification model obtained by training from overfitting to the base class, and classify the image to be processed according to the image classification model. Can get better image classification results.
- the local category feature of the training image is determined by multiple training images in the support set that have undergone expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
- the multiple training images in the above support set are images in the new class.
- multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided
- the model is overfitted to the base class, and the image to be processed is classified according to the image classification model, which can obtain better image classification results.
- a method for training an image classification model includes: acquiring a plurality of training images in a training set, wherein the training set includes a support set and a training set, and the plurality of training images includes the Support multiple training images in the set and multiple training images in the query set; according to the preset first neural network, extract feature vectors of the multiple training images in the query set, and the query set includes all Part of the images in the partial categories in the training set; according to the preset second neural network and preset global category features, the feature vectors of the multiple training images in the query set are processed to obtain the query set
- the training set includes images in the base class and images in the new class; according to the classification results of multiple training images in the query set, update
- the above-mentioned base class can be understood as a large-scale training image set.
- the above-mentioned base class usually includes a large number of annotated images used for model training.
- the images in the base class can be annotated images.
- annotated images can refer to those that have been annotated with the category of the image. image.
- the aforementioned new class usually includes a small number of labeled samples, and the images in the new class may also be labeled images. That is to say, in this embodiment of the present application, the new class is a small sample, that is, the new class includes a small number of images that have been labeled with the category.
- the base category includes 100 categories, each category includes 1000 training images, the new category includes 5 categories, and each category includes 5 training images.
- the global category features are trained from the classification results of the training images in the training set, and the global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set.
- the training set used in the global category training process includes images in the base category and images in the new category, which can prevent the global category features from being overfitted to the images in the base category, so that images in the new category can be identified more accurately.
- the training method of the image classification model in this application can train the model based on a multi-stage training (episodic training) strategy.
- the model training process can be divided into multiple training stages (training episodes). In each training stage, several categories in the training set can be randomly selected to train the model. Finally, after multiple training stages, the model is completed training.
- the global category features can be updated, so that the global category features obtained by training can have better consistency.
- the training set includes the base class
- the images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
- feature vectors of multiple training images in the support set and feature vectors of multiple training images in the query set may be extracted.
- the feature vectors of multiple training images in the query set are processed according to a preset second neural network and preset global category features .
- Obtaining classification results of the multiple training images in the query set includes: extracting feature vectors of the multiple training images in the support set, the support set including part of the training images in the partial categories in the training set; Determine the local category features of the training images according to the feature vectors of the multiple training images in the support set, where multiple category features in the local category features of the training images are used to indicate visual features of all categories in the support set,
- the support set includes part of the training images in the partial categories in the training set; according to the second neural network, the local category feature of the training image, and the global category feature, determine a plurality of the query set The classification result of the training image.
- the updating the global category feature according to the classification results of the multiple training images in the query set includes: Update the global category feature, the first neural network and the second neural network for the classification results of the training images.
- the updating the global category feature according to the classification results of the multiple training images in the query set includes: updating the global The category feature, the classification error is determined based on the classification results of the multiple training images in the query set and the pre-labeled tags of the multiple training images in the query set, and the tags are used to indicate the training images The category it belongs to.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
- the classification error of the current training stage can be used to update the global category features.
- the training set includes images in the base class and images in the new class.
- the effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can avoid the overfitting of the trained image classification model to the base class.
- the image to be processed can be classified, which can get better The result of image classification.
- the updating the global category feature according to the classification results of the multiple training images includes: updating all the features according to the classification error and the registration error The global category feature, wherein the registration error is determined according to a local category feature of the training image and multiple category features in the global category feature.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
- the classification error and registration error of the current training stage can be used to update the global category features.
- the training set includes the images in the base category and the new category.
- the effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can prevent the image classification model obtained by training from overfitting to the base class, and classify the image to be processed according to the image classification model. Can get better image classification results.
- the local category feature of the training image is determined by a plurality of training images in the support set after expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
- the multiple training images in the above support set are images in the new class.
- multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided
- the model is overfitted to the base class, and the image to be processed is classified according to the image classification model, which can obtain better image classification results.
- an image classification device including: an acquisition module for acquiring an image to be processed; a classification module for classifying the image to be processed according to preset global category features to obtain the image to be processed Process the classification result of the image, wherein the global category feature includes multiple category features trained according to multiple training images in the training set, and the multiple category features in the global category feature are used to indicate all the categories in the training set.
- Visual features of the category all categories in the training set are categories to which all training images in the training set belong, and the training set includes images in the base category and images in the new category.
- the global category feature in the image classification device is obtained by training multiple training images in the training set, and the global category feature includes multiple category features that can indicate visual features corresponding to all categories in the training set.
- the training set used in the global category training process includes the images in the base category and the images in the new category, it can prevent the global category features from being over-fitted to the images in the base category, thereby enabling more accurate recognition Images in the new category.
- the global category features in the image classification device can be updated, so that the global category features obtained by training can have better consistency.
- training The collection includes the images in the base class and the images in the new class.
- the effect of the new class (training image in) during the training process can be accumulated with the global category features, so it can avoid the training of the image classification device from over-fitting Combine it into the base class and classify the image to be processed according to the image classification device, which can obtain better image classification results.
- the classification module is specifically configured to: extract a feature vector of the image to be processed; and determine the image to be processed according to the feature vector of the image to be processed Confidence that belongs to a candidate category, where the candidate category is one or more of the multiple categories indicated by the global category feature; according to the confidence, the category of the image to be processed is determined from the candidate category result.
- the device further includes a determining module, configured to: determine the local category characteristics of the image to be processed according to the support set of the image to be processed; The local category feature of the image to be processed and the global category feature to determine the candidate category; wherein the support set of the image to be processed includes multiple images, and the category to which the multiple images belong is the global category feature One or more of the indicated categories.
- the classification module is specifically configured to: determine the feature vector of the image to be processed and the candidate category according to the feature vector of the image to be processed The distance of the feature vector corresponding to each category; according to the distance, the confidence that the image to be processed belongs to the candidate category is determined.
- the classification module is specifically configured to: determine the category with the greatest confidence among the candidate categories as the classification result of the image to be processed.
- the global category feature is obtained by training based on a classification error, and the classification error is based on the classification result of the training image in the query set and the query set
- the training image is determined by a pre-labeled label, the label is used to indicate the category to which the training image belongs, and the query set includes part of the training images in the partial categories in the training set.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
- the global category feature is obtained by training based on classification errors and registration errors, and the classification error is based on the classification results and the results of the training images in the query set.
- the pre-labeled training image in the question set is determined, the label is used to indicate the category to which the training image belongs, the question set includes some training images in some categories in the training set, and the configuration
- the quasi-error is determined based on the local category feature of the training image and multiple category features in the global category feature.
- the local category feature of the training image includes multiple category features determined from multiple training images in the support set.
- the multiple category features in the local category features of the training image are used to indicate the visual features of all categories in the support set, and the support set includes part of the training images in the partial categories in the training set.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
- the local category feature of the training image is determined by multiple training images in the support set that have undergone expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
- the multiple training images in the above support set are images in the new class.
- multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided
- the device is overfitted to the base class, and the image to be processed is classified according to the image classification device, which can obtain better image classification results.
- a training device for an image classification model which includes: an acquisition module for acquiring multiple training images in a training set, wherein the training set includes a support set and a training set, and the multiple training images Including multiple training images in the support set and multiple training images in the query set; a feature extraction module for extracting features of multiple training images in the query set according to a preset first neural network Vector, the question set includes part of images in the partial categories in the training set; the classification module is used to compare the plurality of images in the question set according to the preset second neural network and the preset global category features
- the feature vectors of the training images are processed to obtain classification results of multiple training images in the query set, wherein the global category features include multiple category features, and the multiple category features in the global category features are used to indicate Visual features of all categories in the training set, all categories in the training set are categories to which all training images in the training set belong, and the training set includes images in the base class and images in the new class; update module , Used to update the global category feature
- the global category features are trained from the classification results of multiple training images in the training set.
- the global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set.
- the training set used in the global category training process includes images in the base category and images in the new category, which can prevent the global category features from being overfitted to the images in the base category, thereby enabling more accurate identification of the images in the new category. image.
- the global category features can be updated, so that the global category features obtained by training can have better consistency.
- the training set includes the base class
- the images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
- the classification module is specifically configured to: extract feature vectors of multiple training images in the support set, and the support set includes partial categories in the training set Part of the training images in the support set; determine the local category features of the training images according to the feature vectors of the multiple training images in the support set, and the multiple category features in the local category features of the training images are used to indicate the support set Visual features of all categories, the support set includes part of the training images in the partial categories in the training set; according to the second neural network, the local category features of the training images, and the global category features, the Ask the classification results of multiple training images in the set.
- the update module is specifically configured to: update the global category feature, the first A neural network and the second neural network.
- the update module is specifically configured to: update the global category feature according to a classification error, and the classification error is based on multiple trainings in the query set The classification result of the image and the pre-labeled labels of the multiple training images in the query set are determined, and the labels are used to indicate the category to which the training image belongs.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
- the update module is specifically configured to: update the global category feature according to the classification error and the registration error, wherein the registration error is based on The local category feature of the training image and the multiple category features of the global category feature are determined.
- the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images.
- the training images in the query set include images in the base class and images in the new class.
- the registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
- the local category feature of the training image is determined by multiple training images in the support set that have undergone expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
- the multiple training images in the above support set are images in the new class.
- multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided
- the model is overfitted to the base class, and the image to be processed is classified according to the image classification model, which can obtain better image classification results.
- an image classification device in a fifth aspect, includes: a memory for storing a program; a processor for executing the program stored in the memory. When the program stored in the memory is executed, the processing The device is used to execute the method in any one of the foregoing first aspects.
- an image classification model training device includes: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, The processor is configured to execute the method in any one of the foregoing second aspect.
- the processors in the fifth and sixth aspects described above can be either a central processing unit (CPU), or a combination of a CPU and a neural network computing processor, where the neural network computing processor can include graphics processing GPU (graphics processing unit, GPU), neural-network processing unit (NPU), tensor processing unit (TPU), etc.
- TPU is an artificial intelligence accelerator application specific integrated circuit fully customized by Google for machine learning.
- a computer-readable medium stores program code for device execution.
- the program code includes a method for executing any one of the first aspect or the second aspect. .
- a computer program product containing instructions is provided, when the computer program product runs on a computer, the computer executes the method in any one of the foregoing first aspect or second aspect.
- a chip in a ninth aspect, includes a processor and a data interface, the processor reads instructions stored in a memory through the data interface, and executes any one of the first aspect or the second aspect above The method in the implementation mode.
- the chip may further include a memory in which instructions are stored, and the processor is configured to execute the instructions stored in the memory.
- the processor is configured to execute the method in any one of the implementation manners of the first aspect or the second aspect.
- the aforementioned chip may specifically be a field-programmable gate array (FPGA) or an application-specific integrated circuit (ASIC).
- FPGA field-programmable gate array
- ASIC application-specific integrated circuit
- an electronic device in a tenth aspect, includes the image classification device in any one of the foregoing third aspects, or the electronic device includes the image classification model in any one of the foregoing fourth aspects Training device.
- the electronic device may specifically be a terminal device.
- the electronic device may specifically be a server.
- the global category features can be updated, so that the global category features obtained by training can have better consistency.
- the training set includes the base The images in the class and the images in the new class.
- the effect of the new class (training image in) during the training process can be accumulated with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base Class, according to the image classification model to classify the image to be processed, can more accurately identify the image in the new class.
- Fig. 1 is a schematic structural diagram of a system architecture provided by an embodiment of the present application.
- Fig. 2 is a schematic block diagram of a convolutional neural network model provided by an embodiment of the present application.
- Fig. 3 is a schematic diagram of a chip hardware structure provided by an embodiment of the present application.
- Fig. 4 is a schematic diagram of an application scenario provided by an embodiment of the present application.
- Fig. 5 is a schematic flowchart of a method for training an image classification model provided by an embodiment of the present application.
- Fig. 6 is a schematic block diagram of a method for training an image classification model provided by an embodiment of the present application.
- FIG. 7 is a schematic flowchart of a method for training an image classification model provided by another embodiment of the present application.
- FIG. 8 is a schematic flowchart of an image classification method provided by an embodiment of the present application.
- FIG. 9 is a schematic diagram of the hardware structure of an image classification device according to an embodiment of the present application.
- FIG. 10 is a schematic diagram of the hardware structure of an image classification model training device according to an embodiment of the present application.
- the image classification method provided by the embodiments of the present application can be applied to image retrieval, album management, safe city, human-computer interaction, and other scenes that require image classification or image recognition.
- the images in the embodiments of this application may be static images (or called static pictures) or dynamic images (or called dynamic pictures).
- the images in this application may be videos or dynamic pictures, or The images in can also be static pictures or photos.
- static images or dynamic images are collectively referred to as images.
- the image classification method of the embodiment of the present application can be specifically applied to album classification and photo recognition scenes, and these two scenes are described in detail below.
- the image classification method of the embodiment of the present application can facilitate the user to classify and manage different object categories, thereby facilitating the user's search, saving the user's management time, and improving the efficiency of album management.
- the picture features of the pictures in the album can be extracted first, and then the pictures in the album are classified according to the extracted picture characteristics to obtain the classification result of the pictures. Next, the pictures in the album are classified according to the classification results of the pictures, and the albums arranged according to the picture categories are obtained.
- pictures belonging to the same category may be arranged in a row or a row. For example, in the final album, the pictures in the first row belong to airplanes, and the pictures in the second row belong to cars.
- the user can use the image classification method of the embodiment of the present application to process the captured photo, and can automatically recognize the category of the object being photographed, for example, it can automatically recognize that the object being photographed is a flower, an animal, etc.
- the image classification method of the embodiment of the application can be used to identify the object obtained by taking a photo, and the category to which the object belongs can be identified.
- the photo obtained by the user includes a shared bicycle, and the image classification method of the embodiment of the application is used
- the shared bicycle can be recognized, and the object is recognized as a bicycle, and further, bicycle related information can be displayed.
- the present invention Since the present invention has an excellent learning effect on generalized small samples, it can be well recognized regardless of whether the photographed object comes from the base class or the new class.
- album classification and photo identification described above are only two specific scenarios applied by the image classification method in the embodiment of this application, and the image classification method in the embodiment of this application is not limited to the above two scenarios when applied.
- the image classification method of the application embodiment can be applied to any scene that requires image classification or image recognition.
- the embodiments of this application involve a large number of related applications of neural networks.
- a neural network can be composed of neural units, which can refer to an arithmetic unit that takes x s and intercept 1 as inputs.
- the output of the arithmetic unit can be as shown in formula (1-1):
- s 1, 2,...n, n is a natural number greater than 1
- W s is the weight of x s
- b is the bias of the neural unit.
- f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal.
- the output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function.
- a neural network is a network formed by connecting multiple above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit.
- the input of each neural unit can be connected with the local receptive field of the previous layer to extract the characteristics of the local receptive field.
- the local receptive field can be a region composed of several neural units.
- Deep neural network also called multi-layer neural network
- DNN can be understood as a neural network with multiple hidden layers.
- DNN is divided according to the positions of different layers.
- the neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer.
- the first layer is the input layer
- the last layer is the output layer
- the number of layers in the middle are all hidden layers.
- the layers are fully connected, that is to say, any neuron in the i-th layer must be connected to any neuron in the i+1th layer.
- DNN looks complicated, it is not complicated in terms of the work of each layer. In simple terms, it is the following linear relationship expression: among them, Is the input vector, Is the output vector, Is the offset vector, W is the weight matrix (also called coefficient), and ⁇ () is the activation function.
- Each layer is just the input vector After such a simple operation, the output vector is obtained Due to the large number of DNN layers, the coefficient W and the offset vector The number is also relatively large.
- the definition of these parameters in the DNN is as follows: Take the coefficient W as an example: Suppose that in a three-layer DNN, the linear coefficients from the fourth neuron in the second layer to the second neuron in the third layer are defined as The superscript 3 represents the number of layers where the coefficient W is located, and the subscript corresponds to the output third layer index 2 and the input second layer index 4.
- the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as
- the input layer has no W parameter.
- more hidden layers make the network more capable of portraying complex situations in the real world. Theoretically speaking, a model with more parameters is more complex and has a greater "capacity", which means it can complete more complex learning tasks.
- Training a deep neural network is also a process of learning a weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (a weight matrix formed by vectors W of many layers).
- Convolutional neural network (convolutional neuron network, CNN) is a deep neural network with convolutional structure.
- the convolutional neural network contains a feature extractor composed of a convolutional layer and a sub-sampling layer, which can be regarded as a filter.
- the convolutional layer refers to the neuron layer that performs convolution processing on the input signal in the convolutional neural network.
- a neuron can be connected to only part of the neighboring neurons.
- a convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units in the same feature plane share weights, and the shared weights here are the convolution kernels.
- Sharing weight can be understood as the way to extract image information has nothing to do with location.
- the convolution kernel can be initialized in the form of a matrix of random size. During the training of the convolutional neural network, the convolution kernel can obtain reasonable weights through learning. In addition, the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
- the neural network can use an error back propagation (BP) algorithm to modify the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, forwarding the input signal to the output will cause error loss, and the parameters in the initial neural network model are updated by backpropagating the error loss information, so that the error loss is converged.
- the backpropagation algorithm is a backpropagation motion dominated by error loss, and aims to obtain the optimal neural network model parameters, such as the weight matrix.
- the pixel value of the image can be a red-green-blue (RGB) color value, and the pixel value can be a long integer representing the color.
- the pixel value is 256*Red+100*Green+76Blue, where Blue represents the blue component, Green represents the green component, and Red represents the red component. In each color component, the smaller the value, the lower the brightness, and the larger the value, the higher the brightness.
- the pixel values can be grayscale values.
- the base class includes a large number of labeled samples used to train the model, and the number of these labeled samples is sufficient to meet the requirements of model training.
- the base category may include multiple images that have been labeled with categories, the multiple images may belong to one category, or the multiple images may also belong to multiple different categories.
- the base class can be used to train the image classification model in the embodiment of the present application.
- a new class is a concept opposite to the base class. For example, if a model is trained using multiple labeled samples, then for the (trained) model, the multiple The labeled sample is the base category, and the categories that are not included in the base category are the new categories. For example, we have trained a model through images of a large number of animals (except dogs). At this time, if we want the model to recognize dogs, the images of the large number of animals are the base class, and the images of the dog are the new class.
- each category in the new category includes only a small number of labeled samples.
- the new category can refer to a small sample
- the new category includes a small number of images that have been labeled with their categories. These images can belong to one category, or these images can also be divided into multiple different categories.
- Small sample learning refers to the use of large-scale training sets (including one or more base classes), after training the image classification model, for new classes that have never been seen before (new classes and base classes). Non-overlapping), with the help of a few training samples included in each new class, accurately identify the test samples of the new class (category to which it belongs).
- small sample learning may include standard small sample learning and generalized small sample learning. For example, if the test sample in small sample learning includes only new classes, then this type of problem can be called standard small sample learning; if the test sample includes not only new classes but also base classes, then this type of problem can be called Learning for generalized small samples.
- the image classification method in the embodiment of the present application can be applied to standard small sample learning, and can also be applied to generalized small sample learning.
- the following describes the system architecture applicable to the embodiment of the present application with reference to FIG. 1.
- an embodiment of the present application provides a system architecture 100.
- a data collection device 160 is used to collect training data.
- the training data may include training images and classification results corresponding to the training images, wherein the classification results of the training images may be manually pre-labeled results.
- the data collection device 160 stores the training data in the database 130, and the training device 120 trains to obtain the target model/rule 101 based on the training data maintained in the database 130.
- the training device 120 processes the input original image and compares the output image with the original image until the output image of the training device 120 differs from the original image. The difference is less than a certain threshold, thereby completing the training of the target model/rule 101.
- the above-mentioned target model/rule 101 can be used to implement the image classification method of the embodiment of the present application, that is, the image to be processed is input into the target model/rule 101 after relevant preprocessing to obtain the classification result of the image.
- the target model/rule 101 in the embodiment of the application may specifically be the image classification model in the embodiment of the application.
- the training data maintained in the database 130 may not all come from the collection of the data collection device 160, and may also be received from other devices.
- the training device 120 does not necessarily perform the training of the target model/rule 101 completely based on the training data maintained by the database 130. It may also obtain training data from the cloud or other places for model training.
- the above description should not be used as a reference to this application. Limitations of Examples.
- the target model/rule 101 trained according to the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG. 1.
- the execution device 110 may be a terminal, such as a mobile phone terminal, a tablet computer, Notebook computers, augmented reality (AR)/virtual reality (VR), vehicle-mounted terminals, etc., can also be servers or cloud devices.
- the execution device 110 is configured with an input/output (input/output, I/O) interface 112 for data interaction with external devices.
- the user can input data to the I/O interface 112 through the client device 140.
- the input data in this embodiment of the application may include: the image to be processed input by the client device.
- the preprocessing module 113 and the preprocessing module 114 are used for preprocessing according to the input data (such as the image to be processed) received by the I/O interface 112.
- the preprocessing module 113 and the preprocessing module may not be provided.
- 114 there may only be one preprocessing module, and the calculation module 111 is directly used to process the input data.
- the execution device 110 may call data, codes, etc. in the data storage system 150 for corresponding processing .
- the data, instructions, etc. obtained by corresponding processing may also be stored in the data storage system 150.
- the I/O interface 112 returns the processing result, such as the classification result of the to-be-processed image obtained as described above, to the client device 140 to provide it to the user.
- the training device 120 can generate corresponding target models/rules 101 based on different training data for different goals or tasks, and the corresponding target models/rules 101 can be used to achieve the above goals or complete The above tasks provide the user with the desired result.
- the user can manually set input data, and the manual setting can be operated through the interface provided by the I/O interface 112.
- the client device 140 can automatically send input data to the I/O interface 112. If the client device 140 is required to automatically send the input data and the user's authorization is required, the user can set the corresponding authority in the client device 140.
- the user can view the result output by the execution device 110 on the client device 140, and the specific presentation form may be a specific manner such as display, sound, and action.
- the client device 140 can also be used as a data collection terminal to collect the input data of the input I/O interface 112 and the output result of the output I/O interface 112 as new sample data, and store it in the database 130 as shown in the figure.
- the I/O interface 112 directly uses the input data input to the I/O interface 112 and the output result of the output I/O interface 112 as a new sample as shown in the figure.
- the data is stored in the database 130.
- Fig. 1 is only a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationship between the devices, devices, modules, etc. shown in the figure does not constitute any limitation.
- the data The storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110.
- the target model/rule 101 is obtained by training according to the training device 120.
- the target model/rule 101 may be the image classification model in the embodiment of the application.
- the image provided in the embodiment of the application The classification model may include one or more neural networks.
- the one or more neural networks may include CNN, deep convolutional neural networks (DCNN), and/or recurrent neural networks (RNNS), etc. .
- CNN is a very common neural network
- the structure of CNN will be introduced in detail below in conjunction with Figure 2.
- a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture.
- a deep learning architecture refers to a machine learning algorithm. Multi-level learning is carried out on the abstract level of
- CNN is a feed-forward artificial neural network. Each neuron in the feed-forward artificial neural network can respond to the input image.
- a convolutional neural network (CNN) 200 may include an input layer 210, a convolutional layer/pooling layer 220 (the pooling layer is optional), and a neural network layer 230.
- CNN convolutional neural network
- the convolutional layer/pooling layer 220 as shown in FIG. 2 may include layers 221-226 as shown in Examples.
- layer 221 is a convolutional layer
- layer 222 is a pooling layer
- layer 223 is Convolutional layer
- 224 is a pooling layer
- 225 is a convolutional layer
- 226 is a pooling layer
- 221 and 222 are convolutional layers
- 223 is a pooling layer
- 224 and 225 are convolutions.
- the accumulation layer, 226 is the pooling layer. That is, the output of the convolutional layer can be used as the input of the subsequent pooling layer, or as the input of another convolutional layer to continue the convolution operation.
- the convolution layer 221 can include many convolution operators.
- the convolution operator is also called a kernel. Its function in image processing is equivalent to a filter that extracts specific information from the input image matrix.
- the convolution operator is essentially It can be a weight matrix. This weight matrix is usually pre-defined. In the process of convolution on the image, the weight matrix is usually one pixel after one pixel (or two pixels after two pixels) along the horizontal direction on the input image. ...It depends on the value of stride) to complete the work of extracting specific features from the image.
- the size of the weight matrix should be related to the size of the image. It should be noted that the depth dimension of the weight matrix and the depth dimension of the input image are the same.
- the weight matrix will extend to Enter the entire depth of the image. Therefore, convolution with a single weight matrix will produce a single depth dimension convolution output, but in most cases, a single weight matrix is not used, but multiple weight matrices of the same size (row ⁇ column) are applied. That is, multiple homogeneous matrices.
- the output of each weight matrix is stacked to form the depth dimension of the convolutional image, where the dimension can be understood as determined by the "multiple" mentioned above.
- Different weight matrices can be used to extract different features in the image. For example, one weight matrix is used to extract edge information of the image, another weight matrix is used to extract specific colors of the image, and another weight matrix is used to eliminate unwanted noise in the image.
- the multiple weight matrices have the same size (row ⁇ column), and the feature maps extracted by the multiple weight matrices of the same size have the same size, and then the multiple extracted feature maps of the same size are combined to form a convolution operation. Output.
- weight values in these weight matrices need to be obtained through a lot of training in practical applications.
- Each weight matrix formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions. .
- the initial convolutional layer (such as 221) often extracts more general features, which can also be called low-level features; with the convolutional neural network
- the features extracted by the subsequent convolutional layers (for example, 226) become more and more complex, such as features such as high-level semantics, and features with higher semantics are more suitable for the problem to be solved.
- the pooling layer can be a convolutional layer followed by a layer
- the pooling layer can also be a multi-layer convolutional layer followed by one or more pooling layers.
- the pooling layer may include an average pooling operator and/or a maximum pooling operator for sampling the input image to obtain a smaller size image.
- the average pooling operator can calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling.
- the maximum pooling operator can take the pixel with the largest value within a specific range as the result of the maximum pooling.
- the operators in the pooling layer should also be related to the image size.
- the size of the image output after processing by the pooling layer can be smaller than the size of the image of the input pooling layer, and each pixel in the image output by the pooling layer represents the average value or the maximum value of the corresponding sub-region of the image input to the pooling layer.
- the convolutional neural network 200 After processing by the convolutional layer/pooling layer 220, the convolutional neural network 200 is not enough to output the required output information. Because as mentioned above, the convolutional layer/pooling layer 220 only extracts features and reduces the parameters brought by the input image. However, in order to generate the final output information (required class information or other related information), the convolutional neural network 200 needs to use the neural network layer 230 to generate one or a group of required classes of output. Therefore, the neural network layer 230 may include multiple hidden layers (231, 232 to 23n as shown in FIG. 2) and an output layer 240. The parameters contained in the multiple hidden layers can be based on specific task types. The relevant training data of the, for example, the task type can include image recognition, image classification, image super-resolution reconstruction and so on.
- the output layer 240 After the multiple hidden layers in the neural network layer 230, that is, the final layer of the entire convolutional neural network 200 is the output layer 240.
- the output layer 240 has a loss function similar to the classification cross entropy, which is specifically used to calculate the prediction error.
- the convolutional neural network 200 shown in FIG. 2 is only used as an example of a convolutional neural network. In specific applications, the convolutional neural network may also exist in the form of other network models.
- the image classification model may include the convolutional neural network 200 shown in FIG. 2, and the image classification model may process the image to be processed to obtain the classification result of the image to be processed.
- FIG. 3 is a hardware structure of a chip provided by an embodiment of the application, and the chip includes a neural network processor 30.
- the chip may be set in the execution device 110 as shown in FIG. 1 to complete the calculation work of the calculation module 111.
- the chip can also be set in the training device 120 as shown in FIG. 1 to complete the training work of the training device 120 and output the target model/rule 101.
- the algorithms of each layer in the convolutional neural network as shown in Figure 2 can be implemented in the chip as shown in Figure 3.
- the convolutional neural network can be (one or more) included in the above-mentioned image classification model. A) one of the neural networks.
- the neural network processor NPU 30 is mounted on a host CPU (host CPU) as a coprocessor, and the host CPU distributes tasks.
- the core part of the NPU is the arithmetic circuit 303.
- the controller 304 controls the arithmetic circuit 303 to extract data from the memory (weight memory or input memory) and perform calculations.
- the arithmetic circuit 303 includes multiple processing units (process engines, PE). In some implementations, the arithmetic circuit 303 is a two-dimensional systolic array. The arithmetic circuit 303 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 303 is a general-purpose matrix processor.
- the arithmetic circuit 303 fetches the data corresponding to the matrix B from the weight memory 302 and caches it on each PE in the arithmetic circuit 303.
- the arithmetic circuit 303 takes the matrix A data and the matrix B from the input memory 301 to perform matrix operations, and the partial result or final result of the obtained matrix is stored in an accumulator 308.
- the vector calculation unit 307 can perform further processing on the output of the operation circuit 303, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, and so on.
- the vector calculation unit 307 can be used for network calculations in the non-convolution/non-FC layer of the neural network, such as pooling, batch normalization, local response normalization, etc. .
- the vector calculation unit 307 can store the processed output vector to the unified buffer 306.
- the vector calculation unit 307 may apply a nonlinear function to the output of the arithmetic circuit 303, such as a vector of accumulated values, to generate the activation value.
- the vector calculation unit 307 generates a normalized value, a combined value, or both.
- the processed output vector can be used as an activation input to the arithmetic circuit 303, for example for use in subsequent layers in a neural network.
- the unified memory 306 is used to store input data and output data.
- the weight data directly transfers the input data in the external memory to the input memory 301 and/or the unified memory 306 through the storage unit access controller 305 (direct memory access controller, DMAC), and stores the weight data in the external memory into the weight memory 302, And the data in the unified memory 306 is stored in the external memory.
- DMAC direct memory access controller
- the bus interface unit (BIU) 310 is used to implement interaction between the main CPU, the DMAC, and the fetch memory 309 through the bus.
- An instruction fetch buffer 309 connected to the controller 304 is used to store instructions used by the controller 304;
- the controller 304 is used to call the instructions cached in the memory 309 to control the working process of the computing accelerator.
- the unified memory 306, the input memory 301, the weight memory 302, and the instruction fetch memory 309 are all on-chip (On-Chip) memories.
- the external memory is a memory external to the NPU.
- the external memory can be a double data rate synchronous dynamic random access memory.
- Memory double data rate synchronous dynamic random access memory, referred to as DDR SDRAM
- HBM high bandwidth memory
- each layer in the convolutional neural network shown in FIG. 2 can be executed by the arithmetic circuit 303 or the vector calculation unit 307.
- the execution device 110 in FIG. 1 introduced above can execute each step of the image classification method of the embodiment of the present application.
- the execution device 110 in FIG. 1 may include the CNN model shown in FIG. 2 and the image classification method shown in FIG. Chip.
- the image classification method of the embodiment of the present application will be described in detail below with reference to the accompanying drawings.
- the image classification method provided in the embodiments of the present application can be executed on a server, can also be executed on the cloud, and can also be executed on a terminal device.
- a terminal device as an example, as shown in FIG. 4, the technical solution of the embodiment of the present invention can be applied to a terminal device.
- the image classification method in the embodiment of the present application can classify an input image to obtain a classification result of the input image.
- the terminal device may be mobile or fixed.
- the terminal device may be a mobile phone with image processing function, a tablet personal computer (TPC), a media player, a smart TV, a laptop computer (LC). ), personal digital assistant (PDA), personal computer (PC), camera, video camera, smart watch, wearable device (WD) or self-driving vehicle, etc., embodiments of the present invention There is no restriction on this.
- the classification of images is the basis of various image processing applications, and computer vision often involves the problem of how to classify the acquired images.
- the training of an image classification model requires a large amount of labeled training data.
- image categories with few training samples such as new categories
- it is very difficult to obtain valid data for example, in the medical field and security field.
- the embodiments of the present application propose an image classification method and an image classification model training method. For new classes (small samples) with few training samples, image classification or image recognition can also be implemented well.
- FIG. 5 is a schematic flowchart of an image classification model training method 500 according to an embodiment of the present application.
- the method shown in FIG. 5 may be executed by a device with strong computing capability such as a computer device, a server device, or a computing device.
- the method may be executed by the terminal device in FIG. 4.
- the method shown in Fig. 5 includes steps 510, 520, 530, and 540, which are respectively described in detail below.
- S510 Acquire multiple training images in the training set.
- the training set may be a set of all training images used during training.
- the training set includes images in the base class and images in the new class, and each class in the base class includes far more training images than each class in the new class.
- the number of training images included in each category in the base class is at least an order of magnitude higher than the number of training images included in each category in the new class, that is, each category in the base class
- the number of training images included is at least ten times the number of training images included in each category in the new class.
- the base category includes 100 categories, each category includes 1000 training images, the new category includes 5 categories, and each category includes 5 training images.
- the image classification model in this application may be trained based on a multi-stage training (episodic training) strategy.
- the model training process can be divided into multiple training episodes. In each training stage, several categories in the training set can be randomly selected to train the model.
- the image classification is completed Model training.
- multi-stage training please refer to the prior art, which will not be repeated here.
- the global category features can be updated, so that the global category features obtained by training can have better consistency.
- the training set includes the base class
- the images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
- the training method of the image classification model in the embodiment of the present application can better balance the difference between the number of samples in the base class and the number of samples in the new class, and the impact on the model training process.
- the detailed description of the training method of the image classification model involved in this application may be as described in the method 700 in FIG. 7.
- the method 500 in this application can be divided into multiple training stages. Accordingly, the above-mentioned S510 can mean that in one training stage, multiple training images in the training set are randomly selected, and the extracted The multiple training images in the training set are divided into a support set (support set) and a query set (query set).
- the training set includes a support set and a query set
- the multiple training images in the training set include: multiple training images in the support set and multiple training images in the query set.
- S520 Extract feature vectors of multiple training images in the query set according to the preset first neural network.
- the feature vector of the training image may be used to indicate the visual feature (or image feature) of the training image, and the query set includes partial images in partial categories in the training set.
- feature vectors of multiple training images in the support set may also be extracted.
- the first neural network may be trained by the system 100 shown in FIG. 1.
- the first neural network may be the convolutional neural network shown in FIG. 2.
- S530 Process the feature vectors of the multiple training images in the query set according to the preset second neural network and the preset global category features to obtain classification results of the multiple training images in the query set.
- classification result may refer to the label of the category to which the image belongs.
- the second neural network may be trained by the system 100 shown in FIG. 1.
- the second neural network may be the convolutional neural network shown in FIG. 2.
- the global category feature includes multiple category features, and multiple category features in the global category feature are used to indicate visual features of all categories in the training set, and all categories in the training set are in the training set The category to which all training images belong.
- the feature vectors of the multiple training images in the query set are processed to obtain multiple trainings in the query set
- the classification result of the image may include: extracting feature vectors of multiple training images in the support set; determining the local category features of the training images according to the feature vectors of the multiple training images in the support set; The network, the local category feature of the training image, and the global category feature determine the classification results of the multiple training images in the query set.
- multiple category features in the local category features of the training image are used to indicate the visual features of all categories in the support set, and the support set includes part of the training images in some categories in the training set, and The query set includes some training images in some categories in the training set.
- the category in the support set may be the same as the category in the inquiry set.
- the multiple training images in the training set are divided into a support set and an inquiry set.
- the multiple training images in the support set may include images in the base class and images in the new class.
- the support set and query set are determined by multiple training images randomly selected from the training set.
- the training set includes images in the base class and images in the new class. Therefore, the support set
- the multiple training images of can also include only images in the base class, or the multiple training images in the support set can also only include images in the new class.
- the category features of multiple training images in the base class in the support set and the category features of multiple training images in the new class can be determined.
- the feature vector of each training image in the base category can be determined, and the feature vectors of multiple training images belonging to the same category can be averaged, and the average can be used as the category feature of the category.
- the method of determining the category features of multiple training images in the new class will not be repeated here.
- the multiple training images in the new class can also be cropped, flipped and/or data transformed ( hallucinator) and other image expansion processing to get more new types of images.
- the above-mentioned (obtained) category features can be referred to as local category features of training images (local class representations).
- the local category features of the training image are determined by multiple training images randomly selected (supported in the concentration) during a training phase, that is, these local category features only act on one of the model training processes.
- local category features can also be referred to as episodic class representations.
- the local category feature may also be other names, which is not limited in this application.
- global class representations can be considered as parameters of the image classification model, sharing the class features of all categories in the training set. Therefore, global class representations can be used in multiple training stages in the model training process.
- the local category feature of the training image can be registered to the global category feature, so as to obtain the registration result, that is, the registered global category feature.
- the registration here can also be understood as finding the category feature in the global category feature corresponding to each category feature in the local category feature. For example, find a category feature in the global category feature that has the highest similarity with each category feature in the local category feature.
- the registration error can be determined according to the similarity of each category feature in the local category feature and the category feature in the corresponding global category feature.
- the registration error may be determined based on the similarity between each category feature in the local category features and the category feature in the corresponding global category feature. That is, the registration error in the current training stage is determined according to the local category features of the training image and the multiple category features in the global category features.
- the second neural network may be used to perform dimensionality reduction processing on the registration result, so as to process feature vectors of multiple training images in the query set in a low-dimensional vector space.
- the registration result can be used to predict each training image in the query set to obtain the classification result of each training image in the query set.
- the nearest neighbor method can be used to predict the classification result of the training image.
- the distance between the category feature in the registration result and the feature vector of each training image in the query set can be calculated, and each distance can be normalized to obtain each training image in the training image.
- the probability of belonging to the category indicated by the category feature in the registration result is the classification result of each training image in the query set.
- the classification error can be obtained, wherein the pre-labeled label is used to indicate the true category to which the training image belongs. That is, the classification error of the current training stage is determined according to the classification results of the multiple training images and the pre-labeled labels of the multiple training images.
- S540 Update the global category feature according to the classification results of the multiple training images in the query set.
- the global category feature, the first neural network, and the second neural network may be updated according to the classification results of the multiple training images in the query set.
- the global category feature can be updated according to the classification error.
- the classification error may be determined according to the classification results of the multiple training images by the method in S530.
- the global category feature, the first neural network and the second neural network may be updated according to the classification error.
- the global category feature can be updated according to the classification error and the registration error.
- the classification error may be determined according to multiple category features in the local category feature of the training image and the global category feature by using the method in S530.
- the global category feature, the first neural network and the second neural network can be updated according to the classification error and the registration error.
- the global category features can be updated, so that the global category features obtained by training can have better consistency.
- the training set includes the base The images in the class and the images in the new class.
- the effect of the new class (training image in) during the training process can be accumulated with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base Class, according to the image classification model to classify the image to be processed, can more accurately identify the image in the new class.
- FIG. 7 is a schematic flowchart of a method 700 for training an image classification model according to another embodiment of the present application.
- the method shown in FIG. 7 can be executed by a device with strong computing capabilities such as a computer device, a server device, or a computing device.
- the method can be executed by the terminal device in FIG. 4.
- Each step in the method 700 will be described in detail below.
- Extract feature vectors of multiple training images in the support set the multiple training images including images in the base class and images in the new class.
- the above-mentioned first neural network may be used to extract feature vectors of multiple training images in the support set.
- the c jth category includes k j training images, j is an integer.
- a training set D train can be obtained, and the training set D train includes a base class image and a new class image.
- image expansion processing such as cropping, flipping, and/or data transformation (hallucinator) can be performed on the images in the new class to obtain more new images.
- hallucinator data transformation
- the feature vectors of multiple training images belonging to the same category are calculated to average, and the average can be used as the category feature of the category.
- the local category feature of the training image is registered to the global category feature to obtain a registration result.
- the global category feature is recorded as among them, Is the category feature of the c jth category in the training set.
- the category feature f i in the local category feature and the jth category feature in the global category feature can be calculated in the low-dimensional embedding space (embedding space)
- the similarity of the vector Among them, the jth element Denote f i and The similarity.
- ⁇ ( ⁇ ) is the embedding function of the visual feature of the training image
- ⁇ ( ⁇ ) is the embedding function of the global category feature
- a global category class characteristic features the highest similarity with the category feature f i g cj, wherein the global category corresponding to the category feature f i.
- the registration error can be determined according to the similarity of each category feature in the local category feature and the category feature in the corresponding global category feature.
- the loss function L reg of the training image x i can be used as the registration error, so that the training image is closest to its global category feature in the low-dimensional embedding space.
- the formula for calculating the loss function L reg is as follows.
- CE( ⁇ ) is the cross-entropy loss
- y i is the label of the training image x i .
- the registration error of can be calculated by the following formula.
- the registration result can be used to predict each training image in the query set, and obtain a classification result of each training image in the query set.
- the classification error can be obtained.
- the loss function L fsl can be used as the classification error of the training images (x k , y k ) in the query set, and the loss function L fsl is shown in the following formula.
- the most similar The corresponding category is taken as the category of the training image x k , that is, the classification result of the training image x k .
- registration errors and/or classification errors can be used to update the image classification model.
- the registration error (L reg ) and the classification error (L fsl ) can be combined, and the total loss function L total ( ⁇ ) of multiple training stages can be calculated by the following formula.
- S750 may include at least one of S751, S752, and S753.
- registration error (L reg ), classification error (L fsl ), and/or total loss function (L total ) can be used to update the feature extraction (module).
- the registration error (L reg ), the classification error (L fsl ) and/or the total loss function (L total ) can be used to update the category feature registration (module).
- the registration error (L reg ), the classification error (L fsl ), and/or the total loss function (L total ) can be used to update the global category features.
- FIG. 8 shows a schematic flowchart of an image classification method 800 provided by an embodiment of the present application.
- the method shown in FIG. 8 may be executed by a device with strong computing capabilities such as a computer device, a server device, or a computing device.
- the The method can be executed by the terminal device in FIG. 4.
- the method shown in FIG. 8 includes steps 810 and 820, which are respectively described in detail below.
- S810 Acquire an image to be processed.
- the image to be processed may be an image captured by the terminal device through a camera; or, the image to be processed may also be from the terminal device.
- the obtained image for example, the image stored in the album of the terminal device, or the image obtained by the terminal device from the cloud.
- S820 Classify the image to be processed according to preset global category features, to obtain a classification result of the image to be processed.
- the global category features include multiple category features obtained by training based on multiple training images in the training set, and multiple category features in the global category features are used to indicate visual features of all categories in the training set, so All categories in the training set are categories to which all training images in the training set belong, and the training set includes images in the base class and images in the new class.
- the classifying the image to be processed according to preset global category features to obtain the classification result of the image to be processed may include: extracting the feature vector of the image to be processed; Process the feature vector of the image, and determine the confidence that the image to be processed belongs to a candidate category, where the candidate category is one or more of the multiple categories indicated by the global category feature; according to the confidence, from the The classification result of the image to be processed is determined from the candidate category.
- the method may further include: determining the Process the local category feature of the image; determine the candidate category according to the local category feature of the image to be processed and the global category feature.
- the support set of the image to be processed includes multiple images, and the category to which the multiple images belong is one or more of the multiple categories indicated by the global category feature.
- the candidate category may include the category to which all training images in the support set belong.
- the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed may include: determining the feature of the image to be processed according to the feature vector of the image to be processed The distance between the vector and the feature vector corresponding to each of the candidate categories; and according to the distance, the confidence that the image to be processed belongs to the candidate category is determined.
- the determining the classification result of the image to be processed from the candidate categories according to the confidence may include: determining the category with the highest confidence in the candidate categories as the The classification result of the image to be processed.
- the confidence level here may be the probability that the image to be processed belongs to the candidate category. Therefore, the degree of confidence is the greatest. It can also be said that the image to be processed has the greatest probability of belonging to the candidate category.
- the global category feature is obtained by training according to a classification error, and the classification error is determined according to the classification result of the training image in the query set and the pre-labeled label of the training image in the query set.
- the label is used to indicate the category to which the training image belongs, and the query set includes part of the training images in the partial categories in the training set.
- the global category feature is obtained by training based on registration error
- the registration error is determined based on the local category feature of the training image and multiple category features in the global category feature
- the training image The local category features include multiple category features determined according to multiple training images in the support set, and multiple category features in the local category features of the training image are used to indicate visual features of all categories in the support set
- the The support set includes some training images in some categories in the training set.
- the global category feature is obtained by training based on classification error and registration error.
- the local category feature of the training image is determined by a plurality of training images in the support set that undergoes expansion processing, and the expansion processing includes clipping, flipping, and/or data transformation processing on the image.
- the global category features are trained from the classification results of multiple training images in the training set.
- the global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set.
- the training set used in the global category training process includes images in the base category and images in the new category, which can prevent the global category features from being overfitted to the images in the base category, thereby enabling more accurate identification of the images in the new category. image.
- FIG. 9 is a schematic diagram of the hardware structure of an image classification device according to an embodiment of the present application.
- the image classification device 4000 shown in FIG. 9 includes a memory 4001, a processor 4002, a communication interface 4003, and a bus 4004. Among them, the memory 4001, the processor 4002, and the communication interface 4003 implement communication connections between each other through the bus 4004.
- the memory 4001 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
- the memory 4001 may store a program. When the program stored in the memory 4001 is executed by the processor 4002, the processor 4002 and the communication interface 4003 are used to execute each step of the image classification method of the embodiment of the present application.
- the processor 4002 may adopt a general-purpose central processing unit (central processing unit, CPU), microprocessor, application specific integrated circuit (ASIC), graphics processing unit (GPU), or one or more
- CPU central processing unit
- ASIC application specific integrated circuit
- GPU graphics processing unit
- the integrated circuit is used to execute related programs to realize the functions required by the units in the image classification device of the embodiment of the present application, or to execute the image classification method of the method embodiment of the present application.
- the processor 4002 may also be an integrated circuit chip with signal processing capability.
- each step of the image classification method in the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor 4002 or instructions in the form of software.
- the above-mentioned processor 4002 may also be a general-purpose processor, a digital signal processing (digital signal processing, DSP), an ASIC, a ready-made programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic Devices, discrete hardware components.
- the aforementioned general-purpose processor may be a microprocessor or the processor may also be any conventional processor.
- the steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
- the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers.
- the storage medium is located in the memory 4001, and the processor 4002 reads the information in the memory 4001, and combines its hardware to complete the functions required by the units included in the image classification apparatus of the embodiment of the application, or execute the image classification of the method embodiment of the application. method.
- the communication interface 4003 uses a transceiver device such as but not limited to a transceiver to implement communication between the device 4000 and other devices or a communication network.
- a transceiver device such as but not limited to a transceiver to implement communication between the device 4000 and other devices or a communication network.
- the image to be processed can be acquired through the communication interface 4003.
- the bus 4004 may include a path for transferring information between various components of the device 4000 (for example, the memory 4001, the processor 4002, and the communication interface 4003).
- FIG. 10 is a schematic diagram of the hardware structure of an image classification model training device 5000 according to an embodiment of the present application. Similar to the above device 4000, the image classification model training device 5000 shown in FIG. 10 includes a memory 5001, a processor 5002, a communication interface 5003, and a bus 5004. Among them, the memory 5001, the processor 5002, and the communication interface 5003 implement communication connections between each other through the bus 5004.
- the memory 5001 may store a program.
- the processor 5002 is configured to execute each step of the neural network training method of the embodiment of the present application.
- the processor 5002 may adopt a general-purpose CPU, a microprocessor, an ASIC, a GPU or one or more integrated circuits to execute related programs to implement the image classification model training method of the embodiment of the present application.
- the processor 5002 may also be an integrated circuit chip with signal processing capabilities.
- each step of the training method of the image classification model in the embodiment of the present application can be completed by the integrated logic circuit of hardware in the processor 5002 or instructions in the form of software.
- the image classification model is trained by the image classification model training device 5000 shown in FIG. 10, and the image classification model obtained by training can be used to execute the image classification method of the embodiment of the present application. Specifically, training the image classification model by the device 5000 can obtain the image classification model in the methods shown in FIG. 5 and FIG. 8.
- the device shown in FIG. 10 can obtain training data and the image classification model to be trained from the outside through the communication interface 5003, and then the processor trains the image classification model to be trained according to the training data.
- the device 4000 and device 5000 only show a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the device 4000 and device 5000 may also include those necessary for normal operation. Other devices. At the same time, according to specific needs, those skilled in the art should understand that the device 4000 and the device 5000 may also include hardware devices that implement other additional functions. In addition, those skilled in the art should understand that the device 4000 and the device 5000 may also only include the components necessary to implement the embodiments of the present application, and not necessarily include all the components shown in FIG. 9 and FIG. 10.
- the processor in this embodiment of the application may be a central processing unit (central processing unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (digital signal processors, DSP), and application-specific integrated circuits. (application specific integrated circuit, ASIC), ready-made programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.
- the general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
- the memory in the embodiments of the present application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory.
- the non-volatile memory can be read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), and electronic Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory.
- the volatile memory may be random access memory (RAM), which is used as an external cache.
- RAM random access memory
- static random access memory static random access memory
- DRAM dynamic random access memory
- DRAM synchronous dynamic random access memory
- Access memory synchronous DRAM, SDRAM
- double data rate synchronous dynamic random access memory double data rate SDRAM, DDR SDRAM
- enhanced synchronous dynamic random access memory enhanced SDRAM, ESDRAM
- synchronous connection dynamic random access memory Take memory (synchlink DRAM, SLDRAM) and direct memory bus random access memory (direct rambus RAM, DR RAM).
- the foregoing embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination.
- the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part.
- the computer program product includes one or more computer instructions or computer programs.
- the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part.
- the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
- the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center.
- the computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more sets of available media.
- the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium.
- the semiconductor medium may be a solid state drive.
- At least one refers to one or more, and “multiple” refers to two or more.
- the following at least one item (a)” or similar expressions refers to any combination of these items, including any combination of a single item (a) or plural items (a).
- at least one item (a) of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple .
- the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, rather than corresponding to the embodiments of the present application.
- the implementation process constitutes any limitation.
- the disclosed system, device, and method may be implemented in other ways.
- the device embodiments described above are only illustrative.
- the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented.
- the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
- the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
- each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
- the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
- the technical solution of this application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.
- the aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code .
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- Evolutionary Computation (AREA)
- Artificial Intelligence (AREA)
- General Physics & Mathematics (AREA)
- Health & Medical Sciences (AREA)
- Software Systems (AREA)
- General Health & Medical Sciences (AREA)
- Computing Systems (AREA)
- Data Mining & Analysis (AREA)
- Life Sciences & Earth Sciences (AREA)
- General Engineering & Computer Science (AREA)
- Computer Vision & Pattern Recognition (AREA)
- Molecular Biology (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Biophysics (AREA)
- Biomedical Technology (AREA)
- Medical Informatics (AREA)
- Databases & Information Systems (AREA)
- Multimedia (AREA)
- Bioinformatics & Cheminformatics (AREA)
- Bioinformatics & Computational Biology (AREA)
- Evolutionary Biology (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
- Image Analysis (AREA)
Abstract
Description
本申请要求于2019年07月24日提交中国专利局、申请号为201910672533.7、申请名称为“图像分类方法、图像分类模型的训练方法及其装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of a Chinese patent application filed with the Chinese Patent Office on July 24, 2019, the application number is 201910672533.7, and the application name is "Image Classification Method, Image Classification Model Training Method and Device", all of which are approved The reference is incorporated in this application.
本申请涉及人工智能领域,并且更具体地,涉及图像分类方法、图像分类模型的训练方法及其装置。This application relates to the field of artificial intelligence, and more specifically, to image classification methods, image classification model training methods and devices.
计算机视觉是各个应用领域,如制造业、检验、文档分析、医疗诊断,和军事等领域中各种智能/自主系统中不可分割的一部分,它是一门关于如何运用照相机/摄像机和计算机来获取我们所需的,被拍摄对象的数据与信息的学问。形象地说,就是给计算机安装上眼睛(照相机/摄像机)和大脑(算法)用来代替人眼对目标进行识别、跟踪和测量等,从而使计算机能够感知环境。因为感知可以看作是从感官信号中提取信息,所以计算机视觉也可以看作是研究如何使人工系统从图像或多维数据中“感知”的科学。总的来说,计算机视觉就是用各种成象系统代替视觉器官获取输入信息,再由计算机来代替大脑对这些输入信息完成处理和解释。计算机视觉的最终研究目标就是使计算机能像人那样通过视觉观察和理解世界,具有自主适应环境的能力。Computer vision is an inseparable part of various intelligent/autonomous systems in various application fields, such as manufacturing, inspection, document analysis, medical diagnosis, and military. It is about how to use cameras/video cameras and computers to obtain What we need is the knowledge of the data and information of the subject. Vividly speaking, it is to install eyes (camera/camcorder) and brain (algorithm) on the computer to replace the human eye to identify, track and measure the target, so that the computer can perceive the environment. Because perception can be seen as extracting information from sensory signals, computer vision can also be seen as a science that studies how to make artificial systems "perceive" from images or multi-dimensional data. Generally speaking, computer vision is to use various imaging systems to replace the visual organs to obtain input information, and then the computer replaces the brain to complete the processing and interpretation of the input information. The ultimate research goal of computer vision is to enable computers to observe and understand the world through vision like humans, and have the ability to adapt to the environment autonomously.
图像(或图片)的分类是各类图像处理应用的基础,计算机视觉常常会涉及到如何对获取到的图像进行分类的问题。随着机器学习(或深度学习)的迅速发展,机器学习算法在图像分类处理中得到了越来越广泛的应用,同时,也取得了非常好的效果,但是,机器学习算法高度依赖大量标注好的训练数据,而在很多情况下获取数据的非常困难的。The classification of images (or pictures) is the basis of various image processing applications, and computer vision often involves the problem of how to classify the acquired images. With the rapid development of machine learning (or deep learning), machine learning algorithms have been more and more widely used in image classification processing, and at the same time, they have also achieved very good results. However, machine learning algorithms are highly dependent on a large number of well-labeled The training data is very difficult to obtain in many cases.
因此,如何在训练数据不足的情况下,更好地对图像进行分类是一个亟需解决的问题。Therefore, how to better classify images when the training data is insufficient is an urgent problem to be solved.
发明内容Summary of the invention
本申请提供图像分类方法、图像分类模型的训练方法及其装置,能够更好地对图像进行分类。This application provides an image classification method, an image classification model training method and a device thereof, which can better classify images.
第一方面,提供了一种图像分类方法,该方法包括:获取待处理图像;根据预设的全局类别特征,对所述待处理图像进行分类,得到所述待处理图像的分类结果,其中,所述全局类别特征包括根据训练集中的多个训练图像训练得到的多个类别特征,所述全局类别特征中的多个类别特征用于指示所述训练集中的所有类别的视觉特征,所述训练集中的所有类别为所述训练集中的所有训练图像所属的类别,所述训练集包括基类中的图像和新类中的图像。In a first aspect, an image classification method is provided, the method comprising: obtaining an image to be processed; and classifying the image to be processed according to preset global category characteristics to obtain a classification result of the image to be processed, wherein, The global category features include multiple category features trained according to multiple training images in the training set, and multiple category features in the global category features are used to indicate visual features of all categories in the training set. All categories in the set are categories to which all training images in the training set belong, and the training set includes images in the base class and images in the new class.
上述基类可以理解为大规模训练图像集,上述基类通常包括大量用于模型训练的标注 图像,基类中的图像可以为标注图像,这里的标注图像可以指已经标注过该图像所属类别的图像。The above-mentioned base class can be understood as a large-scale training image set. The above-mentioned base class usually includes a large number of annotated images used for model training. The images in the base class can be annotated images. Here, annotated images can refer to those that have been annotated with the category of the image. image.
相应地,相对于上述基类而言,上述新类中通常包括少量标注样本,新类中的图像也可以为标注图像。也就是说,在本申请实施例中,新类为小样本,即新类中包括少量已经标注所属类别的图像。Correspondingly, with respect to the aforementioned base class, the aforementioned new class usually includes a small number of labeled samples, and the images in the new class may also be labeled images. That is to say, in this embodiment of the present application, the new class is a small sample, that is, the new class includes a small number of images that have been labeled with the category.
例如,基类包括100个类别,每个类别包括1000个(张)训练图像,新类包括5个类别,每个类别包括5个训练图像。For example, the base category includes 100 categories, each category includes 1000 training images, the new category includes 5 categories, and each category includes 5 training images.
在本申请中,全局类别特征是由训练集中的多个训练图像训练得到的,所述全局类别特征包括能够指示训练集中的所有类别对应的视觉特征的多个类别特征,同时,由于所述全局类别训练过程使用的训练集包括基类中的图像和新类中的图像,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the global category features are obtained by training multiple training images in the training set. The global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set. At the same time, because the global The training set used in the category training process includes the images in the base category and the images in the new category, which can prevent the global category features from being overfitted to the images in the base category, so that images in the new category can be identified more accurately.
可选地,本申请中的图像分类模型,可以基于多阶段训练(episodic training)的策略进行模型训练。例如,可以将模型训练过程分为多个训练阶段(training episode),在每个训练阶段中,可以随机抽取训练集中的几个类别来训练模型,最终,经过多个训练阶段,完成对模型的训练。Optionally, the image classification model in this application may be trained based on a multi-stage training (episodic training) strategy. For example, the model training process can be divided into multiple training stages (training episodes). In each training stage, several categories in the training set can be randomly selected to train the model. Finally, after multiple training stages, the model is completed training.
具体地,在模型训练过程中的多个训练阶段中,都可以对所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Specifically, in multiple training stages in the model training process, the global category features can be updated, so that the global category features obtained by training can have better consistency. At the same time, the training set includes the base class The images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
结合第一方面,在第一方面的某些实现方式中,所述根据预设的全局类别特征,对所述待处理图像进行分类,得到所述待处理图像的分类结果,包括:提取所述待处理图像的特征向量;根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度,所述候选类别为所述全局类别特征指示的多个类别中的一个或多个;根据所述置信度,从所述候选类别中确定出所述待处理图像的分类结果。With reference to the first aspect, in some implementations of the first aspect, the classifying the to-be-processed image according to preset global category features to obtain the classification result of the to-be-processed image includes: extracting the The feature vector of the image to be processed; according to the feature vector of the image to be processed, the confidence that the image to be processed belongs to a candidate category is determined, the candidate category being one or more of the multiple categories indicated by the global category feature A; According to the confidence, the classification result of the image to be processed is determined from the candidate category.
结合第一方面,在第一方面的某些实现方式中,在所述根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度之前,所述方法还包括:根据所述待处理图像的支持集,确定所述待处理图像的局部类别特征;根据所述待处理图像的局部类别特征及所述全局类别特征,确定所述候选类别;其中,所述待处理图像的支持集包括多个图像,所述多个图像所属的类别为所述全局类别特征指示的多个类别中的一个或多个。With reference to the first aspect, in some implementations of the first aspect, before the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed, the method further includes: The support set of the image to be processed determines the local category feature of the image to be processed; the candidate category is determined according to the local category feature of the image to be processed and the global category feature; wherein, the image to be processed The support set of includes multiple images, and the category to which the multiple images belong is one or more of the multiple categories indicated by the global category feature.
结合第一方面,在第一方面的某些实现方式中,所述根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度,包括:根据所述待处理图像的特征向量,确定所述待处理图像的特征向量与所述候选类别中的每个类别对应的特征向量的距离;根据所述距离,确定所述待处理图像属于所述候选类别的所述置信度。With reference to the first aspect, in some implementations of the first aspect, the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed includes: Feature vector, determining the distance between the feature vector of the image to be processed and the feature vector corresponding to each of the candidate categories; determining the confidence that the image to be processed belongs to the candidate category according to the distance .
结合第一方面,在第一方面的某些实现方式中,所述根据所述置信度,从所述候选类别中确定出所述待处理图像的分类结果,包括:将所述候选类别中所述置信度最大的类别,确定为所述待处理图像的分类结果。With reference to the first aspect, in some implementations of the first aspect, the determining the classification result of the image to be processed from the candidate category according to the confidence level includes: The category with the greatest confidence is determined as the classification result of the image to be processed.
结合第一方面,在第一方面的某些实现方式中,所述全局类别特征是根据分类误差训练得到的,所述分类误差是根据问询集中的训练图像的分类结果及所述问询集中的训练图 像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别,所述问询集包括所述训练集中的部分类别中的部分训练图像。With reference to the first aspect, in some implementations of the first aspect, the global category feature is obtained by training based on a classification error, and the classification error is based on the classification result of the training image in the query set and the query set The training image is determined by a pre-labeled label, the label is used to indicate the category to which the training image belongs, and the query set includes part of the training images in the partial categories in the training set.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,根据所述分类误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. According to the classification error, the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
进一步地,在模型训练过程中的多个训练阶段中,都可以使用当前训练阶段的分类误差对所述全局类别特征进行更新,同时,训练集中包括基类中的图像和新类中的图像,新类在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Further, in multiple training stages in the model training process, the classification error of the current training stage can be used to update the global category features. At the same time, the training set includes images in the base class and images in the new class. The effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can avoid the overfitting of the trained image classification model to the base class. According to the image classification model, the image to be processed can be classified, which can get better The result of image classification.
结合第一方面,在第一方面的某些实现方式中,所述全局类别特征是根据分类误差及配准误差训练得到的,所述分类误差是根据问询集中的训练图像的分类结果及所述问询集中的训练图像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别,所述问询集包括所述训练集中的部分类别中的部分训练图像,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,所述训练图像的局部类别特征中的多个类别特征用于指示所述支持集中的所有类别的视觉特征,所述支持集包括所述训练集中的部分类别中的部分训练图像。With reference to the first aspect, in some implementations of the first aspect, the global category feature is obtained by training based on classification error and registration error, and the classification error is based on the classification result and the result of the training image in the query set. The pre-labeled training image in the question set is determined, the label is used to indicate the category to which the training image belongs, the question set includes some training images in some categories in the training set, and the configuration The quasi-error is determined based on the local category feature of the training image and multiple category features in the global category feature. The local category feature of the training image includes multiple category features determined from multiple training images in the support set. The multiple category features in the local category features of the training image are used to indicate the visual features of all categories in the support set, and the support set includes part of the training images in the partial categories in the training set.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,根据所述分类误差及所述配准误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. The registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
进一步地,在模型训练过程中的多个训练阶段中,都可以使用当前训练阶段的分类误差及配准误差对所述全局类别特征进行更新,同时,训练集中包括基类中的图像和新类中的图像,新类在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Further, in multiple training stages in the model training process, the classification error and registration error of the current training stage can be used to update the global category features. At the same time, the training set includes the images in the base category and the new category. The effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can prevent the image classification model obtained by training from overfitting to the base class, and classify the image to be processed according to the image classification model. Can get better image classification results.
结合第一方面,在第一方面的某些实现方式中,所述训练图像的局部类别特征是由经过扩充处理的所述支持集中的多个训练图像确定的,所述扩充处理包括对图像进行剪裁处理、翻转处理和/或数据幻化处理。With reference to the first aspect, in some implementations of the first aspect, the local category feature of the training image is determined by multiple training images in the support set that have undergone expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
上述支持集中的多个训练图像是新类中的图像。The multiple training images in the above support set are images in the new class.
在本申请中,通过剪裁处理、翻转处理和/或数据幻化处理对新类中的多个训练图像进行扩充处理,以增加新类中的训练图像的数量,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。In this application, multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided The model is overfitted to the base class, and the image to be processed is classified according to the image classification model, which can obtain better image classification results.
第二方面,提供了一种图像分类模型的训练方法,该方法包括:获取训练集中的多个 训练图像,其中,所述训练集包括支持集和训练集,所述多个训练图像包括所述支持集中的多个训练图像和所述问询集中的多个训练图像;根据预设的第一神经网络,提取所述问询集中的多个训练图像的特征向量,所述问询集包括所述训练集中的部分类别中的部分图像;根据预设的第二神经网络和预设的全局类别特征,对所述问询集中的多个训练图像的特征向量进行处理,得到所述问询集中的多个训练图像的分类结果,其中,所述全局类别特征包括多个类别特征,所述全局类别特征中的多个类别特征用于指示所述训练集中的所有类别的视觉特征,所述训练集中的所有类别为所述训练集中的所有训练图像所属的类别,所述训练集包括基类中的图像和新类中的图像;根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征。In a second aspect, a method for training an image classification model is provided. The method includes: acquiring a plurality of training images in a training set, wherein the training set includes a support set and a training set, and the plurality of training images includes the Support multiple training images in the set and multiple training images in the query set; according to the preset first neural network, extract feature vectors of the multiple training images in the query set, and the query set includes all Part of the images in the partial categories in the training set; according to the preset second neural network and preset global category features, the feature vectors of the multiple training images in the query set are processed to obtain the query set The classification result of the multiple training images of, wherein the global category feature includes multiple category features, and the multiple category features in the global category feature are used to indicate the visual features of all categories in the training set, and the training All categories in the set are the categories to which all the training images in the training set belong. The training set includes images in the base class and images in the new class; according to the classification results of multiple training images in the query set, update The global category characteristics.
上述基类可以理解为大规模训练图像集,上述基类通常包括大量用于模型训练的标注图像,基类中的图像可以为标注图像,这里的标注图像可以指已经标注过该图像所属类别的图像。The above-mentioned base class can be understood as a large-scale training image set. The above-mentioned base class usually includes a large number of annotated images used for model training. The images in the base class can be annotated images. Here, annotated images can refer to those that have been annotated with the category of the image. image.
相应地,相对于上述基类而言,上述新类中通常包括少量标注样本,新类中的图像也可以为标注图像。也就是说,在本申请实施例中,新类为小样本,即新类中包括少量已经标注所属类别的图像。Correspondingly, with respect to the aforementioned base class, the aforementioned new class usually includes a small number of labeled samples, and the images in the new class may also be labeled images. That is to say, in this embodiment of the present application, the new class is a small sample, that is, the new class includes a small number of images that have been labeled with the category.
例如,基类包括100个类别,每个类别包括1000个(张)训练图像,新类包括5个类别,每个类别包括5个训练图像。For example, the base category includes 100 categories, each category includes 1000 training images, the new category includes 5 categories, and each category includes 5 training images.
在本申请中,全局类别特征是由训练集中的训练图像的分类结果训练得到的,所述全局类别特征包括能够指示训练集中的所有类别对应的视觉特征的多个类别特征,同时,由于所述全局类别训练过程使用的训练集包括基类中的图像和新类中的图像,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the global category features are trained from the classification results of the training images in the training set, and the global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set. The training set used in the global category training process includes images in the base category and images in the new category, which can prevent the global category features from being overfitted to the images in the base category, so that images in the new category can be identified more accurately.
可选地,本申请中的图像分类模型的训练方法,可以基于多阶段训练(episodic training)的策略对模型进行训练。例如,可以将模型训练过程分为多个训练阶段(training episode),在每个训练阶段中,可以随机抽取训练集中的几个类别来训练模型,最终,经过多个训练阶段,完成对模型的训练。Optionally, the training method of the image classification model in this application can train the model based on a multi-stage training (episodic training) strategy. For example, the model training process can be divided into multiple training stages (training episodes). In each training stage, several categories in the training set can be randomly selected to train the model. Finally, after multiple training stages, the model is completed training.
具体地,在模型训练过程中的多个训练阶段中,都可以对所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Specifically, in multiple training stages in the model training process, the global category features can be updated, so that the global category features obtained by training can have better consistency. At the same time, the training set includes the base class The images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
可选地,可以提取所述支持集中的多个训练图像的特征向量和所述问询集中的多个训练图像的特征向量。Optionally, feature vectors of multiple training images in the support set and feature vectors of multiple training images in the query set may be extracted.
结合第二方面,在第二方面的某些实现方式中,所述根据预设的第二神经网络和预设的全局类别特征,对所述问询集中的多个训练图像的特征向量进行处理,得到所述问询集中的多个训练图像的分类结果,包括:提取所述支持集中的多个训练图像的特征向量,所述支持集包括所述训练集中的部分类别中的部分训练图像;根据所述支持集中的多个训练图像的特征向量,确定训练图像的局部类别特征,所述训练图像的局部类别特征中的多个类别特征用于指示所述支持集中的所有类别的视觉特征,所述支持集包括所述训练集中的部分类别中的部分训练图像;根据所述第二神经网络、所述训练图像的局部类别特征及所 述全局类别特征,确定所述问询集中的多个训练图像的分类结果。With reference to the second aspect, in some implementations of the second aspect, the feature vectors of multiple training images in the query set are processed according to a preset second neural network and preset global category features , Obtaining classification results of the multiple training images in the query set includes: extracting feature vectors of the multiple training images in the support set, the support set including part of the training images in the partial categories in the training set; Determine the local category features of the training images according to the feature vectors of the multiple training images in the support set, where multiple category features in the local category features of the training images are used to indicate visual features of all categories in the support set, The support set includes part of the training images in the partial categories in the training set; according to the second neural network, the local category feature of the training image, and the global category feature, determine a plurality of the query set The classification result of the training image.
结合第二方面,在第二方面的某些实现方式中,所述根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征,包括:根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征、所述第一神经网络及所述第二神经网络。With reference to the second aspect, in some implementations of the second aspect, the updating the global category feature according to the classification results of the multiple training images in the query set includes: Update the global category feature, the first neural network and the second neural network for the classification results of the training images.
结合第二方面,在第二方面的某些实现方式中,所述根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征,包括:根据分类误差,更新所述全局类别特征,所述分类误差是根据所述问询集中的多个训练图像的分类结果及所述问询集中的多个训练图像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别。With reference to the second aspect, in some implementations of the second aspect, the updating the global category feature according to the classification results of the multiple training images in the query set includes: updating the global The category feature, the classification error is determined based on the classification results of the multiple training images in the query set and the pre-labeled tags of the multiple training images in the query set, and the tags are used to indicate the training images The category it belongs to.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,根据所述分类误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. According to the classification error, the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
进一步地,在模型训练过程中的多个训练阶段中,都可以使用当前训练阶段的分类误差对所述全局类别特征进行更新,同时,训练集中包括基类中的图像和新类中的图像,新类在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Further, in multiple training stages in the model training process, the classification error of the current training stage can be used to update the global category features. At the same time, the training set includes images in the base class and images in the new class. The effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can avoid the overfitting of the trained image classification model to the base class. According to the image classification model, the image to be processed can be classified, which can get better The result of image classification.
结合第二方面,在第二方面的某些实现方式中,所述根据所述多个训练图像的分类结果,更新所述全局类别特征,包括:根据所述分类误差及配准误差,更新所述全局类别特征,其中,所述配准误差是根据所述训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的。With reference to the second aspect, in some implementations of the second aspect, the updating the global category feature according to the classification results of the multiple training images includes: updating all the features according to the classification error and the registration error The global category feature, wherein the registration error is determined according to a local category feature of the training image and multiple category features in the global category feature.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,根据所述分类误差及所述配准误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. The registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
进一步地,在模型训练过程中的多个训练阶段中,都可以使用当前训练阶段的分类误差及配准误差对所述全局类别特征进行更新,同时,训练集中包括基类中的图像和新类中的图像,新类在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Further, in multiple training stages in the model training process, the classification error and registration error of the current training stage can be used to update the global category features. At the same time, the training set includes the images in the base category and the new category. The effect of the new class in the training process can be continuously accumulated with the global category features. Therefore, it can prevent the image classification model obtained by training from overfitting to the base class, and classify the image to be processed according to the image classification model. Can get better image classification results.
结合第二方面,在第二方面的某些实现方式中,所述训练图像的局部类别特征是由经过扩充处理的所述支持集中的多个训练图像确定的,所述扩充处理包括对图像进行剪裁处理、翻转处理和/或数据幻化处理。With reference to the second aspect, in some implementations of the second aspect, the local category feature of the training image is determined by a plurality of training images in the support set after expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
上述支持集中的多个训练图像是新类中的图像。The multiple training images in the above support set are images in the new class.
在本申请中,通过剪裁处理、翻转处理和/或数据幻化处理对新类中的多个训练图像进行扩充处理,以增加新类中的训练图像的数量,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类 结果。In this application, multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided The model is overfitted to the base class, and the image to be processed is classified according to the image classification model, which can obtain better image classification results.
第三方面,提供了一种图像分类装置,包括:获取模块,用于获取待处理图像;分类模块,用于根据预设的全局类别特征,对所述待处理图像进行分类,得到所述待处理图像的分类结果,其中,所述全局类别特征包括根据训练集中的多个训练图像训练得到的多个类别特征,所述全局类别特征中的多个类别特征用于指示所述训练集中的所有类别的视觉特征,所述训练集中的所有类别为所述训练集中的所有训练图像所属的类别,所述训练集包括基类中的图像和新类中的图像。In a third aspect, an image classification device is provided, including: an acquisition module for acquiring an image to be processed; a classification module for classifying the image to be processed according to preset global category features to obtain the image to be processed Process the classification result of the image, wherein the global category feature includes multiple category features trained according to multiple training images in the training set, and the multiple category features in the global category feature are used to indicate all the categories in the training set. Visual features of the category, all categories in the training set are categories to which all training images in the training set belong, and the training set includes images in the base category and images in the new category.
在本申请实施例中,图像分类装置中的全局类别特征是由训练集中的多个训练图像训练得到的,所述全局类别特征包括能够指示训练集中的所有类别对应的视觉特征的多个类别特征,同时,由于所述全局类别训练过程使用的训练集包括基类中的图像和新类中的图像,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In the embodiment of the present application, the global category feature in the image classification device is obtained by training multiple training images in the training set, and the global category feature includes multiple category features that can indicate visual features corresponding to all categories in the training set. At the same time, since the training set used in the global category training process includes the images in the base category and the images in the new category, it can prevent the global category features from being over-fitted to the images in the base category, thereby enabling more accurate recognition Images in the new category.
具体地,在模型训练过程中的多个训练阶段中,都可以对图像分类装置中的所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类装置过拟合到基类,根据该图像分类装置对待处理图像进行分类,能够得到更好的图像分类结果。Specifically, in multiple training stages in the model training process, the global category features in the image classification device can be updated, so that the global category features obtained by training can have better consistency. At the same time, training The collection includes the images in the base class and the images in the new class. The effect of the new class (training image in) during the training process can be accumulated with the global category features, so it can avoid the training of the image classification device from over-fitting Combine it into the base class and classify the image to be processed according to the image classification device, which can obtain better image classification results.
结合第三方面,在第三方面的某些实现方式中,所述分类模块具体用于:提取所述待处理图像的特征向量;根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度,所述候选类别为所述全局类别特征指示的多个类别中的一个或多个;根据所述置信度,从所述候选类别中确定出所述待处理图像的分类结果。With reference to the third aspect, in some implementations of the third aspect, the classification module is specifically configured to: extract a feature vector of the image to be processed; and determine the image to be processed according to the feature vector of the image to be processed Confidence that belongs to a candidate category, where the candidate category is one or more of the multiple categories indicated by the global category feature; according to the confidence, the category of the image to be processed is determined from the candidate category result.
结合第三方面,在第三方面的某些实现方式中,所述装置还包括确定模块,用于:根据所述待处理图像的支持集,确定所述待处理图像的局部类别特征;根据所述待处理图像的局部类别特征及所述全局类别特征,确定所述候选类别;其中,所述待处理图像的支持集包括多个图像,所述多个图像所属的类别为所述全局类别特征指示的多个类别中的一个或多个。With reference to the third aspect, in some implementations of the third aspect, the device further includes a determining module, configured to: determine the local category characteristics of the image to be processed according to the support set of the image to be processed; The local category feature of the image to be processed and the global category feature to determine the candidate category; wherein the support set of the image to be processed includes multiple images, and the category to which the multiple images belong is the global category feature One or more of the indicated categories.
结合第三方面,在第三方面的某些实现方式中,所述分类模块具体用于:根据所述待处理图像的特征向量,确定所述待处理图像的特征向量与所述候选类别中的每个类别对应的特征向量的距离;根据所述距离,确定所述待处理图像属于所述候选类别的所述置信度。With reference to the third aspect, in some implementations of the third aspect, the classification module is specifically configured to: determine the feature vector of the image to be processed and the candidate category according to the feature vector of the image to be processed The distance of the feature vector corresponding to each category; according to the distance, the confidence that the image to be processed belongs to the candidate category is determined.
结合第三方面,在第三方面的某些实现方式中,所述分类模块具体用于:将所述候选类别中所述置信度最大的类别,确定为所述待处理图像的分类结果。With reference to the third aspect, in some implementation manners of the third aspect, the classification module is specifically configured to: determine the category with the greatest confidence among the candidate categories as the classification result of the image to be processed.
结合第三方面,在第三方面的某些实现方式中,所述全局类别特征是根据分类误差训练得到的,所述分类误差是根据问询集中的训练图像的分类结果及所述问询集中的训练图像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别,所述问询集包括所述训练集中的部分类别中的部分训练图像。With reference to the third aspect, in some implementations of the third aspect, the global category feature is obtained by training based on a classification error, and the classification error is based on the classification result of the training image in the query set and the query set The training image is determined by a pre-labeled label, the label is used to indicate the category to which the training image belongs, and the query set includes part of the training images in the partial categories in the training set.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,根据所述分类误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. According to the classification error, the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
结合第三方面,在第三方面的某些实现方式中,所述全局类别特征是根据分类误差及配准误差训练得到的,所述分类误差是根据问询集中的训练图像的分类结果及所述问询集中的训练图像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别,所述问询集包括所述训练集中的部分类别中的部分训练图像,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,所述训练图像的局部类别特征中的多个类别特征用于指示所述支持集中的所有类别的视觉特征,所述支持集包括所述训练集中的部分类别中的部分训练图像。With reference to the third aspect, in some implementations of the third aspect, the global category feature is obtained by training based on classification errors and registration errors, and the classification error is based on the classification results and the results of the training images in the query set. The pre-labeled training image in the question set is determined, the label is used to indicate the category to which the training image belongs, the question set includes some training images in some categories in the training set, and the configuration The quasi-error is determined based on the local category feature of the training image and multiple category features in the global category feature. The local category feature of the training image includes multiple category features determined from multiple training images in the support set. The multiple category features in the local category features of the training image are used to indicate the visual features of all categories in the support set, and the support set includes part of the training images in the partial categories in the training set.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,根据所述分类误差及所述配准误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. The registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
结合第三方面,在第三方面的某些实现方式中,所述训练图像的局部类别特征是由经过扩充处理的所述支持集中的多个训练图像确定的,所述扩充处理包括对图像进行剪裁处理、翻转处理和/或数据幻化处理。With reference to the third aspect, in some implementations of the third aspect, the local category feature of the training image is determined by multiple training images in the support set that have undergone expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
上述支持集中的多个训练图像是新类中的图像。The multiple training images in the above support set are images in the new class.
在本申请中,通过剪裁处理、翻转处理和/或数据幻化处理对新类中的多个训练图像进行扩充处理,以增加新类中的训练图像的数量,因此,能够避免训练得到的图像分类装置过拟合到基类,根据该图像分类装置对待处理图像进行分类,能够得到更好的图像分类结果。In this application, multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided The device is overfitted to the base class, and the image to be processed is classified according to the image classification device, which can obtain better image classification results.
第四方面,提供了一种图像分类模型的训练装置,包括:获取模块,用于获取训练集中的多个训练图像,其中,所述训练集包括支持集和训练集,所述多个训练图像包括所述支持集中的多个训练图像和所述问询集中的多个训练图像;特征提取模块,用于根据预设的第一神经网络,提取所述问询集中的多个训练图像的特征向量,所述问询集包括所述训练集中的部分类别中的部分图像;分类模块,用于根据预设的第二神经网络和预设的全局类别特征,对所述问询集中的多个训练图像的特征向量进行处理,得到所述问询集中的多个训练图像的分类结果,其中,所述全局类别特征包括多个类别特征,所述全局类别特征中的多个类别特征用于指示所述训练集中的所有类别的视觉特征,所述训练集中的所有类别为所述训练集中的所有训练图像所属的类别,所述训练集包括基类中的图像和新类中的图像;更新模块,用于根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征。In a fourth aspect, a training device for an image classification model is provided, which includes: an acquisition module for acquiring multiple training images in a training set, wherein the training set includes a support set and a training set, and the multiple training images Including multiple training images in the support set and multiple training images in the query set; a feature extraction module for extracting features of multiple training images in the query set according to a preset first neural network Vector, the question set includes part of images in the partial categories in the training set; the classification module is used to compare the plurality of images in the question set according to the preset second neural network and the preset global category features The feature vectors of the training images are processed to obtain classification results of multiple training images in the query set, wherein the global category features include multiple category features, and the multiple category features in the global category features are used to indicate Visual features of all categories in the training set, all categories in the training set are categories to which all training images in the training set belong, and the training set includes images in the base class and images in the new class; update module , Used to update the global category feature according to the classification results of the multiple training images in the query set.
在本申请中,全局类别特征是由训练集中的多个训练图像的分类结果训练得到的,所述全局类别特征包括能够指示训练集中的所有类别对应的视觉特征的多个类别特征,同时,由于所述全局类别训练过程使用的训练集包括基类中的图像和新类中的图像,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the global category features are trained from the classification results of multiple training images in the training set. The global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set. At the same time, because The training set used in the global category training process includes images in the base category and images in the new category, which can prevent the global category features from being overfitted to the images in the base category, thereby enabling more accurate identification of the images in the new category. image.
具体地,在模型训练过程中的多个训练阶段中,都可以对所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的 图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Specifically, in multiple training stages in the model training process, the global category features can be updated, so that the global category features obtained by training can have better consistency. At the same time, the training set includes the base class The images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
结合第四方面,在第四方面的某些实现方式中,所述分类模块具体用于:提取所述支持集中的多个训练图像的特征向量,所述支持集包括所述训练集中的部分类别中的部分训练图像;根据所述支持集中的多个训练图像的特征向量,确定训练图像的局部类别特征,所述训练图像的局部类别特征中的多个类别特征用于指示所述支持集中的所有类别的视觉特征,所述支持集包括所述训练集中的部分类别中的部分训练图像;根据所述第二神经网络、所述训练图像的局部类别特征及所述全局类别特征,确定所述问询集中的多个训练图像的分类结果。With reference to the fourth aspect, in some implementations of the fourth aspect, the classification module is specifically configured to: extract feature vectors of multiple training images in the support set, and the support set includes partial categories in the training set Part of the training images in the support set; determine the local category features of the training images according to the feature vectors of the multiple training images in the support set, and the multiple category features in the local category features of the training images are used to indicate the support set Visual features of all categories, the support set includes part of the training images in the partial categories in the training set; according to the second neural network, the local category features of the training images, and the global category features, the Ask the classification results of multiple training images in the set.
结合第四方面,在第四方面的某些实现方式中,所述更新模块具体用于:根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征、所述第一神经网络及所述第二神经网络。With reference to the fourth aspect, in some implementation manners of the fourth aspect, the update module is specifically configured to: update the global category feature, the first A neural network and the second neural network.
结合第四方面,在第四方面的某些实现方式中,所述更新模块具体用于:根据分类误差,更新所述全局类别特征,所述分类误差是根据所述问询集中的多个训练图像的分类结果及所述问询集中的多个训练图像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别。With reference to the fourth aspect, in some implementations of the fourth aspect, the update module is specifically configured to: update the global category feature according to a classification error, and the classification error is based on multiple trainings in the query set The classification result of the image and the pre-labeled labels of the multiple training images in the query set are determined, and the labels are used to indicate the category to which the training image belongs.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,根据所述分类误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. According to the classification error, the global category feature is updated to avoid the overfitting of the global category feature to the image in the base category, so that the image in the new category can be identified more accurately.
结合第四方面,在第四方面的某些实现方式中,所述更新模块具体用于:根据所述分类误差及配准误差,更新所述全局类别特征,其中,所述配准误差是根据所述训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的。With reference to the fourth aspect, in some implementations of the fourth aspect, the update module is specifically configured to: update the global category feature according to the classification error and the registration error, wherein the registration error is based on The local category feature of the training image and the multiple category features of the global category feature are determined.
在本申请中,所述分类误差是根据问询集中的训练图像的分类结果及所述训练图像预先标注的标签确定的,所述问询集中的训练图像包括基类中的图像和新类中的图像,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,根据所述分类误差及所述配准误差更新所述全局类别特征,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the classification error is determined based on the classification results of the training images in the query set and the pre-labeled labels of the training images. The training images in the query set include images in the base class and images in the new class. The registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, and the local category feature of the training image includes the determination based on multiple training images in the support set Multiple category features, update the global category features according to the classification error and the registration error, which can prevent the global category features from being over-fitted to the images in the base class, so that the new class can be more accurately identified image.
结合第四方面,在第四方面的某些实现方式中,所述训练图像的局部类别特征是由经过扩充处理的所述支持集中的多个训练图像确定的,所述扩充处理包括对图像进行剪裁处理、翻转处理和/或数据幻化处理。With reference to the fourth aspect, in some implementations of the fourth aspect, the local category feature of the training image is determined by multiple training images in the support set that have undergone expansion processing, and the expansion processing includes performing an image Tailoring, flipping, and/or data transformation.
上述支持集中的多个训练图像是新类中的图像。The multiple training images in the above support set are images in the new class.
在本申请中,通过剪裁处理、翻转处理和/或数据幻化处理对新类中的多个训练图像进行扩充处理,以增加新类中的训练图像的数量,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。In this application, multiple training images in the new class are expanded through cropping, flipping, and/or data illusion processing to increase the number of training images in the new class. Therefore, the training image classification can be avoided The model is overfitted to the base class, and the image to be processed is classified according to the image classification model, which can obtain better image classification results.
第五方面,提供了一种图像分类装置,该装置包括:存储器,用于存储程序;处理器, 用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行上述第一方面中的任意一种实现方式中的方法。In a fifth aspect, an image classification device is provided. The device includes: a memory for storing a program; a processor for executing the program stored in the memory. When the program stored in the memory is executed, the processing The device is used to execute the method in any one of the foregoing first aspects.
第六方面,提供了一种图像分类模型的训练装置,该装置包括:存储器,用于存储程序;处理器,用于执行所述存储器存储的程序,当所述存储器存储的程序被执行时,所述处理器用于执行上述第二方面中的任意一种实现方式中的方法。In a sixth aspect, an image classification model training device is provided. The device includes: a memory for storing a program; a processor for executing the program stored in the memory, and when the program stored in the memory is executed, The processor is configured to execute the method in any one of the foregoing second aspect.
上述第五方面和第六方面中的处理器既可以是中央处理器(central processing unit,CPU),也可以是CPU与神经网络运算处理器的组合,这里的神经网络运算处理器可以包括图形处理器(graphics processing unit,GPU)、神经网络处理器(neural-network processing unit,NPU)和张量处理器(tensor processing unit,TPU)等等。其中,TPU是谷歌(google)为机器学习全定制的人工智能加速器专用集成电路。The processors in the fifth and sixth aspects described above can be either a central processing unit (CPU), or a combination of a CPU and a neural network computing processor, where the neural network computing processor can include graphics processing GPU (graphics processing unit, GPU), neural-network processing unit (NPU), tensor processing unit (TPU), etc. Among them, TPU is an artificial intelligence accelerator application specific integrated circuit fully customized by Google for machine learning.
第七方面,提供一种计算机可读介质,该计算机可读介质存储用于设备执行的程序代码,该程序代码包括用于执行第一方面或第二方面中的任意一种实现方式中的方法。In a seventh aspect, a computer-readable medium is provided, and the computer-readable medium stores program code for device execution. The program code includes a method for executing any one of the first aspect or the second aspect. .
第八方面,提供一种包含指令的计算机程序产品,当该计算机程序产品在计算机上运行时,使得计算机执行上述第一方面或第二方面中的任意一种实现方式中的方法。In an eighth aspect, a computer program product containing instructions is provided, when the computer program product runs on a computer, the computer executes the method in any one of the foregoing first aspect or second aspect.
第九方面,提供一种芯片,所述芯片包括处理器与数据接口,所述处理器通过所述数据接口读取存储器上存储的指令,执行上述第一方面或第二方面中的任意一种实现方式中的方法。In a ninth aspect, a chip is provided, the chip includes a processor and a data interface, the processor reads instructions stored in a memory through the data interface, and executes any one of the first aspect or the second aspect above The method in the implementation mode.
可选地,作为一种实现方式,所述芯片还可以包括存储器,所述存储器中存储有指令,所述处理器用于执行所述存储器上存储的指令,当所述指令被执行时,所述处理器用于执行第一方面或第二方面中的任意一种实现方式中的方法。Optionally, as an implementation manner, the chip may further include a memory in which instructions are stored, and the processor is configured to execute the instructions stored in the memory. When the instructions are executed, the The processor is configured to execute the method in any one of the implementation manners of the first aspect or the second aspect.
上述芯片具体可以是现场可编程门阵列(field-programmable gate array,FPGA)或者专用集成电路(application-specific integrated circuit,ASIC)。The aforementioned chip may specifically be a field-programmable gate array (FPGA) or an application-specific integrated circuit (ASIC).
第十方面,提供了一种电子设备,该电子设备包括上述第三方面中的任意一个方面中的图像分类装置,或者,该电子设备包括上述第四方面中的任意一个方面中的图像分类模型的训练装置。In a tenth aspect, an electronic device is provided, the electronic device includes the image classification device in any one of the foregoing third aspects, or the electronic device includes the image classification model in any one of the foregoing fourth aspects Training device.
当上述电子设备包括上述第三方面中的任意一个方面中的图像分类装置时,该电子设备具体可以是终端设备。When the above electronic device includes the image classification apparatus in any one of the above third aspects, the electronic device may specifically be a terminal device.
当上述电子设备包括上述第四方面中的任意一个方面中的图像分类模型的训练装置时,该电子设备具体可以是服务器。When the above electronic device includes the image classification model training device in any one of the above fourth aspects, the electronic device may specifically be a server.
在本申请中,在模型训练过程中的多个训练阶段中,都可以对所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够更准确的识别新类中的图像。In this application, in multiple training stages in the model training process, the global category features can be updated, so that the global category features obtained by training can have better consistency. At the same time, the training set includes the base The images in the class and the images in the new class. The effect of the new class (training image in) during the training process can be accumulated with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base Class, according to the image classification model to classify the image to be processed, can more accurately identify the image in the new class.
图1是本申请实施例提供的系统架构的结构示意图。Fig. 1 is a schematic structural diagram of a system architecture provided by an embodiment of the present application.
图2是本申请实施例提供的卷积神经网络模型的示意性框图。Fig. 2 is a schematic block diagram of a convolutional neural network model provided by an embodiment of the present application.
图3是本申请实施例提供的一种芯片硬件结构示意图。Fig. 3 is a schematic diagram of a chip hardware structure provided by an embodiment of the present application.
图4是本申请实施例提供的一种应用场景示意图。Fig. 4 is a schematic diagram of an application scenario provided by an embodiment of the present application.
图5是本申请一个实施例提供的图像分类模型的训练方法的示意性流程图。Fig. 5 is a schematic flowchart of a method for training an image classification model provided by an embodiment of the present application.
图6是本申请一个实施例提供的图像分类模型的训练方法的示意性框图。Fig. 6 is a schematic block diagram of a method for training an image classification model provided by an embodiment of the present application.
图7是本申请另一个实施例提供的图像分类模型的训练方法的示意性流程图。FIG. 7 is a schematic flowchart of a method for training an image classification model provided by another embodiment of the present application.
图8是本申请一个实施例提供的图像分类方法的示意性流程图。FIG. 8 is a schematic flowchart of an image classification method provided by an embodiment of the present application.
图9是本申请实施例的图像分类装置的硬件结构示意图。FIG. 9 is a schematic diagram of the hardware structure of an image classification device according to an embodiment of the present application.
图10是本申请实施例的图像分类模型的训练装置的硬件结构示意图。FIG. 10 is a schematic diagram of the hardware structure of an image classification model training device according to an embodiment of the present application.
下面将结合附图,对本申请中的技术方案进行描述。The technical solution in this application will be described below in conjunction with the drawings.
本申请实施例提供的图像分类方法能够应用在图片检索、相册管理、平安城市、人机交互以及其他需要进行图像分类或者图像识别的场景。应理解,本申请实施例中的图像可以为静态图像(或称为静态画面)或动态图像(或称为动态画面),例如,本申请中的图像可以为视频或动态图片,或者,本申请中的图像也可以为静态图片或照片。为了便于描述,本申请在下述实施例中将静态图像或动态图像统一称为图像。The image classification method provided by the embodiments of the present application can be applied to image retrieval, album management, safe city, human-computer interaction, and other scenes that require image classification or image recognition. It should be understood that the images in the embodiments of this application may be static images (or called static pictures) or dynamic images (or called dynamic pictures). For example, the images in this application may be videos or dynamic pictures, or The images in can also be static pictures or photos. For ease of description, in the following embodiments of the present application, static images or dynamic images are collectively referred to as images.
具体而言,本申请实施例的图像分类方法可以具体应用到相册分类和拍照识别场景中,下面对这两种场景进行详细的介绍。Specifically, the image classification method of the embodiment of the present application can be specifically applied to album classification and photo recognition scenes, and these two scenes are described in detail below.
相册分类:Album category:
用户在手机和云盘上存储了大量图片,按照类别对相册进行分类管理能提高用户的体验。利用本申请实施例的图像分类方法对相册中的图片进行分类,能够得到按照类别进行排列或者存储的相册。本申请实施例的图像分类方法可以方便用户对不同的物体类别进行分类管理,从而方便用户的查找,能够节省用户的管理时间,提高相册管理的效率。Users store a large number of pictures on mobile phones and cloud disks, and sorting and managing albums according to categories can improve user experience. Using the image classification method of the embodiment of the present application to classify pictures in an album, it is possible to obtain albums arranged or stored according to categories. The image classification method of the embodiment of the present application can facilitate the user to classify and manage different object categories, thereby facilitating the user's search, saving the user's management time, and improving the efficiency of album management.
具体地,在采用本申请实施例的图像分类方法进行相册分类时,可以先提取相册中图片的图片特征,然后再根据提取到的图片特征对相册中的图片进行分类,得到图片的分类结果,接下来,再根据图片的分类结果对相册中的图片进行分类,得到按照图片类别进行排列的相册。其中,在根据图片类别对相册中的图片进行排列时,可以将属于同一类的图片排列在一行或者一行。例如,在最终得到的相册中,第一行的图片都属于飞机,第二行的图片都属于汽车。Specifically, when the image classification method of the embodiment of the present application is used to classify albums, the picture features of the pictures in the album can be extracted first, and then the pictures in the album are classified according to the extracted picture characteristics to obtain the classification result of the pictures. Next, the pictures in the album are classified according to the classification results of the pictures, and the albums arranged according to the picture categories are obtained. Among them, when arranging pictures in the album according to picture categories, pictures belonging to the same category may be arranged in a row or a row. For example, in the final album, the pictures in the first row belong to airplanes, and the pictures in the second row belong to cars.
拍照识物:Take photos to identify things:
用户在拍照时,可以利用本申请实施例的图像分类方法对拍到的照片进行处理,能够自动识别出被拍物体的类别,例如,可以自动识别出被拍物体是花卉、动物等。进一步地,利用本申请实施例的图像分类方法可以对拍照得到的物体进行识别,识别出该物体所属的类别,例如,用户拍照得到的照片中包括共享单车,利用本申请实施例的图像分类方法能够对共享单车进行识别,识别出该物体属于自行车,进一步地,还可以显示自行车的相关信息。When taking a photo, the user can use the image classification method of the embodiment of the present application to process the captured photo, and can automatically recognize the category of the object being photographed, for example, it can automatically recognize that the object being photographed is a flower, an animal, etc. Further, the image classification method of the embodiment of the application can be used to identify the object obtained by taking a photo, and the category to which the object belongs can be identified. For example, the photo obtained by the user includes a shared bicycle, and the image classification method of the embodiment of the application is used The shared bicycle can be recognized, and the object is recognized as a bicycle, and further, bicycle related information can be displayed.
由于本发明对广义小样本学习效果出色,所以不论被拍物体是来自基类还是新类,都能很好的识别。Since the present invention has an excellent learning effect on generalized small samples, it can be well recognized regardless of whether the photographed object comes from the base class or the new class.
在现有技术中,对于训练样本很少的图像类别,常常无法有效地对属于该类别的图像进行图像分类或图像识别。利用本申请实施例的图像分类方法,对于训练样本很少的新类 (小样本),也能很好地实现图像分类或图像识别。In the prior art, for image categories with few training samples, it is often impossible to effectively perform image classification or image recognition on images belonging to the category. Using the image classification method of the embodiment of the present application, for a new class (small sample) with few training samples, image classification or image recognition can also be implemented well.
应理解,上文介绍的相册分类和拍照识物只是本申请实施例的图像分类方法所应用的两个具体场景,本申请实施例的图像分类方法在应用时并不限于上述两个场景,本申请实施例的图像分类方法能够应用到任何需要进行图像分类或者图像识别的场景中。It should be understood that the album classification and photo identification described above are only two specific scenarios applied by the image classification method in the embodiment of this application, and the image classification method in the embodiment of this application is not limited to the above two scenarios when applied. The image classification method of the application embodiment can be applied to any scene that requires image classification or image recognition.
本申请实施例涉及了大量神经网络的相关应用,为了更好地理解本申请实施例的方案,下面先对本申请实施例可能涉及的神经网络的相关术语和其他相关概念进行介绍。The embodiments of this application involve a large number of related applications of neural networks. In order to better understand the solutions of the embodiments of this application, the following first introduces related terms and other related concepts of neural networks that may be involved in the embodiments of this application.
(1)神经网络(1) Neural network
神经网络可以是由神经单元组成的,神经单元可以是指以x s和截距1为输入的运算单元,该运算单元的输出可以如公式(1-1)所示: A neural network can be composed of neural units, which can refer to an arithmetic unit that takes x s and intercept 1 as inputs. The output of the arithmetic unit can be as shown in formula (1-1):
其中,s=1、2、……n,n为大于1的自然数,W s为x s的权重,b为神经单元的偏置。f为神经单元的激活函数(activation functions),用于将非线性特性引入神经网络中,来将神经单元中的输入信号转换为输出信号。该激活函数的输出信号可以作为下一层卷积层的输入,激活函数可以是sigmoid函数。神经网络是将多个上述单一的神经单元联结在一起形成的网络,即一个神经单元的输出可以是另一个神经单元的输入。每个神经单元的输入可以与前一层的局部接受域相连,来提取局部接受域的特征,局部接受域可以是由若干个神经单元组成的区域。 Among them, s=1, 2,...n, n is a natural number greater than 1, W s is the weight of x s , and b is the bias of the neural unit. f is the activation function of the neural unit, which is used to introduce nonlinear characteristics into the neural network to convert the input signal in the neural unit into an output signal. The output signal of the activation function can be used as the input of the next convolutional layer, and the activation function can be a sigmoid function. A neural network is a network formed by connecting multiple above-mentioned single neural units together, that is, the output of one neural unit can be the input of another neural unit. The input of each neural unit can be connected with the local receptive field of the previous layer to extract the characteristics of the local receptive field. The local receptive field can be a region composed of several neural units.
(2)深度神经网络(2) Deep neural network
深度神经网络(deep neural network,DNN),也称多层神经网络,可以理解为具有多层隐含层的神经网络。按照不同层的位置对DNN进行划分,DNN内部的神经网络可以分为三类:输入层,隐含层,输出层。一般来说第一层是输入层,最后一层是输出层,中间的层数都是隐含层。层与层之间是全连接的,也就是说,第i层的任意一个神经元一定与第i+1层的任意一个神经元相连。Deep neural network (DNN), also called multi-layer neural network, can be understood as a neural network with multiple hidden layers. DNN is divided according to the positions of different layers. The neural network inside the DNN can be divided into three categories: input layer, hidden layer, and output layer. Generally speaking, the first layer is the input layer, the last layer is the output layer, and the number of layers in the middle are all hidden layers. The layers are fully connected, that is to say, any neuron in the i-th layer must be connected to any neuron in the i+1th layer.
虽然DNN看起来很复杂,但是就每一层的工作来说,其实并不复杂,简单来说就是如下线性关系表达式: 其中, 是输入向量, 是输出向量, 是偏移向量,W是权重矩阵(也称系数),α()是激活函数。每一层仅仅是对输入向量 经过如此简单的操作得到输出向量 由于DNN层数多,系数W和偏移向量 的数量也比较多。这些参数在DNN中的定义如下所述:以系数W为例:假设在一个三层的DNN中,第二层的第4个神经元到第三层的第2个神经元的线性系数定义为 上标3代表系数W所在的层数,而下标对应的是输出的第三层索引2和输入的第二层索引4。 Although DNN looks complicated, it is not complicated in terms of the work of each layer. In simple terms, it is the following linear relationship expression: among them, Is the input vector, Is the output vector, Is the offset vector, W is the weight matrix (also called coefficient), and α() is the activation function. Each layer is just the input vector After such a simple operation, the output vector is obtained Due to the large number of DNN layers, the coefficient W and the offset vector The number is also relatively large. The definition of these parameters in the DNN is as follows: Take the coefficient W as an example: Suppose that in a three-layer DNN, the linear coefficients from the fourth neuron in the second layer to the second neuron in the third layer are defined as The superscript 3 represents the number of layers where the coefficient W is located, and the subscript corresponds to the output third layer index 2 and the input second layer index 4.
综上,第L-1层的第k个神经元到第L层的第j个神经元的系数定义为 In summary, the coefficient from the kth neuron in the L-1th layer to the jth neuron in the Lth layer is defined as
需要注意的是,输入层是没有W参数的。在深度神经网络中,更多的隐含层让网络更能够刻画现实世界中的复杂情形。理论上而言,参数越多的模型复杂度越高,“容量”也就越大,也就意味着它能完成更复杂的学习任务。训练深度神经网络的也就是学习权重矩阵的过程,其最终目的是得到训练好的深度神经网络的所有层的权重矩阵(由很多层的向量W形成的权重矩阵)。It should be noted that the input layer has no W parameter. In deep neural networks, more hidden layers make the network more capable of portraying complex situations in the real world. Theoretically speaking, a model with more parameters is more complex and has a greater "capacity", which means it can complete more complex learning tasks. Training a deep neural network is also a process of learning a weight matrix, and its ultimate goal is to obtain the weight matrix of all layers of the trained deep neural network (a weight matrix formed by vectors W of many layers).
(3)卷积神经网络(3) Convolutional neural network
卷积神经网络(convolutional neuron network,CNN)是一种带有卷积结构的深度神经网络。卷积神经网络包含了一个由卷积层和子采样层构成的特征抽取器,该特征抽取器可 以看作是滤波器。卷积层是指卷积神经网络中对输入信号进行卷积处理的神经元层。在卷积神经网络的卷积层中,一个神经元可以只与部分邻层神经元连接。一个卷积层中,通常包含若干个特征平面,每个特征平面可以由一些矩形排列的神经单元组成。同一特征平面的神经单元共享权重,这里共享的权重就是卷积核。共享权重可以理解为提取图像信息的方式与位置无关。卷积核可以以随机大小的矩阵的形式初始化,在卷积神经网络的训练过程中卷积核可以通过学习得到合理的权重。另外,共享权重带来的直接好处是减少卷积神经网络各层之间的连接,同时又降低了过拟合的风险。Convolutional neural network (convolutional neuron network, CNN) is a deep neural network with convolutional structure. The convolutional neural network contains a feature extractor composed of a convolutional layer and a sub-sampling layer, which can be regarded as a filter. The convolutional layer refers to the neuron layer that performs convolution processing on the input signal in the convolutional neural network. In the convolutional layer of a convolutional neural network, a neuron can be connected to only part of the neighboring neurons. A convolutional layer usually contains several feature planes, and each feature plane can be composed of some rectangularly arranged neural units. Neural units in the same feature plane share weights, and the shared weights here are the convolution kernels. Sharing weight can be understood as the way to extract image information has nothing to do with location. The convolution kernel can be initialized in the form of a matrix of random size. During the training of the convolutional neural network, the convolution kernel can obtain reasonable weights through learning. In addition, the direct benefit of sharing weights is to reduce the connections between the layers of the convolutional neural network, while reducing the risk of overfitting.
(4)损失函数(4) Loss function
在训练深度神经网络的过程中,因为希望深度神经网络的输出尽可能的接近真正想要预测的值,所以可以通过比较当前网络的预测值和真正想要的目标值,再根据两者之间的差异情况来更新每一层神经网络的权重向量(当然,在第一次更新之前通常会有初始化的过程,即为深度神经网络中的各层预先配置参数),比如,如果网络的预测值高了,就调整权重向量让它预测低一些,不断地调整,直到深度神经网络能够预测出真正想要的目标值或与真正想要的目标值非常接近的值。因此,就需要预先定义“如何比较预测值和目标值之间的差异”,这便是损失函数(loss function)或目标函数(objective function),它们是用于衡量预测值和目标值的差异的重要方程。其中,以损失函数举例,损失函数的输出值(loss)越高表示差异越大,那么深度神经网络的训练就变成了尽可能缩小这个loss的过程。In the process of training a deep neural network, because it is hoped that the output of the deep neural network is as close as possible to the value that you really want to predict, you can compare the predicted value of the current network with the target value you really want, and then based on the difference between the two To update the weight vector of each layer of neural network (of course, there is usually an initialization process before the first update, that is, pre-configured parameters for each layer in the deep neural network), for example, if the predicted value of the network If it is high, adjust the weight vector to make its prediction lower, and keep adjusting until the deep neural network can predict the really wanted target value or a value very close to the really wanted target value. Therefore, it is necessary to predefine "how to compare the difference between the predicted value and the target value". This is the loss function or objective function, which is used to measure the difference between the predicted value and the target value. Important equation. Among them, take the loss function as an example. The higher the output value (loss) of the loss function, the greater the difference. Then the training of the deep neural network becomes a process of reducing this loss as much as possible.
(5)反向传播算法(5) Back propagation algorithm
神经网络可以采用误差反向传播(back propagation,BP)算法在训练过程中修正初始的神经网络模型中参数的大小,使得神经网络模型的重建误差损失越来越小。具体地,前向传递输入信号直至输出会产生误差损失,通过反向传播误差损失信息来更新初始的神经网络模型中参数,从而使误差损失收敛。反向传播算法是以误差损失为主导的反向传播运动,旨在得到最优的神经网络模型的参数,例如权重矩阵。The neural network can use an error back propagation (BP) algorithm to modify the size of the parameters in the initial neural network model during the training process, so that the reconstruction error loss of the neural network model becomes smaller and smaller. Specifically, forwarding the input signal to the output will cause error loss, and the parameters in the initial neural network model are updated by backpropagating the error loss information, so that the error loss is converged. The backpropagation algorithm is a backpropagation motion dominated by error loss, and aims to obtain the optimal neural network model parameters, such as the weight matrix.
(6)像素值(6) Pixel value
图像的像素值可以是一个红绿蓝(RGB)颜色值,像素值可以是表示颜色的长整数。例如,像素值为256*Red+100*Green+76Blue,其中,Blue代表蓝色分量,Green代表绿色分量,Red代表红色分量。各个颜色分量中,数值越小,亮度越低,数值越大,亮度越高。对于灰度图像来说,像素值可以是灰度值。The pixel value of the image can be a red-green-blue (RGB) color value, and the pixel value can be a long integer representing the color. For example, the pixel value is 256*Red+100*Green+76Blue, where Blue represents the blue component, Green represents the green component, and Red represents the red component. In each color component, the smaller the value, the lower the brightness, and the larger the value, the higher the brightness. For grayscale images, the pixel values can be grayscale values.
(7)基类(7) Base class
在现有技术中,基类(base class)包括大量用于训练模型的标注样本,这些标注样本的数量足够满足模型训练的需求。例如,基类可以包括已经标注所属类别的多个图像,该多个图像可以属于一个类别,或者,该多个图像也可以属于多个不同的类别。基类可以用于训练本申请实施例中的图像分类模型。In the prior art, the base class includes a large number of labeled samples used to train the model, and the number of these labeled samples is sufficient to meet the requirements of model training. For example, the base category may include multiple images that have been labeled with categories, the multiple images may belong to one category, or the multiple images may also belong to multiple different categories. The base class can be used to train the image classification model in the embodiment of the present application.
(8)新类(8) New class
在现有技术中,新类(novel class)是与基类相对的概念,比如,若使用多个标注样本训练一个模型,则对于(训练好的)该模型而言,训练时使用的多个标注样本就是基类,而基类中不包括的类别就是新类。例如,我们已经通过大量动物(狗除外)的图像训练出来了模型,此时,我们想让该模型识别狗,则该大量动物的图像就是基类,狗的图像就是 新类。In the prior art, a new class (novel class) is a concept opposite to the base class. For example, if a model is trained using multiple labeled samples, then for the (trained) model, the multiple The labeled sample is the base category, and the categories that are not included in the base category are the new categories. For example, we have trained a model through images of a large number of animals (except dogs). At this time, if we want the model to recognize dogs, the images of the large number of animals are the base class, and the images of the dog are the new class.
通常,新类中的每个类别只包括少量标注样本。在本申请中,新类可以指小样本Usually, each category in the new category includes only a small number of labeled samples. In this application, the new category can refer to a small sample
(few-shot),即新类包括少量已经标注所属类别的图像,这些图像可以属于一个类别,或者,这些图像也可以分为多个不同的类别。(few-shot), that is, the new category includes a small number of images that have been labeled with their categories. These images can belong to one category, or these images can also be divided into multiple different categories.
(9)小样本学习(9) Small sample learning
小样本学习(few-shot learning,FSL)指利用大规模的训练集(包括一个或多个基类),对图像分类模型进行训练后,对于从未见过的新类(新类与基类不重叠),借助每个新类包括的少数几个训练样本,准确识别新类的测试样本(所属的类别)。Small sample learning (few-shot learning, FSL) refers to the use of large-scale training sets (including one or more base classes), after training the image classification model, for new classes that have never been seen before (new classes and base classes). Non-overlapping), with the help of a few training samples included in each new class, accurately identify the test samples of the new class (category to which it belongs).
进一步地,小样本学习可以包括标准小样本学习和广义小样本学习。例如,若小样本学习中的测试样本中只包括新类,则可以将该类问题称为标准小样本学习;若测试样本中不仅包括新类,还包括基类,则可以将该类问题称为广义小样本学习。Further, small sample learning may include standard small sample learning and generalized small sample learning. For example, if the test sample in small sample learning includes only new classes, then this type of problem can be called standard small sample learning; if the test sample includes not only new classes but also base classes, then this type of problem can be called Learning for generalized small samples.
本申请实施例中的图像分类方法既可以应用于标准小样本学习,也可以应用于广义小样本学习。下面结合图1对本申请实施例适用的系统架构进行介绍。The image classification method in the embodiment of the present application can be applied to standard small sample learning, and can also be applied to generalized small sample learning. The following describes the system architecture applicable to the embodiment of the present application with reference to FIG. 1.
如图1所示,本申请实施例提供了一种系统架构100。在图1中,数据采集设备160用于采集训练数据。针对本申请实施例的图像分类方法来说,训练数据可以包括训练图像以及训练图像对应的分类结果,其中,训练图像的分类结果可以是人工预先标注的结果。As shown in FIG. 1, an embodiment of the present application provides a system architecture 100. In FIG. 1, a data collection device 160 is used to collect training data. For the image classification method of the embodiment of the present application, the training data may include training images and classification results corresponding to the training images, wherein the classification results of the training images may be manually pre-labeled results.
在采集到训练数据之后,数据采集设备160将这些训练数据存入数据库130,训练设备120基于数据库130中维护的训练数据训练得到目标模型/规则101。After the training data is collected, the data collection device 160 stores the training data in the database 130, and the training device 120 trains to obtain the target model/rule 101 based on the training data maintained in the database 130.
下面对训练设备120基于训练数据得到目标模型/规则101进行描述,训练设备120对输入的原始图像进行处理,将输出的图像与原始图像进行对比,直到训练设备120输出的图像与原始图像的差值小于一定的阈值,从而完成目标模型/规则101的训练。The following describes the target model/rule 101 obtained by the training device 120 based on the training data. The training device 120 processes the input original image and compares the output image with the original image until the output image of the training device 120 differs from the original image. The difference is less than a certain threshold, thereby completing the training of the target model/rule 101.
上述目标模型/规则101能够用于实现本申请实施例的图像分类方法,即,将待处理图像通过相关预处理后输入该目标模型/规则101,即可得到图像的分类结果。本申请实施例中的目标模型/规则101具体可以为本申请实施例中的图像分类模型。需要说明的是,在实际的应用中,所述数据库130中维护的训练数据不一定都来自于数据采集设备160的采集,也有可能是从其他设备接收得到的。另外需要说明的是,训练设备120也不一定完全基于数据库130维护的训练数据进行目标模型/规则101的训练,也有可能从云端或其他地方获取训练数据进行模型训练,上述描述不应该作为对本申请实施例的限定。The above-mentioned target model/rule 101 can be used to implement the image classification method of the embodiment of the present application, that is, the image to be processed is input into the target model/rule 101 after relevant preprocessing to obtain the classification result of the image. The target model/rule 101 in the embodiment of the application may specifically be the image classification model in the embodiment of the application. It should be noted that in actual applications, the training data maintained in the database 130 may not all come from the collection of the data collection device 160, and may also be received from other devices. In addition, it should be noted that the training device 120 does not necessarily perform the training of the target model/rule 101 completely based on the training data maintained by the database 130. It may also obtain training data from the cloud or other places for model training. The above description should not be used as a reference to this application. Limitations of Examples.
根据训练设备120训练得到的目标模型/规则101可以应用于不同的系统或设备中,如应用于图1所示的执行设备110,所述执行设备110可以是终端,如手机终端,平板电脑,笔记本电脑,增强现实(augmented reality,AR)/虚拟现实(virtual reality,VR),车载终端等,还可以是服务器或者云端设备等。在图1中,执行设备110配置输入/输出(input/output,I/O)接口112,用于与外部设备进行数据交互,用户可以通过客户设备140向I/O接口112输入数据,所述输入数据在本申请实施例中可以包括:客户设备输入的待处理图像。The target model/rule 101 trained according to the training device 120 can be applied to different systems or devices, such as the execution device 110 shown in FIG. 1. The execution device 110 may be a terminal, such as a mobile phone terminal, a tablet computer, Notebook computers, augmented reality (AR)/virtual reality (VR), vehicle-mounted terminals, etc., can also be servers or cloud devices. In FIG. 1, the execution device 110 is configured with an input/output (input/output, I/O)
预处理模块113和预处理模块114用于根据I/O接口112接收到的输入数据(如待处理图像)进行预处理,在本申请实施例中,也可以没有预处理模块113和预处理模块114(也可以只有其中的一个预处理模块),而直接采用计算模块111对输入数据进行处理。The preprocessing module 113 and the preprocessing module 114 are used for preprocessing according to the input data (such as the image to be processed) received by the I/
在执行设备110对输入数据进行预处理,或者在执行设备110的计算模块111执行计 算等相关的处理过程中,执行设备110可以调用数据存储系统150中的数据、代码等以用于相应的处理,也可以将相应处理得到的数据、指令等存入数据存储系统150中。When the execution device 110 preprocesses input data, or when the calculation module 111 of the execution device 110 performs calculations and other related processing, the execution device 110 may call data, codes, etc. in the data storage system 150 for corresponding processing , The data, instructions, etc. obtained by corresponding processing may also be stored in the data storage system 150.
最后,I/O接口112将处理结果,如上述得到的待处理图像的分类结果返回给客户设备140,从而提供给用户。Finally, the I/
值得说明的是,训练设备120可以针对不同的目标或称不同的任务,基于不同的训练数据生成相应的目标模型/规则101,该相应的目标模型/规则101即可以用于实现上述目标或完成上述任务,从而为用户提供所需的结果。It is worth noting that the training device 120 can generate corresponding target models/rules 101 based on different training data for different goals or tasks, and the corresponding target models/rules 101 can be used to achieve the above goals or complete The above tasks provide the user with the desired result.
在图1所示情况下,用户可以手动给定输入数据,该手动给定可以通过I/O接口112提供的界面进行操作。另一种情况下,客户设备140可以自动地向I/O接口112发送输入数据,如果要求客户设备140自动发送输入数据需要获得用户的授权,则用户可以在客户设备140中设置相应权限。用户可以在客户设备140查看执行设备110输出的结果,具体的呈现形式可以是显示、声音、动作等具体方式。客户设备140也可以作为数据采集端,采集如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果作为新的样本数据,并存入数据库130。当然,也可以不经过客户设备140进行采集,而是由I/O接口112直接将如图所示输入I/O接口112的输入数据及输出I/O接口112的输出结果,作为新的样本数据存入数据库130。In the case shown in FIG. 1, the user can manually set input data, and the manual setting can be operated through the interface provided by the I/
值得注意的是,图1仅是本申请实施例提供的一种系统架构的示意图,图中所示设备、器件、模块等之间的位置关系不构成任何限制,例如,在图1中,数据存储系统150相对执行设备110是外部存储器,在其它情况下,也可以将数据存储系统150置于执行设备110中。It is worth noting that Fig. 1 is only a schematic diagram of a system architecture provided by an embodiment of the present application, and the positional relationship between the devices, devices, modules, etc. shown in the figure does not constitute any limitation. For example, in Fig. 1, the data The storage system 150 is an external memory relative to the execution device 110. In other cases, the data storage system 150 may also be placed in the execution device 110.
如图1所示,根据训练设备120训练得到目标模型/规则101,该目标模型/规则101在本申请实施例中可以是本申请中的图像分类模型,具体的,本申请实施例提供的图像分类模型可以包括一个或多个神经网络,该一个或多个神经网络可以包括CNN、深度卷积神经网络(deep convolutional neural networks,DCNN)和/或循环神经网络(recurrent neural network,RNNS)等等。As shown in FIG. 1, the target model/rule 101 is obtained by training according to the training device 120. The target model/rule 101 may be the image classification model in the embodiment of the application. Specifically, the image provided in the embodiment of the application The classification model may include one or more neural networks. The one or more neural networks may include CNN, deep convolutional neural networks (DCNN), and/or recurrent neural networks (RNNS), etc. .
由于CNN是一种非常常见的神经网络,下面结合图2重点对CNN的结构进行详细的介绍。如上文的基础概念介绍所述,卷积神经网络是一种带有卷积结构的深度神经网络,是一种深度学习(deep learning)架构,深度学习架构是指通过机器学习的算法,在不同的抽象层级上进行多个层次的学习。作为一种深度学习架构,CNN是一种前馈(feed-forward)人工神经网络,该前馈人工神经网络中的各个神经元可以对输入其中的图像作出响应。Since CNN is a very common neural network, the structure of CNN will be introduced in detail below in conjunction with Figure 2. As mentioned in the introduction to the basic concepts above, a convolutional neural network is a deep neural network with a convolutional structure. It is a deep learning architecture. A deep learning architecture refers to a machine learning algorithm. Multi-level learning is carried out on the abstract level of As a deep learning architecture, CNN is a feed-forward artificial neural network. Each neuron in the feed-forward artificial neural network can respond to the input image.
如图2所示,卷积神经网络(CNN)200可以包括输入层210,卷积层/池化层220(其中池化层为可选的),以及神经网络层230。下面对这些层的相关内容做详细介绍。As shown in FIG. 2, a convolutional neural network (CNN) 200 may include an input layer 210, a convolutional layer/pooling layer 220 (the pooling layer is optional), and a
卷积层/池化层220:Convolutional layer/pooling layer 220:
卷积层:Convolutional layer:
如图2所示卷积层/池化层220可以包括如示例221-226层,举例来说:在一种实现方式中,221层为卷积层,222层为池化层,223层为卷积层,224层为池化层,225为卷积层,226为池化层;在另一种实现方式中,221、222为卷积层,223为池化层,224、225为卷积层,226为池化层。即卷积层的输出可以作为随后的池化层的输入,也可以作为另 一个卷积层的输入以继续进行卷积操作。The convolutional layer/
下面将以卷积层221为例,介绍一层卷积层的内部工作原理。The following will take the
卷积层221可以包括很多个卷积算子,卷积算子也称为核,其在图像处理中的作用相当于一个从输入图像矩阵中提取特定信息的过滤器,卷积算子本质上可以是一个权重矩阵,这个权重矩阵通常被预先定义,在对图像进行卷积操作的过程中,权重矩阵通常在输入图像上沿着水平方向一个像素接着一个像素(或两个像素接着两个像素……这取决于步长stride的取值)的进行处理,从而完成从图像中提取特定特征的工作。该权重矩阵的大小应该与图像的大小相关,需要注意的是,权重矩阵的纵深维度(depth dimension)和输入图像的纵深维度是相同的,在进行卷积运算的过程中,权重矩阵会延伸到输入图像的整个深度。因此,和一个单一的权重矩阵进行卷积会产生一个单一纵深维度的卷积化输出,但是大多数情况下不使用单一权重矩阵,而是应用多个尺寸(行×列)相同的权重矩阵,即多个同型矩阵。每个权重矩阵的输出被堆叠起来形成卷积图像的纵深维度,这里的维度可以理解为由上面所述的“多个”来决定。不同的权重矩阵可以用来提取图像中不同的特征,例如一个权重矩阵用来提取图像边缘信息,另一个权重矩阵用来提取图像的特定颜色,又一个权重矩阵用来对图像中不需要的噪点进行模糊化等。该多个权重矩阵尺寸(行×列)相同,经过该多个尺寸相同的权重矩阵提取后的特征图的尺寸也相同,再将提取到的多个尺寸相同的特征图合并形成卷积运算的输出。The
这些权重矩阵中的权重值在实际应用中需要经过大量的训练得到,通过训练得到的权重值形成的各个权重矩阵可以用来从输入图像中提取信息,从而使得卷积神经网络200进行正确的预测。The weight values in these weight matrices need to be obtained through a lot of training in practical applications. Each weight matrix formed by the weight values obtained through training can be used to extract information from the input image, so that the convolutional neural network 200 can make correct predictions. .
当卷积神经网络200有多个卷积层的时候,初始的卷积层(例如221)往往提取较多的一般特征,该一般特征也可以称之为低级别的特征;随着卷积神经网络200深度的加深,越往后的卷积层(例如226)提取到的特征越来越复杂,比如高级别的语义之类的特征,语义越高的特征越适用于待解决的问题。When the convolutional neural network 200 has multiple convolutional layers, the initial convolutional layer (such as 221) often extracts more general features, which can also be called low-level features; with the convolutional neural network As the network 200 deepens, the features extracted by the subsequent convolutional layers (for example, 226) become more and more complex, such as features such as high-level semantics, and features with higher semantics are more suitable for the problem to be solved.
池化层/池化层220:Pooling layer/pooling layer 220:
由于常常需要减少训练参数的数量,因此卷积层之后常常需要周期性的引入池化层,在如图2中220所示例的221-226各层,可以是一层卷积层后面跟一层池化层,也可以是多层卷积层后面接一层或多层池化层。在图像处理过程中,池化层的唯一目的就是减少图像的空间大小。池化层可以包括平均池化算子和/或最大池化算子,以用于对输入图像进行采样得到较小尺寸的图像。平均池化算子可以在特定范围内对图像中的像素值进行计算产生平均值作为平均池化的结果。最大池化算子可以在特定范围内取该范围内值最大的像素作为最大池化的结果。另外,就像卷积层中用权重矩阵的大小应该与图像尺寸相关一样,池化层中的运算符也应该与图像的大小相关。通过池化层处理后输出的图像尺寸可以小于输入池化层的图像的尺寸,池化层输出的图像中每个像素点表示输入池化层的图像的对应子区域的平均值或最大值。Since it is often necessary to reduce the number of training parameters, it is often necessary to periodically introduce a pooling layer after the convolutional layer. In the 221-226 layers as illustrated by 220 in Figure 2, it can be a convolutional layer followed by a layer The pooling layer can also be a multi-layer convolutional layer followed by one or more pooling layers. In the image processing process, the only purpose of the pooling layer is to reduce the size of the image space. The pooling layer may include an average pooling operator and/or a maximum pooling operator for sampling the input image to obtain a smaller size image. The average pooling operator can calculate the pixel values in the image within a specific range to generate an average value as the result of average pooling. The maximum pooling operator can take the pixel with the largest value within a specific range as the result of the maximum pooling. In addition, just as the size of the weight matrix used in the convolutional layer should be related to the image size, the operators in the pooling layer should also be related to the image size. The size of the image output after processing by the pooling layer can be smaller than the size of the image of the input pooling layer, and each pixel in the image output by the pooling layer represents the average value or the maximum value of the corresponding sub-region of the image input to the pooling layer.
神经网络层230:Neural network layer 230:
在经过卷积层/池化层220的处理后,卷积神经网络200还不足以输出所需要的输出信息。因为如前所述,卷积层/池化层220只会提取特征,并减少输入图像带来的参数。然而为了生成最终的输出信息(所需要的类信息或其他相关信息),卷积神经网络200需 要利用神经网络层230来生成一个或者一组所需要的类的数量的输出。因此,在神经网络层230中可以包括多层隐含层(如图2所示的231、232至23n)以及输出层240,该多层隐含层中所包含的参数可以根据具体的任务类型的相关训练数据进行预先训练得到,例如该任务类型可以包括图像识别,图像分类,图像超分辨率重建等等。After processing by the convolutional layer/
在神经网络层230中的多层隐含层之后,也就是整个卷积神经网络200的最后层为输出层240,该输出层240具有类似分类交叉熵的损失函数,具体用于计算预测误差,一旦整个卷积神经网络200的前向传播(如图2由210至240方向的传播为前向传播)完成,反向传播(如图2由240至210方向的传播为反向传播)就会开始更新前面提到的各层的权重值以及偏差,以减少卷积神经网络200的损失,及卷积神经网络200通过输出层输出的结果和理想结果之间的误差。After the multiple hidden layers in the
需要说明的是,如图2所示的卷积神经网络200仅作为一种卷积神经网络的示例,在具体的应用中,卷积神经网络还可以以其他网络模型的形式存在。It should be noted that the convolutional neural network 200 shown in FIG. 2 is only used as an example of a convolutional neural network. In specific applications, the convolutional neural network may also exist in the form of other network models.
本申请中,图像分类模型可以包括图2所示的卷积神经网络200,该图像分类模型可以对待处理图像进行处理,得到待处理图像的分类结果。In this application, the image classification model may include the convolutional neural network 200 shown in FIG. 2, and the image classification model may process the image to be processed to obtain the classification result of the image to be processed.
图3为本申请实施例提供的一种芯片硬件结构,该芯片包括神经网络处理器30。该芯片可以被设置在如图1所示的执行设备110中,用以完成计算模块111的计算工作。该芯片也可以被设置在如图1所示的训练设备120中,用以完成训练设备120的训练工作并输出目标模型/规则101。如图2所示的卷积神经网络中各层的算法均可在如图3所示的芯片中得以实现,可选地,该卷积神经网络可以为上述图像分类模型包括的(一个或多个)神经网络中的一个。FIG. 3 is a hardware structure of a chip provided by an embodiment of the application, and the chip includes a neural network processor 30. The chip may be set in the execution device 110 as shown in FIG. 1 to complete the calculation work of the calculation module 111. The chip can also be set in the training device 120 as shown in FIG. 1 to complete the training work of the training device 120 and output the target model/rule 101. The algorithms of each layer in the convolutional neural network as shown in Figure 2 can be implemented in the chip as shown in Figure 3. Optionally, the convolutional neural network can be (one or more) included in the above-mentioned image classification model. A) one of the neural networks.
神经网络处理器NPU 30作为协处理器挂载到主CPU(host CPU)上,由主CPU分配任务。NPU的核心部分为运算电路303,控制器304控制运算电路303提取存储器(权重存储器或输入存储器)中的数据并进行运算。The neural network processor NPU 30 is mounted on a host CPU (host CPU) as a coprocessor, and the host CPU distributes tasks. The core part of the NPU is the arithmetic circuit 303. The controller 304 controls the arithmetic circuit 303 to extract data from the memory (weight memory or input memory) and perform calculations.
在一些实现方式中,运算电路303内部包括多个处理单元(process engine,PE)。在一些实现方式中,运算电路303是二维脉动阵列。运算电路303还可以是一维脉动阵列或者能够执行例如乘法和加法这样的数学运算的其它电子线路。在一些实现方式中,运算电路303是通用的矩阵处理器。In some implementation manners, the arithmetic circuit 303 includes multiple processing units (process engines, PE). In some implementations, the arithmetic circuit 303 is a two-dimensional systolic array. The arithmetic circuit 303 may also be a one-dimensional systolic array or other electronic circuits capable of performing mathematical operations such as multiplication and addition. In some implementations, the arithmetic circuit 303 is a general-purpose matrix processor.
举例来说,假设有输入矩阵A,权重矩阵B,输出矩阵C。运算电路303从权重存储器302中取矩阵B相应的数据,并缓存在运算电路303中每一个PE上。运算电路303从输入存储器301中取矩阵A数据与矩阵B进行矩阵运算,得到的矩阵的部分结果或最终结果,保存在累加器(accumulator)308中。For example, suppose there is an input matrix A, a weight matrix B, and an output matrix C. The arithmetic circuit 303 fetches the data corresponding to the matrix B from the weight memory 302 and caches it on each PE in the arithmetic circuit 303. The arithmetic circuit 303 takes the matrix A data and the matrix B from the input memory 301 to perform matrix operations, and the partial result or final result of the obtained matrix is stored in an
向量计算单元307可以对运算电路303的输出做进一步处理,如向量乘,向量加,指数运算,对数运算,大小比较等等。例如,向量计算单元307可以用于神经网络中非卷积/非FC层的网络计算,如池化(pooling),批归一化(batch normalization),局部响应归一化(local response normalization)等。The vector calculation unit 307 can perform further processing on the output of the operation circuit 303, such as vector multiplication, vector addition, exponential operation, logarithmic operation, size comparison, and so on. For example, the vector calculation unit 307 can be used for network calculations in the non-convolution/non-FC layer of the neural network, such as pooling, batch normalization, local response normalization, etc. .
在一些实现方式中,向量计算单元能307将经处理的输出的向量存储到统一缓存器306。例如,向量计算单元307可以将非线性函数应用到运算电路303的输出,例如累加值的向量,用以生成激活值。在一些实现方式中,向量计算单元307生成归一化的值、合并值,或二者均有。在一些实现方式中,处理过的输出的向量能够用作到运算电路303的 激活输入,例如用于在神经网络中的后续层中的使用。In some implementations, the vector calculation unit 307 can store the processed output vector to the unified buffer 306. For example, the vector calculation unit 307 may apply a nonlinear function to the output of the arithmetic circuit 303, such as a vector of accumulated values, to generate the activation value. In some implementations, the vector calculation unit 307 generates a normalized value, a combined value, or both. In some implementations, the processed output vector can be used as an activation input to the arithmetic circuit 303, for example for use in subsequent layers in a neural network.
统一存储器306用于存放输入数据以及输出数据。The unified memory 306 is used to store input data and output data.
权重数据直接通过存储单元访问控制器305(direct memory access controller,DMAC)将外部存储器中的输入数据搬运到输入存储器301和/或统一存储器306、将外部存储器中的权重数据存入权重存储器302,以及将统一存储器306中的数据存入外部存储器。The weight data directly transfers the input data in the external memory to the input memory 301 and/or the unified memory 306 through the storage unit access controller 305 (direct memory access controller, DMAC), and stores the weight data in the external memory into the weight memory 302, And the data in the unified memory 306 is stored in the external memory.
总线接口单元(bus interface unit,BIU)310,用于通过总线实现主CPU、DMAC和取指存储器309之间进行交互。The bus interface unit (BIU) 310 is used to implement interaction between the main CPU, the DMAC, and the fetch
与控制器304连接的取指存储器(instruction fetch buffer)309,用于存储控制器304使用的指令;An instruction fetch
控制器304,用于调用指存储器309中缓存的指令,实现控制该运算加速器的工作过程。The controller 304 is used to call the instructions cached in the
一般地,统一存储器306,输入存储器301,权重存储器302以及取指存储器309均为片上(On-Chip)存储器,外部存储器为该NPU外部的存储器,该外部存储器可以为双倍数据率同步动态随机存储器(double data rate synchronous dynamic random access memory,简称DDR SDRAM)、高带宽存储器(high bandwidth memory,HBM)或其他可读可写的存储器。Generally, the unified memory 306, the input memory 301, the weight memory 302, and the instruction fetch
其中,图2所示的卷积神经网络中各层的运算可以由运算电路303或向量计算单元307执行。Among them, the operations of each layer in the convolutional neural network shown in FIG. 2 can be executed by the arithmetic circuit 303 or the vector calculation unit 307.
上文中介绍的图1中的执行设备110能够执行本申请实施例的图像分类方法的各个步骤,可选地,图1中的执行设备110可以包括图2所示的CNN模型和图3所示的芯片。下面结合附图对本申请实施例的图像分类方法进行详细的介绍。The execution device 110 in FIG. 1 introduced above can execute each step of the image classification method of the embodiment of the present application. Optionally, the execution device 110 in FIG. 1 may include the CNN model shown in FIG. 2 and the image classification method shown in FIG. Chip. The image classification method of the embodiment of the present application will be described in detail below with reference to the accompanying drawings.
本申请实施例提供的图像分类方法可以在服务器上被执行,也可以在云端被执行,还可以在终端设备上被执行。以终端设备为例,如图4所示,本发明实施例的技术方案可以应用于终端设备,本申请实施例中的图像分类方法可以对输入图像进行图像分类,得到该输入图像的分类结果。该终端设备可以为移动的或固定的,例如该终端设备可以是具有图像处理功能的移动电话、平板个人电脑(tablet personal computer,TPC)、媒体播放器、智能电视、笔记本电脑(laptop computer,LC)、个人数字助理(personal digital assistant,PDA)、个人计算机(personal computer,PC)、照相机、摄像机、智能手表、可穿戴式设备(wearable device,WD)或者自动驾驶的车辆等,本发明实施例对此不作限定。The image classification method provided in the embodiments of the present application can be executed on a server, can also be executed on the cloud, and can also be executed on a terminal device. Taking a terminal device as an example, as shown in FIG. 4, the technical solution of the embodiment of the present invention can be applied to a terminal device. The image classification method in the embodiment of the present application can classify an input image to obtain a classification result of the input image. The terminal device may be mobile or fixed. For example, the terminal device may be a mobile phone with image processing function, a tablet personal computer (TPC), a media player, a smart TV, a laptop computer (LC). ), personal digital assistant (PDA), personal computer (PC), camera, video camera, smart watch, wearable device (WD) or self-driving vehicle, etc., embodiments of the present invention There is no restriction on this.
图像(或图片)的分类是各类图像处理应用的基础,计算机视觉常常会涉及到如何对获取到的图像进行分类的问题。但是,图像分类模型的训练需要大量标注好的训练数据,对于训练样本很少的图像类别(例如新类),常常无法有效地对属于该类别的图像进行图像分类或图像识别。而在很多情况下,获取有效的数据是非常困难的,例如,在医疗领域、安全领域等。The classification of images (or pictures) is the basis of various image processing applications, and computer vision often involves the problem of how to classify the acquired images. However, the training of an image classification model requires a large amount of labeled training data. For image categories with few training samples (such as new categories), it is often impossible to effectively perform image classification or image recognition on images belonging to the category. In many cases, it is very difficult to obtain valid data, for example, in the medical field and security field.
基于上述问题,本申请实施例提出了图像分类方法及图像分类模型的训练方法,对于训练样本很少的新类(小样本),也能很好地实现图像分类或图像识别。Based on the foregoing problems, the embodiments of the present application propose an image classification method and an image classification model training method. For new classes (small samples) with few training samples, image classification or image recognition can also be implemented well.
图5是本申请实施例的图像分类模型的训练方法500的示意性流程图。图5所示的方法可以由计算机设备、服务器设备或者运算设备等运算能力较强的设备来执行,例如,该方法可以由图4中的终端设备执行。图5所示的方法包括步骤510、520、530及540,下 面分别对这几个步骤进行详细的介绍。FIG. 5 is a schematic flowchart of an image classification model training method 500 according to an embodiment of the present application. The method shown in FIG. 5 may be executed by a device with strong computing capability such as a computer device, a server device, or a computing device. For example, the method may be executed by the terminal device in FIG. 4. The method shown in Fig. 5 includes
S510,获取训练集中的多个训练图像。S510: Acquire multiple training images in the training set.
其中,训练集(training set)可以为训练时使用的所有训练图像的集合。Among them, the training set (training set) may be a set of all training images used during training.
可选地,所述训练集包括基类中的图像和新类中的图像,基类中每个类别包括的训练图像远多于新类中每个类别包括的训练图像。Optionally, the training set includes images in the base class and images in the new class, and each class in the base class includes far more training images than each class in the new class.
这里的远多于可以理解为,基类中每个类别包括的训练图像的数量,至少比新类中每个类别包括的训练图像的数量高一个数量级,也就是说,基类中每个类别包括的训练图像的数量,至少是新类中每个类别包括的训练图像的数量的十倍。Far more than it can be understood here is that the number of training images included in each category in the base class is at least an order of magnitude higher than the number of training images included in each category in the new class, that is, each category in the base class The number of training images included is at least ten times the number of training images included in each category in the new class.
例如,基类包括100个类别,每个类别包括1000个(张)训练图像,新类包括5个类别,每个类别包括5个训练图像。For example, the base category includes 100 categories, each category includes 1000 training images, the new category includes 5 categories, and each category includes 5 training images.
可选地,本申请中的图像分类模型,可以基于多阶段训练(episodic training)的策略进行模型训练。例如,可以将模型训练过程分为多个训练阶段(training episode),在每个训练阶段中,可以随机抽取训练集中的几个类别来训练模型,最终,经过多个训练阶段,完成对图像分类模型的训练。关于多阶段训练的描述具体可以参照现有技术,这里不再赘述。Optionally, the image classification model in this application may be trained based on a multi-stage training (episodic training) strategy. For example, the model training process can be divided into multiple training episodes. In each training stage, several categories in the training set can be randomly selected to train the model. Finally, after multiple training stages, the image classification is completed Model training. For the description of multi-stage training, please refer to the prior art, which will not be repeated here.
具体地,在模型训练过程中的多个训练阶段中,都可以对所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够得到更好的图像分类结果。Specifically, in multiple training stages in the model training process, the global category features can be updated, so that the global category features obtained by training can have better consistency. At the same time, the training set includes the base class The images in the new class and the images in the new class, the effect of the new class (training image in) during the training process can continue to accumulate with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base class. According to the image classification model to classify the image to be processed, a better image classification result can be obtained.
本申请实施例中的图像分类模型的训练方法,可以更好地平衡基类中样本数量和新类中样本数量的差异,在模型训练过程中产生的影响。本申请涉及的图像分类模型的训练方法的详细描述可以如图7中方法700所述。The training method of the image classification model in the embodiment of the present application can better balance the difference between the number of samples in the base class and the number of samples in the new class, and the impact on the model training process. The detailed description of the training method of the image classification model involved in this application may be as described in the method 700 in FIG. 7.
基于上述多阶段训练的策略,本申请中的方法500可以分为多个训练阶段,相应地,上述S510可以指,在一个训练阶段中,随机抽取训练集中的多个训练图像,并将抽取的训练集中的多个训练图像分为支持集(support set)和问询集(query set)。Based on the above-mentioned multi-stage training strategy, the method 500 in this application can be divided into multiple training stages. Accordingly, the above-mentioned S510 can mean that in one training stage, multiple training images in the training set are randomly selected, and the extracted The multiple training images in the training set are divided into a support set (support set) and a query set (query set).
因此,也可以说,所述训练集包括支持集和问询集,训练集中的多个训练图像包括:支持集中的多个训练图像和问询集中的多个训练图像。Therefore, it can also be said that the training set includes a support set and a query set, and the multiple training images in the training set include: multiple training images in the support set and multiple training images in the query set.
S520,根据预设的第一神经网络,提取所述问询集中的多个训练图像的特征向量。S520: Extract feature vectors of multiple training images in the query set according to the preset first neural network.
其中,训练图像的特征向量可以用于指示所述训练图像的视觉特征(或图像特征),所述问询集包括所述训练集中的部分类别中的部分图像。Wherein, the feature vector of the training image may be used to indicate the visual feature (or image feature) of the training image, and the query set includes partial images in partial categories in the training set.
可选地,在提取所述问询集中的多个训练图像的特征向量时,也可以提取所述支持集中的多个训练图像的特征向量。Optionally, when extracting feature vectors of multiple training images in the query set, feature vectors of multiple training images in the support set may also be extracted.
可选地,所述第一神经网络可以是由如图1所示的系统100训练得到的。Optionally, the first neural network may be trained by the system 100 shown in FIG. 1.
可选地,所述第一神经网络可以为图2所示的卷积神经网络。Optionally, the first neural network may be the convolutional neural network shown in FIG. 2.
S530,根据预设的第二神经网络和预设的全局类别特征,对所述问询集中的多个训练图像的特征向量进行处理,得到所述问询集中的多个训练图像的分类结果。S530: Process the feature vectors of the multiple training images in the query set according to the preset second neural network and the preset global category features to obtain classification results of the multiple training images in the query set.
应理解,这里的分类结果可以是指图像所属的类别的标签。It should be understood that the classification result here may refer to the label of the category to which the image belongs.
可选地,所述第二神经网络可以是由如图1所示的系统100训练得到的。Optionally, the second neural network may be trained by the system 100 shown in FIG. 1.
可选地,所述第二神经网络可以为图2所示的卷积神经网络。Optionally, the second neural network may be the convolutional neural network shown in FIG. 2.
其中,所述全局类别特征包括多个类别特征,所述全局类别特征中的多个类别特征用于指示所述训练集中的所有类别的视觉特征,所述训练集中的所有类别为所述训练集中的所有训练图像所属的类别。Wherein, the global category feature includes multiple category features, and multiple category features in the global category feature are used to indicate visual features of all categories in the training set, and all categories in the training set are in the training set The category to which all training images belong.
在本申请中,所述根据预设的第二神经网络和预设的全局类别特征,对所述问询集中的多个训练图像的特征向量进行处理,得到所述问询集中的多个训练图像的分类结果,可以包括:提取所述支持集中的多个训练图像的特征向量;根据所述支持集中的多个训练图像的特征向量,确定训练图像的局部类别特征;根据所述第二神经网络、所述训练图像的局部类别特征及所述全局类别特征,确定所述问询集中的多个训练图像的分类结果。In this application, according to the preset second neural network and the preset global category features, the feature vectors of the multiple training images in the query set are processed to obtain multiple trainings in the query set The classification result of the image may include: extracting feature vectors of multiple training images in the support set; determining the local category features of the training images according to the feature vectors of the multiple training images in the support set; The network, the local category feature of the training image, and the global category feature determine the classification results of the multiple training images in the query set.
其中,所述训练图像的局部类别特征中的多个类别特征用于指示所述支持集中的所有类别的视觉特征,所述支持集包括所述训练集中的部分类别中的部分训练图像,所述问询集包括所述训练集中的部分类别中的部分训练图像。Wherein, multiple category features in the local category features of the training image are used to indicate the visual features of all categories in the support set, and the support set includes part of the training images in some categories in the training set, and The query set includes some training images in some categories in the training set.
可选地,所述支持集中的类别与所述问询集中的类别可以相同。Optionally, the category in the support set may be the same as the category in the inquiry set.
下面结合图6对上述S530中确定分类结果的步骤进行详细描述。The steps of determining the classification result in the above S530 will be described in detail below with reference to FIG. 6.
如图6所示,训练集中的多个训练图像分为支持集和问询集,支持集中的多个训练图像可以包括基类中的图像和新类中的图像。As shown in FIG. 6, the multiple training images in the training set are divided into a support set and an inquiry set. The multiple training images in the support set may include images in the base class and images in the new class.
需要说明的是,在一个训练阶段中,支持集和问询集是由训练集中随机抽取的多个训练图像确定的,训练集包括基类中的图像和新类中的图像,因此,支持集中的多个训练图像还可以只包括基类中的图像,或者,支持集中的多个训练图像还可以只包括新类中的图像。It should be noted that in a training phase, the support set and query set are determined by multiple training images randomly selected from the training set. The training set includes images in the base class and images in the new class. Therefore, the support set The multiple training images of can also include only images in the base class, or the multiple training images in the support set can also only include images in the new class.
如图6所示,可以确定支持集中的基类中的多个训练图像的类别特征,及新类中的多个训练图像的类别特征。例如,可以确定基类中的每个训练图像的特征向量,对属于同一个类别的多个训练图像的特征向量求均值,则该均值可以作为该类别的类别特征。确定新类中的多个训练图像的类别特征的方法,这里不再赘述。As shown in Figure 6, the category features of multiple training images in the base class in the support set and the category features of multiple training images in the new class can be determined. For example, the feature vector of each training image in the base category can be determined, and the feature vectors of multiple training images belonging to the same category can be averaged, and the average can be used as the category feature of the category. The method of determining the category features of multiple training images in the new class will not be repeated here.
特别地,在确定新类中的多个训练图像的类别特征之前,还可以先对新类中的多个训练图像,进行剪裁处理(cropping)、翻转处理(flipping)和/或数据幻化处理(hallucinator)等图像扩充处理,以得到更多的新类图像。In particular, before determining the category features of the multiple training images in the new class, the multiple training images in the new class can also be cropped, flipped and/or data transformed ( hallucinator) and other image expansion processing to get more new types of images.
在本申请,上述这些(求得的)类别特征(包括基类中的多个训练图像的类别特征和/或新类中的多个训练图像的类别特征)可以称为训练图像的局部类别特征(local class representations)。In this application, the above-mentioned (obtained) category features (including category features of multiple training images in the base category and/or category features of multiple training images in the new category) can be referred to as local category features of training images (local class representations).
可以看出,所述训练图像的局部类别特征是由一个训练阶段中随机抽取的(支持集中的)多个训练图像确定的,也就是说,这些局部类别特征只作用于模型训练过程中的一个训练阶段中,因此,局部类别特征也可以称为阶段类别特征(episodic class representations)。或者局部类别特征也可以为其他的名称,本申请对此并不限定。It can be seen that the local category features of the training image are determined by multiple training images randomly selected (supported in the concentration) during a training phase, that is, these local category features only act on one of the model training processes. In the training phase, therefore, local category features can also be referred to as episodic class representations. Or the local category feature may also be other names, which is not limited in this application.
与之不同,全局类别特征(global class representations)可以认为是图像分类模型的参数,共享训练集中的所有类别的类别特征,因此,全局类别特征可以作用于模型训练过程中的多个训练阶段中。In contrast, global class representations can be considered as parameters of the image classification model, sharing the class features of all categories in the training set. Therefore, global class representations can be used in multiple training stages in the model training process.
可选地,在得到训练图像的局部类别特征之后,可以将所述训练图像的局部类别特征配准到所述全局类别特征,从而得到配准结果,即配准后的全局类别特征。Optionally, after the local category feature of the training image is obtained, the local category feature of the training image can be registered to the global category feature, so as to obtain the registration result, that is, the registered global category feature.
这里的配准也可以理解为找到局部类别特征中的每个类别特征对应的全局类别特征中的类别特征。例如,找到全局类别特征中的、与所述局部类别特征中的每个类别特征相似度最高的一个类别特征。The registration here can also be understood as finding the category feature in the global category feature corresponding to each category feature in the local category feature. For example, find a category feature in the global category feature that has the highest similarity with each category feature in the local category feature.
进一步地,可以根据局部类别特征中的每个类别特征及其对应的全局类别特征中的类别特征的相似度,确定配准误差。Further, the registration error can be determined according to the similarity of each category feature in the local category feature and the category feature in the corresponding global category feature.
具体地,可以基于局部类别特征中的每个类别特征与其对应的全局类别特征中的类别特征的相似度,确定所述配准误差。也就是说,当前训练阶段的配准误差是根据所述训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的。Specifically, the registration error may be determined based on the similarity between each category feature in the local category features and the category feature in the corresponding global category feature. That is, the registration error in the current training stage is determined according to the local category features of the training image and the multiple category features in the global category features.
可选地,可以使用所述第二神经网络对所述配准结果进行降维处理,以在低维的向量空间中对所述问询集中的多个训练图像的特征向量进行处理。Optionally, the second neural network may be used to perform dimensionality reduction processing on the registration result, so as to process feature vectors of multiple training images in the query set in a low-dimensional vector space.
在本申请中,可以使用配准结果对所述问询集中的每个训练图像进行预测,得到所述问询集中的每个训练图像的分类结果。In this application, the registration result can be used to predict each training image in the query set to obtain the classification result of each training image in the query set.
具体地,可以使用距离最邻近的方法预测训练图像的分类结果。Specifically, the nearest neighbor method can be used to predict the classification result of the training image.
例如,可以计算配准结果中的类别特征与所述问询集中的每个训练图像的特征向量之间的距离,对每个距离进行归一化处理,可以得到训练图像中的每个训练图像属于配准结果中的类别特征指示的类别的概率,也就是问询集中的每个训练图像的分类结果。For example, the distance between the category feature in the registration result and the feature vector of each training image in the query set can be calculated, and each distance can be normalized to obtain each training image in the training image. The probability of belonging to the category indicated by the category feature in the registration result is the classification result of each training image in the query set.
进一步地,将每个训练图像的分类结果与该训练图像的预先标注的标签对比,可以得到分类误差,其中,所述预先标注的标签用于指示所述训练图像所属的真实类别。也就是说,当前训练阶段的分类误差是根据所述多个训练图像的分类结果及所述多个训练图像预先标注的标签确定的。Further, comparing the classification result of each training image with the pre-labeled label of the training image, the classification error can be obtained, wherein the pre-labeled label is used to indicate the true category to which the training image belongs. That is, the classification error of the current training stage is determined according to the classification results of the multiple training images and the pre-labeled labels of the multiple training images.
S540,根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征。S540: Update the global category feature according to the classification results of the multiple training images in the query set.
在本申请中,可以根据所述问询集中的多个训练图像的分类结果,更新所述全局类别特征、所述第一神经网络及所述第二神经网络。In this application, the global category feature, the first neural network, and the second neural network may be updated according to the classification results of the multiple training images in the query set.
可选地,可以根据分类误差,更新所述全局类别特征。可选地,可以通过上述S530中的方法,根据所述多个训练图像的分类结果确定所述分类误差。Optionally, the global category feature can be updated according to the classification error. Optionally, the classification error may be determined according to the classification results of the multiple training images by the method in S530.
进一步地,可以根据分类误差,更新所述全局类别特征、所述第一神经网络及所述第二神经网络。Further, the global category feature, the first neural network and the second neural network may be updated according to the classification error.
可选地,可以根据分类误差及配准误差,更新所述全局类别特征。可选地,可以通过上述S530中的方法,根据所述训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定所述分类误差。Optionally, the global category feature can be updated according to the classification error and the registration error. Optionally, the classification error may be determined according to multiple category features in the local category feature of the training image and the global category feature by using the method in S530.
进一步地,可以根据分类误差及配准误差,更新所述全局类别特征、所述第一神经网络及所述第二神经网络。Further, the global category feature, the first neural network and the second neural network can be updated according to the classification error and the registration error.
在本申请中,在模型训练过程中的多个训练阶段中,都可以对所述全局类别特征进行更新,从而可以使得训练得到的全局类别特征具有更好的一致性,同时,训练集中包括基类中的图像和新类中的图像,新类(中的训练图像)在训练过程中产生的效果可以随着全局类别特征不断累积,因此,能够避免训练得到的图像分类模型过拟合到基类,根据该图像分类模型对待处理图像进行分类,能够更准确的识别新类中的图像。In this application, in multiple training stages in the model training process, the global category features can be updated, so that the global category features obtained by training can have better consistency. At the same time, the training set includes the base The images in the class and the images in the new class. The effect of the new class (training image in) during the training process can be accumulated with the global category features. Therefore, it can avoid the image classification model obtained by training from overfitting to the base Class, according to the image classification model to classify the image to be processed, can more accurately identify the image in the new class.
图7是本申请另一个实施例的图像分类模型的训练方法700的示意性流程图。图7所示的方法可以由计算机设备、服务器设备或者运算设备等运算能力较强的设备来执行,例 如,该方法可以由图4中的终端设备执行。下面分别对方法700中的各个步骤进行详细的介绍。FIG. 7 is a schematic flowchart of a method 700 for training an image classification model according to another embodiment of the present application. The method shown in FIG. 7 can be executed by a device with strong computing capabilities such as a computer device, a server device, or a computing device. For example, the method can be executed by the terminal device in FIG. 4. Each step in the method 700 will be described in detail below.
S710,特征提取(模块)。S710, feature extraction (module).
提取支持集中的多个训练图像的特征向量,所述多个训练图像包括基类中的图像和新类中的图像。Extract feature vectors of multiple training images in the support set, the multiple training images including images in the base class and images in the new class.
可选地,可以使用上述第一神经网络,提取支持集中的多个训练图像的特征向量。Optionally, the above-mentioned first neural network may be used to extract feature vectors of multiple training images in the support set.
例如,假设有一组(多个)训练图像,这些训练图像可以用于训练上述图像分类模型,共包括C total={c 1,...,c N}个类别,其中,N表示类别的总数,第c j个类别包括k j个训练图像,j为整数。基于该多个训练图像,可以得到一个训练集D train,训练集D train包括基类图像和新类图像。 For example, suppose there is a set (multiple) training images, these training images can be used to train the above-mentioned image classification model, including a total of C total = {c 1 ,...,c N } categories, where N represents the total number of categories , The c jth category includes k j training images, j is an integer. Based on the multiple training images, a training set D train can be obtained, and the training set D train includes a base class image and a new class image.
在当前训练阶段,从训练集D train中随机抽取C train个类别,在每个类别中抽取n s个训练图像以形成支持集S={(x i,y i),i=1,...,n s×C train},y i为第i个训练图像x i的标签,C train为抽取的类别个数;从训练集D train中的C total个类别中,抽取C train个类别,每个类别包括n q个训练图像,形成一个问询集Q={(x q,y q),q=1,...,n q×C train},其中,n s、n q为正整数。 In the current training stage, C train categories are randomly selected from the training set D train , and n s training images are extracted from each category to form a support set S={(x i ,y i ),i=1,... .,n s ×C train }, y i is the label of the i-th training image x i , C train is the number of categories extracted; from the C total categories in the training set D train , C train categories are extracted, Each category includes n q training images, forming an inquiry set Q={(x q ,y q ),q=1,...,n q ×C train }, where n s and n q are positive Integer.
可选地,可以用F(·)表示特征提取,则对于训练集D train中的第i个训练图像x i,特征向量为f i=F(x i),其中,i为整数。 Optionally, F(·) can be used to represent feature extraction, and for the i-th training image x i in the training set D train , the feature vector is f i =F(x i ), where i is an integer.
S701,图像扩充。S701, image expansion.
可选地,对于支持集中的新类,可以对新类中的图像进行剪裁处理(cropping)、翻转处理(flipping)和/或数据幻化处理(hallucinator)等图像扩充处理,以得到更多的新类图像。Optionally, for the new classes that support the concentration, image expansion processing such as cropping, flipping, and/or data transformation (hallucinator) can be performed on the images in the new class to obtain more new images. Class image.
需要说明的是,在训练集D train中,每个新类只有n few个训练图像,而且,n few往往小于n s+n q。 It should be noted that in the training set D train , there are only n few training images for each new class, and n few are often smaller than n s +n q .
因此,在S701中,需要将新类中的n few个训练图像扩充为n s+n q个训练图像,然后,将其中的n s个训练图像放入支持集,将n q个训练图像放入问询集。 Therefore, in S701, it is necessary to expand the n few training images in the new class to n s + n q training images, and then put n s training images into the support set, and put n q training images into the support set. Enter the inquiry set.
S720,局部类别特征计算。S720, local category feature calculation.
可选地,对支持集中的多个训练图像,计算属于同一个类别的多个训练图像的特征向量求均值,则该均值可以作该类别的类别特征。Optionally, for multiple training images in the support set, the feature vectors of multiple training images belonging to the same category are calculated to average, and the average can be used as the category feature of the category.
计算支持集中的所有训练图像所属的类别的类别特征,从而可以得到训练图像的局部类别特征,记为 其中, 为支持集中第c j个类别的类别特征。 Calculate the category features of the categories to which all the training images in the support set belong, so that the local category features of the training images can be obtained, which is recorded as among them, To support the category characteristics of the c jth category in the set.
S730,类别特征配准(模块)。S730, category feature registration (module).
可选地,将所述训练图像的局部类别特征配准到所述全局类别特征,得到配准结果。Optionally, the local category feature of the training image is registered to the global category feature to obtain a registration result.
或者说,找到局部类别特征中的每个类别特征对应的全局类别特征中的类别特征。In other words, find the category feature in the global category feature corresponding to each category feature in the local category feature.
例如,全局类别特征记为 其中, 为训练集中第c j个类别的类别特征。 For example, the global category feature is recorded as among them, Is the category feature of the c jth category in the training set.
对于局部类别特征中的第j个类别特征f i和全局类别特征中的第j个类别特征 可以在低维的嵌入空间(embedding space)中计算局部类别特征中的类别特征f i和全局类别特征中的类别特征 的相似度,得到向量 其中,第j个元素 表示f i和 的相似度。 For the jth category feature f i in the local category feature and the jth category feature in the global category feature The category feature f i in the local category feature and the category feature in the global category feature can be calculated in the low-dimensional embedding space (embedding space) The similarity of the vector Among them, the jth element Denote f i and The similarity.
例如,可能使用下述公式计算相似度 For example, the following formula may be used to calculate the similarity
其中,θ(·)是训练图像的视觉特征的嵌入函数(embedding function),φ(·)是全局类别特征的嵌入函数。Among them, θ(·) is the embedding function of the visual feature of the training image, and φ(·) is the embedding function of the global category feature.
此时,全局类别特征中与类别特征f i相似度最高的类别特征g cj,为类别特征f i对应的全局类别特征。 At this time, a global category class characteristic features the highest similarity with the category feature f i g cj, wherein the global category corresponding to the category feature f i.
进一步地,可以根据局部类别特征中的每个类别特征及其对应的全局类别特征中的类别特征的相似度,确定配准误差。Further, the registration error can be determined according to the similarity of each category feature in the local category feature and the category feature in the corresponding global category feature.
例如,在本申请中,可以将训练图像x i的损失函数L reg作为配准误差,以使训练图像在低维嵌入空间中最接近其全局类别特征。计算损失函数L reg的公式如下。 For example, in this application, the loss function L reg of the training image x i can be used as the registration error, so that the training image is closest to its global category feature in the low-dimensional embedding space. The formula for calculating the loss function L reg is as follows.
L reg=CE(y i,V i) L reg =CE(y i ,V i )
其中,CE(·)为交叉熵损失,y i为训练图像x i的标签。 Among them, CE(·) is the cross-entropy loss, and y i is the label of the training image x i .
因此,第c j个类别的局部类别特征 的配准误差可以通过以下公式计算。 Therefore, the local category features of the c jth category The registration error of can be calculated by the following formula.
接下来,可以使用softmax函数对 进行归一化处理,从而可以获得每个类别的概率分布 将概率分布P i作为权重,估计所有类别的(全局类别特征中)类别特征的加权和,将该加权和作为当前训练阶段的C train个类别中的第i类的类别表征,记为ξ i,即ξ i=P iG。ξ i就是上述实施例中的配准结果。 Next, you can use the softmax function to Perform normalization processing to obtain the probability distribution of each category The probability distribution P i as a weight, estimated for all categories (global category feature) class characteristic weighted sum, the category representation weighted sum as the current training phase C train a category of class i, referred to as a [xi] i , That is, ξ i =P i G. ξ i is the registration result in the above embodiment.
S740,图像分类。S740, image classification.
可选地,可以使用配准结果对所述问询集中的每个训练图像进行预测,得到所述问询集中的每个训练图像的分类结果。Optionally, the registration result can be used to predict each training image in the query set, and obtain a classification result of each training image in the query set.
进一步地,将每个训练图像的分类结果与该训练图像的预先标注的标签(真实标签)对比,可以得到分类误差。Further, comparing the classification result of each training image with the pre-labeled label (true label) of the training image, the classification error can be obtained.
例如,对于给定一个类别特征ξ i,可以将损失函数L fsl作为问询集中的训练图像(x k,y k)的分类误差,损失函数L fsl如下述公式所示。 For example, for a given category feature ξ i , the loss function L fsl can be used as the classification error of the training images (x k , y k ) in the query set, and the loss function L fsl is shown in the following formula.
L fsl=CE(y k,W k) L fsl =CE(y k ,W k )
c i∈C train c i ∈C train
其中, 表示问询集中的训练图像x k与估计的全局类别特征ξ i的相似度。 among them, Indicates the similarity between the training image x k in the query set and the estimated global category feature ξ i .
此时,可以将相似度最高的 对应的类别作为训练图像x k的类别,即训练图像x k的分类结果。 At this time, the most similar The corresponding category is taken as the category of the training image x k , that is, the classification result of the training image x k .
S750,图像分类模型更新。S750, the image classification model is updated.
可选地,可以使用配准误差和/或分类误差,更新图像分类模型。Optionally, registration errors and/or classification errors can be used to update the image classification model.
例如,在本申请中,可以将配准误差(L reg)和分类误差(L fsl)结合起来,多个训练阶段的总损失函数L total(·)可以由下述公式计算。 For example, in this application, the registration error (L reg ) and the classification error (L fsl ) can be combined, and the total loss function L total (·) of multiple training stages can be calculated by the following formula.
可选地,S750可以包括S751、S752及S753中的至少一个步骤。Optionally, S750 may include at least one of S751, S752, and S753.
S751,更新特征提取(模块)。S751: Update the feature extraction (module).
可选地,可以使用配准误差(L reg)、分类误差(L fsl)和/或总损失函数(L total), 更新特征提取(模块)。 Optionally, registration error (L reg ), classification error (L fsl ), and/or total loss function (L total ) can be used to update the feature extraction (module).
S752,更新类别特征配准(模块)。S752, update the category feature registration (module).
可选地,可以使用配准误差(L reg)、分类误差(L fsl)和/或总损失函数(L total),更新类别特征配准(模块)。 Optionally, the registration error (L reg ), the classification error (L fsl ) and/or the total loss function (L total ) can be used to update the category feature registration (module).
S753,更新全局类别特征。S753: Update the global category characteristics.
可选地,可以使用配准误差(L reg)、分类误差(L fsl)和/或总损失函数(L total),更新全局类别特征。 Optionally, the registration error (L reg ), the classification error (L fsl ), and/or the total loss function (L total ) can be used to update the global category features.
图8示出了本申请实施例提供的图像分类方法800的示意性流程图,图8所示的方法可以由计算机设备、服务器设备或者运算设备等运算能力较强的设备来执行,例如,该方法可以由图4中的终端设备执行。图8所示的方法包括步骤810和820,下面分别对这几个步骤进行详细的介绍。FIG. 8 shows a schematic flowchart of an image classification method 800 provided by an embodiment of the present application. The method shown in FIG. 8 may be executed by a device with strong computing capabilities such as a computer device, a server device, or a computing device. For example, the The method can be executed by the terminal device in FIG. 4. The method shown in FIG. 8 includes
S810,获取待处理图像。S810: Acquire an image to be processed.
可选地,当图8所示的方法800由图4中的终端设备执行时,该待处理图像可以是终端设备通过摄像头拍摄到的图像;或者,该待处理图像还可以是从终端设备内部获得的图像,例如,终端设备的相册中存储的图像,或者终端设备从云端获取的图像。Optionally, when the method 800 shown in FIG. 8 is executed by the terminal device in FIG. 4, the image to be processed may be an image captured by the terminal device through a camera; or, the image to be processed may also be from the terminal device. The obtained image, for example, the image stored in the album of the terminal device, or the image obtained by the terminal device from the cloud.
S820,根据预设的全局类别特征,对所述待处理图像进行分类,得到所述待处理图像的分类结果。S820: Classify the image to be processed according to preset global category features, to obtain a classification result of the image to be processed.
其中,所述全局类别特征包括根据训练集中的多个训练图像训练得到的多个类别特征,所述全局类别特征中的多个类别特征用于指示所述训练集中的所有类别的视觉特征,所述训练集中的所有类别为所述训练集中的所有训练图像所属的类别,所述训练集包括基类中的图像和新类中的图像。Wherein, the global category features include multiple category features obtained by training based on multiple training images in the training set, and multiple category features in the global category features are used to indicate visual features of all categories in the training set, so All categories in the training set are categories to which all training images in the training set belong, and the training set includes images in the base class and images in the new class.
可选地,所述根据预设的全局类别特征,对所述待处理图像进行分类,得到所述待处理图像的分类结果,可以包括:提取所述待处理图像的特征向量;根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度,所述候选类别为所述全局类别特征指示的多个类别中的一个或多个;根据所述置信度,从所述候选类别中确定出所述待处理图像的分类结果。Optionally, the classifying the image to be processed according to preset global category features to obtain the classification result of the image to be processed may include: extracting the feature vector of the image to be processed; Process the feature vector of the image, and determine the confidence that the image to be processed belongs to a candidate category, where the candidate category is one or more of the multiple categories indicated by the global category feature; according to the confidence, from the The classification result of the image to be processed is determined from the candidate category.
可选地,在所述根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度之前,所述方法还可以包括:根据所述待处理图像的支持集,确定待处理图像的局部类别特征;根据所述待处理图像的局部类别特征及所述全局类别特征,确定所述候选类别。Optionally, before the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed, the method may further include: determining the Process the local category feature of the image; determine the candidate category according to the local category feature of the image to be processed and the global category feature.
其中,所述待处理图像的支持集包括多个图像,所述多个图像所属的类别为所述全局类别特征指示的多个类别中的一个或多个。Wherein, the support set of the image to be processed includes multiple images, and the category to which the multiple images belong is one or more of the multiple categories indicated by the global category feature.
可选地,所述候选类别可以包括支持集中的所有训练图像所属的类别。Optionally, the candidate category may include the category to which all training images in the support set belong.
可选地,所述根据所述待处理图像的特征向量,确定所述待处理图像属于候选类别的置信度,可以包括:根据所述待处理图像的特征向量,确定所述待处理图像的特征向量与所述候选类别中的每个类别对应的特征向量的距离;根据所述距离,确定所述待处理图像属于所述候选类别的所述置信度。Optionally, the determining the confidence that the image to be processed belongs to the candidate category according to the feature vector of the image to be processed may include: determining the feature of the image to be processed according to the feature vector of the image to be processed The distance between the vector and the feature vector corresponding to each of the candidate categories; and according to the distance, the confidence that the image to be processed belongs to the candidate category is determined.
可选地,所述根据所述置信度,从所述候选类别中确定出所述待处理图像的分类结果,可以包括:将所述候选类别中所述置信度最大的类别,确定为所述待处理图像的分类结果。Optionally, the determining the classification result of the image to be processed from the candidate categories according to the confidence may include: determining the category with the highest confidence in the candidate categories as the The classification result of the image to be processed.
应理解,这里的置信度可以是所述待处理图像属于所述候选类别的概率。因此,置信度最大,也可以说是,所述待处理图像属于所述候选类别的概率最大。It should be understood that the confidence level here may be the probability that the image to be processed belongs to the candidate category. Therefore, the degree of confidence is the greatest. It can also be said that the image to be processed has the greatest probability of belonging to the candidate category.
可选地,所述全局类别特征是根据分类误差训练得到的,所述分类误差是根据问询集中的训练图像的分类结果及所述问询集中的训练图像预先标注的标签确定的,所述标签用于指示所述训练图像所属的类别,所述问询集包括所述训练集中的部分类别中的部分训练图像。其中,确定所述分类误差的具体过程可以参照图5中的方法500。Optionally, the global category feature is obtained by training according to a classification error, and the classification error is determined according to the classification result of the training image in the query set and the pre-labeled label of the training image in the query set. The label is used to indicate the category to which the training image belongs, and the query set includes part of the training images in the partial categories in the training set. For the specific process of determining the classification error, refer to the method 500 in FIG. 5.
可选地,所述全局类别特征是根据配准误差训练得到的,所述配准误差是根据训练图像的局部类别特征及所述全局类别特征中的多个类别特征确定的,所述训练图像的局部类别特征包括根据支持集中的多个训练图像确定的多个类别特征,所述训练图像的局部类别特征中的多个类别特征用于指示所述支持集中的所有类别的视觉特征,所述支持集包括所述训练集中的部分类别中的部分训练图像。其中,确定所述配准误差的具体过程可以参照图5中的方法500。Optionally, the global category feature is obtained by training based on registration error, the registration error is determined based on the local category feature of the training image and multiple category features in the global category feature, the training image The local category features include multiple category features determined according to multiple training images in the support set, and multiple category features in the local category features of the training image are used to indicate visual features of all categories in the support set, the The support set includes some training images in some categories in the training set. For the specific process of determining the registration error, refer to the method 500 in FIG. 5.
可选地,所述全局类别特征是根据分类误差及配准误差训练得到的。Optionally, the global category feature is obtained by training based on classification error and registration error.
可选地,所述训练图像的局部类别特征是由经过扩充处理的所述支持集中的多个训练图像确定的,所述扩充处理包括对图像进行剪裁处理、翻转处理和/或数据幻化处理。Optionally, the local category feature of the training image is determined by a plurality of training images in the support set that undergoes expansion processing, and the expansion processing includes clipping, flipping, and/or data transformation processing on the image.
在本申请中,全局类别特征是由训练集中的多个训练图像的分类结果训练得到的,所述全局类别特征包括能够指示训练集中的所有类别对应的视觉特征的多个类别特征,同时,由于所述全局类别训练过程使用的训练集包括基类中的图像和新类中的图像,可以避免所述全局类别特征过拟合到基类中的图像,从而能够更准确的识别新类中的图像。In this application, the global category features are trained from the classification results of multiple training images in the training set. The global category features include multiple category features that can indicate the visual features corresponding to all categories in the training set. At the same time, because The training set used in the global category training process includes images in the base category and images in the new category, which can prevent the global category features from being overfitted to the images in the base category, thereby enabling more accurate identification of the images in the new category. image.
图9是本申请实施例的图像分类装置的硬件结构示意图。图9所示的图像分类装置4000包括存储器4001、处理器4002、通信接口4003以及总线4004。其中,存储器4001、处理器4002、通信接口4003通过总线4004实现彼此之间的通信连接。FIG. 9 is a schematic diagram of the hardware structure of an image classification device according to an embodiment of the present application. The image classification device 4000 shown in FIG. 9 includes a memory 4001, a processor 4002, a communication interface 4003, and a bus 4004. Among them, the memory 4001, the processor 4002, and the communication interface 4003 implement communication connections between each other through the bus 4004.
存储器4001可以是只读存储器(read only memory,ROM),静态存储设备,动态存储设备或者随机存取存储器(random access memory,RAM)。存储器4001可以存储程序,当存储器4001中存储的程序被处理器4002执行时,处理器4002和通信接口4003用于执行本申请实施例的图像分类方法的各个步骤。The memory 4001 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 4001 may store a program. When the program stored in the memory 4001 is executed by the processor 4002, the processor 4002 and the communication interface 4003 are used to execute each step of the image classification method of the embodiment of the present application.
处理器4002可以采用通用的中央处理器(central processing unit,CPU),微处理器,应用专用集成电路(application specific integrated circuit,ASIC),图形处理器(graphics processing unit,GPU)或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例的图像分类装置中的单元所需执行的功能,或者执行本申请方法实施例的图像分类方法。The processor 4002 may adopt a general-purpose central processing unit (central processing unit, CPU), microprocessor, application specific integrated circuit (ASIC), graphics processing unit (GPU), or one or more The integrated circuit is used to execute related programs to realize the functions required by the units in the image classification device of the embodiment of the present application, or to execute the image classification method of the method embodiment of the present application.
处理器4002还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请实施例的图像分类方法的各个步骤可以通过处理器4002中的硬件的集成逻辑电路或者软件形式的指令完成。The processor 4002 may also be an integrated circuit chip with signal processing capability. In the implementation process, each step of the image classification method in the embodiment of the present application can be completed by an integrated logic circuit of hardware in the processor 4002 or instructions in the form of software.
上述处理器4002还可以是通用处理器、数字信号处理器(digital signal processing,DSP)、ASIC、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。上述通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本申请实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行 完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器4001,处理器4002读取存储器4001中的信息,结合其硬件完成本申请实施例的图像分类装置中包括的单元所需执行的功能,或者执行本申请方法实施例的图像分类方法。The above-mentioned processor 4002 may also be a general-purpose processor, a digital signal processing (digital signal processing, DSP), an ASIC, a ready-made programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic Devices, discrete hardware components. The aforementioned general-purpose processor may be a microprocessor or the processor may also be any conventional processor. The steps of the method disclosed in the embodiments of the present application may be directly embodied as being executed and completed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory, or electrically erasable programmable memory, registers. The storage medium is located in the memory 4001, and the processor 4002 reads the information in the memory 4001, and combines its hardware to complete the functions required by the units included in the image classification apparatus of the embodiment of the application, or execute the image classification of the method embodiment of the application. method.
通信接口4003使用例如但不限于收发器一类的收发装置,来实现装置4000与其他设备或通信网络之间的通信。例如,可以通过通信接口4003获取待处理图像。The communication interface 4003 uses a transceiver device such as but not limited to a transceiver to implement communication between the device 4000 and other devices or a communication network. For example, the image to be processed can be acquired through the communication interface 4003.
总线4004可包括在装置4000各个部件(例如,存储器4001、处理器4002、通信接口4003)之间传送信息的通路。The bus 4004 may include a path for transferring information between various components of the device 4000 (for example, the memory 4001, the processor 4002, and the communication interface 4003).
图10是本申请实施例的图像分类模型的训练装置5000的硬件结构示意图。与上述装置4000类似,图10所示的图像分类模型的训练装置5000包括存储器5001、处理器5002、通信接口5003以及总线5004。其中,存储器5001、处理器5002、通信接口5003通过总线5004实现彼此之间的通信连接。FIG. 10 is a schematic diagram of the hardware structure of an image classification model training device 5000 according to an embodiment of the present application. Similar to the above device 4000, the image classification model training device 5000 shown in FIG. 10 includes a memory 5001, a processor 5002, a communication interface 5003, and a bus 5004. Among them, the memory 5001, the processor 5002, and the communication interface 5003 implement communication connections between each other through the bus 5004.
存储器5001可以存储程序,当存储器5001中存储的程序被处理器5002执行时,处理器5002用于执行本申请实施例的神经网络的训练方法的各个步骤。The memory 5001 may store a program. When the program stored in the memory 5001 is executed by the processor 5002, the processor 5002 is configured to execute each step of the neural network training method of the embodiment of the present application.
处理器5002可以采用通用的CPU,微处理器,ASIC,GPU或者一个或多个集成电路,用于执行相关程序,以实现本申请实施例的图像分类模型的训练方法。The processor 5002 may adopt a general-purpose CPU, a microprocessor, an ASIC, a GPU or one or more integrated circuits to execute related programs to implement the image classification model training method of the embodiment of the present application.
处理器5002还可以是一种集成电路芯片,具有信号的处理能力。在实现过程中,本申请实施例的图像分类模型的训练方法的各个步骤可以通过处理器5002中的硬件的集成逻辑电路或者软件形式的指令完成。The processor 5002 may also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the training method of the image classification model in the embodiment of the present application can be completed by the integrated logic circuit of hardware in the processor 5002 or instructions in the form of software.
应理解,通过图10所示的图像分类模型的训练装置5000对图像分类模型进行训练,训练得到的图像分类模型就可以用于执行本申请实施例的图像分类方法了。具体地,通过装置5000对图像分类模型进行训练能够得到图5以及图8所示的方法中的图像分类模型。It should be understood that the image classification model is trained by the image classification model training device 5000 shown in FIG. 10, and the image classification model obtained by training can be used to execute the image classification method of the embodiment of the present application. Specifically, training the image classification model by the device 5000 can obtain the image classification model in the methods shown in FIG. 5 and FIG. 8.
具体地,图10所示的装置可以通过通信接口5003从外界获取训练数据以及待训练的图像分类模型,然后由处理器根据训练数据对待训练的图像分类模型进行训练。Specifically, the device shown in FIG. 10 can obtain training data and the image classification model to be trained from the outside through the communication interface 5003, and then the processor trains the image classification model to be trained according to the training data.
应注意,尽管上述装置4000和装置5000仅仅示出了存储器、处理器、通信接口,但是在具体实现过程中,本领域的技术人员应当理解,装置4000和装置5000还可以包括实现正常运行所必须的其他器件。同时,根据具体需要,本领域的技术人员应当理解,装置4000和装置5000还可包括实现其他附加功能的硬件器件。此外,本领域的技术人员应当理解,装置4000和装置5000也可仅仅包括实现本申请实施例所必须的器件,而不必包括图9和图10中所示的全部器件。It should be noted that although the foregoing device 4000 and device 5000 only show a memory, a processor, and a communication interface, in the specific implementation process, those skilled in the art should understand that the device 4000 and device 5000 may also include those necessary for normal operation. Other devices. At the same time, according to specific needs, those skilled in the art should understand that the device 4000 and the device 5000 may also include hardware devices that implement other additional functions. In addition, those skilled in the art should understand that the device 4000 and the device 5000 may also only include the components necessary to implement the embodiments of the present application, and not necessarily include all the components shown in FIG. 9 and FIG. 10.
应理解,本申请实施例中的处理器可以为中央处理单元(central processing unit,CPU),该处理器还可以是其他通用处理器、数字信号处理器(digital signal processor,DSP)、专用集成电路(application specific integrated circuit,ASIC)、现成可编程门阵列(field programmable gate array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。It should be understood that the processor in this embodiment of the application may be a central processing unit (central processing unit, CPU), and the processor may also be other general-purpose processors, digital signal processors (digital signal processors, DSP), and application-specific integrated circuits. (application specific integrated circuit, ASIC), ready-made programmable gate array (field programmable gate array, FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor or the like.
还应理解,本申请实施例中的存储器可以是易失性存储器或非易失性存储器,或可包括易失性和非易失性存储器两者。其中,非易失性存储器可以是只读存储器(read-only memory,ROM)、可编程只读存储器(programmable ROM,PROM)、可擦除可编程只 读存储器(erasable PROM,EPROM)、电可擦除可编程只读存储器(electrically EPROM,EEPROM)或闪存。易失性存储器可以是随机存取存储器(random access memory,RAM),其用作外部高速缓存。通过示例性但不是限制性说明,许多形式的随机存取存储器(random access memory,RAM)可用,例如静态随机存取存储器(static RAM,SRAM)、动态随机存取存储器(DRAM)、同步动态随机存取存储器(synchronous DRAM,SDRAM)、双倍数据速率同步动态随机存取存储器(double data rate SDRAM,DDR SDRAM)、增强型同步动态随机存取存储器(enhanced SDRAM,ESDRAM)、同步连接动态随机存取存储器(synchlink DRAM,SLDRAM)和直接内存总线随机存取存储器(direct rambus RAM,DR RAM)。It should also be understood that the memory in the embodiments of the present application may be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. Among them, the non-volatile memory can be read-only memory (ROM), programmable read-only memory (programmable ROM, PROM), erasable programmable read-only memory (erasable PROM, EPROM), and electronic Erase programmable read-only memory (electrically EPROM, EEPROM) or flash memory. The volatile memory may be random access memory (RAM), which is used as an external cache. By way of exemplary but not restrictive description, many forms of random access memory (RAM) are available, such as static random access memory (static RAM, SRAM), dynamic random access memory (DRAM), and synchronous dynamic random access memory (DRAM). Access memory (synchronous DRAM, SDRAM), double data rate synchronous dynamic random access memory (double data rate SDRAM, DDR SDRAM), enhanced synchronous dynamic random access memory (enhanced SDRAM, ESDRAM), synchronous connection dynamic random access memory Take memory (synchlink DRAM, SLDRAM) and direct memory bus random access memory (direct rambus RAM, DR RAM).
上述实施例,可以全部或部分地通过软件、硬件、固件或其他任意组合来实现。当使用软件实现时,上述实施例可以全部或部分地以计算机程序产品的形式实现。所述计算机程序产品包括一个或多个计算机指令或计算机程序。在计算机上加载或执行所述计算机指令或计算机程序时,全部或部分地产生按照本申请实施例所述的流程或功能。所述计算机可以为通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集合的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质。半导体介质可以是固态硬盘。The foregoing embodiments can be implemented in whole or in part by software, hardware, firmware or any other combination. When implemented by software, the above-mentioned embodiments may be implemented in the form of a computer program product in whole or in part. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website, computer, server or data center via wired (such as infrared, wireless, microwave, etc.). The computer-readable storage medium may be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more sets of available media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium. The semiconductor medium may be a solid state drive.
应理解,本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况,其中A,B可以是单数或者复数。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系,但也可能表示的是一种“和/或”的关系,具体可参考前后文进行理解。It should be understood that the term "and/or" in this article is only an association relationship describing the associated objects, indicating that there can be three types of relationships, for example, A and/or B can mean: A alone exists, and both A and B exist. , There are three cases of B alone, where A and B can be singular or plural. In addition, the character "/" in this document generally indicates that the associated objects before and after are in an "or" relationship, but it may also indicate an "and/or" relationship, which can be understood with reference to the context.
本申请中,“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“以下至少一项(个)”或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。In this application, "at least one" refers to one or more, and "multiple" refers to two or more. "The following at least one item (a)" or similar expressions refers to any combination of these items, including any combination of a single item (a) or plural items (a). For example, at least one item (a) of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple .
应理解,在本申请的各种实施例中,上述各过程的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。It should be understood that, in the various embodiments of the present application, the size of the sequence number of the above-mentioned processes does not mean the order of execution, and the execution order of each process should be determined by its function and internal logic, rather than corresponding to the embodiments of the present application. The implementation process constitutes any limitation.
本领域普通技术人员可以意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、或者计算机软件和电子硬件的结合来实现。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。A person of ordinary skill in the art may be aware that the units and algorithm steps of the examples described in combination with the embodiments disclosed herein can be implemented by electronic hardware or a combination of computer software and electronic hardware. Whether these functions are executed by hardware or software depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统、装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。Those skilled in the art can clearly understand that, for the convenience and conciseness of description, the specific working process of the above-described system, device, and unit can refer to the corresponding process in the foregoing method embodiment, which will not be repeated here.
在本申请所提供的几个实施例中,应该理解到,所揭露的系统、装置和方法,可以通过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。In the several embodiments provided in this application, it should be understood that the disclosed system, device, and method may be implemented in other ways. For example, the device embodiments described above are only illustrative. For example, the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented. In addition, the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, the functional units in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solution of this application essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including Several instructions are used to make a computer device (which may be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (Read-Only Memory, ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code .
以上所述,仅为本申请的具体实施方式,但本申请的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本申请揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本申请的保护范围之内。因此,本申请的保护范围应以所述权利要求的保护范围为准。The above are only specific implementations of this application, but the protection scope of this application is not limited to this. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in this application. Should be covered within the scope of protection of this application. Therefore, the protection scope of this application should be subject to the protection scope of the claims.
Claims (32)
Priority Applications (1)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| US17/582,880 US12039440B2 (en) | 2019-07-24 | 2022-01-24 | Image classification method and apparatus, and image classification model training method and apparatus |
Applications Claiming Priority (2)
| Application Number | Priority Date | Filing Date | Title |
|---|---|---|---|
| CN201910672533.7 | 2019-07-24 | ||
| CN201910672533.7A CN112287954B (en) | 2019-07-24 | 2019-07-24 | Image classification method, image classification model training method and device |
Related Child Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| US17/582,880 Continuation US12039440B2 (en) | 2019-07-24 | 2022-01-24 | Image classification method and apparatus, and image classification model training method and apparatus |
Publications (1)
| Publication Number | Publication Date |
|---|---|
| WO2021013095A1 true WO2021013095A1 (en) | 2021-01-28 |
Family
ID=74193238
Family Applications (1)
| Application Number | Title | Priority Date | Filing Date |
|---|---|---|---|
| PCT/CN2020/102741 Ceased WO2021013095A1 (en) | 2019-07-24 | 2020-07-17 | Image classification method and apparatus, and method and apparatus for training image classification model |
Country Status (3)
| Country | Link |
|---|---|
| US (1) | US12039440B2 (en) |
| CN (1) | CN112287954B (en) |
| WO (1) | WO2021013095A1 (en) |
Cited By (7)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112949693A (en) * | 2021-02-02 | 2021-06-11 | 北京嘀嘀无限科技发展有限公司 | Training method of image classification model, image classification method, device and equipment |
| CN113689436A (en) * | 2021-09-29 | 2021-11-23 | 平安科技(深圳)有限公司 | Image semantic segmentation method, device, equipment and storage medium |
| CN114821150A (en) * | 2022-03-17 | 2022-07-29 | 北京迈格威科技有限公司 | Image classification method, electronic device, storage medium and program product |
| CN114842236A (en) * | 2022-03-22 | 2022-08-02 | 西北工业大学 | Image classification method and device, computer-readable storage medium and electronic device |
| CN115147452A (en) * | 2021-03-30 | 2022-10-04 | 阿里巴巴新加坡控股有限公司 | Model training method, device and moving object re-identification method |
| CN116168257A (en) * | 2023-04-23 | 2023-05-26 | 安徽大学 | Small sample image classification method, device and storage medium based on sample generation |
| CN116188995A (en) * | 2023-04-13 | 2023-05-30 | 国家基础地理信息中心 | Remote sensing image feature extraction model training method, retrieval method and device |
Families Citing this family (11)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| EP3997625A4 (en) * | 2019-10-29 | 2022-11-09 | Samsung Electronics Co., Ltd. | ELECTRONIC DEVICE AND ASSOCIATED CONTROL METHOD |
| JP7486349B2 (en) * | 2020-05-28 | 2024-05-17 | キヤノン株式会社 | Neural network, neural network learning method, program, and image processing device |
| CN115272752B (en) * | 2022-07-13 | 2025-09-26 | 浙江大华技术股份有限公司 | Method, device, equipment and storage medium for training image classification model |
| CN115294396B (en) * | 2022-08-12 | 2024-04-23 | 北京百度网讯科技有限公司 | Backbone network training method and image classification method |
| CN116089863A (en) * | 2023-01-17 | 2023-05-09 | 重庆邮电大学 | Rolling bearing fault diagnosis method based on scale self-adaptive measurement |
| CN118628781A (en) * | 2023-03-09 | 2024-09-10 | 戴尔产品有限公司 | Method, apparatus and computer program product for model comparison |
| CN116580246B (en) * | 2023-05-31 | 2025-09-02 | 平安科技(深圳)有限公司 | Image classification method and related equipment for incremental learning |
| CN116543264A (en) * | 2023-06-02 | 2023-08-04 | 支付宝(杭州)信息技术有限公司 | Training method of image classification model, image classification method and device |
| CN116994174A (en) * | 2023-07-10 | 2023-11-03 | 深圳市优必选科技股份有限公司 | Video recognition methods, devices, equipment and storage media |
| CN116935160B (en) * | 2023-07-19 | 2024-05-10 | 上海交通大学 | Training method, sample classification method, electronic equipment and medium |
| CN118154593B (en) * | 2024-05-10 | 2024-07-30 | 吉林大学 | A data analysis-based anastomotic complication detection system for rectal surgery |
Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102540164A (en) * | 2012-01-04 | 2012-07-04 | 中国电子科技集团公司第二十八研究所 | Radar radiating source classification modeling method based on incremental learning |
| CN109325532A (en) * | 2018-09-18 | 2019-02-12 | 成都网阔信息技术股份有限公司 | The image processing method of EDS extended data set under a kind of small sample |
| CN109344869A (en) * | 2018-08-28 | 2019-02-15 | 东软集团股份有限公司 | A classification model optimization method, device, storage device, and program product |
| US20190080453A1 (en) * | 2017-09-12 | 2019-03-14 | Nantomics, Llc | Few-shot learning based image recognition of whole slide image at tissue level |
| CN109919252A (en) * | 2019-03-26 | 2019-06-21 | 中国科学技术大学 | A method for generating classifiers from a few labeled images |
| CN109934261A (en) * | 2019-01-31 | 2019-06-25 | 中山大学 | A knowledge-driven parameter propagation model and its few-shot learning method |
Family Cites Families (5)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| WO2010062268A1 (en) * | 2008-11-28 | 2010-06-03 | Agency For Science, Technology And Research | A method for updating a 2 dimensional linear discriminant analysis (2dlda) classifier engine |
| CN108319633B (en) * | 2017-11-17 | 2022-02-11 | 腾讯科技(深圳)有限公司 | Image processing method and device, server, system and storage medium |
| CN108846413B (en) * | 2018-05-21 | 2021-07-23 | 复旦大学 | A zero-shot learning method based on global semantically consistent network |
| CN109919183B (en) * | 2019-01-24 | 2020-12-18 | 北京大学 | A kind of image recognition method, device, device and storage medium based on small sample |
| CN110020682B (en) * | 2019-03-29 | 2021-02-26 | 北京工商大学 | Attention mechanism relation comparison network model method based on small sample learning |
-
2019
- 2019-07-24 CN CN201910672533.7A patent/CN112287954B/en active Active
-
2020
- 2020-07-17 WO PCT/CN2020/102741 patent/WO2021013095A1/en not_active Ceased
-
2022
- 2022-01-24 US US17/582,880 patent/US12039440B2/en active Active
Patent Citations (6)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN102540164A (en) * | 2012-01-04 | 2012-07-04 | 中国电子科技集团公司第二十八研究所 | Radar radiating source classification modeling method based on incremental learning |
| US20190080453A1 (en) * | 2017-09-12 | 2019-03-14 | Nantomics, Llc | Few-shot learning based image recognition of whole slide image at tissue level |
| CN109344869A (en) * | 2018-08-28 | 2019-02-15 | 东软集团股份有限公司 | A classification model optimization method, device, storage device, and program product |
| CN109325532A (en) * | 2018-09-18 | 2019-02-12 | 成都网阔信息技术股份有限公司 | The image processing method of EDS extended data set under a kind of small sample |
| CN109934261A (en) * | 2019-01-31 | 2019-06-25 | 中山大学 | A knowledge-driven parameter propagation model and its few-shot learning method |
| CN109919252A (en) * | 2019-03-26 | 2019-06-21 | 中国科学技术大学 | A method for generating classifiers from a few labeled images |
Non-Patent Citations (1)
| Title |
|---|
| LI AOXUE; LUO TIANGE; XIANG TAO; HUANG WEIRAN; WANG LIWEI: "Few-Shot Learning With Global Class Representations", 2019 IEEE/CVF INTERNATIONAL CONFERENCE ON COMPUTER VISION (ICCV), IEEE, 27 October 2019 (2019-10-27), pages 9714 - 9723, XP033723383, DOI: 10.1109/ICCV.2019.00981 * |
Cited By (10)
| Publication number | Priority date | Publication date | Assignee | Title |
|---|---|---|---|---|
| CN112949693A (en) * | 2021-02-02 | 2021-06-11 | 北京嘀嘀无限科技发展有限公司 | Training method of image classification model, image classification method, device and equipment |
| CN112949693B (en) * | 2021-02-02 | 2024-04-26 | 北京嘀嘀无限科技发展有限公司 | Training method of image classification model, image classification method, device and equipment |
| CN115147452A (en) * | 2021-03-30 | 2022-10-04 | 阿里巴巴新加坡控股有限公司 | Model training method, device and moving object re-identification method |
| CN113689436A (en) * | 2021-09-29 | 2021-11-23 | 平安科技(深圳)有限公司 | Image semantic segmentation method, device, equipment and storage medium |
| CN113689436B (en) * | 2021-09-29 | 2024-02-02 | 平安科技(深圳)有限公司 | Image semantic segmentation method, device, equipment and storage medium |
| CN114821150A (en) * | 2022-03-17 | 2022-07-29 | 北京迈格威科技有限公司 | Image classification method, electronic device, storage medium and program product |
| CN114842236A (en) * | 2022-03-22 | 2022-08-02 | 西北工业大学 | Image classification method and device, computer-readable storage medium and electronic device |
| CN116188995A (en) * | 2023-04-13 | 2023-05-30 | 国家基础地理信息中心 | Remote sensing image feature extraction model training method, retrieval method and device |
| CN116188995B (en) * | 2023-04-13 | 2023-08-15 | 国家基础地理信息中心 | Remote sensing image feature extraction model training method, retrieval method and device |
| CN116168257A (en) * | 2023-04-23 | 2023-05-26 | 安徽大学 | Small sample image classification method, device and storage medium based on sample generation |
Also Published As
| Publication number | Publication date |
|---|---|
| CN112287954A (en) | 2021-01-29 |
| US12039440B2 (en) | 2024-07-16 |
| US20220148291A1 (en) | 2022-05-12 |
| CN112287954B (en) | 2025-01-28 |
Similar Documents
| Publication | Publication Date | Title |
|---|---|---|
| US12039440B2 (en) | Image classification method and apparatus, and image classification model training method and apparatus | |
| US12314343B2 (en) | Image classification method, neural network training method, and apparatus | |
| US20250265808A1 (en) | Image classification method and apparatus | |
| WO2021043168A1 (en) | Person re-identification network training method and person re-identification method and apparatus | |
| US12131521B2 (en) | Image classification method and apparatus | |
| US20220375213A1 (en) | Processing Apparatus and Method and Storage Medium | |
| CN110188795B (en) | Image classification method, data processing method and device | |
| CN110532871B (en) | Method and apparatus for image processing | |
| WO2021043273A1 (en) | Image enhancement method and apparatus | |
| WO2022052601A1 (en) | Neural network model training method, and image processing method and device | |
| WO2022001372A1 (en) | Neural network training method and apparatus, and image processing method and apparatus | |
| WO2021073311A1 (en) | Image recognition method and apparatus, computer-readable storage medium and chip | |
| WO2021022521A1 (en) | Method for processing data, and method and device for training neural network model | |
| WO2022001805A1 (en) | Neural network distillation method and device | |
| WO2021227787A1 (en) | Neural network predictor training method and apparatus, and image processing method and apparatus | |
| WO2022179606A1 (en) | Image processing method and related apparatus | |
| CN110222718B (en) | Image processing methods and devices | |
| WO2021047587A1 (en) | Gesture recognition method, electronic device, computer-readable storage medium, and chip | |
| CN113361549A (en) | Model updating method and related device | |
| CN114339054B (en) | Method and device for generating photographing mode and computer readable storage medium | |
| WO2024067884A1 (en) | Data processing method and related apparatus | |
| WO2022156475A1 (en) | Neural network model training method and apparatus, and data processing method and apparatus | |
| CN114693986A (en) | Training method of active learning model, image processing method and device | |
| WO2023272431A1 (en) | Image processing method and apparatus | |
| WO2021189321A1 (en) | Image processing method and device |
Legal Events
| Date | Code | Title | Description |
|---|---|---|---|
| 121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 20844986 Country of ref document: EP Kind code of ref document: A1 |
|
| NENP | Non-entry into the national phase |
Ref country code: DE |
|
| 122 | Ep: pct application non-entry in european phase |
Ref document number: 20844986 Country of ref document: EP Kind code of ref document: A1 |