Face recognition method and device, electronic device and computer-readable storage medium
By generating and using unobstructed face images to generate occluded face images as training data, and optimizing model parameters with loss function, the training data problem of face recognition model wearing masks is solved, and the robustness and recognition accuracy of the model are improved.
Patent Information
- Application Number
- CN202110080991.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-01-21
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2041-01-21
AI Technical Summary
In the prior art, training data of the face recognition model wearing a mask is difficult to obtain, and the method based on local feature extraction ignores the full face information, resulting in low recognition accuracy.
The masked face image is generated by unobstructed face image as training data, and the masked face image is generated by using data augmentation and affine transformation. The model parameters are optimized in combination with classification and comparison loss functions to improve the robustness of the model.
It effectively solves the problem of difficult to obtain training data, and improves the robustness and recognition accuracy of the face recognition model wearing a mask.
Smart Images

Figure CN114091502B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of image processing technology, and in particular to a face recognition method, a face recognition device, an electronic device, and a computer-readable storage medium. Background Art
[0002] With the development of computer technology, image processing technology has been applied to more and more fields, such as face recognition. Face recognition is a biometric technology that identifies a person based on their facial features.
[0003] With more and more people wearing masks, the use of facial recognition based on masked faces is increasing. Unlike regular facial recognition, facial recognition with masks often involves comparing an on-site image of a masked face with a database of ID photos of the person without a mask to determine if they are the same person.
[0004] It should be noted that the information disclosed in the above background technology section is only used to enhance the understanding of the background of the present disclosure, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the Invention
[0005] The purpose of the present disclosure is to provide a face recognition method, a face recognition device, an electronic device and a computer-readable storage medium, thereby overcoming, at least to a certain extent, the problem in the prior art that only local face features can be extracted when extracting features of the human eye for face recognition, and that it is difficult to obtain training data for a face model wearing a mask when performing face recognition based on a face model wearing a mask.
[0006] Other features and advantages of the present disclosure will become apparent from the following detailed description, or may be learned in part by practice of the present disclosure.
[0007] According to a first aspect of the present disclosure, a face recognition method is provided, comprising: obtaining a face image to be recognized; obtaining a pre-trained target face recognition model; the target face recognition model is trained using an unobstructed face image and an occluded face image generated based on the unobstructed face image; and the target face recognition model performs face recognition on the face image to be recognized.
[0008] Optionally, the target face recognition model is trained in the following manner: obtaining a set of unobstructed face images, determining an unobstructed face image from the set of unobstructed face images, and generating an occluded face image corresponding to the unobstructed face image; training the face recognition model to be trained with the unobstructed face images and the occluded face images, and determining the classification loss function of the face recognition model to be trained; determining the first face feature of the unobstructed face image with the first face recognition model, determining the second face feature of the unobstructed face image with the face recognition model to be trained, and determining the third face feature of the occluded face image with the face recognition model to be trained; determining the contrast loss function between the first face recognition model and the face recognition model to be trained based on the first face feature, the second face feature and the third face feature; updating the model parameters of the face recognition model to be trained based on the classification loss function and the contrast loss function to obtain the target face recognition model.
[0009] Optionally, generating an occluded face image corresponding to the unobstructed face image includes: performing data augmentation processing on the unobstructed face image to obtain an augmented face image; determining facial key points of the augmented face image, and selecting an initial occluded image from an occluded image library based on the facial key points of the augmented face image; determining augmented image information of the augmented face image, and adjusting the initial occluded image based on the augmented image information to obtain an occluded image; determining the occluded coverage area of the unobstructed face image, and adding the occluded image to the occluded coverage area through affine transformation processing to generate an occluded face image.
[0010] Optionally, determining the first facial feature of the unobstructed facial image through the first facial recognition model includes: performing face detection processing on the unobstructed facial image to determine the facial key points of the unobstructed facial image; performing image cropping processing on the unobstructed facial image according to the facial key points of the unobstructed facial image to generate an initial feature map of the unobstructed facial image; and inputting the initial feature map into the first facial recognition model to obtain the first facial feature.
[0011] Optionally, a contrast loss function between the first face recognition model and the face recognition model to be trained is determined based on the first facial feature, the second facial feature and the third facial feature, including: determining a first unobstructed face image and a corresponding first occluded face image; determining a positive pair distance based on the first facial feature of the first unobstructed face image, the second facial feature of the first unobstructed face image and the third facial feature of the first occluded face image; determining an unobstructed face image in the unobstructed face image set other than the first unobstructed face image as a second unobstructed face image, and generating a corresponding second occluded face image based on the second unobstructed face image; determining a negative pair distance based on the second facial feature of the first unobstructed face image, the third facial feature of the first occluded face image and the first facial feature of the second unobstructed face image; and determining a contrast loss function based on the positive pair distance and the negative pair distance.
[0012] Optionally, the positive example pair distance is determined based on the first facial feature of the first unobstructed facial image, the second facial feature of the first unobstructed facial image, and the third facial feature of the first occluded facial image, including: determining the feature distance between the first facial feature of the first unobstructed facial image and the second facial feature of the first unobstructed facial image as the first feature distance; determining the feature distance between the first facial feature of the first unobstructed facial image and the third facial feature of the first occluded facial image as the second feature distance; and determining the positive example pair distance based on the first feature distance and the second feature distance.
[0013] Optionally, determining the negative example pair distance based on the second facial feature of the first unobstructed facial image, the third facial feature of the first occluded facial image, and the first facial feature of the second unobstructed facial image includes: determining the negative example pair feature distance corresponding to the first unobstructed facial image based on the second facial feature of the first unobstructed facial image and the first facial feature of the second unobstructed facial image; determining the negative example pair feature distance corresponding to the first occluded facial image based on the third facial feature of the first occluded facial image and the first facial feature of the second unobstructed facial image; determining the negative example pair distance based on the negative example pair feature distance corresponding to the first unobstructed facial image and the negative example pair feature distance corresponding to the first occluded facial image.
[0014] According to a second aspect of the present disclosure, a face recognition device is provided, comprising: an image acquisition module for acquiring a face image to be recognized; a model acquisition module for acquiring a pre-trained target face recognition model; the target face recognition model is trained using unobstructed face images and occluded face images generated based on the unobstructed face images; and a face recognition module for performing face recognition on the face image to be recognized using the target face recognition model.
[0015] Optionally, the face recognition device also includes a model training module, which is used to obtain a set of unobstructed face images, determine unobstructed face images from the set of unobstructed face images, and generate occluded face images corresponding to the unobstructed face images; train the face recognition model to be trained using the unobstructed face images and occluded face images to determine the classification loss function of the face recognition model to be trained; determine the first face feature of the unobstructed face image using the first face recognition model, determine the second face feature of the unobstructed face image using the face recognition model to be trained, and determine the third face feature of the occluded face image using the face recognition model to be trained; determine the contrast loss function between the first face recognition model and the face recognition model to be trained based on the first face feature, the second face feature and the third face feature; update the model parameters of the face recognition model to be trained based on the classification loss function and the contrast loss function to obtain the target face recognition model.
[0016] Optionally, the model training module includes an image generation unit, which is used to perform data augmentation processing on the unobstructed face image to obtain an augmented face image; determine the facial key points of the augmented face image, and select an initial occluded image from the occluded image library based on the facial key points of the augmented face image; determine the augmented image information of the augmented face image, and adjust the initial occluded image based on the augmented image information to obtain an occluded image; determine the occluded coverage area of the unobstructed face image, and add the occluded image to the occluded coverage area through affine transformation processing to generate an occluded face image.
[0017] Optionally, the model training module also includes a feature extraction unit, which is used to perform face detection processing on the unobstructed face image to determine the facial key points of the unobstructed face image; perform image cropping processing on the unobstructed face image according to the facial key points of the unobstructed face image to generate an initial feature map of the unobstructed face image; and input the initial feature map into the first face recognition model to obtain the first facial feature.
[0018] Optionally, the model training module also includes a loss function determination unit, which is used to determine the first unobstructed face image and the corresponding first occluded face image; determine the positive example pair distance based on the first facial feature of the first unobstructed face image, the second facial feature of the first unobstructed face image and the third facial feature of the first occluded face image; determine the unobstructed face images other than the first unobstructed face image in the unobstructed face image set as the second unobstructed face image, and generate the corresponding second occluded face image based on the second unobstructed face image; determine the negative example pair distance based on the second facial feature of the first unobstructed face image, the third facial feature of the first occluded face image and the first facial feature of the second unobstructed face image; and determine the contrast loss function based on the positive example pair distance and the negative example pair distance.
[0019] Optionally, the loss function determination unit includes a positive example pair distance determination subunit, which is used to determine the feature distance between the first facial feature of the first unobstructed facial image and the second facial feature of the first unobstructed facial image as the first feature distance; determine the feature distance between the first facial feature of the first unobstructed facial image and the third facial feature of the first occluded facial image as the second feature distance; and determine the positive example pair distance based on the first feature distance and the second feature distance.
[0020] Optionally, the loss function determination unit also includes a negative example pair distance determination subunit, which is used to determine the negative example pair feature distance corresponding to the first unobstructed face image based on the second facial feature of the first unobstructed face image and the first facial feature of the second unobstructed face image; determine the negative example pair feature distance corresponding to the first occluded face image based on the third facial feature of the first occluded face image and the first facial feature of the second unobstructed face image; and determine the negative example pair distance based on the negative example pair feature distance corresponding to the first unobstructed face image and the negative example pair feature distance corresponding to the first occluded face image.
[0021] According to a third aspect of the present disclosure, an electronic device is provided, comprising: a processor; and a memory, wherein the memory stores computer-readable instructions, and when the computer-readable instructions are executed by the processor, the face recognition method according to any one of the above items is implemented.
[0022] According to a fourth aspect of the present disclosure, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the face recognition method according to any one of the above items is implemented.
[0023] The technical solution provided by the present disclosure may have the following beneficial effects:
[0024] The face recognition method in the exemplary embodiment of the present disclosure obtains a face image to be recognized; obtains a pre-trained target face recognition model; the target face recognition model is trained using an unobstructed face image and an occluded face image generated based on the unobstructed face image; and the target face recognition model performs face recognition on the face image to be recognized. On the one hand, using the unobstructed face image and the occluded face image generated based on the unobstructed face image as training data for the target face recognition model can solve the problem that existing model training data is difficult to obtain. On the other hand, using the unobstructed face image and the corresponding generated occluded face image to train the target face recognition model can greatly improve the robustness of the target face recognition model.
[0025] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0026] The accompanying drawings are incorporated into and constitute a part of the specification, illustrate embodiments consistent with the present disclosure, and together with the specification, are used to explain the principles of the present disclosure. Obviously, the drawings described below are only some embodiments of the present disclosure, and those skilled in the art can derive other drawings based on these drawings without inventive effort. In the drawings:
[0027] Figure 1 Schematically shows a flow chart of a face recognition method according to an exemplary embodiment of the present disclosure;
[0028] Figure 2 Schematically illustrates a flow chart of training a target face recognition model according to an exemplary embodiment of the present disclosure;
[0029] Figure 3 Schematically shows a flow chart of generating an occluded face image according to an exemplary embodiment of the present disclosure;
[0030] Figure 4 Schematically illustrates a mask template image added to an unobstructed face image according to an exemplary embodiment of the present disclosure;
[0031] Figure 5 Schematically illustrates a process diagram of extracting facial features by a first face recognition model according to an exemplary embodiment of the present disclosure;
[0032] Figure 6 A diagram schematically illustrates a process of training a target face recognition model by online generating occluded face images according to an exemplary embodiment of the present disclosure;
[0033] Figure 7 Schematically shows a block diagram of a face recognition device according to an exemplary embodiment of the present disclosure;
[0034] Figure 8 A block diagram schematically illustrates an electronic device according to an exemplary embodiment of the present disclosure;
[0035] Figure 9 A schematic diagram schematically illustrates a computer-readable storage medium according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0036] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be embodied in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete and will fully convey the concepts of the example embodiments to those skilled in the art. Like reference numerals in the drawings represent like or similar parts, and thus repetitive description thereof will be omitted.
[0037] In addition, the described features, structures or characteristics may be combined in any suitable manner in one or more embodiments. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present disclosure. However, those skilled in the art will appreciate that the technical solutions of the present disclosure can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. can be adopted. In other cases, well-known structures, methods, devices, implementations, materials or operations are not shown or described in detail to avoid obscuring various aspects of the present disclosure.
[0038] The blocks shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically separate entities. Specifically, these functional entities may be implemented in software, or in one or more software-hardened modules, or in different networks and / or processor devices and / or microcontroller devices.
[0039] Face recognition for people wearing masks differs from regular face recognition. Mask recognition often involves comparing an on-site image of a person wearing a mask with a database of ID photos of the person without a mask to determine if they are the same person. Training a face recognition model for people wearing masks requires both normal face images and images of the same person wearing a mask. Currently, face recognition for people wearing masks can be performed using the following methods.
[0040] (1) A local feature extraction module is added to the traditional full-face feature extraction network to extract features at the eye, making the overall recognition more inclined to learn eye features, thereby enhancing the accuracy of eye feature recognition. This method also proposes a new incremental loss function that retains a certain amount of features extracted from all images within a category, achieving stricter eye feature extraction constraints and achieving accurate distinction.
[0041] (2) Using images from the Asian face image set, crop the images above the nose bridge, including the eyes and forehead, as a training dataset for face recognition of people wearing masks. This training dataset is then used to train a face recognition model for people wearing masks, which is then deployed and used.
[0042] (3) The face recognition images of the person wearing a mask and the face recognition images of the person not wearing a mask are input to the first basic unit, and then their output is continuously input to the current attention module. The image features output by the current basic unit are self-weighted by the current attention module to obtain image features. This feature is passed to the subsequent basic units. After obtaining the final image features, the model is trained and then the next user's face image is passed on for training until the training converges.
[0043] Among them, method (1) and method (2) mainly use the eye recognition model as a mask-wearing face recognition model or as the main mask-wearing face recognition model. This method ignores information such as facial contours. In addition, in the mask-wearing face recognition scenario, the base image is often also a face image without a mask, which has the conditions for extracting the full face features. However, the eye recognition model can only use the local information of the image. When performing face recognition through method (3), it is necessary to collect both the mask-wearing face image and the non-mask face image of the same person. However, such images are extremely difficult to collect. So far, there is still no large-scale public mask-wearing face dataset. Even for face datasets collected on site, the pictures of the same person collected at the same time are either wearing a mask or not wearing a mask. It is almost impossible to collect both the mask-wearing face image and the non-mask face image of the same person at the same time.
[0044] Based on this, in this example embodiment, a face recognition method is first provided. The face recognition method of the present disclosure can be implemented using a server, or the method described in the present disclosure can be implemented using a terminal device. The terminals described in the present disclosure may include mobile terminals such as mobile phones, tablet computers, laptops, PDAs, personal digital assistants (PDAs), navigation devices, wearable devices, etc., as well as fixed terminals such as desktop computers. Figure 1 The following schematically illustrates a flow chart of a face recognition method according to some embodiments of the present disclosure. Figure 1 , the face recognition method may include the following steps:
[0045] Step S110: Obtain a face image to be recognized.
[0046] Step S120, obtaining a pre-trained target face recognition model; the target face recognition model is trained by using unobstructed face images and occluded face images generated based on the unobstructed face images.
[0047] Step S130: The target face recognition model performs face recognition on the face image to be recognized.
[0048] The face recognition method of this example embodiment uses unobstructed face images and occluded face images generated from them as training data for the target face recognition model, resolving the difficulty in obtaining existing model training data. Furthermore, using unobstructed face images and the corresponding generated occluded face images to train the target face recognition model significantly improves its robustness.
[0049] The face recognition method in this exemplary embodiment will be further described below.
[0050] In step S110 , a face image to be recognized is obtained.
[0051] In some exemplary embodiments of the present disclosure, the facial image to be identified may be a facial image to be processed for facial recognition. The facial image to be identified may be a normal, unobstructed facial image, or an occluded facial image. Among them, an unobstructed facial image may be a facial image whose facial information is not obstructed, such as the eyes, nose, mouth and other key facial positions are not obstructed. An occluded facial image may be an image whose facial information is partially obstructed, such as the nose, mouth and other key facial positions are obstructed. It is understandable that a facial image of a person wearing a mask may be an occluded facial image, and an occluded facial image may also be a facial image in which the facial area is obstructed by other means such as a gauze scarf, and the present disclosure does not make any special limitation on this.
[0052] Obtain a facial image of the person to be identified and perform facial recognition processing on the facial image. The facial image to be identified can be acquired by: capturing a face in real time using an image acquisition device; or it can be a pre-generated facial image. For occluded facial images, this disclosure primarily uses facial images of people wearing masks as an example.
[0053] In step S120, a pre-trained target face recognition model is obtained; the target face recognition model is trained by using unobstructed face images and occluded face images generated based on the unobstructed face images.
[0054] In some exemplary embodiments of the present disclosure, the target face recognition model may be a face recognition model that performs face recognition processing on a face image to be recognized.
[0055] When an unobstructed face image is acquired, an occluded face image corresponding to the unobstructed face image can be generated. The model is trained using the unobstructed and occluded face images as training data to obtain the target face recognition model. Since it is difficult to simultaneously acquire both unobstructed and occluded face images of the same person, using the unobstructed face image and the corresponding occluded face image generated from the unobstructed face image as the model training data for the target face recognition model can effectively address the difficulty in acquiring model training data.
[0056] According to some exemplary embodiments of the present disclosure, a target face recognition model is trained in the following manner: obtaining a set of unobstructed face images, determining an unobstructed face image from the set of unobstructed face images, and generating an occluded face image corresponding to the unobstructed face image; training the face recognition model to be trained with the unobstructed face image and the occluded face image to determine the classification loss function of the face recognition model to be trained; determining the first face feature of the unobstructed face image with the first face recognition model, determining the second face feature of the unobstructed face image with the face recognition model to be trained, and determining the third face feature of the occluded face image with the face recognition model to be trained; determining the contrast loss function between the first face recognition model and the face recognition model to be trained based on the first face feature, the second face feature and the third face feature; updating the model parameters of the face recognition model to be trained based on the classification loss function and the contrast loss function to obtain the target face recognition model.
[0057] The unobstructed face image set may be a set of multiple unobstructed face images. The face recognition model to be trained may be an initially constructed face recognition model. The classification loss function may be a loss function determined when the face recognition model to be trained performs face recognition on both occluded and unobstructed face images. The classification loss function may be used to measure the degree of inconsistency between the true value and the predicted value output by the model. The first face recognition model may be a commonly used ordinary face recognition model, a face recognition model obtained using only unobstructed face images as training data.
[0058] The first facial feature may be a facial feature obtained by extracting features from an unobstructed facial image using a first facial recognition model. The second facial feature may be a facial feature obtained by extracting features from an unobstructed facial image using a facial recognition model to be trained. The third facial feature may be a facial feature obtained by extracting features from an occluded facial image using a facial recognition model to be trained. The contrast loss function may be a loss function determined when facial recognition is performed using the first facial recognition model and the facial recognition model to be trained, respectively. The contrast loss function may be used to enhance the recognition accuracy of the predicted value and the corresponding true value of the facial recognition model to be trained for the occluded facial image. The model parameters may be relevant parameters of the facial recognition model to be trained. For example, the model parameters may include weights and bias values in a neural network.
[0059] refer to Figure 2 , Figure 2 The flowchart of training a target face recognition model according to an exemplary embodiment of the present disclosure is schematically shown.
[0060] In step S210, a set of unobstructed facial images is obtained. The set of unobstructed facial images may include a large number of unobstructed facial images of different people. Each image of each person has a corresponding identity document (ID). The identity document may be an identifier used to distinguish the identity information of different people, for example, an ID number. Each time the face recognition model to be trained is trained, a certain amount of unobstructed facial images (i.e., data sampling) may be selected from the set of unobstructed facial images. For example, the sampling data volume (i.e., batch size) of the sampled images may be determined based on the device parameters of the device used to train the model. For example, the sampling data volume may be determined based on the size of the machine's video memory. For example, the sampling data volume may be determined to be 128, 256, 512, etc. The ID corresponding to the data collected during each data sampling is different. For example, if the sampling data volume is 128, 128 IDs are selected from the set of unobstructed facial images, and one image is randomly selected from the 128 IDs to form the training batch. In other words, unobstructed facial images are determined from the set of unobstructed facial images. After the unobstructed face image is determined, an obstructed face image corresponding to the unobstructed face image may be generated.
[0061] According to some exemplary embodiments of the present disclosure, data augmentation processing is performed on an unobstructed facial image to obtain an augmented facial image; facial key points of the augmented facial image are determined, and an initial occluded image is selected from an occluded image library based on the facial key points of the augmented facial image; augmented image information of the augmented facial image is determined, and the initial occluded image is adjusted based on the augmented image information to obtain an occluded image; an occluded coverage area of the unobstructed facial image is determined, and the occluded image is added to the occluded coverage area through affine transformation processing to generate an occluded facial image.
[0062] In which, the data augmentation processing can be a process of performing random cropping, image brightness adjustment, and random flipping on the unobstructed face image. The augmented face image can be a face image obtained by performing data augmentation processing on the unobstructed face image. Facial key points can be points used to calibrate facial key information during face detection. The occluded image library can be a database that stores initial occluded images. For example, the occluded image library can be a mask image library. The initial occluded image can be an occluded image stored in the occluded image library, such as a mask image. The occluded image can be an image obtained by adjusting the initial occluded image based on the augmented image information of the augmented face image. The occluded coverage area can be the area where the unobstructed face image is occluded.
[0063] refer to Figure 3 , Figure 3The flowchart of generating an occluded face image according to an exemplary embodiment of the present disclosure is schematically shown. In step S310, after obtaining the unobstructed face image, the unobstructed face image can be subjected to random cropping, image brightness adjustment, random flipping and other related data augmentation processing to obtain an augmented face image. In step S320, after obtaining the augmented face image, key point detection is performed on the augmented face image to obtain facial key points. An initial mask image (i.e., mask template) is randomly selected from the occluded image library based on the facial key points. Reference Figure 4 , Figure 4 The mask template image added to the unobstructed face image according to the exemplary embodiment of the present disclosure is schematically shown. A plurality of occluded images can be provided in the occluded image library so that a mask template can be randomly selected later to generate an occluded face image. In step S330, the initial mask image is adjusted according to the augmented image information of the augmented face image to obtain an occluded image, i.e., a mask image. For example, the brightness of the initial mask image can be adjusted according to the face brightness of the augmented face image so that the color difference between the two is close. In step S340, the corresponding occluded coverage area is determined in the unobstructed face image, and the mask image is added to the occluded coverage area through affine transformation, that is, the left and right boundaries of the mask are aligned to the sides of the cheeks of the person, and the lower part of the mask is aligned to the chin of the face.
[0064] It should be noted that in the present disclosure, mask images are not added offline to all unobstructed face images before training. Instead, mask images are added online to unobstructed face images when reading images for training. This is because in face recognition, each image often needs to be trained multiple times. If the mask template corresponding to a certain image is fixed in advance, the corresponding masked image will be the same each time the image is trained, which will result in the final trained model being less robust. The method of adding mask images online to unobstructed face images can ensure that the corresponding masked face images are different when the same image is iterated in different rounds, thereby making the final trained model more robust.
[0065] In step S220, after obtaining an unobstructed face image and generating a corresponding occluded face image based on the unobstructed face image, the unobstructed face image and the occluded face image can be input into the face recognition model to be trained for training to determine the classification loss function of the face recognition model to be trained.
[0066] Specifically, for each batch of images selected during the data sampling phase, a corresponding batch of images of faces wearing masks is generated. If the preset sampling data size is 128, the total number of images after mixing in the masked face images becomes 256. The original images and the masked face images are simultaneously fed into the face recognition model to be trained. The labels of the masked face images are consistent with the labels of the original images and can be represented by numbers such as 1, 2, or 3. The classification loss function of the face recognition model to be trained can use a currently mainstream face recognition loss function, such as the additive angular margin loss function (ALM), as shown in Formula 1.
[0067]
[0068] Here, M can represent the number of training samples. Assuming that the preset sampling data size is 128, when the data of facial images of people wearing masks are mixed in, M here is equal to 256; C can represent the total number of categories. For example, if a batch of training data contains a total of 8,000 facial images of people, then C is equal to 8,000.
[0069] In step S230, the first facial feature of the unobstructed facial image is determined by the first facial recognition model, the second facial feature of the unobstructed facial image is determined by the face recognition model to be trained, and the third facial feature of the occluded facial image is determined by the face recognition model to be trained.
[0070] According to some exemplary embodiments of the present disclosure, face detection processing is performed on an unobstructed facial image to determine facial key points of the unobstructed facial image; image cropping processing is performed on the unobstructed facial image based on the facial key points of the unobstructed facial image to generate an initial feature map of the unobstructed facial image; and the initial feature map is input into a first face recognition model to obtain a first facial feature. The initial feature map may be a facial image obtained by cropping the unobstructed facial image.
[0071] refer to Figure 5 , Figure 5The process diagram of extracting facial features by the first face recognition model according to an exemplary embodiment of the present disclosure is schematically shown. After obtaining an unobstructed face image, face detection processing can be performed on the unobstructed face image to determine a face detection frame corresponding to the unobstructed face image, and the face key points of the unobstructed face image in the face detection frame can be determined; the coordinates of the face key points of the unobstructed face image can be determined based on the pixel coordinates of the original unobstructed face image. Face alignment and image cropping processing are performed on the unobstructed face image according to the face key points of the unobstructed face image to obtain an initial feature map of the unobstructed face image. The obtained initial feature map is input into the first face recognition model to perform feature extraction on the unobstructed face image through the first face recognition model to obtain the first facial feature. Specifically, the first face recognition model can be obtained based on the face recognition data set commonly used in the prior art and the model training method of any general face recognition model.
[0072] In step S240, a contrast loss function between the first face recognition model and the face recognition model to be trained is determined based on the first face feature, the second face feature, and the third face feature. Specifically, the contrast loss function can be determined by:
[0073] According to some exemplary embodiments of the present disclosure, a first unobstructed facial image and a corresponding first occluded facial image are determined; a positive pair distance is determined based on a first facial feature of the first unobstructed facial image, a second facial feature of the first unobstructed facial image, and a third facial feature of the first occluded facial image; unobstructed facial images other than the first unobstructed facial image in an unobstructed facial image set are determined as second unobstructed facial images, and a corresponding second occluded facial image is generated based on the second unobstructed facial image; a negative pair distance is determined based on the second facial feature of the first unobstructed facial image, the third facial feature of the first occluded facial image, and the first facial feature of the second unobstructed facial image; a contrast loss function is determined based on the positive pair distance and the negative pair distance.
[0074] The first unobstructed face image may be a currently selected sample image, which may be represented by sample X. The first obstructed face image may be an image generated based on the first unobstructed face image, which may be represented by sample X. m The first facial feature of the first unobstructed facial image can be a facial feature obtained by extracting features from the first unobstructed facial image by the first facial recognition model, and can be represented by F c The second facial feature of the first unobstructed facial image can be a facial feature obtained by extracting features from the first unobstructed facial image by the face recognition model to be trained, and can be represented by F cmThe third facial feature of the first occluded face image can be a facial feature obtained by extracting features from the first occluded face image by the face recognition model to be trained, and can be obtained by using F m express.
[0075] The second unobstructed facial image may be any unobstructed facial image in the set of unobstructed facial images other than the first unobstructed facial image, and the number of second unobstructed facial images may be multiple. The second occluded facial image may be an image generated corresponding to the second unobstructed facial image. The first facial feature of the second unobstructed facial image may be a facial feature obtained by extracting features from the second unobstructed facial image using the first facial recognition model.
[0076] A positive pair can be an image pair consisting of an unobstructed face image and an occluded face image of the same person. A positive pair distance can be the distance between the image features of the unobstructed face image and the image features of the occluded face image of the same person. A negative pair can be an image pair consisting of an unobstructed face image of a certain person and an occluded face image of a different person. A negative pair distance can be the distance between the image features of the unobstructed face image of a certain person and the image features of the occluded face image of a different person.
[0077] In order to further enhance the recognition accuracy of the face model to be trained for comparing occluded face images with images in the unobstructed face image library, an optimized contrast loss function can be used in conjunction with a classification loss function to optimize the face recognition model to be trained. Because the first face recognition model has a high recognition accuracy for unobstructed face images (i.e., ordinary faces), using the contrast loss function to optimize the face recognition model to be trained can make it as close to the first face recognition model as possible while still being able to extract features of occluded faces. The model trained in this way will be able to better extract features of unobstructed faces and improve the comparison accuracy of occluded face images (faces wearing masks) and unobstructed face images (ordinary faces).
[0078] After determining the first facial feature of the first unobstructed facial image, the second facial feature of the first unobstructed facial image, and the third facial feature of the first occluded facial image, the positive example pair distance can be determined based on the first facial feature of the first unobstructed facial image, the second facial feature of the first unobstructed facial image, and the third facial feature of the first occluded facial image.
[0079] According to some exemplary embodiments of the present disclosure, the feature distance between the first facial feature of the first unobstructed facial image and the second facial feature of the first unobstructed facial image is determined as the first feature distance; the feature distance between the first facial feature of the first unobstructed facial image and the third facial feature of the first occluded facial image is determined as the second feature distance; and the positive example pair distance is determined based on the first feature distance and the second feature distance.
[0080] The first feature distance may be the feature distance between the first face feature of the first unobstructed face image and the second face feature of the first unobstructed face image, and may be expressed as d pc The second feature distance can be the feature distance between the first face feature of the first unobstructed face image and the third face feature of the first obstructed face image, which can be expressed as d pm Specifically, the first characteristic distance is shown in Formula 2, and the second characteristic distance is shown in Formula 3.
[0081] d pc =(F c -F cm ) 2 (Formula 2)
[0082] d pm =(F c -F m ) 2 (Formula 3)
[0083] After determining the first facial feature of the second unobstructed facial image, the negative pair distance can be determined based on the second facial feature of the first unobstructed facial image, the third facial feature of the first obstructed facial image, and the first facial feature of the second unobstructed facial image.
[0084] According to some exemplary embodiments of the present disclosure, the negative example pair feature distance corresponding to the first unobstructed face image is determined based on the second facial feature of the first unobstructed face image and the first facial feature of the second unobstructed face image; the negative example pair feature distance corresponding to the first occluded face image is determined based on the third facial feature of the first occluded face image and the first facial feature of the second unobstructed face image; and the negative example pair distance is determined based on the negative example pair feature distance corresponding to the first unobstructed face image and the negative example pair feature distance corresponding to the first occluded face image.
[0085] The negative example pair feature distance corresponding to the first unobstructed facial image may be the feature distance between the second facial feature of the first unobstructed facial image and the first facial feature of the second unobstructed facial image. The negative example pair feature distance corresponding to the first occluded facial image may be the feature distance between the third facial feature of the first occluded facial image and the first facial feature of the second unobstructed facial image.
[0086] Since the data IDs of the samples in a batch are strictly restricted to be different during the data sampling stage, each sampled batch of training data can be matched with all other sample images in the batch as negative pairs. Assuming that the initial batch size is N, each sample X input to the face recognition model to be trained can be matched with N-1 samples input to the first face recognition model as negative pairs; similarly, each sample X input to the face recognition model to be trained can be matched with N-1 samples input to the first face recognition model as negative pairs. m It can also be paired with the N-1 samples input to the first face recognition model to form negative pairs. Therefore, the negative pair distance of each unobstructed face image and the negative pair distance of each obstructed face image can be calculated; the square of the negative pair distance of the unobstructed face image can be calculated using d nc Indicates that the square of the distance between negative examples of occluded face images can be d nm The feature distance of the negative example pair corresponding to the unobstructed face image is shown in Formula 4, and the feature distance of the negative example pair corresponding to the occluded face image is shown in Formula 5.
[0087]
[0088]
[0089] After determining the positive example pair distance and the negative example pair distance, the contrast loss function can be determined based on the positive example pair distance and the negative example pair distance. The calculation method of the contrast loss function is shown in Formulas 6 to 8.
[0090]
[0091] d neg =max(margin-d nc ,0) 2 +max(margin-d nm ,0) 2 (Formula 7)
[0092]
[0093] Margin can be a pre-set constant. The margin value can ensure that negative examples are as far apart as possible and positive examples are as close as possible during model training. y can be 1 or 0. If the current training sample pair is a positive example, the value of y is 1; if the current training sample pair is a negative example, the value of y is 0.
[0094] In step S250, the model parameters of the face recognition model to be trained are updated based on the classification loss function and the contrast loss function to obtain a target face recognition model. After calculating the classification loss function of the model to be trained and the contrast loss function between the model to be trained and the first face recognition model, the model parameters of the face recognition model to be trained can be updated using the classification loss function and the contrast loss function until the loss function values of the classification loss function and the contrast loss function converge. The parameter values of the model parameters of the face recognition model to be trained at this time are determined, and the target face recognition model can be obtained.
[0095] refer to Figure 6 , Figure 6 The present invention schematically illustrates a process diagram for training a target face recognition model by online generation of occluded face images according to an exemplary embodiment of the present disclosure. After performing face alignment and key point detection processing on the unobstructed face image, a corresponding occluded face image can be generated online based on the identified face key points. The occluded face image is input into the face recognition model to be trained, and a classification loss function of the face recognition model to be trained is determined. In addition, a contrast loss function between the face recognition model to be trained and the first face recognition model is determined, and the model training of the face recognition model to be trained is updated according to the classification loss function and the contrast loss function until the loss function converges to obtain the target face recognition model. By pre-training the first face recognition model, its features are used as a supervision information of the target face recognition model. At the same time, the generated occluded face image and the original unobstructed face image are mixed and classified training is adopted as another supervision information of the target face recognition model. The face recognition model to be trained is trained by these two pieces of supervision information, so that the model can better extract the facial features of the unobstructed face image, and can also improve the comparison accuracy between the occluded face image and the unobstructed face image.
[0096] In step S130 , the target face recognition model performs face recognition on the face image to be recognized.
[0097] In some exemplary embodiments of the present disclosure, face recognition can be the process of performing face recognition on a face image to be recognized. After obtaining the face image to be recognized, the face image to be recognized can be input into a target face recognition model, which outputs a predicted value for the face image to be recognized, thereby determining whether the face image to be recognized is a specific person.
[0098] It should be noted that the terms "first", "second", "third", etc. used in this disclosure are only for distinguishing different unobstructed facial images, different obstructed facial images, different facial features, different feature distances, etc., and should not impose any limitations on this disclosure.
[0099] In summary, the face recognition method in the exemplary embodiments of the present disclosure comprises obtaining a face image to be recognized; obtaining a pre-trained target face recognition model; training the target face recognition model using an unobstructed face image and an occluded face image generated from the unobstructed face image; and performing face recognition on the face image to be recognized by the target face recognition model. On one hand, using the unobstructed face image and the occluded face image generated from the unobstructed face image as training data for the target face recognition model can address the difficulty in obtaining training data for existing models. On the other hand, using the unobstructed face image and the corresponding generated occluded face image to train the target face recognition model can significantly improve the robustness of the target face recognition model. Furthermore, using the output features of the first face recognition model as supervisory information for the target face recognition model, while using the generated occluded face image and the original unobstructed face image as a mixed, classified training method as additional supervisory information for the target face recognition model can further improve the recognition accuracy of comparing occluded face images with a library of unobstructed face images.
[0100] It should be noted that although the steps of the method of the present invention are described in a specific order in the accompanying drawings, this does not require or imply that the steps must be performed in this specific order, or that all steps must be performed to achieve the desired results. Additionally or alternatively, certain steps may be omitted, multiple steps may be combined into one step, and / or one step may be broken down into multiple steps.
[0101] In addition, in this exemplary embodiment, a face recognition device is also provided. Figure 7 The face recognition device 700 may include: an image acquisition module 710, a model acquisition module 720 and a face recognition module 730.
[0102] Specifically, the image acquisition module 710 is used to acquire the face image to be identified; the model acquisition module 720 is used to acquire a pre-trained target face recognition model; the target face recognition model is trained by unobstructed face images and occluded face images generated based on the unobstructed face images; the face recognition module 730 is used to perform face recognition on the face image to be identified by the target face recognition model.
[0103] The face recognition device 700 uses unobstructed face images and occluded face images generated based on unobstructed face images as training data to obtain a target face recognition model, and uses the target face recognition model to perform face recognition on the face image to be recognized. This can solve the problem that when the existing occluded face recognition model performs face recognition, when the eye recognition model is used as the main occluded face recognition model, information such as the face contour is ignored, and the training data of the occluded face recognition model is difficult to collect.
[0104] In an exemplary embodiment of the present disclosure, the face recognition device 700 also includes a model training module, which is used to obtain a set of unobstructed face images, determine an unobstructed face image from the set of unobstructed face images, and generate an occluded face image corresponding to the unobstructed face image; train the face recognition model to be trained by the unobstructed face images and the occluded face images, and determine the classification loss function of the face recognition model to be trained; determine the first face feature of the unobstructed face image by the first face recognition model, determine the second face feature of the unobstructed face image by the face recognition model to be trained, and determine the third face feature of the occluded face image by the face recognition model to be trained; determine the contrast loss function between the first face recognition model and the face recognition model to be trained based on the first face feature, the second face feature and the third face feature; update the model parameters of the face recognition model to be trained based on the classification loss function and the contrast loss function to obtain the target face recognition model.
[0105] In an exemplary embodiment of the present disclosure, the model training module includes an image generation unit for performing data augmentation processing on an unobstructed face image to obtain an augmented face image; determining facial key points of the augmented face image, and selecting an initial occluded image from an occluded image library based on the facial key points of the augmented face image; determining augmented image information of the augmented face image, and adjusting the initial occluded image based on the augmented image information to obtain an occluded image; determining an occluded coverage area of the unobstructed face image, and adding the occluded image to the occluded coverage area through affine transformation processing to generate an occluded face image.
[0106] In an exemplary embodiment of the present disclosure, the model training module also includes a feature extraction unit, which is used to perform face detection processing on the unobstructed face image to determine the facial key points of the unobstructed face image; perform image cropping processing on the unobstructed face image according to the facial key points of the unobstructed face image to generate an initial feature map of the unobstructed face image; and input the initial feature map into the first face recognition model to obtain a first facial feature.
[0107] In an exemplary embodiment of the present disclosure, the model training module also includes a loss function determination unit for determining a first unobstructed face image and a corresponding first occluded face image; determining a positive pair distance based on a first facial feature of the first unobstructed face image, a second facial feature of the first unobstructed face image, and a third facial feature of the first occluded face image; determining an unobstructed face image other than the first unobstructed face image in the unobstructed face image set as a second unobstructed face image, and generating a corresponding second occluded face image based on the second unobstructed face image; determining a negative pair distance based on the second facial feature of the first unobstructed face image, the third facial feature of the first occluded face image, and the first facial feature of the second unobstructed face image; and determining a contrast loss function based on the positive pair distance and the negative pair distance.
[0108] In an exemplary embodiment of the present disclosure, the loss function determination unit includes a positive example pair distance determination subunit, which is used to determine the feature distance between the first facial feature of the first unobstructed facial image and the second facial feature of the first unobstructed facial image as the first feature distance; determine the feature distance between the first facial feature of the first unobstructed facial image and the third facial feature of the first occluded facial image as the second feature distance; and determine the positive example pair distance based on the first feature distance and the second feature distance.
[0109] In an exemplary embodiment of the present disclosure, the loss function determination unit also includes a negative example pair distance determination subunit, which is used to determine the negative example pair feature distance corresponding to the first unobstructed face image based on the second facial feature of the first unobstructed face image and the first facial feature of the second unobstructed face image; determine the negative example pair feature distance corresponding to the first occluded face image based on the third facial feature of the first occluded face image and the first facial feature of the second unobstructed face image; and determine the negative example pair distance based on the negative example pair feature distance corresponding to the first unobstructed face image and the negative example pair feature distance corresponding to the first occluded face image.
[0110] The specific details of the virtual modules of the above-mentioned face recognition devices have been described in detail in the corresponding face recognition methods, and therefore will not be repeated here.
[0111] It should be noted that although several modules or units of the face recognition device are mentioned in the detailed description above, this division is not mandatory. In fact, according to the embodiments of the present disclosure, the features and functions of two or more modules or units described above can be embodied in a single module or unit. Conversely, the features and functions of a single module or unit described above can be further divided and embodied by multiple modules or units.
[0112] In addition, in an exemplary embodiment of the present disclosure, an electronic device capable of implementing the above method is also provided.
[0113] Those skilled in the art will appreciate that various aspects of the present invention may be implemented as systems, methods, or program products. Accordingly, various aspects of the present invention may be implemented as a complete hardware embodiment, a complete software embodiment (including firmware, microcode, etc.), or a combination of hardware and software embodiments, which may be collectively referred to herein as "circuits," "modules," or "systems."
[0114] Reference below Figure 8 An electronic device 800 according to such an embodiment of the present invention will be described. Figure 8 The electronic device 800 shown is merely an example and should not limit the functions and scope of use of the embodiments of the present invention.
[0115] like Figure 8 As shown, electronic device 800 is implemented as a general-purpose computing device. Components of electronic device 800 may include, but are not limited to, the aforementioned at least one processing unit 810, the aforementioned at least one storage unit 820, a bus 830 connecting various system components (including storage unit 820 and processing unit 810), and a display unit 840.
[0116] The storage unit stores program codes, which can be executed by the processing unit 810, so that the processing unit 810 performs the steps according to various exemplary embodiments of the present invention described in the above “Exemplary Methods” section of this specification.
[0117] The storage unit 820 may include a readable medium in the form of a volatile storage unit, such as a random access memory unit (RAM) 821 and / or a cache memory unit 822 , and may further include a read-only memory unit (ROM) 823 .
[0118] The storage unit 820 may include a program / utility 824 having a set (at least one) of program modules 825, such program modules 825 including but not limited to: an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment.
[0119] Bus 830 may represent one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processing unit, or a local bus using any of a variety of bus architectures.
[0120] The electronic device 800 can also communicate with one or more external devices 870 (e.g., a keyboard, a pointing device, a Bluetooth device, etc.), one or more devices that enable a user to interact with the electronic device 800, and / or any device that enables the electronic device 800 to communicate with one or more other computing devices (e.g., a router, a modem, etc.). Such communication can occur via an input / output (I / O) interface 850. Furthermore, the electronic device 800 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 860. As shown, the network adapter 860 communicates with other modules of the electronic device 800 via a bus 830. It should be understood that, although not shown in the figure, other hardware and / or software modules can be used in conjunction with the electronic device 800, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0121] Through the description of the above embodiments, it is easy for those skilled in the art to understand that the example embodiments described herein can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the embodiments of the present disclosure can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a terminal device, or a network device, etc.) to execute the method according to the embodiments of the present disclosure.
[0122] In exemplary embodiments of the present disclosure, a computer-readable storage medium is also provided, storing a program product capable of implementing the aforementioned methods of this specification. In some possible embodiments, various aspects of the present invention may also be implemented in the form of a program product comprising program code. When the program product is executed on a terminal device, the program code is configured to cause the terminal device to perform the steps according to various exemplary embodiments of the present invention described in the "Exemplary Methods" section of this specification.
[0123] refer to Figure 9 , a program product 900 for implementing the above method according to an embodiment of the present invention is described. The program product 900 may be a portable compact disc read-only memory (CD-ROM) and include program code, and may be run on a terminal device, such as a personal computer. However, the program product of the present invention is not limited thereto. In this document, a readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0124] The program product may be implemented in any combination of one or more readable media. The readable medium may be a readable signal medium or a readable storage medium. The readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination thereof. More specific examples (a non-exhaustive list) of readable storage media include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof.
[0125] A computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A readable signal medium may also be any readable medium other than a readable storage medium that can transmit, propagate, or transfer a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0126] The program code embodied on the readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0127] The program code for performing the operations of the present invention may be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, and the like, as well as conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user computing device, partially on the user device, as a stand-alone software package, partially on the user computing device and partially on a remote computing device, or entirely on a remote computing device or server. In cases involving a remote computing device, the remote computing device may be connected to the user computing device via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device (e.g., via the Internet using an Internet service provider).
[0128] Furthermore, the above-described figures are merely illustrative of the processes included in the method according to exemplary embodiments of the present invention and are not intended to be limiting. It is readily understood that the processes illustrated in the above-described figures do not indicate or limit the temporal order of these processes. Furthermore, it is readily understood that these processes may be executed synchronously or asynchronously, for example, in multiple modules.
[0129] Other embodiments of the present disclosure will readily occur to those skilled in the art after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present disclosure that follow from the general principles of the present disclosure and include common knowledge or customary techniques in the art not disclosed herein. The description and examples are to be considered as exemplary only, with the true scope and spirit of the present disclosure being indicated by the claims.
[0130] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes can be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A face recognition method, characterized in that: include: Obtain the face image to be recognized; Obtaining a pre-trained target face recognition model; the target face recognition model is trained using an unobstructed face image and an occluded face image generated based on the unobstructed face image; Performing face recognition on the face image to be recognized by the target face recognition model; The target face recognition model is trained in the following way: Acquire a set of unobstructed face images, determine an unobstructed face image from the set of unobstructed face images, and generate an obstructed face image corresponding to the unobstructed face image; Training a face recognition model to be trained using the unobstructed face image and the obstructed face image, and determining a classification loss function of the face recognition model to be trained; Determining a first facial feature of the unobstructed facial image using a first facial recognition model, determining a second facial feature of the unobstructed facial image using the face recognition model to be trained, and determining a third facial feature of the obstructed facial image using the face recognition model to be trained; Determine a contrast loss function between the first face recognition model and the face recognition model to be trained based on the first face feature, the second face feature, and the third face feature; Updating the model parameters of the face recognition model to be trained according to the classification loss function and the contrast loss function to obtain the target face recognition model; The determining, based on the first facial feature, the second facial feature, and the third facial feature, a contrast loss function between the first facial recognition model and the to-be-trained facial recognition model includes: Determining a first unobstructed face image and a corresponding first obstructed face image; determining a positive pair distance based on a first facial feature of the first unobstructed facial image, a second facial feature of the first unobstructed facial image, and a third facial feature of the first obstructed facial image; determining an unobstructed facial image other than the first unobstructed facial image in the unobstructed facial image set as a second unobstructed facial image, and generating a corresponding second obstructed facial image based on the second unobstructed facial image; Determining a negative pair distance based on the second facial feature of the first unobstructed facial image, the third facial feature of the first obstructed facial image, and the first facial feature of the second unobstructed facial image; The contrast loss function is determined according to the positive example pair distance and the negative example pair distance.
2. The method according to claim 1, characterized in that Generating the obstructed face image corresponding to the unobstructed face image includes: Performing data augmentation processing on the unobstructed face image to obtain an augmented face image; Determining facial key points of the augmented facial image, and selecting an initial occluded image from an occluded image library according to the facial key points of the augmented facial image; Determining augmented image information of the augmented facial image, and adjusting the initial occluded image according to the augmented image information to obtain the occluded image; An occlusion coverage area of the unoccluded face image is determined, and the occlusion image is added to the occlusion coverage area through affine transformation processing to generate the occluded face image.
3. The method according to claim 1, characterized in that Determining the first facial feature of the unobstructed facial image by using a first facial recognition model includes: Performing face detection processing on the unobstructed face image to determine facial key points of the unobstructed face image; Performing image cropping processing on the unobstructed facial image according to facial key points of the unobstructed facial image to generate an initial feature map of the unobstructed facial image; The initial feature map is input into the first face recognition model to obtain the first face feature.
4. The method according to claim 1, wherein The determining of the positive example pair distance according to the first facial feature of the first unobstructed facial image, the second facial feature of the first unobstructed facial image, and the third facial feature of the first obstructed facial image includes: determining a feature distance between a first facial feature of the first unobstructed facial image and a second facial feature of the first unobstructed facial image as a first feature distance; determining a feature distance between a first facial feature of the first unobstructed facial image and a third facial feature of the first obstructed facial image as a second feature distance; The positive example pair distance is determined according to the first feature distance and the second feature distance.
5. The method according to claim 1, wherein The determining of the negative example pair distance according to the second facial feature of the first unobstructed facial image, the third facial feature of the first obstructed facial image, and the first facial feature of the second unobstructed facial image includes: Determining a negative example pair feature distance corresponding to the first unobstructed facial image based on the second facial feature of the first unobstructed facial image and the first facial feature of the second unobstructed facial image; Determining a negative example pair feature distance corresponding to the first occluded face image based on the third facial feature of the first occluded face image and the first facial feature of the second unoccluded face image; The negative example pair distance is determined according to the negative example pair feature distance corresponding to the first unobstructed face image and the negative example pair feature distance corresponding to the first obstructed face image.
6. A face recognition device, characterized in that: include: An image acquisition module is used to acquire a face image to be recognized; A model acquisition module is used to acquire a pre-trained target face recognition model; the target face recognition model is trained by using an unobstructed face image and an occluded face image generated based on the unobstructed face image; A face recognition module, configured to perform face recognition on the face image to be recognized using the target face recognition model; The model acquisition module is further configured to acquire a set of unobstructed face images, determine an unobstructed face image from the set of unobstructed face images, and generate an obstructed face image corresponding to the unobstructed face image; Training a face recognition model to be trained using the unobstructed face image and the obstructed face image, and determining a classification loss function of the face recognition model to be trained; Determining a first facial feature of the unobstructed facial image using a first facial recognition model, determining a second facial feature of the unobstructed facial image using the face recognition model to be trained, and determining a third facial feature of the obstructed facial image using the face recognition model to be trained; Determine a contrast loss function between the first face recognition model and the face recognition model to be trained based on the first face feature, the second face feature, and the third face feature; Updating the model parameters of the face recognition model to be trained according to the classification loss function and the contrast loss function to obtain the target face recognition model; The determining, based on the first facial feature, the second facial feature, and the third facial feature, a contrast loss function between the first facial recognition model and the to-be-trained facial recognition model includes: Determining a first unobstructed face image and a corresponding first obstructed face image; determining a positive pair distance based on a first facial feature of the first unobstructed facial image, a second facial feature of the first unobstructed facial image, and a third facial feature of the first obstructed facial image; determining an unobstructed facial image other than the first unobstructed facial image in the unobstructed facial image set as a second unobstructed facial image, and generating a corresponding second obstructed facial image based on the second unobstructed facial image; Determining a negative pair distance based on the second facial feature of the first unobstructed facial image, the third facial feature of the first obstructed facial image, and the first facial feature of the second unobstructed facial image; The contrast loss function is determined according to the positive example pair distance and the negative example pair distance.
7. An electronic device, characterized in that: include: processor; as well as A memory having computer-readable instructions stored thereon, wherein the computer-readable instructions, when executed by the processor, implement the face recognition method according to any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that A computer program is stored thereon, and when the computer program is executed by a processor, the face recognition method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Face recognition model generation and face recognition method, system and device and medium
CN112001372A