Method, device and storage medium for determining feature extraction layer in face recognition model
Through branch analysis and training of the target network model, the feature extraction layer of the face recognition model is determined, which solves the problem of insufficient accuracy of the feature extraction layer and achieves more efficient feature differentiation and training under large-scale data.
Patent Information
- Application Number
- CN202111315762.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-08
- Publication Date
- 2025-10-03
- Estimated Expiration
- 2041-11-08
AI Technical Summary
In the existing technology, the accuracy of the feature extraction layer of the face recognition model is insufficient, which affects the classification effect.
Two face sample images of the same object are analyzed through the two branches of the target network model to obtain clustering result vectors, and the model is trained based on these vectors to determine the feature extraction layer of the face recognition model.
The accuracy of the feature extraction layer of the face recognition model is improved, which can better distinguish facial features, support training under large-scale data and preserve global difficult sample information.
Smart Images

Figure CN113989899B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the fields of artificial intelligence technology, specifically deep learning and computer vision technology, and in particular to a method, device, and storage medium for determining a feature extraction layer in a face recognition model. Background Art
[0002] In the scenario of classifying facial images, a facial recognition model is usually used in related technologies to classify facial images. The accuracy of facial features extracted by the feature extraction layer in the facial recognition model is very important for the classification of the facial recognition model. Summary of the Invention
[0003] The present disclosure provides a method, device, and storage medium for determining a feature extraction layer in a face recognition model.
[0004] According to one aspect of the present disclosure, a method for determining a feature extraction layer in a face recognition model is provided, the method comprising: inputting a first face sample image into a first branch in a target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch comprises a first feature extraction layer and a first clustering layer connected in sequence; inputting a second face sample image into a second branch in the target network model to obtain a second clustering result vector of the second face sample image, wherein the second branch comprises a second feature extraction layer and a second clustering layer connected in sequence, and the first face sample image and the second face sample image correspond to the same object; training the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model; and using the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model.
[0005] According to another aspect of the present disclosure, a device for determining a feature extraction layer in a face recognition model is provided, the device comprising: a first processing module for inputting a first face sample image into a first branch in a target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch comprises a first feature extraction layer and a first clustering layer connected in sequence; a second processing module for inputting a second face sample image into a second branch in the target network model to obtain a second clustering result vector of the second face sample image, wherein the second branch comprises a second feature extraction layer and a second clustering layer connected in sequence, and the first face sample image and the second face sample image correspond to the same object; a training module for training the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model; a first determination module for using the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model.
[0006] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method for determining the feature extraction layer in the face recognition model of the present disclosure.
[0007] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the method for determining the feature extraction layer in the face recognition model disclosed in the embodiment of the present disclosure.
[0008] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the method for determining a feature extraction layer in a face recognition model of the present disclosure.
[0009] One embodiment of the above application has the following advantages or beneficial effects:
[0010] Two face sample images of the same subject are analyzed using two branches in a target network model to obtain clustering result vectors for the two face sample images. The target network model is then trained based on the obtained clustering result vectors to obtain a trained target network model. The feature extraction layer in the first branch of the trained target network model is then used to determine the feature extraction layer of the face recognition model. Thus, a method for obtaining the feature extraction layer of the face recognition model is provided.
[0011] It should be understood that the contents described in this section are not intended to identify the key or important features of the embodiments of the present disclosure, nor are they intended to limit the scope of the present disclosure. Other features of the present disclosure will become readily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS
[0012] The accompanying drawings are provided to facilitate a better understanding of the present invention and do not constitute a limitation of the present disclosure.
[0013] Figure 1 is a flowchart of a method for determining a feature extraction layer in a face recognition model according to the first embodiment of the present disclosure;
[0014] Figure 2 is a flowchart of a method for determining a feature extraction layer in a face recognition model according to the second embodiment of the present disclosure;
[0015] Figure 3 is a schematic diagram of a process for training a target network model according to the third embodiment of the present disclosure;
[0016] Figure 4 is a schematic structural diagram of a device for determining a feature extraction layer in a face recognition model according to a fourth embodiment of the present disclosure;
[0017] Figure 5 is a structural diagram of a device for determining a feature extraction layer in a face recognition model according to a fifth embodiment of the present disclosure;
[0018] Figure 6 It is a block diagram of an electronic device used to implement the method for determining the feature extraction layer in the face recognition model of the embodiment of the present disclosure. DETAILED DESCRIPTION
[0019] The following description of exemplary embodiments of the present disclosure is made in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding. These details should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.
[0020] The following describes a method, device, and storage medium for determining a feature extraction layer in a face recognition model according to an embodiment of the present disclosure with reference to the accompanying drawings.
[0021] Figure 1 It is a flowchart of a method for determining a feature extraction layer in a face recognition model according to the first embodiment of the present disclosure.
[0022] like Figure 1 As shown, the method for determining the feature extraction layer in the face recognition model may include:
[0023] Step 101: Input a first face sample image into a first branch in a target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch includes a first feature extraction layer and a first clustering layer connected in sequence.
[0024] Among them, it should be noted that the executor of the method for determining the feature extraction layer in the face recognition model of this embodiment is the device for determining the feature extraction layer in the face recognition model. The device for determining the feature extraction layer in the face recognition model can be implemented by software and / or hardware. The device for determining the feature extraction layer in the face recognition model can be configured in an electronic device, which may include but is not limited to a terminal device, a server, etc. This embodiment does not specifically limit the electronic device.
[0025] The first face sample image in this embodiment may be an unlabeled face sample image or a face sample image with labeled information.
[0026] Specifically, after the first face sample image is placed in the first branch of the target network model, the first feature extraction layer in the first branch performs feature extraction on the first face sample image to obtain a first face feature vector of the first face sample image, and inputs the first face feature vector into the first clustering layer to perform clustering processing on the first face feature vector through the first clustering layer to obtain a first clustering result vector of the first face sample image.
[0027] Step 102: Input the second face sample image into the second branch in the target network model to obtain a second clustering result vector of the second face sample image, wherein the second branch includes a second feature extraction layer and a second clustering layer connected in sequence, and the first face sample image and the second face sample image correspond to the same object.
[0028] The second face sample image in this embodiment may be an unlabeled face sample image, thereby eliminating the need to label the image and reducing the cost of training the model.
[0029] Specifically, after the second face sample image is placed in the second branch of the target network model, the second feature extraction layer in the second branch performs feature extraction on the second face sample image to obtain a second face feature vector of the second face sample image, and inputs the second face feature vector into the second clustering layer to perform clustering processing on the second face feature vector through the second clustering layer to obtain a second clustering result vector of the second face sample image.
[0030] In some embodiments, the network structures of the first and second feature extraction layers can be the same. For example, the network structures of the first and second feature extraction layers can be the network structures of convolutional neural networks (CNNs). For another example, the network structures of the first and second feature extraction layers can adopt the network structure of the encoding layer in a translation transformer model.
[0031] The network structures of the first clustering layer and the second clustering layer in this embodiment may also be the same. For example, the first clustering layer and the second clustering layer may adopt a multilayer perceptron (MLP).
[0032] Step 103: Train the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model.
[0033] In some embodiments, in order to enable the feature extraction layer in the trained target network model to extract more distinguishing facial features, the exemplary implementation method of the above-mentioned training target network model is: determining the target loss function value of the target network model based on the first clustering result vector and the second clustering result vector; updating the target network model according to the target loss function value until the target function value converges to obtain the trained target network model.
[0034] In some embodiments, in order to enable model training to be updated faster, the first feature extraction layer and the second feature extraction layer have the same network structure, and the first clustering layer and the second clustering layer have the same network structure. An exemplary implementation of updating the target network model according to the target loss function value is: updating the parameters of the second feature extraction layer and the parameters of the second clustering layer according to the target loss function value; updating the parameters of the second feature extraction layer according to the updated parameters of the second feature extraction layer, and updating the parameters of the first clustering layer according to the updated parameters of the second clustering layer.
[0035] In some embodiments, the parameters of the first clustering layer may be updated based on the parameters of the second clustering layer in a moving average manner. In other words, the parameters of the first clustering layer are obtained by processing the parameters of the second clustering layer in a moving average manner.
[0036] In some embodiments, the parameters of the first feature extraction layer may be updated based on the parameters of the second feature extraction layer in a moving average manner. In other words, the parameters of the first feature extraction layer are obtained by processing the parameters of the second feature extraction layer in a moving average manner.
[0037] Step 104: Use the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model.
[0038] In some embodiments, after using the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model, in order to further improve the accuracy of the subsequent face recognition model, the face recognition model can also be trained using sample face images with labeled information to obtain a trained face recognition model. Thus, based on the trained face model, face recognition is performed on the face image to be recognized to accurately determine the face recognition result of the face image to be recognized, such as the classification result of the face image to be recognized.
[0039] The method for determining the feature extraction layer in a face recognition model of the presently disclosed embodiment analyzes two sample face images of the same subject using two branches in a target network model to obtain a clustering result vector for the two sample face images, trains the target network model based on the obtained clustering result vector to obtain a trained target network model, and determines the feature extraction layer of the face recognition model from the feature extraction layer in the first branch of the trained target network model. Thus, a method for obtaining the feature extraction layer of a face recognition model is provided.
[0040] Based on the above embodiments, in order to enable the feature extraction layer in the face recognition model to learn more discriminative features, in the process of training the target network model, the target network model can be trained in a combined manner of queues and clustering, thereby avoiding the linear growth of computing resources as the training data increases, supporting face recognition training under large-scale data, and at the same time, through the global online clustering method, preserving the information of global difficult samples to a certain extent. Figure 2 The method of this embodiment is further described.
[0041] It should be noted that the first feature extraction layer and the second feature extraction layer in the target network model of this embodiment have the same network structure, and the first clustering layer and the second clustering layer have the same network structure. In addition, the target network model may also include a first loss function layer, a second loss function layer and a feature vector queue layer, wherein the feature vector queue layer is used to cache the face feature vector output by the first feature extraction layer. Figure 2 As shown, the method may include:
[0042] Step 201: Input a first face sample image into a first branch in a target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch includes a first feature extraction layer and a first clustering layer connected in sequence.
[0043] Step 202: Input the second face sample image into the second branch in the target network model to obtain a second clustering result vector of the second face sample image, wherein the second branch includes a second feature extraction layer and a second clustering layer connected in sequence, and the first face sample image and the second face sample image correspond to the same object.
[0044] It should be noted that the specific implementation of step 201 and step 202 can be found in the relevant description of the above embodiment and will not be repeated here.
[0045] Step 203: Obtain the first facial feature vector output by the first feature extraction layer, and obtain the second facial feature vector output by the second feature extraction layer.
[0046] In step 204, the positive sample pairs consisting of the first facial feature vector and the second facial feature vector, and the negative sample pairs consisting of the second facial feature vector and each historical facial feature vector in the feature vector queue layer are input into the first loss function layer to obtain a first cross entropy loss value.
[0047] It should be noted that the facial feature vectors stored in the feature vector queue layer are dynamically updated. For example, during model training, if the facial feature vector of the first face sample image is obtained through the feature extraction layer in the first branch, the facial feature vector of the first face sample image can be inserted into the head of the feature vector queue layer, and the facial feature vector at the tail of the feature vector queue layer can be deleted.
[0048] In some embodiments, the target network model may further include: a label queue layer. The label queue layer is used to cache the actual labels corresponding to the face sample images input into the first branch. In order to accurately determine the first cross-entropy loss value, when the target network model further includes a label queue layer, the first sample face image may be a face image annotated with a label. An exemplary implementation of step 204 is as follows: according to the first loss function layer, determine the first predicted label of the positive sample pair and the second predicted label of each negative sample pair; obtain the first actual label corresponding to the first face feature vector in the label queue layer; obtain the second actual label corresponding to the historical face feature vector in each negative sample pair in the label queue layer; determine the first cross-entropy loss value based on the first actual label and the first predicted label, and each label vector and the corresponding second actual label.
[0049] Specifically, the first actual label and the first predicted label, each label vector and the corresponding second actual label can be input into a cross entropy loss calculation model to obtain a first cross entropy loss value from the cross entropy loss calculation model.
[0050] It is important to understand that the label vectors stored in the label queue layer are dynamically updated. For example, during model training, when a label vector corresponding to the label of the first face sample image is obtained, the label vector corresponding to the first face sample image can be inserted into the head of the label queue layer, and the label vector at the tail of the label queue layer can be deleted.
[0051] Step 205: Input the first clustering result vector and the second clustering result vector into a second loss function layer to obtain a second cross entropy loss value.
[0052] In some embodiments, in order to accurately determine the second cross-entropy loss value, the above-mentioned inputting of the first clustering result vector and the second clustering result vector into the second loss function layer to obtain the second cross-entropy loss value is an exemplary implementation as follows: using the second loss function in the second loss function layer, the cross-entropy loss between the first clustering result vector and the second clustering result vector is calculated, and the cross-entropy loss obtained by calculation is used as the second cross-entropy loss value.
[0053] Step 206 : Perform a weighted summation on the first cross entropy loss value and the second cross entropy loss value to obtain a target loss function value of the target network model.
[0054] Specifically, the product of the first cross entropy loss value and the corresponding first weight coefficient and the product of the second cross entropy loss value and the corresponding second weight coefficient can be added, and the obtained value can be used as the target loss function value of the target network model.
[0055] Among them, the calculation formula of the target loss function value l of the target network model is:
[0056] l=w1*l1+w2*l2
[0057] In the above calculation formula, w1 represents the first weight coefficient, w2 represents the second weight coefficient, l1 represents the first cross entropy loss value, and l2 represents the second cross entropy loss value.
[0058] Step 207: Use the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model.
[0059] In this embodiment, in the process of training the target network model, the target network model is trained in a manner that can be combined with queues and clustering, which can avoid the linear growth of computing resources with the increase of training data, support face recognition training under large-scale data, and at the same time, through the global online clustering method, preserve the information of global difficult samples to a certain extent, so that the feature extraction layer in the face recognition model determined by the first feature extraction layer in the target network model can learn more discriminative features.
[0060] Based on any of the above embodiments, in order to make the clustering more uniform and avoid concentrated clustering to certain categories, before inputting the first clustering result vector and the second clustering result vector into the second loss function layer to obtain the second cross entropy loss value, the clustering result center vector of the first branch can also be obtained; the first clustering result vector is subtracted from the clustering result center vector to obtain an updated first clustering result vector.
[0061] In some embodiments, in order to accurately determine the clustering result center vector corresponding to the first branch, the above-mentioned target network model may also include: a clustering result vector sequence layer for storing the clustering result vector output by the first clustering layer. An exemplary implementation method for obtaining the clustering result center vector of the first branch is: averaging all historical clustering result vectors in the clustering result vector sequence layer to obtain the clustering result average vector; and determining the clustering result center vector based on the clustering result average vector.
[0062] For example, when training the model, face sample images can be input into the model in batches. Assuming that they are clustered into N categories, the clustering result center vector C is N-dimensional. For the first branch, if B face sample images are passed through the first feature extraction layer and the first clustering layer, B N-dimensional clustering result vectors can be obtained. The average of these B N-dimensional clustering result vectors is the clustering result average vector C. B , where the average vector C is obtained based on the clustering results B , we can determine the clustering result center vector is C = m*C + (1-m)*C B . Where m is a pre-set weight coefficient.
[0063] In some embodiments, in order to "sharpen" the differences between cluster centers and make cluster boundaries more obvious, before the first clustering result vector and the second clustering result vector are input into the second loss function layer to obtain the second cross entropy loss value, the first clustering result vector may be sharpened according to the first sharpening factor corresponding to the first branch; and the second clustering result vector may be sharpened according to the second sharpening factor corresponding to the second branch.
[0064] As an exemplary implementation, the first clustering result vector may be divided by a first sharpening factor, and the second clustering result vector may be divided by a second sharpening factor.
[0065] The first sharpening factor and the second sharpening factor are pre-set values in the device, and the values of the first sharpening factor and the second sharpening factor are both between 0 and 1.
[0066] In other embodiments, before inputting the first clustering result vector and the second clustering result vector into the second loss function layer to obtain the second cross entropy loss value, the following steps may be performed: obtaining the clustering result center vector of the first branch; subtracting the clustering result center vector from the first clustering result vector to obtain an updated first clustering result vector, and sharpening the updated first clustering result vector according to the first sharpening factor corresponding to the first branch, and sharpening the second clustering result vector according to the second sharpening factor corresponding to the second branch. In this way, the second loss function layer in the target network model can accurately determine the corresponding cross entropy loss value based on the processed first clustering result vector and the second clustering result vector.
[0067] In order to make those skilled in the art understand the present application clearly, Figure 3 The process of training the target network model is described exemplarily. It should be noted that in this embodiment, the first feature extraction layer in the first branch k is used as CNN. k , the first clustering layer is MLP k , the second feature extraction layer in the second branch q is CNN q , the second clustering layer is MLP q For example, Figure 3 As shown, this may include:
[0068] First, the first face sample image is input into the first branch of the target network model to obtain a first clustering result vector of the first face sample image, and the second face sample image is input into the second branch of the target network model to obtain a second clustering result vector of the second face sample image.
[0069] In this embodiment, the first face sample image and the second face sample image may correspond to the same object, for example, the object is a user object, that is, the first face sample image and the second face sample image correspond to the same person.
[0070] Specifically, after the first face sample image is input into the first branch of the target network model, the CNN in the first branch k Get the first face feature vector F of the first face sample image k , and the first face feature vector F k Input to MLP k , to obtain the first clustering result vector of the first face sample image.
[0071] Specifically, after the second face sample image is input into the second branch of the target network model, the CNN in the second branch q Get the second face feature vector F of the second face sample image q, and the second face feature vector F q Input to MLP q , to obtain the second clustering result vector of the second face sample image.
[0072] It should be noted that the CNN in this embodiment k and CNN q The network structure of the above CNN is the same. k and CNN q The parameters are the same. During the training process, CNN performs back propagation. k Stop gradient backpropagation. Among them, CNN k The parameters of CNN are q Moving average.
[0073] It should be noted that the MLP in this embodiment k and MLP q The network structure is the same. During the initialization process, the above MLP k and MLP q The parameters are the same. During the training process, MLP performs back propagation, MLP k Stop gradient backpropagation. Among them, MLP k The parameters of MLP are q Moving average.
[0074] Among them, it should be noted that CNN is cached by queue k The first facial feature vector F output k And the first face feature vector F k Corresponding tags, a feature queue, and a tag queue.
[0075] It should be noted that the lengths of the feature queue and the label queue in this embodiment are the same and fixed. During training, the feature queue can be updated based on the facial feature vector of the face sample image input to the first branch k, and the label queue can be updated based on the label corresponding to the facial feature vector.
[0076] For example, for Figure 3 In terms of Figure 3 Only the feature queue A is shown in FIG. Assume that the length of the feature queue A is 3, where w + 、w1 - and w2 - Represents the face feature vector cached in feature queue A. It should be noted that since the length of feature queue A is 3, when a new face feature vector is inserted into feature queue A, the face feature vector at the end of feature queue A can be deleted.
[0077] Specifically, the first face feature vector F k Cache it in feature queue A, then combine the face feature vector in feature object A with the second face feature vector F q Input into softmax to obtain the probability distribution sequence corresponding to the feature sequence A, and perform cross entropy on the probability distribution sequence to obtain the first cross entropy loss value l1.
[0078] Finally, the final loss function value L is obtained by weighted summing the first cross entropy loss value l1 and the second cross entropy loss value l2.
[0079] In order to implement the above embodiment, the embodiment of the present disclosure also provides a device for determining a feature extraction layer in a face recognition model.
[0080] Figure 4 4 is a schematic structural diagram of a device for determining a feature extraction layer in a face recognition model according to the fourth embodiment of the present disclosure.
[0081] like Figure 4 As shown, the device 400 for determining the feature extraction layer in the face recognition model may include a first processing module 401, a second processing module 402, a training module 403 and a first determining module 404, wherein:
[0082] The first processing module 401 is used to input the first face sample image into the first branch of the target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch includes a first feature extraction layer and a first clustering layer connected in sequence.
[0083] The second processing module 402 is used to input the second face sample image into the second branch in the target network model to obtain a second clustering result vector of the second face sample image, wherein the second branch includes a second feature extraction layer and a second clustering layer connected in sequence, and the first face sample image and the second face sample image correspond to the same object.
[0084] The training module 403 is used to train the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model.
[0085] The first determining module 404 is configured to use the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model.
[0086] It should be noted that the aforementioned explanation of the embodiment of the method for determining the feature extraction layer in the face recognition model is also applicable to this embodiment, and will not be repeated in this embodiment.
[0087] The apparatus for determining a feature extraction layer in a face recognition model of the disclosed embodiment analyzes two face sample images of the same subject using two branches in a target network model to obtain a clustering result vector for the two face sample images, trains the target network model based on the obtained clustering result vector to obtain a trained target network model, and determines the feature extraction layer of the face recognition model from the feature extraction layer in the first branch of the trained target network model. Thus, a method for obtaining a feature extraction layer of a face recognition model is provided.
[0088] In one embodiment of the present disclosure, Figure 5 As shown, the apparatus 500 for determining a feature extraction layer in a face recognition model may include: a first processing module 501, a second processing module 502, a training module 503, a first determination module 504, a first acquisition module 505, a second determination module 506, a second acquisition module 507, an updating module 508, a first sharpening processing module 509, and a second sharpening processing module 510. The training module 503 may include a determination unit 5031 and an updating unit 5032.
[0089] It should be noted that for detailed descriptions of the first processing module 501, the second processing module 502 and the first processing module 504, please refer to Figure 4 The description of the first processing module 401, the second processing module 402 and the first processing module 404 in the illustrated embodiment will not be repeated here.
[0090] In one embodiment of the present disclosure, the training module 503 may include:
[0091] The determining unit 5031 is used to determine the target loss function value of the target network model according to the first clustering result vector and the second clustering result vector.
[0092] The updating unit 5032 is used to update the target network model according to the target loss function value until the target function value converges to obtain a trained target network model.
[0093] In one embodiment of the present disclosure, the first feature extraction layer and the second feature extraction layer have the same network structure, the first clustering layer and the second clustering layer have the same network structure, and the updating unit 5032 is specifically used to: update the parameters of the second feature extraction layer and the parameters of the second clustering layer according to the target loss function value; update the parameters of the second feature extraction layer according to the updated parameters of the second feature extraction layer, and update the parameters of the first clustering layer according to the updated parameters of the second clustering layer.
[0094] In one embodiment of the present disclosure, the target network model further includes a first loss function layer, a second loss function layer, and a feature vector queue layer, wherein the feature vector queue layer is used to cache the facial feature vector output by the first feature extraction layer. The device may further include:
[0095] The first acquisition module 505 is configured to acquire the first facial feature vector output by the first feature extraction layer, and acquire the second facial feature vector output by the second feature extraction layer.
[0096] The second determination module 506 is used to input the positive sample pairs consisting of the first facial feature vector and the second facial feature vector, and the negative sample pairs consisting of the second facial feature vector and each historical facial feature vector in the feature vector queue layer, into the first loss function layer to obtain a first cross entropy loss value.
[0097] In one embodiment of the present disclosure, the above-mentioned determination unit 5032 is specifically used to: input the first clustering result vector and the second clustering result vector into the second loss function layer to obtain a second cross entropy loss value; and perform weighted summation on the first cross entropy loss value and the second cross entropy loss value to obtain the target loss function value of the target network model.
[0098] In one embodiment of the present disclosure, the above-mentioned target network model also includes: a label queue layer, a second determination module 506, which is specifically used to: determine the first predicted label of the positive sample pair and the second predicted label of each negative sample pair according to the first loss function layer; obtain the first actual label corresponding to the first facial feature vector in the label queue layer; obtain the second actual label corresponding to the historical facial feature vector in each negative sample pair in the label queue layer; determine the first cross entropy loss value based on the first actual label and the first predicted label, each label vector and the corresponding second actual label.
[0099] In one embodiment of the present disclosure, the apparatus may further include:
[0100] The second acquisition module 507 is used to obtain the center vector of the clustering result of the first branch.
[0101] The updating module 508 is configured to subtract the clustering result center vector from the first clustering result vector to obtain an updated first clustering result vector.
[0102] In one embodiment of the present disclosure, the above-mentioned target network model also includes: a clustering result vector sequence layer for storing the clustering result vector output by the first clustering layer, and a second acquisition module 507, which is specifically used to: average all historical clustering result vectors in the clustering result vector sequence layer to obtain a clustering result average vector; and determine the clustering result center vector based on the clustering result average vector.
[0103] In one embodiment of the present disclosure, the apparatus further includes:
[0104] The first sharpening processing module 509 is configured to perform sharpening processing on the first clustering result vector according to a first sharpening factor corresponding to the first branch.
[0105] The second sharpening processing module 510 is configured to perform sharpening processing on the second clustering result vector according to a second sharpening factor corresponding to the second branch.
[0106] It should be noted that the above explanation of the embodiment of the method for determining the feature extraction layer in the face recognition model is also applicable to the device for determining the feature extraction layer in the face recognition model in this embodiment, and will not be repeated here.
[0107] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium, and a computer program product.
[0108] Figure 6 A schematic block diagram of an example electronic device 600 that can be used to implement embodiments of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital assistants, cellular phones, smartphones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are provided as examples only and are not intended to limit the implementation of the present disclosure described and / or claimed herein.
[0109] like Figure 6 As shown, the electronic device 600 may include a computing unit 601, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 602 or a computer program loaded from a storage unit 608 into a random access memory (RAM) 603. Various programs and data required for the operation of the device 600 may also be stored in the RAM 603. The computing unit 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. An input / output (I / O) interface 605 is also connected to the bus 604.
[0110] Various components in device 600 are connected to I / O interface 605, including an input unit 606, such as a keyboard, mouse, etc.; an output unit 607, such as various types of displays, speakers, etc.; a storage unit 608, such as a magnetic disk, optical disk, etc.; and a communication unit 609, such as a network card, modem, wireless communication transceiver, etc. The communication unit 609 allows device 600 to exchange information / data with other devices via a computer network such as the Internet and / or various telecommunication networks.
[0111] The computing unit 601 can be various general-purpose and / or specialized processing components with processing and computing capabilities. Some examples of the computing unit 601 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units that run machine learning model algorithms, a digital signal processor (DSP), and any appropriate processor, controller, microcontroller, etc. The computing unit 601 performs the various methods and processes described above, such as the method for determining the feature extraction layer in the face recognition model. For example, in some embodiments, the method for determining the feature extraction layer in the face recognition model can be implemented as a computer software program, which is tangibly contained in a machine-readable medium, such as the storage unit 608. In some embodiments, part or all of the computer program can be loaded and / or installed on the device 600 via the ROM 602 and / or the communication unit 609. When the computer program is loaded into the RAM 603 and executed by the computing unit 601, one or more steps of the method for determining the feature extraction layer in the face recognition model described above can be performed. Alternatively, in other embodiments, the computing unit 601 may be configured to execute the method for determining the feature extraction layer in the face recognition model in any other appropriate manner (for example, by means of firmware).
[0112] Various embodiments of the systems and techniques described above can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), system-on-chip systems (SOCs), complex programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various embodiments can include being implemented in one or more computer programs that are executable and / or interpreted on a programmable system that includes at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.
[0113] The program code for implementing the method of the present disclosure can be written in any combination of one or more programming languages. These program codes can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device so that when the program code is executed by the processor or controller, the functions / operations specified in the flow chart and / or block diagram are implemented. The program code can be executed entirely on the machine, partially on the machine, as a stand-alone software package, partially on the machine and partially on a remote machine, or entirely on a remote machine or server.
[0114] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0115] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).
[0116] The systems and techniques described herein can be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system can be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), the Internet, and a blockchain network.
[0117] A computer system may include a client and a server. The client and server are generally remote from each other and typically interact via a communication network. The client-server relationship is established by computer programs running on the respective computers and establishing a client-server relationship with each other. The server may be a cloud server, also known as a cloud computing server or cloud host, a host product within the cloud computing service ecosystem that addresses the management difficulties and poor scalability of traditional physical hosts and VPS services ("Virtual Private Servers" or simply "VPS"). The server may be a cloud server, a server in a distributed system, or a server integrated with blockchain.
[0118] It's important to note that artificial intelligence (AI) is the study of how computers can simulate certain human thought processes and intelligent behaviors (such as learning, reasoning, thinking, and planning). This encompasses both hardware and software technologies. AI hardware technologies generally include sensors, specialized AI chips, cloud computing, distributed storage, and big data processing. AI software technologies primarily encompass computer vision, speech recognition, natural language processing, machine learning / deep learning, big data processing, and knowledge graphs.
[0119] It should be understood that the various forms of the processes shown above can be used to reorder, add, or delete steps. For example, the steps described in this disclosure can be performed in parallel, sequentially, or in a different order, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved. This is not a limitation herein.
[0120] The above specific embodiments do not constitute a limitation on the scope of protection of this disclosure. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions may be made based on design requirements and other factors. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of this disclosure shall be included within the scope of protection of this disclosure.
Claims
1. A method for determining a feature extraction layer in a face recognition model, comprising: Inputting a first face sample image into a first branch of a target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch includes a first feature extraction layer and a first clustering layer connected in sequence; Inputting a second face sample image into a second branch of the target network model to obtain a second clustering result vector of the second face sample image, wherein the second branch includes a second feature extraction layer and a second clustering layer connected in sequence, and the first face sample image and the second face sample image correspond to the same object; Training the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model; Using the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model; The target network model further includes a first loss function layer, a second loss function layer, and a feature vector queue layer, wherein the feature vector queue layer is used to cache the face feature vector output by the first feature extraction layer. The method further includes: Obtaining a first facial feature vector output by the first feature extraction layer, and obtaining a second facial feature vector output by the second feature extraction layer; Inputting a positive sample pair consisting of the first facial feature vector and the second facial feature vector, and a negative sample pair consisting of the second facial feature vector and each historical facial feature vector in the feature vector queue layer, into the first loss function layer to obtain a first cross entropy loss value; The training of the target network model according to the first clustering result vector and the second clustering result vector includes: Inputting the first clustering result vector and the second clustering result vector into the second loss function layer to obtain a second cross entropy loss value; A weighted sum is performed on the first cross entropy loss value and the second cross entropy loss value to obtain a target loss function value of the target network model.
2. The method according to claim 1, wherein The training of the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model includes: Determining a target loss function value of the target network model according to the first clustering result vector and the second clustering result vector; According to the target loss function value, the target network model is updated until the target loss function value converges to obtain a trained target network model.
3. The method according to claim 2, wherein: The first feature extraction layer and the second feature extraction layer have the same network structure, the first clustering layer and the second clustering layer have the same network structure, and updating the target network model according to the target loss function value includes: Update the parameters of the second feature extraction layer and the parameters of the second clustering layer according to the target loss function value; The parameters of the second feature extraction layer are updated according to the updated parameters of the second feature extraction layer, and the parameters of the first clustering layer are updated according to the updated parameters of the second clustering layer.
4. The method according to claim 2, wherein: The target network model further includes: a label queue layer, wherein the positive sample pairs consisting of the first facial feature vector and the second facial feature vector, and the negative sample pairs consisting of the second facial feature vector and each historical facial feature vector in the feature vector queue layer, are input into the first loss function layer to obtain a first cross entropy loss value, including: Determining, according to the first loss function layer, a first predicted label for the positive sample pair and a second predicted label for each of the negative sample pairs; Obtaining a first actual label corresponding to the first facial feature vector in the label queue layer; Obtaining a second actual label in the label queue layer corresponding to the historical face feature vector in each of the negative sample pairs; A first cross entropy loss value is determined according to the first actual label, the first predicted label, each label vector, and the corresponding second actual label.
5. The method according to claim 2, wherein: Before inputting the first clustering result vector and the second clustering result vector into the second loss function layer to obtain a second cross entropy loss value, the method includes: Obtaining a clustering result center vector of the first branch; The clustering result center vector is subtracted from the first clustering result vector to obtain an updated first clustering result vector.
6. The method according to claim 5, wherein: The target network model further includes: a classification feature vector sequence layer for storing the clustering result vector output by the first clustering layer, and obtaining the clustering result center vector of the first branch includes: Averaging all historical clustering result vectors in the clustering result vector sequence layer to obtain a clustering result average vector; The clustering result center vector is determined according to the clustering result average vector.
7. The method according to any one of claims 2 to 6, wherein: Before inputting the first clustering result vector and the second clustering result vector into the second loss function layer to obtain a second cross entropy loss value, the method further includes: performing sharpening processing on the first clustering result vector according to a first sharpening factor corresponding to the first branch; The second clustering result vector is sharpened according to a second sharpening factor corresponding to the second branch.
8. A device for determining a feature extraction layer in a face recognition model, comprising: a first processing module, configured to input a first face sample image into a first branch of a target network model to obtain a first clustering result vector of the first face sample image, wherein the first branch includes a first feature extraction layer and a first clustering layer connected in sequence; a second processing module, configured to input a second facial sample image into a second branch of the target network model to obtain a second clustering result vector of the second facial sample image, wherein the second branch includes a second feature extraction layer and a second clustering layer connected in sequence, and the first facial sample image and the second facial sample image correspond to the same object; A training module, configured to train the target network model according to the first clustering result vector and the second clustering result vector to obtain a trained target network model; A first determining module is configured to use the first feature extraction layer in the trained target network model as the feature extraction layer in the face recognition model; The target network model further includes a first loss function layer, a second loss function layer, and a feature vector queue layer, wherein the feature vector queue layer is used to cache the face feature vector output by the first feature extraction layer. The device further includes: A first acquisition module, configured to acquire a first facial feature vector output by the first feature extraction layer, and acquire a second facial feature vector output by the second feature extraction layer; a second determination module, configured to input a positive sample pair consisting of the first facial feature vector and the second facial feature vector, and a negative sample pair consisting of the second facial feature vector and each historical facial feature vector in the feature vector queue layer, into the first loss function layer to obtain a first cross entropy loss value; The training module is specifically used for: Inputting the first clustering result vector and the second clustering result vector into the second loss function layer to obtain a second cross entropy loss value; A weighted sum is performed on the first cross entropy loss value and the second cross entropy loss value to obtain a target loss function value of the target network model.
9. The device according to claim 8, wherein The training module includes: a determining unit, configured to determine a target loss function value of the target network model based on the first clustering result vector and the second clustering result vector; An updating unit is used to update the target network model according to the target loss function value until the target loss function value converges to obtain a trained target network model.
10. The device according to claim 9, wherein The first feature extraction layer and the second feature extraction layer have the same network structure, the first clustering layer and the second clustering layer have the same network structure, and the updating unit is specifically configured to: Update the parameters of the second feature extraction layer and the parameters of the second clustering layer according to the target loss function value; The parameters of the second feature extraction layer are updated according to the updated parameters of the second feature extraction layer, and the parameters of the first clustering layer are updated according to the updated parameters of the second clustering layer.
11. The device according to claim 9, wherein The target network model further includes: a label queue layer, and a second determination module, specifically configured to: Determining, according to the first loss function layer, a first predicted label for the positive sample pair and a second predicted label for each of the negative sample pairs; Obtaining a first actual label corresponding to the first facial feature vector in the label queue layer; Obtaining a second actual label in the label queue layer corresponding to the historical face feature vector in each of the negative sample pairs; A first cross entropy loss value is determined according to the first actual label, the first predicted label, each label vector, and the corresponding second actual label.
12. The device according to claim 9, wherein The device further comprises: A second acquisition module, configured to acquire a center vector of the clustering result of the first branch; An updating module is configured to subtract the clustering result center vector from the first clustering result vector to obtain an updated first clustering result vector.
13. The device according to claim 12, wherein The target network model further includes: a clustering result vector sequence layer for storing the clustering result vector output by the first clustering layer; and the second acquisition module is specifically configured to: Averaging all historical clustering result vectors in the clustering result vector sequence layer to obtain a clustering result average vector; The clustering result center vector is determined according to the clustering result average vector.
14. The device according to any one of claims 9 to 13, wherein: The device further comprises: a first sharpening processing module, configured to perform sharpening processing on the first clustering result vector according to a first sharpening factor corresponding to the first branch; The second sharpening processing module is used to perform sharpening processing on the second clustering result vector according to a second sharpening factor corresponding to the second branch.
15. An electronic device comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 7.
16. A non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are configured to cause the computer to execute the method according to any one of claims 1 to 7.
17. A computer program product comprising a computer program, which, when executed by a processor, implements the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Model training and image processing method and device, electronic equipment and storage medium
CN112733808A
Image recognition method, apparatus, electronic device, storage medium and program product
EP3869403A2