Dimension reduction method and device for face recognition features
By splicing and pre-training feature dimensionality reduction model of feature vectors extracted in the face recognition system, the problem of excessive computing resource consumption caused by excessive feature dimensions is solved, and efficient face recognition after dimensionality reduction is achieved.
Patent Information
- Application Number
- CN202411442057.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-15
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-10-15
AI Technical Summary
In the face recognition system, the feature dimensions extracted by the deep learning model are too high, resulting in excessive computing resources consumption in subsequent retrieval, and the existing technology has not yet proposed an effective solution.
By obtaining the feature vector extracted from the face image to be recognized by the feature extraction model, the pre-trained feature dimensionality reduction model is used for dimensionality reduction processing. The training sample of the target feature vector includes the feature extraction model from the positive faces of multiple objects The eigenvectors extracted from images and snapped images, the loss function includes the length loss and similarity loss before and after the dimensionality reduction of the eigenvector.
The feature dimension is reduced, the computing and storage costs are reduced, while key features are retained, and the efficiency of the face recognition system is improved.
Smart Images

Figure CN119418380A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of machine learning technology, and more specifically, to a method and device for reducing the dimensionality of facial recognition features. Background Art
[0002] Face recognition technology plays an important role in modern public security, especially when processing large-scale face databases and snapshot data. In face recognition systems, deep learning models are usually used to extract facial feature representations, which are then used for various tasks such as identity authentication and facial recognition. With the development of deep learning technology, face recognition models have become more and more complex, and the output feature dimensions have become higher and higher. Although this can improve recognition accuracy, it also brings higher computing and storage costs.
[0003] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0004] The embodiments of the present application provide a method and device for reducing the dimensionality of facial recognition features, so as to at least solve the technical problem that the feature dimensionality extracted by the model in related facial recognition solutions is too high, resulting in excessive consumption of computing resources for subsequent retrieval.
[0005] According to one aspect of an embodiment of the present application, a method for reducing the dimension of facial recognition features is provided, comprising: obtaining at least one first feature vector extracted by at least one feature extraction model from a face image to be recognized; concatenating at least one first feature vector to obtain a second feature vector; and performing dimension reduction processing on the second feature vector using a pre-trained feature dimension reduction model to obtain a target feature vector, wherein the training samples of the feature dimension reduction model include: multiple feature vectors extracted by at least one feature extraction model from frontal face images and captured images of multiple objects, and the dimensions of the loss function for training the feature dimension reduction model include: length loss and similarity loss before and after the feature vector dimension reduction.
[0006] Optionally, the feature dimension reduction model is trained in the following manner: obtaining multiple frontal face images and snapshot images of multiple objects, wherein each object corresponds to an identity identifier, at least one frontal face image and at least one snapshot image; for each frontal face image, using at least one feature extraction model to perform feature extraction on the frontal face image, and forming a third feature vector set with the obtained at least one third feature vector; for each snapshot image, using at least one feature extraction model to perform feature extraction on the snapshot image, and forming a fourth feature vector set with the obtained at least one fourth feature vector; constructing multiple training samples, wherein each training sample includes: at least one third feature vector corresponding to the same object; A set of feature vectors, at least one fourth feature vector set, and an identity identifier of the object; constructing an initial model, wherein the initial model includes at least one fully connected layer, and the initial model is used to reduce the dimension of each third feature vector of the input to a fifth feature vector, and reduce the dimension of each fourth feature vector of the input to a sixth feature vector; iteratively training the initial model using multiple training samples, during the training process, adjusting the model parameters using a target loss function, and using the trained model as a feature dimension reduction model, wherein the target loss function includes: a first loss function for reflecting the length difference before and after the feature vector dimension reduction and a second loss function for reflecting the similarity difference before and after the feature vector dimension reduction.
[0007] Optionally, for each training sample, obtain a fifth feature vector set corresponding to each third feature vector set and a sixth feature vector set corresponding to each fourth feature vector set in the training sample output by the model; concatenate the third feature vectors extracted by the same feature extraction model in all third feature vector sets in the training sample, form the obtained seventh feature vectors into a seventh feature vector set, normalize the seventh feature vectors, and form the obtained eighth feature vectors into an eighth feature vector set; concatenate the fourth feature vectors extracted by the same feature extraction model in all fourth feature vector sets in the training sample, form the obtained ninth feature vectors into a ninth feature vector set, normalize the ninth feature vectors Normalize the obtained tenth eigenvectors to form a tenth eigenvector set; splice the fifth eigenvectors extracted by the same feature extraction model in all fifth eigenvector sets corresponding to the training samples, form the obtained eleventh eigenvectors into an eleventh eigenvector set, normalize the eleventh eigenvectors, and form the obtained twelfth eigenvector set; splice the sixth eigenvectors extracted by the same feature extraction model in all sixth eigenvector sets corresponding to the training samples, form the obtained thirteenth eigenvectors into a thirteenth eigenvector set, normalize the thirteenth eigenvectors, and form the obtained fourteenth eigenvector set.
[0008] Optionally, the first loss function is determined in the following manner: in each training batch, for each training sample in the training batch, determining the average value of the lengths of each seventh eigenvector in the set of seventh eigenvectors corresponding to the training sample as the first eigenvector length; determining the average value of the lengths of each ninth eigenvector in the set of ninth eigenvectors corresponding to the training sample as the second eigenvector length; determining the average value of the lengths of each eleventh eigenvector in the set of eleventh eigenvectors corresponding to the training sample as the third eigenvector length; determining the average value of the lengths of each thirteenth eigenvector in the set of thirteenth eigenvectors corresponding to the training sample as the fourth eigenvector length; constructing the first loss function based on the difference between the length of the third eigenvector corresponding to each training sample in the training batch and the length of the first eigenvector, and the difference between the length of the fourth eigenvector and the length of the second eigenvector.
[0009] Optionally, the first loss function is determined by the following formula: L1 = w1·L len (len og ,len g )+w2·
[0010] L len (len op ,len p ) where L1 represents the first loss function, w1 and w2 are preset weight values, w1,w2∈(0,1) and w1+w2=1, len og and len g Respectively represent the length of the third feature vector and the length of the first feature vector, N represents the number of training samples in the training batch, len ogi and len gi They represent the length of the third eigenvector and the length of the first eigenvector corresponding to the i-th training sample, respectively. len op and len p Respectively represent the length of the fourth eigenvector and the length of the second eigenvector, len opi and len pi They respectively represent the length of the fourth eigenvector and the length of the second eigenvector corresponding to the i-th training sample.
[0011] Optionally, the second loss function is determined in the following manner: in each training batch, for every two training samples in the training batch, the eighth feature vectors corresponding to the same feature extraction model in the eighth feature vector sets of the two training samples are paired, the first similarity between each pair of eighth feature vectors is determined, and the average of each first similarity is determined as the first comprehensive similarity; the first comprehensive similarities corresponding to every two training samples are formed into a first similarity matrix; for every two training samples in the training batch, the tenth feature vectors corresponding to the same feature extraction model in the tenth feature vector sets of the two training samples are paired, the second similarity between each pair of tenth feature vectors is determined, and each second similarity is determined. The average of the third similarities is the second comprehensive similarity; the second comprehensive similarities corresponding to every two training samples are formed into a second similarity matrix; for every two training samples in the training batch, each eighth eigenvector in the eighth eigenvector set corresponding to each training sample in the two training samples is paired with the tenth eigenvector corresponding to the same feature extraction model in the tenth eigenvector set corresponding to the other training sample, and the third similarity between each pair of the eighth eigenvector and the tenth eigenvector is determined, and the average of each third similarity is determined as the third comprehensive similarity; the third comprehensive similarities corresponding to every two training samples are formed into a third similarity matrix; for every two training samples in the training batch, the tenth eigenvectors of the two training samples are respectively The twelfth eigenvectors corresponding to the same feature extraction model in the two feature vector sets are paired, the fourth similarity between each pair of twelfth eigenvectors is determined, and the average value of each fourth similarity is determined as the fourth comprehensive similarity; the fourth comprehensive similarities corresponding to every two training samples are combined into a fourth similarity matrix; for every two training samples in the training batch, the fourteenth eigenvectors corresponding to the same feature extraction model in the fourteenth eigenvector sets of the two training samples are paired, the fifth similarity between each pair of fourteenth eigenvectors is determined, and the average value of each fifth similarity is determined as the fifth comprehensive similarity; the fifth comprehensive similarities corresponding to every two training samples are combined into a fifth similarity matrix; for every two training samples in the training batch, For every two training samples, each twelfth eigenvector in the set of twelfth eigenvectors corresponding to each training sample in the two training samples is paired with the fourteenth eigenvector corresponding to the same feature extraction model in the set of fourteenth eigenvectors corresponding to the other training sample, the sixth similarity between each pair of twelfth eigenvectors and fourteenth eigenvectors is determined, and the average of each sixth similarity is determined as the sixth comprehensive similarity; the sixth comprehensive similarities corresponding to every two training samples are combined into a sixth similarity matrix; and a second loss function is constructed based on the differences between the fourth similarity matrix and the first similarity matrix, the differences between the fifth similarity matrix and the second similarity matrix, and the differences between the sixth similarity matrix and the third similarity matrix.
[0012] Optionally, for any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, determine the maximum similarity and the minimum similarity among the target similarities corresponding to the target comprehensive similarity, and update the target comprehensive similarity according to a preset formula; wherein the target similarity matrix includes one of the following: a first similarity matrix, a second similarity matrix, a third similarity matrix, a fourth similarity matrix, a fifth similarity matrix, and a sixth similarity matrix; the target comprehensive similarity includes one of the following: a first comprehensive similarity, a second comprehensive similarity, a third comprehensive similarity, a fourth comprehensive similarity, a fifth comprehensive similarity, and a sixth comprehensive similarity; the target similarity includes one of the following: a first similarity, a second similarity, a third similarity, a fourth similarity, a fifth similarity, and a sixth similarity; and the preset formula includes: sim ′ =w3·avgsim+w4·(maxsim·mask+minsim·(1-mask)), where avgsim represents the comprehensive similarity of the target, sim ′ It represents the updated value of the target comprehensive similarity, w3 and w4 are the preset weight values, w3,w4∈[0,1] and w3+w4=1, maxsim represents the maximum similarity, minsim represents the minimum similarity, and mask represents the mask corresponding to the target comprehensive similarity in the model calculation.
[0013] Optionally, for any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, and the target comprehensive similarity is less than a preset similarity threshold, the target comprehensive similarity in the target similarity matrix is replaced with the preset similarity threshold; wherein the target similarity matrix includes one of the following: a first similarity matrix, a second similarity matrix, a third similarity matrix, a fourth similarity matrix, a fifth similarity matrix, and a sixth similarity matrix, and the target comprehensive similarity includes one of the following: a first comprehensive similarity, a second comprehensive similarity, a third comprehensive similarity, a fourth comprehensive similarity, a fifth comprehensive similarity, and a sixth comprehensive similarity.
[0014] Optionally, the second loss function is determined by the following formula: L2 = w5·L sim (sim og ,sim g )+w6·
[0015] L sim (sim op ,sim p )+w7·L sim (sim oc ,simc ), where L2 represents the second loss function, w5, w6 and w7 are preset weight values, w5, w6, w7∈(0,1) and w5+w6+w7=1, sim og and sim g Represent the fourth similarity matrix and the first similarity matrix respectively, M represents the number of matrix elements, sim ogj and sim gj denote the jth element in the fourth similarity matrix and the first similarity matrix respectively, sim op and sim p Represent the fifth similarity matrix and the second similarity matrix respectively, sim opj and sim pj denote the jth element in the fifth similarity matrix and the second similarity matrix respectively, sim oc and sim c Respectively represent the sixth similarity matrix and the third similarity matrix, sim ocj and sim cj represent the j-th element in the sixth similarity matrix and the third similarity matrix respectively.
[0016] Optionally, the target loss function is determined in the following manner: determining a first loss function and a second loss function respectively; determining a first weight corresponding to the first loss function and a second weight corresponding to the second loss function respectively; and performing weighted summation of the first loss function and the second loss function according to the first weight and the second weight to obtain the target loss function.
[0017] According to another aspect of an embodiment of the present application, a dimensionality reduction device for face recognition features is also provided, including: an acquisition module, used to acquire at least one first feature vector extracted by at least one feature extraction model from a face image to be identified; a splicing module, used to splice at least one first feature vector to obtain a second feature vector; a dimensionality reduction module, used to perform dimensionality reduction processing on the second feature vector using a pre-trained feature dimensionality reduction model to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted by at least one feature extraction model from frontal face images and captured images of multiple objects, and the dimensions of the loss function for training the feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector.
[0018] According to another aspect of an embodiment of the present application, a computer program product is also provided, the computer program product comprising: a computer program, wherein when the computer program is executed by a processor, the above-mentioned dimensionality reduction method of face recognition features is implemented.
[0019] According to another aspect of an embodiment of the present application, an electronic device is further provided, comprising: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the above-mentioned dimensionality reduction method of face recognition features through the computer program.
[0020] In an embodiment of the present application, at least one first feature vector extracted from a face image to be identified by at least one feature extraction model is obtained; at least one first feature vector is concatenated to obtain a second feature vector; and the second feature vector is subjected to dimensionality reduction processing using a pre-trained feature dimensionality reduction model to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted from frontal face images and snapshot images of multiple objects by at least one feature extraction model, and the dimensions of the loss function for training the feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector. In this way, when training the feature dimensionality reduction model, the loss function used includes two dimensions, namely, length loss and similarity loss, to ensure that the feature vector after dimensionality reduction does not deviate too much from the original feature, and to ensure that similar face images remain close in the feature space after dimensionality reduction, and the second feature vector is subjected to dimensionality reduction processing using a pre-trained feature dimensionality reduction model, thereby reducing the amount of data while retaining key features, thereby solving the technical problem that the feature dimension extracted by the model in the related face recognition scheme is too high, resulting in excessive consumption of computing resources for subsequent retrieval. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0022] Figure 1 is a flowchart of an optional method for reducing the dimension of face recognition features according to an embodiment of the present application;
[0023] Figure 2 is a schematic structural diagram of an optional face recognition feature dimensionality reduction device according to an embodiment of the present application;
[0024] Figure 3 It is a schematic diagram of the structure of an optional electronic device according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below 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, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present application.
[0026] It should be noted that the terms "first", "second", etc. in the specification, claims and drawings of the present application are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0027] The facial data collected in this application are information and data authorized by the user or fully authorized by all parties, and the collection, storage, use, processing, transmission, provision, disclosure and application of the relevant data comply with the relevant laws, regulations and standards of the relevant countries and regions, take necessary confidentiality measures, do not violate public order and good morals, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0028] Example 1
[0029] According to an embodiment of the present application, a method for reducing the dimension of facial recognition features is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0030] Figure 1 is a flow chart of a method for reducing the dimension of face recognition features provided in an embodiment of the present application, such as Figure 1 As shown, the method comprises the following steps:
[0031] Step S102, obtaining at least one first feature vector extracted by at least one feature extraction model from the face image to be recognized;
[0032] Step S104, concatenating at least one first feature vector to obtain a second feature vector;
[0033] Step S106, using a pre-trained feature dimensionality reduction model to perform dimensionality reduction processing on the second feature vector to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted from frontal face images and snapshot images of multiple objects by at least one feature extraction model, and the dimensions of the loss function of the training feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector.
[0034] The following describes the various steps of the dimensionality reduction method for face recognition features in combination with a specific implementation process.
[0035] In order to solve the problem of high feature dimensionality of model extraction in face recognition solutions, this application proposes to use a pre-trained feature dimensionality reduction model to perform dimensionality reduction processing.
[0036] Optionally, the feature dimensionality reduction model is trained in the following manner: obtaining multiple frontal face images and snapshot images of multiple objects, wherein each object corresponds to an identity identifier, at least one frontal face image and at least one snapshot image; for each frontal face image, performing feature extraction on the frontal face image using at least one feature extraction model, and forming a third feature vector set with the obtained at least one third feature vector; for each snapshot image, performing feature extraction on the snapshot image using at least one feature extraction model, and forming a fourth feature vector set with the obtained at least one fourth feature vector; constructing multiple training samples, wherein each training sample includes: at least one third feature vector set corresponding to the same object, at least one fourth feature vector set, and the identity identifier of the object. After obtaining the above data, an initial model is constructed, wherein the initial model includes at least one fully connected layer, and the initial model is used to reduce the dimension of each third eigenvector of the input to a fifth eigenvector, and reduce the dimension of each fourth eigenvector of the input to a sixth eigenvector; the initial model is iteratively trained using multiple training samples, and during the training process, the model parameters are adjusted using the target loss function, and the trained model is used as a feature dimensionality reduction model, wherein the target loss function includes: a first loss function for reflecting the length difference before and after the dimensionality reduction of the feature vector and a second loss function for reflecting the similarity difference before and after the dimensionality reduction of the feature vector.
[0037] As an optional implementation, in order to facilitate unified processing, the training samples may be preprocessed before training the model. The specific processing process may be performed according to the following steps:
[0038] S1, for each training sample, obtaining a fifth feature vector set corresponding to each third feature vector set and a sixth feature vector set corresponding to each fourth feature vector set in the training sample output by the model;
[0039] S2, concatenating the third feature vectors extracted by the same feature extraction model in all the third feature vector sets in the training sample, forming the obtained seventh feature vectors into a seventh feature vector set, normalizing the seventh feature vectors, and forming the obtained eighth feature vectors into an eighth feature vector set;
[0040] S3, concatenating the fourth feature vectors extracted by the same feature extraction model in all fourth feature vector sets in the training sample, forming the obtained ninth feature vectors into a ninth feature vector set, normalizing the ninth feature vectors, and forming the obtained tenth feature vectors into a tenth feature vector set;
[0041] S4, concatenating the fifth feature vectors extracted by the same feature extraction model in all fifth feature vector sets corresponding to the training samples, forming the obtained eleventh feature vectors into an eleventh feature vector set, normalizing the eleventh feature vectors, and forming the obtained twelfth feature vectors into a twelfth feature vector set;
[0042] S5, concatenating the sixth eigenvectors extracted by the same feature extraction model in all the sixth eigenvector sets corresponding to the training samples, forming the obtained thirteenth eigenvectors into a thirteenth eigenvector set, normalizing the thirteenth eigenvectors, and forming the obtained fourteenth eigenvectors into a fourteenth eigenvector set.
[0043] Optionally, the first loss function is determined in the following manner: in each training batch, for each training sample in the training batch, determining the average value of the lengths of each seventh eigenvector in the set of seventh eigenvectors corresponding to the training sample as the first eigenvector length; determining the average value of the lengths of each ninth eigenvector in the set of ninth eigenvectors corresponding to the training sample as the second eigenvector length; determining the average value of the lengths of each eleventh eigenvector in the set of eleventh eigenvectors corresponding to the training sample as the third eigenvector length; determining the average value of the lengths of each thirteenth eigenvector in the set of thirteenth eigenvectors corresponding to the training sample as the fourth eigenvector length; constructing the first loss function based on the difference between the length of the third eigenvector corresponding to each training sample in the training batch and the length of the first eigenvector, and the difference between the length of the fourth eigenvector and the length of the second eigenvector.
[0044] Among them, the first loss function can be determined by the following formula:
[0045] L1=w1·L len (len og ,len g )+w2·L len (len op ,lenp )
[0046] Where L1 represents the first loss function, w1 and w2 are preset weight values, w1, w2∈(0,1) and w1+w2=1, L len (len og ,len g ) is:
[0047]
[0048] In the formula, len og and len g Respectively represent the length of the third feature vector and the length of the first feature vector, N represents the number of training samples in the training batch, len ogi and len gi They represent the length of the third eigenvector and the length of the first eigenvector corresponding to the i-th training sample, respectively. len (len op ,len p ) is:
[0049]
[0050] In the formula, len op and len p Respectively represent the length of the fourth eigenvector and the length of the second eigenvector, len opi and len pi They respectively represent the length of the fourth eigenvector and the length of the second eigenvector corresponding to the i-th training sample.
[0051] Optionally, the second loss function is determined by:
[0052] S1, in each training batch, for every two training samples in the training batch, pair the eighth feature vectors corresponding to the same feature extraction model in the eighth feature vector sets of the two training samples, determine the first similarity between each pair of eighth feature vectors, and determine the average value of each first similarity as the first comprehensive similarity; the first comprehensive similarities corresponding to every two training samples form a first similarity matrix;
[0053] S2, for every two training samples in the training batch, pair the tenth eigenvectors corresponding to the same feature extraction model in the tenth eigenvector sets of the two training samples, determine the second similarity between each pair of tenth eigenvectors, and determine the average value of each second similarity as the second comprehensive similarity; the second comprehensive similarities corresponding to every two training samples form a second similarity matrix;
[0054] S3, for every two training samples in the training batch, pair each eighth eigenvector in the eighth eigenvector set corresponding to each training sample in the two training samples with the tenth eigenvector corresponding to the same feature extraction model in the tenth eigenvector set corresponding to the other training sample, determine the third similarity between each pair of the eighth eigenvector and the tenth eigenvector, and determine the average of each third similarity as the third comprehensive similarity; form a third similarity matrix with the third comprehensive similarities corresponding to every two training samples;
[0055] S4, for every two training samples in the training batch, pair the twelfth feature vectors corresponding to the same feature extraction model in the twelfth feature vector sets of the two training samples, determine the fourth similarity between each pair of twelfth feature vectors, and determine the average value of each fourth similarity as the fourth comprehensive similarity; form a fourth similarity matrix with the fourth comprehensive similarities corresponding to every two training samples;
[0056] S5, for every two training samples in the training batch, pair the fourteenth feature vectors corresponding to the same feature extraction model in the fourteenth feature vector sets of the two training samples, determine the fifth similarity between each pair of fourteenth feature vectors, and determine the average value of each fifth similarity as the fifth comprehensive similarity; form a fifth similarity matrix with the fifth comprehensive similarities corresponding to every two training samples;
[0057] S6, for every two training samples in the training batch, pair each twelfth eigenvector in the twelfth eigenvector set corresponding to each training sample in the two training samples with the fourteenth eigenvector corresponding to the same feature extraction model in the fourteenth eigenvector set corresponding to the other training sample, determine the sixth similarity between each pair of the twelfth eigenvector and the fourteenth eigenvector, and determine the average of each sixth similarity as the sixth comprehensive similarity; form a sixth similarity matrix with the sixth comprehensive similarities corresponding to every two training samples;
[0058] S7, constructing a second loss function according to the difference between the fourth similarity matrix and the first similarity matrix, the difference between the fifth similarity matrix and the second similarity matrix, and the difference between the sixth similarity matrix and the third similarity matrix.
[0059] Optionally, for any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, determine the maximum similarity and the minimum similarity among the target similarities corresponding to the target comprehensive similarity, and update the target comprehensive similarity according to a preset formula; wherein the target similarity matrix includes one of the following: a first similarity matrix, a second similarity matrix, a third similarity matrix, a fourth similarity matrix, a fifth similarity matrix, and a sixth similarity matrix; the target comprehensive similarity includes one of the following: a first comprehensive similarity, a second comprehensive similarity, a third comprehensive similarity, a fourth comprehensive similarity, a fifth comprehensive similarity, and a sixth comprehensive similarity; the target similarity includes one of the following: a first similarity, a second similarity, a third similarity, a fourth similarity, a fifth similarity, and a sixth similarity; and the preset formula includes:
[0060] sim ′ =w3·avgsim+w4·(maxsim·mask+minsim·(1-mask))
[0061] In the formula, avgsim represents the comprehensive similarity of the target, sim ′ It represents the updated value of the target comprehensive similarity, w3 and w4 are the preset weight values, w3,w4∈[0,1] and w3+w4=1, maxsim represents the maximum similarity, minsim represents the minimum similarity, mask represents the mask corresponding to the target comprehensive similarity in the model calculation, and the value of mask is 0 or 1.
[0062] Optionally, for any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, and the target comprehensive similarity is less than a preset similarity threshold, the target comprehensive similarity in the target similarity matrix is replaced with the preset similarity threshold; wherein the target similarity matrix includes one of the following: a first similarity matrix, a second similarity matrix, a third similarity matrix, a fourth similarity matrix, a fifth similarity matrix, and a sixth similarity matrix, and the target comprehensive similarity includes one of the following: a first comprehensive similarity, a second comprehensive similarity, a third comprehensive similarity, a fourth comprehensive similarity, a fifth comprehensive similarity, and a sixth comprehensive similarity.
[0063] For example, the target comprehensive similarity can be modified using the following formula:
[0064] sim g [(sim g <thresh)&mask g ]=thresh
[0065] sim p [(sim p <thresh)&mask p ]=thresh
[0066] sim c [(sim c <thresh)&mask c ]=thresh
[0067] In the above formula, mask g 、mask p 、mask c They respectively represent the masks corresponding to the comprehensive similarities of each target in the model calculation, and thresh represents the preset similarity threshold.
[0068] Optionally, the second loss function is determined by the following formula:
[0069] L2=w5·L sim (sim og ,sim g )+w6·L sim (sim op ,sim p )+w7·L sim (sim oc ,sim c )
[0070] Where L2 represents the second loss function, w5, w6 and w7 are preset weight values, w5, w6, w7∈(0, 1) and w5+w6+w7=1, L sim (sim og ,sim g ) is:
[0071]
[0072] In the formula, sim og and sim g Represent the fourth similarity matrix and the first similarity matrix respectively, M represents the number of matrix elements, sim ogj and sim gj denote the jth element in the fourth similarity matrix and the first similarity matrix respectively,
[0073] L sim (sim op ,sim p ) is:
[0074]
[0075] In the formula, sim op and sim p Represent the fifth similarity matrix and the second similarity matrix respectively, sim opj and sim pj denote the jth element in the fifth similarity matrix and the second similarity matrix, L sim (sim oc ,sim c ) is:
[0076]
[0077] In the formula, sim oc and sim c Respectively represent the sixth similarity matrix and the third similarity matrix, sim ocj and sim cj represent the j-th element in the sixth similarity matrix and the third similarity matrix respectively.
[0078] Optionally, when determining the above-mentioned target loss function, the first loss function and the second loss function can be determined respectively; then the first weight corresponding to the first loss function and the second weight corresponding to the second loss function can be determined respectively; finally, the first loss function and the second loss function are weightedly summed according to the first weight and the second weight to obtain the target loss function.
[0079] After training the above-mentioned feature dimensionality reduction model, when using the model for face recognition processing, the following steps can be adopted: first, obtain at least one first feature vector extracted by at least one feature extraction model from the face image to be recognized; then, concatenate at least one first feature vector to obtain a second feature vector; finally, use the pre-trained feature dimensionality reduction model to reduce the dimension of the second feature vector to obtain a target feature vector.
[0080] It should be noted that the above-mentioned feature dimensionality reduction model can reduce the dimensionality of features of a single feature extraction model, and can also reduce the dimensionality of features after fusion of multiple models.
[0081] In an embodiment of the present application, at least one first feature vector extracted from a face image to be identified by at least one feature extraction model is obtained; at least one first feature vector is concatenated to obtain a second feature vector; and the second feature vector is subjected to dimensionality reduction processing using a pre-trained feature dimensionality reduction model to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted from frontal face images and snapshot images of multiple objects by at least one feature extraction model, and the dimensions of the loss function for training the feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector. In this way, when training the feature dimensionality reduction model, the loss function used includes two dimensions, namely, length loss and similarity loss, to ensure that the feature vector after dimensionality reduction does not deviate too much from the original feature, and to ensure that similar face images remain close in the feature space after dimensionality reduction, and the second feature vector is subjected to dimensionality reduction processing using a pre-trained feature dimensionality reduction model, thereby reducing the amount of data while retaining key features, thereby solving the technical problem that the feature dimension extracted by the model in the related face recognition scheme is too high, resulting in excessive consumption of computing resources for subsequent retrieval.
[0082] Example 2
[0083] According to an embodiment of the present application, a face recognition feature dimensionality reduction device for implementing the face recognition feature dimensionality reduction method in embodiment 1 is also provided, such as Figure 2 As shown, the face recognition feature dimensionality reduction device at least includes: an acquisition module 21, a splicing module 22 and a dimensionality reduction module 23, wherein:
[0084] An acquisition module 21, used for acquiring at least one first feature vector extracted by at least one feature extraction model from a face image to be recognized;
[0085] A concatenation module 22, configured to concatenate at least one first feature vector to obtain a second feature vector;
[0086] The dimension reduction module 23 is used to use a pre-trained feature dimension reduction model to perform dimension reduction processing on the second feature vector to obtain a target feature vector, wherein the training samples of the feature dimension reduction model include: multiple feature vectors extracted from the frontal face images and snapshot images of multiple objects by at least one feature extraction model, and the dimensions of the loss function of the training feature dimension reduction model include: length loss and similarity loss before and after the feature vector dimension reduction.
[0087] The functions of each module of the dimensionality reduction device for face recognition features are explained below in conjunction with a specific implementation process.
[0088] In order to solve the problem of high feature dimensionality of model extraction in face recognition solutions, this application proposes to use a pre-trained feature dimensionality reduction model to perform dimensionality reduction processing.
[0089] Optionally, the feature dimensionality reduction model is trained in the following manner: obtaining multiple frontal face images and snapshot images of multiple objects, wherein each object corresponds to an identity identifier, at least one frontal face image and at least one snapshot image; for each frontal face image, performing feature extraction on the frontal face image using at least one feature extraction model, and forming a third feature vector set with the obtained at least one third feature vector; for each snapshot image, performing feature extraction on the snapshot image using at least one feature extraction model, and forming a fourth feature vector set with the obtained at least one fourth feature vector; constructing multiple training samples, wherein each training sample includes: at least one third feature vector set corresponding to the same object, at least one fourth feature vector set, and the identity identifier of the object. After obtaining the above data, an initial model is constructed, wherein the initial model includes at least one fully connected layer, and the initial model is used to reduce the dimension of each third eigenvector of the input to a fifth eigenvector, and reduce the dimension of each fourth eigenvector of the input to a sixth eigenvector; the initial model is iteratively trained using multiple training samples, and during the training process, the model parameters are adjusted using the target loss function, and the trained model is used as a feature dimensionality reduction model, wherein the target loss function includes: a first loss function for reflecting the length difference before and after the dimensionality reduction of the feature vector and a second loss function for reflecting the similarity difference before and after the dimensionality reduction of the feature vector.
[0090] As an optional implementation, in order to facilitate unified processing, the training samples can also be preprocessed before training the model. The specific processing process can be carried out according to the following steps: for each training sample, obtain the fifth feature vector set corresponding to each third feature vector set and the sixth feature vector set corresponding to each fourth feature vector set in the training sample output by the model; splice the third feature vectors extracted by the same feature extraction model in all third feature vector sets in the training sample, form the obtained seventh feature vectors into a seventh feature vector set, normalize the seventh feature vectors, and form the obtained eighth feature vectors into an eighth feature vector set; splice the fourth feature vectors extracted by the same feature extraction model in all fourth feature vector sets in the training sample, and form the obtained The ninth eigenvectors form a ninth eigenvector set, and the ninth eigenvectors are normalized to form the obtained tenth eigenvectors into a tenth eigenvector set; the fifth eigenvectors extracted by the same feature extraction model in all fifth eigenvector sets corresponding to the training samples are spliced, and the obtained eleventh eigenvectors are formed into an eleventh eigenvector set, and the eleventh eigenvectors are normalized to form the obtained twelfth eigenvector set; the sixth eigenvectors extracted by the same feature extraction model in all sixth eigenvector sets corresponding to the training samples are spliced, and the obtained thirteenth eigenvectors are formed into a thirteenth eigenvector set, and the thirteenth eigenvectors are normalized to form the obtained fourteenth eigenvector set.
[0091] Optionally, the first loss function is determined in the following manner: in each training batch, for each training sample in the training batch, determining the average value of the lengths of each seventh eigenvector in the set of seventh eigenvectors corresponding to the training sample as the first eigenvector length; determining the average value of the lengths of each ninth eigenvector in the set of ninth eigenvectors corresponding to the training sample as the second eigenvector length; determining the average value of the lengths of each eleventh eigenvector in the set of eleventh eigenvectors corresponding to the training sample as the third eigenvector length; determining the average value of the lengths of each thirteenth eigenvector in the set of thirteenth eigenvectors corresponding to the training sample as the fourth eigenvector length; constructing the first loss function based on the difference between the length of the third eigenvector corresponding to each training sample in the training batch and the length of the first eigenvector, and the difference between the length of the fourth eigenvector and the length of the second eigenvector.
[0092] Among them, the first loss function can be determined by the following formula:
[0093] L1=w1·L len (len og ,len g )+w2·Llen (len op ,len p )
[0094] Where L1 represents the first loss function, w1 and w2 are preset weight values, w1, w2∈(0,1) and w1+w2=1, L len (len og ,len g ) is:
[0095]
[0096] In the formula, len og and len g Respectively represent the length of the third feature vector and the length of the first feature vector, N represents the number of training samples in the training batch, len ogi and len gi They represent the length of the third eigenvector and the length of the first eigenvector corresponding to the i-th training sample, respectively. len (len op ,len p ) is:
[0097]
[0098] In the formula, len op and len p Respectively represent the length of the fourth eigenvector and the length of the second eigenvector, len opi and len pi They respectively represent the length of the fourth eigenvector and the length of the second eigenvector corresponding to the i-th training sample.
[0099] Optionally, the second loss function is determined in the following manner: in each training batch, for every two training samples in the training batch, the eighth feature vectors corresponding to the same feature extraction model in the eighth feature vector sets of the two training samples are paired, the first similarity between each pair of eighth feature vectors is determined, and the average of each first similarity is determined as the first comprehensive similarity; the first comprehensive similarities corresponding to every two training samples are formed into a first similarity matrix; for every two training samples in the training batch, the tenth feature vectors corresponding to the same feature extraction model in the tenth feature vector sets of the two training samples are paired, the second similarity between each pair of tenth feature vectors is determined, and each second similarity is determined. The average of the third similarities is the second comprehensive similarity; the second comprehensive similarities corresponding to every two training samples are formed into a second similarity matrix; for every two training samples in the training batch, each eighth eigenvector in the eighth eigenvector set corresponding to each training sample in the two training samples is paired with the tenth eigenvector corresponding to the same feature extraction model in the tenth eigenvector set corresponding to the other training sample, and the third similarity between each pair of the eighth eigenvector and the tenth eigenvector is determined, and the average of each third similarity is determined as the third comprehensive similarity; the third comprehensive similarities corresponding to every two training samples are formed into a third similarity matrix; for every two training samples in the training batch, the tenth eigenvectors of the two training samples are respectively The twelfth eigenvectors corresponding to the same feature extraction model in the two feature vector sets are paired, the fourth similarity between each pair of twelfth eigenvectors is determined, and the average value of each fourth similarity is determined as the fourth comprehensive similarity; the fourth comprehensive similarities corresponding to every two training samples are combined into a fourth similarity matrix; for every two training samples in the training batch, the fourteenth eigenvectors corresponding to the same feature extraction model in the fourteenth eigenvector sets of the two training samples are paired, the fifth similarity between each pair of fourteenth eigenvectors is determined, and the average value of each fifth similarity is determined as the fifth comprehensive similarity; the fifth comprehensive similarities corresponding to every two training samples are combined into a fifth similarity matrix; for every two training samples in the training batch, For every two training samples, each twelfth eigenvector in the set of twelfth eigenvectors corresponding to each training sample in the two training samples is paired with the fourteenth eigenvector corresponding to the same feature extraction model in the set of fourteenth eigenvectors corresponding to the other training sample, the sixth similarity between each pair of twelfth eigenvectors and fourteenth eigenvectors is determined, and the average of each sixth similarity is determined as the sixth comprehensive similarity; the sixth comprehensive similarities corresponding to every two training samples are combined into a sixth similarity matrix; and a second loss function is constructed based on the differences between the fourth similarity matrix and the first similarity matrix, the differences between the fifth similarity matrix and the second similarity matrix, and the differences between the sixth similarity matrix and the third similarity matrix.
[0100] Optionally, for any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, determine the maximum similarity and the minimum similarity among the target similarities corresponding to the target comprehensive similarity, and update the target comprehensive similarity according to a preset formula; wherein the target similarity matrix includes one of the following: a first similarity matrix, a second similarity matrix, a third similarity matrix, a fourth similarity matrix, a fifth similarity matrix, and a sixth similarity matrix; the target comprehensive similarity includes one of the following: a first comprehensive similarity, a second comprehensive similarity, a third comprehensive similarity, a fourth comprehensive similarity, a fifth comprehensive similarity, and a sixth comprehensive similarity; the target similarity includes one of the following: a first similarity, a second similarity, a third similarity, a fourth similarity, a fifth similarity, and a sixth similarity; and the preset formula includes:
[0101] sim ′ =w3·avgsim+w4·(maxsim·mask+minsim·(1-mask))
[0102] In the formula, avgsim represents the comprehensive similarity of the target, sim ′ It represents the updated value of the target comprehensive similarity, w3 and w4 are the preset weight values, w3,w4∈[0,1] and w3+w4=1, maxsim represents the maximum similarity, minsim represents the minimum similarity, mask represents the mask corresponding to the target comprehensive similarity in the model calculation, and the value of mask is 0 or 1.
[0103] Optionally, for any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, and the target comprehensive similarity is less than a preset similarity threshold, the target comprehensive similarity in the target similarity matrix is replaced with the preset similarity threshold; wherein the target similarity matrix includes one of the following: a first similarity matrix, a second similarity matrix, a third similarity matrix, a fourth similarity matrix, a fifth similarity matrix, and a sixth similarity matrix, and the target comprehensive similarity includes one of the following: a first comprehensive similarity, a second comprehensive similarity, a third comprehensive similarity, a fourth comprehensive similarity, a fifth comprehensive similarity, and a sixth comprehensive similarity.
[0104] In the above formula, mask g 、mask p 、mask c They respectively represent the masks corresponding to the comprehensive similarities of each target in the model calculation, and thresh represents the preset similarity threshold.
[0105] Optionally, the second loss function is determined by the following formula:
[0106] L2=w5·L sim (sim og ,sim g )+w6·L sim (sim op ,sim p )+w7·L sim (sim oc ,sim c )
[0107] Where L2 represents the second loss function, w5, w6 and w7 are preset weight values, w5, w6, w7∈(0, 1) and w5+w6+w7=1, L sim (sim og ,sim g ) is:
[0108]
[0109] In the formula, sim og and sim g Represent the fourth similarity matrix and the first similarity matrix respectively, M represents the number of matrix elements, sim ogj and sim gj denote the jth element in the fourth similarity matrix and the first similarity matrix respectively,
[0110] L sim (sim op ,sim p ) is:
[0111]
[0112] In the formula, sim op and sim p Represent the fifth similarity matrix and the second similarity matrix respectively, sim opj and sim pj denote the jth element in the fifth similarity matrix and the second similarity matrix, L sim (sim oc ,sim c ) is:
[0113]
[0114] In the formula, sim oc and sim c Respectively represent the sixth similarity matrix and the third similarity matrix, sim ocj and simcj represent the j-th element in the sixth similarity matrix and the third similarity matrix respectively.
[0115] Optionally, when determining the above-mentioned target loss function, the first loss function and the second loss function can be determined respectively; then the first weight corresponding to the first loss function and the second weight corresponding to the second loss function can be determined respectively; finally, the first loss function and the second loss function are weightedly summed according to the first weight and the second weight to obtain the target loss function.
[0116] After the above-mentioned feature dimensionality reduction model is trained, the following steps can be taken when using the model for face recognition processing: the acquisition module first obtains at least one first feature vector extracted by at least one feature extraction model from the face image to be recognized; the splicing module then splices at least one first feature vector to obtain a second feature vector; the dimensionality reduction module finally uses the pre-trained feature dimensionality reduction model to perform dimensionality reduction processing on the second feature vector to obtain a target feature vector.
[0117] It should be noted that each module in the dimensionality reduction device for face recognition features in the embodiment of the present application corresponds one by one to each implementation step of the dimensionality reduction method for face recognition features in Example 1. Since a detailed description has been given in Example 1, some details not reflected in this embodiment can be referred to Example 1 and will not be repeated here.
[0118] Example 3
[0119] According to an embodiment of the present application, a computer program product is also provided, which includes a computer program, wherein when the computer program is executed by a processor, the dimensionality reduction method of face recognition features in Example 1 is implemented.
[0120] According to an embodiment of the present application, a non-volatile storage medium is also provided, which includes a stored computer program, wherein the device where the non-volatile storage medium is located executes the dimensionality reduction method of face recognition features in Example 1 by running the computer program.
[0121] According to an embodiment of the present application, a processor is also provided, which is used to run a computer program, wherein the dimensionality reduction method of face recognition features in Example 1 is executed when the computer program is running.
[0122] According to an embodiment of the present application, an electronic device is also provided, which includes: a memory and a processor, wherein a computer program is stored in the memory, and the processor is configured to execute the dimensionality reduction method of face recognition features in Example 1 through the computer program.
[0123] Specifically, the computer program executes the following steps when it is running: obtaining at least one first feature vector extracted by at least one feature extraction model from a face image to be identified; concatenating at least one first feature vector to obtain a second feature vector; and performing dimensionality reduction processing on the second feature vector using a pre-trained feature dimensionality reduction model to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted by at least one feature extraction model from frontal face images and captured images of multiple objects, and the dimensions of the loss function for training the feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector.
[0124] As an optional implementation, the electronic device may be in the form of a mobile terminal, a computer terminal or a similar computing device. Figure 3 FIG. 1 shows a hardware structure block diagram of an electronic device for implementing a dimensionality reduction method for face recognition features. Figure 3 As shown, the electronic device 30 may include one or more (302a, 302b, ..., 302n are used to illustrate) processors 302 (the processor 302 may include but is not limited to a processing device such as a microprocessor MCU or a programmable logic device FPGA), a memory 304 for storing data, and a transmission device 306 for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the BUS bus), a network interface, a power supply and / or a camera. It can be understood by those skilled in the art that Figure 3 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 3 More or fewer components as shown, or with Figure 3 Different configurations are shown.
[0125] It should be noted that the one or more processors 302 and / or other data processing circuits described above may generally be referred to herein as "data processing circuits". The data processing circuits may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuit may be a single independent processing module, or may be incorporated in whole or in part into any of the other components in the electronic device 30. As described in the embodiments of the present application, the data processing circuit acts as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).
[0126] The memory 304 can be used to store software programs and modules of application software, such as the program instructions / data storage device corresponding to the dimensionality reduction method of face recognition features in the embodiment of the present application. The processor 302 executes various functional applications and data processing by running the software programs and modules stored in the memory 304, that is, realizing the vulnerability detection method of the above-mentioned application. The memory 304 may include a high-speed random access memory, and may also include a non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 304 may further include a memory remotely arranged relative to the processor 302, and these remote memories may be connected to the electronic device 30 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0127] The transmission device 306 is used to receive or send data via a network. The specific example of the above network may include a wireless network provided by a communication provider of the electronic device 30. In one example, the transmission device 306 includes a network adapter (Network Interface Controller, NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 306 can be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.
[0128] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the electronic device 30 .
[0129] The serial numbers of the above embodiments are only for description and do not represent the advantages or disadvantages of the embodiments.
[0130] In the above embodiments of the present application, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, please refer to the relevant description of other embodiments.
[0131] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0132] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed over multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0133] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0134] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art or all or part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, disk or optical disk, etc. Various media that can store program codes.
[0135] The above are only preferred implementations of the present application. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present application. These improvements and modifications should also be regarded as the scope of protection of the present application.
Claims
1. A dimensionality reduction method for face recognition features, characterized in that: include: Obtaining at least one first feature vector extracted by at least one feature extraction model from the face image to be recognized; concatenating the at least one first eigenvector to obtain a second eigenvector; The second feature vector is subjected to dimensionality reduction processing using a pre-trained feature dimensionality reduction model to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted by at least one of the feature extraction models from frontal face images and snapshot images of multiple objects, and the dimensions of the loss function for training the feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector.
2. The method according to claim 1, characterized in that The feature dimension reduction model is trained in the following way: Acquire multiple frontal face images and snapshot images of multiple objects, wherein each object corresponds to an identity identifier, at least one frontal face image and at least one snapshot image; For each frontal face image, extract features from the frontal face image using at least one of the feature extraction models, and form a third feature vector set with the obtained at least one third feature vector; For each captured image, extract features from the captured image using at least one of the feature extraction models, and form a fourth feature vector set with the obtained at least one fourth feature vector; Constructing a plurality of training samples, wherein each training sample includes: at least one third feature vector set corresponding to the same object, at least one fourth feature vector set, and an identity identifier of the object; Constructing an initial model, wherein the initial model includes at least one fully connected layer, and the initial model is used to reduce the dimension of each of the third eigenvectors input into a fifth eigenvector, and reduce the dimension of each of the fourth eigenvectors input into a sixth eigenvector; The initial model is iteratively trained using the multiple training samples. During the training process, the model parameters are adjusted using the target loss function, and the model after training is used as the feature dimensionality reduction model, wherein the target loss function includes: a first loss function for reflecting the length difference before and after the dimensionality reduction of the feature vector and a second loss function for reflecting the similarity difference before and after the dimensionality reduction of the feature vector.
3. The method according to claim 2, characterized in that The method further comprises: For each training sample, obtain a fifth feature vector set corresponding to each of the third feature vector sets and a sixth feature vector set corresponding to each of the fourth feature vector sets in the training sample output by the model; splicing the third feature vectors extracted by the same feature extraction model in all the third feature vector sets in the training sample, forming the obtained seventh feature vectors into a seventh feature vector set, normalizing the seventh feature vectors, and forming the obtained eighth feature vectors into an eighth feature vector set; splicing the fourth feature vectors extracted by the same feature extraction model in all the fourth feature vector sets in the training sample, forming the obtained ninth feature vectors into a ninth feature vector set, normalizing the ninth feature vectors, and forming the obtained tenth feature vectors into a tenth feature vector set; splicing the fifth feature vectors extracted by the same feature extraction model in all fifth feature vector sets corresponding to the training samples, forming the obtained eleventh feature vectors into an eleventh feature vector set, normalizing the eleventh feature vectors, and forming the obtained twelfth feature vectors into a twelfth feature vector set; The sixth eigenvectors extracted by the same feature extraction model in all the sixth eigenvector sets corresponding to the training samples are concatenated, and the obtained thirteenth eigenvectors are combined into a thirteenth eigenvector set, and the thirteenth eigenvectors are normalized, and the obtained fourteenth eigenvectors are combined into a fourteenth eigenvector set.
4. The method according to claim 3, characterized in that The first loss function is determined by: In each training batch, for each training sample in the training batch, determining that the average value of the lengths of the seventh eigenvectors in the set of seventh eigenvectors corresponding to the training sample is the first eigenvector length; Determine that the average value of the lengths of each ninth eigenvector in the ninth eigenvector set corresponding to the training sample is the second eigenvector length; Determine that the average value of the lengths of the eleventh feature vectors in the eleventh feature vector set corresponding to the training sample is the third feature vector length; Determine that the average value of the lengths of the thirteenth eigenvectors in the thirteenth eigenvector set corresponding to the training sample is the length of the fourth eigenvector; The first loss function is constructed according to the difference between the third feature vector length and the first feature vector length, and the difference between the fourth feature vector length and the second feature vector length corresponding to each training sample in the training batch.
5. The method according to claim 4, characterized in that The first loss function is determined by the following formula: L1=w1·L len (only og ,only g )+w2·L len (only op ,only p ) Where L1 represents the first loss function, w1 and w2 are preset weight values, w1,w2∈(0,1) and len og and len g respectively represent the length of the third feature vector and the length of the first feature vector, N represents the number of training samples in the training batch, len ogi and len gi represent the length of the third feature vector and the length of the first feature vector corresponding to the i-th training sample respectively, len op and len p Respectively represent the length of the fourth feature vector and the length of the second feature vector, len opi and len pi They respectively represent the length of the fourth feature vector and the length of the second feature vector corresponding to the i-th training sample.
6. The method according to claim 3, characterized in that The second loss function is determined by: In each training batch, for every two training samples in the training batch, the eighth feature vectors corresponding to the same feature extraction model in the eighth feature vector sets of the two training samples are paired, a first similarity between each pair of the eighth feature vectors is determined, and an average value of each of the first similarities is determined as a first comprehensive similarity; the first comprehensive similarities corresponding to every two training samples are combined into a first similarity matrix; For every two training samples in the training batch, pair the tenth eigenvectors corresponding to the same feature extraction model in the tenth eigenvector sets of the two training samples, determine the second similarity between each pair of the tenth eigenvectors, and determine the average value of each second similarity as the second comprehensive similarity; form a second similarity matrix with the second comprehensive similarities corresponding to every two training samples; For every two training samples in the training batch, pair each eighth eigenvector in the set of eighth eigenvectors corresponding to each training sample in the two training samples with the tenth eigenvector corresponding to the same feature extraction model in the set of tenth eigenvectors corresponding to the other training sample, determine the third similarity between each pair of the eighth eigenvectors and the tenth eigenvector, and determine the average value of each third similarity as the third comprehensive similarity; form a third similarity matrix with the third comprehensive similarities corresponding to every two training samples; For every two training samples in the training batch, pair the twelfth feature vectors corresponding to the same feature extraction model in the twelfth feature vector sets of the two training samples, determine the fourth similarity between each pair of the twelfth feature vectors, and determine the average value of each fourth similarity as a fourth comprehensive similarity; form a fourth similarity matrix with the fourth comprehensive similarities corresponding to every two training samples; For every two training samples in the training batch, the fourteenth feature vectors corresponding to the same feature extraction model in the fourteenth feature vector sets of the two training samples are paired, a fifth similarity between each pair of the fourteenth feature vectors is determined, and an average value of each of the fifth similarities is determined as a fifth comprehensive similarity; the fifth comprehensive similarities corresponding to every two training samples are combined into a fifth similarity matrix; For every two training samples in the training batch, pair each twelfth feature vector in the twelfth feature vector set corresponding to each training sample in the two training samples with the fourteenth feature vector corresponding to the same feature extraction model in the fourteenth feature vector set corresponding to another training sample, determine the sixth similarity between each pair of the twelfth feature vector and the fourteenth feature vector, and determine the average value of each sixth similarity as the sixth comprehensive similarity; form a sixth similarity matrix with the sixth comprehensive similarities corresponding to every two training samples; The second loss function is constructed according to the difference between the fourth similarity matrix and the first similarity matrix, the difference between the fifth similarity matrix and the second similarity matrix, and the difference between the sixth similarity matrix and the third similarity matrix.
7. The method according to claim 6, characterized in that The method further comprises: For any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, determine the maximum similarity and the minimum similarity among the target similarities corresponding to the target comprehensive similarity, and update the target comprehensive similarity according to a preset formula; The target similarity matrix includes one of the following: the first similarity matrix, the second similarity matrix, the third similarity matrix, the fourth similarity matrix, the fifth similarity matrix, and the sixth similarity matrix; the target comprehensive similarity includes one of the following: the first comprehensive similarity, the second comprehensive similarity, the third comprehensive similarity, the fourth comprehensive similarity, the fifth comprehensive similarity, and the sixth comprehensive similarity; the target similarity includes one of the following: the first similarity, the second similarity, the third similarity, the fourth similarity, the fifth similarity, and the sixth similarity; and the preset formula includes: <h2 style=";text-align:left;direction:ltr">SIM<h2 style=";text-align:left;direction:ltr"> ′ <h2 style=";text-align:left;direction:ltr"> = w3 avgsim + w4 (maxsim mask + minsim (1 mask)) Where avgsim represents the comprehensive similarity of the target, sim ′ represents the updated value of the target comprehensive similarity, w3 and w4 are preset weight values, w3, w4∈[0,1] and w3+w4=1, maxsim represents the maximum similarity, minsim represents the minimum similarity, and mask represents the mask corresponding to the target comprehensive similarity in the model calculation.
8. The method according to claim 6, characterized in that The method further comprises: For any target comprehensive similarity in the target similarity matrix, if the identity identifier of the training sample corresponding to the row where the target comprehensive similarity is located is the same as the identity identifier of the training sample corresponding to the column where the target comprehensive similarity is located, and the target comprehensive similarity is less than a preset similarity threshold, the target comprehensive similarity in the target similarity matrix is replaced with the preset similarity threshold; Among them, the target similarity matrix includes one of the following: the first similarity matrix, the second similarity matrix, the third similarity matrix, the fourth similarity matrix, the fifth similarity matrix, and the sixth similarity matrix; the target comprehensive similarity includes one of the following: the first comprehensive similarity, the second comprehensive similarity, the third comprehensive similarity, the fourth comprehensive similarity, the fifth comprehensive similarity, and the sixth comprehensive similarity.
9. The method according to claim 6, characterized in that The second loss function is determined by the following formula: L2=w5·L sim (sim og ,sim g )+w6·L sim (sim op ,sim p )+w7·L sim (sim oc ,sim c ) Wherein, L2 represents the second loss function, w5, w6 and w7 are preset weight values, w5, w6, w7∈(0, 1) and w5+w6+w7=1, sim og and sim g Respectively represent the fourth similarity matrix and the first similarity matrix, M represents the number of matrix elements, sim ogj and sim gj represent the j-th element in the fourth similarity matrix and the first similarity matrix respectively, sim op and sim p Respectively represent the fifth similarity matrix and the second similarity matrix, sim opj and sim pj represent the j-th element in the fifth similarity matrix and the second similarity matrix respectively, sim oc and sim c Respectively represent the sixth similarity matrix and the third similarity matrix, sim ocj and sim cj Respectively represent the j-th element in the sixth similarity matrix and the third similarity matrix.
10. The method according to claim 2, characterized in that The objective loss function is determined in the following way: Determine the first loss function and the second loss function respectively; Determine a first weight corresponding to the first loss function and a second weight corresponding to the second loss function respectively; The first loss function and the second loss function are weightedly summed according to the first weight and the second weight to obtain the target loss function.
11. A dimensionality reduction device for face recognition features, characterized in that: include: An acquisition module, used for acquiring at least one first feature vector extracted by at least one feature extraction model from a face image to be recognized; A splicing module, used for splicing the at least one first feature vector to obtain a second feature vector; A dimensionality reduction module is used to use a pre-trained feature dimensionality reduction model to perform dimensionality reduction processing on the second feature vector to obtain a target feature vector, wherein the training samples of the feature dimensionality reduction model include: multiple feature vectors extracted by at least one of the feature extraction models from frontal face images and snapshot images of multiple objects, and the dimensions of the loss function for training the feature dimensionality reduction model include: length loss and similarity loss before and after dimensionality reduction of the feature vector.
12. A computer program product, characterized in that include: A computer program, wherein when the computer program is executed by a processor, it implements the dimensionality reduction method of face recognition features described in any one of claims 1 to 10.
13. An electronic device, characterized in that: include: A memory and a processor, wherein the memory stores a computer program, and the processor is configured to execute the dimensionality reduction method of face recognition features described in any one of claims 1 to 10 through the computer program.
Citation Information
Patent Citations
A face recognition method based on feature reuse
CN109214263A
Face recognition method and face recognition equipment
CN110765866A
Group sparse-based age estimation method and electronic equipment
CN112990145A
Face feature dimensionality reduction extraction method and system
CN114648789A
Linear target detection method and device, terminal equipment and medium
CN116416510A