A face recognition method, face recognition model training method and related devices

By directly identifying heterogeneous face images and using feature vectors and loss parameters to train the model, the cumbersome visual domain conversion problem in the existing technology is solved, and efficient heterogeneous face recognition is achieved.

CN114463794BActive Publication Date: 2025-08-15HUAWEI CLOUD COMPUTING TECHNOLOGIES CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202011133566.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-10-21
Publication Date
2025-08-15
Estimated Expiration
2040-10-21

AI Technical Summary

Technical Problem

The existing heterogeneous face recognition technology requires converting heterogeneous face images into homologous images for recognition and matching. The process is cumbersome and time-consuming, and the image effect generated by the generator is unstable.

Method used

The face images of different visual domains are directly recognized without visual domain conversion processing. By obtaining the feature vectors of heterogeneous face image pairs, a similarity matrix is constructed and the face recognition model is trained using symmetry loss, first discriminant loss and second discriminant loss parameters, and the distance parameters of the feature vector are directly calculated to match.

Benefits of technology

It improves the efficiency and accuracy of facial recognition, simplifies processing flow, reduces dependence on the generator, and improves the speed and effect of recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114463794B_ABST
    Figure CN114463794B_ABST
Patent Text Reader

Abstract

The present invention discloses a face recognition method, a face recognition model training method, and related devices for improving the efficiency of face recognition. The method includes obtaining corresponding feature vectors from two face images, then comparing a distance parameter between the two feature vectors. If the distance parameter is greater than a preset value, it is determined that the two face images do not match; if the distance parameter is less than the preset value, it is determined that the two face images do match.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present application relate to the field of face recognition, and in particular to a face recognition method and related devices. Background Art

[0002] With the development of deep learning, more and more researchers are turning their attention to heterogeneous face recognition (HFR) technology. Heterogeneous face recognition involves identifying and matching facial images from different visual domains. For example, it can identify and match a sketched face image with an optical face image to determine whether the two faces belong to the same person. Heterogeneous face recognition has important practical applications. For example, public security departments can create a sketch based on the description provided by an eyewitness and then use heterogeneous face recognition technology to find a matching face based on the sketch, thereby identifying a suspect.

[0003] Existing heterogeneous face recognition technology requires first converting heterogeneous face images into homogeneous face images through a generator. For example, a visible light face image is converted into a thermal imaging face image through a generator, and then the thermal imaging face image is identified and matched with another thermal imaging face image.

[0004] However, the existing technology of using a generator to obtain homologous images for comparison is relatively cumbersome and time-consuming, and is more dependent on the effect of the images generated by the generator. Summary of the Invention

[0005] The embodiments of the present application provide a method and related devices for face recognition, which can directly recognize two pictures in different visual domains to be recognized without the need to convert the pictures into visual domains, thereby improving the efficiency of recognition.

[0006] The first aspect of the embodiments of the present application provides a method for training a face recognition model:

[0007] For face images in different visual domains, they are also called heterogeneous face images. For example, an optical face image and a near-infrared face image are a pair of heterogeneous face images. A set of heterogeneous face image pairs can be obtained from the sample library. The heterogeneous face image pair set includes N pairs of heterogeneous face images, and each pair of heterogeneous face images corresponds to a target face among N different faces. After obtaining N pairs of heterogeneous face images, N groups of feature vectors can be obtained based on the N pairs of heterogeneous face images. Each group of feature vectors includes two feature vectors. After obtaining N groups of feature vectors, a similarity matrix can be obtained based on the N groups of feature vectors by combination. The elements on the diagonal of the similarity matrix represent the distance parameters between the two feature vectors corresponding to the same target face, and the elements on the off-diagonal of the similarity matrix represent the distance parameters between the two feature vectors corresponding to different target faces and corresponding to different visual domains. After that, the loss parameters of the similarity matrix can be obtained. The loss parameters include symmetric loss parameters. The symmetric loss parameters are symmetric about the diagonal in the similarity matrix, that is, D ij Elements and D ji The sum of the squares of the differences of the elements of , where i is not equal to j. After obtaining the loss parameter, the face recognition model can be trained according to the loss parameter.

[0008] In combination with the first aspect, in the first implementation of the first aspect of the embodiment of the present application, the loss parameter may further include a first discriminant loss parameter and a second discriminant loss parameter, wherein the first discriminant loss parameter is D in the similarity matrix mn The sum of the elements, where m is equal to n, and the second discriminant loss parameter is D in the similarity matrix jk The sum of the elements where j is greater than k.

[0009] In combination with the first aspect, in the second implementation of the first aspect of the embodiment of the present application, the second discriminant loss can be D in the similarity matrix ab The sum of the first N elements in sorted by numerical value from large to small, where a is greater than b.

[0010] In combination with the first aspect, any one of the first implementation method of the first aspect to the second implementation method of the first aspect, in the third implementation method of the first aspect of the embodiment of the present application, when the symmetric loss parameter converges to the first preset value, the first discriminant loss parameter converges to the second preset value, and the second discriminant loss parameter converges to the third preset value, the parameters corresponding to the face recognition model are obtained.

[0011] The second aspect of the embodiment of the present application provides a face recognition method:

[0012] A first facial image and a second facial image to be identified are obtained, wherein the first facial image and the second facial image have different image attributes, which may be any one of a visual domain, a lighting condition, and a shooting angle. After obtaining the first facial image and the second facial image, a first eigenvector may be obtained based on the first facial image, and a second eigenvector may be obtained based on the second facial image. Then, a distance parameter between the first eigenvector and the second eigenvector may be obtained by calculation, and the distance parameter may be a Euclidean distance or a cosine distance. If the distance parameter is lower than a preset value, it may be determined that a matching relationship exists between the first facial image and the second facial image. If the distance parameter is greater than the above-mentioned preset value, it may be determined that no matching relationship exists between the first facial image and the second facial image.

[0013] The third aspect of the present application embodiment provides a face recognition model training method:

[0014] Obtain N pairs of face image pairs, where N is an integer greater than or equal to 2. The N pairs of face image pairs include a first face image pair and a second face image pair, wherein the first face image pair includes a face image of the first target face in a first image attribute and a face image of the second target face in a second image attribute, and the second face image pair includes a face image of the second target face in a third image attribute and a face image of the first target face in a fourth image attribute. The image attribute may include any one of a visual domain, a lighting condition, and a shooting angle. After that, a symmetric loss parameter can be obtained based on the first face image pair and the second face image pair. The symmetric loss parameter is the product of the square of the difference between the distance parameter of the first face image pair and the distance parameter of the second face image pair and 1 / [N(N-1)]. After obtaining the symmetric loss parameter, the face recognition model can be trained based on the symmetric loss parameter.

[0015] In conjunction with the third aspect, in a first implementation of the third aspect of the embodiment of the present application, the first image attribute, the second image attribute, the third image attribute, and the fourth image attribute correspond to four different image attributes;

[0016] Alternatively, the first image attribute and the fourth image attribute correspond to different image attributes, the second image attribute and the third image attribute correspond to different image attributes, the first image attribute and the third image attribute correspond to the same image attribute, and the fourth image attribute and the second image attribute correspond to the same image attribute.

[0017] In combination with the first implementation method of the third aspect, in the second implementation method of the third aspect of the embodiment of the present application, after obtaining N pairs of face image pairs, before training the face recognition model according to the symmetric loss parameters, the corresponding N distance parameters can also be obtained based on the N pairs of face image pairs. The distance parameter is the distance parameter between the two face images of each pair of face image pairs in the N pairs of face image pairs, which can be the Euclidean distance or the cosine distance. After obtaining the N distance parameters, the contrast loss parameter can be obtained based on the N distance parameters. After that, the face recognition model can be trained in combination with the symmetric loss parameter and the contrast loss parameter.

[0018] In combination with the second implementation method of the third aspect, in the third implementation method of the third aspect of the embodiment of the present application, the face recognition model is trained according to the symmetric loss parameter and the contrast loss parameter, that is, when the symmetric loss parameter converges to the first preset value and the contrast loss parameter converges to the second preset value, the corresponding parameters of the face recognition model are obtained.

[0019] A fourth aspect of the present application provides a method for training a face recognition model:

[0020] Obtain N groups of facial images, where N is an integer greater than 0, and each group of facial images in the N groups of facial images includes a first facial image, a second facial image, and a third facial image, wherein the first facial image includes a facial image of a first target face in a first image attribute, the second facial image includes a facial image of the first target face in a second image attribute, and the third facial image includes a facial image of the second target face in a third image attribute, wherein the third image attribute, the first image attribute, and the second image attribute are three different image attributes, and the image attribute includes any one of a visual domain, a lighting condition, and a shooting angle, or the third image attribute is different from the first image attribute. One image attribute is the same image attribute, and the first image attribute and the second image attribute are different image attributes. After that, the symmetric loss parameter can be obtained according to the first face image, the second face image and the third face image. The symmetric loss parameter is the sum of the difference between the first distance parameter and the second distance parameter. The first distance parameter is the distance parameter between the first face image and the third face image, and the second distance parameter is the distance parameter between the second face image and the third face image. The distance parameter can be the Euclidean distance or the cosine distance. After obtaining the symmetric loss parameter, the face recognition model can be trained according to the symmetric loss parameter.

[0021] In combination with the fourth aspect, in the first implementation method of the fourth aspect of the embodiment of the present application, the face recognition model is trained according to the symmetric loss parameter, that is, when the symmetric loss parameter converges to a preset value, the parameters corresponding to the face recognition model are obtained.

[0022] A fifth aspect of the present application provides a facial recognition model training device that implements the facial recognition model training method described in the first aspect. This functionality can be implemented in hardware or by executing corresponding software on the hardware. The hardware includes one or more modules corresponding to the aforementioned functionality.

[0023] A sixth aspect of the present application provides a facial recognition device that implements the facial recognition method described in the second aspect. This functionality can be implemented in hardware or by executing corresponding software on the hardware. The hardware includes one or more modules corresponding to the aforementioned functionality.

[0024] A seventh aspect of the present application provides a facial recognition model training device that implements the facial recognition model training method described in the third aspect. This functionality can be implemented in hardware or by executing corresponding software on the hardware. The hardware includes one or more modules corresponding to the aforementioned functionality.

[0025] In an eighth aspect, embodiments of the present application provide a facial recognition model training device that implements the facial recognition model training method described in the fourth aspect. This function can be implemented in hardware or by executing corresponding software on the hardware. The hardware includes one or more modules corresponding to the aforementioned functions.

[0026] A ninth aspect of the embodiments of the present application provides a computer device, including:

[0027] Processor, memory, input and output devices, and bus;

[0028] The processor, memory, and input and output devices are connected to the bus;

[0029] The processor is used to execute any one of the methods of the first aspect, the first implementation of the first aspect, and the third implementation of the first aspect.

[0030] A tenth aspect of the embodiments of the present application provides a computer device, including:

[0031] Processor, memory, input and output devices, and bus;

[0032] The processor, memory, and input and output devices are connected to the bus;

[0033] The processor is used to execute any one of the methods of the first aspect, the first implementation of the first aspect, and the second implementation of the first aspect.

[0034] According to an eleventh aspect of the present application, a computer device is provided, including:

[0035] Processor, memory, input and output devices, and bus;

[0036] The processor, memory, and input and output devices are connected to the bus;

[0037] The processor is used to execute any one of the methods of the third aspect, the first implementation of the first aspect, and the second implementation of the first aspect.

[0038] A twelfth aspect of the embodiments of the present application provides a computer device, including:

[0039] Processor, memory, input and output devices, and bus;

[0040] The processor, memory, and input and output devices are connected to the bus;

[0041] The processor is used to execute the method of any one of the aforementioned fourth aspect and the first implementation manner of the fourth aspect.

[0042] A thirteenth aspect of an embodiment of the present application provides a computer storage medium for storing the above-mentioned computer software instructions for a computer device or a computer device, including instructions for executing a program designed for a computer device or a computer device.

[0043] A fourteenth aspect of the embodiments of the present application provides a computer program product. When the computer program product is executed on a computer, the computer executes any one of the methods of the first to fourth aspects above. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] Figure 1 This is a flowchart of the face recognition model training method according to an embodiment of the present application;

[0045] Figure 2 A schematic diagram of obtaining training samples for an embodiment of the present application;

[0046] Figure 3 A schematic diagram of obtaining a feature vector based on a training sample in an embodiment of the present application;

[0047] Figure 4 This is a schematic diagram of obtaining a similarity matrix based on a feature vector in an embodiment of the present application;

[0048] Figure 5 A flowchart of a face recognition method in an embodiment of the present application;

[0049] Figure 6 A schematic diagram of a process for retraining a face recognition model in an embodiment of the present application;

[0050] Figure 7 This is another flowchart of the face recognition model training method in an embodiment of the present application;

[0051] Figure 8 This is another flowchart of the face recognition model training method in an embodiment of the present application;

[0052] Figure 9 This is a structural diagram of a face recognition model training device in an embodiment of the present application;

[0053] Figure 10 This is a structural diagram of a face recognition device in an embodiment of the present application;

[0054] Figure 11 This is another structural diagram of the face recognition model training device in an embodiment of the present application;

[0055] Figure 12 This is another structural diagram of the face recognition model training device in an embodiment of the present application;

[0056] Figure 13 This is a structural diagram of a computer device in an embodiment of the present application. DETAILED DESCRIPTION

[0057] An embodiment of the present application provides a face recognition model training method for training a face recognition model, so that the trained face recognition model can directly obtain corresponding feature vectors based on two heterogeneous face images, and then perform recognition based on the distance parameters of the feature vectors.

[0058] With the rapid development of deep learning technology, homologous face recognition technology has developed rapidly, and more and more researchers have begun to pay attention to heterogeneous face recognition technology. Heterogeneous face recognition technology refers to face recognition across visual domains and has important application value. For example, the public security organs can compare the obtained sketch face image of the suspect or the near-infrared face image with the optical face image in the database, and then identify the optical face image that matches the suspect's face image. In the existing technology, before performing heterogeneous face recognition, the two face images need to be unified into face images of the same visual domain. In the embodiment of the present application, the two heterogeneous face images can be directly compared without the need to process the face images again.

[0059] See also Figure 1 , a process of the face recognition model training method in the embodiment of the present application includes:

[0060] 101. Obtaining heterogeneous face image pairs;

[0061] See also Figure 2At the beginning of training, it is necessary to select N pairs of heterogeneous face images from the training set, that is, select 2N face images, or select N pairs of face images. These N pairs of face images can include heterogeneous face image pairs, or can include face image pairs with different image attributes of the two face images. Specifically, the image attributes can include lighting conditions or shooting angles, which are not limited here. This embodiment is explained by selecting N pairs of heterogeneous face images. Each pair of heterogeneous faces in the N pairs of heterogeneous face images corresponds to a target face among N different faces, that is, the face image with sequence number S and the face image with sequence number N+S correspond to the same target face, S is any integer from 1 to N. It should be noted that the N pairs of heterogeneous face images can include multiple visual domains. For example, one pair of heterogeneous face images includes an optical face image of user A and a sketch face image of user A, and the other pair of heterogeneous face images includes an optical face image of user B and a near-infrared face image of user B. Please refer again Figure 2 For the sake of simplicity, this embodiment only takes heterogeneous face images in two visual domains, optical and sketch, and N equals 4 as an example for explanation. Figure 2 In the figure, “X” represents the identifier of the face image, the superscript of “X” represents the category of the visual domain, where “1” represents an optical face image, “2” represents a sketched face image, and the subscript of “X” represents the serial number of the face image.

[0062] 102. Obtaining a feature vector based on a heterogeneous face image pair;

[0063] After obtaining N pairs of heterogeneous face images, refer to Figure 3 , the two face images in each pair of heterogeneous face images can be input into the twin network with shared parameters respectively. The twin network can be composed of VGG16 or ResNet50, which is not limited here. For example, the face image with optical visual domain is input into one branch of the twin network, and the face image with sketch visual domain is input into the other branch of the twin network, and then the corresponding feature vector is obtained. Figure 3 In the figure, "P" represents the identifier of the feature vector, the subscript of "P" represents the identifier of the target face corresponding to the feature vector, and the superscript of "P" represents the identifier of the visual domain corresponding to the feature vector, where "1" represents an optical face image and "2" represents a sketched face image.

[0064] 103. Obtain a similarity matrix based on the eigenvector;

[0065] After obtaining the feature vectors corresponding to N pairs of heterogeneous face images, refer to Figure 4, the acquired feature vectors are combined in pairs to obtain N square feature vector combinations, that is, 16 feature vector combinations, and then a similarity matrix is obtained. The elements in the similarity matrix represent the distance parameter between the two combined feature vectors. The distance parameter can be a Euclidean distance parameter or a cosine distance parameter, which is not limited here. Furthermore, the elements on the diagonal of the similarity matrix represent the distance parameter between two feature vectors corresponding to the same target face but corresponding to different visual domains, and the elements on the off-diagonal represent the distance parameter between two feature vectors corresponding to different target faces and corresponding to different visual domains.

[0066] 104. Obtain loss parameters according to the similarity matrix;

[0067] After obtaining the similarity matrix, the loss parameters can be obtained according to the similarity matrix. Specifically, the loss parameters may include a symmetric loss parameter, a first discriminant loss parameter, and a second discriminant loss parameter, which are described below:

[0068] 1) Symmetric loss parameters

[0069] For two pairs of heterogeneous face images that are symmetrical about the diagonal of the similarity matrix, that is, corresponding to the same pair of target faces but with different combinations of visual domains, for example, one pair of heterogeneous face images is the optical face image of user A and the sketch face image of user B, and the other pair of heterogeneous face images is the sketch face image of user A and the optical face image of user B. When the face recognition model reaches an ideal state, the distance between the feature vectors corresponding to the two pairs of heterogeneous face images should be as small as possible. Therefore, it is necessary to train the face recognition model through a symmetric loss parameter. The symmetric loss parameter is D in the similarity matrix. ij Elements and D ji The sum of the squared differences of the elements of , where i is not equal to j.

[0070] 2) First discriminant loss parameter

[0071] For the elements on the diagonal of the similarity matrix, that is, the distance parameters of the feature vectors corresponding to two face images with the same target face but different visual domains, when the face recognition model reaches an ideal state, the distance parameters between the feature vectors corresponding to the two face images should be as small as possible. Therefore, it is necessary to train the face recognition model through the first discriminant loss parameter, which is D in the similarity matrix. mn The sum of the elements of , where m is equal to n.

[0072] 3) Second discriminant loss parameter

[0073] For the elements on the off-diagonal line of the similarity matrix, that is, the distance parameters of the feature vectors corresponding to two face images with different target faces and different visual domains, when the face recognition model reaches an ideal state, the distance parameters between the feature vectors corresponding to the two face images should be as large as possible. Therefore, it is necessary to train the face recognition model through the second discriminant loss parameter, which is the similarity matrix D ab The sum of the first N elements in sorted by numerical value from large to small, where a is greater than b.

[0074] 105. Train according to the loss parameters.

[0075] After obtaining the loss parameters, the face recognition model can be trained according to the loss parameters. Specifically, when the symmetric loss parameter converges to a first preset value, the first discriminant loss parameter converges to a second preset value, and the second discriminant loss parameter converges to a third preset value, the parameters corresponding to the face recognition model are obtained.

[0076] See also Figure 5 The following describes the face recognition method in the embodiment of the present application. A process of the face recognition method in the embodiment of the present application includes:

[0077] 501. Acquire a first facial image and a second facial image;

[0078] To recognize a face, it is necessary to first obtain two face images to be recognized, namely the first face image and the second face image. It should be noted that the first face image and the second face image are images with different image attributes. Specifically, the image attributes may include any one of the visual domain, lighting conditions and shooting angles. For example, the first face image may be an optical face image, and the second face image may be a near-infrared face image, or the first face image may be a face image at a first shooting angle, and the second face image may be a face image at another shooting angle. The specific details are not limited here.

[0079] 502. Obtain a first eigenvector and a second eigenvector;

[0080] After obtaining the first facial image and the second facial image, the first eigenvector corresponding to the first facial image and the second eigenvector corresponding to the second facial image can be obtained through the Siamese network.

[0081] 503. Obtain a distance parameter according to the first eigenvector and the second eigenvector;

[0082] After obtaining the first eigenvector and the second eigenvector, the distance parameter between the first eigenvector and the second eigenvector can be obtained by calculation. Specifically, the distance parameter can be Euclidean distance or cosine distance, which is not limited here.

[0083] 504. When the distance parameter is less than or equal to a preset value, it is determined that a matching relationship exists; when the distance parameter is greater than the preset value, it is determined that no matching relationship exists.

[0084] After obtaining the distance parameter, if the value of the distance parameter is less than or equal to the preset value, it is determined that the first face image and the second face image have a matching relationship, that is, they correspond to the same target face; if the value of the distance parameter is greater than the preset value, it is determined that the first face image and the second face image do not have a matching relationship.

[0085] In an embodiment of the present application, the corresponding feature vector can be directly obtained based on the facial image to be matched, and then compared to determine whether there is a matching relationship between the facial images to be matched. There is no need to process the facial image through a generator, thereby improving the efficiency of face recognition.

[0086] It should be noted that after the face recognition model is trained and put into use, the backend administrator can obtain the statistical recognition rate of the target face. When the recognition rate of the target face is lower than the preset value, the training set can be supplemented with heterogeneous face image pairs of the target face or face image pairs with different image attributes to train the face recognition model again. For details, please refer to Figure 6 , a process of retraining the face recognition model in an embodiment of the present application includes:

[0087] 601. Obtain a trained face recognition model;

[0088] Through the above Figure 1 The corresponding face recognition model training method obtains a trained face recognition model.

[0089] 602. Obtain the facial image to be recognized input by the user;

[0090] Get the two facial images to be recognized passed in by the user for subsequent recognition.

[0091] 603. Output recognition results;

[0092] Through the above Figure 5 The corresponding face recognition method recognizes the face image to be recognized and outputs the recognition result after obtaining the recognition result.

[0093] 604. Count the recognition rate of the target face;

[0094] The recognition rate of the target face can be counted based on the number of recognition times and displayed for the convenience of back-end management personnel to view.

[0095] 605. Determine whether the recognition rate of the target face is lower than a preset value;

[0096] After the recognition rate of the target face is counted, it can be determined whether the recognition rate of the target face is lower than a preset value. If not, return to step 602 and continue to recognize facial images input by other users. If so, execute step 606.

[0097] 606. The backend administrator adds the facial image corresponding to the target face to the training set.

[0098] When the recognition rate of a target face is lower than the preset value, the model needs to be trained for the target face. Specifically, the backend administrator can add a small amount of facial images corresponding to the target face to the training set, and then use the above Figure 1 The face recognition model training method in is used to train the face recognition model, and the details are not repeated here.

[0099] In the embodiment of the present application, the face recognition model can be trained according to the recognition rate of the target face, thereby improving the accuracy of face recognition.

[0100] Another face recognition model training method in the embodiment of the present application is described below. Figure 7 , a process of the face recognition model training method in the embodiment of the present application includes:

[0101] 701. Obtain N pairs of face images;

[0102] At the beginning of training, it is necessary to obtain N pairs of face images. These N pairs of face images include face image pairs corresponding to the same target face and face image pairs corresponding to different target faces. The N pairs of face images also include a first face image pair and a second face image pair. The first face image pair includes a face image of the first target face in a first image attribute and a face image of the second target face in a second image attribute. The second face image pair includes a face image of the second target face in a third image attribute and a face image of the first target face in a fourth image attribute. It should be noted that the image attribute can be any one of the visual domain, lighting conditions, and shooting angles. Among them, the first image attribute, the second image attribute, and the third image attribute And the fourth image attribute corresponds to four different image attributes, for example, the first face image pair includes the optical face image of user A and the sketch face image of user B, and the second face image pair includes the near-infrared face image of user A and the thermal infrared face image of user B, or, the first image attribute and the fourth image attribute correspond to different image attributes, the second image attribute and the third image attribute correspond to different image attributes, the first image attribute and the third image attribute correspond to the same image attribute, and the fourth image attribute and the second image attribute correspond to the same image attribute, for example, the first face image pair includes the optical face image of user A and the sketch face image of user B, and the second face image pair includes the sketch face image of user A and the optical face image of user B.

[0103] It should be noted that the above-mentioned first facial image pair and second facial image pair do not specifically refer to two pairs of facial images. As long as the two pairs of facial images meet the above relationship, they are all the first facial image pair and the second facial image pair.

[0104] 702. Obtain a symmetric loss parameter according to the first face image pair and the second face image pair;

[0105] After obtaining N pairs of face image pairs, a symmetric loss parameter can be obtained based on the first face image pair and the second face image pair in the N pairs of face image pairs. The symmetric loss parameter is the product of the square value of the difference between the distance parameter of the first face image pair and the distance parameter of the second face image pair and 1 / [N(N-1)]. Specifically, the distance parameter of the first face image pair is the distance parameter between the feature vectors of the two corresponding face images, and the distance parameter of the second face image pair is the distance parameter between the feature vectors of the two corresponding face images. The distance parameter can be a Euclidean distance parameter or a cosine distance parameter.

[0106] 703. Obtain contrast loss parameters based on N pairs of face images;

[0107] After obtaining N pairs of face images, contrast loss parameters can be obtained based on the N pairs of face images. The specific acquisition method will not be described here.

[0108] It should be noted that the embodiment of the present application does not limit the order of step 702 and step 703. Step 702 may be performed first and then step 703, or step 703 may be performed first and then step 702.

[0109] 704. Train the face recognition model according to the symmetric loss parameter and the contrast loss parameter.

[0110] After obtaining the symmetric loss parameters and the contrast loss parameters, the face recognition model can be trained according to the symmetric loss parameters and the contrast loss parameters. Specifically, the first face image pair and the second face image pair are both composed of a first target face and a second target face. The only difference is that the visual domains corresponding to the first target face and the second target face are different. Therefore, the distance parameter between the two face images of the first face image pair and the distance parameter between the two face images of the second face image pair should be as small as possible. Specifically, the distance parameter can be the Euclidean distance or the cosine distance. Therefore, when the symmetric loss parameter converges to a sufficiently small first preset value, when the contrast loss parameter also converges to the second preset value, it can be considered that the face recognition model has achieved the expected effect, and the corresponding parameters of the face recognition model can be obtained.

[0111] The following describes another face recognition model training method according to the embodiment of the present application. Figure 8 , a process of the face recognition model training method in the embodiment of the present application includes:

[0112] 801. Obtain N groups of face images;

[0113] At the beginning of training, N groups of facial images need to be obtained first, where N is an integer greater than 0. Each group of facial images in the N groups of facial images includes a first facial image, a second facial image, and a third facial image. The first facial image includes a facial image of the first target face in a first image attribute, the second facial image includes a facial image of the first target face in a second image attribute, and the third facial image includes a facial image of the second target face in a third image attribute. It should be noted that the image attribute may include any one of a visual domain, a lighting condition, and a shooting angle, wherein the third image attribute, the first image attribute, and the second image attribute are three different image attributes. For example, the first facial image may be an optical facial image of user A, the second facial image may be a sketch facial image of user A, and the third facial image may be a near-infrared facial image of user B. Alternatively, the third image attribute is the same image attribute as the first visual domain, and the first image attribute and the second image attribute are different image attributes. For example, the first facial image may be an optical facial image of user A, the second facial image may be a sketch facial image of user A, and the third facial image may be an optical facial image of user B.

[0114] 802. Obtain a symmetric loss parameter according to the first face image, the second face image, and the third face image;

[0115] After obtaining N groups of facial images, a symmetric loss parameter can be obtained based on the first facial image, the second facial image and the third facial image in the N groups of images. Specifically, the symmetric loss parameter is the sum of the difference between the first distance parameter and the second distance parameter, wherein the first distance parameter is the distance parameter between the feature vector of the first facial image and the feature vector of the third facial image, and the second distance parameter is the distance parameter between the feature vector of the second facial image and the feature vector of the third facial image. The distance parameter can be a Euclidean distance parameter or a cosine distance parameter, which is not limited here.

[0116] 803. Training the face recognition model according to the symmetric loss parameter;

[0117] After obtaining the symmetric loss parameters, the face recognition model can be trained according to the symmetric loss parameters. Specifically, for example, the first distance parameter is the distance parameter between the optical face image of user A and the optical face image of user B, and the second distance parameter is the distance parameter between the sketch face image of user A and the optical face image of user B. Among them, the first distance parameter and the second distance parameter both represent the difference between the face image of user A and the face image of user B. The difference is that the visual domains corresponding to the face images are different. Therefore, when the gap between the first distance parameter and the second distance parameter is small enough, it can be considered that the face recognition model has been trained to the expected effect. Therefore, when the symmetric loss parameter tends to a sufficiently small preset value, the parameters corresponding to the face recognition model can be obtained.

[0118] The following describes the face recognition model training device in the embodiment of the present application. Figure 9 The face recognition model training device in the embodiment of the present application includes an acquisition module 901 and a training module 902.

[0119] An acquisition module 901 is configured to acquire N pairs of heterogeneous face images, where each pair of the N pairs of heterogeneous face images corresponds to a target face among N different faces;

[0120] The acquisition module 901 is further configured to acquire N groups of feature vectors based on N pairs of heterogeneous face images, where each group of feature vectors includes two feature vectors.

[0121] The acquisition module 901 is further configured to acquire a similarity matrix based on the N sets of eigenvectors, wherein the elements on the diagonal of the similarity matrix are distance parameters between two eigenvectors corresponding to the same target face but corresponding to different visual domains, and the elements on the off-diagonal of the similarity matrix are distance parameters between two eigenvectors corresponding to different target faces;

[0122] The acquisition module 901 is also used to obtain the loss parameters of the similarity matrix. The loss parameters include symmetric loss parameters. The symmetric loss parameters are D ij Elements and D ji The sum of the squares of the differences of the elements of , where i is not equal to j;

[0123] The training module 902 is used to perform training according to the loss parameters.

[0124] Based on the above Figure 9 Based on the face recognition model training device 900, the loss parameter also includes a first discriminant loss parameter and a second discriminant loss parameter. The first discriminant loss parameter is D in the similarity matrix. mn The sum of the elements of , where m is equal to n, and the second discriminant loss parameter is the similarity matrix D jkThe sum of the elements of , where j is greater than k.

[0125] Furthermore, the second discriminant loss parameter is D in the similarity matrix ab The sum of the first N elements in sorted by numerical value from large to small, where a is greater than b.

[0126] The training module 902 is specifically used to obtain parameters corresponding to the face recognition model when the symmetric loss parameter converges to a first preset value, the first discriminant loss parameter converges to a second preset value, and the second discriminant loss parameter converges to a third preset value.

[0127] The face recognition device in the embodiment of the present application is described below. Figure 10 The face recognition device in the embodiment of the present application includes an acquisition module 1001 and a determination module 1002.

[0128] An acquisition module 1001 is configured to acquire a first facial image and a second facial image, wherein the first facial image and the second facial image correspond to different visual domains, or the first facial image and the second facial image correspond to the same visual domain. The computer device may be based on a facial recognition model obtained by training the computer device;

[0129] The acquisition module 1001 is further configured to acquire a first feature vector based on the first facial image and a second feature vector based on the second facial image;

[0130] The acquisition module 1001 is further configured to acquire a distance parameter between the first eigenvector and the second eigenvector, where the distance parameter includes a Euclidean distance parameter or a cosine distance parameter;

[0131] The determination module 1002 is configured to determine whether a matching relationship exists between the first face image and the second face image when the distance parameter is lower than a preset value.

[0132] The following describes another face recognition model training device in the embodiment of the present application. Figure 11 In an embodiment of the present application, another face recognition model training device includes an acquisition module 1101 and a training module 1102:

[0133] The acquisition module 1101 is configured to acquire N pairs of face image pairs, where N is an integer greater than or equal to 2, and the N pairs of face image pairs include a first face image pair and a second face image pair, wherein the first face image pair includes a face image of a first target face in a first image attribute and a face image of a second target face in a second image attribute, and the second face image pair includes a face image of the second target face in a third image attribute and a face image of the first target face in a fourth image attribute. Figure 7 The corresponding embodiments are similar and will not be described again here;

[0134] The acquisition module 1101 is further configured to acquire a symmetric loss parameter based on the first face image pair and the second face image pair, where the symmetric loss parameter is the product of the square of the difference between the distance parameter of the first face image pair and the distance parameter of the second face image pair and 1 / N(N-1);

[0135] The training module 1102 is used to train the face recognition model according to the symmetric loss parameters.

[0136] In the above Figure 11 On the basis of another corresponding face recognition model training device 1100, the acquisition module 1101 is further used to obtain contrast loss parameters according to N pairs of face images;

[0137] The training module 1102 is further used to train the face recognition model according to the symmetric loss parameter and the contrast loss parameter.

[0138] The training module 1102 is specifically used to obtain parameters corresponding to the face recognition model when the symmetric loss parameter converges to a first preset value and the contrast loss parameter converges to a second preset value.

[0139] The following describes another face recognition model training device in the embodiment of the present application. Figure 12 In another embodiment of the present application, another face recognition model training device includes an acquisition module 1201 and a training module 1202:

[0140] An acquisition module 1201 is configured to acquire N groups of facial images, where N is an integer greater than 0, and each group of facial images in the N groups of facial images includes a first facial image, a second facial image, and a third facial image, wherein the first facial image includes a facial image of a first target face in a first image attribute, the second facial image includes a facial image of the first target face in a second image attribute, and the third facial image includes a facial image of the second target face in a third image attribute, wherein the third image attribute, the first image attribute, and the second image attribute are three different image attributes, or the third image attribute and the first image attribute are the same image attribute, and the first image attribute and the second image attribute are different image attributes;

[0141] The acquisition module 1201 is further configured to acquire a symmetric loss parameter based on the first face image, the second face image, and the third face image, where the symmetric loss parameter is the sum of the differences between the first distance parameter and the second distance parameter, where the first distance parameter is the distance parameter between the first face image and the third face image, and the second distance parameter is the distance parameter between the second face image and the third face image;

[0142] The training module 1202 is used to train the face recognition model according to the symmetric loss parameters.

[0143] In the above Figure 12 Based on another corresponding face recognition model training device, the training module 1202 is specifically used to obtain relevant parameters of the face recognition model when the symmetric loss parameter converges to a preset value.

[0144] Figure 13 13 is a schematic diagram of the structure of a computer device provided in an embodiment of the present application. The computer device 1300 may include one or more central processing units (CPU) 1301 and a memory 1305. The memory 1305 stores one or more application programs or data.

[0145] Memory 1305 may be volatile or persistent storage. The program stored in memory 1305 may include one or more modules, each of which may include a series of instruction operations on the server. Furthermore, CPU 1301 may be configured to communicate with memory 1305 and execute the series of instruction operations in memory 1305 on server 1300.

[0146] The server 1300 may also include one or more power supplies 1302, one or more wired or wireless network interfaces 1303, one or more input and output interfaces 1304, and / or one or more operating systems, such as Windows Server™, Mac OS X™, Unix™, Linux™, FreeBSD™, etc.

[0147] The CPU 1301 can execute the aforementioned Figure 1 、 Figure 5 、 Figure 6 、 Figure 7 as well as Figure 8 The operations in the illustrated embodiment will not be described in detail here.

[0148] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

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

[0150] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0151] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0152] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, read-only memory), random access memory (RAM, random access memory), disk or optical disk, and other media that can store program code.

Claims

1. A face recognition model training method, characterized in that: include: Acquire a heterogeneous face image pair set, the heterogeneous face image pair set including N pairs of heterogeneous face images, each pair of heterogeneous face images in the N pairs of heterogeneous face images corresponding to a target face among N different faces; Obtaining N groups of feature vectors according to the N pairs of heterogeneous face images, each group of feature vectors in the N groups of feature vectors includes two feature vectors; Obtaining a similarity matrix based on the N groups of eigenvectors, wherein the elements on the diagonal of the similarity matrix are distance parameters between two eigenvectors corresponding to the same target face and corresponding to different visual domains, and the elements on the off-diagonal of the similarity matrix are distance parameters between two eigenvectors corresponding to different target faces and corresponding to different visual domains; Obtain the loss parameter of the similarity matrix, the loss parameter includes a symmetric loss parameter, and the symmetric loss parameter is D in the similarity matrix ij Elements and D ji The sum of the squares of the differences of the elements of , wherein the i is not equal to the j; The face recognition model is trained according to the loss parameter.

2. The method according to claim 1, characterized in that The loss parameters also include a first discriminant loss parameter and a second discriminant loss parameter. The first discriminant loss parameter is D in the similarity matrix. mn The sum of the elements of , wherein m is equal to n, and the second discriminant loss parameter is D in the similarity matrix jk The sum of the elements of , where j is greater than k.

3. The method according to claim 2, characterized in that The second discriminant loss parameter is D in the similarity matrix ab The sum of the first N elements in the elements of sorted from large to small in numerical value, where a is greater than b.

4. The method according to any one of claims 2 to 3, characterized in that The training according to the loss parameter includes: When the symmetric loss parameter converges to a first preset value, the first discriminant loss parameter converges to a second preset value, and the second discriminant loss parameter converges to a third preset value, the parameters corresponding to the face recognition model are obtained.

5. A face recognition model training method, characterized in that: include: Obtaining N pairs of facial image pairs, where N is an integer greater than or equal to 2, the N pairs of facial image pairs including a first facial image pair and a second facial image pair, the first facial image pair including a facial image of a first target face in a first image attribute and a facial image of a second target face in a second image attribute, the second facial image pair including a facial image of the second target face in a third image attribute and a facial image of the first target face in a fourth image attribute, the image attributes including any one of a visual domain, a lighting condition, and a shooting angle, the first image attribute, the second image attribute, the third image attribute, and the fourth image attribute corresponding to four different image attributes, or the first image attribute and the fourth image attribute corresponding to different image attributes, the second image attribute and the third image attribute corresponding to different image attributes, the first image attribute and the third image attribute corresponding to the same image attribute, and the fourth image attribute and the second image attribute corresponding to the same image attribute; Obtaining a symmetric loss parameter according to the first face image pair and the second face image pair, the symmetric loss parameter being the product of a square value of a difference between a distance parameter of the first face image pair and a distance parameter of the second face image pair and 1 / [N(N-1)]; The face recognition model is trained according to the symmetric loss parameters.

6. The face recognition model training method according to claim 5, characterized in that: After acquiring N pairs of face images and before training the face recognition model according to the symmetric loss parameter, the method further includes: Obtaining a contrast loss parameter according to the N pairs of face images; The training of the face recognition model according to the symmetric loss parameter includes: The face recognition model is trained according to the symmetric loss parameter and the contrast loss parameter.

7. The face recognition model training method according to claim 6, characterized in that: The training of the face recognition model according to the symmetric loss parameter and the contrast loss parameter includes: When the symmetric loss parameter converges to a first preset value and the contrast loss parameter converges to a second preset value, parameters corresponding to the face recognition model are obtained.

8. A face recognition model training method, characterized in that: include: Obtaining N groups of facial images, where N is an integer greater than 0, each group of facial images in the N groups of facial images includes a first facial image, a second facial image, and a third facial image, the first facial image including a facial image of a first target face in a first image attribute, the second facial image including a facial image of the first target face in a second image attribute, and the third facial image including a facial image of the second target face in a third image attribute, wherein the third image attribute, the first image attribute, and the second image attribute are three different image attributes, and the image attributes include any one of a visual domain, a lighting condition, and a shooting angle; Alternatively, the third image attribute and the first image attribute are the same image attribute, and the first image attribute and the second image attribute are different image attributes; Obtaining a symmetric loss parameter based on the first facial image, the second facial image, and the third facial image, the symmetric loss parameter being the sum of differences between a first distance parameter and a second distance parameter, the first distance parameter being the distance parameter between the first facial image and the third facial image, and the second distance parameter being the distance parameter between the second facial image and the third facial image; The face recognition model is trained according to the symmetric loss parameters.

9. The face recognition model training method according to claim 8, characterized in that: The training of the face recognition model according to the symmetric loss parameter includes: When the symmetric loss parameter converges to a preset value, relevant parameters of the face recognition model are obtained.

10. A face recognition model training device, characterized in that: include: an acquisition module, configured to acquire a set of heterogeneous face image pairs, wherein the set of heterogeneous face image pairs includes N pairs of heterogeneous face images, and each pair of heterogeneous face images in the N pairs of heterogeneous face images corresponds to a target face among N different faces; The acquisition module is further configured to acquire N groups of feature vectors based on the N pairs of heterogeneous facial images, wherein each group of feature vectors in the N groups of feature vectors includes two feature vectors; The acquisition module is further configured to acquire a similarity matrix based on the N groups of eigenvectors, wherein the elements on the diagonal of the similarity matrix are distance parameters between two eigenvectors corresponding to the same target face and corresponding to different visual domains, and the elements on the off-diagonal of the similarity matrix are distance parameters between two eigenvectors corresponding to different target faces; The acquisition module is further used to obtain the loss parameter of the similarity matrix, wherein the loss parameter includes a symmetric loss parameter, which is the D ij Elements and D ji The sum of the squares of the differences of the elements of , wherein the i is not equal to the j; A training module is used to perform training according to the loss parameter.

11. A face recognition model training device, characterized in that: include: an acquisition module, configured to acquire N groups of facial images, where N is an integer greater than 0, each group of facial images in the N groups of facial images including a first facial image, a second facial image, and a third facial image, wherein the first facial image includes a facial image of a first target face in a first image attribute, the second facial image includes a facial image of the first target face in a second image attribute, and the third facial image includes a facial image of the second target face in a third image attribute, wherein the third image attribute, the first image attribute, and the second image attribute are three different image attributes, and the image attributes include any one of a visual domain, a lighting condition, and a shooting angle; Alternatively, the third image attribute and the first image attribute are the same image attribute, and the first image attribute and the second image attribute are different image attributes; The acquisition module is further configured to acquire a symmetric loss parameter based on the first facial image, the second facial image, and the third facial image, the symmetric loss parameter being the sum of differences between a first distance parameter and a second distance parameter, the first distance parameter being the distance parameter between the first facial image and the third facial image, and the second distance parameter being the distance parameter between the second facial image and the third facial image; A training module is used to train the face recognition model according to the symmetric loss parameters.

12. A computer device, characterized in that: include: Processor, memory, input and output devices, and bus; The processor, memory, and input and output devices are connected to the bus; The processor is configured to execute the method according to any one of claims 1 to 4.

13. A computer device, characterized in that: include: Processor, memory, input and output devices, and bus; The processor, memory, and input and output devices are connected to the bus; The processor is configured to execute the method according to any one of claims 5 to 7.

14. A computer device, characterized in that: include: Processor, memory, input and output devices, and bus; The processor, memory, and input and output devices are connected to the bus; The processor is configured to execute the method according to claim 8 or 9.

Citation Information

Patent Citations

  • Heterogeneous face recognition model training method, face recognition method and related devices

    CN110781856A

  • Training method and device of face recognition model

    CN111666925A