Model training method and apparatus, and electronic device
By automatically determining the labeling of sample images for a multi-label classification model based on preset rules, the problems of high training cost and long training cycle are solved, achieving high efficiency and accuracy in model training.
Patent Information
- Application Number
- CN202310620468.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2026-01-09
- Estimated Expiration
- 2043-05-29
AI Technical Summary
When training multi-label classification models, existing technologies require manual relabeling of the training dataset, resulting in high training costs and long training cycles.
By obtaining the first label of the sample image, determining the second label of the sample image under the target category based on the preset transformation rule, and setting the labels under other categories besides the first category as preset labels, the multi-label classification model is trained using the sample image and the second label.
It improves the training accuracy and efficiency of multi-label classification models, reduces the need for manual annotation, and shortens the training cycle.
Smart Images

Figure CN116580266B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of artificial intelligence, in particular to the technical field of image processing, deep learning and the like, and specifically to a model training method and device and an electronic device. BACKGROUND
[0002] In training a single-label classification model, only one or several categories (such as people, animals, food, etc.) are generally marked in the sample pictures of the training data set, and other categories existing in the sample pictures are ignored. In training a multi-label classification model, the training data needs to be manually reorganized to mark all categories corresponding to the multi-label classification model, resulting in high model training cost and long training period. SUMMARY
[0003] The present disclosure provides a model training method, device and electronic device.
[0004] According to an aspect of the present disclosure, a model training method is provided, comprising:
[0005] obtaining a first data set, at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected, wherein the first data set comprises sample images and at least one first annotation label of the sample images;
[0006] determining a second annotation label of the sample images under the first category based on a preset conversion rule and the first annotation label;
[0007] determining the second annotation label of the sample images under other categories in the target categories except the first category as a first preset label;
[0008] training the multi-label classification model to be corrected by using the sample images and the second annotation label of the sample images under the target categories, to obtain the multi-label classification model.
[0009] According to another aspect of the present disclosure, a model training device is provided, comprising:
[0010] an obtaining module configured to obtain a first data set, at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected, wherein the first data set comprises sample images and at least one first annotation label of the sample images;
[0011] a determining module configured to determine a second annotation label of the sample images under the first category based on a preset conversion rule and the first annotation label;
[0012] the determining module is configured to determine the second annotation label of the sample images under other categories in the target categories except the first category as a first preset label;
[0013] The training module is configured to train the multi-label classification model to be corrected by using the sample image and the second label of the sample image in the target category, so as to obtain the multi-label classification model.
[0014] According to another aspect of the present disclosure, an electronic device is provided, comprising:
[0015] at least one processor; and
[0016] a memory in communication connection with the at least one processor; wherein
[0017] The memory stores instructions executable 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 of the above-mentioned embodiments.
[0018] According to another aspect of the present disclosure, a non-transitory computer readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable a computer to perform the method according to the above-mentioned embodiments.
[0019] It should be understood that the contents described in this part are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they used to limit the scope of the present disclosure. Other features of the present disclosure will become apparent through the following description. BRIEF DESCRIPTION OF DRAWINGS
[0020] The accompanying drawings are used to better understand the present scheme and do not constitute a limitation on the present disclosure. Among them:
[0021] Figure 1 A flowchart of a model training method provided by an embodiment of the present disclosure is shown;
[0022] Figure 2 A flowchart of another model training method provided by an embodiment of the present disclosure is shown;
[0023] Figure 3 A flowchart of another model training method provided by an embodiment of the present disclosure is shown;
[0024] Figure 4 A flowchart of another model training method provided by an embodiment of the present disclosure is shown;
[0025] Figure 5 A structural diagram of another model training device provided by an embodiment of the present disclosure is shown;
[0026] Figure 6 A block diagram of an electronic device for implementing the model training of the embodiments of the present disclosure is shown. DETAILED DESCRIPTION
[0027] Exemplary embodiments of the present disclosure are described herein with reference to the accompanying drawings, which are meant to be exemplary in nature, and include various details intended to facilitate understanding of the present disclosure. Accordingly, it should be understood that various changes and modifications to the embodiments described herein can be made by those having ordinary skill in the art without departing from the scope and spirit of the present disclosure. Also, for the purpose of clarity and a concise description, descriptions of well-known functions and constructions are omitted from the following description.
[0028] Artificial intelligence is a discipline that studies the use of computers to simulate some thinking processes and intelligent behaviors of people (such as learning, reasoning, thinking, planning, etc.), which has both hardware and software technical fields. Artificial intelligence hardware technology generally includes technologies such as sensors, special artificial intelligence chips, cloud computing, distributed storage, big data processing, etc.; artificial intelligence software technology includes computer vision technology, speech recognition technology, natural language processing technology, and deep learning, big data processing technology, knowledge graph technology, etc. several directions.
[0029] The model training method, device, electronic device and storage medium of the embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0030] It should be noted that the model training method implemented by the present disclosure is configured in a model training device (hereinafter referred to as a training device) for illustration. The determination device can be applied to any electronic device to enable the electronic device to perform the function of training the model.
[0031] Among them, the electronic device can be any device with computing power, for example, it can be a personal computer (Personal Computer, PC for short), a mobile terminal, etc. The mobile terminal can be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, etc. Hardware devices with various operating systems, touch screens and / or display screens.
[0032] Figure 1 A flowchart of a model training method provided by the embodiments of the present disclosure is shown.
[0033] As shown in Figure 1 , the method comprises:
[0034] Step 101, obtaining a first data set, at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected, wherein the first data set comprises a sample image and at least one first annotation label of the sample image.
[0035] Among them, the first category is a category with lower classification accuracy corresponding to the multi-label classification model to be corrected. The first category can be pre-set in the system.
[0036] In the present disclosure, the multi-label classification model can be used to determine whether the image contains objects under multiple target categories. For example, the multi-label classification model can be used to determine whether the image contains people, animals, etc. Generally, the multi-label classification model supports more target categories for classification, and the multi-label classification model obtained by training can have low accuracy in classifying a certain target category. The multi-label classification model can be continuously trained (i.e., corrected) using sample images to improve the accuracy of the multi-label classification model in classifying all target categories.
[0037] In the present disclosure, the label annotation manner of the sample images in the first data set is different from the label annotation manner of the sample images corresponding to the multi-label classification model, and the sample images in the first data set are not labeled with annotation labels under all target categories. When training the multi-label classification model using the first data set, the annotation labels of each sample image in the first data set under all target categories need to be determined before the multi-label classification model can be trained using the first data set.
[0038] In addition, the first data set can include multiple sub-data sets, and the label annotation manner of the sample images in each sub-data set can be different. When the first categories are multiple, the categories corresponding to the first annotation labels of all sample images in the first data set can include part or all of the first categories.
[0039] Step 102, based on the preset conversion rule and the first annotation label, determining the second annotation label of the sample image under the first category.
[0040] In the present disclosure, the conversion rule between the first annotation label of the sample image in the first data set and the target category corresponding to the multi-label classification model can be determined in advance. Then, based on the conversion rule, the first annotation label of the sample image is converted to determine the second annotation label of the sample image under the first category. Thus, the efficiency and accuracy of sample image annotation are improved, and the accuracy of the multi-label classification model is improved.
[0041] Optionally, when the first data set includes multiple sub-data sets, the first annotation label of the sample image in each sub-data set can be converted based on the conversion rule between the first annotation label of the sample image in each sub-data set and the target category corresponding to the multi-label classification model, to determine the second annotation label of the sample image under the first category.
[0042] Step 103, determining the second annotation label of the sample image under the other categories except the first category in the target categories as the first preset label.
[0043] The first preset label is used to identify that the sample image is in an unknown state under the corresponding target category. The first preset label can be identified by a value such as -1. The present disclosure does not limit this.
[0044] In the present disclosure, the second annotation label of the sample image in other categories except the first category in the target categories can be determined as the first preset label. The influence of shielding the second annotation label of the sample image in other categories on training the multi-label classification model is shielded, and the accuracy of the multi-label classification model in classifying in other categories is ensured.
[0045] Optionally, in the case that the first category is multiple, and the second annotation label of a certain sample image in a certain first category in the multiple first categories is failed to be determined based on the preset conversion rule and the first annotation label, the second annotation label of the sample image in the first category can be determined as the first preset label.
[0046] In step 104, the multi-label classification model to be corrected is trained by using the sample image and the second annotation label of the sample image in the target category, so as to obtain the multi-label classification model.
[0047] In the present disclosure, after the second annotation label of the sample image in each target category is determined, the multi-label classification model to be corrected can be trained by using the sample image and the second annotation label of the sample image in each target category, so as to obtain the multi-label classification model. Therefore, the accuracy of the multi-label classification model training is improved.
[0048] For example, the sample image can be input into the multi-label classification model to be corrected, the confidence of the second annotation label in each target category output by the multi-label classification model is obtained, and the loss value is determined based on each confidence and the second annotation label. Then, the multi-label classification model can be corrected based on the loss value to obtain the final multi-label classification model.
[0049] The loss value can be determined by the following loss function:
[0050]
[0051] wherein y i is the second annotation label in the i-th target category, p(y i ) is the confidence of the second annotation label in the i-th target category output by the multi-label classification model, and N is the sample quantity.
[0052] Optionally, the target category corresponding to the second annotation label which is not the first preset label can be determined as an effective category. Then, the multi-label classification model to be corrected can be trained by using the sample image and the second annotation label of the sample image in the effective category, so as to obtain the final multi-label classification model. Therefore, the accuracy of the model training is improved.
[0053] In the present disclosure, after obtaining a first data set including sample images and at least one first annotation label of the sample images, at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected, based on a preset conversion rule and the first annotation label, a second annotation label of the sample images in the first category is determined, and a second annotation label of the sample images in other categories except the first category in the target categories is determined as a first preset label. Then, the multi-label classification model to be corrected is trained by using the sample images and the second annotation label of the sample images in the target categories, to obtain a multi-label classification model. Thus, by determining the second annotation label of the sample images in the first category in the target categories based on the preset conversion rule and the first annotation label, and setting the second annotation label of the sample images in other categories except the first category in the target categories as the first preset label, the accuracy and efficiency of determining the second annotation label of the sample images are improved, and the influence of the second annotation label in other categories on training the multi-label classification model is avoided, thereby improving the accuracy and efficiency of training the multi-label classification model.
[0054] Figure 2 A flowchart of a model training method provided by an embodiment of the present disclosure is shown.
[0055] As shown in Figure 2 , the method comprises:
[0056] Step 201: obtaining a first data set, at least one first category in a plurality of target categories corresponding to a multi-label classification model to be corrected, wherein the first data set includes sample images and at least one first annotation label of the sample images.
[0057] In the present disclosure, the specific implementation process of step 201 can refer to the detailed description of any embodiment of the present disclosure, which will not be repeated here.
[0058] Step 202: when the first annotation label is one, and all the first annotation labels in the first data set correspond to a plurality of second categories, if the second category corresponding to the first annotation label of the sample images is the same as the first category, the second annotation label of the sample images in the first category is determined as a second preset label.
[0059] The second preset label is used to identify that the sample images contain objects in the corresponding target categories. The second preset label can be identified by a numerical value such as 1, and the present disclosure does not limit this.
[0060] In the present disclosure, in the case that each sample image corresponds to only one first annotation label, and the first annotation labels of all sample images in the first data set correspond to multiple second categories, that is, in the case that the first data set is a single-label multi-classification training data set. For example, the first annotation label of sample image 1 is 0, the first annotation label of sample image 2 is 1, and the first annotation labels of other sample images in the first data set are only 0 or 1. Wherein, 0 represents that the sample image contains a person and does not contain a vehicle, and 1 represents that the sample image contains a vehicle and does not contain a person.
[0061] At this time, when the second category corresponding to the first annotation label of the sample image is the same as the first category, the second annotation label of the sample image under the first category is determined as the second preset label. For example, the first category is “person”, the first annotation label of sample image 1 is 0, and the corresponding second category is “person”. It can be determined that sample image 1 only contains a person, and therefore it can be determined that the second annotation label of sample image 1 under the first category “person” is the second preset label.
[0062] Step 203, in the case that the second category corresponding to the first annotation label of the sample image is different from the first category, the second annotation label of the sample image under the first category is determined as the third preset label.
[0063] Wherein, the third preset label is used to identify that the sample image does not contain the object under the corresponding target category. The third preset label can be identified by 0 and the like, and the present disclosure does not make any limitation in this regard.
[0064] In the present disclosure, in the case that the second category corresponding to the first annotation label of the sample image is different from the first category, it is indicated that the sample image does not contain the object under the first category. Therefore, the second annotation label of the sample image under the first category can be determined as the third preset label. Thus, the accuracy of the second annotation label of the sample image under the target category is improved.
[0065] For example, the first category is “person”, the first annotation label of sample image 2 is 1, and the corresponding second category is “vehicle”. It can be determined that sample image 1 only does not contain a person, and therefore it can be determined that the second annotation label of sample image 2 under the first category “person” is the third preset label.
[0066] Step 204, determining the second annotation label of the sample image under the other categories in the target category except the first category as the first preset label.
[0067] Step 205, training the multi-label classification model to be corrected by using the sample image and the second annotation label of the sample image under the target category, to obtain the multi-label classification model.
[0068] In the present disclosure, the specific implementation process of steps 204-205 can be referred to the detailed description of any embodiment of the present disclosure, which will not be repeated here.
[0069] In the present disclosure, after obtaining the first data set including the sample image and the at least one first annotation label of the sample image, and at least one first category in the plurality of target categories supported by the multi-label classification model to be corrected, in the case that the first annotation label is one, and all the first annotation labels in the first data set correspond to the same first category, when the second category corresponding to the first annotation label of the sample image is the same as the first category, the second annotation label of the sample image in the first category is determined as the second preset label, and in the case that the second category corresponding to the first annotation label of the sample image is different from the first category, the second annotation label of the sample image in the first category is determined as the third preset label, and the second annotation label of the sample image in the other categories except the first category in the target categories is determined as the first preset label. Then, the multi-label classification model to be corrected is trained by using the sample image and the second annotation label of the sample image in the target categories, so as to obtain the multi-label classification model. Thus, the accuracy and efficiency of determining the second annotation label of the sample image are improved, and the influence of the second annotation label in other categories on training the multi-label classification model is avoided, and thus the accuracy and efficiency of training the multi-label classification model are improved.
[0070] Figure 3 A flowchart of a model training method provided by an embodiment of the present disclosure is shown.
[0071] As shown in Figure 3 , the method comprises:
[0072] Step 301: obtaining a first data set and at least one first category in a plurality of target categories corresponding to a multi-label classification model to be corrected, wherein the first data set includes a sample image and at least one first annotation label of the sample image.
[0073] In the present disclosure, the specific implementation process of step 301 can be referred to the detailed description of any embodiment of the present disclosure, which will not be repeated here.
[0074] Step 302: in the case that the first annotation label is one, and all the first annotation labels in the first data set correspond to the same first category, the first annotation label of the sample image is determined as the second annotation label of the sample image in the same first category.
[0075] In the present disclosure, in the case that each sample image corresponds to one first annotation label, and all the first annotation labels in the first data set correspond to the same first category, the first annotation label of the sample image can be determined as the second annotation label of the sample image in the first category. Thus, the accuracy of determining the second annotation label of the sample image in the target category is improved.
[0076] For example, the first category is "person", all the first annotation labels in the first data set correspond to "person", the first annotation label of the sample image 1 is 0, and the first annotation label of the sample image 2 is 1. Wherein, 0 represents that the sample image does not contain a person, and 1 represents that the sample image contains a person. The first annotation label of the sample image can be determined as the second annotation label of the sample image in the first category "person".
[0077] Optionally, in the case that each sample image corresponds to multiple first annotation labels, and each first annotation label corresponds to a different second category, each second category is matched with the first category, and the second annotation label of the sample image in the first category is determined from the multiple first annotation labels of the sample image. When the second annotation label of the sample image in the first category is failed to be determined from the multiple first annotation labels of the sample image, the second annotation label of the sample image in the first category can be determined as the first preset label. Thus, the accuracy of determining the second annotation label of the sample image in the target category is improved.
[0078] For example, the sample image 1 corresponds to the first annotation label 1 and the first annotation label 2, the second category corresponding to the first annotation label 1 is "person", which is used to identify whether the sample image 1 contains a person, and the second category corresponding to the first annotation label 2 is "vehicle", which is used to identify whether the sample image 1 contains a vehicle. When the first category is "person", the first category and the second category corresponding to the first annotation label 1 are the same. Therefore, the first annotation label 1 can be determined as the second annotation label of the sample image 1 in the first category "person". When the first category is "animal", the first category and the second category corresponding to the first annotation label 1, and the second category corresponding to the first annotation label 2 are all different. At this time, the second annotation label of the sample image 1 in the first category "animal" can be determined as the first preset label.
[0079] In step 303, the second annotation label of the sample image in the other category except the first category in the target category is determined as the first preset label.
[0080] In step 304, the multi-label classification model to be corrected is trained by using the sample image and the second annotation label of the sample image in the target category, so as to obtain the multi-label classification model.
[0081] In the present disclosure, the specific implementation process of steps 303-304 can be referred to the detailed description of any embodiment of the present disclosure, which will not be repeated here.
[0082] In the present disclosure, after obtaining the first data set including the sample image and at least one first annotation label of the sample image, at least one first category in the plurality of target categories supported by the multi-label classification model to be corrected, in the case that the first annotation label is one and all the first annotation labels in the first data set correspond to the same first category, the first annotation label of the sample image is determined as the second annotation label of the sample image in the first category, and the second annotation label of the sample image in other categories except the first category in the target categories is determined as the first preset label. Then, the multi-label classification model to be corrected is trained by using the sample image and the second annotation label of the sample image in the target categories, to obtain the multi-label classification model. Thus, while improving the accuracy and efficiency of determining the second annotation label of the sample image, the influence of the second annotation label in other categories on training the multi-label classification model is avoided, and thus the accuracy and efficiency of training the multi-label classification model are improved.
[0083] Figure 4 A flowchart of a model training method provided by an embodiment of the present disclosure is shown.
[0084] As shown in Figure 4 , the method comprises:
[0085] Step 401: obtaining a first data set and at least one first category in a plurality of target categories corresponding to a multi-label classification model to be corrected, wherein the first data set includes a sample image and at least one first annotation label of the sample image.
[0086] Step 402: determining a second annotation label of the sample image in the first category based on a preset conversion rule and the first annotation label.
[0087] Step 403: determining the second annotation label of the sample image in other categories except the first category in the target categories as a first preset label.
[0088] In the present disclosure, the specific implementation process of steps 401-403 can be referred to the detailed description of any embodiment of the present disclosure, which will not be repeated here.
[0089] Step 404: inputting the sample image into the multi-label classification model to be corrected, and obtaining a second confidence of the second annotation label in each target category output by the multi-label classification model to be corrected.
[0090] Step 405: in the case that the second annotation label corresponding to any target category is not the first preset label, determining the any target category as an effective category.
[0091] In the present disclosure, in the case that the second annotation label corresponding to a certain target category is the first preset label, it is indicated that the multi-label classification model has high classification accuracy in the target category, and the multi-label classification model is continued to be modified in the target category, which may have a negative interference effect on model training. Therefore, the target category with the corresponding second annotation label not being the first preset label is determined as an effective category. The multi-label classification network is modified according to the second confidence corresponding to the effective category, and only the first category with low classification accuracy is trained to improve the accuracy of the multi-label classification model.
[0092] In step 406, a loss value is determined according to the second annotation label in the effective category and the second confidence corresponding to the effective category, so as to modify the multi-label classification model to be modified according to the loss value.
[0093] The loss value can be determined by the following loss function:
[0094]
[0095] where y i is the second annotation label in the ith effective category, p(y i ) is the second confidence of the multi-label classification model outputting the second annotation label in the ith effective category, and N is the number of samples.
[0096] In the present disclosure, in the case that the loss value is greater than the preset threshold, the parameters of the multi-category classification model can be adjusted based on the loss value, and the adjusted multi-label classification model is continued to be trained using the training data until the number of training data of the training multi-label classification model reaches the preset number, and the final multi-label classification model is obtained.
[0097] Optionally, in the case that the first category is multiple, after the multi-label classification model is modified according to the loss value, in the case that the annotation label of the sample image in a certain first category is not a preset label, the number of samples corresponding to the first category is updated. Then, the number of samples corresponding to each first category is compared with the second threshold, and in the case that the number of samples corresponding to each first category is greater than the second threshold, the last modified multi-label classification model is determined as the final multi-label classification model. Thus, the sufficiency of the number of samples corresponding to each first category is ensured, thereby improving the accuracy of the multi-label classification model.
[0098] In the present disclosure, after obtaining a first data set including sample images and at least one first annotation label of the sample images, at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected for classification, based on a preset conversion rule and the first annotation label, a second annotation label of the sample images under the first category is determined, and the second annotation label of the sample images under other categories in the target categories except the first category is determined as a first preset label. Then, the sample images are input into the multi-label classification model to be corrected, and the second confidence of the second annotation label under each target category output by the multi-label classification model to be corrected is obtained. In the case that the second annotation label corresponding to any target category is not the first preset label, the target category is determined as an effective category, and the loss value is determined according to the second annotation label under the effective category and the second confidence corresponding to the effective category, so as to correct the multi-label classification model to be corrected according to the loss value. Therefore, the loss value is determined according to the second confidence corresponding to the effective category in which the corresponding second annotation label in the target category is not the first preset label, and the second annotation label under the effective category, which is beneficial to avoid the influence of the second annotation label under other categories on the training of the multi-label classification model, and further improves the accuracy of training the multi-label classification model.
[0099] To implement the above-mentioned embodiments, the present disclosure further provides a model training device.
[0100] Figure 5 A structural schematic diagram of a model training device provided by the present disclosure is provided.
[0101] As shown in the Figure 5 The model training device 500 includes an acquisition module 510, a first determination module 520, and a training module 530.
[0102] The acquisition module 510 is configured to acquire a first data set and at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected for classification, wherein the first data set includes sample images and at least one first annotation label of the sample images.
[0103] The determination module 520 is configured to determine a second annotation label of the sample images under the first category based on a preset conversion rule and the first annotation label.
[0104] The determination module 520 is configured to determine a second annotation label of the sample images under other categories in the target categories except the first category as a first preset label.
[0105] The training module 530 is configured to train the multi-label classification model to be corrected by using the sample images and the second annotation label of the sample images under the target categories, so as to obtain the multi-label classification model.
[0106] In a possible implementation of the present disclosure, the determining module 520 is configured to:
[0107] In a case where the first annotation label is one and all the first annotation labels in the first data set correspond to the plurality of second categories, when the second category corresponding to the first annotation label of the sample image is the same as the first category, the second annotation label of the sample image in the first category is determined as the second preset label.
[0108] In a case where the second category corresponding to the first annotation label of the sample image is different from the first category, the second annotation label of the sample image in the first category is determined as the third preset label.
[0109] In a possible implementation of the present disclosure, the determining module 520 is configured to:
[0110] In a case where the first annotation label is one and all the first annotation labels in the first data set correspond to the same first category, the first annotation label of the sample image is determined as the second annotation label of the sample image in the same first category.
[0111] In a possible implementation of the present disclosure, the determining module 520 is configured to:
[0112] In a case where the first annotation label is multiple and each first annotation label corresponds to a different second category, each second category is matched with the first category, and the second annotation label of the sample image in the first category is determined from the multiple first annotation labels of the sample image.
[0113] In a possible implementation of the present disclosure, the training module 530 is configured to:
[0114] The sample picture is input into the multi-label classification model to be corrected, and the second confidence of the second annotation label in each target category output by the multi-label classification model to be corrected is obtained.
[0115] In a case where the second annotation label corresponding to any target category is not the first preset label, the any target category is determined as an effective category.
[0116] According to the second annotation label in the effective category and the second confidence corresponding to the effective category, a loss value is determined, and the multi-label classification model to be corrected is corrected according to the loss value.
[0117] In a possible implementation of the present disclosure, the training module 530 is further configured to:
[0118] In a case where the annotation label corresponding to any first category of the sample image is not the first preset label, the sample quantity corresponding to the any first category is updated.
[0119] In a case where the number of samples corresponding to each first category is greater than the second threshold, the last modified multi-label classification model is determined as the final multi-label classification model.
[0120] It should be noted that the foregoing model training method embodiment is also applicable to the device of the embodiment, and thus will not be described here again.
[0121] After obtaining the first data set including the sample image and at least one first annotation label of the sample image, at least one first category in the plurality of target categories supported by the multi-label classification model to be modified, determining the second annotation label of the sample image under the first category based on the preset conversion rule and the first annotation label, and determining the second annotation label of the sample image under other categories in the target categories except the first category as the first preset label, then training the multi-label classification model to be modified by using the sample image and the second annotation label of the sample image under the target categories, to obtain the multi-label classification model. Therefore, by determining the second annotation label of the sample image under the first category in the target categories based on the preset conversion rule and the first annotation label, and setting the second annotation label of the sample image under other categories in the target categories except the first category as the first preset label, the accuracy and efficiency of determining the second annotation label of the sample image are improved, and the influence of the second annotation label under other categories on training the multi-label classification model is avoided, thereby improving the accuracy and efficiency of training the multi-label classification model.
[0122] According to embodiments of the present disclosure, the present disclosure also provides an electronic device and a readable storage medium.
[0123] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptops, desktops, tablets, personal digital assistants, servers, blade servers, mainframes, and other appropriate computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular telephones, smart phones, wearable devices, and other similar computing devices. The components shown here, their connections and relationships, and their functions, are meant to be examples only, and are not intended to limit implementations of the present disclosure described and / or claimed in this document.
[0124] As Figure 6As shown, the device 600 includes a computing unit 601 that can perform various appropriate actions and processes in accordance with a computer program stored in a ROM (Read-Only Memory) 602 or a computer program loaded into a RAM (Random Access Memory) 603 from the storage unit 608. In the RAM 603, various programs and data required for the operation of the device 600 can also be stored. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other through a bus 604. An I / O (Input / Output) interface 605 is also connected to the bus 604.
[0125] A plurality of components in the device 600 are connected to the I / O interface 605, including an input unit 606 such as a keyboard, a mouse, and the like, an output unit 607 such as various types of displays, speakers, and the like, a storage unit 608 such as a magnetic disk, an optical disk, and the like, and a communication unit 609 such as a network card, a modem, a wireless communication transceiver, and the like. The communication unit 609 allows the device 600 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.
[0126] The computing unit 601 can be various general-purpose and / or special-purpose processing components having processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a CPU (Central Processing Unit), a GPU (Graphic Processing Unit), various special-purpose AI (Artificial Intelligence) computing chips, various computing units running machine learning model algorithms, a DSP (Digital Signal Processor), and any appropriate processor, controller, microcontroller, and the like. The computing unit 601 performs various methods and processes described above, such as the model training method. For example, in some embodiments, the model training method can be implemented as a computer software program that is tangibly embodied in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the model training method described above can be performed. Alternatively, in other embodiments, the computing unit 601 can be configured to perform the model training method by any other appropriate means, such as by means of firmware.
[0127] Various implementations of the systems and techniques described above can be realized in digital electronic circuitry, integrated circuitry, a Field Programmable Gate Array (FPGA), an Application-Specific Integrated Circuit (ASIC), an Application Specific Standard Product (ASSP), a System on a Chip (SOC), a Complex Programmable Logic Device (CPLD), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include implementation in one or more computer programs that are executable and / or interpretable on a programmable system including at least one programmable processor, which can be special or general purpose, coupled to receive data and instructions from, and to transmit data and instructions to, a storage system, at least one input device, and at least one output device.
[0128] Program code for carrying out methods of the present disclosure can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general or special purpose computer, such that the program code, when executed by the processor or controller, causes the functions / operations specified in the flowcharts and / or block diagrams to be implemented. The program code can execute entirely on a machine, partly on the machine, as a stand-alone software package, partly on the machine and partly on a remote machine or entirely on the remote machine or server.
[0129] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include a linearly-programmed electronic storage, a portable computer diskette, a hard disk, RAM, ROM, EPROM (Electrically Programmable Read-Only-Memory), or flash memory, an optical fiber, a CD-ROM (Compact Disc Read-Only Memory), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0130] To provide for interaction with a user, the systems and techniques described here can be implemented on a computer having a display device (e.g., a CRT (Cathode-Ray Tube) or LCD (Liquid Crystal Display) monitor) for displaying information to the user and a keyboard and a pointing device (e.g., a mouse or a trackball) by which the user can provide input to the computer. Other kinds of devices can be used to provide for interaction with a user as well; for example, feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form, including acoustic, speech, or tactile input.
[0131] The systems and techniques described here can be implemented in a computing system that includes a back-end component (e.g., as a data server), or that includes a middleware component (e.g., an application server), or that includes a front-end component (e.g., a user computer having a graphical user interface or a Web browser through which a user can interact with an implementation of the systems and techniques described here), or any combination of such back-end, middleware, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a LAN (Local Area Network), a WAN (Wide Area Network), the Internet, and a blockchain network.
[0132] The computer system can include clients and servers. This relationship can be implemented by a computer program running on the respective computers and having a client-server relationship with one another. The servers can be cloud servers, also known as cloud computing servers or cloud hosts, which are a host product in the cloud computing service system to solve the defects of large management difficulty and weak business expansion in traditional physical hosts and VPS services (Virtual Private Server). The servers can also be servers of a distributed system or servers combined with a blockchain.
[0133] It should be understood that the various forms of flow shown above can be reordered, steps added or deleted. For example, the steps described in the present disclosure can be executed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in the present disclosure can be achieved, which is not limited herein.
[0134] The above detailed description does not constitute a limitation on the protection scope of the present disclosure. Those skilled in the art should understand that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modifications, equivalent replacements and improvements made within the spirit and principles of the present disclosure shall be included in the protection scope of the present disclosure.
Claims
1. A model training method, comprising: obtaining a first data set, at least one first category of a plurality of target categories supported by a multi-label classification model to be corrected, wherein the first data set comprises sample images and at least one first annotation label of the sample images, and the first category is a category with lower classification accuracy corresponding to the multi-label classification model to be corrected; determining a second annotation label of the sample image in the first category based on a preset conversion rule and the first annotation label; determining a second annotation label of the sample image in other categories of the target categories except the first category as a first preset label, wherein the first preset label is used to identify an unknown state of the sample image in the corresponding target category; inputting the sample image into the multi-label classification model to be corrected to obtain a second confidence of the second annotation label in each target category output by the multi-label classification model to be corrected; determining any target category as a valid category in a case where the corresponding second annotation label of the target category is not the first preset label; determining a loss value according to the second annotation label in the valid category and the second confidence corresponding to the valid category, and correcting the multi-label classification model to be corrected according to the loss value; updating the sample quantity corresponding to any first category in a case where the annotation label of the sample image in the first category is not the first preset label; determining the last corrected multi-label classification model as a final multi-label classification model in a case where the sample quantity corresponding to each first category is greater than a second threshold.
2. The method of claim 1, wherein, The determination of the second annotation label of the sample image in the first category based on the preset conversion rule and the first annotation label comprises: in a case where the first annotation label is one and all first annotation labels in the first data set correspond to a plurality of second categories, determining the second annotation label of the sample image in the first category as a second preset label when the second category corresponding to the first annotation label of the sample image is the same as the first category; in a case where the second category corresponding to the first annotation label of the sample image is different from the first category, determining the second annotation label of the sample image in the first category as a third preset label.
3. The method of claim 1, wherein, The determination of the second annotation label of the sample image in the first category based on the preset conversion rule and the first annotation label comprises: in a case where the first annotation label is one and all first annotation labels in the first data set correspond to the same first category, determining the first annotation label of the sample image as the second annotation label of the sample image in the same first category.
4. The method of claim 1, wherein, The determination of the second annotation label of the sample image in the first category based on the preset conversion rule and the first annotation label comprises: In a case where the first annotation label is multiple, and each of the first annotation label corresponds to a different second category, each of the second category is matched with the first category, and a second annotation label of the sample image in the first category is determined from the multiple first annotation labels of the sample image.
5. A model training apparatus, comprising: an acquisition module configured to acquire a first data set, at least one first category in a plurality of target categories supported by a multi-label classification model to be corrected, wherein the first data set comprises a sample image and at least one first annotation label of the sample image, and the first category is a category with lower classification accuracy corresponding to the multi-label classification model to be corrected; a determination module configured to determine a second annotation label of the sample image in the first category based on a preset conversion rule and the first annotation label; the determination module is configured to determine a second annotation label of the sample image in a category other than the first category in the target categories as a first preset label, wherein the first preset label is used to identify an unknown state of the sample image in the corresponding target category; a training module configured to train the multi-label classification model to be corrected by using the sample image and the second annotation label of the sample image in the target categories, so as to obtain a multi-label classification model; the training module is specifically configured to: input the sample image into the multi-label classification model to be corrected, and acquire a second confidence degree of the second annotation label in each of the target categories output by the multi-label classification model to be corrected; in a case where the second annotation label corresponding to any target category is not the first preset label, determine the any target category as a valid category; determine a loss value according to the second annotation label in the valid category and the second confidence degree corresponding to the valid category, and correct the multi-label classification model to be corrected according to the loss value; in a case where the annotation label corresponding to any first category of the sample image is not the first preset label, update the sample quantity corresponding to the any first category; in a case where the sample quantity corresponding to each of the first categories is greater than a second threshold value, determine the multi-label classification model after the last correction as a final multi-label classification model.
6. The apparatus of claim 5, wherein, the determination module is configured to: in a case where the first annotation label is one, and all the first annotation labels in the first data set correspond to multiple second categories, when the second category corresponding to the first annotation label of the sample image is the same as the first category, determine the second annotation label of the sample image in the first category as a second preset label; in a case where the second category corresponding to the first annotation label of the sample image is different from the first category, determine the second annotation label of the sample image in the first category as a third preset label.
7. The apparatus of claim 6, wherein, the determination module is configured to: In a case where the first annotation label is one and all the first annotation labels in the first data set correspond to a same first category, the first annotation label of the sample image is determined as the second annotation label of the sample image in the same first category.
8. The apparatus of claim 6, wherein, The determining module is configured to: In a case where the first annotation label is multiple and each of the first annotation labels corresponds to a different second category, each of the second categories is matched with the first category, and the second annotation label of the sample image in the first category is determined from the multiple first annotation labels of the sample image. 9.An electronic device comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable 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 of any one of claims 1-4.
10. A non-transitory computer readable storage medium having stored thereon computer instructions, wherein, The computer instructions are used to enable the computer to perform the method of any one of claims 1-4. 11.A computer program product comprising a computer program which, when executed by a processor, implements the method of any one of claims 1-4.