Training methods for classification models, image classification methods, devices and electronic equipment
By clustering and labeling training images, a classification model capable of recognizing multi-level categories is generated, solving the problem of poor adaptability of existing classification models and achieving efficient classification in different business scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-02
- Publication Date
- 2026-03-06
AI Technical Summary
In existing technologies, classification models have poor adaptability in different business scenarios and cannot simultaneously identify different levels of category labels, resulting in trained models that cannot meet diverse classification needs.
By clustering the training images, multiple clusters are generated, and the second-level category labels of the training images are determined based on the clusters. The basic classification model is trained by combining the first-level and second-level category labels to generate a classification model that can recognize multi-level categories.
It improves image annotation efficiency and enhances the adaptability of the classification model, enabling it to meet coarse-to-fine classification needs in different business scenarios.
Smart Images

Figure CN115222991B_ABST
Abstract
Description
Technical Field
[0001] This disclosure relates to the field of computer technology, and in particular to a method for training a classification model, an image classification method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product. Background Technology
[0002] With the continuous development of computer technology, more and more content platforms are using classification models to perform image classification tasks. In certain business scenarios of content platforms, some subcategories are often merged into a large category for business definition. For example, subcategories such as Corgi, Golden Monkey, and Fish are defined as a large category called "Animal". Then, image samples containing the above subcategories are used for binary classification training to determine whether an image is an "animal".
[0003] However, different business scenarios often have different requirements for broad categories. For example, business scenario A defines corgis, golden monkeys, and fish as "animals"; business scenario B defines corgis and golden monkeys (excluding fish) as animals (referring only to "terrestrial animals"). When this happens, it is usually necessary to train the classification model used in business scenario A and the classification model used in business scenario B separately, which results in the trained classification model having poor adaptability. Summary of the Invention
[0004] This disclosure provides a method for training a classification model, an image classification method, an apparatus, an electronic device, a computer-readable storage medium, and a computer program product, to at least solve the problem of poor adaptability of classification models trained in related technologies. The technical solution of this disclosure is as follows:
[0005] According to a first aspect of the present disclosure, a method for training a classification model is provided, comprising:
[0006] Acquire training images, which carry first-level category labels;
[0007] The training images are clustered to obtain multiple clusters;
[0008] Based on the cluster to which the training image belongs, determine the second-level category label of the training image;
[0009] The basic classification model is trained using the training images carrying the first-level category label and the second-level category label to obtain a classification model. The basic classification model is the model obtained after training using the training images carrying the first-level category label.
[0010] In one embodiment, determining the second-level category label of the training image based on the cluster to which the training image belongs includes:
[0011] Determine the correlation coefficient between the training image and the cluster to which the training image belongs;
[0012] The second-level category label of the training image is determined based on the correlation coefficient.
[0013] In one embodiment, when the correlation coefficient is represented by the distance between the training image and the cluster center of the cluster to which the training image belongs, determining the second-level category label of the training image based on the correlation coefficient includes:
[0014] For training images whose distance is less than or equal to a distance threshold, a first preset value is used as the second-level category label of the training image;
[0015] For training images whose distance is greater than the distance threshold, the cluster center of the cluster to which the training image belongs is used as the second-level category label of the training image.
[0016] In one embodiment, when the correlation coefficient is represented by the number of images in the cluster to which the training image belongs, determining the second-level category label of the training image based on the correlation coefficient includes:
[0017] For training images in clusters where the number of images is less than or equal to a threshold, a first preset value is used as the second-level category label of the training image;
[0018] For training images in clusters where the number of images exceeds the threshold, the cluster center of the cluster to which the training image belongs is used as the second-level category label of the training image.
[0019] In one embodiment, training the basic classification model using the training images carrying the first-level category label and the second-level category label to obtain the classification model includes:
[0020] The training image carrying the first-level category label and the second-level category label is input into the basic classification model to obtain the first loss of the first-level category label and the second loss of the second-level category label. When the second-level category label is the first preset value, the second loss is the second preset value.
[0021] The loss value is determined based on the first loss and the second loss;
[0022] The model parameters of the basic classification model are adjusted based on the loss value until the training stopping condition is met, thus obtaining the classification model.
[0023] In one embodiment, determining the loss value of the training image based on the first loss and the second loss includes:
[0024] The loss value is obtained by weighting the first loss, the second loss, and the preset weight coefficient corresponding to the second loss.
[0025] In one embodiment, the method further includes:
[0026] Obtain test images from the business side, wherein the test images differ from the second-level categories to which the training images belong;
[0027] The test image is classified and identified using the classification model to obtain a first confidence level corresponding to the first-level category and a second confidence level corresponding to the second-level category.
[0028] A first confidence threshold for the first-level category is generated based on the first confidence level, and a second confidence threshold for the second-level category is generated based on the second confidence level.
[0029] The classification model is configured using the first confidence threshold and the second confidence threshold to obtain the classification model used by the business terminal.
[0030] In one embodiment, the clustering process of the training images to obtain multiple clusters includes:
[0031] The training images are used to extract features using the basic classification model to obtain the image features of the training images;
[0032] The training images are clustered based on their image features to obtain the multiple clusters.
[0033] According to a second aspect of the present disclosure, an image classification method is provided, comprising:
[0034] Obtain the image to be classified;
[0035] The image to be classified is input into the classification model, and the classification model is used to classify and identify the image to be classified, thereby obtaining the first-level category and the second-level category of the image to be classified.
[0036] The classification model is a model trained using the training method of the classification model described in any one of the first aspects.
[0037] According to a third aspect of the present disclosure, a training apparatus for a classification model is provided, comprising:
[0038] The image acquisition module is configured to acquire training images, which carry first-level category labels;
[0039] The clustering module is configured to perform clustering processing on the training images to obtain multiple clusters;
[0040] The annotation module is configured to determine the second-level category label of the training image based on the cluster to which the training image belongs;
[0041] The training module is configured to train a base classification model using the training images carrying the first-level category label and the second-level category label to obtain a classification model, wherein the base classification model is a model obtained after training using the training images carrying the first-level category label.
[0042] In one embodiment, the annotation module includes:
[0043] The coefficient determination unit is configured to perform the task of determining the association coefficient between the training image and the cluster to which the training image belongs;
[0044] The labeling unit is configured to perform the task of determining a second-level category label for the training image based on the correlation coefficient.
[0045] In one embodiment, when the correlation coefficient is represented by the distance between the training image and the cluster center of the cluster to which the training image belongs, the labeling unit is configured to perform the following actions: for training images whose distance is less than or equal to a distance threshold, use a first preset value as the second-level category label of the training image; for training images whose distance is greater than the distance threshold, use the cluster center of the cluster to which the training image belongs as the second-level category label of the training image.
[0046] In one embodiment, when the correlation coefficient is represented by the number of images in the cluster to which the training image belongs, the labeling unit is configured to perform the following operations: for training images in clusters where the number of images is less than or equal to a threshold, the first preset value is used as the second-level category label of the training image; for training images in clusters where the number of images is greater than the threshold, the cluster center of the cluster to which the training image belongs is used as the second-level category label of the training image.
[0047] In one embodiment, the training module includes:
[0048] The loss acquisition unit is configured to input the training image carrying the first-level category label and the second-level category label into the base classification model to obtain a first loss for the first-level category label and a second loss for the second-level category label. When the second-level category label is the first preset value, the second loss is the second preset value.
[0049] The loss generation unit is configured to determine a loss value based on the first loss and the second loss;
[0050] The parameter adjustment unit is configured to adjust the model parameters of the base classification model according to the loss value until the training stopping condition is met, thereby obtaining the classification model.
[0051] In one embodiment, the loss generation unit is configured to perform a weighted sum based on the first loss, the second loss, and a preset weight coefficient corresponding to the second loss to obtain the loss value.
[0052] In one embodiment, the image acquisition module is configured to acquire a test image from the service terminal, wherein the test image differs from the second-level category to which the training image belongs;
[0053] The device further includes: a classification and recognition module, configured to perform classification and recognition on the test image through the classification model to obtain a first confidence level corresponding to a first-level category and a second confidence level corresponding to a second-level category;
[0054] The threshold generation module is configured to generate a first confidence threshold for the first-level category based on the first confidence level, and generate a second confidence threshold for the second-level category based on the second confidence level.
[0055] The model configuration module is configured to configure the classification model using the first confidence threshold and the second confidence threshold to obtain the classification model used by the business end.
[0056] In one embodiment, the clustering module includes:
[0057] The feature extraction unit is configured to perform feature extraction on the training image using the base classification model to obtain the image features of the training image;
[0058] The clustering unit is configured to perform clustering processing on the training images based on the image features of the training images to obtain the plurality of clusters.
[0059] According to a fourth aspect of the present disclosure, an image classification apparatus is provided, comprising:
[0060] The image acquisition module is configured to acquire images to be classified.
[0061] The classification module is configured to input the image to be classified into a classification model, and classify and identify the image to be classified through the classification model to obtain a first-level category and a second-level category of the image to be classified; wherein the classification model is a model trained using the training method of the classification model described in any of the first aspects.
[0062] According to a fifth aspect of the present disclosure, an electronic device is provided, comprising:
[0063] processor;
[0064] Memory used to store the processor's executable instructions;
[0065] The processor is configured to execute the instructions to implement a training method for a classification model as described in any embodiment of the first aspect, and / or to implement an image classification method as described in the second aspect.
[0066] According to a sixth aspect of the present disclosure, a computer-readable storage medium is provided, wherein when instructions in the computer-readable storage medium are executed by a processor of an electronic device, the electronic device is enabled to perform a training method for a classification model as described in any embodiment of the first aspect, and / or to implement an image classification method as described in the second aspect.
[0067] According to a seventh aspect of the present disclosure, a computer program product is provided, the computer program product including instructions that, when executed by a processor of an electronic device, enable the electronic device to perform a training method for a classification model as described in any embodiment of the first aspect, and / or to implement an image classification method as described in the second aspect.
[0068] The technical solutions provided by the embodiments of this disclosure bring at least the following beneficial effects:
[0069] This paper presents a training method for a cluster-based classification model. After acquiring training images carrying first-level labels, the training images are clustered to obtain multiple clusters. Based on the cluster to which the training image belongs, it is automatically labeled to obtain second-level category labels, thus improving the efficiency of image labeling. The basic classification model is trained using training images carrying both first-level and second-level category labels, resulting in a classification model capable of simultaneously recognizing category labels at different levels. This can meet the needs of various business scenarios requiring different levels of category recognition, from coarse to fine.
[0070] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description
[0071] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this disclosure and, together with the description, serve to explain the principles of this disclosure, and are not intended to unduly limit this disclosure.
[0072] Figure 1 This is an exemplary schematic diagram illustrating image classification processing in a related art.
[0073] Figure 2 This is a flowchart illustrating a training method for a classification model according to an exemplary embodiment.
[0074] Figure 3 This is a schematic diagram illustrating an image classification process according to an exemplary embodiment.
[0075] Figure 4 This is a flowchart illustrating a training process for a basic classification model according to an exemplary embodiment.
[0076] Figure 5 This is a flowchart illustrating a testing procedure for a classification model according to an exemplary embodiment.
[0077] Figure 6 This is a flowchart illustrating a training method for a classification model according to an exemplary embodiment.
[0078] Figure 7 This is an application environment diagram illustrating an image classification method according to an exemplary embodiment.
[0079] Figure 8 This is a flowchart illustrating an image classification method according to an exemplary embodiment.
[0080] Figure 9 This is a block diagram illustrating a training apparatus for a classification model according to an exemplary embodiment.
[0081] Figure 10 This is a block diagram illustrating an image classification apparatus according to an exemplary embodiment.
[0082] Figure 11 This is a block diagram illustrating an electronic device according to an exemplary embodiment.
[0083] Figure 12 This is a block diagram illustrating another electronic device according to an exemplary embodiment. Detailed Implementation
[0084] To enable those skilled in the art to better understand the technical solutions of this disclosure, the technical solutions in the embodiments of this disclosure will be clearly and completely described below with reference to the accompanying drawings.
[0085] It should be noted that the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in orders other than those illustrated or described herein. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this disclosure. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this disclosure as detailed in the appended claims.
[0086] It should also be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for display, data used for analysis, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties.
[0087] Figure 1 This diagram illustrates the classification process of a classification model in related technologies. A classification model typically consists of two parts: a feature extractor and a classifier. The feature extractor extracts high-level semantic features (e.g., contour, shape, texture, etc.) from the input image after layers of processing. The classifier maps these high-level semantic features to corresponding categories, learning the mapping relationship between features and categories. In related technologies, such as... Figure 1 As shown, in certain business scenarios of content platforms, several subcategories are often merged into a single broad category for business definition. For example, subcategories such as Corgi, Golden Monkey, and Fish are defined as a single broad category called "Animal." Then, image samples containing these subcategories are used for binary classification training to determine whether an image is an "animal." However, the training methods employed in these techniques suffer from poor adaptability in the resulting classification model.
[0088] To address the aforementioned technical problems, the classification model training method provided in this disclosure can be applied to electronic devices. The electronic device may include a terminal, a server, or a model training system comprising a terminal and a server. A basic classification model is pre-deployed in the electronic device; this basic classification model is a model pre-trained using training images carrying first-level category labels. Specifically, the electronic device acquires training images carrying first-level category labels; performs clustering processing on the training images to obtain multiple clusters; labels the training images according to their clusters to obtain second-level category labels; and trains the basic classification model using the training images carrying both first-level and second-level category labels to obtain a classification model, which can then be configured by different business terminals to meet their varying classification needs.
[0089] The terminals can be, but are not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, and smart in-vehicle systems. Portable wearable devices can include smartwatches, smart bracelets, and head-mounted devices. Servers can be implemented using independent servers or server clusters composed of multiple servers.
[0090] Figure 2 This is a flowchart illustrating a training method for a classification model according to an exemplary embodiment, such as... Figure 2 As shown, the training method for the classification model is used in electronic devices, including steps S210 to S240.
[0091] In step S210, training images are acquired, and the training images carry first-level category labels.
[0092] The training images consist of several images, each labeled with a first-level category label.
[0093] In this embodiment of the disclosure, the categories include multiple levels, and the scope of a category decreases as the level increases. In one example, the first-level category is the category with the broadest coverage; for example, several training images can be divided into two first-level categories: whether they are animals or not. The second-level category has a narrower coverage than the first-level category; for example, the aforementioned training images can be divided into three second-level categories.
[0094] Specifically, the first-level category labels can be labels obtained in advance through manual or machine annotation. Several training images can be pre-stored in the local database of the electronic device, or uploaded to the electronic device when model training is required.
[0095] In step S220, the training images are clustered to obtain multiple clusters.
[0096] The number of clusters can be pre-configured according to actual needs.
[0097] Specifically, clustering is a process that uses clustering algorithms to divide the objects to be processed into multiple disjoint clusters according to a specific criterion (e.g., distance), maximizing the similarity of objects within the same cluster while maximizing the differences between objects in different clusters. Clustering can employ any of the following methods: partitioning clustering (e.g., K-means clustering), hierarchical clustering (e.g., Agglomerative clustering), and density clustering (e.g., DBSCAN, Density-Based Spatial Clustering of Applications with Noise). In this embodiment, after acquiring several training images, the electronic device extracts features from each training image to obtain image features for each training image. A pre-configured clustering algorithm is then used to cluster the several training images based on the image features of each training image, resulting in multiple clusters, each cluster containing at least one similar training image. Feature extraction for each training image can be performed using any model with feature extraction capabilities, such as ResNet (Residual Network 50, a residual network), Inception (an asymmetric convolutional network), DenseNet (a densely connected convolutional network), etc.
[0098] In step S230, the second-level category label of the training image is determined according to the cluster to which the training image belongs.
[0099] Specifically, each cluster can have a unique cluster identifier, which can be represented by a number, cluster center, etc. After the electronic device performs clustering processing on several training images to obtain multiple clusters, the training images belonging to each cluster can be labeled using the cluster identifier corresponding to the cluster, thus obtaining the second-level category label corresponding to each training image.
[0100] In step S240, the basic classification model is trained using training images carrying first-level category labels and second-level category labels to obtain the classification model.
[0101] The base classification model can be any model with classification and recognition capabilities, such as ResNet50, Inception-v3, DenseNet, etc. In this embodiment, the base classification model is a model obtained by training several training images carrying first-level category labels. Specifically, each training image labeled with the first-level category label can be input into the initial base classification model, which then classifies and recognizes each training image to obtain the predicted category of each training image. A loss function is used to calculate the loss value based on the predicted category and the first-level category label, and the model parameters of the initial base classification model are adjusted in the direction of decreasing the loss value until the training stopping condition is met, thus obtaining the base classification model.
[0102] Specifically, refer to Figure 3 After labeling each training image with a second-level category label, the electronic device inputs each training image, labeled with both first-level and second-level category labels, into the base classification model. The base classification model then extracts features and classifies each training image, obtaining the first-level and second-level predicted categories for each image. A loss function is then used to calculate the loss value based on the first-level predicted category, the second-level predicted category, the first-level category label, and the second-level category label. The model parameters of the base classification model are adjusted in the direction that the loss value decreases until the training stopping condition is met, resulting in a classification model capable of simultaneously recognizing multiple categories.
[0103] The loss function can be any of the following: cross-entropy loss function, relative entropy loss function, etc. The training stopping condition can be any of the following: the number of training iterations reaches a preset number, the model accuracy reaches a preset accuracy, or the loss value reaches a preset loss value.
[0104] In one embodiment, the electronic device can continue to annotate the training images according to steps S220-S230 to obtain more refined third-level category labels, ..., Mth-level category labels (M is a positive integer greater than or equal to 3). Step S240 is repeated, using training images carrying first-level to Nth-level category labels to train the basic classification model, resulting in a classification model capable of simultaneously recognizing N levels of categories. This better meets the subsequent coarse-to-fine classification and recognition needs of different business applications.
[0105] The training method for the aforementioned classification model provides a cluster-based approach. After acquiring training images carrying first-level labels, the training images are clustered to obtain multiple clusters. Based on the cluster to which the training image belongs, it is automatically labeled to obtain second-level category labels, thus improving labeling efficiency. The basic classification model is trained using training images carrying both first-level and second-level category labels, resulting in a classification model capable of simultaneously recognizing category labels at different levels. This meets the needs of various business scenarios requiring coarse-to-fine category recognition at different levels.
[0106] In an exemplary embodiment, step S220, clustering the training images to obtain multiple clusters, includes: extracting features from the training images using a basic classification model to obtain image features of the training images; and clustering the training images based on the image features of the training images to obtain multiple clusters.
[0107] Specifically, after acquiring several training images, the electronic device can use the feature extractor in the basic classification model to extract features from each training image, obtaining the image features (embedding) for each training image. A pre-configured clustering algorithm is then used to cluster the several training images based on the image features of each training image, resulting in multiple clusters. Since the basic classification model is trained and is the model most relevant to the current classification task, using it to extract features from the training images can improve the relevance of image features to the training task, thereby helping to improve the model's performance.
[0108] In one exemplary embodiment, such as Figure 4 As shown, after training the classification model, the method further includes:
[0109] In step S410, the test image of the business side is obtained.
[0110] The test images consist of a set number. Different business units may use different test images, depending on their classification requirements. The second-level categories of the test images may differ from those of the training images. In one example, the training images may contain second-level categories 1, 2, 3, and 4. The test images may contain only second-level categories 1 and 4. Alternatively, the test images may belong to the same second-level category as the training images.
[0111] Specifically, several test images can be pre-stored in the local database of the electronic device, or uploaded to the electronic device when model testing is required.
[0112] In step S420, the test image is classified and identified using a classification model to obtain the first confidence level corresponding to the first-level category and the second confidence level corresponding to the second-level category.
[0113] The confidence level can be represented using probability.
[0114] Specifically, the electronic device uses the classification model trained in steps S210 to S240 to classify and identify each test image, and obtains the first confidence level of each first-level category corresponding to each test image, and the second confidence level corresponding to each second-level category.
[0115] In step S430, a first confidence threshold for the first-level category is generated based on the first confidence level, and a second confidence threshold for the second-level category is generated based on the second confidence level.
[0116] Specifically, the electronic device calculates a first evaluation metric for the classification model and a corresponding first confidence threshold based on the first confidence score of several test images for each first-level category. The first evaluation metric can be one or more of precision, recall, and error rate. Correspondingly, the electronic device calculates a second evaluation metric for the classification model and a corresponding second confidence threshold based on the second confidence score of several test images for each second-level category. The second evaluation metric can also be one or more of precision, recall, and error rate.
[0117] In step S440, a classification model is configured using a first confidence threshold and a second confidence threshold to obtain the classification model used by the business side.
[0118] Specifically, the electronic device configures the classification model using a first confidence threshold corresponding to each first-level category and a second confidence threshold corresponding to each second-level category, resulting in a classification model suitable for the business application that can classify and recognize both first-level and second-level categories. In one example, during training, several training images of a group of animals are classified into second-level categories 1, 2, 3, and 4. During testing, it is found that several test images of a group of land animals on the business application only contain second-level categories 1 and 4. Therefore, the classification model obtained during testing, corresponding to the business application, has the ability to classify and recognize both second-level categories 1 and 4.
[0119] In one embodiment, since the second-level category labels obtained based on cluster annotation do not have explicit meaning, the business side can deploy a mapping relationship between the second-level categories and the actual categories. After the corresponding classification model on the business side is put into use, the second-level categories identified by the classification model on the business side can be mapped to the actual category to which the image belongs based on this mapping relationship. Continuing with the above example, a mapping relationship between second-level category 1 and second-level category 4 and land animals can be deployed on the business side. If the classification model on the business side identifies a certain image as second-level category 1 or second-level category 4, then the explicit classification result of the image as a land animal can be output. Thus, a bridge from "animal" to "land animal" is built through cluster categories.
[0120] In this embodiment, the trained classification model is tested using test images that meet the requirements of the business side, so that different business sides can obtain a classification model suitable for themselves based on the same trained classification model, thereby improving the efficiency of the business side in deploying the classification model and simplifying the operation process of the business side in deploying the classification model.
[0121] In an exemplary embodiment, step S230, which involves labeling the training image according to the cluster to which the training image belongs, to obtain a second-level category label, includes: determining the correlation coefficient between the training image and the cluster to which the training image belongs; and labeling the training image according to the correlation coefficient to obtain a second-level category label for the training image.
[0122] The correlation coefficient can be represented, but is not limited to, by the distance between a training image and the cluster center of its cluster, or by the number of training images in the cluster to which the training image belongs. Distance can be represented by Euclidean distance, cosine distance, etc.
[0123] Specifically, after the electronic device has clustered several training images, the correlation coefficient between each training image and the cluster to which each training image belongs is obtained. Based on the correlation coefficient, the second-level category label of each training image is obtained, and then the training image is labeled.
[0124] In one exemplary embodiment, when the correlation coefficient is represented by the distance between the training image and the cluster center of the cluster to which the training image belongs, for training images whose distance is less than or equal to a distance threshold, a first preset value can be used to label the training image to obtain a second-level category label for the training image. For training images whose distance is greater than the distance threshold, the cluster center of the cluster to which the training image belongs can be used to label the training image to obtain a second-level category label for the training image.
[0125] The first preset value is used for sample selection during training. During training, training images labeled with the first preset value can be excluded from the loss calculation, or their loss weight can be reduced. The first preset value can be any value that distinguishes it from the cluster center, such as -1. The distance threshold can be determined according to actual needs, for example, 0.5. In one example, training image 1 and training image 2 belong to cluster A. If the distance between training image 1 and the cluster center of cluster A is greater than the distance threshold, then training image 1 is labeled with a second-level category label of -1; if the distance between training image 2 and the cluster center of cluster A is less than or equal to the distance threshold, then training image 1 is labeled with a second-level category label of the cluster center of cluster A. Since distance reflects the correlation between the training image and the cluster center, the smaller the distance, the stronger the correlation. By setting the second-level category label of training images far from the cluster center to the first preset value, image samples with low confidence can be eliminated, thereby helping to improve the accuracy of the model.
[0126] In another exemplary embodiment, when the correlation coefficient is represented by the number of images in the cluster to which the training image belongs, for training images in clusters with an image count less than or equal to a threshold, a first preset value can be used to label the training images in that cluster, resulting in a second-level category label for the training images. For training images in clusters with an image count greater than the threshold, the cluster center of the cluster to which the training image belongs can be used to label the training images in that cluster, resulting in a second-level category label for the training images. The threshold can be determined according to actual needs. In one example, the threshold can be a fixed value; in another example, the threshold can be determined based on the number of clusters, for example, configured as: threshold = total number of training samples / 3N, where N is the number of clusters. By setting the second-level category label of training images in clusters with fewer samples to the first preset value, clusters with fewer samples can be eliminated, thereby reducing the noise impact of small samples and improving the accuracy of the model.
[0127] In one exemplary embodiment, such as Figure 5 As shown, in step S150, the basic classification model is trained using training images carrying first-level category labels and second-level category labels to obtain the classification model. This can be specifically implemented through steps S510 to S530.
[0128] In step S510, the training images carrying the first-level category label and the second-level category label are input into the basic classification model to obtain the first loss of the first-level category label and the second loss of the second-level category label.
[0129] In step S520, the loss value is determined based on the first loss and the second loss.
[0130] In step S530, the model parameters of the basic classification model are adjusted according to the loss value until the training stopping condition is met, and the classification model is obtained.
[0131] Specifically, after labeling each training image with a second-level category label, the electronic device inputs each training image labeled with both first-level and second-level category labels into the base classification model. The base classification model extracts features and classifies each training image, obtaining the first-level predicted category and the second-level predicted category for each training image. A first loss is calculated based on the first-level predicted category and the first-level category label using a loss function. A second loss is calculated based on the second-level predicted category and the second-level category label using a loss function. It's important to note that when the second-level category label is a first preset value, the second loss is a second preset value. This second preset value is used to reduce the impact of training images with the second-level category label of the first preset value on model training. The second preset value can be set according to actual needs; for example, it can be 0. The electronic device calculates the first and second losses to obtain the loss value and adjusts the model parameters of the base classification model in the direction of decreasing the loss value until the training stopping condition is met, resulting in a classification model capable of recognizing multi-level categories. The electronic device can perform calculations on the first and second losses using any of the following methods: addition, multiplication, weighted sum, etc.
[0132] In this embodiment, by using the original classification task and a multi-classification task based on clustering to jointly train the model, not only can the trained classification model have the ability to recognize different levels of category labels at the same time, thereby improving the adaptability of the classification model, but it can also improve the robustness of feature representation.
[0133] In an exemplary embodiment, step S520, determining the loss value based on the first loss and the second loss, includes: performing a weighted sum based on the first loss, the second loss, and a preset weighting coefficient corresponding to the second loss to obtain the loss value.
[0134] The weighting coefficients can be pre-configured hyperparameters. Since the multi-class classification task involving clustering generally has a large loss, a large weighting coefficient would easily lead to the model, after joint training, being more inclined to learn the multi-class classification task involving clustering with the larger loss. Therefore, in this embodiment, the weighting coefficients can be configured to values less than 1, for example, 0.5. In this embodiment, the loss value of the training image can be calculated using the following formula:
[0135] Loss = Loss1 + b * Loss2
[0136] Where Loss represents the loss value; Loss1 represents the first loss; Loss2 represents the second loss; and b represents the weighting coefficient.
[0137] In this embodiment, by assigning corresponding weight coefficients to the multi-classification task of clustering clusters, the model can learn in a balanced manner in classification tasks at different levels, thus ensuring the model's ability to handle classification tasks at different levels simultaneously.
[0138] In one exemplary embodiment, such as Figure 6 As shown, a method for training a classification model is provided, including steps S602 to S622.
[0139] In step S602, several training images are acquired, each carrying a first-level category label, which can be a binary classification label.
[0140] In step S604, feature extraction is performed on each training image using a base classification model to obtain the image features of each training image. The base classification model is a model obtained by training the training images carrying first-level category labels.
[0141] In step S606, the K-means algorithm is used to cluster several training images based on the image features of each training image, resulting in multiple clusters. Each cluster contains at least one training image of similar category.
[0142] In step S608, the correlation coefficient between the training image and the cluster to which the training image belongs is determined. The training image is then labeled according to the correlation coefficient to obtain the second-level category label of the training image. The specific implementation of the correlation coefficient and the labeling of the training image based on the correlation coefficient can be found in the above embodiments, and will not be elaborated upon here.
[0143] In step S610, the training images carrying first-level and second-level category labels are input into the basic classification model to obtain a first loss for the first-level category label and a second loss for the second-level category label. Wherein, if the second-level category label is a first preset value, the second loss is a second preset value.
[0144] In step S612, the product of the preset weight coefficient and the second loss is obtained, and then the sum of the first loss and the product is obtained to get the loss value.
[0145] In step S614, the model parameters of the basic classification model are adjusted according to the loss value until the training stopping condition is met, and the classification model is obtained.
[0146] In step S616, several test images are acquired from the business side. The second-level categories to which the test images belong may differ from those to which the training images belong.
[0147] In step S618, each test image is classified and identified using a classification model to obtain the first confidence level corresponding to each first-level category and the second confidence level corresponding to each second-level category for each test image.
[0148] In step S620, a first confidence threshold for the first-level category is generated based on the first confidence level and the precision-recall curve corresponding to the first-level category; a second confidence threshold for the second-level category is generated based on the second confidence level and the precision-recall curve corresponding to the second-level category.
[0149] In step S622, the classification model is configured using the first confidence threshold and the second confidence threshold to obtain the classification model used by the business side.
[0150] The image classification method provided in this disclosure can be applied to, for example... Figure 7 In the application environment shown, terminal 710 interacts with server 720 via a network. A data storage system can store the data that server 720 needs to process. The data storage system can be integrated onto server 720 or placed on a cloud or other network server. Terminal 710 is equipped with a client capable of displaying multimedia resources, which can be, but is not limited to, video, social, instant messaging, e-commerce, etc. Multimedia resources can be digitally transmitted resources such as images and videos. Server 720 is equipped with a classification model for image classification processing. This classification model is trained using any of the above-described training methods. Specifically, server 720 acquires the image to be classified uploaded by terminal 110; inputs the image to be classified into the classification model; and uses the classification model to classify and identify the image to be classified, obtaining the first-level category and the second-level category of the image.
[0151] Among them, terminal 710 can be, but is not limited to, various personal computers, laptops, smartphones, tablets, IoT devices, and portable wearable devices. IoT devices can include smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, etc. Portable wearable devices can include smartwatches, smart bracelets, head-mounted devices, etc. Server 720 can be implemented using a standalone server or a server cluster composed of multiple servers.
[0152] Figure 8 This is a flowchart illustrating an image classification method according to an exemplary embodiment, such as... Figure 8 As shown, the image classification method is used in the server and includes steps S810 to S820.
[0153] In step S810, the image to be classified is obtained.
[0154] In step S820, the image to be classified is input into the classification model, and the classification model is used to classify and identify the image to be classified to obtain the first-level category and the second-level category of the image to be classified.
[0155] The classification model is a model that is trained and tested using any of the above-mentioned classification model training methods and is applicable to the current business.
[0156] The images to be classified can be images directly uploaded through the current business terminal; or images extracted from video files uploaded through the current business terminal, such as the cover image or keyframes of the video file.
[0157] Specifically, after acquiring the image to be classified, the server inputs it into the classification model corresponding to the current business terminal. This model performs feature extraction and classification on the image, obtaining the confidence score for each first-level category and the confidence score for each second-level category. The server outputs the first-level category that satisfies the first confidence threshold and the second-level category that satisfies the second confidence threshold, thus obtaining the first-level and second-level categories of the image to be classified.
[0158] In one embodiment, the classification model may output only the second-level category.
[0159] In one embodiment, the business side can deploy a mapping relationship between the second-level category and the actual category. After the classification model outputs the first-level category and the second-level category, the second-level category can be mapped to the actual category to which the image to be classified belongs based on the mapping relationship.
[0160] It should be understood that although the steps in the flowchart above are shown sequentially as indicated by the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowchart above may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0161] It is understood that the same / similar parts between the various embodiments of the methods described above in this specification can be referred to each other. Each embodiment focuses on the differences from other embodiments, and relevant parts can be referred to the description of other method embodiments.
[0162] Figure 9This is a block diagram of a classification model training apparatus 900 according to an exemplary embodiment. (Refer to...) Figure 9 The device 900 includes an image acquisition module 902, a clustering module 904, an annotation module 906, and a training module 908.
[0163] Image acquisition module 902 is configured to acquire training images carrying first-level category labels; clustering module 904 is configured to perform clustering processing on the training images to obtain multiple clusters; annotation module 906 is configured to determine the second-level category label of the training image based on the cluster to which the training image belongs; training module 908 is configured to train a basic classification model using training images carrying first-level and second-level category labels to obtain a classification model, wherein the basic classification model is the model obtained after training using training images carrying first-level category labels.
[0164] In one exemplary embodiment, the annotation module 906 includes: a coefficient determination unit configured to determine the association coefficient between a training image and the cluster to which the training image belongs; and a label annotation unit configured to determine a second-level category label for the training image based on the association coefficient.
[0165] In an exemplary embodiment, when the correlation coefficient is represented by the distance between the training image and the cluster center of the cluster to which the training image belongs, the labeling unit is configured to perform the following actions: for training images whose distance is less than or equal to a distance threshold, the first preset value is used as the second-level category label of the training image; for training images whose distance is greater than the distance threshold, the cluster center of the cluster to which the training image belongs is used as the second-level category label of the training image.
[0166] In an exemplary embodiment, when the correlation coefficient is represented by the number of images in the cluster to which the training image belongs, the labeling unit is configured to perform the following actions: for training images in clusters where the number of images is less than or equal to a threshold, the first preset value is used as the second-level category label of the training image; for training images in clusters where the number of images is greater than the threshold, the cluster center of the cluster to which the training image belongs is used as the second-level category label of the training image.
[0167] In an exemplary embodiment, the training module 908 includes: a loss acquisition unit configured to input training images carrying first-level category labels and second-level category labels into a base classification model to obtain a first loss for the first-level category labels and a second loss for the second-level category labels, wherein the second loss is a second preset value when the second-level category label is a first preset value; a loss generation unit configured to determine a loss value based on the first loss and the second loss; and a parameter adjustment unit configured to adjust the model parameters of the base classification model based on the loss value until the training stopping condition is met to obtain a classification model.
[0168] In one exemplary embodiment, the loss generation unit is configured to perform a weighted sum based on a first loss, a second loss, and a preset weight coefficient corresponding to the second loss to obtain a loss value.
[0169] In one exemplary embodiment, the image acquisition module 902 is configured to acquire a test image from the service terminal, wherein the test image and the training image belong to different second-level categories; the apparatus 900 further includes: a classification and recognition module configured to perform classification and recognition on the test image using a classification model to obtain a first confidence level corresponding to a first-level category and a second confidence level corresponding to a second-level category; a threshold generation module configured to generate a first confidence threshold for the first-level category based on the first confidence level and generate a second confidence threshold for the second-level category based on the second confidence level; and a model configuration module configured to configure a classification model using the first confidence threshold and the second confidence threshold to obtain a classification model used by the service terminal.
[0170] In one exemplary embodiment, the clustering module 904 includes: a feature extraction unit configured to perform feature extraction on the training image using a basic classification model to obtain image features of the training image; and a clustering unit configured to perform clustering processing on the training image based on the image features of the training image to obtain multiple clusters.
[0171] Figure 10 This is a block diagram of an image classification apparatus 1000 according to an exemplary embodiment. (Refer to...) Figure 10 The device 1000 includes an image acquisition module 1002 and a classification module 1004.
[0172] Image acquisition module 1002 is configured to acquire an image to be classified; classification module 1004 is configured to input the image to be classified into a classification model, and classify and identify the image to be classified through the classification model to obtain the first-level category and the second-level category of the image to be classified; wherein, the classification model is a model trained using the training method of the classification model described in any of the above embodiments.
[0173] Regarding the apparatus in the above embodiments, the specific manner in which each module performs its operation has been described in detail in the embodiments related to the method, and will not be elaborated upon here.
[0174] Figure 11 This is a block diagram illustrating an electronic device Z00 for training a classification model and / or classifying images based on the classification model, according to an exemplary embodiment. For example, the electronic device Z00 may be a mobile phone, computer, digital broadcasting terminal, messaging device, game console, tablet device, medical device, fitness equipment, personal digital assistant, etc.
[0175] Reference Figure 11 The electronic device Z00 may include one or more of the following components: processing component Z02, memory Z04, power supply component Z06, multimedia component Z08, audio component Z10, input / output (I / O) interface Z12, sensor component Z14, and communication component Z16.
[0176] Processing component Z02 typically controls the overall operation of electronic device Z00, such as operations associated with display, telephone calls, data communication, camera operation, and recording. Processing component Z02 may include one or more processors Z20 to execute instructions to complete all or part of the steps of the methods described above. Furthermore, processing component Z02 may include one or more modules to facilitate interaction between processing component Z02 and other components. For example, processing component Z02 may include a multimedia module to facilitate interaction between multimedia component Z08 and processing component Z02.
[0177] Memory Z04 is configured to store various types of data to support the operation of electronic device Z00. Examples of this data include instructions for any application or method operating on electronic device Z00, contact data, phonebook data, messages, pictures, videos, etc. Memory Z04 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, optical disk, or graphene memory.
[0178] Power supply component Z06 provides power to various components of electronic device Z00. Power supply component Z06 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to electronic device Z00.
[0179] Multimedia component Z08 includes a screen that provides an output interface between the electronic device Z00 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touchscreen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors may sense not only the boundaries of the touch or swipe action but also the duration and pressure associated with the touch or swipe operation. In some embodiments, multimedia component Z08 includes a front-facing camera and / or a rear-facing camera. When the electronic device Z00 is in an operating mode, such as a shooting mode or a video mode, the front-facing camera and / or the rear-facing camera may receive external multimedia data. Each front-facing camera and rear-facing camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
[0180] Audio component Z10 is configured to output and / or input audio signals. For example, audio component Z10 includes a microphone (MIC) configured to receive external audio signals when electronic device Z00 is in an operating mode, such as call mode, recording mode, and voice recognition mode. The received audio signals may be further stored in memory Z04 or transmitted via communication component Z16. In some embodiments, audio component Z10 also includes a speaker for outputting audio signals.
[0181] I / O interface Z12 provides an interface between processing component Z02 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include, but are not limited to, home buttons, volume buttons, power buttons, and lock buttons.
[0182] Sensor assembly Z14 includes one or more sensors for providing state assessments of various aspects of electronic device Z00. For example, sensor assembly Z14 can detect the on / off state of electronic device Z00, the relative positioning of components such as the display and keypad of electronic device Z00, changes in position of electronic device Z00 or its components, the presence or absence of user contact with electronic device Z00, orientation or acceleration / deceleration of device Z00, and temperature changes of electronic device Z00. Sensor assembly Z14 may include a proximity sensor configured to detect the presence of nearby objects without any physical contact. Sensor assembly Z14 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, sensor assembly Z14 may also include an accelerometer, gyroscope, magnetometer, pressure sensor, or temperature sensor.
[0183] Communication component Z16 is configured to facilitate wired or wireless communication between electronic device Z00 and other devices. Electronic device Z00 can access wireless networks based on communication standards, such as WiFi, carrier networks (such as 2G, 3G, 4G, or 5G), or combinations thereof. In one exemplary embodiment, communication component Z16 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, communication component Z16 also includes a near-field communication (NFC) module to facilitate short-range communication. For example, the NFC module may be implemented based on radio frequency identification (RFID) technology, Infrared Data Association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology, and other technologies.
[0184] In an exemplary embodiment, the electronic device Z00 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the methods described above.
[0185] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory Z04 including instructions, which can be executed by a processor Z20 of an electronic device Z00 to perform the above-described method. For example, the computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0186] In an exemplary embodiment, a computer program product is also provided, the computer program product including instructions that can be executed by a processor Z20 of an electronic device Z00 to perform the above method.
[0187] Figure 12 This is a block diagram illustrating an electronic device S00 for training a classification model and / or classifying images based on the classification model, according to an exemplary embodiment. For example, the electronic device S00 can be a server. (Refer to...) Figure 12 The electronic device S00 includes a processing component S20, which further includes one or more processors, and memory resources represented by a memory S22 for storing instructions, such as application programs, that can be executed by the processing component S20. The application programs stored in the memory S22 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component S20 is configured to execute instructions to perform the methods described above.
[0188] The electronic device S00 may further include: a power supply component S24 configured to perform power management of the electronic device S00, a wired or wireless network interface S26 configured to connect the electronic device S00 to a network, and an input / output (I / O) interface S28. The electronic device S00 can operate on an operating system stored in memory S22, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, or similar.
[0189] In an exemplary embodiment, a computer-readable storage medium including instructions is also provided, such as a memory S22 including instructions, which can be executed by a processor of an electronic device S00 to perform the above-described method. The storage medium can be a computer-readable storage medium, for example, a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0190] In an exemplary embodiment, a computer program product is also provided, the computer program product including instructions that can be executed by a processor of an electronic device S00 to perform the above method.
[0191] It should be noted that the above-mentioned apparatus, electronic equipment, computer-readable storage medium, computer program product, etc., may also include other implementation methods according to the description of the method embodiments. For specific implementation methods, please refer to the description of the relevant method embodiments, which will not be elaborated here.
[0192] Other embodiments of this disclosure will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This disclosure is intended to cover any variations, uses, or adaptations of this disclosure that follow the general principles of this disclosure and include common knowledge or customary techniques in the art not disclosed herein. The specification and examples are to be considered exemplary only, and the true scope and spirit of this disclosure are indicated by the claims.
[0193] It should be understood that this disclosure is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of this disclosure is limited only by the appended claims.
Claims
1. A method for training a classification model, characterized in that, The method comprises the following steps: obtaining training images carrying first-level category labels; performing clustering processing on the training images to obtain a plurality of clustering clusters; determining second-level category labels of the training images according to the clustering clusters to which the training images belong; training a basic classification model using the training images carrying the first-level category labels and the second-level category labels to obtain a classification model, wherein the basic classification model is a model obtained by training using the training images carrying the first-level category labels; determining the second-level category labels of the training images according to the clustering clusters to which the training images belong comprises: determining a correlation coefficient between the training images and the clustering clusters to which the training images belong; and determining the second-level category labels of the training images according to the correlation coefficient; when the correlation coefficient is represented by a distance between the training images and clustering cluster centers of the clustering clusters to which the training images belong, determining the second-level category labels of the training images according to the correlation coefficient comprises: for training images with a distance less than or equal to a distance threshold, taking a first preset value as the second-level category label of the training images; and for training images with a distance greater than the distance threshold, taking the clustering cluster center of the clustering cluster to which the training images belong as the second-level category label of the training images; the first preset value is a value that is distinguished from the clustering cluster center. 2.The method of claim 1, wherein, when the correlation coefficient is represented by the number of images in the clustering cluster to which the training images belong; determining the second-level category labels of the training images according to the correlation coefficient comprises: for training images in a clustering cluster with a number of images less than or equal to a number threshold, taking a first preset value as the second-level category label of the training images; for training images in a clustering cluster with a number of images greater than the number threshold, taking the clustering cluster center of the clustering cluster to which the training images belong as the second-level category label of the training images.
3. The method of claim 1 or 2, wherein the method further comprises: training the basic classification model using the training images carrying the first-level category labels and the second-level category labels to obtain a classification model comprises: inputting the training images carrying the first-level category labels and the second-level category labels into the basic classification model to obtain a first loss of the first-level category labels and a second loss of the second-level category labels, wherein the second loss is a second preset value in the case that the second-level category label is the first preset value; determining a loss value according to the first loss and the second loss; adjusting model parameters of the basic classification model according to the loss value until a training stop condition is met to obtain the classification model.
4. The method of claim 3, wherein the training of the classification model is performed by using a machine learning algorithm. determining the loss value according to the first loss and the second loss comprises: performing weighted sum on the first loss, the second loss, and a preset weight coefficient corresponding to the second loss to obtain the loss value. 5.The method of claim 1 or 2, wherein, The method further comprises: obtaining test images of a service end, wherein the test images differ from the second-level categories to which the training images belong. The test image is classified and recognized by the classification model to obtain a first confidence degree corresponding to the first-level category and a second confidence degree corresponding to the second-level category; The first confidence degree threshold of the first-level category is generated according to the first confidence degree, and the second confidence degree threshold of the second-level category is generated according to the second confidence degree; The classification model used by the service end is obtained by configuring the classification model with the first confidence degree threshold and the second confidence degree threshold. 6.The method of claim 1 or 2, wherein, The training image is clustered to obtain a plurality of clustering clusters, including: The training image is subjected to feature extraction by the basic classification model to obtain image features of the training image; The training image is subjected to clustering processing based on the image features of the training image to obtain the plurality of clustering clusters.
7. An image classification method characterized by, Including: Obtaining an image to be classified; The image to be classified is input into a classification model, and the image to be classified is classified and recognized by the classification model to obtain a first-level category and a second-level category of the image to be classified; The classification model is a model obtained by training the classification model using the training method of any one of claims 1-6. 8.A device for training a classification model, comprising: Including: An image acquisition module configured to perform obtaining a training image, the training image carrying a first-level category label; A clustering module configured to perform clustering processing on the training image to obtain a plurality of clustering clusters; A labeling module configured to perform determining a second-level category label of the training image according to a clustering cluster to which the training image belongs; A training module configured to perform training a basic classification model using the training image carrying the first-level category label and the second-level category label to obtain a classification model, the basic classification model being a model obtained by training the training image carrying the first-level category label; The labeling module is further configured to determine a correlation coefficient between the training image and the clustering cluster to which the training image belongs; when the correlation coefficient is represented by a distance between the training image and a clustering cluster center of the clustering cluster to which the training image belongs, the determining of the second-level category label of the training image according to the correlation coefficient includes: for the training image with a distance less than or equal to a distance threshold, a first preset value is taken as the second-level category label of the training image; For the training image with a distance greater than the distance threshold, the clustering cluster center of the clustering cluster to which the training image belongs is taken as the second-level category label of the training image; the first preset value is a value distinguishing from the clustering cluster center.
9. An image classification apparatus characterized by comprising: Including: An image acquisition module configured to perform obtaining an image to be classified; A classification module configured to perform inputting the image to be classified into a classification model, and classifying and recognizing the image to be classified by the classification model to obtain a first-level category and a second-level category of the image to be classified; The classification model is a model obtained by training the classification model using the training method of any one of claims 1-6.
10. An electronic device, comprising: Including: A processor; A memory for storing instructions executable by the processor; The processor is configured to execute the instructions to implement the training method of the classification model as claimed in any one of claims 1 to 6, and / or to implement the image classification method as claimed in claim 7.
11. A computer readable storage medium, characterized in that, When the instructions in the computer-readable storage medium are executed by the processor of the electronic device, the electronic device is enabled to perform the training method of the classification model as claimed in any one of claims 1 to 6, and / or to implement the image classification method as claimed in claim 7.
12. A computer program product, comprising instructions therein, characterised in that, The instructions are executed by the processor of the electronic device, the electronic device is enabled to perform the training method of the classification model as claimed in any one of claims 1 to 6, and / or to implement the image classification method as claimed in claim 7.
Citation Information
Patent Citations
Image recognition method and system based on hierarchical category dynamic calculation
CN114492630A
Animal identification method and device, equipment, storage medium and program product
CN114818971A