简体   繁体   English

如何计算人脸识别系统的准确率?

[英]How to calculate accuracy for facial recognition system?

I am new to Biometric Evaluation and I wish to plot the ROC curve, CMC curve, and Genuine Vs Imposter Distribution.我是生物特征评估的新手,我希望绘制 ROC 曲线、CMC 曲线和 Genuine Vs Imposter 分布。 I trained the model on my dataset based on https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/ .我基于https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/在我的数据集上训练了模型。 If I give a test image, it is working correctly.如果我给出一个测试图像,它就可以正常工作。 But, I do not know how to get a genuine and imposter score based on this method for the entire Test Dataset.但是,我不知道如何根据这种方法为整个测试数据集获得真实和冒名顶替的分数。

All state-of-the-art models such as VGG-Face, FaceNet or DeepFace tested on LFW (Labeled Faces in the Wild) data set.所有最先进的模型,如 VGG-Face、FaceNet 或 DeepFace,都在 LFW(野外标记人脸)数据集上进行了测试。 Luckily, scikit learn offers this data set as an out-of-the-box function.幸运的是,scikit learn 将此数据集作为开箱即用的功能提供。

from sklearn.datasets import fetch_lfw_pairs
fetch_lfw_pairs = fetch_lfw_pairs(subset = 'test', color = True, resize = 1)
pairs = fetch_lfw_pairs.pairs
labels = fetch_lfw_pairs.target

Now, you should test each pair with your model.现在,您应该使用您的模型测试每一对。

predictions = []
for i in range(0, pairs.shape[0]):
   pair = pairs[i]
   img1 = pair[0]
   img2 = pair[1]
   prediction = verify(img1, img2) #this should return 1 for same person, 0 for different persons.
   predictions.append(prediction)

Then, you should compare predictions and labels.然后,您应该比较预测和标签。

from sklearn.metrics import accuracy_score
score = accuracy_score(labels, predictions)

Besides, you can calculate some other metrics此外,您可以计算一些其他指标

from sklearn.metrics import precision_score, recall_score, f1_score从 sklearn.metrics 导入 precision_score、recall_score、f1_score

precision = precision_score(actuals, predictions)
recall = recall_score(actuals, predictions)
f1 = f1_score(actuals, predictions)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM