Face template dynamic updating method and device, storage medium and computer equipment
By using a dynamic face template update method, the problems of poor recognition stability and high manual update costs caused by dynamic changes in the appearance of face recognition systems in existing technologies are solved, realizing real-time and accurate updates of face templates and continuous optimization of the system.
Patent Information
- Application Number
- CN202511690426.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-18
- Publication Date
- 2026-02-06
AI Technical Summary
Existing facial recognition systems adopt a "one-time registration, permanent recognition" model, which leads to a significant difference between the real-time recognition image and the initial fixed template features when the appearance changes dynamically. This results in poor recognition stability and high costs for manual updates, making it difficult to meet the stability requirements of long-term facial recognition scenarios.
A method for dynamically updating face templates is provided. The method triggers template updates by detecting preset conditions, obtains the current face template and candidate sample set, performs cluster analysis, selects the cluster center with high similarity as the new face template, and clears the candidate sample library to achieve dynamic updates.
It enables real-time and accurate dynamic updates of face templates, enhancing the system's flexibility and adaptability, ensuring accurate identification of target users in various changing environments, and allowing the system to be continuously optimized and upgraded.
Smart Images

Figure CN121482877A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of face recognition, and particularly relates to a face template dynamic updating method and device, a storage medium and a computer device. BACKGROUND
[0002] The existing face recognition system generally adopts a "one-time registration permanent recognition" mode. After a fixed template is generated by a user during first-time registration, there are significant defects in long-term use, specifically as follows:
[0003] 1) Insufficient adaptation to dynamic changes in appearance: changes in real-time recognition images and initial fixed template features are increased due to the user's age growth (facial contour and skin state change), appearance adjustment (hair style and beard style change), temporary accessories (makeup and wearing glasses), and the like;
[0004] 2) Poor recognition stability: the above changes cause the recognition score to decrease, and even cause misrecognition and rejection, thereby affecting the face recognition efficiency;
[0005] 3) High cost of manual updating: the existing solution relies on user manual re-registration, which is tedious and cannot adapt to dynamic changes in time, and thus cannot meet the stability requirements of long-term face recognition scenarios. SUMMARY
[0006] The present application aims to at least solve one of the above technical defects, and particularly aims to solve the technical defects that the face recognition system in the prior art adopts a "one-time registration permanent recognition" mode, which causes changes in real-time recognition images and initial fixed template features to be increased, and recognition stability to be poor, and dynamic changes to be adapted in time.
[0007] The present application provides a face template dynamic updating method, which comprises the following steps:
[0008] When it is detected that a face template of a target user meets preset template updating conditions, a current face template of the target user saved in a template database is acquired, and a candidate sample set saved in a candidate sample library when the target user is currently updated is called;
[0009] A clustering analysis is performed on the current face template and the candidate sample set, a plurality of cluster centers are obtained, at least one cluster center is selected as a new face template from the plurality of cluster centers according to the similarity between each cluster center and the current face template;
[0010] The current face template in the template database is replaced by the new face template, and the candidate sample set in the candidate sample library is emptied.
[0011] Optionally, the step of obtaining the current face template of the target user stored in the template database when the target user's face template is detected to meet the preset template update conditions includes:
[0012] When the target user's face template is detected to meet the preset update cycle, the current face template of the target user stored in the template database is obtained;
[0013] Alternatively, when the number of candidate samples of the target user stored in the candidate sample library meets the preset sample number threshold, the current face template of the target user stored in the template database is obtained.
[0014] Optionally, before detecting that the number of candidate samples of the target user stored in the candidate sample library meets a preset sample number threshold, the method further includes:
[0015] The existence of outliers in the candidate sample library is detected using the isolated forest algorithm.
[0016] If they exist, the outlier samples are removed, and then it is detected whether there are unstable samples in the candidate sample library. The unstable samples refer to samples whose number proportion is less than a preset proportion threshold, and whose corresponding cluster center has a similarity to the current face template in the template database that is less than a first preset similarity threshold.
[0017] If no outlier samples are found, the presence of unstable samples in the candidate sample library is directly detected.
[0018] If there are unstable state samples, then the unstable state samples are removed.
[0019] If there are no unstable state samples, no action is taken.
[0020] Optionally, the process of forming the candidate sample set includes:
[0021] The face image of the target user is acquired each time face recognition is triggered after the last update of the face template. The face image is then preprocessed to obtain a preprocessed face image.
[0022] The facial feature vector is extracted from the preprocessed facial image, and the facial feature vector is matched with the current facial template of the target user stored in the template database to obtain the similarity matching result.
[0023] Based on the preprocessed face image and the similarity matching result, determine whether to use the face feature vector as a candidate sample;
[0024] If so, the facial feature vector and the corresponding preprocessed facial image are stored in the candidate sample library;
[0025] Otherwise, the facial feature vector and the corresponding preprocessed facial image will not be stored in the candidate sample library.
[0026] Optionally, determining whether to use the facial feature vector as a candidate sample based on the preprocessed facial image and the similarity matching result includes:
[0027] The image quality of the preprocessed face image is determined, and the image quality is compared with a preset image quality threshold to obtain a first comparison result;
[0028] The similarity matching result is compared with a preset matching score threshold to obtain a second comparison result;
[0029] If the first comparison result indicates that the image quality is not less than the preset image quality threshold, and the second comparison result indicates that the similarity matching result is not less than the preset matching score threshold, then the face feature vector is determined to be a candidate sample.
[0030] If the first comparison result indicates that the image quality is less than the preset image quality threshold, and / or the second comparison result indicates that the similarity matching result is less than the preset matching score threshold, then it is determined that the face feature vector will not be used as a candidate sample.
[0031] Optionally, the cluster analysis of the current face template and the candidate sample set to obtain multiple cluster centers includes:
[0032] A preset clustering algorithm is used to divide the current face template and the candidate sample set into multiple clusters according to a preset number of clusters;
[0033] Calculate the central feature vector of each cluster to obtain multiple cluster centers.
[0034] Optionally, the step of selecting at least one cluster center from multiple cluster centers as a new face template based on the similarity between each cluster center and the current face template includes:
[0035] Calculate the similarity between each cluster center and the current face template to obtain multiple similarity values;
[0036] Cluster centers with similarity values not less than the second preset similarity threshold are used as candidate update templates;
[0037] Based on the number of candidate update templates and their corresponding states, at least one candidate update template is selected from the candidate update templates as a new face template.
[0038] Optionally, selecting at least one candidate update template as a new face template from the candidate update templates based on the number of candidate update templates and their corresponding states includes:
[0039] If there is only one candidate update template, then the candidate update template will be used directly as the new face template.
[0040] If there are multiple candidate update templates, the existence of a main state and a temporary state representing the appearance state of the target user is determined based on the number of candidate samples corresponding to each candidate update template.
[0041] If it exists, the candidate update template corresponding to the main state is used as the main template, and the candidate update template corresponding to the temporary state is used as the backup template. The backup template is used to perform secondary face matching when the face matching score of the main template is less than a preset score threshold.
[0042] If it does not exist, the candidate update template with the most candidate samples will be used as the new face template.
[0043] Optionally, the method further includes:
[0044] Continuously monitor the target user's face recognition scores multiple times when face recognition is triggered after the template is updated;
[0045] If the face recognition score is lower than the preset recognition score threshold multiple times in a row, the template update is determined to be abnormal, and the template backtracking mechanism is triggered to restore the current face template to the face template before the update, and send an abnormal reminder to relevant personnel.
[0046] If the face recognition score is not lower than the preset recognition score threshold at least once, the template update is determined to be normal, and the monitoring process is exited.
[0047] This application also provides a face template dynamic update device, including:
[0048] The data acquisition module is used to acquire the current face template of the target user stored in the template database when the face template of the target user is detected to meet the preset template update conditions, and to retrieve the candidate sample set saved when the target user is currently updated from the candidate sample library.
[0049] The template selection module is used to perform cluster analysis on the current face template and the candidate sample set to obtain multiple cluster centers. Based on the similarity between each cluster center and the current face template, at least one cluster center is selected from the multiple cluster centers as a new face template.
[0050] The template update module is used to replace the current face template in the template database with the new face template, and to clear the candidate sample set in the candidate sample library.
[0051] This application also provides a computer-readable storage medium storing computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the face template dynamic update method as described in any of the above embodiments.
[0052] This application also provides a computer device, including: one or more processors, and memory;
[0053] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the face template dynamic update method as described in any of the above embodiments.
[0054] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0055] The face template dynamic update method, apparatus, storage medium, and computer equipment provided in this application can, when a target user's face template is detected to meet preset template update conditions, obtain the target user's current face template stored in the template database and retrieve the candidate sample set saved during the current update from the candidate sample library. Next, this application can perform cluster analysis on the current face template and the candidate sample set, and select at least one cluster center from multiple cluster centers as a new face template based on the similarity between each cluster center and the current face template. The current face template in the template database is then replaced with the new face template. This not only enables real-time and accurate dynamic updates of the face template according to the target user's actual situation, ensuring accurate identification of the target user in various changing environments, but also enhances the system's flexibility and adaptability, enabling it to better cope with challenges in different scenarios. Finally, this application can also clear the candidate sample set in the candidate sample library, thereby preparing for the next template update process and ensuring the system's continuous optimization and upgrade capabilities. Attached Figure Description
[0056] To more clearly illustrate the technical solutions in the embodiments of this application 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 only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0057] Figure 1A flowchart illustrating a method for dynamically updating a face template provided in an embodiment of this application;
[0058] Figure 2 A schematic diagram illustrating the process of determining whether to use a facial feature vector as a candidate sample, provided in an embodiment of this application.
[0059] Figure 3 A schematic diagram illustrating the process of selecting at least one candidate update template from candidate update templates as a new face template, as provided in an embodiment of this application.
[0060] Figure 4 This is a schematic diagram of the structure of a face template dynamic updating device provided in an embodiment of this application;
[0061] Figure 5 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0062] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0063] In one embodiment, such as Figure 1 As shown, Figure 1 This is a flowchart illustrating a method for dynamically updating a face template according to an embodiment of this application; this application provides a method for dynamically updating a face template, the method including:
[0064] S110: When the target user's face template is detected to meet the preset template update conditions, the current face template of the target user stored in the template database is obtained, and the candidate sample set saved when the target user is currently updated is retrieved from the candidate sample library.
[0065] In this step, when dynamically updating the face template of the target user, it is possible to first check whether the face template of the target user meets the preset template update conditions. These template update conditions may include update cycle conditions or candidate sample quantity conditions, etc. The specific settings can be made according to the actual situation, and there are no restrictions here.
[0066] When the preset template update conditions are met, this application can obtain the current face template of the target user from the template database. The template database is used to store face template information of different users. The face template information may include the current face template and historical face templates. The template database also records the template generation time and collection environment parameters (such as light intensity and device model) to facilitate subsequent traceability.
[0067] Meanwhile, this application can also retrieve the candidate sample set saved by the target user during the current update from the candidate sample library. This candidate sample library is used to store sample information such as face images and corresponding face feature vectors collected and filtered by different users after the last update of the face template and each time face recognition is triggered, thereby accumulating reliable data for subsequent clustering updates and avoiding low-quality samples (blurred, severely occluded) from polluting the clustering results.
[0068] S120: Perform cluster analysis on the current face template and candidate sample set to obtain multiple cluster centers. Based on the similarity between each cluster center and the current face template, select at least one cluster center from the multiple cluster centers as the new face template.
[0069] In this step, after obtaining the current face template of the target user stored in the template database through S110 and retrieving the candidate sample set saved when the target user is currently updated from the candidate sample library, this application can perform cluster analysis on the current face template and the candidate sample set, thus obtaining multiple cluster centers. Then, this application can select at least one cluster center as a new face template from the multiple cluster centers based on the similarity between each cluster center and the current face template.
[0070] Specifically, this application can employ a preset clustering algorithm to divide the current face template and candidate sample set into multiple clusters according to a preset number of clusters. For example, the K-Means clustering algorithm can be used to divide samples into different clusters by calculating indicators such as the distance between samples. Then, the central feature vector of each cluster is calculated, thereby obtaining multiple cluster centers, which represent the feature centers of samples of different categories.
[0071] Next, this application can calculate the similarity between each cluster center and the current face template. After obtaining multiple similarity values, this application can select at least one cluster center as a new face template based on the similarity values between each cluster center and the current face template. It is understood that a higher similarity value indicates that the cluster center is closer to the current face template and is more likely to represent the target user's current true appearance features. The core principle of the template update strategy in this application is that the system always tends to select the template that best represents the user's long-term, stable, and mainstream appearance state.
[0072] Therefore, this application can select the cluster center that best represents the user's long-term, stable, and mainstream appearance state from multiple cluster centers as the new face template. Furthermore, considering that a user's appearance state may change intermittently, when different appearance states are similar to the current face template, this application can also select multiple cluster centers as new face templates, each corresponding to a different appearance state. For example, when a user has two appearance states—a primary state and a temporary state—and the cluster centers corresponding to these two states have a high similarity to the current face template, this application can use the cluster center corresponding to the primary state as the primary template and the cluster center corresponding to the temporary state as a backup template. The primary template is used for daily face recognition, while the backup template can perform secondary face matching when the face matching score of the primary template falls below a preset threshold, thereby improving the accuracy and robustness of face recognition.
[0073] S130: Replace the current face template in the template database with the new face template, and clear the candidate sample set in the candidate sample library.
[0074] In this step, after selecting the cluster center that best represents the user's long-term, stable, and mainstream appearance from multiple cluster centers via S120 as the new face template, this application can replace the existing current face template in the template database with the new face template, so that subsequent face recognition is based on the updated face template. Simultaneously, this application can also clear the candidate sample set in the candidate sample library to prepare for the next template update process, ensuring that the system can be continuously optimized and upgraded to better adapt to changes in the target user's appearance.
[0075] In the above embodiments, when the target user's face template is detected to meet the preset template update conditions, the current face template of the target user stored in the template database can be obtained, and the candidate sample set saved during the current update of the target user can be retrieved from the candidate sample library. Next, this application can perform cluster analysis on the current face template and the candidate sample set, and select at least one cluster center from multiple cluster centers as a new face template based on the similarity between each cluster center and the current face template. The current face template in the template database is then replaced with the new face template. This not only enables real-time and accurate dynamic updating of the face template according to the actual situation of the target user, ensuring accurate identification of the target user in various changing environments, but also enhances the flexibility and adaptability of the system, enabling it to better cope with challenges in different scenarios. Finally, this application can also clear the candidate sample set in the candidate sample library, thereby preparing for the next template update process and ensuring the continuous optimization and upgrade capability of the system.
[0076] In one embodiment, when it is detected that the face template of the target user meets the preset template update conditions, obtaining the current face template of the target user stored in the template database in S110 may include:
[0077] S111: When the face template of the target user is detected to meet the preset update cycle, the current face template of the target user stored in the template database is obtained.
[0078] S112: Alternatively, when it is detected that the number of candidate samples of the target user stored in the candidate sample library meets the preset sample number threshold, the current face template of the target user stored in the template database is obtained.
[0079] In this embodiment, the preset template update conditions can be flexibly set to two triggering mechanisms in parallel. On the one hand, when the system detects that the target user's face template has reached the preset update cycle since the last update (such as once a week, setting a fixed update cycle (every Sunday at 00:00, outside of peak attendance hours) to avoid the update operation occupying attendance resources), the template update process is automatically triggered. At this time, the currently effective face template of the user is retrieved from the template database as the basic reference.
[0080] On the other hand, if the number of candidate samples accumulated for a user in the candidate sample library reaches a preset threshold (e.g., 400 or 500 valid samples after quality screening), the update procedure is immediately initiated, and the current face template is also obtained from the template database. The preset sample number threshold in this application can be set according to actual conditions to ensure that the sample size is sufficient to support cluster analysis, thereby reducing clustering bias caused by small samples.
[0081] This dual-condition triggering mechanism ensures both the periodicity of template updates, preventing a decline in recognition rate due to prolonged periods without updates, and the flexibility to adjust the update pace based on actual sample accumulation, ensuring sufficient data support for each update. When either condition is met, the system will simultaneously execute subsequent clustering analysis and template replacement operations, while clearing the candidate sample library to prepare for the next round of updates, forming a complete closed-loop optimization process.
[0082] In one embodiment, before detecting that the number of candidate samples of the target user stored in the candidate sample library meets a preset sample number threshold, step S112 may further include:
[0083] S1121: Detect whether there are outliers in the candidate sample library using the isolated forest algorithm.
[0084] S1122: If they exist, after removing the outlier samples, detect whether there are unstable state samples in the candidate sample library. The unstable state samples refer to samples whose number proportion is less than a preset proportion threshold, and whose corresponding cluster center has a similarity to the current face template in the template database that is less than a first preset similarity threshold.
[0085] S1123: If there are no outlier samples, then directly detect whether there are unstable samples in the candidate sample library.
[0086] S1124: If there are unstable state samples, then the unstable state samples are removed.
[0087] S1125: If there are no unstable state samples, no processing is required.
[0088] In this embodiment, before performing candidate sample quantity detection, the system first screens the candidate sample library for outliers using the Isolation Forest algorithm. This algorithm constructs a random hyperplane to segment the sample space and identifies outliers based on sample path length, effectively eliminating low-quality samples caused by factors such as equipment malfunction, environmental interference, or human occlusion. For example, if the path length of a sample is significantly shorter than that of normal samples, it is determined to be an outlier and is removed.
[0089] After cleaning up outliers, the system further checks for unstable samples. These samples must meet two conditions: first, their proportion within their cluster is below a preset threshold (e.g., 10%); second, the similarity between their cluster center and the current face template is below a first preset threshold (e.g., 0.7). For example, when a user's facial features change due to temporary makeup, these samples may form independent small clusters, but because they cannot represent the user's long-term characteristics, they are judged as unstable samples.
[0090] If unstable samples are detected, the system will automatically perform a removal operation, retaining only candidate samples that reflect the user's mainstream characteristics and meet the quantity requirements. This dual screening mechanism ensures the data quality of cluster analysis, avoiding the impact of outliers on cluster center shifts and preventing short-term feature changes from interfering with template updates. Ultimately, only samples that pass the quality check will be included in the sample count. The system will only trigger the subsequent template update process when the number of valid samples reaches a preset threshold.
[0091] In one embodiment, the process of forming the candidate sample set may include:
[0092] S101: Obtain the face image of the target user each time face recognition is triggered after the last update of the face template, preprocess the face image to obtain the preprocessed face image.
[0093] S103: Extract facial feature vectors from the preprocessed face image, and perform similarity matching between the facial feature vectors and the current face template of the target user stored in the template database to obtain a similarity matching result.
[0094] S103: Determine whether to use the facial feature vector as a candidate sample based on the preprocessed face image and the similarity matching result.
[0095] S104: If so, the facial feature vector and the corresponding preprocessed facial image are stored in the candidate sample library.
[0096] S105: Otherwise, the facial feature vector and the corresponding preprocessed facial image are not stored in the candidate sample library.
[0097] In this embodiment, after the target user completes the last face template update, the sample acquisition process is executed synchronously whenever the system triggers the face recognition function. First, the user's face image is acquired through an image acquisition device. Then, preprocessing operations such as grayscale conversion, histogram equalization, and geometric correction are performed on the original image to eliminate interference factors such as uneven lighting and angular deviations. Next, this application can use deep learning models such as ArcFace or CosFace to extract a 128-dimensional feature vector of the face region. This vector contains core feature information such as facial contours and the distribution of facial features.
[0098] Furthermore, the system can calculate the cosine similarity between the extracted feature vector and the current face template stored in the template database, obtaining a matching score in the range of 0-1. When the similarity exceeds a preset threshold (e.g., 0.85), the sample is determined to be a valid candidate sample; if it is below the threshold, it is determined to be an invalid sample. This dynamic filtering mechanism can ensure the correlation between the sample and the user's current features, while avoiding false rejections caused by normal fluctuations such as changes in facial expressions or slight occlusion.
[0099] For samples that pass quality inspection, the system can associate and store their feature vectors with preprocessed images, and record metadata such as acquisition time and device model. All valid samples are categorized by user ID and stored in a candidate sample library, providing a data foundation for subsequent clustering analysis. When a user triggers facial recognition, the system will simultaneously execute the sample acquisition and screening process to ensure that the candidate sample library can reflect the changing trends of the user's facial features in real time.
[0100] This sample formation mechanism employs a three-tiered screening system—preprocessing, feature extraction, and similarity matching—to ensure both data quality and update efficiency. Preprocessing eliminates environmental interference, feature extraction captures core biometrics, and similarity matching ensures sample representativeness. This triple-layered protection mechanism ensures that the data in the candidate sample library reflects both long-term stable user characteristics and a reasonable range of short-term variations, providing reliable data support for subsequent template updates.
[0101] In one embodiment, such as Figure 2 As shown, Figure 2 This is a schematic diagram illustrating the process of determining whether to use a facial feature vector as a candidate sample, as provided in the embodiments of this application. S103, determining whether to use the facial feature vector as a candidate sample based on the preprocessed facial image and the similarity matching result, may include:
[0102] S1031: Determine the image quality of the preprocessed face image, compare the image quality with a preset image quality threshold, and obtain the first comparison result.
[0103] S1032: Compare the similarity matching result with the preset matching score threshold to obtain the second comparison result.
[0104] S1033: If the first comparison result is that the image quality is not less than the preset image quality threshold, and the second comparison result is that the similarity matching result is not less than the preset matching score threshold, then the face feature vector is determined as a candidate sample.
[0105] S1034: If the first comparison result is that the image quality is less than the preset image quality threshold, and / or the second comparison result is that the similarity matching result is less than the preset matching score threshold, then it is determined that the face feature vector will not be used as a candidate sample.
[0106] In this embodiment, when determining whether to use facial feature vectors as candidate samples, the system can perform dual screening of candidate samples from two dimensions: image quality and matching degree. In the image quality assessment stage, this application can use a referenceless image quality evaluation algorithm (such as BRISQUE) to calculate indicators such as sharpness and noise level of the preprocessed image, and compare them with preset image quality thresholds (such as sharpness ≥ 0.8 and occlusion area ≤ 10%). This algorithm effectively identifies quality problems such as blurring and overexposure by analyzing the statistical characteristics of natural scenes in the image, without requiring an original reference image.
[0107] In the similarity matching stage, the system calculates the cosine similarity between the extracted 128-dimensional feature vector and the current face template in the template library. Once the image quality score meets the standard, if the similarity score exceeds a preset matching score threshold (e.g., 0.9), the sample is deemed to simultaneously meet both quality and feature consistency requirements. This dual-control mechanism of "quality-feature" ensures that candidate samples possess clear biometric representations and accurately reflect the user's current appearance.
[0108] For samples that pass the double verification, the system can associate and store their feature vectors with the preprocessed image, and record metadata such as acquisition time and device type. Samples that do not meet the standards are only recorded as invalid samples in the attendance or access control system (this does not affect normal attendance) and are not stored in the candidate sample library.
[0109] This screening strategy avoids wasting computational resources through pre-screening quality checks, while improving the accuracy of template updates. When the number of valid samples in the candidate sample library reaches a preset threshold, the system will automatically trigger the subsequent clustering analysis process, forming a complete closed-loop system of sample collection, quality control, and template updates.
[0110] In one embodiment, S120 performs cluster analysis on the current face template and the candidate sample set to obtain multiple cluster centers, which may include:
[0111] S121: Using a preset clustering algorithm, the current face template and the candidate sample set are divided into multiple clusters according to a preset number of clusters.
[0112] S122: Calculate the central feature vector of each cluster to obtain multiple cluster centers.
[0113] In this embodiment, the system first selects a mature clustering algorithm, such as the K-means algorithm. This algorithm is simple to implement and highly efficient, and can well meet the requirements of this application for clustering analysis of face templates and candidate sample sets. Meanwhile, the preset number of clusters is not fixed, but can be flexibly adjusted according to actual conditions, such as the complexity of the target user's historical data features and the number of samples.
[0114] After determining the clustering algorithm and the number of clusters, the system can input all sample data from the current face template and candidate sample set into the algorithm, which will then divide the data into clusters according to the preset number of clusters. During the division process, the algorithm will group samples with high similarity into the same cluster based on the feature similarity between the samples, thus forming multiple different clusters.
[0115] After clustering, the system can further process each cluster, calculating the central feature vector for each cluster. Specifically, for each cluster, the system can statistically analyze the feature vectors of all samples within that cluster, and then use specific calculation methods (such as averaging) to obtain the central feature vectors that represent the overall characteristics of the cluster. These central feature vectors constitute multiple cluster centers. These cluster centers will serve as an important basis for selecting new face templates in subsequent steps, ensuring that the selected new face templates accurately represent the user's long-term, stable, and mainstream appearance.
[0116] In one specific implementation, this application can use the K-means clustering algorithm to analyze the sample set, and set the number of clusters K=2 (to adapt to different appearance states, such as no beard / with beard, no glasses / with glasses). The algorithm will randomly select two samples as initial cluster centers, and then iteratively calculate and assign all samples to the category of the nearest cluster center. After each iteration, the system will recalculate the central feature vector of each cluster (i.e., the mean of all sample feature vectors), and adjust the sample assignment based on the new cluster centers, until the cluster centers no longer change significantly or the preset number of iterations is reached.
[0117] This dynamic optimization mechanism can automatically capture stable patterns in users' appearance features, such as changes in eye features caused by long-term wearing of glasses, or differences in facial contours due to seasonal beard growth. The two cluster centers generated ultimately represent typical features of users in different states, providing a reliable basis for subsequent template selection. If the user's feature distribution is relatively simple (such as maintaining a fixed hairstyle and makeup for a long time), the system can also adjust the number of clusters K=1, directly using the mean vector of all samples as the unique cluster center, ensuring the flexibility and accuracy of template updates.
[0118] In one embodiment, selecting at least one cluster center as a new face template from multiple cluster centers based on the similarity between each cluster center and the current face template in step S120 may include:
[0119] S123: Calculate the similarity between each cluster center and the current face template to obtain multiple similarity values.
[0120] S124: Use cluster centers with similarity values not less than the second preset similarity threshold as candidate update templates.
[0121] S125: Based on the number of candidate update templates and their corresponding states, select at least one candidate update template from the candidate update templates as a new face template.
[0122] In this embodiment, when selecting at least one cluster center from multiple cluster centers as a new face template, the system first calculates the similarity between each cluster center obtained through cluster analysis and the current face template. This step aims to quantitatively evaluate the closeness of each cluster center to the user's current appearance features, providing a quantitative basis for subsequent template updates. Common similarity measurement methods such as cosine similarity and Euclidean distance can be used when calculating similarity. The specific method can be chosen based on actual needs and the characteristics of the feature vectors, and no restrictions are imposed here.
[0123] After obtaining multiple similarity values, the system can set a second preset similarity threshold. This threshold is used to filter out cluster centers that are sufficiently similar to the current face template as candidate update templates. The purpose of this step is to ensure that the updated face template can maintain the continuity and stability of the user's facial features, avoiding a decrease in recognition rate due to over-updating. Only cluster centers with similarity values not less than this threshold will be included in the candidate update template consideration.
[0124] After identifying candidate update templates, the system can further select at least one candidate update template as the new face template based on the number of candidate update templates and their corresponding status. The decision logic for this step can be flexible and varied. For example, when there is only one candidate update template, it can be directly used as the new face template; when there are multiple candidate update templates, a comprehensive evaluation can be conducted based on factors such as their similarity value with the current face template, the proportion of samples, and cluster stability, to select the candidate update template that best matches the user's long-term, stable, and mainstream appearance status as the new face template.
[0125] Furthermore, the system could consider incorporating a user feedback mechanism, allowing users to manually confirm or adjust candidate update templates, thereby improving the accuracy of template updates and user satisfaction. For example, after the system automatically selects a new face template, both the old and new templates can be displayed to the user simultaneously, allowing them to choose or fine-tune according to their needs and aesthetic preferences. This human-machine collaborative approach retains the efficiency of automated updates while increasing the flexibility and personalization of user participation.
[0126] In one embodiment, such as Figure 3 As shown, Figure 3 This is a schematic diagram illustrating the process of selecting at least one candidate update template from the candidate update templates as a new face template, as provided in the embodiments of this application. S125, selecting at least one candidate update template from the candidate update templates as a new face template based on the number of candidate update templates and their corresponding states, may include:
[0127] S1251: If there is only one candidate update template, then the candidate update template will be used directly as the new face template.
[0128] S1252: If there are multiple candidate update templates, determine whether there are main states and temporary states representing the appearance status of the target user based on the number of candidate samples corresponding to each candidate update template.
[0129] S1253: If it exists, then the candidate update template corresponding to the main state is used as the main template, and the candidate update template corresponding to the temporary state is used as the backup template.
[0130] S1254: If it does not exist, the candidate update template with the largest number of candidate samples will be used as the new face template.
[0131] In this embodiment, when there is only one candidate update template, the system can directly use that candidate update template as the new face template. When the system faces multiple candidate update templates, it can initiate an intelligent decision-making process to determine the final face template scheme to be adopted. First, by analyzing the sample quantity distribution corresponding to each candidate template, the system identifies the master and slave states of the user's appearance features—if the sample quantity of a certain state is significantly higher than that of other states (e.g., the proportion exceeds 60%), then that state is determined to be the master state, and the other states are temporary states. For example, if a user has maintained a short hairstyle for a long time but recently tried long hair, the system will set the template corresponding to short hair as the master template and the long hair template as a backup.
[0132] This primary and backup template mechanism achieves a balance between dynamic adaptation and risk control. The primary template handles daily recognition tasks, ensuring a basic recognition rate; the backup template is automatically activated when the primary template fails to match, improving the pass rate in special scenarios through secondary matching. Furthermore, the system can also record the usage frequency of the backup template. When the temporary state continues for more than a preset period (e.g., 3 months) or the sample proportion exceeds a threshold, the backup template is automatically upgraded to the primary template, completing adaptive updates.
[0133] If the sample size of each candidate template is evenly distributed (e.g., the sample proportions of different makeup looks and hairstyles are similar), the system adopts a majority voting principle to select the template with the largest sample size as the sole update template. This strategy avoids system oscillations caused by frequent template switching while ensuring a high degree of alignment between the template and the user's current mainstream characteristics. Furthermore, all template switching operations in this application generate detailed logs, including key information such as switching time, triggering conditions, and comparisons between the old and new templates, thus providing data support for subsequent auditing and optimization.
[0134] Through this hierarchical decision-making mechanism, the system can flexibly respond to gradual or sudden changes in users' physical characteristics while ensuring recognition accuracy, thus effectively balancing the timeliness of updates and system stability.
[0135] In one embodiment, the method may further include:
[0136] S140: Continuously monitor the target user's face recognition scores multiple times when face recognition is triggered after the template is updated.
[0137] S141: If the face recognition score is lower than the preset recognition score threshold multiple times in a row, the template update is determined to be abnormal, and the template backtracking mechanism is triggered to restore the current face template to the face template before the update, and send an abnormal reminder to relevant personnel.
[0138] S142: If the face recognition score is not lower than the preset recognition score threshold at least once, the template update is determined to be normal, and the monitoring process is exited.
[0139] In this embodiment, after updating the face template, the system also initiates a continuous monitoring mechanism to track and record subsequent face recognition processes triggered by the target user. Specifically, the system can record the recognition score generated each time face recognition occurs. These scores reflect the quantitative evaluation of the degree of matching between the current face and the updated template by the face recognition system. By continuously collecting multiple face recognition scores, the system can obtain a set of data sequences regarding the recognition performance after the template update.
[0140] Next, the system can analyze and judge this set of data sequences. If the face recognition score is lower than the preset recognition score threshold multiple times consecutively (e.g., three or more times, the specific number can be set according to the actual application scenario and needs), this threshold is a pre-set critical value used to judge whether the recognition performance meets the standard. When the score is lower than this value, it indicates that there may be a problem in the updated template during the recognition process, resulting in a decrease in recognition accuracy. At this time, the system will determine that the template update is abnormal and immediately trigger the template backtracking mechanism.
[0141] Understandably, the template rollback mechanism set up in this application aims to restore the current face template to the one before the update, that is, to undo the previous update operation and restore the system to the old template state that is familiar to users and has stable recognition performance, thereby ensuring the normal operation of the face recognition system. Simultaneously, the system will also send anomaly alerts to relevant personnel (such as system administrators and maintenance personnel) to notify them that there has been a problem with the template update and that further investigation and handling are required.
[0142] Conversely, if, during the monitoring process, the face recognition score is not lower than the preset recognition score threshold at least once, it indicates that the updated template performed well in at least one recognition and meets the recognition requirements. In this case, the system will determine that the template update is normal and exit the monitoring process, no longer tracking and recording subsequent face recognition scores, thereby saving system resources and improving operating efficiency.
[0143] This dynamic monitoring and feedback mechanism ensures the reliability and stability of face template updates, enabling timely adjustments and corrections when problems occur, and guaranteeing the continuous and efficient operation of the face recognition system.
[0144] The following describes the face template dynamic update device provided in the embodiments of this application. The face template dynamic update device described below can be referred to in correspondence with the face template dynamic update method described above.
[0145] In one embodiment, such as Figure 4 As shown, Figure 4 This is a schematic diagram of a face template dynamic updating device provided in an embodiment of this application; this application also provides a face template dynamic updating device, which may include a data acquisition module 210, a template selection module 220, and a template updating module 230, specifically including the following:
[0146] The data acquisition module 210 is used to acquire the current face template of the target user stored in the template database when the face template of the target user is detected to meet the preset template update conditions, and to retrieve the candidate sample set saved when the target user is currently updating from the candidate sample library.
[0147] The template selection module 220 is used to perform cluster analysis on the current face template and the candidate sample set to obtain multiple cluster centers. Based on the similarity between each cluster center and the current face template, at least one cluster center is selected from the multiple cluster centers as a new face template.
[0148] The template update module 230 is used to replace the current face template in the template database with the new face template, and to clear the candidate sample set in the candidate sample library.
[0149] In the above embodiments, when the target user's face template is detected to meet the preset template update conditions, the current face template of the target user stored in the template database can be obtained, and the candidate sample set saved during the current update of the target user can be retrieved from the candidate sample library. Next, this application can perform cluster analysis on the current face template and the candidate sample set, and select at least one cluster center from multiple cluster centers as a new face template based on the similarity between each cluster center and the current face template. The current face template in the template database is then replaced with the new face template. This not only enables real-time and accurate dynamic updating of the face template according to the actual situation of the target user, ensuring accurate identification of the target user in various changing environments, but also enhances the flexibility and adaptability of the system, enabling it to better cope with challenges in different scenarios. Finally, this application can also clear the candidate sample set in the candidate sample library, thereby preparing for the next template update process and ensuring the continuous optimization and upgrade capability of the system.
[0150] In one embodiment, this application also provides a computer-readable storage medium storing computer-readable instructions that, when executed by one or more processors, cause the one or more processors to perform the steps of the face template dynamic update method as described in any of the above embodiments.
[0151] In one embodiment, this application also provides a computer device, including: one or more processors, and memory.
[0152] The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the face template dynamic update method as described in any of the above embodiments.
[0153] Indicatively, such as Figure 5 As shown, Figure 5 This is a schematic diagram of the internal structure of a computer device 300 provided in an embodiment of this application. The computer device 300 can be provided as a server. (Refer to...) Figure 5 The computer device 300 includes a processing component 302, which further includes one or more processors, and memory resources represented by memory 301 for storing instructions, such as applications, that can be executed by the processing component 302. The applications stored in memory 301 may include one or more modules, each corresponding to a set of instructions. Furthermore, the processing component 302 is configured to execute instructions to perform the face template dynamic update method of any of the above embodiments.
[0154] The computer device 300 may also include a power supply component 303 configured to perform power management of the computer device 300, a wired or wireless network interface 304 configured to connect the computer device 300 to a network, and an input / output (I / O) interface 305. The computer device 300 may operate on an operating system stored in memory 301, such as Windows Server™, Mac OS X™, Unix™, Linux™, Free BSD™, or similar.
[0155] Those skilled in the art will understand that Figure 5 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0156] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0157] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0158] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for dynamically updating a face template, characterized in that, The method includes: When the target user's face template is detected to meet the preset template update conditions, the current face template of the target user stored in the template database is obtained, and the candidate sample set saved when the target user is currently updated is retrieved from the candidate sample library. Cluster analysis is performed on the current face template and the candidate sample set to obtain multiple cluster centers. Based on the similarity between each cluster center and the current face template, at least one cluster center is selected from the multiple cluster centers as a new face template. Replace the current face template in the template database with the new face template, and clear the candidate sample set in the candidate sample library.
2. The method for dynamically updating face templates according to claim 1, characterized in that, When the face template of the target user is detected to meet the preset template update conditions, the current face template of the target user stored in the template database is obtained, including: When the target user's face template is detected to meet the preset update cycle, the current face template of the target user stored in the template database is obtained; Alternatively, when the number of candidate samples of the target user stored in the candidate sample library meets the preset sample number threshold, the current face template of the target user stored in the template database is obtained.
3. The method for dynamically updating face templates according to claim 2, characterized in that, Before detecting that the number of candidate samples of the target user stored in the candidate sample library meets the preset sample number threshold, the process further includes: The existence of outliers in the candidate sample library is detected using the isolated forest algorithm. If they exist, the outlier samples are removed, and then it is detected whether there are unstable samples in the candidate sample library. The unstable samples refer to samples whose number proportion is less than a preset proportion threshold, and whose corresponding cluster center has a similarity to the current face template in the template database that is less than a first preset similarity threshold. If no outlier samples are found, the presence of unstable samples in the candidate sample library is directly detected. If there are unstable state samples, then the unstable state samples are removed. If there are no unstable state samples, no action is taken.
4. The method for dynamically updating face templates according to claim 1, characterized in that, The process of forming the candidate sample set includes: The face image of the target user is acquired each time face recognition is triggered after the last update of the face template. The face image is then preprocessed to obtain a preprocessed face image. The facial feature vector is extracted from the preprocessed facial image, and the facial feature vector is matched with the current facial template of the target user stored in the template database to obtain the similarity matching result. Based on the preprocessed face image and the similarity matching result, determine whether to use the face feature vector as a candidate sample; If so, the facial feature vector and the corresponding preprocessed facial image are stored in the candidate sample library; Otherwise, the facial feature vector and the corresponding preprocessed facial image will not be stored in the candidate sample library.
5. The method for dynamically updating face templates according to claim 4, characterized in that, The step of determining whether to use the facial feature vector as a candidate sample based on the preprocessed facial image and the similarity matching result includes: The image quality of the preprocessed face image is determined, and the image quality is compared with a preset image quality threshold to obtain a first comparison result; The similarity matching result is compared with a preset matching score threshold to obtain a second comparison result; If the first comparison result indicates that the image quality is not less than the preset image quality threshold, and the second comparison result indicates that the similarity matching result is not less than the preset matching score threshold, then the face feature vector is determined to be a candidate sample. If the first comparison result indicates that the image quality is less than the preset image quality threshold, and / or the second comparison result indicates that the similarity matching result is less than the preset matching score threshold, then it is determined that the face feature vector will not be used as a candidate sample.
6. The method for dynamically updating face templates according to claim 1, characterized in that, The clustering analysis of the current face template and the candidate sample set yields multiple cluster centers, including: A preset clustering algorithm is used to divide the current face template and the candidate sample set into multiple clusters according to a preset number of clusters; Calculate the central feature vector of each cluster to obtain multiple cluster centers.
7. The method for dynamically updating a face template according to claim 1 or 6, characterized in that, The step of selecting at least one cluster center from multiple cluster centers as a new face template based on the similarity between each cluster center and the current face template includes: Calculate the similarity between each cluster center and the current face template to obtain multiple similarity values; Cluster centers with similarity values not less than the second preset similarity threshold are used as candidate update templates; Based on the number of candidate update templates and their corresponding states, at least one candidate update template is selected from the candidate update templates as a new face template.
8. The method for dynamically updating a face template according to claim 7, characterized in that, The step of selecting at least one candidate update template as a new face template from the candidate update templates based on the number of candidate update templates and their corresponding states includes: If there is only one candidate update template, then the candidate update template will be used directly as the new face template. If there are multiple candidate update templates, the existence of a main state and a temporary state representing the appearance state of the target user is determined based on the number of candidate samples corresponding to each candidate update template. If it exists, the candidate update template corresponding to the main state is used as the main template, and the candidate update template corresponding to the temporary state is used as the backup template. The backup template is used to perform secondary face matching when the face matching score of the main template is less than a preset score threshold. If it does not exist, the candidate update template with the most candidate samples will be used as the new face template.
9. The method for dynamically updating a face template according to claim 1, characterized in that, The method further includes: Continuously monitor the target user's face recognition scores multiple times when face recognition is triggered after the template is updated; If the face recognition score is lower than the preset recognition score threshold multiple times in a row, the template update is determined to be abnormal, and the template backtracking mechanism is triggered to restore the current face template to the face template before the update, and send an abnormal reminder to relevant personnel. If the face recognition score is not lower than the preset recognition score threshold at least once, the template update is determined to be normal, and the monitoring process is exited.
10. A face template dynamic update device, characterized in that, include: The data acquisition module is used to acquire the current face template of the target user stored in the template database when the face template of the target user is detected to meet the preset template update conditions, and to retrieve the candidate sample set saved when the target user is currently updated from the candidate sample library. The template selection module is used to perform cluster analysis on the current face template and the candidate sample set to obtain multiple cluster centers. Based on the similarity between each cluster center and the current face template, at least one cluster center is selected from the multiple cluster centers as a new face template. The template update module is used to replace the current face template in the template database with the new face template, and to clear the candidate sample set in the candidate sample library.
11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-readable instructions, which, when executed by one or more processors, cause the one or more processors to perform the steps of the face template dynamic update method as described in any one of claims 1 to 9.
12. A computer device, characterized in that, include: One or more processors, and memory; The memory stores computer-readable instructions, which, when executed by the one or more processors, perform the steps of the face template dynamic update method as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Face recognition method based on clustering analysis autonomous re-learning
CN111079720A