Face recognition method and device and storage medium
By training the face recognition model with separate positive and negative sample training sets and filtering out low-quality negative samples, the problem of high false recognition rate in image search scenarios is solved, and the recognition accuracy of low-quality face images is improved.
Patent Information
- Application Number
- CN202411126155.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-16
- Publication Date
- 2026-03-03
AI Technical Summary
Existing technologies have a high false recognition rate in image search scenarios, especially in poor lighting conditions, when the face is at an off angle, occluded, or has low resolution, resulting in insufficient recognition accuracy.
The face recognition model is trained using separate positive and negative training sets. The quality of positive training images is higher than that of negative samples. By filtering low-quality negative training images, the false recognition rate is reduced and the recognition accuracy of low-quality face images is improved.
In image search scenarios, the false recognition rate of face recognition is reduced, the recognition accuracy of low-quality face images is improved, and the false recognition rate between candidate face images and face images to be recognized is less than a preset threshold.
Smart Images

Figure CN121600563A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a face recognition method, device, and storage medium. Background Technology
[0002] Facial recognition technology refers to the process of determining whether a face exists in an input face image or video stream based on human facial features. If a face exists, the technology further detects the position and size of each face. Then, based on this information, it extracts the facial features of each face and compares them with known facial features or facial features in known face images to identify the identity of each face.
[0003] However, when the input facial image or video stream is of poor quality, it may provide limited facial information, leading to a high false recognition rate with the aforementioned facial recognition technology. Therefore, related technologies typically adjust the relationship between person ID (identification) and facial features to a one-to-many structure, recording the multiple facial features with the highest similarity. When multiple facial features point to different person IDs, the specific person is usually determined by averaging the similarity of these multiple facial features. False recognition only occurs when the similarity between the extracted facial features and N non-personal facial features is greater than the similarity to the person's own facial features. This reduces the false recognition rate to the Nth power of the previous probability, thus lowering the overall false recognition rate.
[0004] However, the above technologies may still have a high false recognition rate in image search scenarios. Summary of the Invention
[0005] This invention provides a face recognition method, device, and storage medium to address the shortcomings of existing technologies in image search scenarios, which may still have a high false recognition rate, thereby reducing the false recognition rate of face recognition in image search scenarios.
[0006] This invention provides a face recognition method, comprising the following steps: Obtain the image of the face to be identified; the image of the face to be identified includes the face to be identified. The face image to be identified is input into a preset face recognition model for face recognition processing to determine at least one candidate face image related to the face to be identified; the false recognition rate between the candidate face image and the face image to be identified is less than a preset false recognition rate threshold. The face recognition model described above is trained based on separate positive and negative training sets. The positive training set includes multiple positive training images, and the negative training set includes at least one negative training image. The image quality of the positive training images is higher than that of the negative training images.
[0007] According to a face recognition method provided by the present invention, the determination of the above-mentioned positive sample training set and negative sample training set includes: Obtain the total training set and the known set of face test images; the total training set includes multiple training images, the set of face test images includes multiple face test images, and the image quality of the face test images is lower than a preset quality threshold. Based on the face test image set, at least one negative sample training image that matches the image quality of the face test images is selected from the total training set, and at least one negative sample training image is removed from the total training set to obtain the positive sample training set. At least one negative sample training image is merged with the face test image set to obtain the negative sample training set.
[0008] According to a face recognition method provided by the present invention, the above-mentioned selection of at least one negative sample training image that matches the image quality of the face test images from the total training set based on a set of face test images includes: The total training set is input into the baseline recognition model for feature extraction processing to determine the first face feature corresponding to the total training set; and the face test image set is input into the baseline recognition model for feature extraction processing to determine the second face feature corresponding to the face test image set. Perform matrix operations on the second face feature and the first face feature to determine the collision matrix; the collision matrix includes multiple first elements, each of which represents the image similarity between each face test image in the face test image set and each training image in the total training set; Based on each first element in the collision matrix, at least one negative sample training image that matches the image quality of the face test image is selected from the total training set.
[0009] According to a face recognition method provided by the present invention, the above-mentioned selection of at least one negative sample training image from the total training set based on each first element in the collision matrix and matching the image quality of the face test image includes: Based on the preset false recognition rate condition, the target element corresponding to the preset false recognition rate condition is determined from multiple first elements of the collision matrix, and the target element is determined as the similarity threshold. If any first element in the collision matrix is greater than the similarity threshold, then the training image corresponding to any first element is used as a negative sample training image.
[0010] According to a face recognition method provided by the present invention, the training method of the above-mentioned face recognition model includes: Obtain the total number of input images required in each iteration of the initial face recognition model; Based on the total number of images, the positive sample training set and the negative sample training set are arranged into a mixed queue in a set order; the mixed queue includes multiple second elements, each of which includes a first number of positive sample training images and a second number of negative sample training images. In each iteration of the initial face recognition model, a second element is sequentially obtained from the hybrid queue and input into the initial face recognition model for training to obtain the face recognition model.
[0011] According to a face recognition method provided by the present invention, each positive sample training image in the positive sample training set includes a positive sample label. The method further involves arranging the positive sample training set and the negative sample training set into a mixed queue according to a predetermined order based on the total number of images. The positive training images in the positive training set are shuffled according to their labels to obtain the shuffled positive training set. Based on the total number of images, a first number of positive training images are obtained from the disordered positive training set, and based on the total number of images and the first number, a second number of negative training images are randomly obtained from the negative training set. The first number of positive training images and the second number of negative training images are then arranged in sequence to form a second element. Arrange the second elements in sequence to form a mixed queue.
[0012] According to a face recognition method provided by the present invention, each positive sample training image in the positive sample training set includes a positive sample label, and each negative sample training image in the negative sample training set includes a negative sample label. The method involves inputting a second element into an initial face recognition model for training to obtain a face recognition model, comprising: For each second element, based on the sorting results of the positive and negative training images in the second element, sort the corresponding positive and negative labels to determine the label matrix corresponding to the second element. The second element is input into the initial face recognition model for feature extraction to obtain the third face feature corresponding to the second element; Based on the label arrangement order in the label matrix, feature segmentation is performed on the third face feature to determine the positive sample features corresponding to the positive sample training image and the negative sample features corresponding to the negative sample training image in the second element. The first loss corresponding to the positive sample training image is calculated based on the positive sample features, and the second loss corresponding to the negative sample training image is calculated based on the negative sample features. The initial face recognition model is then trained based on the first and second losses to obtain the face recognition model.
[0013] According to a face recognition method provided by the present invention, the negative sample training set includes at least one type of negative sample training set, each second element includes a negative sample image of a type corresponding to the type of negative sample training set, and the calculation of the second loss corresponding to the negative sample training image based on the negative sample features includes: For each type of negative sample image in the second element, calculate the feature similarity between each pair of negative sample training images in the second element based on their respective negative sample features. Each feature similarity is matched with a preset loss segmentation function to determine the third loss corresponding to each feature similarity. The loss segmentation function includes multiple similarity intervals and the loss corresponding to each similarity interval. Each similarity interval corresponds to the false recognition rate at each level, and the maximum value of the similarity interval is proportional to the magnitude of its corresponding loss. The total second loss corresponding to the negative sample training images in the second element is determined based on the third loss of each feature similarity.
[0014] The present invention also provides a face recognition device, comprising the following modules: The acquisition module is used to acquire the face image to be identified; the face image to be identified includes the face to be identified. The face recognition module is used to input the face image to be recognized into a preset face recognition model for face recognition processing, and determine at least one candidate face image related to the face to be recognized; the false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold. The face recognition model described above is trained based on separate positive and negative training sets. The positive training set includes multiple positive training images, and the negative training set includes at least one negative training image. The image quality of the positive training images is higher than that of the negative training images.
[0015] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the face recognition method as described above.
[0016] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the face recognition method as described above.
[0017] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the face recognition method as described above.
[0018] The present invention provides a face recognition method, apparatus, and storage medium. This method acquires a face image including the face to be recognized, and inputs the face image into a preset face recognition model for face recognition processing to determine at least one candidate face image related to the face to be recognized. The false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold. The face recognition model is trained based on separate positive and negative sample training sets, with the image quality of the positive training images in the positive training set being higher than that of the negative training images in the negative training set. In this method, because the face recognition model is trained using low-quality negative sample training images, the accuracy of the trained face recognition model for recognizing low-quality images is improved. Therefore, in image search scenarios, the relevant images searched based on the trained face recognition model are naturally the face images most relevant to the input face image to be recognized. That is, the false recognition rate between the searched candidate face image and the face image to be recognized will be less than the preset false recognition rate threshold, thus reducing the false recognition rate of face recognition in the face image to be recognized. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0020] Figure 1 This is one of the flowcharts illustrating the face recognition method provided by the present invention.
[0021] Figure 2 This is the second flowchart of the face recognition method provided by the present invention.
[0022] Figure 3 This is a schematic diagram of the negative sample training image screening process provided by the present invention.
[0023] Figure 4 This is the third flowchart of the face recognition method provided by the present invention.
[0024] Figure 5 This is a schematic diagram of the hybrid queue of the training image input device provided by the present invention.
[0025] Figure 6This is a schematic diagram of the multi-loss calculation structure provided by the present invention.
[0026] Figure 7 This is a structural schematic diagram of the face recognition device provided by the present invention.
[0027] Figure 8 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation
[0028] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0029] The following will first explain the technical terms that may be involved in the embodiments of the present invention.
[0030] Face recognition is an algorithm that identifies individuals based on facial image features. Taking 2D (two-dimensional) face recognition as an example, it generally employs deep learning-based methods. Specifically, it uses convolutional neural networks to extract facial features, and then compares the similarity between features from two face images to identify the individual.
[0031] Loss function, also known as cost function, is a function that maps random events to non-negative real numbers to represent the "risk" or "loss" of those random events. In applications, it is often used as an optimization criterion; the model is solved and evaluated by minimizing the loss function. The loss function defines the difference between the trained model and the ground truth labels, so its quality directly affects the performance of the trained model. Commonly used frameworks in face recognition include ArcFace.
[0032] Epoch: In neural network models, an epoch refers to a complete training process of the entire training dataset through the neural network model, including forward propagation and backward propagation. This process ensures that all training samples are processed by the model at least once. During forward propagation, the model makes predictions, and during backward propagation, the model parameters are updated based on the prediction error.
[0033] batch_size: The batch size, which is the number of samples selected before each training session. After selection, the samples in the batch are fed into the network model, and their corresponding parameter adjustment values are calculated. Finally, the average of all parameter adjustment values is taken as the final adjustment value, thereby adjusting and optimizing the network parameters.
[0034] subsample_size: The number of images / pictures taken within each class when using triplet input.
[0035] Class center: This is a weight in one dimension of the last fully connected layer in the face recognition network. There are weights in several dimensions for each category, and each dimension represents a class center.
[0036] Image feature extraction: In face recognition, a convolutional network is used to summarize a face image into a vector of a certain dimension. These vectors can represent the face. By comparing these features (such as comparing cosine distance, Euclidean distance, etc.), it can be determined whether two photos are of the same person.
[0037] Unconventional misidentification: In face recognition, we often encounter some low-quality, unusable face or non-face images. Due to defects in the detection model or the feature discrimination of the recognition model, they are ultimately identified as irrelevant face IDs. This misidentification phenomenon can be called unconventional misidentification.
[0038] The relevant technical background of the present invention will be described below.
[0039] Existing facial recognition models perform well in typical security scenarios (access control, turnstiles, etc.) due to suitable external conditions such as lighting, pose, and distance, generally matching pre-reserved IDs in the database correctly. However, in special image-based search scenarios (poor lighting, excessively off-center facial angles, moving faces, obscured faces (hats, masks, sunglasses, etc.), or faces too far from the camera resulting in low resolution), the limited useful information provided by the face easily leads to unconventional misidentifications. In practical applications, various low-quality facial images have emerged, with similarities to pre-reserved facial images with different IDs far exceeding the threshold, some even reaching 0.9 or higher. In contrast, existing facial recognition models, after extracting high-dimensional features from each image and comparing them, show cosine similarities between several images exceeding 0.6. There are two reasons for their high similarity: 1. The training dataset contains low-quality face images. These low-quality images, due to occlusion, poor pixel quality, angle, or distance, cannot provide effective facial information and should be removed during the labeling process. However, errors inevitably occur during the labeling of training data, making it impossible to guarantee the complete removal of these low-quality faces. Therefore, the face recognition model is interfered with during training by data containing these low-quality face images that are correctly labeled. 2. The existing face recognition model's classification layer + loss function (softmax, Arcface, etc.) structure predicts the classification based on the cosine similarity between the features of each image in the current batch and the class center weight matrix. The prediction results are then judged by labels, and a loss is generated to constrain model iteration. This structure lacks control over the discriminative power between low- and medium-quality face images. Therefore, the above techniques suffer from a high false recognition rate for face images.
[0040] To reduce the false recognition rate of facial images, one related technique adjusts the relationship between personnel ID and facial features to a one-to-many structure and records the multiple facial features with the highest similarity. When multiple facial features point to different personnel IDs, the specific personnel are generally determined by averaging the similarity of these multiple facial features. False recognition only occurs when the similarity between the extracted facial features and N non-personal facial features is greater than the similarity between the extracted facial features and the person's own facial features. This reduces the false recognition rate to the Nth power of the previous probability, thus lowering the false recognition rate. However, this technique mainly addresses the false recognition problem of personnel in the database in deployment scenarios. In image search scenarios, the false recognition rate may still be relatively high. Related technology 2 proposes filtering out face images with image quality scores below a preset threshold, thereby effectively reducing the false recognition rate of face recognition. It also employs multi-dimensional feature matching that integrates facial features and facial attribute features to improve the accuracy of face recognition. However, this technology obtains the image quality score of each face image through a pre-built image quality detection model and filters out face images below the preset threshold. This method heavily tests the capabilities of the image quality detection model, as many face images with high scores are actually low-quality and unusable, negatively impacting model training. Therefore, this technology may also have a high false recognition rate in image search scenarios.
[0041] Based on this, embodiments of the present invention provide a face recognition method, device, and storage medium, which can solve the above-mentioned technical problems.
[0042] The following is combined Figures 1-6 The facial recognition method of the present invention is described.
[0043] Figure 1 This is one of the flowcharts illustrating the face recognition method provided by the present invention, such as... Figure 1 As shown, the method includes the following steps: S102, Obtain the face image to be identified; the face image to be identified includes the face to be identified.
[0044] The image to be identified can be a face image to be searched in an image search scenario. This image typically includes one face, denoted as the face to be identified. In an image search scenario, it is generally necessary to search for one or more face images that are close to or related to the face to be identified.
[0045] The method for obtaining the face image to be identified can be to acquire the face image in real time, or to store the face image to be identified in the cloud or locally in advance and retrieve it directly from the cloud or local when needed, or other methods. There are no specific limitations here, as long as the face image to be identified can be obtained.
[0046] S104, the face image to be identified is input into a preset face recognition model for face recognition processing to determine at least one candidate face image related to the face to be identified; the false recognition rate between the candidate face image and the face image to be identified is less than a preset false recognition rate threshold.
[0047] The aforementioned face recognition model is trained using separate positive and negative training sets. The positive training set includes multiple positive training images, and the negative training set includes at least one negative training image. Furthermore, the image quality of the positive training images is higher than that of the negative training images. In other words, before searching for a face image to be recognized, a new face recognition model can be pre-trained. This new model distinguishes between the positive training images (training images with correctly labeled faces) and the negative training images (training images with incorrectly labeled faces) in the training set. Specifically, it separates the lower-quality negative training images from the higher-quality positive training images. The model is then trained using these separate positive and negative training images. This training method allows the face recognition model to more accurately recognize both high-quality and low-quality face images.
[0048] After obtaining the trained face recognition model through the above training, the face image to be recognized can be input into the trained face recognition model. The face recognition model can extract the facial features of the face image to be recognized, and at the same time, it can extract the facial features of multiple face images in the preset database. The facial features of the face image to be recognized are compared with the facial features of multiple face images in the preset database to find (or search for) one or more face images that are most relevant / similar to the face to be recognized in the face image to be recognized, and these are recorded as candidate face images.
[0049] It should be noted that when performing image search on low-quality face images, the number of candidate face images searched by the face recognition model in this embodiment will be less than the number searched by the face recognition model in related technologies. Furthermore, when performing face recognition on low-quality face images using the face recognition model in this embodiment, since the face recognition model in this embodiment is trained using separate low-quality negative sample training images, the recognition accuracy of the face recognition model for low-quality face images will be improved. That is, the false recognition rate of the face recognition model for low-quality face images will be reduced. Specifically, the false recognition rate between the finally searched candidate face images and the face image to be recognized may be less than a preset false recognition rate threshold, or the accuracy may be greater than a certain accuracy threshold. The size of the preset false recognition rate threshold or the accuracy threshold can be set according to the actual situation.
[0050] In this embodiment, a face image including the face to be identified is acquired, and the face image is input into a preset face recognition model for face recognition processing to determine at least one candidate face image related to the face to be identified. The false recognition rate between the candidate face image and the face image to be identified is less than a preset false recognition rate threshold. The face recognition model is trained on separate positive and negative sample training sets, with the image quality of the positive training images in the positive training set being higher than that of the negative training images in the negative training set. In this method, because the face recognition model is trained using low-quality negative sample training images, the accuracy of the trained face recognition model for recognizing low-quality images is improved. Therefore, in image search scenarios, the relevant images searched based on the trained face recognition model are naturally the face images most relevant to the input face image to be identified. That is, the false recognition rate between the searched candidate face image and the face image to be identified will be less than the preset false recognition rate threshold, thus reducing the false recognition rate of face recognition in the face image to be identified.
[0051] Existing conventional face recognition model training processes typically involve first feeding the training set into a data input device, which then performs operations such as segmentation, shuffling, and data augmentation according to requirements. The data is then fed into the network model according to the batch size, and the network model processes the high-dimensional facial features to calculate the loss function. Finally, gradient backpropagation and updates are performed. For the training set, images with the same face ID are usually stored in the same folder and labeled accordingly. However, a problem exists in actual training sets: due to the massive size of face recognition training datasets, typically millions or even tens of millions of images, the data labeling process is difficult and time-consuming. Therefore, the labeled dataset inevitably contains errors, resulting in some low-quality, unusable face images (such as overly blurry faces, faces wearing masks and helmets, faces wearing sunglasses and masks, etc.) being mixed into the folders of different IDs in the training set. Existing recognition models lack the ability to distinguish between such low-quality, unusable faces. Furthermore, during training, these faces are mixed into normal classifications, further interfering with the iterative updates of model weights. This results in excessively high feature similarity between these low-quality faces and unrelated face images. For example, in existing face recognition processes, the cosine similarity of features extracted from two blurry faces using a baseline recognition model reaches 0.639, leading to a high false recognition rate.
[0052] Based on this, embodiments of the present invention train a face recognition model that can improve the recognition accuracy of low-quality face images / reduce the false recognition rate of low-quality face images. The following embodiments will describe the training process of the face recognition model provided by the present invention. First, the method of obtaining the separate positive sample training set and negative sample training set used in training the face recognition model will be described.
[0053] In some embodiments, Figure 2 This is the second flowchart illustrating the face recognition method provided by this invention, as shown below. Figure 2 As shown, the method for determining the positive and negative sample training sets can include the following steps: S202, Obtain the total training set and the known set of face test images; the total training set includes multiple training images, the set of face test images includes multiple face test images, and the image quality of the face test images is lower than a preset quality threshold.
[0054] In this step, a pre-annotated (manually annotated) total training set can be obtained first. This total training set includes multiple training images, and each training image can include a face sample or a label annotating a face sample. The label can be the ID of the corresponding face sample.
[0055] It should be noted that some face samples in the training images included in the total training set may have incorrectly labeled tags. In related technologies, these incorrectly labeled training images are mistakenly identified as correctly labeled training images and used in the training of the face recognition model, resulting in a high false recognition rate for the trained face recognition model. Therefore, in this embodiment of the invention, after obtaining the total training set, it can be cleaned or corrected to filter out the incorrectly labeled training images.
[0056] In addition, to facilitate the filtering of incorrectly labeled training images in the overall training set, a set of face test images can be pre-collected. This set of face test training images can include multiple face test images. It should be noted that these face test images are all low-quality and unusable. Low quality can mean that the image quality of the face test image is below a preset quality threshold. The size of this preset quality threshold can be set according to the actual situation. Face images with image quality greater than this preset quality threshold are generally considered to have higher image quality, and the face recognition model generally has a lower false recognition rate for these face images, i.e., higher accuracy.
[0057] It should be noted that the aforementioned face test dataset can be one or more. When there are multiple datasets, each face test dataset can correspond to a set of low-quality face test images. For example, it can include a set of low-quality face test images caused by poor lighting conditions, a set of low-quality face test images caused by face movement, a set of low-quality face test images caused by face occlusion, a set of low-quality face test images caused by the face being too far from the camera, etc.
[0058] S204. Based on the face test image set, at least one negative sample training image that matches the image quality of the face test images is selected from the total training set, and at least one negative sample training image is removed from the total training set to obtain the positive sample training set.
[0059] In this step, after obtaining the low-quality face test image set and the total training set, the low-quality face training images in the total training set can be filtered based on the face test image set. The filtered low-quality face training images can be recorded as negative sample training images. Optionally, this filtering process may include the following steps: Step A1: Input the total training set into the baseline recognition model for feature extraction processing to determine the first face feature corresponding to the total training set; and input the face test image set into the baseline recognition model for feature extraction processing to determine the second face feature corresponding to the face test image set.
[0060] Step A2: Perform matrix operations on the second face feature and the first face feature to determine the collision matrix; the collision matrix includes multiple first elements, each of which represents the image similarity between each face test image in the face test image set and each training image in the total training set.
[0061] Step A3: Based on each first element in the collision matrix, select at least one negative sample training image from the total training set that matches the image quality of the face test image.
[0062] The baseline recognition model can be a pre-established, simple, and easy-to-implement recognition model, such as a simplified optimal recognition model, a random classifier, or a simple linear regression model. This baseline recognition model is used to extract facial features from training images, and generally, the extracted facial features are highly accurate.
[0063] See Figure 3 The diagram illustrates the negative sample training image selection process. After obtaining the total training set, each training image in the total training set can be input into the baseline recognition model for facial feature extraction to obtain the facial features corresponding to each training image, denoted as the first facial feature (e.g., Features1 in the diagram). It should be noted that this first facial feature can be a facial feature matrix, which includes the facial features of all training images.
[0064] After obtaining the set of face test images, taking one set of face test images as an example, each face test image in this set (also called an unusable face image set) can be input into the baseline recognition model to extract face features, obtaining the face features corresponding to each face test image, denoted as the second face feature (such as Features2 in the figure). It should be noted that the second face feature can also be a face feature matrix, which includes the face features of all face test images.
[0065] Assuming the face test image set includes m face test images, the second face feature obtained after passing through the baseline recognition model is an m×512 dimensional feature matrix A. Assuming the total training set includes n training images, the first face feature obtained after passing through the baseline recognition model is an n×512 dimensional feature matrix B. The second and first face features can then be input into the matrix operation module for matrix operations to obtain the collision matrix. The matrix operation process can be seen in the following formula: .
[0066] in, B T Characteristic matrix BThe transpose of the matrix has a size of 512×n; xsd The collision matrix is obtained after matrix operations and has a size of m×n. That is, the collision matrix includes m rows and n columns of elements, and each element represents the image similarity between each face test image and each training image. list The training set to be deleted consists of the selected negative sample training images; Y This is the similarity threshold.
[0067] The above similarity threshold Y The determination method may include: based on a preset false recognition rate condition, identifying the target element corresponding to the preset false recognition rate condition from multiple first elements of the collision matrix, and determining the target element as the similarity threshold. Here, the preset false recognition rate condition refers to a condition requiring a certain false recognition rate. This preset false recognition rate condition is a condition for a relatively high false recognition rate; for example, a false recognition rate of 1 / 100,000 can be chosen as the preset false recognition rate condition. Assuming a collision matrix of size m×n contains 1 million elements, a false recognition rate of 1 / 100,000 corresponds to 10 elements among these 1 million elements. Therefore, the 10th element can be selected from the collision matrix containing 1 million elements (e.g., by row), and then this 10th element can be used as the similarity threshold.
[0068] Then, each element in the collision matrix can be compared with a similarity threshold, i.e., it can be determined whether each element in the collision matrix is greater than the similarity threshold. Optionally, if any first element in the collision matrix is greater than the similarity threshold, then the training image corresponding to any first element is used as a negative sample training image. That is, if an element in the collision matrix is greater than the similarity threshold, it means that the training image corresponding to that element has a high image similarity to the face test image. However, there should be no images in the training set that are too similar to these low-quality unusable face test images. In other words, the training image corresponding to that element is likely a low-quality unusable face training image, so it can be used as a negative sample training image.
[0069] By finding all elements in the collision matrix that are greater than the similarity threshold and recording their positions, the corresponding training images in the total training set can be found and used as negative sample training images.
[0070] It is understandable that using different types / different benchmark classes of face test image sets will result in the selection of corresponding types of negative sample training images from the total training set.
[0071] After filtering out negative training images from the total training set, these negative training images can be deleted from the total training set (i.e., the training set list to be deleted). The training set consisting of the remaining training images can be called the positive training set. The training images in the positive training set are generally high-quality and usable training images.
[0072] In addition, the process of filtering low-quality, unusable negative training images in the total training set can also be called a data filtering process, and the module that implements the above data filtering process can be referred to as a data filter.
[0073] S206, merge at least one negative sample training image with the face test image set to obtain a negative sample training set.
[0074] In this step, after selecting different types of negative sample training images from the total training set, the different types of negative sample training images can be merged with their corresponding class of face test image sets, that is, the different types of negative sample training images are added to their corresponding class of face test image sets, and finally different types of new face test image sets are obtained, all of which are called negative sample training sets. The training images in the negative sample training set are generally low-quality and unusable training images.
[0075] After obtaining the above-mentioned different types of negative sample training sets and positive sample training sets, the different types of negative sample training sets and positive sample training sets can be saved separately for use in subsequent training of face recognition models.
[0076] In this embodiment, low-quality face training images in the total training set are filtered using known types of low-quality face test images, which improves the accuracy of the training data. Furthermore, negative sample training images are filtered out by performing feature extraction and matrix collision operations between the training images in the total training set and the known types of low-quality face test images. This further improves the accuracy of the training data without changing the training speed of the face recognition model. Moreover, a similarity threshold is determined in the collision matrix using a preset false recognition rate condition for threshold comparison. This improves the efficiency and accuracy of identifying negative sample training images, further enhancing the accuracy of the training data.
[0077] After cleaning the entire training set as described above, the cleaned negative sample training set needs to be added to the training using a data input device. There are two common types of data input devices: The first is a regular data input device, which treats all images in the training set as a whole and shuffles this whole in each epoch of training; then, in each round of training, a fixed number of images are read sequentially from the shuffled queue according to the batch size and converted into a pixel matrix to input into the network. Its advantage is that the data selected in each round is completely shuffled, and the model can learn all the image features in the training set during each epoch. The disadvantage is that if the number of images / images in each class in the training set is uneven, it will lead to a large difference in the probability of updating the weights of each class. The second type is the triplet data input device. It treats all the labels of all categories in the entire training set as a whole, and shuffles this whole in each epoch of training. Then, in each training round, it calculates the number of categories for each round according to the set subsample_size and batch_size, and reads images / pictures that meet the set parameters, converting them into pixel matrices and inputting them into the recognition network for iterative processing. Its advantage is that the model can learn all categories in the training set during each epoch, and each category has an equal probability of being selected, making it more suitable for training sets with uneven data distribution. As described above, both types of data input devices share a common feature: all images / pictures input into the model are positive samples. However, because negative samples cannot enter the training set, the model cannot improve its feature discrimination of negative face types.
[0078] Based on this, this embodiment of the invention proposes to also incorporate the obtained negative sample training set into the training process of the face recognition model, so as to improve the feature discrimination of the finally trained face recognition model for negative faces, and ultimately reduce the non-standard misidentification rate. The following embodiments illustrate the process of training the face recognition model based on the positive sample training image set and the negative sample training set.
[0079] In some embodiments, Figure 4 This is the third flowchart of the face recognition method provided by the present invention, as shown below. Figure 4 As shown, the training method for the above-mentioned face recognition model may include the following steps: S302, obtain the total number of input images required in each iteration of the initial face recognition model.
[0080] Before training the face recognition model, the model architecture can be constructed and parameters initialized to obtain an initial face recognition model. The number of iterations per training round and the total number of input images in each iteration can also be preset.
[0081] S304, based on the total number of images, the positive sample training set and the negative sample training set are arranged into a mixed queue in a set order; the mixed queue includes multiple second elements, each of which includes a first number of positive sample training images and a second number of negative sample training images.
[0082] In this step, the training images included in the positive sample training set obtained through the above screening are all high-quality, usable training images and can all be denoted as positive sample training images. Each positive sample training image in the positive sample training set includes a positive sample label, which is the accurate label of each positive sample training image itself, such as the ID of the sample face in the positive sample training image, which is the real ID of the sample face. The negative sample training images and face test images included in the negative sample training set can all be denoted as negative sample training images, which are all low-quality, unusable training images. Each negative sample training image in the negative sample training set includes a negative sample label, which can be a pre-set label, generally a value less than 0. The negative sample label is the same for each negative sample training image in each type of negative sample training set, that is, one type of negative sample training set corresponds to one negative sample label, and different types of negative sample training sets correspond to different negative sample labels, for example, the negative sample label corresponding to negative sample training set 1 is -1, the negative sample label corresponding to negative sample training set 2 is -2, and so on.
[0083] After determining the total number of images input in each iteration, a second element representing the total number of images can be formed by combining the positive training images from the positive training image set and the negative training images from the negative training image set. Multiple second elements are then arranged in a predetermined order (e.g., according to the order in which the selected images are arranged in their original training sets) to form a mixed queue. In each training round, various types of data are input according to this mixed queue. That is, each second element in the mixed queue participates in one iteration, and each iteration includes both positive and negative training images. The process of obtaining each second element is explained below.
[0084] Optionally, the positive training images in the positive training set can be shuffled according to their positive labels to obtain a shuffled positive training set; based on the total number of images, a first number of positive training images can be obtained from the shuffled positive training set, and based on the total number of images and the first number, a second number of negative training images can be randomly obtained from the negative training set, and the first number of positive training images and the second number of negative training images can be arranged sequentially to form a second element; the second elements can be arranged sequentially to form a mixed queue.
[0085] See Figure 5The diagram shows a mixed queue for the training image input device. Taking two negative sample training sets as an example, if more types are needed, they can be continuously added to the mixed queue according to this rule. The diagram shows the entire data queue for training one epoch (i.e., the mixed queue mentioned above). The order of data retrieval in each iteration is from left to right. The area within the arrow represents the data fed into the face recognition model in each iteration (denoted as iter) during training. `base` is the number of positive sample training images in each second element (all denoted as the first quantity, i.e., the training set in the diagram), denoted as `batch_size`. The number of face IDs of the positive sample training images fed into the face recognition model by each iter is (base / subsample_size). For example, if the first quantity of positive sample training images to be selected, `base`, is 80, and the number of IDs to be selected, `subsample_size`, is 4, then the number of positive sample training images to be selected for each ID is 20. Negative classes -1 and -2 are the different negative class sample training sets obtained after the above filtering. `wj1` and `wj2` are the number of negative sample training images corresponding to different negative classes fed into the face recognition model by each iter (all denoted as the second quantity). all_batch is the batch_size of each iter input face recognition model, and the relationship between them is shown in the following formula: all_batch = base + wj1 + wj2.
[0086] To facilitate subsequent segmentation of facial features from positive and negative training images, the mixed training queue needs quantitative segmentation and sorting. This ensures that training data is accurately fed into the face recognition model in label order during each training iteration. Specifically, after obtaining the positive training set, the positive training images are shuffled according to their labels. This involves randomly sorting the positive training images by their labels, and then selecting a first number of positive training images from the new set. Simultaneously, the number of images needed for all negative classes can be obtained by subtracting the first number from the total number of images in each iteration. Then, the number of negative images needed for each negative class is obtained by dividing the images equally or unevenly by type, denoted as the second number. The second number of negative training images is then randomly selected from the corresponding class's negative training set. Finally, the first number of positive training images and the second number of negative training images for each class are arranged sequentially to form a second element. Figure 5 The `all_batch` in the diagram corresponds to a set of images. The principle behind the quantitative segmentation and sorting of the trained hybrid queue is as follows: for i in range(0, epoch_len): F_inds.extend (triplet_inds[(i* base):((i+1)* base)])
[0087] F_inds.extend (random.sample(wj1_inds, wj1))
[0088] F_inds.extend(random.sample(wj2_inds, wj2)).
[0089] Where epoch_len is the iter value required to train one epoch (i.e., the total number of images all_batch mentioned above), F_inds is the total data queue sent to the model for each epoch, triplet_inds is the queue of positive sample training images after being shuffled by ID, and wj1_inds and wj2_inds are the data queues for negative class-1 and negative class-2, respectively (composed of their respective negative sample training images). The queues are combined according to all_batch and their respective batch_size, ultimately achieving... Figure 5 The queue is sorted.
[0090] In addition, to achieve the above Figure 5 The module for queue input in this embodiment can also be called a data input device. In this embodiment, the data input device can be denoted as epoch_aug.
[0091] S306. In each iteration of the initial face recognition model, a second element is sequentially obtained from the hybrid queue and input into the initial face recognition model for training to obtain the face recognition model.
[0092] In this step, after constructing the hybrid queue containing multiple second elements, during the training of the initial face recognition model, each iteration sequentially selects one second element from the hybrid queue and inputs it into the initial face recognition model. The initial face recognition model is then trained using its output, combined with the positive sample labels of the input training data, ultimately yielding a trained face recognition model. The specific training process will be detailed in the following embodiments.
[0093] In this embodiment, by combining various training data into queues based on their labels, data input can be performed according to a predefined data selection method in each iteration of the initial face recognition model training. This improves the accuracy of data input, thereby enhancing the accuracy of subsequent loss calculations and ultimately improving the training accuracy of the face recognition model. Furthermore, by selecting positive sample training sets based on shuffled IDs and simultaneously selecting negative sample training sets through random sampling in each iteration, a data foundation is provided for subsequently segmenting the features of each training set to calculate their respective losses. This also improves the robustness of the selected training data against interference, thus enhancing the robustness of the trained face recognition model.
[0094] The following examples illustrate the process of feature segmentation and loss calculation based on the training data input by the above-mentioned hybrid queue to train a face recognition model.
[0095] In some embodiments, each positive sample training image in the positive sample training set includes a positive sample label, and each negative sample training image in the negative sample training set includes a negative sample label. The step of "inputting the second element into the initial face recognition model for training to obtain the face recognition model" in S306 may include the following steps: Step B1: For each second element, sort the corresponding positive and negative sample labels according to the sorting results of the positive and negative sample training images in the second element, and determine the label matrix corresponding to the second element.
[0096] For each second element, the positive or negative labels can be sorted according to the order of the positive training images and the different negative training images in the second element to obtain the sorted label matrix.
[0097] Step B2: Input the second element into the initial face recognition model for feature extraction to obtain the third face feature corresponding to the second element.
[0098] Step B3: Perform feature segmentation on the third face features according to the label arrangement order in the label matrix to determine the positive sample features corresponding to the positive sample training images and the negative sample features corresponding to the negative sample training images in the second element.
[0099] Among them, see Figure 6The flowchart illustrating the multi-loss calculation structure shows that, continuing with the two negative class training sample sets (negative class-1 and negative class-2) as an example, the training data (i.e., each second element) after being segmented and sorted by the epoch_aug data input device can be fed into the backbone network of the face recognition model for face feature extraction, obtaining the third face feature corresponding to each second element. This third face feature is a high-dimensional feature, which includes features from both the positive sample training images and the features from the two different negative class training images. These features have different effects on the iterative update of the model parameters, therefore, the loss needs to be calculated separately for each feature.
[0100] To facilitate the calculation of different losses for the features of different training images, it is necessary to first segment the third face features, which include the features of all training images. That is, it is necessary to segment the third face features corresponding to each second element. Specifically, this can be done by separating the features belonging to the positive sample training images from the features belonging to the negative class training images.
[0101] Assume that the third face feature corresponding to each second element is a p*512 dimensional feature (let's call it denoted as p). Fc 512 _all ), p is the all_batch mentioned above; then the FG_FL structure proposed in this embodiment (i.e. Figure 6 The structure within the red box segments the third-face feature. In the case of two negative classes, this third-face feature can be segmented into three parts: the positive sample features corresponding to the positive training image set, and the negative sample features corresponding to the two negative training image sets respectively. Assuming the labels of the two negative training image sets are -1 and -2 respectively, this process continues as new negative training image sets are added. The steps for feature segmentation using the FG_FL structure are shown in the following formula: .
[0102] in, labels This represents the label matrix of the input images in the current training iteration. Positive sample labels are generally greater than 0 because they are usually real face IDs, such as being labeled from 1, 2, 3, etc. The ",:" symbol indicates rounding down the row. index base , index wj1 , index wj2 These represent the indices of the positive sample labels extracted from the label matrix, the indices of the negative sample labels of negative class 1, and the indices of the negative sample labels of negative class 2, respectively. base_fc 512、 wj 1 _fc 512、 wj 2 _fc512 represent the positive sample features, negative sample features of negative class 1, and negative sample features of negative class 2 obtained after segmenting the corresponding third face features based on the index of the positive sample label, the index of the negative sample label of negative class 1, and the index of the negative sample label of negative class 2, respectively.
[0103] The above formula can be used to obtain the positive sample features, negative sample features of negative class 1, and negative sample features of negative class 2.
[0104] Step B4: Calculate the first loss corresponding to the positive sample training image based on the positive sample features, and calculate the second loss corresponding to the negative sample training image based on the negative sample features. Then, train the initial face recognition model based on the first and second losses to obtain the face recognition model.
[0105] Among them, after obtaining positive sample features through segmentation, the positive sample features (i.e. base_fc 512) Input the data into the classification layer (e.g., a fully connected layer) for classification processing to determine the feature prediction result. Then, calculate the loss by comparing the positive sample labels of the positive training image with the feature prediction result (where the feature prediction result could be, for example, the predicted face ID, and the positive sample label could be, for example, the real face ID). The resulting loss is denoted as the first loss. base_loss (This first loss could be, for example, cross-entropy loss).
[0106] For the obtained negative sample features of each negative class, the reason why the similarity of negative sample features (face negative sample features) within a negative class is too high is that regardless of whether it is a large profile, wearing a hat or mask, or a blurred face, the effective features of the face are not obvious, and even the position and shape of facial features cannot be distinguished. This leads to excessively high feature similarity obtained by the face recognition model, affecting the feature discrimination of negative sample features. Based on this, this embodiment proposes to calculate the loss of each negative sample feature of each negative class, which is denoted as the second loss. The calculation of the second loss is essentially to perform intra-class comparison using the negative sample features of each negative class to complete the loss calculation. Optionally, the negative sample training set includes at least one type of negative sample training set, and each second element includes a negative sample image of a type corresponding to the type of negative sample training set. The above calculation of the second loss corresponding to the negative sample training image based on the negative sample features may include: For each type of negative sample image in the second element, the feature similarity between each pair of negative sample training images in the second element is calculated based on their respective negative sample features. Each feature similarity is then matched with a preset loss segmentation function to determine the third loss corresponding to each feature similarity. The aforementioned loss segmentation function includes multiple similarity intervals and the loss corresponding to each similarity interval. Each similarity interval corresponds to a certain level of false recognition rate, and the maximum value of the similarity interval is proportional to the magnitude of its corresponding loss. The total second loss corresponding to the negative sample training images in the second element is determined based on the third loss of each feature similarity.
[0107] Continuing with the example of each second element containing two negative sample training images of a negative class, each class of negative sample training images generally includes multiple negative sample training images. Here, we will use the calculation of the second loss for a single negative sample training image as an example. For the negative sample training images of that class in the second element, we can calculate the feature similarity between every two negative sample training images of that class. Specifically, we can arbitrarily select the negative sample features of two negative sample training images from the negative sample features obtained above for feature similarity calculation to obtain the feature similarity between every two negative sample training images. Then, we can use the following loss piecewise function to match the loss corresponding to each feature similarity, that is, obtain the corresponding loss between two negative sample training images, denoted as the third loss. The formula for the loss piecewise function is as follows: .
[0108] in, FL_loss This represents the third loss between every two negative training images; i and j These represent any two negative sample training images; It represents the feature similarity (or cosine similarity) between every two negative training images. These are the cosine similarity thresholds for different stages, and their values can be set according to the actual situation. For example, these three coefficients can be 0.2, 0.4, and 0.6 respectively. These are the penalty parameters for different stages, and their values can be set according to the actual situation. For example, these two coefficients can be 0.6 and 1 respectively.
[0109] As can be seen from the above formula, the third loss differs depending on the similarity intervals corresponding to the feature similarity of the two negative training images. Furthermore, the greater the feature similarity between the two negative training images, the larger the maximum value of their corresponding similarity interval, and the greater the corresponding third loss; conversely, the smaller the similarity, the smaller the third loss. Therefore, this embodiment will penalize negative sample features with excessively high similarity (e.g., as shown in the formula above). , The higher the similarity, the stronger the penalty. Specifically, in a single training round, the more negative sample feature pairs of the negative class exhibiting excessively high similarity, or the greater the similarity of the negative sample features of the negative class, the less capable the face recognition model is of distinguishing such images. FL_loss Stronger penalties or constraints will be imposed, enabling face recognition models to further improve their feature discrimination of such images, thereby improving their feature discrimination of negative sample features, that is, improving their feature discrimination of low-quality negative sample training images.
[0110] Furthermore, the division of the aforementioned similarity intervals can be referenced to the thresholds of face recognition models under various / levels of false recognition rates. For example, the false recognition rates differ at different levels, allowing for the division of different similarity intervals and the setting of different penalties / constraints for each interval. Specifically, a higher cosine similarity threshold corresponds to a lower false recognition rate. If, in a given training epoch, there are more negative training image pairs with feature similarity (or cosine similarity) greater than the cosine similarity threshold, then the penalties / constraints should be set more aggressively.
[0111] After calculating the third loss between every two negative sample training images within the same negative class in the second element, the average of all third losses within that negative class can be calculated. The resulting average is the total second loss corresponding to the negative sample images of that negative class. For example, when there are two negative classes, the corresponding two second losses are as follows: Figure 6 In FL_loss 1 and FL_loss 2.
[0112] After obtaining the first loss corresponding to the positive sample training image and the second loss corresponding to each type of negative sample training image in each second element, the first loss and each second loss can be summed to obtain the total loss. For example, when there are two negative classes, this total loss... Loss_all The calculation formula is as follows: .
[0113] in, γ 1 and γ 2 represents the weights of the second loss for the two negative classes. The specific values can be set according to the actual situation, such as 0.1 for both. This is just an example.
[0114] After obtaining the total loss corresponding to each second element, the value of the total loss can be used to perform backward gradient update on the initial face recognition model to train the initial face recognition model. Finally, after training is completed, a trained face recognition model is obtained.
[0115] It is understandable that the negative training samples of the above negative class... FL_loss The total loss function can be formed by stacking the negative classes based on the number of negative classes and combining it with the loss of the positive sample training images. Therefore, more branches can be added at any time based on the continuously collected negative sample classes without increasing the size and time consumption of the model, thereby continuously improving the robustness of the model. This means that the model can improve the recognition accuracy of different negative class samples, and reduce the false recognition rate of different negative class samples.
[0116] In this embodiment, a label matrix is formed by the labels of the positive training images and the corresponding labels of the negative sample images in each second element. This matrix is used to segment the common facial features of both the positive and negative training images. Different losses are then calculated based on the segmented features to train the face recognition model. This allows for ordered segmentation of high-dimensional facial features, facilitating separate loss calculations and improving the accuracy of loss calculation, thereby enhancing the accuracy of model training. Furthermore, when calculating the loss for negative training images, different loss penalties can be applied based on the similarity of features between the negative sample images. For example, the greater the similarity, the greater the loss penalty. This improves the model's feature discrimination ability for negative training samples, thereby increasing the accuracy of the final trained face recognition model in recognizing low-quality face images or reducing the false recognition rate.
[0117] The face recognition device provided by the present invention will be described below. The face recognition device described below can be referred to in correspondence with the face recognition method described above.
[0118] Figure 7 This is a schematic diagram of the face recognition device provided by the present invention. See below. Figure 7 As shown, the device may include: The acquisition module 410 is used to acquire a face image to be identified; the face image to be identified includes the face to be identified. The face recognition module 420 is used to input the face image to be recognized into a preset face recognition model for face recognition processing, and determine at least one candidate face image related to the face to be recognized; the false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold. The face recognition model described above is trained based on separate positive and negative training sets. The positive training set includes multiple positive training images, and the negative training set includes at least one negative training image. The image quality of the positive training images is higher than that of the negative training images.
[0119] In some embodiments, the above-described apparatus may further include a training set determination module, which may include: The training set acquisition unit is used to acquire the total training set and the known face test image set; the total training set includes multiple training images, the face test image set includes multiple face test images, and the image quality of the face test images is lower than a preset quality threshold. The positive sample training set determination unit is used to select at least one negative sample training image that matches the image quality of the face test images from the total training set based on the face test image set, and remove at least one negative sample training image from the total training set to obtain the positive sample training set. The negative sample training set determination unit is used to merge at least one negative sample training image with the face test image set to obtain a negative sample training set.
[0120] Optionally, the aforementioned positive sample training set determination unit is specifically used for
[0121] The total training set is input into the baseline recognition model for feature extraction to determine the first face feature corresponding to the total training set; and the face test image set is input into the baseline recognition model for feature extraction to determine the second face feature corresponding to the face test image set; matrix operations are performed on the second face feature and the first face feature to determine the collision matrix; the collision matrix includes multiple first elements, each first element representing the image similarity between each face test image in the face test image set and each training image in the total training set; based on each first element in the collision matrix, at least one negative sample training image that matches the image quality of the face test image is selected from the total training set.
[0122] Optionally, the aforementioned positive sample training set determination unit is specifically used for
[0123] Based on the preset false recognition rate condition, the target element corresponding to the preset false recognition rate condition is determined from multiple first elements of the collision matrix, and the target element is determined as the similarity threshold; if any first element in the collision matrix is greater than the similarity threshold, the training image corresponding to any first element is used as the negative sample training image.
[0124] In some embodiments, the above-described apparatus may further include a training module, which may include: The total number of images acquisition unit is used to acquire the total number of input images required in each iteration of the initial face recognition model; The training queue determination unit is used to form a mixed queue of positive sample training sets and negative sample training sets in a set order according to the total number of images; the mixed queue includes a plurality of second elements, each second element including a first number of positive sample training images and a second number of negative sample training images. The training unit is used to sequentially obtain a second element from the hybrid queue during each iteration of the initial face recognition model, and input the second element into the initial face recognition model for training to obtain the face recognition model.
[0125] Optionally, each positive training image in the aforementioned positive training set includes a positive label, and the aforementioned training queue determination unit is specifically used for...
[0126] The positive training images in the positive training set are shuffled according to their positive labels to obtain a shuffled positive training set. Based on the total number of images, a first number of positive training images are obtained from the shuffled positive training set. Based on the total number of images and the first number, a second number of negative training images are randomly obtained from the negative training set. The first number of positive training images and the second number of negative training images are arranged in sequence to form a second element. The second elements are arranged in sequence to form a mixed queue.
[0127] Optionally, each positive training image in the positive training set includes a positive sample label, and each negative training image in the negative training set includes a negative sample label. The training queue determination unit is specifically used for...
[0128] For each second element, based on the ranking results of the positive and negative training images in the second element, the corresponding positive and negative labels are sorted to determine the label matrix corresponding to the second element. The second element is then input into the initial face recognition model for feature extraction to obtain the third face features corresponding to the second element. The third face features are then segmented according to the label arrangement order in the label matrix to determine the positive features corresponding to the positive training images in the second element and the negative features corresponding to the negative training images. The first loss corresponding to the positive training images is calculated based on the positive features, and the second loss corresponding to the negative training images is calculated based on the negative features. The initial face recognition model is then trained based on the first and second losses to obtain the face recognition model.
[0129] Optionally, the aforementioned negative sample training set includes at least one type of negative sample training set, and each second element includes a negative sample image of a type corresponding to the type of negative sample training set. The aforementioned training queue determination unit is specifically used for...
[0130] For each type of negative sample image in the second element, the feature similarity between each pair of negative sample training images in the second element is calculated based on their respective negative sample features. Each feature similarity is then matched with a preset loss segmentation function to determine the third loss corresponding to each feature similarity. The aforementioned loss segmentation function includes multiple similarity intervals and the loss corresponding to each similarity interval. Each similarity interval corresponds to a certain level of false recognition rate, and the maximum value of the similarity interval is proportional to the magnitude of its corresponding loss. The total second loss corresponding to the negative sample training images in the second element is determined based on the third loss of each feature similarity.
[0131] It should be noted that the apparatus provided in this embodiment of the invention can implement all the method steps implemented in the above method embodiment and can achieve the same technical effect. Therefore, the parts and beneficial effects that are the same as those in the method embodiment will not be described in detail here.
[0132] Figure 8 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 8 As shown, the electronic device may include: a processor 510, a communications interface 520, a memory 530, and a communication bus 540, wherein the processor 510, the communications interface 520, and the memory 530 communicate with each other through the communication bus 540. The processor 510 can call logical instructions in the memory 530 to execute a face recognition method, which includes: acquiring a face image to be recognized; the face image to be recognized includes the face to be recognized; inputting the face image to be recognized into a preset face recognition model for face recognition processing, and determining at least one candidate face image related to the face to be recognized; the false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold; wherein the face recognition model is trained based on separate positive sample training sets and negative sample training sets, the positive sample training set includes multiple positive sample training images, the negative sample training set includes at least one negative sample training image, and the image quality of the positive sample training images is higher than that of the negative sample training images.
[0133] Furthermore, the logical instructions in the aforementioned memory 530 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0134] On the other hand, the present invention also provides a computer program product, which includes a computer program that can be stored on a computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the face recognition method provided by the above methods. The method includes: acquiring a face image to be recognized; the face image to be recognized includes the face to be recognized; inputting the face image to be recognized into a preset face recognition model for face recognition processing, and determining at least one candidate face image related to the face to be recognized; the false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold; wherein the face recognition model is trained based on separate positive sample training sets and negative sample training sets, the positive sample training set includes multiple positive sample training images, the negative sample training set includes at least one negative sample training image, and the image quality of the positive sample training images is higher than the image quality of the negative sample training images.
[0135] In another aspect, the present invention also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the face recognition method provided by the above methods. The method includes: acquiring a face image to be recognized; the face image to be recognized includes a face to be recognized; inputting the face image to be recognized into a preset face recognition model for face recognition processing, and determining at least one candidate face image related to the face to be recognized; the false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold; wherein the face recognition model is trained based on separate positive sample training sets and negative sample training sets, the positive sample training set includes multiple positive sample training images, the negative sample training set includes at least one negative sample training image, and the image quality of the positive sample training images is higher than the image quality of the negative sample training images.
[0136] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. 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 the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0137] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A face recognition method, characterized in that, include: Acquire an image of a face to be identified; the image of the face to be identified includes the face to be identified; The face image to be identified is input into a preset face recognition model for face recognition processing to determine at least one candidate face image related to the face to be identified; the false recognition rate between the candidate face image and the face image to be identified is less than a preset false recognition rate threshold. The face recognition model is trained based on separate positive and negative training sets. The positive training set includes multiple positive training images, and the negative training set includes at least one negative training image. The image quality of the positive training images is higher than that of the negative training images.
2. The face recognition method according to claim 1, characterized in that, The methods for determining the positive sample training set and the negative sample training set include: Obtain the total training set and the known set of face test images; the total training set includes multiple training images, the set of face test images includes multiple face test images, and the image quality of the face test images is lower than a preset quality threshold; Based on the set of face test images, at least one negative sample training image that matches the image quality of the face test images is selected from the total training set, and the at least one negative sample training image is removed from the total training set to obtain the positive sample training set. The at least one negative sample training image is merged with the face test image set to obtain the negative sample training set.
3. The face recognition method according to claim 2, characterized in that, The step of selecting at least one negative sample training image from the total training set that matches the image quality of the face test images, based on the face test image set, includes: The total training set is input into the baseline recognition model for feature extraction processing to determine the first face feature corresponding to the total training set; and the face test image set is input into the baseline recognition model for feature extraction processing to determine the second face feature corresponding to the face test image set. Matrix operations are performed on the second face feature and the first face feature to determine a collision matrix; the collision matrix includes multiple first elements, each first element representing the image similarity between each face test image in the face test image set and each training image in the total training set; Based on each first element in the collision matrix, at least one negative sample training image that matches the image quality of the face test image is selected from the total training set.
4. The face recognition method according to claim 3, characterized in that, The step of selecting at least one negative sample training image from the total training set that matches the image quality of the face test image based on each first element in the collision matrix includes: Based on a preset false recognition rate condition, a target element corresponding to the preset false recognition rate condition is determined from multiple first elements of the collision matrix, and the target element is determined as a similarity threshold. If any first element in the collision matrix is greater than the similarity threshold, then the training image corresponding to any first element is used as a negative sample training image.
5. The face recognition method according to any one of claims 1 to 4, characterized in that, The training methods for the face recognition model include: Obtain the total number of input images required in each iteration of the initial face recognition model; Based on the total number of images, the positive sample training set and the negative sample training set are arranged into a mixed queue in a set order; the mixed queue includes a plurality of second elements, each second element including a first number of positive sample training images and a second number of negative sample training images. In each iteration of the initial face recognition model, a second element is sequentially obtained from the hybrid queue and input into the initial face recognition model for training to obtain the face recognition model.
6. The face recognition method according to claim 5, characterized in that, Each positive training image in the positive training set includes a positive label. The step of forming a mixed queue of the positive training set and the negative training set according to a predetermined order based on the total number of images includes: The positive training images in the positive training set are shuffled according to their positive labels to obtain the shuffled positive training set. Based on the total number of images, a first number of positive sample training images are obtained from the disordered positive sample training set, and based on the total number of images and the first number, a second number of negative sample training images are randomly obtained from the negative sample training set, and the first number of positive sample training images and the second number of negative sample training images are arranged in sequence to form a second element. The second elements are arranged sequentially to form the hybrid queue.
7. The face recognition method according to claim 5, characterized in that, Each positive training image in the positive training set includes a positive sample label, and each negative training image in the negative training set includes a negative sample label. The step of inputting the second element into the initial face recognition model for training to obtain the face recognition model includes: For each second element, based on the sorting results of the positive and negative training images in the second element, sort the corresponding positive and negative labels to determine the label matrix corresponding to the second element; The second element is input into the initial face recognition model for feature extraction to obtain the third face feature corresponding to the second element; Based on the label arrangement order in the label matrix, the third face feature is segmented to determine the positive sample features corresponding to the positive sample training image and the negative sample features corresponding to the negative sample training image in the second element. The first loss corresponding to the positive sample training image is calculated based on the positive sample features, and the second loss corresponding to the negative sample training image is calculated based on the negative sample features. The initial face recognition model is then trained based on the first loss and the second loss to obtain the face recognition model.
8. The face recognition method according to claim 7, characterized in that, The negative sample training set includes at least one type of negative sample training set, and each second element includes a negative sample image of a type corresponding to the type of the negative sample training set. The step of calculating the second loss corresponding to the negative sample training image based on the negative sample features includes: For each type of negative sample image in the second element, the feature similarity between each pair of negative sample training images in the second element is calculated based on their respective negative sample features. Each feature similarity is matched with a preset loss segmentation function to determine the third loss corresponding to each feature similarity; the loss segmentation function includes multiple similarity intervals and the loss corresponding to each similarity interval, each similarity interval corresponds to the false recognition rate at each level, and the maximum value of the similarity interval is proportional to the size of its corresponding loss; The total second loss corresponding to the negative sample training image in the second element is determined based on the third loss of each feature similarity.
9. A face recognition device, characterized in that, include: An acquisition module is used to acquire an image of a face to be identified; the image of the face to be identified includes the face to be identified. The face recognition module is used to input the face image to be recognized into a preset face recognition model for face recognition processing, and determine at least one candidate face image related to the face to be recognized; the false recognition rate between the candidate face image and the face image to be recognized is less than a preset false recognition rate threshold; The face recognition model is trained based on separate positive and negative training sets. The positive training set includes multiple positive training images, and the negative training set includes at least one negative training image. The image quality of the positive training images is higher than that of the negative training images.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the face recognition method as described in any one of claims 1 to 8.