A method, device and related products for multi-label image classification
By adopting the preset activation function of label joint distribution and partial label sample training in the multi-label classification model, combined with the Partial Label Loss loss function, the low accuracy problem caused by the failure to consider label correlation in the existing model is solved, and the accuracy of image multi-label classification is improved.
Patent Information
- Application Number
- CN202210982882.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-16
- Publication Date
- 2025-09-09
- Estimated Expiration
- 2042-08-16
AI Technical Summary
Existing multi-label classification models fail to fully consider the correlation between labels, resulting in low classification accuracy, and increasing the size or number of training samples cannot improve classification accuracy.
A multi-label classification model with a preset activation function based on joint label distribution and partial label sample training is adopted. The correlation between labels is considered in the network output layer, and the Partial Label Loss loss function is introduced to reduce labeling bias and overfitting problems.
The accuracy of multi-label image classification is improved, especially the AUC value and F1 value, which reduces the risk of model overfitting and improves classification accuracy.
Smart Images

Figure CN115147666B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of artificial intelligence, and in particular to a method, device, and related products for multi-label image classification. Background Art
[0002] In recent years, deep learning models have become increasingly popular in the field of labeled image classification due to their end-to-end, high accuracy, and high practicality. For example, deep neural network models have been used in the field of single-label image classification. However, in real-world scenarios, multi-label classification of images is often required. A label represents an attribute of the image content.
[0003] Currently, it's possible to perform multi-label image classification using trained multi-label classification models, such as the trained Xception neural network model. Existing models often convert multi-label classification problems into multiple binary classification problems for prediction. For example, N binary classifiers are built for N labels to predict the labels. However, such models have low classification accuracy, and this accuracy cannot be further improved by increasing the training sample size or the number of training cycles. Summary of the Invention
[0004] In view of this, the embodiments of the present application provide a method, device and related products for multi-label image classification, aiming to improve the multi-label classification model and enhance the classification accuracy of multi-label image classification.
[0005] In a first aspect, an embodiment of the present application provides a method for multi-label image classification, the method comprising:
[0006] Get the image to be classified;
[0007] Inputting the image to be classified into a preset first classification model to obtain at least one label of the image to be classified;
[0008] The preset first classification model is used to identify images and perform multi-label classification; the network output layer of the preset first classification model adopts a preset activation function based on joint label distribution;
[0009] The preset first classification model is obtained by training with partial label samples; the partial label samples are samples in which the number of labels trained is less than the total number of actual labels.
[0010] Optionally, the preset first classification model is trained in the following manner:
[0011] Acquire a training sample set, where the training sample set includes a plurality of partially labeled samples;
[0012] For the current round of training, a first classification model is trained based on the training sample set and a preset activation function to obtain the preset first classification model.
[0013] Optionally, the loss function of the preset first classification model is a first loss function; the first loss function is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels.
[0014] Optionally, the first loss function is obtained by:
[0015] Determining a sample-label ratio of the partially labeled samples;
[0016] Determining a first weight of the partially labeled samples according to a preset mapping relationship between the sample label ratio and the sample weight;
[0017] Performing weighted averaging processing on the second loss functions of some labeled samples using the determined first weights to obtain a third loss function;
[0018] The product of the second weight and the third loss function is added to the fourth loss function to obtain the first loss function; the second weight is used to express the contribution of the loss of the training sample set to the final loss.
[0019] Optionally, the preset activation function is a Softmax function.
[0020] In a second aspect, an embodiment of the present application further provides a device for multi-label image classification, the device comprising:
[0021] An acquisition unit, used for acquiring an image to be classified;
[0022] a classification unit, configured to input the image to be classified into a preset first classification model to obtain at least one label of the image to be classified;
[0023] The preset first classification model is used to identify images and perform multi-label classification; the network output layer of the preset first classification model adopts a preset activation function based on joint label distribution;
[0024] The preset first classification model is obtained by training with partial label samples; the partial label samples are samples in which the number of labels trained is less than the total number of actual labels.
[0025] Optionally, the device further includes: a training unit for training the first classification model; the training unit includes:
[0026] An acquisition module, configured to acquire a training sample set, wherein the training sample set includes a plurality of partially labeled samples;
[0027] The training module is used to train the first classification model based on the training sample set and the preset activation function for the current round of training to obtain the preset first classification model.
[0028] Optionally, the loss function of the preset first classification model is a first loss function; the first loss function is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels.
[0029] In a third aspect, an embodiment of the present application further provides an electronic device, comprising: at least one processor and a memory communicatively connected to the at least one processor;
[0030] The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method as described in any one of the first aspects.
[0031] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to cause the computer to execute any of the methods described in the first aspect.
[0032] The present application provides a method, device and related products for multi-label classification of images. When executing the method: first, the image to be classified is obtained, and then the image to be classified is input into a first classification model whose network output layer is a preset activation function to obtain at least one label of the image to be classified. The preset activation function is a function based on the joint distribution of labels, and the training samples are partial label samples. In this way, during the training process, the correlation between labels is fully considered, which avoids the problem of low classification accuracy caused by the use of a discriminant algorithm with independent labels, and can eliminate the problem of overfitting of the model due to label annotation deviation, thereby improving the classification accuracy of multi-label classification of images. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] In order to more clearly illustrate the technical solutions in this embodiment or the prior art, the following briefly introduces the drawings required for use in the embodiment or the prior art description. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0034] Figure 1 A schematic diagram of an application scenario provided in an embodiment of the present application;
[0035] Figure 2 A flowchart of a method for multi-label image classification provided in an embodiment of the present application;
[0036] Figure 3 A flow chart of a training method for a first classification model provided in an embodiment of the present application;
[0037] Figure 4 A schematic diagram of the structure of an apparatus for multi-label image classification provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] As mentioned above, existing models often convert multi-label classification problems into binary classification problems for prediction. The inventors discovered that this approach does not consider the correlation between labels. In addition, existing models often use the Sigmoid function as the activation function of the neural network output layer, treating different label attributes as independent of each other. Moreover, the inventors found that in real images, such as video cover images, attribute correlations often exist between labels. Therefore, in multi-label image classification, using a classification model that does not consider the correlation between labels will reduce classification accuracy.
[0039] Therefore, this application proposes a multi-label classification model that uses a function based on the joint distribution of labels in the network output layer activation function. By considering the correlation between labels in the network output layer, the classification accuracy of image label classification is improved.
[0040] In order to enable those skilled in the art to better understand the technical solution of the present application, first, the application scenario of the technical solution of the present application is described in conjunction with the drawings in the embodiments of the present application.
[0041] See also Figure 1 , is a schematic diagram of an application scenario provided by an embodiment of the present application. Figure 1 As shown, the application scenario includes a terminal device 110, which can be any electronic device with processing capabilities, including but not limited to a smart phone, a tablet computer, a laptop computer, a desktop computer, a server, and the like.
[0042] For example, the terminal device 110 may process the input image 120. Specifically, the terminal device 110 may recognize the input image and, based on the recognition results, determine to add multiple labels 130 to the image. The multiple labels 130 may respectively indicate multiple content attributes in the image. Specifically, the terminal device 110 may, for example, determine the image processing results as multiple labels based on a multi-label classification model. By adding these multiple labels, for example, it is possible to detect objects in the image 120, determine which labels are present in the image 120, and perform multi-label classification on the image.
[0043] This application scenario also includes a server 140. The terminal device 110 can be connected to the server 140 via a network, which can include a wired or wireless communication link. For example, the server 140 can be used to train a multi-label classification model and, in response to a model acquisition request sent by the terminal device 110, send the trained multi-label classification model 150 to the terminal device 110, so that the terminal device 110 can recognize the input image and determine the multiple labels to add to the image 120.
[0044] For example, the server may be a server that provides various services, such as a background management server that provides support for applications running on the terminal device 110. For example, the server may be a cloud server, a server of a distributed system, or a server combined with a blockchain.
[0045] The application scenario also includes a database 160, which may, for example, maintain a large number of images, including labeled images. The labels of the images may indicate an attribute of the image content. For example, the server 140 may access the database 160 and randomly extract a portion of the images from the large number of images in the database, using the extracted images as training samples to train a multi-label classification model. The server 140 may also be used for multimodal feature extraction and fusion 180 and knowledge graph construction 170.
[0046] It should be noted that the training method of the multi-label classification model provided in this application can be executed by the server 140. Accordingly, the training device of the multi-label classification model provided in this application can be set in the server 140. The method of predicting labels provided in this application can be executed by the terminal device 110. Accordingly, the device for predicting labels provided in this application can be set in the terminal device 110.
[0047] It should be understood that Figure 1 The number and type of terminal devices, servers and databases in the embodiment are merely illustrative. Depending on the implementation requirements, any number and type of terminal devices, servers and databases may be provided.
[0048] Multi-label classification models can be applied in a variety of fields, such as content recognition and automatic classification of mobile phone album pictures, or as upstream tasks to provide data and feature support for downstream artificial intelligence tasks such as knowledge graph construction, multimodal feature extraction and fusion.
[0049] The following is a clear and complete description of the technical solutions in the embodiments of this application with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0050] See also Figure 2 , is a flow chart of a method for multi-label image classification provided in an embodiment of the present application. The method includes at least the following steps:
[0051] S201: Obtain an image to be classified.
[0052] The terminal device can obtain the images to be classified in a variety of ways, such as by using an image acquisition device or extracting them from a database. For example, a smartphone or camera can be used to capture a landscape photo or extract a video screenshot as a cover image.
[0053] S202: Inputting the image to be classified into a preset first classification model to obtain at least one label of the image to be classified.
[0054] The terminal device inputs the acquired image to be classified into a preset first classification model. The preset first classification model identifies the attributes in the input image and outputs at least one label of the image to be classified according to a predetermined correspondence between the label and the attribute.
[0055] Tags are used to describe a content attribute of an image. The correspondence between tags and content attributes is predetermined. For example, the correspondence between tags and content attributes can be constructed by adding them. Figure 1 It has been described in detail and will not be elaborated here.
[0056] In an embodiment of the present application, the network output layer of the preset first classification model adopts a preset activation function based on the joint distribution of labels. Exemplary explanation: The existing model adopts the Xception neural network model, and the network output layer adopts the Softmax function as the activation function. That is, each label is predicted simultaneously during application, and the joint distribution relationship between labels is considered in the output layer. In this way, during the training process, the attribute association between labels can be fully considered, thereby avoiding the problem of low classification accuracy caused by using a discriminant algorithm with independent labels, and improving the classification accuracy of multi-label image classification.
[0057] In an embodiment of the present application, a first classification model can be trained by a training sample set and a preset activation function, wherein the training sample set includes a plurality of partially labeled samples. Partially labeled samples are samples in which the number of labels for training is less than the total number of actual labels. For example, a sample set contains 100 samples and the total number of labels for each sample is 10. Among them, 3 labels in 20 samples are not labeled or are artificially masked. That is, if these 20 samples are used as training samples for training, the unlabeled or masked labels will not be recognized for training. That is, if the number of labels participating in the training is less than the total number of actual labels, then these 20 samples are all partially labeled samples. In actual application, selecting partial labels can reduce the probability of ambiguous or mislabeled labels participating in the training. Therefore, using these partially labeled samples as training samples can improve the accuracy of the samples, thereby reducing the degree of overfitting problems in the multi-label classification model after training.
[0058] In addition, the cost of labeling partial labels is lower than that of fully labeled samples, and a large number of partially labeled samples can be collected in a short period of time. Larger training samples also reduce the degree of overfitting problems in the model and improve classification accuracy.
[0059] In an embodiment of the present application, for the first classification model, during the training process, its loss function can be a first loss function, which is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels.
[0060] Example explanation: For example, if the sample label ratio is n, the first loss function can be expressed as
[0061] g(n)=αn β +c
[0062] Where α, β, and c are mapping parameters.
[0063] In the embodiments of the present application, the multi-label classification model selected may be an Xception neural network model. The Xception neural network is an improved Inception network that completely separates channel correlation from spatial correlation by adjusting the ratio of the number of 3*3 convolution branches to the number of 1*1 convolution channels. Compared to the Inception network, the model parameter size is reduced, and the performance of model training and inference is improved. In the embodiments of the present application, other deep convolutional neural networks may also be used as the multi-label classification model.
[0064] The present application provides a method for multi-label classification of images. When executing the method: first, the image to be classified is obtained, and then the image to be classified is input into a first classification model whose network output layer is a preset activation function to obtain at least one label of the image to be classified. The preset activation function is a function based on the joint distribution of labels, and the training samples are partial label samples. In this way, during the training process, the correlation between labels is fully considered, which avoids the problem of low classification accuracy caused by using a discriminant algorithm with independent labels, and can eliminate the problem of overfitting of the model due to label annotation deviation, thereby improving the classification accuracy of multi-label classification of images.
[0065] about Figure 2 There are many ways to implement the training of the multi-label classification model. In order to better illustrate the training of the multi-label classification model, the following description is made in conjunction with the accompanying drawings in the embodiments of this application.
[0066] See also Figure 3 , is a flow chart of a training method for a first classification model provided in an embodiment of the present application. Applied to the Xception neural network model, the method includes at least the following steps:
[0067] S301: Obtain a training sample set and a test set, wherein the training sample set includes a plurality of partially labeled samples and a plurality of fully labeled samples.
[0068] In the embodiment of the present application, partially labeled samples are samples whose number of trained labels is less than the total number of actual labels. Full label samples are a set of samples whose number of trained labels is equal to the total number of actual labels. For example, if the training sample set consists of 100 image samples, and the number of samples whose number of trained labels is less than the total number of actual labels of the samples is 20, then these 20 samples are all partially labeled samples. The remaining 80 samples are fully labeled samples. The training samples in the embodiment of the present application involve both partially labeled samples and fully labeled samples.
[0069] S302: For the current round of training, train a first classification model based on the training sample set and the first loss function to obtain a trained first classification model.
[0070] In an embodiment of the present application, the trained first classification model is the preset first classification model.
[0071] In the current round of training, the obtained training sample set is fed into the first classification model for convolution processing. The network output layer, after being activated by an activation function, outputs the predicted probability of each training label for each sample in the target sample set. The predicted probabilities and the true label vector are used to calculate the current model loss. Stochastic gradient descent is used to minimize the loss and update the model parameters.
[0072] In the embodiment of the present application, a first loss function is introduced. Specifically, the first loss function can be obtained by the following method:
[0073] The sample-label ratio of a partially labeled sample is determined by taking the ratio of the number of training labels to the number of full labels. If the number of training labels is 2 and the total number of labels in the sample is 10, the sample-label ratio is 0.2.
[0074] Then, according to the preset mapping relationship between the sample label ratio and the sample weight, the first weight of the partially labeled sample is determined. In the embodiment of the present application, the mapping relationship between the sample label ratio and the sample weight can be:
[0075]
[0076] Among them, p y is the partial label ratio of each sample in the training sample set, which is determined by calculating the ratio of the number of training labels to the total number of actual labels. α, β, and γ are the mapping parameters of the model, which can be set by those skilled in the art as needed. g(p y ) is the sample weight of the sample.
[0077] The second loss function of the partial label samples is weighted averaged using the determined first weight to obtain a third loss function. In the embodiment of the present application, the second loss function can be an existing Multi-Sigmoid loss function.
[0078] The third loss function can be a Partial Label Loss loss function, specifically:
[0079]
[0080] Among them, C is the complete set of sample labels in the training sample set; Indicates that the sample is marked with the current label; This sample is not annotated with the current label.
[0081] The product of the second weight and the third loss function is added to the fourth loss function to obtain the first loss function. The second weight is used to express the contribution of the loss of the training sample set to the final loss. For example, the fourth loss function is a Multi-Sigmoid loss function (a loss function commonly used in existing models). Then the first loss function is:
[0082] l=l multi-sigmoid +ωl partial-label
[0083] Where ω is the regularization weight that controls the influence of the third loss function on the first loss function, and can be adjusted by those skilled in the art as needed. The Multi-Sigmoid loss function splits the multi-label classification task into multiple binary classification tasks, each of which uses binary cross entropy loss to calculate the loss.
[0084] By introducing a third loss function into the existing loss function and using it to constrain the existing loss function, it can act as a regularization term to a certain extent. By reducing the labeling bias that may be introduced by training with all labels, the degree of overfitting of the model is alleviated, thereby improving the accuracy of multi-label image classification.
[0085] S303: Determine a classification evaluation index of the trained first classification model based on the test set.
[0086] In an embodiment of the present application, the test set is input into the trained first classification model to determine the training results. Specifically, the performance improvement effect of the first classification model can be determined by using classification evaluation indicators. In an embodiment of the present application, the classification evaluation indicators can be the AUC value and F1 value of the classification label.
[0087] S304: In response to the classification indicator meeting a preset condition, completing the training of the first classification model.
[0088] In the embodiment of the present application, the classification indicator is the above-mentioned classification evaluation indicator. It is determined whether the classification evaluation indicator reaches a preset threshold. If so, the training of the multi-label classification model is completed. Otherwise, the model mapping parameters need to be adjusted and the classification model training is continued until the preset threshold is met.
[0089] In an embodiment of the present application, by introducing the first loss function Partial Label Loss loss function, the impact of the sample set composed of partial label samples on the entire training can be determined, the degree of overfitting problem of the model can be reduced, and the classification accuracy of the first classification model after training can be further improved.
[0090] For a more vivid explanation Figure 3 The training of the multi-label classification model is illustrated below using a 480P video cover image as an input sample:
[0091] The target sample set size is 10 million, and the test set size is 1 million. Partially annotated samples (with fewer than 3 labels) account for approximately 70% of the total number of samples. Specifically, samples with 1 label account for 27.91% of the partially annotated samples, and samples with 2 labels account for 40.75% of the partially annotated samples. The total number of image label categories is 1,600, including ancient costumes, urban scenes, dramas, etc. Each label of each image is represented as a 1,600-dimensional sparse multi-hot vector. The annotated label dimension is assigned 1, and the unannotated label dimension is assigned 0.
[0092] The target sample set and its corresponding labels were input into the Xception neural network model for supervised learning training. The network output layer used the Softmax function as the activation function. The model output was a 1600-dimensional sparse vector, with each dimension ranging from 0 to 1.
[0093] The Softmax function is:
[0094]
[0095] The loss function used in this model is:
[0096] l=l multi-sigmoid +ωl partial-label
[0097] The model uses label AUC value and F1 value as evaluation indicators. After a small-scale pre-training to search for mapping parameters, a set of ideal parameter selections (α=0.1, β=1, γ=-1, ω=0.1) is obtained. After 1 million steps of training using the above training model, compared with the existing model, the AUC value slightly decreased by 0.10%, and the F1 value increased by 1.20%. The AUC value and F1 value obtained by the specific softmax part label model compared with the existing model are shown in Table 1. In the embodiment of the present application, the existing model is a model obtained by training the Xception neural network model combined with the sigmoid activation function.
[0098]
[0099] Table 1
[0100] The embodiment of the present application uses a large number of partially labeled image samples for training, adds PartialLabel Loss loss to the model, and improves the regularization of Multi-Sigmoid Loss, thereby improving the F1 value while maintaining a high AUC value, further improving the accuracy of image multi-label classification.
[0101] The present application also provides a schematic diagram of a device 400 for multi-label image classification. Figure 4 .Depend on Figure 4 It can be seen that the device 400 includes:
[0102] The acquisition unit 401 is used to acquire an image to be classified.
[0103] The classification unit 402 is configured to input the image to be classified into a preset first classification model to obtain at least one label of the image to be classified.
[0104] The preset first classification model is used to identify images and perform multi-label classification. The network output layer of the preset first classification model adopts a preset activation function based on the joint distribution of labels.
[0105] Optionally, the apparatus 400 further includes: a training unit for training the first classification model. The training unit includes:
[0106] An acquisition module is used to acquire a training sample set, where the training sample set includes a plurality of partially labeled samples, where the partially labeled samples are samples whose number of training labels is less than the total number of actual labels;
[0107] The training module is used to train the first classification model based on the training sample set and the preset activation function for the current round of training to obtain the preset first classification model.
[0108] Optionally, the loss function of the preset first classification model is a first loss function; the first loss function is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels.
[0109] Optionally, the loss function of the preset first classification model is a first loss function; the first loss function is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels.
[0110] Optionally, the first loss function is obtained by:
[0111] Determining a sample label ratio of the partially labeled samples; determining a first weight of the partially labeled samples according to a preset mapping relationship between the sample label ratio and the sample weight;
[0112] Performing weighted averaging processing on the second loss functions of some labeled samples using the determined first weights to obtain a third loss function;
[0113] The fourth loss function is added to the product of the second weight and the third loss function to obtain the first loss function; the second weight is used to express the contribution of the loss of the training sample set to the final loss.
[0114] Optionally, the preset activation function is the Softmax activation function.
[0115] An embodiment of the present application provides a multi-label classification device for an image. In which, an acquisition unit 401 acquires an image to be classified. The classification unit 402 inputs the image to be classified into a first classification model whose network output layer is a preset activation function to obtain at least one label of the image to be classified. In which, the preset activation function is a function based on the joint distribution of labels, and the training samples are partial label samples. In this way, during the training process, the correlation between labels is fully considered, avoiding the problem of low classification accuracy caused by using a discriminant algorithm with independent labels, and can eliminate the problem of overfitting of the model due to label annotation deviation, thereby improving the accuracy of multi-label classification of images.
[0116] In addition, the embodiments of the present application also provide an electronic device and a computer storage medium for implementing the solution provided by the embodiments of the present application.
[0117] Among them, an electronic device includes: at least one processor and a memory communicatively connected to the at least one processor; the memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform a method for multi-label image classification.
[0118] The computer storage medium stores code. When the code is executed, the device executing the code implements the method for multi-label image classification described in any embodiment of the present application.
[0119] The "first" and "second" in the names such as "first" and "second" (if any) mentioned in the embodiments of this application are only used as name identifiers and do not represent the first or second in order.
[0120] Through the description of the above embodiments, it can be known that those skilled in the art can clearly understand that all or part of the steps in the above embodiment methods can be implemented by means of software plus a general hardware platform. Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a storage medium, such as a read-only memory (ROM) / RAM, a magnetic disk, an optical disk, etc., and includes a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network communication device such as a router) to execute the methods described in each embodiment or certain parts of the embodiments of the present application.
[0121] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple. For the relevant parts, refer to the partial description of the method embodiment. Some or all of the modules can be selected according to actual needs to achieve the purpose of the embodiment. Those of ordinary skill in the art can understand and implement it without paying any creative work.
[0122] The above description is merely an exemplary embodiment of the present application and is not intended to limit the scope of protection of the present application.
Claims
1. A method for multi-label image classification, characterized in that: The method comprises: Get the image to be classified; Inputting the image to be classified into a preset first classification model to obtain at least one label of the image to be classified; the label is used to represent a content attribute of the image; Among them, the preset first classification model is used to recognize images and perform multi-label classification; the network output layer of the preset first classification model adopts a preset activation function based on the joint distribution of labels; the loss function of the preset first classification model is the first loss function; the first loss function is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels; the method of obtaining the first loss function includes: determining the first weight of the partial label sample according to the mapping relationship between the preset sample label ratio and the sample weight; using the determined first weight to perform weighted averaging on the second loss function of the partial label sample to obtain a third loss function; adding the product of the second weight and the third loss function to the fourth loss function to obtain the first loss function; the second weight is used to express the contribution of the loss of the training sample set to the final loss; The preset first classification model is obtained by training with partial label samples; the partial label samples are samples in which the number of labels trained is less than the total number of actual labels.
2. The method according to claim 1, characterized in that The preset first classification model is trained in the following way: Acquire a training sample set, where the training sample set includes a plurality of partially labeled samples; For the current round of training, a first classification model is trained based on the training sample set and a preset activation function to obtain the preset first classification model.
3. The method according to claim 1 or 2, characterized in that The preset activation function is the Softmax activation function.
4. A device for multi-label image classification, characterized in that: The device comprises: An acquisition unit, used for acquiring an image to be classified; a classification unit, configured to input the image to be classified into a preset first classification model to obtain at least one label of the image to be classified; Among them, the preset first classification model is used to recognize images and perform multi-label classification; the network output layer of the preset first classification model adopts a preset activation function based on the joint distribution of labels; the loss function of the preset first classification model is the first loss function; the first loss function is related to the sample label ratio of the partial label samples; the sample label ratio is the ratio of the number of trained labels in the sample to the total number of actual labels; the method of obtaining the first loss function includes: determining the first weight of the partial label sample according to the mapping relationship between the preset sample label ratio and the sample weight; using the determined first weight to perform weighted averaging on the second loss function of the partial label sample to obtain a third loss function; adding the product of the second weight and the third loss function to the fourth loss function to obtain the first loss function; the second weight is used to express the contribution of the loss of the training sample set to the final loss; The preset first classification model is obtained by training with partial label samples; the partial label samples are samples in which the number of labels trained is less than the total number of actual labels.
5. The device according to claim 4, characterized in that The apparatus further includes: a training unit for training a first classification model; the training unit includes: An acquisition module, configured to acquire a training sample set, wherein the training sample set includes a plurality of partially labeled samples; The training module is used to train the first classification model based on the training sample set and the preset activation function for the current round of training to obtain the preset first classification model.
6. An electronic device comprising: at least one processor and a memory communicatively coupled to the at least one processor; The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 3.
7. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable the computer to execute the method according to any one of claims 1 to 3.
Citation Information
Patent Citations
Image multi-label classification method and device, equipment and storage medium
CN114443877A