A method, device, equipment and storage medium for constructing a face recognition model

By introducing the sorting loss function in the training process of the face recognition model and combining the face loss function for end-to-end training, the problem of low hit rate of the face recognition model in the prior art in 1:N face recognition is solved, and the recognition accuracy is improved.

CN114792438BActive Publication Date: 2025-04-04SHENZHEN JIESHUN SCI & TECH IND
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210324975.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-30
Publication Date
2025-04-04
Estimated Expiration
2042-03-30

AI Technical Summary

Technical Problem

The existing face recognition model fails to effectively improve the first hit rate in 1:N face recognition, resulting in a low recognition accuracy.

Method used

By introducing a sorting loss function in the training process of the face recognition model, and combining the face loss function for end-to-end training, the sorting results of the same face similarity score are improved, so that it can be as advanced as possible.

Benefits of technology

The first hit rate of face recognition results is improved and the recognition accuracy of face recognition models is enhanced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114792438B_ABST
    Figure CN114792438B_ABST
Patent Text Reader

Abstract

The present application discloses a method, device, equipment and storage medium for constructing a face recognition model. The method includes: obtaining a face image, and annotating the face image according to the collector to obtain a face data set; building a random initialization model based on a neural network structure, and using the face loss function as the loss function of the first stage training of the model, and then using the face data set to perform the first stage training on the random initialization model to obtain the first stage trained model; using the face loss function and the sorting loss function as the loss function of the second stage training of the model, and then using the face data set to perform the second stage training on the first stage trained model to obtain a face recognition model; wherein the sorting loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets. It can improve the accuracy of face recognition of the face recognition model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of face recognition, and in particular to a face recognition model construction method, device, equipment and storage medium. Background Art

[0002] At present, with the development of deep learning technology, face recognition has been widely used in practice. At present, the construction of general face recognition models is based on deep network training, and the loss functions are mainly ArcFace loss, AM-Softmax, and Tplett Loss. In the actual comparison process, the network is mainly used to extract the features of the face image to calculate the cosine similarity to determine which person the face belongs to or whether it is the same person. The above loss functions are basically realized by increasing the interval between the cosine similarities between the same person and different people. In 1:N face recognition, the face to be recognized is generally compared with the faces in the face database one by one, and then the one with the greatest similarity is found. By setting a threshold, the one with the greatest similarity exceeding the set threshold is considered to be the same person, but the first hit rate is not considered. There is a selection of the most similar face in the face database for comparison. If the face with the highest similarity is wrong, then the final recognition result will definitely be wrong. Therefore, how to improve the first hit rate and improve the accuracy of face recognition is an urgent problem to be solved. Summary of the invention

[0003] In view of this, the purpose of the present invention is to provide a method, device, equipment and medium for constructing a face recognition model, which can improve the accuracy of face recognition of the face recognition model. The specific scheme is as follows:

[0004] In a first aspect, the present application discloses a method for constructing a face recognition model, comprising:

[0005] Acquire a face image, and annotate the face image according to the collector to obtain a face data set;

[0006] Building a randomly initialized model based on a neural network structure, and using a face loss function as a loss function for the first stage of model training, and then using the face data set to perform the first stage of training on the randomly initialized model to obtain a model after the first stage of training;

[0007] The face loss function and the ranking loss function are used as loss functions for the second stage training of the model, and then the face data set is used to perform the second stage training on the model trained in the first stage to obtain a face recognition model;

[0008] Among them, the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0009] Optionally, the labeling of the facial image according to the collector includes:

[0010] The same ID tag is added to one or more facial images corresponding to the same collector, and the photo serial numbers are added in sequence, so that the facial images of the same collector are marked with the same ID tag.

[0011] Optionally, building a random initialization model based on a neural network structure includes:

[0012] A random initialization model is built based on a neural network structure, wherein the neural network structure is ResNet or MobileFaceNet.

[0013] Optionally, the performing a first-stage training on the randomly initialized model using the face data set to obtain a first-stage trained model includes:

[0014] The randomly initialized model is trained in the first stage using the face data set, and the training is interrupted after the training reaches a target number of epochs to obtain the first stage trained model.

[0015] Optionally, before performing a second stage of training on the model trained in the first stage using the face dataset, the method further includes:

[0016] According to the similarity score of each sample, the similarity score ranking of each sample in the face data set in the corresponding positive sample set and the similarity score ranking of each sample in all sample sets are calculated using the score ranking calculation formula; the positive sample set is a face data set for the same collector;

[0017] The score ranking calculation formula is:

[0018] R(i, S) = 1 + I{(sj-si)>0};

[0019] Where S is the sample set, i is the i-th sample, R(i, S) is the similarity score ranking of the i-th sample in the sample set S, s is the similarity score, sj is the similarity score of the j-th sample, and si is the similarity score of the i-th sample; I is the mapping function, and I takes 1 when sj-si is greater than 0, otherwise I takes 0.

[0020] Optionally, the sorting loss function Lap is:

[0021] Lap=1-AP;AP=R(i,Sp) / R(i,Sa);

[0022] Among them, Sp is the positive sample set, Sa is all sample sets, R(i, Sp) is the similarity score ranking of sample i in the positive sample set, and R(i, Sa) is the similarity score ranking of sample i in all sample sets.

[0023] In a second aspect, the present application discloses a face recognition method, comprising:

[0024] Obtain a face image to be identified, and input the face image to be identified into a face recognition model to obtain a face recognition result; the face recognition model is a face recognition model obtained by sequentially performing the first stage training and the second stage training on a randomly initialized model built based on a neural network structure using a face data set containing annotations by the collector;

[0025] Among them, the first stage training is to use the face loss function as the loss function of the model, and then use the face data set to train the randomly initialized model; the second stage training is to use the face loss function and the ranking loss function as the loss function of the model, and then use the face data set to train the first stage trained model obtained after the first stage training; wherein, the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0026] In a second aspect, the present application discloses a face recognition model construction device, comprising:

[0027] A face data set acquisition module is used to acquire face images and annotate the face images according to the collector to obtain a face data set;

[0028] A first training module is used to build a randomly initialized model based on a neural network structure, and use a face loss function as a loss function for the first stage of model training, and then use the face data set to perform the first stage of training on the randomly initialized model to obtain a model after the first stage of training;

[0029] A second training module is used to use the face loss function and the ranking loss function as the loss functions of the second stage training of the model, and then use the face data set to perform the second stage training on the model trained in the first stage to obtain a face recognition model;

[0030] Among them, the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0031] In a third aspect, the present application discloses an electronic device, comprising:

[0032] Memory, used to store computer programs;

[0033] A processor is used to execute the computer program to implement the aforementioned face recognition model construction method.

[0034] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the aforementioned face recognition model construction method.

[0035] In the present application, a face data set is obtained by acquiring face images and annotating the face images according to the collector; a randomly initialized model is built based on a neural network structure, and a face loss function is used as the loss function of the first stage training of the model, and then the face data set is used to perform the first stage training on the randomly initialized model to obtain the first stage trained model; the above-mentioned face loss function and the sorting loss function are used as the loss functions of the second stage training of the model, and then the face data set is used to perform the second stage training on the first stage trained model to obtain a face recognition model; wherein the sorting loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets. As can be seen from the above, the present application adds an end-to-end sorting loss function that can improve the first-place hit rate on the basis of the general face loss function, thereby adding a comparison and sorting supervision when calculating the loss, so that the ranking result of the same person is as high as possible during the comparison, that is, the similarity of the same person should be ranked as high as possible in the front, and the similarity of different people should be ranked as far back as possible, thereby solving the problem caused by the currently commonly used loss function that only considers widening the similarity interval between the same person and different people without considering the sorting, thereby improving the first-place hit rate of the face recognition result and improving the recognition accuracy of the face recognition model. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0037] Figure 1 A flow chart of a face recognition model construction method provided in this application;

[0038] Figure 2a A schematic diagram of the effect of a face loss function provided for this application;

[0039] Figure 2b A schematic diagram of the effect of a sorting loss function provided for this application;

[0040] Figure 3 A flow chart of a face recognition method provided for this application;

[0041] Figure 4 A schematic diagram of the structure of a face recognition model building device provided in this application;

[0042] Figure 5 A structural diagram of an electronic device provided for this application. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0044] In the prior art, the features of the face image are extracted through the network to calculate the cosine similarity to determine which person the face belongs to or whether it is the same person. The loss function is basically realized by increasing the interval between the cosine similarities between the same person and different people. The greatest similarity is found by comparison, and then a threshold is set. The greatest similarity exceeds the set threshold and is considered to be the same person, but the first hit rate is not considered. There is a selection of the most similar face in the face library for comparison. If the face with the highest similarity is wrong, then the final recognition result must be wrong. In order to overcome the above technical problems, the present application proposes a method for constructing a face recognition model, which can improve the accuracy of face recognition of the face recognition model.

[0045] The present application discloses a method for constructing a face recognition model. Figure 1 As shown, the method may include the following steps:

[0046] Step S11: Acquire a face image, and annotate the face image according to the collector to obtain a face data set.

[0047] In this embodiment, firstly, a plurality of face images are acquired, and the face images are labeled according to the collector to obtain a face data set. That is, face images are collected and labeled, and the same person is labeled the same, for example, the first person has multiple face images, all labeled as 0, and the second person has multiple face images labeled as 1, so that the labeled face images are used as the face data set.

[0048] In this embodiment, the labeling of the facial images according to the collector may include: adding the same ID tag to one or more facial images corresponding to the same collector, and adding photo serial numbers in sequence, so that the facial images of the same collector are labeled with the same ID tag. That is, facial images are collected and labeled, and the same person is labeled with the same ID and arranged in sequence. For example, the first person has multiple facial images, all labeled as 0, and the second person has multiple facial images labeled as 1. For example, the first person has 10 facial images, and the person's ID is labeled as 0, and the photo serial numbers are 0, 1, 2...9. The second person is labeled as 1, has 7 facial photos, and the photo serial numbers are 0, 1, 2...6. And so on.

[0049] Step S12: Building a randomly initialized model based on the neural network structure, and using the face loss function as the loss function for the first stage of model training, and then using the face data set to perform the first stage of training on the randomly initialized model to obtain a model after the first stage of training.

[0050] In this embodiment, a network model is built based on a neural network structure. The neural network structure can be ResNet or MobileFaceNet, or other deep convolutional network structures. After the construction, a random initialization model is obtained, that is, the parameter values ​​of the randomly initialized model after the construction are random values, and the model has no recognition ability at this time. After the random initialization model is built, the general face loss function is first used as the loss function of the first stage training of the random initialization model, and the face data set is input into the random initialization model to perform the first stage training on the random initialization model to obtain the model after the first stage training, so that the model has a certain ability to distinguish faces and a basis for sorting face similarity. The above face loss function can be any one of ArcFace loss, AM-Softmax or Tplet Loss.

[0051] In this embodiment, the first-stage training of the randomly initialized model using the face data set to obtain the first-stage trained model may include: using the face data set to perform the first-stage training of the randomly initialized model, interrupting the training after the training reaches the target number of epochs, and obtaining the first-stage trained model. It can be understood that in the process of performing the first-stage training of the randomly initialized model using the face data set with the above-mentioned face loss function as a constraint, the training is interrupted after the training reaches the target number of epochs to prevent overfitting caused by excessive training, and the first-stage trained model is obtained at this time, and the above-mentioned target number can be 20 times. Among them, epoch means using all the data in the training set to perform a complete training of the model, also known as "one generation of training", that is, all training samples have undergone one forward propagation and one backward propagation in the neural network.

[0052] Step S13: Use the above-mentioned face loss function and ranking loss function as the loss functions for the second stage training of the model, and then use the face data set to perform the second stage training on the model trained in the first stage to obtain a face recognition model; wherein the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0053] In this embodiment, after the first-stage trained model is obtained through training, the above-mentioned face loss function and ranking loss function are used as loss functions for the second-stage training of the model, and then the first-stage trained model is trained for the second stage using the face data set to obtain a face recognition model; wherein the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0054] In this embodiment, before the second stage training of the model after the first stage training using the face data set, the method may further include: calculating the similarity score ranking of each sample in the face data set in the corresponding positive sample set and the similarity score ranking of each sample in all sample sets using a score ranking calculation formula according to the similarity score of each sample; the positive sample set is a face data set for the same collector;

[0055] The score ranking calculation formula is:

[0056] R(i, S) = 1 + I{(sj-si)>0};

[0057] Where S is the sample set, i is the i-th sample, R(i, S) is the similarity score ranking of the i-th sample in the sample set S, s is the similarity score, sj is the similarity score of the j-th sample, and si is the similarity score of the i-th sample; I is the mapping function, and I takes 1 when sj-si is greater than 0, otherwise I takes 0.

[0058] In this embodiment, the sorting loss function Lap is:

[0059] Lap=1-AP;AP=R(i,Sp) / R(i,Sa);

[0060] Among them, Sp is the positive sample set, Sa is all sample sets, R(i, Sp) is the similarity score ranking of sample i in the positive sample set, and R(i, Sa) is the similarity score ranking of sample i in all sample sets.

[0061] That is, in this embodiment, the sample set of the same person is called Sp, the sample sets of different people are called Sn, and all sample sets are called Sa. Then the definition is: the AP loss function of a sample = its ranking in the similarity score of the positive sample set / its ranking in the similarity score of all sample sets, that is, AP = R (i, Sp) / R (i, Sa). The calculation method of the above AP loss function ranking function is as follows:

[0062] R(i, S)=1+I{(sj-si)>0}, where S is the sample set, i is the i-th sample, R(i, S) is the similarity score ranking of the i-th sample in the sample set S, s is the similarity score, sj is the similarity score of the j-th sample, and si is the similarity score of the i-th sample; I is a mapping function, and I takes 1 when sj-si is greater than 0, otherwise I takes 0. For example, if the score set is {0.5, 0.7, 0.3, 0.4, 0.9, 0.6}, and we want to see where 0.4 ranks, then the score ranking calculation formula is 1+I{0.5-0.4}+I{0.7-0.4}+I{0.3-0.4}+I{0.4-0.4}+I{0.9-0.4}+I{0.6-0.4}=1+1+1+0+0+1+1=5, then it ranks 5th in the sequence, which is consistent with the actual situation. And because in practical applications, the larger the AP value, the better, in the actual training process, we hope that the AP loss function is as small as possible, so the ranking loss function in this embodiment is Lap, Lap=1-AP. The main advantage of the AP loss function is to sort the face similarity, and then make the similarity scores of the same person as much as possible in the front, which is also the same operation in practice, so it is end-to-end training.

[0063] It is understandable that the commonly used face loss function aims to distinguish the same person from different people, such as Figure 2aAs mentioned above, the ranking loss function proposed in this embodiment is to make the scores of the same face similarity ranked as high as possible, such as Figure 2b As described. Therefore, in this embodiment, the network training process is divided into two stages. In the first stage, the commonly used face loss function is used for supervised training, and the training is interrupted after the training reaches the target number of epochs; then the face loss function and the sorting loss function are used to jointly supervise the training. Specifically, 10 epochs can be trained to obtain the final face recognition model, so that the similarity scores of the same faces are ranked as high as possible. In addition, the above steps in this embodiment can not only be used for face recognition, but also are applicable to algorithms that actually have a comparison and sorting process, such as pedestrian re-identification, image retrieval, etc.

[0064] Furthermore, the results of experiments using ResNet50 and MS1M datasets for training and testing on the IJBC dataset showed that when the training method was a single face loss function, the test accuracy of IJBC (1e-4) was 96.4%, and the test accuracy of IJBC (1e-5) was 88.0%; when the training method was a joint training of the face loss function and the sorting loss function, that is, the method disclosed in this embodiment, the test accuracy of IJBC (1e-4) was 97.01%, and the test accuracy of IJBC (1e-5) was 90.2%, which shows that the accuracy of face recognition is improved.

[0065] As can be seen from the above, in this embodiment, a face data set is obtained by acquiring face images and annotating the face images according to the collector; a randomly initialized model is built based on a neural network structure, and the face loss function is used as the loss function of the first stage training of the model, and then the face data set is used to perform the first stage training on the randomly initialized model to obtain the first stage trained model; the above-mentioned face loss function and the sorting loss function are used as the loss functions of the second stage training of the model, and then the face data set is used to perform the second stage training on the first stage trained model to obtain a face recognition model; wherein, the sorting loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets. It can be seen from the above that on the basis of the general face loss function, an end-to-end sorting loss function that can improve the first-place hit rate is added. Therefore, a comparison and sorting supervision is added when calculating the loss, so that the ranking result of the same person is as high as possible during the comparison, that is, the similarity of the same person should be ranked as high as possible in the front, and the similarity of different people should be ranked as far back as possible. This solves the problem caused by the currently commonly used loss function that only considers widening the similarity interval between the same person and different people without considering the sorting, improves the first-place hit rate of the face recognition result, and improves the recognition accuracy of the face recognition model.

[0066] The present application discloses a face recognition method. Figure 3 As shown, the method may include the following steps:

[0067] Obtaining a face image to be recognized, and inputting the face image to be recognized into a face recognition model to obtain a face recognition result;

[0068] The face recognition model is a face recognition model obtained by using a face data set containing collector annotations to perform first-stage training and second-stage training on a randomly initialized model built based on a neural network structure; wherein, the first-stage training is to use the face loss function as the loss function of the model, and then use the face data set to train the randomly initialized model; the second-stage training is to use the face loss function and the ranking loss function as the loss function of the model, and then use the face data set to train the first-stage trained model obtained after the first-stage training; wherein the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0069] In some specific embodiments, labeling the facial images according to the collector may include: adding the same ID tag to one or more facial images corresponding to the same collector, and adding photo serial numbers in sequence, so that the facial images of the same collector are labeled with the same ID tag.

[0070] In some specific embodiments, building a random initialization model based on a neural network structure may include: building a random initialization model based on a neural network structure, and the neural network structure is ResNet or MobileFaceNet.

[0071] In some specific embodiments, performing the first stage training on the randomly initialized model using the face dataset to obtain the first stage trained model may include: performing the first stage training on the randomly initialized model using the face dataset, interrupting the training after the training reaches a target number of epochs, and obtaining the first stage trained model.

[0072] In some specific embodiments, before the second stage training of the model after the first stage training using the face data set, the method may also include: calculating the similarity score ranking of each sample in the face data set in the corresponding positive sample set and the similarity score ranking of each sample in all sample sets using a score ranking calculation formula according to the similarity score of each sample; the positive sample set is a face data set for the same collector;

[0073] The score ranking calculation formula is:

[0074] R(i, S) = 1 + I{(sj-si)>0};

[0075] Where S is the sample set, i is the i-th sample, R(i, S) is the similarity score ranking of the i-th sample in the sample set S, s is the similarity score, sj is the similarity score of the j-th sample, and si is the similarity score of the i-th sample; I is the mapping function, and I takes 1 when sj-si is greater than 0, otherwise I takes 0.

[0076] In some specific embodiments, the ranking loss function Lap is:

[0077] Lap=1-AP;AP=R(i,Sp) / R(i,Sa);

[0078] Among them, Sp is the positive sample set, Sa is all sample sets, R(i, Sp) is the similarity score ranking of sample i in the positive sample set, and R(i, Sa) is the similarity score ranking of sample i in all sample sets.

[0079] As can be seen from the above, in this embodiment, an end-to-end sorting loss function that can improve the first-place hit rate is added on the basis of the general face loss function, thereby adding a comparison and sorting supervision when calculating the loss, so that the ranking result of the same person is as high as possible during the comparison, that is, the similarity of the same person should be ranked as high as possible in the front, and the similarity of different people should be ranked as far back as possible, thereby solving the problem caused by the currently commonly used loss function that only considers widening the similarity interval between the same person and different people without considering the sorting, thereby improving the first-place hit rate of the face recognition result and improving the recognition accuracy of the face recognition model.

[0080] Correspondingly, the embodiment of the present application also discloses a face recognition model construction device, see Figure 4 As shown, the device comprises:

[0081] The face data set acquisition module 11 is used to acquire face images and annotate the face images according to the collector to obtain the face data set;

[0082] The first training module 12 is used to build a random initialization model based on a neural network structure, and use the face loss function as the loss function of the first stage training of the model, and then use the face data set to perform the first stage training on the random initialization model to obtain a model after the first stage training;

[0083] The second training module 13 is used to use the above-mentioned face loss function and ranking loss function as the loss function of the second stage training of the model, and then use the face data set to perform the second stage training on the model trained in the first stage to obtain a face recognition model;

[0084] Among them, the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

[0085] As can be seen from the above, in this embodiment, an end-to-end sorting loss function that can improve the first-place hit rate is added on the basis of the general face loss function, thereby adding a comparison and sorting supervision when calculating the loss, so that the ranking result of the same person is as high as possible during the comparison, that is, the similarity of the same person should be ranked as high as possible in the front, and the similarity of different people should be ranked as far back as possible, thereby solving the problem caused by the currently commonly used loss function that only considers widening the similarity interval between the same person and different people without considering the sorting, thereby improving the first-place hit rate of the face recognition result and improving the recognition accuracy of the face recognition model.

[0086] In some specific embodiments, the face data set acquisition module 11 may specifically include:

[0087] The label adding unit is used to add the same ID label to one or more facial images corresponding to the same collector, and add photo serial numbers in sequence, so that the facial images of the same collector are marked with the same ID label.

[0088] In some specific embodiments, the first training module 12 may specifically include:

[0089] The random initialization model building unit is used to build a random initialization model based on a neural network structure, wherein the neural network structure is ResNet or MobileFaceNet.

[0090] In some specific embodiments, the first training module 12 can be specifically used to perform the first stage training on the randomly initialized model using the face data set, interrupt the training after the training reaches a target number of epochs, and obtain the first stage trained model.

[0091] In some specific embodiments, the face recognition model building device may specifically include:

[0092] A score ranking determination unit, used to calculate the similarity score ranking of each sample in the face data set in the corresponding positive sample set and the similarity score ranking of each sample in all sample sets according to the similarity score of each sample using a score ranking calculation formula; the positive sample set is a face data set for the same collector;

[0093] The score ranking calculation formula is:

[0094] R(i, S) = 1 + I{(sj-si)>0};

[0095] Where S is the sample set, i is the i-th sample, R(i, S) is the similarity score ranking of the i-th sample in the sample set S, s is the similarity score, sj is the similarity score of the j-th sample, and si is the similarity score of the i-th sample; I is the mapping function, and I takes 1 when sj-si is greater than 0, otherwise I takes 0.

[0096] In some specific embodiments, the ranking loss function Lap is:

[0097] Lap=1-AP;AP=R(i,Sp) / R(i,Sa);

[0098] Among them, Sp is the positive sample set, Sa is all sample sets, R(i, Sp) is the similarity score ranking of sample i in the positive sample set, and R(i, Sa) is the similarity score ranking of sample i in all sample sets.

[0099] Furthermore, the present application also discloses an electronic device, see Figure 5 As shown, the contents in the drawings should not be considered as any limitation on the scope of use of the present application.

[0100] Figure 5 The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the face recognition model construction method disclosed in any of the aforementioned embodiments.

[0101] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0102] In addition, the memory 22, as a carrier for storing resources, can be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon include an operating system 221, a computer program 222, and data 223 including a face data set, etc. The storage method can be temporary storage or permanent storage.

[0103] The operating system 221 is used to manage and control the hardware devices and computer programs 222 on the electronic device 20, so as to realize the operation and processing of the massive data 223 in the memory 22 by the processor 21, and it can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the face recognition model construction method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0104] Furthermore, an embodiment of the present application also discloses a computer storage medium, in which computer executable instructions are stored. When the computer executable instructions are loaded and executed by a processor, the steps of the face recognition model construction method disclosed in any of the aforementioned embodiments are implemented.

[0105] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0106] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.

[0107] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0108] The above is a detailed introduction to the face recognition model construction method, device, equipment and medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for constructing a face recognition model, characterized in that: include: Acquire a face image, and annotate the face image according to the collector to obtain a face data set; Building a randomly initialized model based on a neural network structure, and using a face loss function as a loss function for the first stage of model training, and then using the face data set to perform the first stage of training on the randomly initialized model to obtain a model after the first stage of training; According to the similarity score of each sample, a score ranking calculation formula is used to calculate the similarity score ranking of each sample in the face data set in the corresponding positive sample set, as well as the similarity score ranking of each sample in all sample sets; The positive sample set is a face dataset for the same collector; The face loss function and the ranking loss function are used as loss functions for the second stage training of the model, and then the face data set is used to perform the second stage training on the model trained in the first stage to obtain a face recognition model; The ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets; The step of labeling the facial image according to the collector includes: The same ID tag is added to one or more facial images corresponding to the same collector, and the photo serial numbers are added in sequence, so that the facial images of the same collector are marked with the same ID tag.

2. The method for constructing a face recognition model according to claim 1, characterized in that: The randomly initialized model is constructed based on the neural network structure, including: A random initialization model is built based on a neural network structure, wherein the neural network structure is ResNet or MobileFaceNet.

3. The method for constructing a face recognition model according to claim 1, characterized in that: The step of performing the first-stage training on the randomly initialized model using the face data set to obtain a first-stage trained model includes: The randomly initialized model is trained in the first stage using the face data set, and the training is interrupted after the training reaches a target number of epochs to obtain the first stage trained model.

4. The method for constructing a face recognition model according to claim 1, characterized in that: The score ranking calculation formula is: R(i, S) = 1 + I{(sj-si)>0}; Where S is the sample set, i is the i-th sample, R(i, S) is the similarity score ranking of the i-th sample in the sample set S, s is the similarity score, sj is the similarity score of the j-th sample, and si is the similarity score of the i-th sample; I is the mapping function, and I takes 1 when sj-si is greater than 0, otherwise I takes 0.

5. The method for constructing a face recognition model according to any one of claims 1 to 4, characterized in that: The sorting loss function Lap is: Lap=1-AP;AP=R(i,Sp) / R(i,Sa); Among them, Sp is the positive sample set, Sa is all sample sets, R(i, Sp) is the similarity score ranking of sample i in the positive sample set, and R(i, Sa) is the similarity score ranking of sample i in all sample sets.

6. A face recognition method, characterized in that: include: Obtaining a face image to be recognized, and inputting the face image to be recognized into a face recognition model to obtain a face recognition result; The face recognition model is a face recognition model obtained by sequentially performing the first stage training and the second stage training on a randomly initialized model built based on a neural network structure using a face data set containing collector annotations; The process of constructing a face dataset with collector annotations includes: adding the same ID tag to one or more face images corresponding to the same collector, and adding photo serial numbers in sequence, so that the face images of the same collector are annotated with the same ID tag; Among them, the first stage training is to use the face loss function as the loss function of the model, and then use the face data set to train the randomly initialized model; the second stage training is to calculate the similarity score ranking of each sample in the face data set in the corresponding positive sample set and the similarity score ranking of each sample in all sample sets based on the similarity score of each sample using the score ranking calculation formula; the positive sample set is a face data set for the same collector; the face loss function and the ranking loss function are used as the loss function of the model, and then the first stage trained model obtained after the first stage training is trained using the face data set; wherein the ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets.

7. A face recognition model construction device, characterized in that: include: A face data set acquisition module is used to acquire face images and annotate the face images according to the collector to obtain a face data set; A first training module is used to build a randomly initialized model based on a neural network structure, and use a face loss function as a loss function for the first stage of model training, and then use the face data set to perform the first stage of training on the randomly initialized model to obtain a model after the first stage of training; The second training module is used to calculate the similarity score ranking of each sample in the face data set in the corresponding positive sample set and the similarity score ranking of each sample in all sample sets by using a score ranking calculation formula according to the similarity score of each sample; The positive sample set is a face data set for the same collector; the face loss function and the sorting loss function are used as loss functions for the second stage training of the model, and then the face data set is used to perform the second stage training on the model trained in the first stage to obtain a face recognition model; The ranking loss function of a single sample in the face data set is a function constructed based on the ratio of the similarity score ranking of the sample in the positive sample set to the similarity score ranking of the sample in all sample sets; Among them, the face data set acquisition module is used to add the same ID tag to one or more face images corresponding to the same collector, and add photo serial numbers in sequence, so that the face images of the same collector are marked with the same ID tag.

8. An electronic device, characterized in that: include: Memory, used to store computer programs; A processor, used to execute the computer program to implement the face recognition model construction method as described in any one of claims 1 to 5.

9. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein when the computer program is executed by a processor, the method for constructing a face recognition model as described in any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Model training method and device, image feature extraction method and device and electronic equipment

    CN111274422A

  • Image feature extraction model training method and device and electronic equipment

    CN114119989A