Pedestrian gender and age recognition method and device based on clothing description generation

Through a method based on clothing description generation, combined with technologies such as backbone network and human body part detection model, the problem of low accuracy of traditional pedestrian gender and age recognition technology is solved, and high-accuracy recognition at different angles and environments is achieved, which is suitable for Scenarios such as urban security and health monitoring.

CN118334711BActive Publication Date: 2024-08-27HUAQIAO UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410757573.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-13
Publication Date
2024-08-27
Estimated Expiration
2044-06-13

AI Technical Summary

Technical Problem

Traditional pedestrian gender and age recognition technology is greatly affected by observation angles and environmental factors, resulting in low recognition accuracy and lack of robustness, and cannot be widely used in scenarios such as urban security and health monitoring.

Method used

Using a method based on clothing description generation, by building a pedestrian gender and age recognition model, using the backbone network, human body part detection model, image subtitle generation model and word embedding model, the clothing text description is generated and vector features are extracted, and the image features are combined to perform gender and age identification. Age recognition to improve the accuracy and robustness of recognition.

Benefits of technology

It improves the accuracy and robustness of pedestrian gender and age recognition, can be widely used in urban security, health monitoring and personalized recommendation systems in smart cities, and enhances the ability to identify pedestrians' gender and age.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118334711B
    Figure CN118334711B
Patent Text Reader

Abstract

The invention discloses a pedestrian gender and age recognition method and device based on clothing description generation, which relates to the field of image recognition, and comprises: constructing a pedestrian gender and age recognition model, processing a pedestrian image into recognition features and image features through a linear mapping layer and a front a layer Transformer block, obtaining the position of the human body parts in the pedestrian image by using a human body part detection model, and cropping each human body part image, generating clothing text descriptions corresponding to each human body part image by using an image caption generation model, and mapping the clothing text descriptions into clothing text description vectors by using a word embedding model, inputting the clothing text description vectors into a feature extraction module, extracting corresponding vector features, splicing all the vector features and then connecting them to the recognition features and image features, and sequentially passing through a rear b layer Transformer block, a first fully connected layer and a Softmax function layer to obtain a recognition result, and solving the problem that the gender and age recognition technology is greatly affected by factors such as the observation angle and the environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image recognition, and in particular to a method and device for identifying the gender and age of a pedestrian based on clothing description generation. Background Art

[0002] Pedestrian gender and age recognition technology can be used in urban security, health monitoring and personalized recommendations. Traditional implementation methods are based on voice or face data, which have high requirements for environmental noise and pedestrian cooperation and cannot be widely used. The method based on pedestrian body images has better applicability and can be used in most scenarios that support monitoring, but it is greatly affected by factors such as observation angle and environment, resulting in low recognition accuracy and lack of robustness. Summary of the invention

[0003] The purpose of this application is to propose a method and device for pedestrian gender and age recognition based on clothing description generation in response to the above-mentioned technical problems.

[0004] In a first aspect, the present invention provides a method for identifying the gender and age of a pedestrian based on clothing description generation, comprising the following steps:

[0005] Construct a pedestrian gender and age recognition model and train it to obtain a trained pedestrian gender and age recognition model. The pedestrian gender and age recognition model includes a backbone network, a human body part detection model, an image caption generation model, a word embedding model and a feature extraction module. The backbone network includes a linear mapping layer, an a+b layer Transformer block, a fully connected layer and a Softmax function layer. The pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block. The human body part detection model is used to obtain the position of the human body part in the pedestrian image. Based on the position of the human body part, each human body part image is cropped out in the pedestrian image. The image caption generation model is used to generate clothing text descriptions corresponding to each human body part image, and the word embedding model is used to map the clothing text description to a clothing text description vector. The clothing text description vector is input into the feature extraction module to extract the corresponding vector features. The vector features corresponding to all clothing text description vectors are spliced ​​and then connected to the recognition features and image features to obtain the connection features. The connection features are sequentially passed through the last b layer Transformer block, the first fully connected layer and the Softmax function layer to obtain the posterior probability of gender and age.

[0006] Obtain the pedestrian image to be identified, input it into the trained pedestrian gender and age recognition model, obtain the gender and age posterior probabilities, and select the gender and age category with the largest gender and age posterior probability value as the recognition result.

[0007] Preferably, the pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block, specifically including:

[0008] The linear mapping layer includes a convolutional layer and a flattening layer connected in sequence, and the linear mapping is performed using the following formula:

[0009] ;

[0010] in, is a pedestrian image, represents the real number domain, H and W are the height and width of the pedestrian image respectively, and B is the number of samples in each batch; is the image feature, Conv(•) represents the convolution layer, Flatten(•) represents the flattening layer, N is the number of image features, and C is the number of channels; the convolution kernel size of the convolution layer is h×w, h represents the vertical sliding step, and w represents the horizontal sliding step. Its output shape is The flattening layer is used to transform the image features of shape The image features are processed into a shape of The image features, is the number of image features, and then the second and third dimensions are swapped to obtain a shape of Image features ;

[0011] Initialize an initial feature with the same number of channels as the image feature μ, concatenate it with the image feature and send it to the Transformer block stacked in the first a layers. The formula is as follows:

[0012] ;

[0013] ;

[0014] p = γ a [:, 0 ,:], q = γ a [:, 1 :,:] ;

[0015] in, is the initial feature; Concat is a feature connection operation, which is used to connect the initial feature t with the image feature μ in the second dimension to obtain the input feature of the first layer Transformer block; is the input feature of the first layer Transformer block; is the output feature of the nth layer Transformer block; γ a [:, 0 ,:] It means extracting all the data belonging to the 0th channel in the second dimension of the output features of the a-th layer Transformer block. γ a [:, 1 :,:] It means extracting all the data after the first channel for the second dimension of the output features of the a-th layer Transformer block; and They are recognition features and image features respectively.

[0016] Preferably, the positions of the human body parts in the pedestrian image are obtained by using a human body part detection model, and each human body part image is cut out from the pedestrian image based on the position of the human body part, specifically including:

[0017] The human body part detection model is used to detect the locations of the facial parts, upper body parts, lower body parts, and feet parts in the pedestrian image, as shown in the following formula:

[0018] ;

[0019] y k = C r o p ( x , { i k , j k , h k , w k } ) = x [ : , : , i k : i k + h k , j k : j k + w k ] ;

[0020] Among them, Detector is the function corresponding to the human body part detection model, {i k ,j k ,h k ,w k} is the location of the kth human body part, i k With j k They represent the ordinate and abscissa of the origin of the human body part, respectively. k With w k They represent the height and width of the human body part, respectively; k represents the serial number of the human body part; when k is 0, it represents the face part; when k is 1, it represents the upper body part; when k is 2, it represents the lower body part; and when k is 3, it represents the foot part; Crop is an image cropping operation, which crops the kth human body part image from the pedestrian image x based on the position of the kth human body part; is the kth human body part image, x [ : , : , i k : i k + h k , j k : j k + w k ] Indicates the channel numbers of all the third dimensions extracted from the pedestrian image x. and and the channel number of the fourth dimension is between and All data in between.

[0021] Preferably, the image caption generation model is used to generate clothing text descriptions corresponding to the images of various human body parts, and the clothing text descriptions are mapped into clothing text description vectors using a word embedding model. The clothing text description vectors are input into a feature extraction module to extract corresponding vector features. The vector features corresponding to all clothing text description vectors are concatenated and then connected to the recognition features and the image features to obtain connection features, which specifically include:

[0022] Input the images of various human body parts into the image caption generation model to obtain the corresponding clothing text description, as shown in the following formula:

[0023] ;

[0024] ;

[0025] Among them, ICM is the function corresponding to the image caption generation model, z k is the clothing text description corresponding to the k-th human body part image. The clothing text description includes clothing style and clothing color. WEM is the function corresponding to the word embedding model. is the clothing text description vector corresponding to the k-th clothing text description, B is the number of samples in each batch, and C is the number of channels;

[0026] The feature extraction module includes a second fully connected layer and a linear rectifier function layer connected in sequence. The clothing text description vector passes through the second fully connected layer and the linear rectifier function layer to obtain the corresponding vector feature, as shown in the following formula:

[0027] ;

[0028] ;

[0029] Among them, FC(•) is the function corresponding to the second fully connected layer; is the vector feature corresponding to the k-th clothing text description vector, which is composed of the k-th clothing text description vector f k Mapped by the second fully connected layer; ReLU (•) is a linear rectification function; is the vector feature corresponding to the kth clothing text description vector after activation by the linear rectification function layer;

[0030] The vector features corresponding to all clothing text description vectors are concatenated, and the concatenated vector features are connected to the recognition features and image features, as shown in the following formula:

[0031] ;

[0032] ;

[0033] ;

[0034] Reshape is a shape adjustment operation, which is used in vector features. Add a new dimension between the first and second dimensions to obtain vector features that can be used for feature concatenation ; Concat is a feature concatenation operation, which concatenates several features with the same number of channels C in the second dimension. is the concatenated vector feature; and are recognition features and image features respectively, and N is the number of image features; It is a connection feature formed by connecting the recognition feature p, the image feature q and the concatenated vector feature v in the second dimension.

[0035] Preferably, the connection features are sequentially passed through the last b layers of Transformer blocks, the first fully connected layer, and the Softmax function layer to obtain the posterior probabilities of gender and age, specifically including:

[0036] The connection features are input into the Transformer block with b layers stacked after that, and the calculation formula is as follows:

[0037] ;

[0038] ;

[0039] d = ψ b [:, 0 ,:] ;

[0040] in, Represents the connection characteristics, represents the output features of the σth layer Transformer block, ψ b [:, 0 ,:] It means extracting all the data belonging to the 0th channel in the second dimension of the output features of the b-th layer Transformer block. is the final feature; after the final feature passes through the first fully connected layer and the Softmax function layer, the posterior probabilities of gender and age are obtained.

[0041] Preferably, the gender and age categories are the permutations and combinations of different genders and different age groups.

[0042] In a second aspect, the present invention provides a pedestrian gender and age recognition device based on clothing description generation, comprising:

[0043] A model building module is configured to build and train a pedestrian gender and age recognition model to obtain a trained pedestrian gender and age recognition model. The pedestrian gender and age recognition model includes a backbone network, a human body part detection model, an image caption generation model, a word embedding model and a feature extraction module. The backbone network includes a linear mapping layer, an a+b layer Transformer block, a fully connected layer and a Softmax function layer. The pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block. The position of the human body part in the pedestrian image is obtained by using the human body part detection model. Each human body part image is cropped out from the pedestrian image based on the position of the human body part. The image caption generation model is used to generate clothing text descriptions corresponding to each human body part image, and the clothing text description is mapped into a clothing text description vector by using the word embedding model. The clothing text description vector is input into the feature extraction module to extract the corresponding vector features. The vector features corresponding to all clothing text description vectors are spliced ​​and then connected to the recognition features and image features to obtain the connection features. The connection features are sequentially passed through the rear b layer Transformer block, the first fully connected layer and the Softmax function layer to obtain the posterior probability of gender and age.

[0044] The classification module is configured to obtain a pedestrian image to be identified, input it into a trained pedestrian gender and age recognition model, obtain gender and age posterior probabilities, and select the gender and age category with the largest gender and age posterior probability value as the recognition result.

[0045] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0046] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0047] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0048] Compared with the prior art, the present invention has the following beneficial effects:

[0049] (1) The pedestrian gender and age recognition method based on clothing description generation proposed in the present invention generates clothing text descriptions for the clothing of the pedestrian's head, upper body, lower body and feet, and then maps the clothing text descriptions into vector features. The accuracy of the pedestrian gender and age recognition method is enhanced by using clothing vector features that are gender-related, age-related and highly robust.

[0050] (2) The pedestrian gender and age recognition method based on clothing description generation proposed in this invention can be widely used in urban security, health monitoring and personalized recommendation systems in smart city scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0051] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0052] Figure 1 A flowchart of a method for identifying pedestrian gender and age based on clothing description generation according to an embodiment of the present application;

[0053] Figure 2 A flowchart of a method for identifying pedestrian gender and age based on clothing description generation according to an embodiment of the present application;

[0054] Figure 3 A flowchart of a method for generating clothing descriptions of a method for identifying pedestrian gender and age based on clothing descriptions according to an embodiment of the present application;

[0055] Figure 4 A schematic diagram of a pedestrian gender and age recognition device based on clothing description generation according to an embodiment of the present application;

[0056] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0058] Figure 1 A method for identifying the gender and age of a pedestrian based on clothing description generation provided by an embodiment of the present application is shown, comprising the following steps:

[0059] S1, constructing and training a pedestrian gender and age recognition model to obtain a trained pedestrian gender and age recognition model. The pedestrian gender and age recognition model includes a backbone network, a human body part detection model, an image caption generation model, a word embedding model and a feature extraction module. The backbone network includes a linear mapping layer, an a+b layer Transformer block, a fully connected layer and a Softmax function layer. The pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block. The human body part detection model is used to obtain the position of the human body part in the pedestrian image. Based on the position of the human body part, each human body part image is cropped out in the pedestrian image. The image caption generation model is used to generate clothing text descriptions corresponding to each human body part image, and the word embedding model is used to map the clothing text description to a clothing text description vector. The clothing text description vector is input into the feature extraction module to extract the corresponding vector features. The vector features corresponding to all clothing text description vectors are spliced ​​and then connected to the recognition features and image features to obtain the connection features. The connection features are sequentially passed through the rear b layer Transformer block, the first fully connected layer and the Softmax function layer to obtain the posterior probability of gender and age.

[0060] In a specific embodiment, the pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block, specifically including:

[0061] The linear mapping layer includes a convolutional layer and a flattening layer connected in sequence, and the linear mapping is performed using the following formula:

[0062] ;

[0063] in, is a pedestrian image, represents the real number domain, H and W are the height and width of the pedestrian image respectively, and B is the number of samples in each batch; is the image feature, Conv(•) represents the convolution layer, Flatten(•) represents the flattening layer, N is the number of image features, and C is the number of channels; the convolution kernel size of the convolution layer is h×w, h represents the vertical sliding step, and w represents the horizontal sliding step. Its output shape is The flattening layer is used to transform the image features of shape The image features are processed into a shape of The image features, is the number of image features, and then the second and third dimensions are swapped to obtain a shape of Image features ;

[0064] Initialize an initial feature with the same number of channels as the image feature μ, concatenate it with the image feature and send it to the Transformer block stacked in the first a layers. The formula is as follows:

[0065] ;

[0066] ;

[0067] p = γ a [:, 0 ,:], q = γ a [:, 1 :,:] ;

[0068] in, is the initial feature; Concat is a feature connection operation, which is used to connect the initial feature t with the image feature μ in the second dimension to obtain the input feature of the first layer Transformer block; is the input feature of the first layer Transformer block; is the output feature of the nth layer Transformer block; γ a [:, 0 ,:] It means extracting all the data belonging to the 0th channel in the second dimension of the output features of the a-th layer Transformer block. γ a [:, 1 :,:] It means extracting all the data after the first channel for the second dimension of the output features of the a-th layer Transformer block; and They are recognition features and image features respectively.

[0069] In a specific embodiment, the positions of human body parts in a pedestrian image are obtained by using a human body part detection model, and each human body part image is cropped out from the pedestrian image based on the positions of the human body parts, specifically including:

[0070] The human body part detection model is used to detect the locations of the facial parts, upper body parts, lower body parts, and feet parts in the pedestrian image, as shown in the following formula:

[0071] ;

[0072] y k = C r o p ( x , { i k , j k , h k , w k } ) = x [ : , : , i k : i k + h k , j k : j k + w k ] ;

[0073] Among them, Detector is the function corresponding to the human body part detection model, {i k ,j k ,h k ,w k} is the location of the kth human body part, i k With j k They represent the ordinate and abscissa of the origin of the human body part, respectively.k With w k They represent the height and width of the human body part, respectively; k represents the serial number of the human body part; when k is 0, it represents the face part; when k is 1, it represents the upper body part; when k is 2, it represents the lower body part; and when k is 3, it represents the foot part; Crop is an image cropping operation, which crops the kth human body part image from the pedestrian image x based on the position of the kth human body part; is the kth human body part image, x [ : , : , i k : i k + h k , j k : j k + w k ] Indicates the channel numbers of all the third dimensions extracted from the pedestrian image x. and and the channel number of the fourth dimension is between and All data in between.

[0074] In a specific embodiment, an image caption generation model is used to generate clothing text descriptions corresponding to images of various human body parts, and a word embedding model is used to map clothing text descriptions into clothing text description vectors. The clothing text description vectors are input into a feature extraction module to extract corresponding vector features. The vector features corresponding to all clothing text description vectors are concatenated and then connected to the recognition features and image features to obtain connection features, which specifically include:

[0075] Input the images of various human body parts into the image caption generation model to obtain the corresponding clothing text description, as shown in the following formula:

[0076] ;

[0077] ;

[0078] Among them, ICM is the function corresponding to the image caption generation model, z k is the clothing text description corresponding to the k-th human body part image. The clothing text description includes clothing style and clothing color. WEM is the function corresponding to the word embedding model. is the clothing text description vector corresponding to the k-th clothing text description, B is the number of samples in each batch, and C is the number of channels;

[0079] The feature extraction module includes a second fully connected layer and a linear rectifier function layer connected in sequence. The clothing text description vector passes through the second fully connected layer and the linear rectifier function layer to obtain the corresponding vector feature, as shown in the following formula:

[0080] ;

[0081] ;

[0082] Among them, FC(•) is the function corresponding to the second fully connected layer; is the vector feature corresponding to the k-th clothing text description vector, which is composed of the k-th clothing text description vector f k Mapped by the second fully connected layer; ReLU (•) is a linear rectification function; is the vector feature corresponding to the kth clothing text description vector after activation by the linear rectification function layer;

[0083] The vector features corresponding to all clothing text description vectors are concatenated, and the concatenated vector features are connected to the recognition features and image features, as shown in the following formula:

[0084] ;

[0085] ;

[0086] ;

[0087] Reshape is a shape adjustment operation, which is used in vector features. Add a new dimension between the first and second dimensions to obtain vector features that can be used for feature concatenation ; Concat is a feature concatenation operation, which concatenates several features with the same number of channels C in the second dimension. is the concatenated vector feature; and are recognition features and image features respectively, and N is the number of image features; It is a connection feature formed by connecting the recognition feature p, the image feature q and the concatenated vector feature v in the second dimension.

[0088] In a specific embodiment, the connection features are sequentially passed through the last b layers of Transformer blocks, the first fully connected layer, and the Softmax function layer to obtain the posterior probabilities of gender and age, which specifically include:

[0089] The connection features are input into the Transformer block with b layers stacked after that, and the calculation formula is as follows:

[0090] ;

[0091] ;

[0092] d = ψ b [:, 0 ,:] ;

[0093] in, Represents the connection characteristics, represents the output features of the σth layer Transformer block, ψ b [:, 0 ,:] It means extracting all the data belonging to the 0th channel in the second dimension of the output features of the b-th layer Transformer block. is the final feature; after the final feature passes through the first fully connected layer and the Softmax function layer, the posterior probabilities of gender and age are obtained.

[0094] Specifically, in the training phase, pedestrian images with gender labels and age labels are obtained as pedestrian gender and age recognition datasets. The pedestrian gender and age recognition datasets are preprocessed to obtain training data, and the pedestrian gender and age recognition model is trained using the training data. The preprocessing process includes: resizing all pedestrian images in the pedestrian gender and age recognition dataset to H×W, where H and W are the height and width of the pedestrian image, respectively, and using random horizontal flipping and random cropping to perform data preprocessing on the pedestrian images.

[0095] For further reference, Figure 2 , select the ViT-Base model as the backbone network to build a pedestrian gender and age recognition model. In one embodiment, the ViT-Base model has a total of 12 layers of Transformer blocks, of which the first 4 layers of Transformer blocks are involved in the generation of recognition features and image features, and the last 8 layers of Transformer blocks are used to process connection features. The pedestrian image and the output features of the 4th layer Transformer block of the backbone network are used as inputs to the clothing description generation method, and the output of the clothing description generation method is used as input features of the 5th layer Transformer block of the ViT-Base model. In the ViT-Base model, the pedestrian image is first mapped to image features through a linear mapping layer. Specifically, the pedestrian image is input into the convolution layer to obtain a shape of The image features of, that is, the number of image features in the vertical direction is , the number of image features in the horizontal direction is , the number of channels of the image feature is C, and then the space is flattened by the flattening layer to obtain the shape The image feature μ is initialized again, and then it is concatenated with the image feature μ and sent to the four-layer stacked Transformer block. The calculation of each layer of Transformer block includes regularization operation, self-attention operation and multi-layer perceptron operation. The calculation of Transformer block is an existing technology and will not be repeated here. Finally, the recognition feature and image feature are obtained.

[0096] Furthermore, the clothing description generation method is used to generate vector features corresponding to the clothing text description vectors for the four body parts of the pedestrian image, and the vector features are connected to the recognition features and image features. Figure 3 ,The clothing description generation method specifically includes:

[0097] The human body part detection model is used to obtain the position of the human body parts in the pedestrian image, and the human body part images are cropped out in the pedestrian image based on the position of the human body parts; the image caption generation model is used to generate the clothing text description corresponding to each human body part image, and the word embedding model is used to map the clothing text description into a clothing text description vector; the feature extraction module is used to extract the vector features corresponding to the clothing text description features; the vector features corresponding to all the clothing text description features are spliced, and the spliced ​​vector features are connected to the recognition features and the image features to obtain the connection features.

[0098] In one embodiment, the human body part detection model uses a pre-trained YOLOv8 model, which can detect the location of the facial parts, upper body parts, lower body parts and foot parts in the pedestrian image; the image subtitle generation model uses a pre-trained NIC model, which can generate a text description of the corresponding clothing for the human body part image, and the text description includes information such as clothing style and clothing color. The description information of pedestrian clothing style, color and other clothing has strong gender correlation and age correlation, and it has strong robustness and is less affected by the observation angle and environment. This means that after the description information of the clothing is embedded in the visual model, a gender-related, age-related and highly robust clothing feature can be introduced into the visual model. The feature extraction module uses a second fully connected layer and a linear rectifier function layer. In other embodiments, other suitable models can also be selected to achieve the same function, which is not limited here.

[0099] Specifically, the connection features are input into the following 8-layer stacked Transformer blocks. The calculation method of the Transformer block here is consistent with the calculation method of the above Transformer block. The final features are obtained after passing through the last layer of Transformer blocks.

[0100] In the training process of the pedestrian gender and age recognition model, the first fully connected layer and the Softmax function layer are used to convert the recognition features into the posterior probability of the pedestrian's gender and age, and the cross entropy loss of gender and age is calculated and output using the cross entropy, as shown in the following formula:

[0101] ;

[0102] Among them, e is the loss function of the pedestrian gender and age recognition model; FC is the first fully connected layer, which is used to adjust the number of feature channels of the final feature d to be consistent with the product of the number of genders and the number of ages in the training set; Softmax is the Softmax function layer, which is used to convert the feature value into the posterior probability of gender and age; CrossEntropy is the cross entropy loss function, which is used to calculate the cross entropy loss value of the posterior probability of gender and age and its gender and age label T. According to the cross entropy loss e of gender and age, the pedestrian gender and age recognition model is subjected to stochastic gradient descent to complete the model training.

[0103] S2, obtain the pedestrian image to be identified, input it into the trained pedestrian gender and age recognition model, obtain the gender and age posterior probabilities, and select the gender and age category with the largest gender and age posterior probability values ​​as the recognition result.

[0104] In a specific embodiment, the gender and age categories are the permutation and combination results of different genders and different age groups.

[0105] Specifically, in the inference stage: the trained pedestrian gender and age recognition model obtained in the training stage is used to extract features from pedestrian images, and based on the gender and age posterior probabilities output by the Softmax function layer, the gender and age category with the largest gender and age posterior probability value is selected as the recognition result output by the pedestrian gender and age recognition model. Each gender and age category corresponds to a gender and age posterior probability value, and the gender and age category is the encoding result of gender and age. For example, there are 2 genders (male, female) and 3 age groups (young, middle-aged, and elderly). The gender and age category has 2×3 six categories, namely male youth, male middle-aged, male elderly, female youth, female middle-aged, and female elderly.

[0106] Further references Figure 4 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a pedestrian gender and age recognition device based on clothing description generation. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0107] The present application embodiment provides a pedestrian gender and age recognition device based on clothing description generation, including:

[0108] Model construction module 1 is configured to construct and train a pedestrian gender and age recognition model to obtain a trained pedestrian gender and age recognition model. The pedestrian gender and age recognition model includes a backbone network, a human body part detection model, an image caption generation model, a word embedding model and a feature extraction module. The backbone network includes a linear mapping layer, an a+b layer Transformer block, a fully connected layer and a Softmax function layer. The pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block. The position of the human body part in the pedestrian image is obtained by using the human body part detection model. Each human body part image is cropped out from the pedestrian image based on the position of the human body part. The image caption generation model is used to generate clothing text descriptions corresponding to each human body part image, and the clothing text description is mapped into a clothing text description vector by using the word embedding model. The clothing text description vector is input into the feature extraction module to extract the corresponding vector features. The vector features corresponding to all clothing text description vectors are spliced ​​and then connected to the recognition features and image features to obtain the connection features. The connection features are sequentially passed through the rear b layer Transformer block, the first fully connected layer and the Softmax function layer to obtain the posterior probability of gender and age.

[0109] Classification module 2 is configured to obtain a pedestrian image to be identified, input it into a trained pedestrian gender and age recognition model, obtain gender and age posterior probabilities, and select the gender and age category with the largest gender and age posterior probability value as the recognition result.

[0110] Figure 5 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Figure 5 As shown, the electronic device of this embodiment includes: a processor 501 and a memory 502; wherein the memory 502 is used to store computer-executable instructions; the processor 501 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description in the above method embodiment.

[0111] Optionally, the memory 502 may be independent or integrated with the processor 501 .

[0112] When the memory 502 is independently provided, the electronic device further includes a bus 503 for connecting the memory 502 and the processor 501 .

[0113] An embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When a processor executes the computer execution instructions, the above method is implemented.

[0114] An embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by a processor, the above method is implemented.

[0115] In the embodiments provided by the present invention, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules is only a logical function division, and there may be other division methods in actual implementation, such as multiple modules can be combined or integrated into another system, or some features can be ignored or not executed. Another point, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or modules, which can be electrical, mechanical or other forms.

[0116] The modules described as separate components may or may not be physically separated, and the components shown as modules may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to implement the solution of this embodiment.

[0117] In addition, each functional module in each embodiment of the present invention may be integrated into one processing unit, or each module may exist physically separately, or two or more modules may be integrated into one unit. The above-mentioned module-composed unit may be implemented in the form of hardware or in the form of hardware plus software functional units.

[0118] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to perform some steps of the methods of various embodiments of the present application.

[0119] It should be understood that the processor may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or any conventional processor. The steps of the method disclosed in the invention may be directly implemented as being executed by a hardware processor, or may be implemented by a combination of hardware and software modules in the processor.

[0120] The memory may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk or an optical disk, etc.

[0121] The bus may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, the bus in the drawings of the present application is not limited to only one bus or one type of bus.

[0122] The above storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk. The storage medium can be any available medium that can be accessed by a general or special purpose computer.

[0123] An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an application specific integrated circuit (ASIC). Of course, the processor and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0124] Those skilled in the art can understand that all or part of the steps of implementing the above-mentioned method embodiments can be completed by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, the steps of the above-mentioned method embodiments are executed; and the aforementioned storage medium includes: ROM, RAM, disk or optical disk and other media that can store program codes.

[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for identifying the gender and age of pedestrians based on clothing description generation, characterized in that: The following steps are involved: A pedestrian gender and age recognition model is constructed and trained to obtain a trained pedestrian gender and age recognition model, wherein the pedestrian gender and age recognition model includes a backbone network, a human body part detection model, an image caption generation model, a word embedding model and a feature extraction module, wherein the backbone network includes a linear mapping layer, an a+b layer Transformer block, a fully connected layer and a Softmax function layer, wherein the pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block, the human body part detection model is used to obtain the position of the human body part in the pedestrian image, and based on the position of the human body part Cut out images of various human body parts from the pedestrian image, generate clothing text descriptions corresponding to the images of various human body parts using the image caption generation model, map the clothing text descriptions into clothing text description vectors using the word embedding model, input the clothing text description vectors into the feature extraction module, extract corresponding vector features, concatenate the vector features corresponding to all clothing text description vectors and then connect them to the recognition features and image features to obtain connection features, and sequentially pass the connection features through the rear b-layer Transformer blocks, the first fully connected layer and the Softmax function layer to obtain the posterior probabilities of gender and age; Obtain a pedestrian image to be identified, input it into the trained pedestrian gender and age recognition model, obtain gender and age posterior probabilities, and select the gender and age category with the largest gender and age posterior probability value as the recognition result.

2. The method for identifying pedestrian gender and age based on clothing description generation according to claim 1 is characterized in that: The pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block, specifically including: The linear mapping layer includes a convolution layer and a flattening layer connected in sequence, and the linear mapping is performed using the following formula: ; in, is a pedestrian image, represents the field of real numbers, H and W are the height and width of the pedestrian image, B is the number of samples in each batch; is the image feature, Conv(•) represents the convolution layer, Flatten(•) represents the flattening layer, N is the number of image features, C is the number of channels; the convolution kernel size of the convolution layer is h × w , h Indicates the vertical sliding step length, w Represents the horizontal sliding step length, and its output shape is The flattening layer is used to transform the image into The image features are processed into a shape of The image features, is the number of image features, and then the second and third dimensions are swapped to obtain a shape of Image features ; Initialize a μ The initial features with the same number of channels are concatenated with the image features and sent to the Transformer block stacked in the first a layers. The formula is as follows: ; ; ; in, is the initial feature; Concat is the feature connection operation, which is used to connect the initial feature t With image features μ Perform feature concatenation on the second dimension to obtain the input features of the first layer Transformer block; is the input feature of the first layer Transformer block; For the η Output features of the layer Transformer block; It means extracting all the data belonging to the 0th channel in the second dimension of the output features of the a-th layer Transformer block. It means extracting all the data after the first channel for the second dimension of the output features of the a-th layer Transformer block; and They are recognition features and image features respectively.

3. The method for identifying pedestrian gender and age based on clothing description generation according to claim 1, characterized in that: The method of obtaining the positions of the human body parts in the pedestrian image by using the human body part detection model and cutting out the images of the human body parts in the pedestrian image based on the positions of the human body parts specifically includes: The positions of the facial parts, upper body parts, lower body parts and foot parts in the pedestrian image are detected by the human body part detection model, as shown in the following formula: ; ; Wherein, Detector is the function corresponding to the human body part detection model, { i k , j k , h k , w k } is the k The location of individual body parts, i k and j k They represent the ordinate and abscissa of the origin of the human body part, h k and w k Respectively represent the height and width of the human body part, k Indicates the serial number of the human body part. k When it is 0, it indicates the face part. k When it is 1, it indicates the upper body part. k When it is 2, it indicates the lower body. k When it is 3, it indicates the foot part; Crop is the image cropping operation, which is based on the k The location of individual body parts in pedestrian images x Cut out the first k images of individual body parts; For the k Individual body part images, Indicates the extraction of pedestrian images x The channel numbers of all third dimensions in and and the channel number of the fourth dimension is between and All data in between.

4. The method for identifying pedestrian gender and age based on clothing description generation according to claim 3 is characterized in that: The method of using the image caption generation model to generate clothing text descriptions corresponding to the images of various human body parts, and using the word embedding model to map the clothing text descriptions into clothing text description vectors, inputting the clothing text description vectors into the feature extraction module, extracting corresponding vector features, and concatenating the vector features corresponding to all clothing text description vectors and then connecting them to the recognition features and the image features to obtain connection features specifically includes: The images of various human body parts are input into the image caption generation model to obtain the corresponding clothing text description, as shown in the following formula: ; ; Among them, ICM is the function corresponding to the image caption generation model, z k For the k a text description of clothing corresponding to an image of a body part, wherein the text description of clothing includes clothing style and clothing color, and WEM is a function corresponding to the word embedding model. For the k The clothing text description vector corresponding to the clothing text description, B is the number of samples in each batch, C is the number of channels; The feature extraction module includes a second fully connected layer and a linear rectifier function layer connected in sequence. The clothing text description vector passes through the second fully connected layer and the linear rectifier function layer to obtain the corresponding vector feature, as shown in the following formula: ; ; Among them, FC(•) is the function corresponding to the second fully connected layer; For the k The vector features corresponding to the clothing text description vector are k Clothing text description vector f k Mapped by the second fully connected layer; ReLU (•) is a linear rectification function; is the first k The vector features corresponding to the clothing text description vector; The vector features corresponding to all clothing text description vectors are concatenated, and the concatenated vector features are connected to the recognition features and image features, as shown in the following formula: ; ; ; Reshape is a shape adjustment operation, which is used in vector features. Add a new dimension between the first and second dimensions to obtain vector features that can be used for feature concatenation ; Concat is a feature connection operation, which connects several features with the same number of channels in the second dimension C The feature connection of is the concatenated vector feature; and are recognition features and image features respectively. N is the number of image features; Identify the characteristics p , Image features q And the concatenated vector features v Concatenated features concatenated along the second dimension.

5. The method for pedestrian gender and age recognition based on clothing description generation according to claim 1 is characterized in that: The connection features are sequentially passed through the last b layers of Transformer blocks, the first fully connected layer, and the Softmax function layer to obtain the posterior probabilities of gender and age, specifically including: The connection features are input into the Transformer block with b layers stacked after that, and the calculation formula is as follows: ; ; ; in, Represents the connection characteristics, Indicates σ The output features of the layer Transformer block, It means extracting all the data belonging to the 0th channel in the second dimension of the output features of the b-th layer Transformer block. is the final feature; after the final feature passes through the first fully connected layer and the Softmax function layer, the posterior probabilities of gender and age are obtained.

6. The method for identifying pedestrian gender and age based on clothing description generation according to claim 1, characterized in that: The gender and age categories are the permutation and combination results of different genders and different age groups.

7. A pedestrian gender and age recognition device based on clothing description generation, characterized in that: include: The model building module is configured to build and train a pedestrian gender and age recognition model to obtain a trained pedestrian gender and age recognition model, wherein the pedestrian gender and age recognition model includes a backbone network, a human body part detection model, an image caption generation model, a word embedding model and a feature extraction module, wherein the backbone network includes a linear mapping layer, an a+b layer Transformer block, a fully connected layer and a Softmax function layer, wherein the pedestrian image is processed into recognition features and image features through the linear mapping layer and the first a layer Transformer block, the human body part detection model is used to obtain the position of the human body part in the pedestrian image, and based on the human body According to the position of the body part, various human body part images are cropped out from the pedestrian image, the image caption generation model is used to generate clothing text descriptions corresponding to the various human body part images, and the word embedding model is used to map the clothing text descriptions into clothing text description vectors, the clothing text description vectors are input into the feature extraction module, and the corresponding vector features are extracted, and the vector features corresponding to all clothing text description vectors are spliced ​​and then connected to the recognition features and image features to obtain connection features, and the connection features are sequentially passed through the rear b-layer Transformer block, the first fully connected layer and the Softmax function layer to obtain the posterior probabilities of gender and age; The classification module is configured to obtain a pedestrian image to be identified, input it into the trained pedestrian gender and age recognition model, obtain gender and age posterior probabilities, and select the gender and age category with the largest gender and age posterior probability value as the recognition result.

8. An electronic device, comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.