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

How to calculate accuracy for facial recognition system?

我是生物识别评估的新手,我想绘制 ROC 曲线、CMC 曲线和正版与冒名顶替者分布。我根据 https://www.pyimagesearch.com/2018/06/18/face-recognition-with-opencv-python-and-deep-learning/ 在我的数据集上训练了模型。如果我提供测试图像,它可以正常工作。 但是,我不知道如何根据这种方法为整个测试数据集获得真实和冒名顶替的分数。

所有最先进的模型,如 VGG-Face、FaceNet 或 DeepFace,都在 LFW(Labeled Faces in the Wild)数据集上进行了测试。幸运的是,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

现在,您应该用您的模型测试每一对。

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)

然后,您应该比较预测和标签。

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

此外,您还可以计算一些其他指标

from sklearn.metrics import precision_score, recall_score, f1_score
    
precision = precision_score(actuals, predictions)
recall = recall_score(actuals, predictions)
f1 = f1_score(actuals, predictions)