CN-116259083-B - Image quality recognition model determining method and related device
Abstract
The embodiment of the application discloses a method and a related device for determining an image quality recognition model, which relate to image recognition and machine learning in the field of artificial intelligence, and in an image classification scene, the image quality is related to classification difficulty, so that an image sample marked with an actual classification category is obtained, probability distribution of the image sample under a plurality of classification categories is determined through an initial classification model, attention weights corresponding to the classification difficulty are generated for the image sample based on the probability distribution through an attention layer, the attention weights can enable the model to pay more attention to the image sample which is not easy to classify, and the size of the attention weights output by the attention layer can play a role in distinguishing the image quality of an input image. Therefore, a recognition model for recognizing the image quality according to the attention weight can be obtained by changing the attention layer in the trained classification model into the model output layer without specially labeling the image quality sample, and the acquisition cost of the recognition model is reduced.
Inventors
- FU CANMIAO
Assignees
- 腾讯科技(深圳)有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20211208
Claims (20)
- 1. A method of determining an image quality recognition model, the method comprising: Obtaining an image sample comprising a sample tag, the sample tag being used to identify an actual classification category of the image sample; inputting the image sample into an initial classification model, and determining probability distribution under a plurality of classification categories through the initial classification model; Determining attention weights respectively corresponding to the image samples of the target number through the attention layer of the initial classification model according to probability distribution respectively corresponding to the image samples of the target number, wherein the sum of the attention weights respectively corresponding to the image samples of the target number is a constant, the attention weights are used for marking classification difficulty of the image samples, and the attention weights are inversely related to the classification difficulty; determining a loss function corresponding to the image sample according to the attention weight and the difference between the probability distribution and the actual classification category; model training is carried out on the initial classification model through the loss function, and a classification model is obtained; and changing the attention layer of the classification model into a model output layer to obtain an identification model for identifying the image quality according to the attention weight.
- 2. The method according to claim 1, wherein the method further comprises: acquiring an image to be identified; determining the attention weight corresponding to the image to be identified according to the identification model; and determining an identification result of the image quality of the image to be identified based on the association relation between the attention weight and the classification difficulty, wherein the higher the classification difficulty is, the lower the image quality is.
- 3. The method of claim 1, wherein the acquiring the image sample including the sample tag comprises: A sample batch including a target number of image samples is acquired from the image sample set.
- 4. A method according to claim 3, wherein the obtaining a sample batch comprising a target number of image samples from the set of image samples comprises: sequentially acquiring a plurality of sample batches from the image sample set according to the target quantity respectively corresponding to the different sample batches; In the process of determining the attention weights respectively corresponding to the image samples in the plurality of sample batches through the attention layer of the initial classification model, the sum of the attention weights respectively corresponding to the plurality of sample batches is the same.
- 5. A method according to claim 3, wherein said determining, from the probability distribution, the attention weight corresponding to the image sample by the attention layer of the initial classification model comprises: determining an initial attention value corresponding to the image sample through an attention layer of the initial classification model according to the probability distribution; And normalizing the initial attention value according to the target number of the image samples in the sample batch where the image samples are located and the constant to obtain the attention weight.
- 6. The method according to any one of claims 1-5, further comprising: The numerical range of the attention weights determined by the attention layer is pre-adjusted to increase the upper and lower limits of the numerical range.
- 7. The method according to any one of claims 1-5, wherein said determining a loss function for said image sample based on said attention weight and a difference of said probability distribution from said actual classification category comprises: determining an initial loss function based on the difference of the probability distribution and the actual classification category; And taking the attention weight as the weight of the initial loss function, and determining the loss function corresponding to the image sample.
- 8. The method according to any one of claims 1-5, wherein said changing the attention layer of the classification model to a model output layer results in an identification model for identifying image quality based on the attention weight, comprising: Deleting a classification layer serving as a model output layer in the classification model; And taking the attention layer of the classification model as a model output layer to obtain a recognition model for recognizing the image quality according to the attention weight.
- 9. The method according to any one of claims 1-5, wherein the image sample is a face image sample, and the sample tag is used to identify an actual user identifier corresponding to a face in the face image sample.
- 10. The method of claim 9, wherein the plurality of classification categories are determined based on the actual user identification.
- 11. A determining device of an image quality recognition model, characterized in that the device comprises an acquiring unit, a determining unit, a training unit and a modifying unit: The acquisition unit is used for acquiring an image sample comprising a sample label, wherein the sample label is used for identifying the actual classification category of the image sample; The determining unit is used for inputting the image sample into an initial classification model, and determining probability distribution under a plurality of classification categories through the initial classification model; the determining unit is further configured to determine, according to probability distributions corresponding to the target number of image samples, attention weights corresponding to the target number of image samples respectively through an attention layer of the initial classification model, where a sum of the attention weights corresponding to the target number of image samples respectively is a constant, the attention weights are used to identify classification difficulty of the image samples, and the attention weights are inversely related to the classification difficulty; The determining unit is further configured to determine a loss function corresponding to the image sample according to the attention weight and a difference between the probability distribution and the actual classification category; the training unit is used for carrying out model training on the initial classification model through the loss function to obtain a classification model; and the changing unit is used for changing the attention layer of the classification model into a model output layer to obtain an identification model for identifying the image quality according to the attention weight.
- 12. The apparatus according to claim 11, wherein the acquisition unit is further configured to acquire an image to be identified; The determining unit is further used for determining the attention weight corresponding to the image to be identified according to the identification model; the determining unit is further configured to determine a recognition result for the image quality of the image to be recognized based on the association relationship between the attention weight and the classification difficulty, where the greater the classification difficulty is, the lower the image quality is.
- 13. The apparatus of claim 11, wherein the acquisition unit is further configured to: A sample batch including a target number of image samples is acquired from the image sample set.
- 14. The apparatus of claim 13, wherein the acquisition unit is further configured to: sequentially acquiring a plurality of sample batches from the image sample set according to the target quantity respectively corresponding to the different sample batches; In the process of determining the attention weights respectively corresponding to the image samples in the plurality of sample batches through the attention layer of the initial classification model, the sum of the attention weights respectively corresponding to the plurality of sample batches is the same.
- 15. The apparatus of claim 13, wherein the determining unit is further configured to: determining an initial attention value corresponding to the image sample through an attention layer of the initial classification model according to the probability distribution; And normalizing the initial attention value according to the target number of the image samples in the sample batch where the image samples are located and the constant to obtain the attention weight.
- 16. The apparatus according to any one of claims 11-15, further comprising an adjustment unit for pre-adjusting a range of values of the attention weight determined by the attention layer to increase an upper and lower limit of the range of values.
- 17. The apparatus according to any one of claims 11-15, wherein the determining unit is further configured to: determining an initial loss function based on the difference of the probability distribution and the actual classification category; And taking the attention weight as the weight of the initial loss function, and determining the loss function corresponding to the image sample.
- 18. The apparatus according to any of claims 11-15, wherein the modifying unit is further configured to: Deleting a classification layer serving as a model output layer in the classification model; And taking the attention layer of the classification model as a model output layer to obtain a recognition model for recognizing the image quality according to the attention weight.
- 19. The apparatus according to any one of claims 11-15, wherein the image samples are face image samples, and the sample tags are used to identify actual user identities corresponding to faces in the face image samples.
- 20. The apparatus of claim 19, wherein the plurality of classification categories are determined based on the actual user identification.
Description
Image quality recognition model determining method and related device Technical Field The present application relates to the field of image processing, and in particular, to a method and an apparatus for determining an image quality recognition model. Background Currently, many business scenarios need to apply an image recognition technology, and services such as face recognition, face editing, video understanding, content recommendation and the like are performed based on the image recognition technology through an input image to be recognized. In these business scenes, the accuracy of the image recognition result is affected by the image quality of the input image to be recognized, however, the related technology mostly adopts a depth model to recognize the image quality, but training the depth model needs a large number of image samples, the image samples need to be marked with labels showing the image quality, and the label marking needs to consume a large amount of manpower and time. Therefore, in order to save the cost, the image quality of the image to be identified is generally not identified before processing in the service scenario, so that the accuracy of the image identification result is difficult to ensure. Disclosure of Invention In order to solve the technical problems, the application provides a method and a related device for determining an image quality recognition model, which can obtain the recognition model for image quality recognition without specially marking an image quality sample, thereby greatly reducing the acquisition cost of the recognition model. The embodiment of the application discloses the following technical scheme: In one aspect, an embodiment of the present application provides a method for determining an image quality recognition model, where the method includes: Obtaining an image sample comprising a sample tag, the sample tag being used to identify an actual classification category of the image sample; inputting the image sample into an initial classification model, and determining probability distribution under a plurality of classification categories through the initial classification model; Determining an attention weight corresponding to the image sample through an attention layer of the initial classification model according to the probability distribution, wherein the attention weight is used for identifying the classification difficulty of the image sample; determining a loss function corresponding to the image sample according to the attention weight and the difference between the probability distribution and the actual classification category; model training is carried out on the initial classification model through the loss function, and a classification model is obtained; and changing the attention layer of the classification model into a model output layer to obtain an identification model for identifying the image quality according to the attention weight. On the other hand, the embodiment of the application provides a determining device of an image quality identification model, which comprises an acquisition unit, a determining unit, a training unit and a changing unit: The acquisition unit is used for acquiring an image sample comprising a sample label, wherein the sample label is used for identifying the actual classification category of the image sample; The determining unit is used for inputting the image sample into an initial classification model, and determining probability distribution under a plurality of classification categories through the initial classification model; The determining unit is further configured to determine, according to the probability distribution, an attention weight corresponding to the image sample through an attention layer of the initial classification model, where the attention weight is used to identify classification difficulty of the image sample; The determining unit is further configured to determine a loss function corresponding to the image sample according to the attention weight and a difference between the probability distribution and the actual classification category; the training unit is used for carrying out model training on the initial classification model through the loss function to obtain a classification model; and the changing unit is used for changing the attention layer of the classification model into a model output layer to obtain an identification model for identifying the image quality according to the attention weight. In yet another aspect, an embodiment of the present application provides a computer device including a processor and a memory: The memory is used for storing program codes and transmitting the program codes to the processor; the processor is configured to execute the method for determining the image quality recognition model according to the above aspect according to the instructions in the program code. In yet another aspect, an embodiment of the present application provi