Person attribute classification method and device, storage medium and computer device

By combining a feature recognition network and a classifier to form a target attribute classification model, and training it with a margind softmax loss function and a classification loss function, the problem of insufficient character attribute classification ability is solved, and high-accuracy attribute recognition is achieved.

CN118918388BActive Publication Date: 2025-11-07ZKTECO CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411174465.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2025-11-07
Estimated Expiration
2044-08-26

AI Technical Summary

Technical Problem

Existing technologies have poor ability to classify human attributes, especially in complex scenarios where it is difficult to accurately identify the diversity of human attributes and differences between inside and outside categories.

Method used

A target attribute classification model combining a feature recognition network and a classifier is adopted. The model is trained using a softmax loss function with margin and a classification loss function to enhance the model's ability to distinguish between categories and dynamically adjust sample weights.

Benefits of technology

It improves the accuracy and capability of character attribute classification, enabling accurate identification of character attributes in complex scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118918388B_ABST
    Figure CN118918388B_ABST
Patent Text Reader

Abstract

The application provides a person attribute classification method and device, a storage medium and computer equipment. When classifying the attributes of a person, the attributes to be classified of the person image are determined first, and then a target attribute classification model corresponding to the attributes to be classified is determined, so as to improve the attribute classification capability through a single-attribute model. The model is obtained by combining a feature recognition network provided with a softmax loss function with intervals and a classifier provided with a classification loss function. The softmax loss function with intervals improves the classification capability of the model by reducing the angle difference between the features of the samples in the same class and increasing the angle difference between the features of the samples in different classes. The classification loss function further improves the classification capability of the model by dynamically adjusting the weights to balance the different classes of samples in the attributes. Therefore, when the person image is input into the target attribute classification model, a prediction classification result with high precision output by the target attribute classification model can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, in particular to a person attribute classification method and device, storage medium and computer equipment. BACKGROUND

[0002] In the booming development of computer vision technology, person attribute classification is gradually becoming a core component of intelligent video surveillance systems. Through advanced algorithms such as deep learning, this technology realizes the automatic extraction and high-level semantic conversion of pedestrian information in surveillance videos, such as accurate identification of attributes such as gender, age, and clothing style, which has wide application potential in various fields.

[0003] Although the person attribute classification technology has made significant progress in recent years, its classification ability still faces many challenges, resulting in unsatisfactory recognition results in some complex scenarios. For example, human attributes have diversity, each attribute itself has large intra-class difference and small inter-class difference, such as different age habits and the ambiguity of some clothing in gender, which leads to poor classification ability of existing technology. SUMMARY

[0004] The purpose of the present application is to at least solve one of the above technical defects, especially the technical defect that the human attributes have diversity, each attribute itself has large intra-class difference and small inter-class difference, which leads to poor classification ability of existing technology.

[0005] The present application provides a person attribute classification method, which comprises:

[0006] Obtaining a person image to be classified, and determining an attribute to be classified of the person image;

[0007] Determining a target attribute classification model corresponding to the attribute to be classified; the target attribute classification model is obtained by combining a feature recognition network and a classifier; wherein the feature recognition network is pre-configured with a softmax loss function with interval, and the classifier is pre-configured with a classification loss function;

[0008] Inputting the person image into the target attribute classification model to obtain a predicted classification result of the person image under the attribute to be classified output by the target attribute classification model.

[0009] Optionally, the determining of the target attribute classification model corresponding to the attribute to be classified comprises:

[0010] Obtaining sample image data corresponding to the attribute to be classified, the sample image data comprising a real classification result labeled based on the attribute to be classified;

[0011] inputting the sample image data into a preset initial attribute classification model to obtain a predicted classification result of the sample image data under the to-be-classified attribute output by the initial attribute classification model;

[0012] training the initial attribute classification model by taking the predicted classification result approaching the true classification result as a target and using a softmax loss function with interval and a classification loss function;

[0013] When the initial attribute classification model meets a preset training end condition, the initial attribute classification model after training is taken as a target attribute classification model.

[0014] Optionally, the obtaining of the sample image data corresponding to the to-be-classified attribute comprises:

[0015] determining a plurality of classification types under the to-be-classified attribute, and obtaining sample person images corresponding to each classification type in equal proportions;

[0016] annotating a true classification result in each sample person image based on each classification type, and performing image mixing on each annotated sample person image to form sample image data.

[0017] Optionally, the training of the initial attribute classification model by taking the predicted classification result approaching the true classification result as a target and using the softmax loss function with interval and the classification loss function comprises:

[0018] calculating the predicted classification result by using the softmax loss function with interval to obtain an identification loss value, and calculating a classification loss value between the predicted classification result and the true classification result by using the classification loss function;

[0019] determining a total loss value of the initial attribute classification model according to the identification loss value and the classification loss value, and updating parameters in the initial attribute classification model based on the total loss value.

[0020] Optionally, the calculation expression of the total loss value comprises:

[0021]

[0022] In the formula, Loss represents the total loss value, Loss1 represents the identification loss value of the softmax loss function with interval, Loss2 represents the classification loss value of the classification loss function, a represents an adjustment weight of the identification loss value, and b represents an adjustment weight of the classification loss value.

[0023] Optionally, the inputting the person image into the target attribute classification model to obtain a predicted classification result of the person image in the attribute to be classified output by the target attribute classification model comprises:

[0024] inputting the person image into the feature recognition network to obtain a person feature vector obtained by the feature recognition network performing feature recognition on the person image;

[0025] performing feature classification on the person feature vector by using the classifier to obtain the predicted classification result of the person image in the attribute to be classified.

[0026] Optionally, the performing feature classification on the person feature vector by using the classifier to obtain the predicted classification result of the person image in the attribute to be classified comprises:

[0027] inputting the person feature vector into the classifier to enable the classifier to perform probability prediction on the person feature vector based on the attribute to be classified to obtain a predicted probability of each classification type under the attribute to be classified;

[0028] sorting the predicted probabilities by using the classifier, and taking a classification type with the largest predicted probability in the sorting result as the predicted classification result output by the classifier.

[0029] The present application also provides a person attribute classification device, comprising:

[0030] an image acquisition module configured to acquire a person image to be classified and determine an attribute to be classified of the person image;

[0031] a model determination module configured to determine a target attribute classification model corresponding to the attribute to be classified; the target attribute classification model is obtained by combining a feature recognition network and a classifier; wherein, a softmax loss function with an interval is pre-set in the feature recognition network, and a classification loss function is pre-set in the classifier;

[0032] a model classification module configured to input the person image into the target attribute classification model to obtain a predicted classification result of the person image in the attribute to be classified output by the target attribute classification model.

[0033] The present application also provides a storage medium, wherein the storage medium stores computer readable instructions, and the computer readable instructions are executed by one or more processors to enable the one or more processors to perform the steps of the person attribute classification method according to any one of the above embodiments.

[0034] The present application also provides a computer device, comprising: one or more processors, and a memory.

[0035] The memory stores computer readable instructions which, when executed by the one or more processors, perform the steps of the person attribute classification method of any of the above embodiments.

[0036] From the above technical solutions, the embodiments of the present application have the following advantages:

[0037] The person attribute classification method, device, storage medium and computer equipment provided by the present application can first determine the attribute to be classified of the person image when the attribute classification of the person image is needed, and then determine the target attribute classification model corresponding to the attribute to be classified, so as to improve the attribute classification ability through the single attribute model. Since the model is obtained by combining the feature recognition network and the classifier, the softmax loss function with interval is pre-set in the feature recognition network, and the classification loss function is pre-set in the classifier. The softmax loss function with interval can make the samples belonging to the same category more compact in the feature space and make the samples of different categories more dispersed in the feature space by reducing the angle difference between the features of the samples in the same category and increasing the angle difference between the features of the samples in different categories, thereby improving the classification ability of the model. In addition, the classification loss function can dynamically adjust the weights of different category samples in the attribute, so that the model pays more attention to the types that are difficult to identify, and further improves the classification ability of the model. Therefore, by inputting the person image into the target attribute classification model, the prediction classification result with high precision under the attribute to be classified output by the target attribute classification model can be obtained. BRIEF DESCRIPTION OF DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or the prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and those skilled in the art can obtain other drawings according to these drawings without creative labor.

[0039] Figure 1 A flowchart of a person attribute classification method provided by an embodiment of the present application;

[0040] Figure 2 A flowchart of a target attribute classification model determination process provided by an embodiment of the present application;

[0041] Figure 3 A structural diagram of a person attribute classification device provided by an embodiment of the present application;

[0042] Figure 4An internal result schematic diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0043] The technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work are within the scope of protection of the present application.

[0044] Although the human attribute classification technology has made significant progress in recent years, its classification ability still faces many challenges, resulting in unsatisfactory recognition effect in some complex scenarios. For example, human attributes have diversity, each attribute itself has large intra-class difference and small inter-class difference, such as different age wearing habits and ambiguity of certain clothing on gender, resulting in poor classification ability of the existing technology.

[0045] Based on this, the present application proposes the following technical solutions, please see the following:

[0046] In one embodiment, as shown in Figure 1 , Figure 1 A flowchart of a human attribute classification method provided by an embodiment of the present application; the present application provides a human attribute classification method, which specifically includes the following:

[0047] S110: obtaining a human image to be classified, and determining an attribute to be classified of the human image.

[0048] In this step, in some passenger flow attribute analysis scenarios, if a user needs to classify a certain attribute of a person in the passenger flow, the human attribute classification function can be started in the computer device, so that the computer device can obtain the human image to be classified through the image acquisition device, and then the attribute to be classified of the human image can be further determined to classify the human image based on the attribute to be classified.

[0049] It can be understood that in the passenger flow attribute analysis scenario, multiple cameras are usually provided, and these cameras have stable connectivity, supporting multiple connection modes such as USB, Wi-Fi, etc. to connect with the computer device. Therefore, the computer device can obtain the real-time picture in the passenger flow attribute analysis scenario through the camera, and when the human to be classified appears in the picture, the real-time picture is automatically captured to form the human image to be classified.

[0050] Further, after obtaining the person image, the computer device can perform a preprocessing operation on the person image, which includes but is not limited to normalization processing, sharpening processing, denoising processing, etc. The normalization processing refers to mapping the data of each dimension of the data vector to the interval between (0, 1) or (-1, 1), or mapping a certain norm of the data vector to 1. It can be understood that the pixel value of the person image in the present application is an integer in the range of 0-255. Although the pixel data of the original image can be directly used as the training data of the model, it may cause some problems in the training process of the model, such as slowing down the model training speed, too many iterations causing slow convergence, etc. Therefore, the present application can improve the model training efficiency through normalization processing.

[0051] The sharpening processing here refers to compensating the outline of the image, enhancing the edge and gray level jump of the image, and making the image clear, which can be divided into two categories of spatial domain processing and frequency domain processing. The edge and outline of the ground object on the image, or the characteristics of some linear target elements are highlighted to improve the contrast between the person edge and the surrounding pixels. The denoising processing refers to the process of reducing noise in a digital image. Generally, the image information obtained during the digitalization and transmission of the image is often affected by the imaging device and external environmental noise, that is, the received image information generally includes noise, and these noises will become an important reason for image interference. Through denoising processing of the image, the noise in the image is removed, and the authenticity and accuracy of the obtained image are further improved.

[0052] The above preprocessing operation on the obtained person image can scale the person image to a suitable size and effectively improve the clarity of the image itself, facilitating subsequent processing of the person image.

[0053] In addition, the to-be-classified attribute refers to the attribute of each type of the person to be classified. For example, when the attribute is gender, the types after classification can include male and female; when the attribute is age, the types after classification can include teenagers, middle-aged and old people. The present application can determine the to-be-classified attribute of the person image according to the actual needs of the analysis scene. The to-be-classified attribute here can be one or multiple, which is not limited here.

[0054] S120: determining a target attribute classification model corresponding to the to-be-classified attribute.

[0055] In the present embodiment, after determining the to-be-classified attribute of the person image through step S110, the computer device can use the target attribute classification model corresponding to the to-be-classified attribute to improve the attribute classification ability through a single attribute model, and then perform attribute classification on the person image through the target attribute classification model to obtain a classification result with high accuracy.

[0056] It can be understood that a plurality of pre-trained target attribute classification models are pre-stored in the computer device, each target attribute classification model corresponds to one attribute to be classified, and can perform specific type classification on the person image under the corresponding attribute to be classified. Therefore, the computer device can directly obtain the target attribute classification model corresponding to the attribute to be classified after determining the attribute to be classified of the person image, so that the target attribute classification model can perform attribute classification on the input person image under the attribute to be classified, and obtain the corresponding classification result.

[0057] When the attribute to be classified of the person image is one, the computer device can directly obtain one target attribute classification model corresponding to the attribute to be classified to perform person attribute classification; when the attribute to be classified of the person image is multiple, the computer device can obtain a target attribute classification model corresponding to each attribute and simultaneously perform person attribute classification on each target attribute classification model, and the operation processes of each model are independent of each other and do not affect each other.

[0058] Specifically, the target attribute classification model is obtained by combining a feature recognition network and a classifier; the feature recognition network here can adopt an open source model, which is mainly used for feature extraction of the person in the person image; and the classifier is mainly used for allocating input data to a specific type or label, and is a core component for solving classification problems, which can make classification decisions according to input features.

[0059] Further, the feature recognition network is pre-provided with a softmax loss function with interval, and the classifier is pre-provided with a classification loss function, and the application can further improve the classification ability of the model through the cooperation of the softmax loss function with interval and the classification loss function.

[0060] In detail, the softmax loss function with interval refers to introducing an interval parameter on the basis of the traditional softmax loss function to enhance the discrimination of the model for correct categories, which can be applied in face recognition, fine-grained classification and other functional models, so that the model can more strictly distinguish different categories on the decision boundary. The softmax loss function with interval can be an ArcFace loss function, a CosFace loss function or other loss functions with the same function, which is not limited herein. In the present application, the softmax loss function with interval provided in the feature recognition network can adopt an ArcFace loss function. The ArcFace loss function can reduce the angle difference between intra-class sample features and increase the angle difference between inter-class sample features, so that the representation of samples belonging to the same class in the feature space is more compact, and the representation of samples of different classes in the feature space is more dispersed, thereby improving the classification ability of the model.

[0061] In addition, the classification loss function refers to a function used to evaluate the performance of a model on a classification problem in machine learning, aiming to quantify the degree of difference between the model's prediction results and the true labels. The classification loss function can include a focal loss function, a cross-entropy loss function, a hinge loss function, an exponential loss function, etc. In this application, the pre-set classification loss function in the classifier can adopt a focal loss function, which is a dynamically scaled cross-entropy loss function, mainly used to solve the class imbalance problem in tasks such as target detection. It introduces a modulation factor to make the model pay more attention to more difficult samples during training, thereby improving the overall classification ability.

[0062] S130: inputting the person image into the target attribute classification model to obtain a predicted classification result of the person image under the attribute to be classified output by the target attribute classification model.

[0063] In this step, after determining the target attribute classification model in step S120, the computer device can input the person image into the target attribute classification model to classify the person image by the target attribute classification model, and obtain a predicted classification result with high accuracy under the attribute to be classified output by the target attribute classification model.

[0064] It can be understood that since the target attribute classification model is obtained by taking the sample image data as the training sample, taking the real classification result labeled in the sample image data as the sample label, and training the pre-set initial attribute classification model by using the interval softmax loss function and the classification loss function, therefore, when the computer device inputs the person image into the target attribute classification model, the predicted classification result of the person image under the attribute to be classified output by the target attribute classification model can be obtained.

[0065] In the above embodiments, when a person image needs to be classified, the attribute to be classified of the person image can be determined first, and then the target attribute classification model corresponding to the attribute to be classified can be determined, so as to improve the attribute classification ability by using the single-attribute model. Since the model is obtained by combining the feature recognition network and the classifier, the softmax loss function with interval is preset in the feature recognition network, and the classification loss function is preset in the classifier. The softmax loss function with interval can make the samples belonging to the same category more compact in the feature space and make the samples of different categories more dispersed in the feature space by reducing the angle difference between the sample features in the same category and increasing the angle difference between the sample features in different categories, thereby improving the classification ability of the model. In addition, the classification loss function can make the model pay more attention to the types that are difficult to identify by dynamically adjusting the weights of the samples of different categories in the attribute, thereby further improving the classification ability of the model. Therefore, by inputting the person image into the target attribute classification model, a prediction classification result with high precision under the attribute to be classified can be obtained.

[0066] In one embodiment, as shown in Figure 2 , Figure 2 a flowchart of a target attribute classification model determination process provided by an embodiment of the present application is provided; Figure 2 In the step S120, the target attribute classification model corresponding to the attribute to be classified can be determined by the following steps:

[0067] S121: Obtain sample image data corresponding to the attribute to be classified, wherein the sample image data includes a real classification result labeled based on the attribute to be classified.

[0068] S122: Input the sample image data into a preset initial attribute classification model to obtain a prediction classification result of the sample image data under the attribute to be classified output by the initial attribute classification model.

[0069] S123: Train the initial attribute classification model by taking the prediction classification result close to the real classification result as the target and using the softmax loss function with interval and the classification loss function.

[0070] S124: When the initial attribute classification model meets the preset training end condition, the initial attribute classification model after training is taken as the target attribute classification model.

[0071] In this embodiment, when determining the target attribute classification model, the computer device can first select a corresponding feature recognition network and a classifier to obtain an initial attribute classification model, and then improve and train the initial attribute classification model. In the training process, the computer device can first obtain sample image data corresponding to the attribute to be classified, the sample image data including a real classification result labeled based on the attribute to be classified. In this way, after the sample image data is input into the initial attribute classification model, a predicted classification result of the sample image data output by the initial attribute classification model under the attribute to be classified can be obtained. Then, the computer device can take the predicted classification result approaching the real classification result as a target, and train the initial attribute classification model using the softmax loss function with interval and the classification loss function. When the initial attribute classification model meets a preset training end condition, the computer device can take the trained initial attribute classification model as the target attribute classification model.

[0072] Specifically, the computer device can take the sample image data as a training sample, take the real classification result of the sample image data as a sample label, then input the training sample with the sample label into a preset initial attribute classification model for forward propagation to train the model, and use the softmax loss function with interval and the classification loss function to optimize the parameters of the model in the backward propagation process of the model. When the model meets a certain training condition or a parameter convergence condition, such as the number of iterations reaching a set value, it is considered that the training is completed, and at this time, the trained model can be taken as the final target attribute classification model.

[0073] In one embodiment, the step S121 of obtaining the sample image data corresponding to the attribute to be classified can include:

[0074] S1211: Determine a plurality of classification types under the attribute to be classified, and obtain sample person images corresponding to each classification type in equal proportions.

[0075] S1212: Label a real classification result in each sample person image based on each classification type, and mix the labeled sample person images to form sample image data.

[0076] In this embodiment, when the computer device obtains the sample image data, it can first determine a plurality of classification types under the to-be-classified attribute. For example, when the attribute is gender, the classification types can be divided into male and female; when the attribute is age, the classification types can be divided into youth, middle age, and old age. Then, the computer device can obtain sample person images corresponding to each classification type in equal proportions, and then label the real classification results of each classification type in each sample person image, and mix the sample person images after labeling to form the sample image data, so as to improve the efficiency and generalization ability of the model when the model is trained using the sample image data.

[0077] It can be understood that, by obtaining sample person images corresponding to each classification type in equal proportions, the present application can ensure that the number of samples of each classification type in the data set is roughly equal, so that the model can learn the feature distribution of each classification type in the training process, rather than being biased towards one or more categories, thereby improving the generalization ability of the model. In addition, by mixing sample person images of each classification type, the model can be exposed to more diverse data in the training process, and can learn more generalized feature representations, thereby avoiding overfitting of the model.

[0078] Of course, after the computer device mixes the sample image data, it can also preprocess the sample image data, such as normalization processing, sharpening processing, denoising processing, and the like, so as to scale the sample image data to a suitable size and effectively improve the clarity of the image itself, thereby improving the model training efficiency.

[0079] In one embodiment, the step S123 of training the initial attribute classification model with the goal of approaching the predicted classification result to the real classification result, and using the softmax loss function with interval and the classification loss function, can include:

[0080] S1231: calculating the predicted classification result using the softmax loss function with interval to obtain a recognition loss value, and calculating the classification loss value between the predicted classification result and the real classification result using the classification loss function.

[0081] S1232: determining the total loss value of the initial attribute classification model according to the recognition loss value and the classification loss value, and updating the parameters in the initial attribute classification model based on the total loss value.

[0082] In this embodiment, when the computer device trains the initial attribute classification model by using the loss function, the computer device can first calculate the predicted classification result by using the softmax loss function with interval to obtain a recognition loss value, and calculate the classification loss value between the predicted classification result and the real classification result by using the classification loss function. Then, the computer device can determine the total loss value of the initial attribute classification model according to the recognition loss value and the classification loss value, and update the parameters in the initial attribute classification model based on the total loss value.

[0083] It can be understood that, since the softmax loss function with interval is a loss function specially designed for deep face recognition, the softmax loss function with interval can be used to calculate the recognition loss value of the feature recognition network in the feature recognition network. The classification loss function as a dynamic scaling cross-entropy loss function can be used to calculate the classification loss value of the classifier. Finally, the computer device can combine the two loss values to determine the total loss value of the initial attribute classification model, and update the parameters in the initial attribute classification model based on the total loss value.

[0084] In one embodiment, the calculation expression of the total loss value in step S1232 can include:

[0085]

[0086] In the formula, Loss represents the total loss value; Loss1 represents the recognition loss value of the softmax loss function with interval; Loss2 represents the classification loss value of the classification loss function; a represents the adjustment weight of the recognition loss value; and b represents the adjustment weight of the classification loss value.

[0087] In this embodiment, when the computer device calculates the total loss value of the initial attribute classification model, the computer device can first determine the recognition loss value of the feature recognition network, that is, the output value of the softmax loss function with interval, and the classification loss value of the classifier, that is, the output value of the classification loss function. Then, the computer device adds the output values of the two loss functions after weight adjustment to obtain the total loss value.

[0088] Further, when designing the target loss function of the initial attribute classification model, the computer device can add the interval softmax loss function of the feature recognition network and the classification loss function of the classifier after weight adjustment. In this way, the computer device can directly use the target loss function to optimize the parameters of the initial attribute classification model. The target loss function can not only reduce the loss between the feature recognition result of the feature recognition network and the real recognition result, but also reduce the loss between the classification result of the classifier and the real classification result. Therefore, the prediction classification result generated by the model can converge to the real classification result more quickly and accurately. In this way, when the target attribute classification model is used to classify the attributes of the person image, a prediction classification result with high accuracy can be obtained.

[0089] In one embodiment, the step S130 of inputting the person image into the target attribute classification model to obtain the prediction classification result of the person image under the to-be-classified attribute output by the target attribute classification model can include:

[0090] S131: inputting the person image into the feature recognition network to obtain the person feature vector obtained by the feature recognition network by performing feature recognition on the person image.

[0091] S132: performing feature classification on the person feature vector by using the classifier to obtain the prediction classification result of the person image under the to-be-classified attribute.

[0092] In this embodiment, when the computer device classifies the attributes of the person image by using the target attribute classification model, the computer device can first input the person image into the feature recognition network to obtain the person feature vector obtained by the feature recognition network by performing feature recognition on the person image, and then perform feature classification on the person feature vector by using the classifier to obtain the prediction classification result of the person image under the to-be-classified attribute.

[0093] It can be understood that the target attribute classification model includes the feature recognition network and the classifier. The feature recognition network can identify the person feature vector of the recognition region corresponding to the to-be-classified attribute, such as the face region, the head-shoulder region, and the body region, from the input person image. The classifier has learned the feature distribution of each classification type under the to-be-classified attribute, and thus can directly perform feature classification on the input person feature vector and output the prediction classification result of the person image under the to-be-classified attribute.

[0094] In one embodiment, the step S132 of performing feature classification on the person feature vector by using the classifier to obtain the prediction classification result of the person image under the to-be-classified attribute can include:

[0095] S1321: Input the feature vector of the person into the classifier so that the classifier can make probability predictions on the feature vector of the person based on the attribute to be classified, and obtain the predicted probability of each classification type under the attribute to be classified.

[0096] S1322: The classifier sorts the predicted probabilities and takes the class with the highest predicted probability as the predicted classification result output by the classifier.

[0097] In this embodiment, when the computer device uses a classifier to classify the feature vector of a person, it can first input the feature vector of the person into the classifier so that the classifier can make probability predictions on the feature vector of the person based on the attribute to be classified, obtain the predicted probability of each classification type under the attribute to be classified, and then sort the predicted probabilities of each prediction probability through the classifier, and take the classification type with the highest predicted probability in the sorting result as the predicted classification result output by the classifier.

[0098] For example, when the attribute to be classified in the target attribute classification model is gender, that is, when its classifier learns the feature distribution of each category under gender, after inputting the image of a person into the target attribute classification model, the target attribute classification model can input the feature vector of the person output by the feature recognition network into the classifier and obtain the predicted probabilities of each category output by the classifier, which are: [male, 0.6] and [female, 0.4]. At this time, the target attribute classification model can output the category with the highest predicted probability, that is, the predicted probability of 0.6, as the final predicted classification result, that is, the predicted classification result of the image of the person is male.

[0099] The character attribute classification device provided in the embodiments of this application is described below. The character attribute classification device described below can be referred to in correspondence with the character attribute classification method described above.

[0100] In one embodiment, such as Figure 3 As shown, Figure 3 This application provides a schematic diagram of a person attribute classification device according to an embodiment of the present application; the present application also provides a person attribute classification device, including an image acquisition module 210, a model determination module 220, and a model classification module 230, specifically including the following:

[0101] Image acquisition module 210 is used to acquire images of people to be classified and to determine the classification attributes of the images of people.

[0102] The model determination module 220 is used to determine the target attribute classification model corresponding to the attribute to be classified; the target attribute classification model is obtained by combining a feature recognition network and a classifier; wherein, the feature recognition network is pre-set with a softmax loss function with intervals, and the classifier is pre-set with a classification loss function.

[0103] The model classification module 230 is configured to input the person image into the target attribute classification model to obtain a predicted classification result of the person image in the attribute to be classified output by the target attribute classification model.

[0104] In the above embodiment, when the attribute classification of the person image is needed, the attribute to be classified of the person image can be determined first, and then the target attribute classification model corresponding to the attribute to be classified can be determined, so as to improve the attribute classification ability through the model of a single attribute. Since the model is obtained by combining the feature recognition network and the classifier, the softmax loss function with interval is pre-set in the feature recognition network, and the classification loss function is pre-set in the classifier. The softmax loss function with interval can make the samples belonging to the same category more compact in the feature space and make the samples of different categories more dispersed in the feature space by reducing the angle difference between the features of the samples in the same category and increasing the angle difference between the features of the samples in different categories, thereby improving the classification ability of the model. In addition, the classification loss function can make the model pay more attention to the types that are difficult to identify by dynamically adjusting the weights of the samples of different categories in the attribute, thereby further improving the classification ability of the model. Therefore, by inputting the person image into the target attribute classification model, the predicted classification result with high precision in the attribute to be classified output by the target attribute classification model can be obtained.

[0105] In one embodiment, the model determination module 220 can include:

[0106] The sample acquisition sub-module is configured to acquire sample image data corresponding to the attribute to be classified, the sample image data including a real classification result labeled based on the attribute to be classified.

[0107] The model prediction sub-module is configured to input the sample image data into the preset initial attribute classification model to obtain a predicted classification result of the sample image data in the attribute to be classified output by the initial attribute classification model.

[0108] The model training sub-module is configured to train the initial attribute classification model by taking the predicted classification result close to the real classification result as a target and using the softmax loss function with interval and the classification loss function.

[0109] The model generation sub-module is configured to take the initial attribute classification model trained to meet the preset training end condition as the target attribute classification model.

[0110] In one embodiment, the sample acquisition sub-module can include:

[0111] The image acquisition unit is configured to determine a plurality of classification types under an attribute to be classified, and acquire sample person images corresponding to each classification type in equal proportions.

[0112] The image mixing unit is configured to label a true classification result in each sample person image based on each classification type, and mix the labeled sample person images to form sample image data.

[0113] In an embodiment, the model training submodule can include:

[0114] The loss value calculation unit is configured to calculate the predicted classification result by using a softmax loss function with interval to obtain an identification loss value, and calculate a classification loss value between the predicted classification result and the true classification result by using a classification loss function.

[0115] The model parameter updating unit is configured to determine a total loss value of the initial attribute classification model according to the identification loss value and the classification loss value, and update parameters in the initial attribute classification model based on the total loss value.

[0116] In an embodiment, the model parameter updating unit can include:

[0117]

[0118] In the formula, Loss represents the total loss value; Loss1 represents the identification loss value of the softmax loss function with interval; Loss2 represents the classification loss value of the classification loss function; a represents an adjustment weight of the identification loss value; and b represents an adjustment weight of the classification loss value.

[0119] In an embodiment, the model classification module 230 can include:

[0120] The feature recognition submodule is configured to input the person image into a feature recognition network to obtain a person feature vector obtained by the feature recognition network performing feature recognition on the person image.

[0121] The attribute classification submodule is configured to perform feature classification on the person feature vector by using a classifier to obtain a predicted classification result of the person image under the attribute to be classified.

[0122] In an embodiment, the attribute classification submodule can include:

[0123] The probability prediction unit is configured to input the person feature vector into the classifier to enable the classifier to perform probability prediction on the person feature vector based on the attribute to be classified to obtain a predicted probability of each classification type under the attribute to be classified.

[0124] The type selection unit is configured to sort each prediction probability by a classifier, and take the classification type with the maximum prediction probability in the sorting result as a prediction classification result output by the classifier.

[0125] In one embodiment, the present application further provides a storage medium, wherein computer readable instructions are stored in the storage medium, and the computer readable instructions are executed by one or more processors to enable the one or more processors to perform the steps of the character attribute classification method in any of the above embodiments.

[0126] In one embodiment, the present application further provides a computer device, wherein computer readable instructions are stored in the computer device, and the computer readable instructions are executed by one or more processors to enable the one or more processors to perform the steps of the character attribute classification method in any of the above embodiments.

[0127] As shown in Figure 4 , Figure 4 Fig. 1 shows an internal structure schematic diagram of a computer device provided by an embodiment of the present application. The computer device 300 can be provided as a server. As shown in Figure 4 , the computer device 300 includes a processing component 302, which further includes one or more processors, and a memory resource represented by a memory 301, for storing instructions executable by the processing component 302, such as an application program. The application program stored in the memory 301 can include one or more than one module each corresponding to a set of instructions. In addition, the processing component 302 is configured to execute the instructions to perform the character attribute classification method in any of the above embodiments.

[0128] The computer device 300 can further include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 can operate based on an operating system stored in the memory 301, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM or the like.

[0129] Those skilled in the art can understand that Figure 4 the structure shown in the above embodiment is only a block diagram of part of the structure related to the scheme of the present application, and does not constitute a limitation on the computer device to which the scheme of the present application is applied. The specific computer device can include more or less components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0130] Finally, it should be noted that the terms "first", "second", and the like, herein do not denote any order, quantity, combination, or importance, but rather are used to distinguish one element from another, and are not intended to denote the presence of any such actual relationship or order. Moreover, the terms "include", "have", or any other variant thereof are intended to encompass non-exclusive inclusions, such that processes, methods, articles, or apparatuses that comprise a list of elements are not required to comprise only those elements in the list, but can include other elements not expressly listed, or also include elements inherent in such processes, methods, articles, or apparatuses. Without additional restrictions, an element preceded by "comprises... a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus that comprises the stated element.

[0131] The various embodiments in the specification are described in progressive order with each embodiment building on the previous one, and each embodiment can be combined with other embodiments in any way technically possible. The same or similar parts and principles in the embodiments can be interchanged.

[0132] The above description of disclosed embodiments provides enabling disclosure sufficient for one of ordinary skill in the art to implement or use the application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and generic principles defined herein can be applied to other embodiments without departing from the spirit or scope of the application. Thus, the present application is not to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method of classifying a character attribute, characterized by, The method comprises: acquiring a person image to be classified, and determining a classification attribute of the person image to be classified; determining a target attribute classification model corresponding to the classification attribute to be classified; the target attribute classification model is obtained by combining a feature recognition network and a classifier; wherein, a softmax loss function with interval is pre-set in the feature recognition network, and a classification loss function is pre-set in the classifier; inputting the person image into the target attribute classification model to obtain a predicted classification result of the person image under the classification attribute to be classified output by the target attribute classification model; wherein, the determination of the target attribute classification model corresponding to the classification attribute to be classified comprises: acquiring sample image data corresponding to the classification attribute to be classified; the sample image data comprises a real classification result labeled based on the classification attribute to be classified; inputting the sample image data into a preset initial attribute classification model to obtain a predicted classification result of the sample image data under the classification attribute to be classified output by the initial attribute classification model; training the initial attribute classification model by taking the predicted classification result approaching the real classification result as a target, and using the softmax loss function with interval and the classification loss function; when the initial attribute classification model meets a preset training end condition, taking the initial attribute classification model after training as the target attribute classification model; the inputting of the person image into the target attribute classification model to obtain the predicted classification result of the person image under the classification attribute to be classified output by the target attribute classification model comprises: inputting the person image into the feature recognition network to obtain a person feature vector obtained by the feature recognition network performing feature recognition on the person image; performing feature classification on the person feature vector by using the classifier to obtain the predicted classification result of the person image under the classification attribute to be classified.

2. The character attribute classification method of claim 1, wherein, the acquisition of the sample image data corresponding to the classification attribute to be classified comprises: determining a plurality of classification types under the classification attribute to be classified, and acquiring sample person images corresponding to each classification type in equal proportion; labeling a real classification result in each sample person image based on each classification type, and performing image mixing on each labeled sample person image to form sample image data.

3. The character attribute classification method of claim 1, wherein, the training of the initial attribute classification model by taking the predicted classification result approaching the real classification result as a target, and using the softmax loss function with interval and the classification loss function comprises: calculating the predicted classification result by using the softmax loss function with interval to obtain an identification loss value, and calculating a classification loss value between the predicted classification result and the real classification result by using the classification loss function; determining a total loss value of the initial attribute classification model according to the identification loss value and the classification loss value, and updating parameters in the initial attribute classification model based on the total loss value.

4. The character attribute classification method of claim 3, wherein, the calculation expression of the total loss value comprises: ; In the formula, Loss represents a total loss value; Loss1 represents an identification loss value of an interval softmax loss function; Loss2 represents a classification loss value of a classification loss function; a represents an adjustment weight of the identification loss value; and b represents an adjustment weight of the classification loss value.

5. The character attribute classification method of claim 1, wherein, The feature classification of the person feature vector by the classifier to obtain a predicted classification result of the person image under the to-be-classified attribute includes: The person feature vector is input into the classifier to enable the classifier to perform probability prediction on the person feature vector based on the to-be-classified attribute to obtain a predicted probability of each classification type under the to-be-classified attribute; The classifier sorts each predicted probability, and the classification type with the maximum predicted probability in the sorting result is taken as the predicted classification result output by the classifier.

6. A person attribute classifying apparatus characterized by comprising: It includes: An image acquisition module configured to acquire a person image to be classified and determine a to-be-classified attribute of the person image; A model determination module configured to determine a target attribute classification model corresponding to the to-be-classified attribute; the target attribute classification model is obtained by combining a feature identification network and a classifier; the feature identification network is pre-configured with an interval softmax loss function, and the classifier is pre-configured with a classification loss function; A model classification module configured to input the person image into the target attribute classification model to obtain a predicted classification result of the person image under the to-be-classified attribute output by the target attribute classification model; The model determination module includes: Acquiring sample image data corresponding to the to-be-classified attribute; the sample image data includes a real classification result labeled based on the to-be-classified attribute; Inputting the sample image data into a preset initial attribute classification model to obtain a predicted classification result of the sample image data under the to-be-classified attribute output by the initial attribute classification model; Training the initial attribute classification model by taking the predicted classification result approaching the real classification result as a target and using an interval softmax loss function and a classification loss function; When the initial attribute classification model meets a preset training end condition, taking the trained initial attribute classification model as the target attribute classification model; The model classification module includes: Inputting the person image into the feature identification network to obtain a person feature vector obtained by the feature identification network performing feature identification on the person image; Classifying the person feature vector by the classifier to obtain a predicted classification result of the person image under the to-be-classified attribute.

7. A storage medium characterized by: The storage medium stores computer readable instructions, and the computer readable instructions are executed by one or more processors to enable the one or more processors to perform the steps of the person attribute classification method in any one of claims 1 to 5.

8. A computer device, comprising: It includes: One or more processors and a memory; The memory stores computer readable instructions which, when executed by the one or more processors, perform the steps of the character attribute classification method of any one of claims 1 to 5.

Citation Information

Patent Citations

  • Image processing method and device, electronic device and storage medium

    CN110570383A

  • Image recognition method and device, computer equipment and storage medium

    CN111178128A