Model evaluation method, device and storage medium
Through the combination of multiple evaluation protocols and evaluation indicators, the evaluation indicators of the machine learning model are calculated, which solves the problems of single evaluation indicators and low calculation efficiency in the existing technology, and achieves a comprehensive evaluation of model performance and efficiency improvement.
Patent Information
- Application Number
- CN202210143982.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-02-17
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2042-02-17
AI Technical Summary
The evaluation index of the machine learning model in the existing technology is single, which makes it impossible to comprehensively evaluate the model performance, and the calculation efficiency of the evaluation index value is low, resulting in reduced model evaluation efficiency.
Provides a model evaluation method that obtains a variety of preconfigured evaluation protocols and evaluation indicators, combines feature similarity and sample similarity calculations, and generates a similarity matrix to calculate model accuracy and improve the calculation efficiency of evaluation indicators.
Comprehensively evaluate the model through a variety of evaluation protocols and evaluation indicators to improve the calculation efficiency of evaluation index results, thereby improving model evaluation efficiency.
Smart Images

Figure CN114519520B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a model evaluation method, device and storage medium. Background Art
[0002] Currently, machine learning models are increasingly being used in various fields. For example, face recognition models play a vital role in scenarios such as face verification and face payment. Before a machine learning model is formally applied to actual products, a comprehensive evaluation of the model's predictive performance is required.
[0003] At present, the evaluation method for machine learning models generally provides a specific data set and specific evaluation indicators based on the model, and judges the quality of the model by comparing the numerical values of the evaluation indicators. For example, for classification models, common evaluation indicators include accuracy, recall rate, prediction accuracy, etc. However, the existing evaluation indicators for machine learning models are relatively simple and cannot accurately evaluate the performance of machine learning models in all aspects. In addition, traditional model evaluation methods have relatively high requirements on the number of samples in the evaluation data set, so the calculation efficiency of the evaluation indicator value is relatively low, which leads to reduced model evaluation efficiency. Summary of the invention
[0004] In view of this, the embodiments of the present disclosure provide a model evaluation method, device and storage medium to solve the problems in the prior art that the model evaluation index is single, the model performance cannot be comprehensively evaluated, the calculation efficiency of the evaluation index value is relatively low, and the model evaluation efficiency is reduced.
[0005] In a first aspect of an embodiment of the present disclosure, a model evaluation method is provided, comprising: obtaining a preconfigured evaluation protocol, the evaluation protocol comprising a first evaluation protocol, a second evaluation protocol and a third evaluation protocol, each evaluation protocol corresponding to its own test set; performing an evaluation operation on a first model to be evaluated using a combination of one or more protocols in the evaluation protocol to obtain an evaluation index result for the first model to be evaluated; when evaluating the first model to be evaluated using the first evaluation protocol, obtaining the feature similarity of each group of image pairs in the test set of the first evaluation protocol, comparing the feature similarity with a threshold, and calculating the evaluation index result based on the comparison result; when evaluating the first model to be evaluated using the second evaluation protocol or the third evaluation protocol, obtaining a detection set and an interference set in the test set of the second evaluation protocol or the third evaluation protocol, and generating a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively; calculating the sample similarity between the query matrix and the database matrix, generating a similarity matrix based on the sample similarity, calculating the model accuracy based on the similarity matrix, and using the model accuracy as the evaluation index result for the first model to be evaluated.
[0006] According to a second aspect of an embodiment of the present disclosure, a model evaluation device is provided, comprising: an acquisition module, configured to acquire a pre-configured evaluation protocol, the evaluation protocol comprising a first evaluation protocol, a second evaluation protocol and a third evaluation protocol, each evaluation protocol corresponding to a respective test set; an evaluation module, configured to perform an evaluation operation on a first model to be evaluated using a combination of one or more protocols in the evaluation protocol, so as to obtain an evaluation index result for the first model to be evaluated; a comparison module, configured to acquire the feature similarity of each group of image pairs in the test set of the first evaluation protocol when evaluating the first model to be evaluated using the first evaluation protocol, compare the feature similarity with a threshold, and calculate the evaluation index result according to the comparison result; a generation module, configured to acquire a detection set and an interference set in the test set of the second evaluation protocol or the third evaluation protocol when evaluating the first model to be evaluated using the second evaluation protocol or the third evaluation protocol, and generate a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively; a calculation module, configured to calculate the sample similarity between the query matrix and the database matrix, generate a similarity matrix based on the sample similarity, calculate the model accuracy according to the similarity matrix, and use the model accuracy as the evaluation index result of the first model to be evaluated.
[0007] According to a third aspect of the embodiments of the present disclosure, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the above method are implemented.
[0008] At least one of the above technical solutions adopted in the embodiments of the present disclosure can achieve the following beneficial effects:
[0009] By obtaining a pre-configured evaluation protocol, the evaluation protocol includes a first evaluation protocol, a second evaluation protocol and a third evaluation protocol, each evaluation protocol corresponds to a respective test set; using a combination of one or more protocols in the evaluation protocol, performing an evaluation operation on the first model to be evaluated to obtain an evaluation index result for the first model to be evaluated; when evaluating the first model to be evaluated using the first evaluation protocol, obtaining the feature similarity of each group of image pairs in the test set of the first evaluation protocol, comparing the feature similarity with a threshold, and calculating the evaluation index result according to the comparison result; when evaluating the first model to be evaluated using the second evaluation protocol or the third evaluation protocol, obtaining a detection set and an interference set in the test set of the second evaluation protocol or the third evaluation protocol, and generating a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively; calculating the sample similarity between the query matrix and the database matrix, generating a similarity matrix based on the sample similarity, calculating the model accuracy according to the similarity matrix, and using the model accuracy as the evaluation index result of the first model to be evaluated. The present disclosure can comprehensively evaluate the model through a variety of evaluation protocols and evaluation indicators, can improve the calculation efficiency of the evaluation index result, and thus improve the model evaluation efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present disclosure. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 is a flow chart of a model evaluation method provided by an embodiment of the present disclosure;
[0012] Figure 2 is a schematic diagram of the structure of a model evaluation device provided by an embodiment of the present disclosure;
[0013] Figure 3 It is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0014] In the following description, specific details such as specific system structures and technologies are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present disclosure. However, it should be clear to those skilled in the art that the present disclosure may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obstructing the description of the present disclosure with unnecessary details.
[0015] As described in the background technology, when applying the face model to actual scenarios for face recognition or face payment verification, it is necessary to conduct a comprehensive evaluation of the face model so as to evaluate the prediction results of the face model. For example, taking the face recognition model as an example, the application of the face recognition model is relatively wide and the scenarios are complex, such as face verification on the gate of a railway station, face payment on a mobile phone software, etc. Therefore, a comprehensive and reliable evaluation of the face recognition model is required.
[0016] Traditional face model evaluation methods usually only provide specific data sets and corresponding specific evaluation indicators, and judge the quality of the model by comparing the numerical values of the evaluation indicators. For example, for classification models, common evaluation indicators include accuracy, recall rate, prediction accuracy, etc. However, the data sets and evaluation indicators used by existing face model evaluation methods are relatively simple, and it is impossible to use customized data sets for model evaluation, and the evaluation indicators are also relatively simple. In addition, due to the evaluation data sets of traditional face model evaluation methods under the real scene scale (such as millions of pictures), the calculation speed of traditional face model evaluation methods is slow and the evaluation efficiency is low. The traditional face model evaluation method does not combine the evaluation of the face quality model, resulting in the inability to evaluate the face quality model.
[0017] In view of the problems in the prior art, the embodiments of the present disclosure design a variety of evaluation protocols and evaluation indicators, and can comprehensively evaluate the face recognition model in the face model evaluation task, including using different methods such as test sets of different sizes, face verification and face query. When evaluating the face recognition model, based on the similarity calculation method accelerated by Faiss, combined with the evaluation of the face quality model, that is, combined with the indicator calculation of the face quality value, a solution is provided that can quickly and comprehensively evaluate the face recognition model and the face quality model.
[0018] Figure 1 It is a flowchart of the model evaluation method provided in an embodiment of the present disclosure. Figure 1 The model evaluation method can be executed by the server. Figure 1 As shown, the model evaluation method may specifically include:
[0019] S101, obtaining a pre-configured evaluation protocol, where the evaluation protocol includes a first evaluation protocol, a second evaluation protocol, and a third evaluation protocol, and each evaluation protocol corresponds to a respective test set;
[0020] S102, using a combination of one or more protocols in the evaluation protocol to perform an evaluation operation on the first model to be evaluated, so as to obtain an evaluation index result of the first model to be evaluated;
[0021] S103, when evaluating the first model to be evaluated using the first evaluation protocol, obtaining the feature similarity of each image pair in the test set of the first evaluation protocol, comparing the feature similarity with a threshold, and calculating an evaluation index result according to the comparison result;
[0022] S104, when evaluating the first model to be evaluated by using the second evaluation protocol or the third evaluation protocol, obtaining a detection set and an interference set in a test set of the second evaluation protocol or the third evaluation protocol, and generating a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively;
[0023] S105, calculating the sample similarity between the query matrix and the database matrix, generating a similarity matrix based on the sample similarity, calculating the model accuracy according to the similarity matrix, and using the model accuracy as an evaluation indicator result of the first model to be evaluated.
[0024] Specifically, the model evaluation method of the embodiment of the present disclosure is an evaluation of the face recognition model and the face quality model, that is, the prediction performance of the face recognition model and the face quality model is evaluated through a pre-configured evaluation protocol. However, it should be noted that the evaluation method of the embodiment of the present disclosure is not limited to the evaluation of the face model, and any other machine learning model is also applicable. The following embodiments of the present disclosure are described with the face model as the application scenario, and the application scenario does not constitute a limitation on the technical solution of the present disclosure.
[0025] Furthermore, three evaluation protocols are provided in the model evaluation method of the embodiment of the present disclosure. The evaluation protocols here can be considered as a complete set of evaluation methods. The three evaluation protocols are relatively independent of each other, and the implementation of any evaluation protocol does not depend on the implementation of other evaluation protocols. In order to comprehensively evaluate the face recognition model, the embodiment of the present disclosure provides the following three evaluation protocols: LFW protocol, IJB protocol and MegaFace protocol. Each evaluation protocol corresponds to one or more evaluation methods and evaluation indicators. In practical applications, each evaluation protocol provides a public face test set, and users can also customize the face test set according to the evaluation protocol.
[0026] According to the technical solution provided by the embodiment of the present disclosure, the present disclosure obtains a pre-configured evaluation protocol, the evaluation protocol includes a first evaluation protocol, a second evaluation protocol and a third evaluation protocol, each evaluation protocol corresponds to a respective test set; using a combination of one or more protocols in the evaluation protocol, the first model to be evaluated is evaluated to obtain the evaluation index result of the first model to be evaluated; when the first model to be evaluated is evaluated using the first evaluation protocol, the feature similarity of each group of image pairs in the test set of the first evaluation protocol is obtained, the feature similarity is compared with the threshold, and the evaluation index result is calculated according to the comparison result; when the first model to be evaluated is evaluated using the second evaluation protocol or the third evaluation protocol, the detection set and the interference set in the test set of the second evaluation protocol or the third evaluation protocol are obtained, and the query matrix and the database matrix are generated based on the sample features in the detection set and the interference set respectively; the sample similarity between the query matrix and the database matrix is calculated, the similarity matrix is generated based on the sample similarity, the model accuracy is calculated according to the similarity matrix, and the model accuracy is used as the evaluation index result of the first model to be evaluated. The present disclosure can comprehensively evaluate the model through multiple evaluation protocols and evaluation indicators, and can improve the calculation efficiency of the evaluation index result, thereby improving the model evaluation efficiency.
[0027] In some embodiments, a first evaluation protocol is used to evaluate a first model to be evaluated, including: obtaining positive image pairs and negative image pairs in a test set corresponding to the first evaluation protocol, using the first model to be evaluated to predict the positive image pairs and the negative image pairs respectively, obtaining normalized features corresponding to each image, and calculating the feature similarity of each group of image pairs using the normalized features of the image; comparing the feature similarity with a threshold, and taking image pairs with feature similarity greater than the threshold as predicted positive image pairs, and taking image pairs with feature similarity less than or equal to the threshold as predicted negative image pairs; judging the prediction results of the predicted positive image pairs and the predicted negative image pairs, determining the number of correct image pairs for which the prediction results are obtained, and the number of incorrect image pairs for which the prediction results are obtained, and calculating preset evaluation index results based on the number of correct image pairs and the number of incorrect image pairs; wherein the preset evaluation index results include prediction accuracy, prediction accuracy, true positive rate, false positive rate, ROC curve graph, and AUC value.
[0028] Specifically, the first evaluation protocol is the LFW evaluation protocol. First, a test set pre-customized for the LFW evaluation protocol is obtained. The test set of the LFW evaluation protocol is N groups of face image pairs (e.g., N=6000), which includes N1 groups of positive image pairs and N2 groups of negative face image pairs, so N=N1+N2. A positive image pair means that the faces in each image in the N1 group of positive image pairs belong to the same person, while a negative image pair means that the faces do not belong to the same person.
[0029] Furthermore, in the process of evaluating the model using the LFW evaluation protocol, the model to be evaluated recognizes each pair of images in the data set (test set) in turn, and gives the probability of belonging to a positive pair and a negative pair. By comparing the predicted answer of the N pairs of face test results with the actual answer, the face recognition accuracy ACC, the true positive rate TPR, the false positive rate FPR, the ROC curve and the AUC value are obtained. The evaluation process of the LFW evaluation protocol is described in detail below in conjunction with a specific embodiment, which may specifically include the following contents:
[0030] First, obtain the first model to be evaluated (i.e., face recognition model), which can output the extracted feature f according to the input image; prepare N groups of face image pairs as a test set, wherein the N groups of face image pairs include N1 groups of positive image pairs and N2 groups of negative image pairs.
[0031] Next, perform the following operations: For each pair of images in the test set: use the face recognition model to extract the normalized features f1 and f2 corresponding to each image; calculate the similarity sim = cos(f1, f2) of the image pair; divide the test set into 10 equal parts, each of which contains 1 / 10 positive pairs and 1 / 10 negative pairs. For each part, use [-1, 1] with an interval of 0.01 to obtain the thr corresponding to each value; the image pairs with predicted sim>thr are taken as the predicted positive image pairs, and the others are taken as the predicted negative image pairs.
[0032] Furthermore, the remaining 9 sets of correct positive prediction logarithms TP, incorrect positive prediction logarithms FP, correct negative prediction logarithms TN, and incorrect negative prediction logarithms FN are calculated; based on the above calculation results, the preset evaluation index results are calculated, for example:
[0033] Calculate the accuracy ACC(thr) = (TP + TN) / (N / 10);
[0034] Calculate the true positive rate TPR(thr) = (TP) / (TP+FN);
[0035] Calculate the false positive rate FPR(thr) = (FP) / (FP+TN);
[0036] After calculating the accuracy, true positive rate, and false positive rate, the thr when the ACC is the highest is used as the thr value of the current portion, and the ACC of the current portion is calculated according to the above method; that is, the TPR and FPR of the current portion under the above multiple thr values are calculated; and by calculating the average value of ACC, TPR, and FPR of 10 sets of data, the ROC graph is drawn and the AUC value is calculated, and the above calculation results are used as the indicator results of the face recognition model. In actual applications, users can select one or more of the above indicator results as the final evaluation indicators. The LFW evaluation protocol is usually used for verification during model training because the amount of data is generally small and the calculation speed is fast.
[0037] In some embodiments, the first model to be evaluated is evaluated using a second evaluation protocol, including: obtaining a detection set and an interference set in a test set corresponding to the second evaluation protocol, and using the first model to be evaluated to predict the images in the detection set and the interference set, respectively, to obtain normalized features corresponding to each image; based on the normalized features of each image, calculating the feature similarity between each image in the detection set and each image in the interference set, sorting the feature similarities, and judging the prediction accuracy of the first model to be evaluated based on the sorting result, and using the prediction accuracy as the evaluation index result of the first model to be evaluated.
[0038] Specifically, the second evaluation protocol is the IJB evaluation protocol, which includes two modes: face verification (1:1) and face query (1:N). Unlike the LFW protocol, a sample (i.e., image) in the IJB protocol can be one or more face images of the same person.
[0039] The test set for face verification is N groups of sample pairs (such as N = 8000000), of which N1 groups are positive sample pairs and N2 groups are negative sample pairs, so N = N1 + N2. The test process model recognizes each pair of images in the data set in turn, and gives the probability of belonging to a positive pair and a negative pair. By comparing the predicted answers of the N pairs of face test results with the true answers, the TPR values, ROC curves and AUC values corresponding to multiple groups of FPRs are obtained. In the embodiment of the present disclosure, the sample can be an image sample, and the sample pair can also be called an image pair.
[0040] The test set of face query is divided into two parts: the detection set and the interference set. The detection set contains N1 samples, and the interference set contains N2 samples. Each portrait in the detection set has a unique corresponding portrait in the interference set. The test process model recognizes each portrait in the detection set in turn and gives the similarity with the image in the interference set. The topk accuracy is obtained by comparing the predicted answer with the true answer. The topk accuracy means that for each sample in the detection set, if the similarity with the same portrait sample in the interference set ranks in the top k, the prediction is correct; the ratio of the number of correctly predicted samples to the number of samples in the detection set is the topk accuracy.
[0041] The face verification process and face query process of the IJB evaluation protocol are described in detail below in conjunction with specific embodiments, which may specifically include the following contents:
[0042] In the face verification process of the IJB evaluation protocol, the face recognition model can output the extracted feature f based on an input image; the test set is N groups of face sample pairs, including N1 groups of positive pairs and N2 groups of negative pairs, so N = N1 + N2.
[0043] Next, perform the following operations: for each pair of samples in the test set, use the face recognition model to extract the normalized features f1 and f2 of each sample. If there are multiple images, sum the features directly or weightedly; calculate the similarity of the sample pair sim = cos(f1,f2); take values of [-1,1] at intervals of 0.01, and for each value thr, predict the image pairs (i.e., sample pairs) with sim>thr as positive sample pairs, and the others as negative sample pairs. Calculate the number of correct predictions of positive pairs in the test set TP, the number of incorrect predictions of positive pairs FP, the number of correct predictions of negative pairs TN, and the number of incorrect predictions of negative pairs FN; calculate the preset evaluation index results based on the above calculation results, for example:
[0044] Calculate the true positive rate TPR(thr) = (TP) / (TP+FN);
[0045] Calculate the false positive rate FPR(thr) = (FP) / (FP+TN);
[0046] After calculating the true positive rate and false positive rate, record the TPR values when FPR = 1e-6, 1e-5, 1e-4, 1e-3, 1e-2 and 1e-1, draw the ROC graph and calculate the AUC value, and use the above calculation results as the indicator results of the face recognition model.
[0047] In the face query process of the IJB evaluation protocol, the face recognition model can output the extracted feature f based on an input image; the test set includes a detection set and an interference set, the detection set contains N1 samples, the interference set contains N2 samples, and each person in the detection set has a unique corresponding person in the interference set;
[0048] Next, perform the following operations: For each sample in the detection set and the interference set, use the face recognition model to extract the normalized features f1 and f2. If there are multiple images, sum the features directly or weightedly. For each sample in the detection set, calculate the similarity sim=cos(f1,f2) with each interference set feature, and sort them from large to small. Calculate the accuracy of top1, top5, and top10 respectively, and record them as the indicator results of the model. Output one or more indicator results selected by the user.
[0049] In some embodiments, the third evaluation protocol includes a face verification test method, and the first model to be evaluated is evaluated using the face verification test method in the third evaluation protocol, including: obtaining a detection set and an interference set in a test set corresponding to the third evaluation protocol, forming positive sample pairs from images belonging to the same object in the detection set, and combining the images in the detection set with the images in the interference set to obtain negative sample pairs; using the first model to be evaluated to predict the positive sample pairs and the negative sample pairs respectively, to obtain the normalized features corresponding to each image, and using the normalized features of the image to calculate the feature similarity of each group of positive sample pairs or negative sample pairs; comparing the feature similarity with a threshold, and taking sample pairs with feature similarity greater than the threshold as predicted positive sample pairs, and taking sample pairs with feature similarity less than or equal to the threshold as predicted negative sample pairs; determining the prediction results of the positive sample pairs based on the predicted positive sample pairs, and determining the prediction results of the negative sample pairs based on the predicted negative sample pairs, and calculating the preset evaluation index results based on the prediction results of the positive sample pairs and the prediction results of the negative sample pairs; wherein the preset evaluation index results include true positive rate, false positive rate, ROC curve graph and AUC value.
[0050] Specifically, the third evaluation protocol is the MegaFace evaluation protocol, which includes two methods: face verification (1:1) and face query (1:N). Both methods can use the same test set, which is divided into a detection set and an interference set. The detection set contains N1 portrait images, the interference set contains N2 portrait images, and there are no identical portraits in the detection set and the interference set.
[0051] Furthermore, in the face verification test, the images of the same person in the detection set are paired into positive sample pairs, and each image in the detection set and each image in the interference set are paired into negative sample pairs, and the same calculation method and evaluation indicators as the IJB evaluation protocol are used. In the face query test, the model recognizes each person in the detection set in turn, and puts other samples belonging to the same person into the interference set in turn for similarity sorting, and obtains the topk accuracy by comparing the predicted answer with the true answer.
[0052] The face verification process and face query process of the MegaFace evaluation protocol are described in detail below in conjunction with specific embodiments, which may include the following contents:
[0053] In the MegaFace evaluation protocol process, the face recognition model can output the extracted feature f based on an input image; the test set includes a detection set and an interference set, where the detection set contains N1 samples, the interference set contains N2 samples, and there are no identical portraits in the detection set and the interference set.
[0054] Next, perform the following operations: During the face verification test, the images of the same person in the detection set are paired into positive sample pairs, and each image in the detection set and each image in the interference set are paired into negative sample pairs, and the same calculation method and evaluation indicators as the IJB evaluation protocol are used.
[0055] In some embodiments, the third evaluation protocol includes a face query test method, and the first model to be evaluated is evaluated using the face verification test method in the third evaluation protocol, including: obtaining a detection set and an interference set in the test set corresponding to the third evaluation protocol, and predicting the images in the detection set and the interference set respectively using the first model to be evaluated to obtain the normalized features corresponding to each image; traversing each image in the detection set in turn, and putting the images belonging to the same object into the interference set in turn to obtain a new interference set, and calculating the feature similarity between the normalized features of the image in the detection set and the normalized features of each image in the new interference set; sorting the feature similarities, and judging the prediction accuracy of the first model to be evaluated based on the sorting result, and using the prediction accuracy as the evaluation index result of the first model to be evaluated.
[0056] Specifically, similar to the face verification test process, the test set used in the face query test process is divided into two parts: a detection set and an interference set. The detection set contains N1 portrait images, the interference set contains N2 portrait images, and there are no identical portraits in the detection set and the interference set.
[0057] Furthermore, during the face query test, for each sample in the detection set and the interference set, the face recognition model is used to extract normalized features f1 and f2; for each sample s1 in the detection set, for each sample s2 belonging to the same portrait as the sample, s2 is added to the interference set to form a new interference set, and the similarity sim=cos(f1,f2) between s1 and each interference set feature is calculated, and sorted from large to small; finally, the accuracy of top1, top5 and top10 are calculated respectively, and recorded as the indicator results of the model.
[0058] In some embodiments, a query matrix and a database matrix are generated based on sample features in a detection set and an interference set, respectively, including: obtaining normalized features corresponding to each image in the detection set and normalized features corresponding to each image in the interference set, generating a query matrix according to the normalized features and feature channels corresponding to each image in the detection set, and generating a database matrix according to the normalized features and feature channels corresponding to each image in the interference set.
[0059] Specifically, since both the IJB evaluation protocol and the MegaFace evaluation protocol need to calculate and sort the similarity between each detection set and each interference set sample, direct calculation is very time-consuming. Therefore, the embodiment of the present disclosure proposes an acceleration strategy based on Faiss accelerated similarity calculation. When calculating the topk accuracy of face query, the maximum value of k is generally 10, so it is only necessary to obtain the top 10 interference set samples that are most similar to the detection set samples. Based on this, the embodiment of the present disclosure proposes a Faiss accelerated similarity calculation process.
[0060] In some embodiments, the sample similarity between the query matrix and the database matrix is calculated, and a similarity matrix is generated based on the sample similarity, including: using an accelerated similarity algorithm to calculate the similarity between samples in the database matrix and the query matrix, selecting a number of samples according to the similarity sorting, and generating a similarity matrix based on normalized features and feature channels corresponding to the number of samples.
[0061] Specifically, in the Faiss accelerated similarity calculation process, the query matrix is first generated based on the normalized features and feature channels corresponding to each image in the detection set, and the database matrix is generated based on the normalized features and feature channels corresponding to each image in the interference set. That is, the sample feature of the detection set is F1∈R N1×l , the interference set sample feature is F2∈R N2×l .
[0062] Furthermore, we use F1 as the query matrix xq and F2 as the database matrix xb; we use the faiss-gpu open source library to calculate the top 10 samples in xb that are most similar to each sample in xq, and obtain the similarity matrix S∈R N1×10 and index matrix I∈R N1×10 .
[0063] In some embodiments, the method also includes: when evaluating the second model to be evaluated using the first evaluation protocol, the second evaluation protocol and / or the third evaluation protocol, using the first model to be evaluated to predict the normalized features of each image in the image pair, and using the second model to be evaluated to predict the quality value of each image in the image pair, calculating the weighted similarity of the image pair based on the normalized features and quality values of the images, determining the evaluation index result based on the weighted similarity, and evaluating the second model to be evaluated using the evaluation index result; wherein the first model to be evaluated is a face recognition model, and the second model to be evaluated is a face quality model.
[0064] Specifically, due to the lack of true value of portrait quality, it is difficult to accurately evaluate the face quality model itself. To address this problem, the embodiment of the present disclosure proposes a quality model evaluation method combined with a face model. The present disclosure provides two methods, namely, one is a method of weighting the similarity based on the quality score, and the other is a method of removing low-quality samples in proportion.
[0065] Furthermore, a similarity weighting method based on quality score is used. This method weights the similarity by calculating the quality of the sample. Generally, the lower the quality value, the lower the weight and the smaller the similarity. If the face evaluation index obtained by weighted similarity calculation is higher than the original similarity calculation method, it means that the quality value output by the face quality model is valid. The more the index is improved, the more accurate the quality model is. The following is a detailed description of the similarity calculation process based on quality score in conjunction with a specific embodiment, which may include the following contents:
[0066] The samples in the sample pair are input into the face recognition model and the face quality model respectively, and the face recognition model and the face quality model are used to output the features f1 and f2 of the two samples, as well as the quality values s1 and s2 respectively; the quality value of the sample pair is calculated by a certain formula, such as the sum and average s = (s1 + s2) / 2; the weighted similarity of the sample pair is sim = cos (f1, f2) * s, thereby outputting the weighted similarity sim of each sample pair.
[0067] Furthermore, in the method of removing low-quality samples in proportion, the quality values of the test samples are sorted, a certain proportion (such as 10%) of the samples with the lowest quality are removed, and the remaining samples are used as the test set for evaluation. The more the evaluation index is improved, the more accurate the quality model is.
[0068] It should be noted that, in the embodiment of the present disclosure, when calculating the similarity of sample pairs, the inverse of the Euclidean distance may be used instead of the cosine similarity.
[0069] According to the technical solution provided by the embodiments of the present disclosure, the present disclosure provides a comprehensive face model evaluation solution with 3 evaluation protocols, 5 evaluation methods and 17 evaluation indicators; the present disclosure also uses the accelerated evaluation strategy of Faiss to accelerate the similarity calculation, so as to improve the efficiency of similarity calculation in the evaluation process of IJB protocol and MegaFace protocol; in addition, the embodiments of the present disclosure combine the face recognition model to perform face quality model evaluation, so it can not only comprehensively evaluate the face recognition model, but also comprehensively evaluate the face quality model.
[0070] The following are embodiments of the device disclosed herein, which can be used to execute the method embodiments disclosed herein. For details not disclosed in the device embodiments disclosed herein, please refer to the method embodiments disclosed herein.
[0071] Figure 2 Schematic diagram of the structure of the model evaluation device provided by the embodiment of the present disclosure. Figure 2 As shown, the model evaluation device includes:
[0072] The acquisition module 201 is configured to acquire a pre-configured evaluation protocol, where the evaluation protocol includes a first evaluation protocol, a second evaluation protocol, and a third evaluation protocol, and each evaluation protocol corresponds to a respective test set;
[0073] The evaluation module 202 is configured to perform an evaluation operation on the first model to be evaluated by using a combination of one or more protocols in the evaluation protocol to obtain an evaluation index result of the first model to be evaluated;
[0074] The comparison module 203 is configured to obtain the feature similarity of each image pair in the test set of the first evaluation protocol when evaluating the first model to be evaluated using the first evaluation protocol, compare the feature similarity with the threshold, and calculate the evaluation index result according to the comparison result;
[0075] The generation module 204 is configured to obtain a detection set and an interference set in a test set of the second evaluation protocol or the third evaluation protocol when evaluating the first model to be evaluated using the second evaluation protocol or the third evaluation protocol, and generate a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively;
[0076] The calculation module 205 is configured to calculate the sample similarity between the query matrix and the database matrix, generate a similarity matrix based on the sample similarity, calculate the model accuracy according to the similarity matrix, and use the model accuracy as the evaluation indicator result of the first model to be evaluated.
[0077] In some embodiments, Figure 2 The comparison module 203 obtains the positive image pairs and the negative image pairs in the test set corresponding to the first evaluation protocol, and predicts the positive image pairs and the negative image pairs respectively using the first model to be evaluated to obtain the normalized features corresponding to each image, and calculates the feature similarity of each group of image pairs using the normalized features of the image; compares the feature similarity with the threshold, and takes the image pairs whose feature similarity is greater than the threshold as the predicted positive image pairs, and takes the image pairs whose feature similarity is less than or equal to the threshold as the predicted negative image pairs; judges the prediction results of the predicted positive image pairs and the predicted negative image pairs, determines the number of pairs of correct image pairs whose prediction results are obtained, and the number of pairs of incorrect image pairs whose prediction results are obtained, and calculates the preset evaluation index results based on the number of correct image pairs and the number of incorrect image pairs; wherein the preset evaluation index results include prediction accuracy, prediction accuracy, true positive rate, false positive rate, ROC curve graph and AUC value.
[0078] In some embodiments, Figure 2The generation module 204 obtains the detection set and the interference set in the test set corresponding to the second evaluation protocol, and uses the first model to be evaluated to predict the images in the detection set and the interference set respectively to obtain the normalized features corresponding to each image; based on the normalized features of each image, the feature similarity between each image in the detection set and each image in the interference set is calculated, the feature similarities are sorted, and the prediction accuracy of the first model to be evaluated is determined according to the sorting result, and the prediction accuracy is used as the evaluation indicator result of the first model to be evaluated.
[0079] In some embodiments, the third evaluation protocol includes a face verification test method, Figure 2 The generation module 204 obtains the detection set and the interference set in the test set corresponding to the third evaluation protocol, and groups the images belonging to the same object in the detection set into positive sample pairs, and combines the images in the detection set with the images in the interference set to obtain negative sample pairs; uses the first model to be evaluated to predict the positive sample pairs and the negative sample pairs respectively, and obtains the normalized features corresponding to each image, and uses the normalized features of the image to calculate the feature similarity of each group of positive sample pairs or negative sample pairs; compares the feature similarity with the threshold, and uses the sample pairs with feature similarity greater than the threshold as the predicted positive sample pairs, and uses the sample pairs with feature similarity less than or equal to the threshold as the predicted negative sample pairs; determines the prediction results of the positive sample pairs according to the predicted positive sample pairs, and determines the prediction results of the negative sample pairs according to the predicted negative sample pairs, and calculates the preset evaluation index results according to the prediction results of the positive sample pairs and the prediction results of the negative sample pairs; wherein the preset evaluation index results include the true positive rate, the false positive rate, the ROC curve graph and the AUC value.
[0080] In some embodiments, the third evaluation protocol includes a face query test method, Figure 2 The generation module 204 obtains the detection set and the interference set in the test set corresponding to the third evaluation protocol, and predicts the images in the detection set and the interference set respectively using the first model to be evaluated to obtain the normalized features corresponding to each image; traverses each image in the detection set in turn, puts the images belonging to the same object into the interference set in turn to obtain a new interference set, calculates the feature similarity between the normalized features of the images in the detection set and the normalized features of each image in the new interference set; sorts the feature similarities, and determines the prediction accuracy of the first model to be evaluated based on the sorting result, and uses the prediction accuracy as the evaluation index result of the first model to be evaluated.
[0081] In some embodiments, Figure 2The calculation module 205 obtains the normalized features corresponding to each image in the detection set and the normalized features corresponding to each image in the interference set, generates a query matrix according to the normalized features and feature channels corresponding to each image in the detection set, and generates a database matrix according to the normalized features and feature channels corresponding to each image in the interference set.
[0082] In some embodiments, Figure 2 The calculation module 205 uses an accelerated similarity algorithm to calculate the similarity between the samples in the database matrix and the query matrix, selects a number of samples according to the similarity sorting, and generates a similarity matrix according to the normalized features and feature channels corresponding to the samples.
[0083] In some embodiments, Figure 2 When the calculation module 205 uses the first evaluation protocol, the second evaluation protocol and / or the third evaluation protocol to evaluate the second model to be evaluated, the first model to be evaluated is used to predict the normalized features of each image in the image pair, and the second model to be evaluated is used to predict the quality value of each image in the image pair, and the weighted similarity of the image pair is calculated according to the normalized features and quality values of the images, and the evaluation index result is determined according to the weighted similarity, and the second model to be evaluated is evaluated using the evaluation index result; wherein, the first model to be evaluated is a face recognition model, and the second model to be evaluated is a face quality model.
[0084] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present disclosure.
[0085] Figure 3 Schematic diagram of the structure of the electronic device 3 provided in the embodiment of the present disclosure. Figure 3 As shown, the electronic device 3 of this embodiment includes: a processor 301, a memory 302, and a computer program 303 stored in the memory 302 and executable on the processor 301. When the processor 301 executes the computer program 303, the steps in the above-mentioned method embodiments are implemented. Alternatively, when the processor 301 executes the computer program 303, the functions of the modules / units in the above-mentioned device embodiments are implemented.
[0086] Exemplarily, the computer program 303 may be divided into one or more modules / units, which are stored in the memory 302 and executed by the processor 301 to complete the present disclosure. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 303 in the electronic device 3.
[0087] The electronic device 3 may be a desktop computer, a notebook, a PDA, a cloud server, or other electronic device. The electronic device 3 may include, but is not limited to, a processor 301 and a memory 302. Those skilled in the art will appreciate that Figure 3 It is only an example of the electronic device 3 and does not constitute a limitation of the electronic device 3. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.
[0088] The processor 301 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc.
[0089] The memory 302 may be an internal storage unit of the electronic device 3, for example, a hard disk or memory of the electronic device 3. The memory 302 may also be an external storage device of the electronic device 3, for example, a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device 3. Further, the memory 302 may also include both an internal storage unit and an external storage device of the electronic device 3. The memory 302 is used to store computer programs and other programs and data required by the electronic device. The memory 302 may also be used to temporarily store data that has been output or is to be output.
[0090] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0091] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0092] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this disclosure.
[0093] In the embodiments provided in the present disclosure, it should be understood that the disclosed apparatus / computer equipment and methods can be implemented in other ways. For example, the apparatus / computer equipment embodiments described above are merely schematic. For example, the division of modules or units is only a logical function division. There may be other division methods in actual implementation. Multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of the apparatus or unit, which may be electrical, mechanical or other forms.
[0094] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0095] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0096] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present disclosure implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. The computer program may include computer program code, and the computer program code may be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, the computer-readable medium does not include electric carrier signals and telecommunication signals.
[0097] The above embodiments are only used to illustrate the technical solutions of the present disclosure, rather than to limit them. Although the present disclosure has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should all be included in the protection scope of the present disclosure.
Claims
1. A model evaluation method, characterized in that: include: Obtaining a preconfigured evaluation protocol, wherein the evaluation protocol includes a first evaluation protocol, a second evaluation protocol, and a third evaluation protocol, each of the evaluation protocols corresponding to a respective test set; Using the third evaluation protocol in the evaluation protocol, an evaluation operation is performed on the first model to be evaluated to obtain an evaluation index result for the first model to be evaluated; When evaluating the first model to be evaluated by using the third evaluation protocol, obtaining a detection set and an interference set in a test set of the third evaluation protocol, and generating a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively; Calculating sample similarity between the query matrix and the database matrix, generating a similarity matrix based on the sample similarity, calculating model accuracy according to the similarity matrix, and using the model accuracy as an evaluation index result of the first model to be evaluated; The third evaluation protocol includes a face query test method, and the first model to be evaluated is evaluated using the face verification test method in the third evaluation protocol, including: Obtaining a detection set and an interference set in a test set corresponding to the third evaluation protocol, and using the first model to be evaluated to predict the images in the detection set and the interference set, respectively, to obtain normalized features corresponding to each image; Traversing each image in the detection set in turn, putting images belonging to the same object into the interference set in turn to obtain a new interference set, and calculating the feature similarity between the normalized features of the images in the detection set and the normalized features of each image in the new interference set; Sorting the feature similarities, and judging the prediction accuracy of the first model to be evaluated according to the sorting result, and using the prediction accuracy as the evaluation index result of the first model to be evaluated; The generating a query matrix and a database matrix based on the sample features in the detection set and the interference set respectively comprises: Obtaining normalized features corresponding to each image in the detection set and normalized features corresponding to each image in the interference set, generating a query matrix according to the normalized features and feature channels corresponding to each image in the detection set, and generating a database matrix according to the normalized features and feature channels corresponding to each image in the interference set; The calculating the sample similarity between the query matrix and the database matrix, and generating a similarity matrix based on the sample similarity, comprises: Using an accelerated similarity algorithm, the similarity between the samples in the database matrix and the query matrix is calculated, a number of samples are selected according to the similarity sorting, and a similarity matrix is generated according to the normalized features and feature channels corresponding to the number of samples; The detection set includes multiple portrait images, the interference set includes multiple portrait images, and the detection set and the interference set do not contain the same portrait.
2. The method according to claim 1, characterized in that The method further comprises: When evaluating the second model to be evaluated using the first evaluation protocol, the second evaluation protocol and / or the third evaluation protocol, the first model to be evaluated is used to predict the normalized features of each image in the image pair, and the second model to be evaluated is used to predict the quality value of each image in the image pair, and the weighted similarity of the image pair is calculated based on the normalized features and the quality values of the images, an evaluation index result is determined based on the weighted similarity, and the second model to be evaluated is evaluated using the evaluation index result; The first model to be evaluated is a face recognition model, and the second model to be evaluated is a face quality model.
3. A model evaluation device, characterized in that: include: An acquisition module is configured to acquire a preconfigured evaluation protocol, wherein the evaluation protocol includes a first evaluation protocol, a second evaluation protocol, and a third evaluation protocol, and each of the evaluation protocols corresponds to a respective test set; An evaluation module is configured to perform an evaluation operation on the first model to be evaluated by using the third evaluation protocol in the evaluation protocol to obtain an evaluation index result for the first model to be evaluated; A generation module is configured to obtain a detection set and an interference set in a test set of the third evaluation protocol when evaluating the first model to be evaluated using the third evaluation protocol, and generate a query matrix and a database matrix based on sample features in the detection set and the interference set, respectively; A calculation module is configured to calculate sample similarity between the query matrix and the database matrix, generate a similarity matrix based on the sample similarity, calculate a model accuracy according to the similarity matrix, and use the model accuracy as an evaluation indicator result of the first model to be evaluated; Among them, the third evaluation protocol includes a face query test method, and the generation module is used to obtain a detection set and an interference set in a test set corresponding to the third evaluation protocol, and for the images in the detection set and the interference set, use the first model to be evaluated to predict the images respectively to obtain the normalized features corresponding to each image; traverse each image in the detection set in turn, put the images belonging to the same object into the interference set in turn to obtain a new interference set, and calculate the feature similarity between the normalized features of the images in the detection set and the normalized features of each image in the new interference set; sort the feature similarities, and judge the prediction accuracy of the first model to be evaluated according to the sorting result, and use the prediction accuracy as the evaluation index result of the first model to be evaluated; The calculation module is used to obtain the normalized features corresponding to each image in the detection set and the normalized features corresponding to each image in the interference set, generate a query matrix according to the normalized features and feature channels corresponding to each image in the detection set, and generate a database matrix according to the normalized features and feature channels corresponding to each image in the interference set; The calculation module is used to calculate the similarity between the samples in the database matrix and the query matrix by using an accelerated similarity algorithm, select a number of samples according to the similarity sorting, and generate a similarity matrix according to the normalized features and feature channels corresponding to the number of samples; wherein the detection set contains a plurality of portrait images, the interference set contains a plurality of portrait images, and the detection set and the interference set do not have the same portrait; The detection set includes multiple portrait images, the interference set includes multiple portrait images, and the detection set and the interference set do not contain the same portrait.
4. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 2 is implemented.
