Identity recognition, its model training method and device

By extracting general and local features in federated learning and optimizing local models with personalized distinction loss functions, the problem of time-consuming and insufficient local recognition performance of general models is solved, and a more efficient local recognition effect is achieved.

CN119091480BActive Publication Date: 2025-08-05PEKING UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410991190.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2025-08-05
Estimated Expiration
2044-07-23

AI Technical Summary

Technical Problem

Existing federated learning cannot effectively adapt to local features in facial recognition, resulting in increased time-consuming and degraded localized recognition performance.

Method used

By extracting features in general and local models and optimizing the local model with preset personalized distinction loss function, it can distinguish local features in private datasets and generate pre-trained recognition models.

Benefits of technology

Reduces the computational time-consuming of the model and improves the identification performance and adaptability of the local model in the local dataset.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119091480B_ABST
    Figure CN119091480B_ABST
Patent Text Reader

Abstract

This application discloses an identity recognition and model training method and device. The model training method includes: sampling a private data set to obtain training data; extracting features from the training data using a universal model and a local model to obtain universal features belonging to the universal model and local features belonging to the local model; training the local model based on the universal features, local features, and a preset personalized discrimination loss function, wherein the preset personalized discrimination loss function is used to optimize the local model so that the local model can distinguish local features in the private data set; and generating a pre-trained recognition model when the private data set sampling is completed. Therefore, by adopting the embodiments of the present application, the time consumption of the model can be reduced while improving the localized recognition performance of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of machine learning technology, and in particular to a method and device for identity recognition and model training thereof. Background Art

[0002] Federated Learning (FL) is a distributed machine learning method that allows multiple clients (such as mobile devices, browsers, and edge devices) to jointly train a shared machine learning model with a server while maintaining data privacy and localization. Federated learning has been applied to face recognition tasks, but this method jointly trains a universal model. Because face recognition data may contain local characteristics (such as camera type and ethnicity), universal models are not well adapted to local recognition scenarios. Therefore, it is a major demand to maintain a universal model while providing each client with a local, personalized model.

[0003] In related technologies, the method adopted is to use a preset conversion layer to convert the universal features into local features after the universal model extracts features. The preset conversion layer requires additional calculation of the conversion, which increases the time consumption of the model. At the same time, the extracted universal features themselves are not for local services, so some local features that are crucial for personalized recognition may have been lost during the feature extraction process, thereby reducing the localized recognition performance of the model. Summary of the Invention

[0004] The embodiments of this application provide a method and apparatus for identity recognition and model training. To provide a basic understanding of some aspects of the disclosed embodiments, a brief summary is provided below. This summary is not intended to be a comprehensive review, identify key or important elements, or delineate the scope of protection for these embodiments. Its sole purpose is to present some concepts in a simplified form, serving as a prelude to the detailed description that follows.

[0005] In a first aspect, an embodiment of the present application provides a recognition model training method, which is applied to a client, wherein the client includes a private dataset, a general model deployed for federated learning, and a local model. The general model is a model shared by all clients, and the local model is trained for a local service. The method includes:

[0006] Sampling private datasets to obtain training data;

[0007] Extract features from the training data using the general model and the local model to obtain general features belonging to the general model and local features belonging to the local model;

[0008] Training a local model based on common features, local features, and a preset personalized distinguishing loss function. The preset personalized distinguishing loss function is used to optimize the local model so that the local model can distinguish local features in the private dataset.

[0009] When the private dataset sampling is completed, a pre-trained recognition model is generated.

[0010] Optionally, the general model includes a first classifier layer, and the training data includes face images and their corresponding identity labels;

[0011] Before distinguishing the loss function based on common features, local features, and preset personalization, it also includes:

[0012] Input the common features into the first classifier layer to obtain the first classification result;

[0013] Calculating a first general face recognition loss based on the first classification result and the identity label in combination with a preset face recognition loss function;

[0014] Based on the first universal face recognition loss, the model parameters of the universal model are updated.

[0015] Optionally, the local model includes a batch normalization layer and a second classifier layer, where the batch normalization layer is the same as the normalization layer of the feature extractor included in the general model;

[0016] The method also includes:

[0017] Input the local features into the second classifier layer to obtain the second classification result;

[0018] Calculate the second general face recognition loss based on the second classification result and the identity label in combination with the preset face recognition loss function;

[0019] Based on the second general face recognition loss, update the personalized parameters of the batch normalization layer.

[0020] Optionally, train a local model based on common features, local features, and a preset personalized differentiation loss function, including:

[0021] Calculate the cosine similarity between local features and universal features;

[0022] Calculate target similarity between common features;

[0023] Calculate the personalized distinction loss value based on the preset personalized distinction loss function, cosine similarity and target similarity;

[0024] Calculate the face recognition loss value based on the preset face recognition loss function, universal features and local features;

[0025] Calculate the sum of the personalized distinction loss and the face recognition loss to obtain the final loss for optimizing the model parameters of the local model.

[0026] Based on the final loss value, optimize the model parameters of the local model.

[0027] Optionally, a personalized distinction loss value is calculated based on a preset personalized distinction loss function, cosine similarity, and target similarity, including:

[0028] Construct a mask matrix based on the cosine similarity and target similarity;

[0029] Divide the training data into positive sample pairs representing facial images of the same identity and negative sample pairs representing facial images of different identities;

[0030] For each positive sample pair and negative sample pair indicated by each element in the mask matrix, compare the cosine similarity associated with each element with the target similarity;

[0031] Based on the comparison results, the positive and negative sample pairs are penalized by presetting a personalized discrimination loss function to encourage the local model to show greater similarity between positive sample pairs and smaller similarity between negative sample pairs, thereby obtaining a personalized discrimination loss value.

[0032] Optionally, based on the comparison results, the positive and negative sample pairs are penalized by a preset personalized discriminative loss function, including:

[0033] When the comparison result indicates that the cosine similarity is less than the target similarity, the positive sample pair is penalized by a preset personalized discrimination loss function; or,

[0034] When the comparison result indicates that the cosine similarity is greater than the difference between the target similarity and the preset boundary value, the negative sample pair is penalized by a preset personalized discrimination loss function.

[0035] Optionally, the preset personalized discrimination loss function is:

[0036] in,

[0037] To personalize the loss value, is the batch normalization layer of the local model, For a single communication round, For local features, For general features, is the cosine similarity between local features and universal features, is the target similarity between common features, is the mask value. When the universal feature indicated by each element in the mask matrix is the same as the local feature, the mask value of each element is set to 1, or when the universal feature indicated by each element in the mask matrix is different from the local feature, the mask value of each element is set to 0. is the preset boundary value.

[0038] In a second aspect, an embodiment of the present application provides an identity recognition method, the method comprising:

[0039] Receive a face recognition request, which carries a user's face image;

[0040] Input the face image into a pre-trained recognition model and output the user's identity features; the pre-trained recognition model is trained using the above-mentioned recognition model training method;

[0041] The user's identity characteristics are compared with the identity characteristics registered by the user to obtain the user's comparison result.

[0042] In a third aspect, an embodiment of the present application provides a recognition model training device, which includes a private dataset, a general model deployed for federated learning, and a local model. The general model is a model shared by all clients, and the local model is trained for a local service. The device includes:

[0043] The sampling module is used to sample the private dataset to obtain training data;

[0044] A feature extraction module is used to extract features from training data using a universal model and a local model to obtain universal features belonging to the universal model and local features belonging to the local model;

[0045] A training module is used to train a local model based on common features, local features, and a preset personalized differentiation loss function. The preset personalized differentiation loss function is used to optimize the local model so that the local model can distinguish local features in the private dataset;

[0046] The generation module is used to generate a pre-trained recognition model when the private dataset sampling is completed.

[0047] In a fourth aspect, an embodiment of the present application provides an identity recognition device, comprising:

[0048] A receiving module, configured to receive a face recognition request, wherein the face recognition request carries a user's face image;

[0049] An output module is used to input a face image into a pre-trained recognition model and output the user's identity features; the pre-trained recognition model is trained using the above-mentioned recognition model training method;

[0050] The comparison module is used to compare the user's identity characteristics with the user's registered identity characteristics to obtain the user's comparison result.

[0051] The technical solutions provided by the embodiments of the present application may have the following beneficial effects:

[0052] In the embodiments of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, thereby reducing the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model, so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model.

[0053] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0054] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.

[0055] Figure 1 This is a flow chart of a recognition model training method provided in an embodiment of the present application;

[0056] Figure 2 This is a schematic diagram of a model training architecture under federated learning provided in an embodiment of the present application;

[0057] Figure 3 This is a flow chart of an identity recognition method provided in an embodiment of the present application;

[0058] Figure 4 This is a structural diagram of a recognition model training device provided in an embodiment of the present application;

[0059] Figure 5 This is a schematic diagram of the structure of an identity recognition device provided in an embodiment of the present application;

[0060] Figure 6 This is a structural diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0061] The following description and the drawings sufficiently illustrate specific embodiments of the application to enable those skilled in the art to practice them.

[0062] It should be clear that the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of this application.

[0063] When the following description refers to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. Instead, they are merely examples of devices and methods consistent with certain aspects of the present application, as detailed in the appended claims.

[0064] In the description of this application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to specific circumstances. In addition, in the description of this application, unless otherwise specified, "multiple" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the previous and subsequent associated objects are in an "or" relationship.

[0065] It should be noted that in this application, when collecting facial images, the user will be clearly informed of the purpose, and the collection will only be carried out after obtaining the user's consent, and the facial images collected are within the necessary scope. For example, there is a sampling module in this application. When executing the sampling module, the user will be clearly informed of the purpose of collecting facial images, that is, the user will be informed that the sampling module will collect facial images. Only after obtaining the user's consent will the collected facial data be used for model training, and the facial images collected by the sampling module are within the necessary scope.

[0066] The present application provides an identity recognition and model training method and device to solve the problems existing in the above-mentioned related technical problems. In the embodiment of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, which reduces the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model. The following is a detailed description using an exemplary embodiment.

[0067] This application provides an identity recognition and model training method and device to solve the problems existing in the above-mentioned related technical issues. Figure 1 -Attached Figure 3 , a detailed introduction to the recognition model training method provided in the embodiments of this application is provided. This method can be implemented using a computer program and can be run on a recognition model training device based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone tool application.

[0068] See Figure 1 , provides a flow chart of a recognition model training method for an embodiment of the present application, which is applied to a client, the client including a private data set, a general model deployed for federated learning, and a local model. The general model is a model shared by all clients, and the local model is trained for local services. Figure 1 As shown, the method of the embodiment of the present application may include the following steps:

[0069] S101, sampling the private data set to obtain training data;

[0070] Among them, the private dataset can be understood as assuming that there is a dataset containing N samples D , where each sample Represents a face image and its corresponding identity label, with a total of n different identities. A deep face recognition model uses a feature extractor Ø to generate a feature vector , and through a weighted The classifier layer is used for classification. A softmax-based loss function is usually used to optimize these parameters, as follows:

[0071] ;

[0072] Among them, the function and It varies in different methods. For example, CosFace uses and , while ArcFace uses and .here is a hyperparameter, is a vector and The angle between.

[0073] In the federated learning environment of this application, it is assumed that there is a server and clients, each client There is a private dataset , on each client In the deployment of a general model and client-specific local model parameters ,in, Represents the batch normalization layer, whose structure is similar to the feature extractor The normalization layer in is the same, and all clients Have the same network architecture.

[0074] Compared with traditional FedAvg, this application differs in two main aspects: (1) The classifier layers are kept locally because they are dispensable for inference and directly affect personal privacy. (2) Each client $c$ has a local model ,in Represents a function that combines batch normalization parameters and The other parameters of are used to generate the feature extractor.

[0075] In one embodiment, the private datasets owned by each client are first determined. These datasets contain locally collected facial images and their corresponding identity labels. Then, before sampling, the datasets are preprocessed as necessary, including image cropping, scaling, and normalization, to ensure data consistency and model input requirements. Secondly, based on the training objectives and the characteristics of the dataset, an appropriate sampling strategy is selected. The strategies adopted may include random sampling, stratified sampling, oversampling, or undersampling. Finally, a certain number of samples are randomly selected from the private dataset to form a training batch of training data.

[0076] For example, given a private dataset , each iteration draws a small batch of samples from .

[0077] S102, extracting features from the training data using the universal model and the local model to obtain universal features belonging to the universal model and local features belonging to the local model;

[0078] The universal model is shared by all clients in federated learning. It is initialized by a central server and distributed to each client. Its purpose is to capture common features across clients and provide basic recognition capabilities for all clients. During the federated learning process, the central server collects model updates from all clients and aggregates them to improve the universal model. The local model is optimized for a specific client and contains client-specific parameters, such as those of the batch normalization layer. This aims to improve the model's adaptability to client-specific datasets and achieve more accurate face recognition.

[0079] In some embodiments, the general model and the local model are first initialized, and then the training data are input into the initialized general model and the local model respectively, and feature extraction is performed through the feature extractor of the model to obtain general features belonging to the general model and local features belonging to the local model.

[0080] For example, for a sample , and its corresponding features are extracted as ,in Generate a combined and Weighted feature extractor.

[0081] The general model includes a first classifier layer, and the training data includes face images and their corresponding identity labels.

[0082] In an embodiment of the present application, the process of updating the model parameters of the general model includes: inputting the general features into the first classifier layer to obtain a first classification result; calculating the first general face recognition loss based on the first classification result and the identity label in combination with a preset face recognition loss function; and updating the model parameters of the general model based on the first general face recognition loss.

[0083] The local model includes a batch normalization layer and a second classifier layer, and the batch normalization layer is the same as the normalization layer of the feature extractor included in the general model.

[0084] In an embodiment of the present application, the process of updating the model parameters of the local model includes: inputting local features into the second classifier layer to obtain a second classification result; calculating the second universal face recognition loss based on the second classification result and the identity label in combination with a preset face recognition loss function; and updating the personalized parameters of the batch normalization layer based on the second universal face recognition loss.

[0085] The default face recognition loss function is:

[0086] ;in, The second general face recognition loss, For the Batch normalization layer with communication rounds, For the The classifier layer under communication rounds, is the number of training samples, and are the first and second functions respectively, is a natural number, is the ith adjacent eigenvector, For feature markers.

[0087] S103, training a local model based on the universal features, the local features, and a preset personalized differentiation loss function, wherein the preset personalized differentiation loss function is used to optimize the local model so that the local model can distinguish the local features in the private dataset;

[0088] In an embodiment of the present application, the specific process of training a local model based on universal features, local features, and a preset personalized discrimination loss function includes: calculating the cosine similarity between local features and universal features; calculating the target similarity between universal features; calculating the personalized discrimination loss value based on the preset personalized discrimination loss function, cosine similarity, and target similarity; calculating the face recognition loss value based on the preset face recognition loss function, universal features, and local features; calculating the sum of the personalized discrimination loss value and the face recognition loss value to obtain the final loss value for optimizing the model parameters of the local model; and optimizing the model parameters of the local model based on the final loss value. Optimizing the parameters of the local model The final training loss is:

[0089] in, is the final training loss, is the face recognition loss value, To personalize the loss value, is a hyperparameter, and the loss only affects the parameter , without affecting the general model parameters.

[0090] For example, the cosine similarity between features:

[0091] , similarly, calculate the target similarity between common features ,get .

[0092] Specifically, the process of calculating the personalized discrimination loss value based on the preset personalized discrimination loss function, cosine similarity and target similarity includes: constructing a mask matrix based on cosine similarity and target similarity; dividing positive sample pairs representing face images of the same identity and negative sample pairs representing face images of different identities from the training data; for the positive sample pairs and negative sample pairs indicated by each element in the mask matrix, comparing the size between the cosine similarity associated with each element and the target similarity; based on the comparison result, penalizing the positive sample pairs and negative sample pairs through the preset personalized discrimination loss function to encourage the local model to show greater similarity between positive sample pairs and smaller similarity between negative sample pairs, thereby obtaining the personalized discrimination loss value.

[0093] Specifically, based on the comparison result, the process of penalizing the positive sample pairs and the negative sample pairs by using the preset personalized discrimination loss function includes: when the comparison result indicates that the cosine similarity is less than the target similarity, the positive sample pairs are penalized by using the preset personalized discrimination loss function; or, when the comparison result indicates that the cosine similarity is greater than the difference between the target similarity and the preset boundary value, the negative sample pairs are penalized by using the preset personalized discrimination loss function.

[0094] The preset personalized differentiation loss function is:

[0095] in,

[0096] To personalize the loss value, is the batch normalization layer of the local model, For a single communication round, For local features, For general features, is the cosine similarity between local features and universal features, is the target similarity between common features, is the mask value. When the universal feature indicated by each element in the mask matrix is the same as the local feature, the mask value of each element is set to 1, or when the universal feature indicated by each element in the mask matrix is different from the local feature, the mask value of each element is set to 0. is the preset boundary value.

[0097] For example, the mask matrix ,in express ,otherwise .

[0098] S104: When the private data set sampling is completed, a pre-trained recognition model is generated.

[0099] In an embodiment of the present application, after the training is completed, it can be determined whether the sampling of the private data set is completed. If the sampling of the private data set is completed, a pre-trained recognition model is generated; or if the sampling of the private data set is not completed, the step of sampling the private data set is continued.

[0100] For example Figure 2 As shown, Figure 2This is a schematic diagram of a model training architecture under federated learning provided by this application. The architecture consists of a server and a client. The server sends training auxiliary parameters to the client, and the client uploads the trained general model to the server for aggregation. In addition, the client also trains a local personalized local model. By sampling the data set saved in the client, the sampled training data is input into the general model and the local model to obtain the general features belonging to the general model and the local features belonging to the local model. Then, the parameters of the local model are optimized in combination with the preset personalized discrimination loss function (i.e., the discrimination loss function).

[0101] In an embodiment of the present application, by presetting a personalized discriminative loss function (PDLoss), it is possible to ensure that local features are more discriminative than universal features in the local data set. This optimization not only improves the recognition accuracy of the model, but also enhances the model's adaptability to different client data distributions, effectively addressing the problem of data heterogeneity.

[0102] In the embodiments of the present application, the design of independently updating the batch normalization layer parameters in the model training architecture of the present application enables the model to better adapt to the characteristics of local data, improving training efficiency and model performance. This mechanism allows the global model and local model to be more coordinated during the training process, thereby improving the convergence speed and stability of the overall model.

[0103] In the embodiments of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, thereby reducing the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model, so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model.

[0104] See Figure 3 , provides a flow chart of an identity recognition method according to an embodiment of the present application. Figure 3 As shown, the method of the embodiment of the present application may include the following steps:

[0105] S201, receiving a face recognition request, the face recognition request carrying a user's face image;

[0106] In some embodiments, a facial recognition request is received, the facial recognition request is parsed, and a facial image of the user is extracted from the parsed data.

[0107] S202, inputting the face image into a pre-trained recognition model and outputting the user's identity features; the pre-trained recognition model is trained using the above-mentioned recognition model training method;

[0108] The pre-trained recognition model can be a local model or a universal model.

[0109] In some embodiments, when the current recognition task needs to be performed on the server side, the facial image is processed through the general model of the server side to obtain the user's identity features.

[0110] In other embodiments, when the current recognition task needs to be performed on the client, the facial image is processed using a local model on the client to obtain the user's identity features.

[0111] In an embodiment of the present application, a pre-trained recognition model can be generated according to the following steps, including: sampling a private data set to obtain training data; extracting features from the training data through a general model and a local model to obtain general features belonging to the general model and local features belonging to the local model; training a local model based on the general features, local features and a preset personalized discrimination loss function, and the preset personalized discrimination loss function is used to optimize the local model so that the local model can distinguish the local features in the private data set; when the sampling of the private data set is completed, a pre-trained recognition model is generated.

[0112] S203: Compare the user's identity features with the user's registered identity features to obtain a comparison result for the user.

[0113] In an embodiment of the present application, during the user registration stage, a face recognition model is used to extract the identity features of the face image submitted by the user when registering, and the extracted identity features are securely stored in a database and associated with the user's unique identifier (such as a user ID). The real identity features of the user registration are obtained through the user ID, and the user's identity features are compared with the identity features registered by the user to calculate the similarity score between the two feature vectors. The score represents the degree of similarity between them, and a similarity threshold is set to determine whether the comparison result indicates that the two features belong to the same user. If the similarity score exceeds the threshold, the comparison is determined to be successful and the user's identity is confirmed; if it is lower than the threshold, the comparison is determined to have failed, and the comparison result is fed back to the user or system in an appropriate manner, such as by displaying it through a user interface.

[0114] In the embodiments of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, thereby reducing the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model, so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model.

[0115] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0116] See Figure 4 , which shows a schematic diagram of the structure of a recognition model training device provided by an exemplary embodiment of the present application. The recognition model training device can be implemented as all or part of an electronic device through software, hardware, or a combination of both. The device includes a private dataset, a general model deployed for federated learning, and a local model. The general model is a model shared by all clients, and the local model is trained for local services. The device 1 includes a sampling module 10, a feature extraction module 20, a training module 30, and a generation module 40.

[0117] A sampling module 10 is used to sample the private data set to obtain training data;

[0118] A feature extraction module 20 is used to extract features from the training data using the universal model and the local model to obtain universal features belonging to the universal model and local features belonging to the local model;

[0119] A training module 30 is configured to train a local model based on universal features, local features, and a preset personalized differentiation loss function, wherein the preset personalized differentiation loss function is used to optimize the local model so that the local model can distinguish local features in the private dataset;

[0120] The generation module 40 is used to generate a pre-trained recognition model when the private data set sampling is completed.

[0121] Optionally, the device further comprises:

[0122] A first input module, configured to input the common features into a first classifier layer to obtain a first classification result;

[0123] A first loss calculation module, configured to calculate a first general face recognition loss based on the first classification result and the identity label in combination with a preset face recognition loss function;

[0124] The first updating module is used to update the model parameters of the general model based on the first general face recognition loss.

[0125] Optionally, the device further comprises:

[0126] A second input module is used to input the local features into the second classifier layer to obtain a second classification result;

[0127] A second loss calculation module, configured to calculate a second general face recognition loss based on the second classification result and the identity label in combination with a preset face recognition loss function;

[0128] The second updating module is used to update the personalized parameters of the batch normalization layer based on the second general face recognition loss.

[0129] It should be noted that the recognition model training device provided in the above embodiment only uses the division of the above functional modules as an example when executing the recognition model training method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the recognition model training device provided in the above embodiment and the recognition model training method embodiment belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.

[0130] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0131] In the embodiments of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, thereby reducing the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model, so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model.

[0132] See Figure 5 , which shows a schematic diagram of the structure of an identity recognition device provided by an exemplary embodiment of the present application. The recognition model training device can be implemented as all or part of an electronic device through software, hardware, or a combination of both. The device 2 includes a receiving module 10, an output module 20, and a comparison module 30.

[0133] A receiving module 10 is configured to receive a face recognition request, wherein the face recognition request carries a user's face image;

[0134] An output module 20, configured to input a facial image into a pre-trained recognition model and output a user's identity features; the pre-trained recognition model is trained using the recognition model training method according to any one of claims 1 to 7;

[0135] The comparison module 30 is used to compare the user's identity characteristics with the user's registered identity characteristics to obtain the user's comparison result.

[0136] It should be noted that the recognition model training device provided in the above embodiment only uses the division of the above functional modules as an example when executing the recognition model training method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the recognition model training device provided in the above embodiment and the recognition model training method embodiment belong to the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.

[0137] The serial numbers of the above embodiments of the present application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0138] In the embodiments of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, thereby reducing the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model, so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model.

[0139] The present application also provides a computer-readable medium having program instructions stored thereon, which, when executed by a processor, implement the recognition model training methods provided by the above-mentioned various method embodiments.

[0140] The present application also provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the recognition model training methods of the above-mentioned various method embodiments.

[0141] See Figure 6 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 6 As shown, the electronic device 1000 may include: at least one processor 1001 , at least one network interface 1004 , a user interface 1003 , a memory 1005 , and at least one communication bus 1002 .

[0142] The communication bus 1002 is used to implement the connection and communication between these components.

[0143] The user interface 1003 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 1003 may also include a standard wired interface and a wireless interface.

[0144] The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0145] The processor 1001 may include one or more processing cores. The processor 1001 utilizes various interfaces and circuits to connect various components within the electronic device 1000. It executes instructions, programs, code sets, or instruction sets stored in the memory 1005, and accesses data stored in the memory 1005 to perform various functions and process data within the electronic device 1000. Optionally, the processor 1001 may be implemented in hardware using at least one of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 1001 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing content displayed on the display; and the modem handles wireless communications. It is understood that the modem may also be implemented independently of the processor 1001 and implemented on a separate chip.

[0146] Among them, the memory 1005 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 1005 includes a non-transitory computer-readable storage medium. The memory 1005 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 1005 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 1005 may also be optionally at least one storage system located away from the aforementioned processor 1001. As Figure 6 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a recognition model training application.

[0147] exist Figure 6In the electronic device 1000 shown, the user interface 1003 is mainly used to provide an input interface for the user and obtain data input by the user; and the processor 1001 can be used to call the recognition model training application stored in the memory 1005 and specifically perform the following operations:

[0148] Sampling private datasets to obtain training data;

[0149] Extract features from the training data using the general model and the local model to obtain general features belonging to the general model and local features belonging to the local model;

[0150] Training a local model based on common features, local features, and a preset personalized distinguishing loss function. The preset personalized distinguishing loss function is used to optimize the local model so that the local model can distinguish local features in the private dataset.

[0151] When the private dataset sampling is completed, a pre-trained recognition model is generated.

[0152] In one embodiment, the processor 1001 further performs the following operations:

[0153] Input the common features into the first classifier layer to obtain the first classification result;

[0154] Calculating a first general face recognition loss based on the first classification result and the identity label in combination with a preset face recognition loss function;

[0155] Based on the first universal face recognition loss, the model parameters of the universal model are updated.

[0156] In one embodiment, the processor 1001 further performs the following operations:

[0157] Input the local features into the second classifier layer to obtain the second classification result;

[0158] Calculate the second general face recognition loss based on the second classification result and the identity label in combination with the preset face recognition loss function;

[0159] Based on the second general face recognition loss, update the personalized parameters of the batch normalization layer.

[0160] In one embodiment, when the processor 1001 trains the local model based on the universal features, the local features, and the preset personalized differentiation loss function, it specifically performs the following operations:

[0161] Calculate the cosine similarity between local features and universal features;

[0162] Calculate target similarity between common features;

[0163] Calculate the personalized distinction loss value based on the preset personalized distinction loss function, cosine similarity and target similarity;

[0164] Calculate the face recognition loss value based on the preset face recognition loss function, universal features and local features;

[0165] Calculate the sum of the personalized distinction loss and the face recognition loss to obtain the final loss for optimizing the model parameters of the local model.

[0166] Based on the final loss value, optimize the model parameters of the local model.

[0167] In one embodiment, when the processor 1001 calculates the personalized distinction loss value according to the preset personalized distinction loss function, the cosine similarity, and the target similarity, it specifically performs the following operations:

[0168] Construct a mask matrix based on the cosine similarity and target similarity;

[0169] Divide the training data into positive sample pairs representing facial images of the same identity and negative sample pairs representing facial images of different identities;

[0170] For each positive sample pair and negative sample pair indicated by each element in the mask matrix, compare the cosine similarity associated with each element with the target similarity;

[0171] Based on the comparison results, the positive and negative sample pairs are penalized by presetting a personalized discrimination loss function to encourage the local model to show greater similarity between positive sample pairs and smaller similarity between negative sample pairs, thereby obtaining a personalized discrimination loss value.

[0172] In one embodiment, when the processor 1001 penalizes the positive sample pairs and the negative sample pairs based on the comparison result by using a preset personalized discrimination loss function, the processor 1001 specifically performs the following operations:

[0173] When the comparison result indicates that the cosine similarity is less than the target similarity, the positive sample pair is penalized by a preset personalized discrimination loss function; or,

[0174] When the comparison result indicates that the cosine similarity is greater than the difference between the target similarity and the preset boundary value, the negative sample pair is penalized by a preset personalized discrimination loss function.

[0175] In the embodiments of the present application, on the one hand, the present application trains a local model based on universal features, local features and a preset personalized discrimination loss function. This process does not require additional conversion calculations, thereby reducing the time consumption of the model; on the other hand, the preset personalized discrimination loss function provided by the present application is used to optimize the local model, so that the local model can distinguish local features in a private data set, ensuring that local features are more discriminative than universal features in the local data set, thereby improving the recognition performance of the local model.

[0176] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing the relevant hardware through a computer program. The recognition model training program can be stored in a computer-readable storage medium. When executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory, or a random access memory.

[0177] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A recognition model training method, characterized in that: Applied to a client, the client includes a private dataset, a common model deployed for federated learning, and a local model, the common model is a model shared by all clients, and the local model is trained for a local service, the method comprising: Sampling the private data set to obtain training data; Performing feature extraction on the training data using the universal model and the local model to obtain universal features belonging to the universal model and local features belonging to the local model; Training the local model based on the universal features, the local features, and a preset personalized differentiation loss function, wherein the preset personalized differentiation loss function is used to optimize the local model so that the local model can distinguish the local features in the private dataset; When the private data set sampling is completed, a pre-trained recognition model is generated; wherein, The training of the local model according to the universal features, the local features, and a preset personalized differentiation loss function includes: Calculating the cosine similarity between the local feature and the universal feature; Calculating target similarity between the common features; Calculating a personalized distinction loss value according to a preset personalized distinction loss function, the cosine similarity, and the target similarity; Calculating a face recognition loss value according to a preset face recognition loss function, the universal features, and the local features; Calculating the sum of the personalized distinction loss value and the face recognition loss value to obtain a final loss value for optimizing the model parameters of the local model; Based on the final loss value, the model parameters of the local model are optimized; wherein, The preset personalized differentiation loss function is: in, To personalize the loss value, is the batch normalization layer of the local model, t is a single communication round, i is the local feature, j is the common feature, S i,j is the cosine similarity between the local feature and the universal feature, is the target similarity between common features, M i,j is a mask value. When the universal feature indicated by each element in the mask matrix is the same as the local feature, the mask value of each element is set to 1; or when the universal feature indicated by each element in the mask matrix is different from the local feature, the mask value of each element is set to 0, and τ is a preset boundary value.

2. The method according to claim 1, characterized in that The general model includes a first classifier layer, and the training data includes face images and their corresponding identity labels; Before distinguishing the loss function based on the universal features, the local features, and the preset personalized features, the method further includes: Inputting the common features into the first classifier layer to obtain a first classification result; Calculating a first general face recognition loss based on the first classification result and the identity label in combination with a preset face recognition loss function; Based on the first universal face recognition loss, model parameters of the universal model are updated.

3. The method according to claim 2, characterized in that The local model includes a batch normalization layer and a second classifier layer, wherein the batch normalization layer is the same as the normalization layer of the feature extractor included in the general model; The method further comprises: Inputting the local features into the second classifier layer to obtain a second classification result; Calculating a second general face recognition loss based on the second classification result and the identity label in combination with a preset face recognition loss function; Based on the second universal face recognition loss, updating the personalized parameters of the batch normalization layer.

4. The method according to claim 1, wherein The calculating of the personalized distinction loss value according to the preset personalized distinction loss function, the cosine similarity and the target similarity includes: Constructing a mask matrix according to the cosine similarity and the target similarity; Dividing from the training data positive sample pairs of facial images representing the same identity and negative sample pairs of facial images representing different identities; For the positive sample pair and the negative sample pair indicated by each element in the mask matrix, comparing the cosine similarity associated with each element with the target similarity; Based on the comparison results, the positive sample pairs and negative sample pairs are penalized by presetting a personalized discrimination loss function to encourage the local model to show greater similarity between the positive sample pairs and smaller similarity between the negative sample pairs, thereby obtaining a personalized discrimination loss value.

5. The method according to claim 4, characterized in that Based on the comparison result, penalizing the positive sample pair and the negative sample pair by using a preset personalized discrimination loss function includes: When the comparison result indicates that the cosine similarity is less than the target similarity, the positive sample pair is penalized by a preset personalized discrimination loss function; or, When the comparison result indicates that the cosine similarity is greater than the difference between the target similarity and a preset boundary value, the negative sample pair is penalized by a preset personalized distinction loss function.

6. An identity recognition method, characterized in that: The method comprises: receiving a face recognition request, the face recognition request carrying a face image of a user; Inputting the facial image into a pre-trained recognition model to output the identity features of the user; the pre-trained recognition model is trained by the recognition model training method according to any one of claims 1 to 5; The identity characteristics of the user are compared with the identity characteristics registered by the user to obtain a comparison result of the user.

7. A recognition model training device implemented using the method according to any one of claims 1 to 5, characterized in that: The apparatus includes a private dataset, a general model deployed for federated learning, and a local model, wherein the general model is a model shared by all clients, and the local model is trained for a local service. The apparatus includes: A sampling module, configured to sample the private data set to obtain training data; A feature extraction module, configured to extract features from the training data using the universal model and the local model to obtain universal features belonging to the universal model and local features belonging to the local model; a training module, configured to train the local model based on the universal features, the local features, and a preset personalized differentiation loss function, wherein the preset personalized differentiation loss function is used to optimize the local model so that the local model can distinguish the local features in the private dataset; The generation module is used to generate a pre-trained recognition model when the sampling of the private data set is completed.

8. An identity recognition device, characterized in that: The device comprises: A receiving module, configured to receive a face recognition request, wherein the face recognition request carries a face image of a user; An output module, configured to input the facial image into a pre-trained recognition model and output the identity features of the user; the pre-trained recognition model is trained using the recognition model training method according to any one of claims 1 to 5; The comparison module is used to compare the identity characteristics of the user with the identity characteristics registered by the user to obtain a comparison result of the user.

Citation Information

Patent Citations

  • Face recognition method and device based on knowledge federation, equipment, medium and system

    CN111046857A

  • Face recognition method based on secret sharing and federated learning

    CN115830679A