Commit 5cf9904e92e488cee53b76fb53cf2ca539b50225

Authored by Keyur Patel
1 parent 1843ef01

Refactored evalLiveness to evalEER

openbr/core/eval.cpp
@@ -1168,12 +1168,12 @@ void EvalKNN(const QString &knnGraph, const QString &knnTruth, const QString &cs @@ -1168,12 +1168,12 @@ void EvalKNN(const QString &knnGraph, const QString &knnTruth, const QString &cs
1168 qDebug("FNIR @ FPIR = 0.01: %.3f", 1-getOperatingPointGivenFAR(operatingPoints, 0.01).TAR); 1168 qDebug("FNIR @ FPIR = 0.01: %.3f", 1-getOperatingPointGivenFAR(operatingPoints, 0.01).TAR);
1169 } 1169 }
1170 1170
1171 -void EvalLiveness(const QString &predictedXML, QString gt_property, QString distribution_property){ 1171 +void EvalEER(const QString &predictedXML, QString gt_property, QString distribution_property){
1172 if (gt_property.isEmpty()) 1172 if (gt_property.isEmpty())
1173 gt_property = "LivenessGT"; 1173 gt_property = "LivenessGT";
1174 if (distribution_property.isEmpty()) 1174 if (distribution_property.isEmpty())
1175 distribution_property = "LivenessDistribution"; 1175 distribution_property = "LivenessDistribution";
1176 - int genuineTemplateCount = 0; 1176 + int classOneTemplateCount = 0;
1177 const TemplateList templateList(TemplateList::fromGallery(predictedXML)); 1177 const TemplateList templateList(TemplateList::fromGallery(predictedXML));
1178 1178
1179 QHash<QString, int> gtLabels; 1179 QHash<QString, int> gtLabels;
@@ -1182,7 +1182,7 @@ void EvalLiveness(const QString &amp;predictedXML, QString gt_property, QString dist @@ -1182,7 +1182,7 @@ void EvalLiveness(const QString &amp;predictedXML, QString gt_property, QString dist
1182 QString templateKey = templateList[i].file.path() + templateList[i].file.baseName(); 1182 QString templateKey = templateList[i].file.path() + templateList[i].file.baseName();
1183 int gtLabel = templateList[i].file.get<int>(gt_property); 1183 int gtLabel = templateList[i].file.get<int>(gt_property);
1184 if (gtLabel == 1) 1184 if (gtLabel == 1)
1185 - genuineTemplateCount++; 1185 + classOneTemplateCount++;
1186 QList<float> templateScores = templateList[i].file.getList<float>(distribution_property); 1186 QList<float> templateScores = templateList[i].file.getList<float>(distribution_property);
1187 gtLabels[templateKey] = gtLabel; 1187 gtLabels[templateKey] = gtLabel;
1188 scores[templateKey] = templateScores; 1188 scores[templateKey] = templateScores;
@@ -1213,8 +1213,8 @@ void EvalLiveness(const QString &amp;predictedXML, QString gt_property, QString dist @@ -1213,8 +1213,8 @@ void EvalLiveness(const QString &amp;predictedXML, QString gt_property, QString dist
1213 else if (scores[key][0] < thresNorm && gtLabel == 0) 1213 else if (scores[key][0] < thresNorm && gtLabel == 0)
1214 FA +=1; 1214 FA +=1;
1215 } 1215 }
1216 - float FAR = FA / float(numTemplates - genuineTemplateCount);  
1217 - float FRR = FR / float(genuineTemplateCount); 1216 + float FAR = FA / float(numTemplates - classOneTemplateCount);
  1217 + float FRR = FR / float(classOneTemplateCount);
1218 1218
1219 float diff = std::abs(FAR-FRR); 1219 float diff = std::abs(FAR-FRR);
1220 if (diff < minDiff){ 1220 if (diff < minDiff){
@@ -1225,8 +1225,8 @@ void EvalLiveness(const QString &amp;predictedXML, QString gt_property, QString dist @@ -1225,8 +1225,8 @@ void EvalLiveness(const QString &amp;predictedXML, QString gt_property, QString dist
1225 thres += stepSize; 1225 thres += stepSize;
1226 } 1226 }
1227 1227
1228 - qDebug() <<"Genuine Templates:" << genuineTemplateCount << "Spoof Templates:"  
1229 - << numTemplates - genuineTemplateCount << "Total Templates:" << numTemplates; 1228 + qDebug() <<"Class 0 Templates:" << classOneTemplateCount << "Class 1 Templates:"
  1229 + << numTemplates - classOneTemplateCount << "Total Templates:" << numTemplates;
1230 qDebug("EER: %.3f @ Threshold %.3f", EER*100, EERThres); 1230 qDebug("EER: %.3f @ Threshold %.3f", EER*100, EERThres);
1231 1231
1232 } 1232 }
openbr/core/eval.h
@@ -34,7 +34,7 @@ namespace br @@ -34,7 +34,7 @@ namespace br
34 float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", int normalizationIndexA = 0, int normalizationIndexB = 1, int sampleIndex = 0, int totalExamples = 5); // Return average error 34 float EvalLandmarking(const QString &predictedGallery, const QString &truthGallery, const QString &csv = "", int normalizationIndexA = 0, int normalizationIndexB = 1, int sampleIndex = 0, int totalExamples = 5); // Return average error
35 void EvalRegression(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = ""); 35 void EvalRegression(const QString &predictedGallery, const QString &truthGallery, QString predictedProperty = "", QString truthProperty = "");
36 void EvalKNN(const QString &knnGraph, const QString &knnTruth, const QString &csv = ""); 36 void EvalKNN(const QString &knnGraph, const QString &knnTruth, const QString &csv = "");
37 - void EvalLiveness(const QString &predictedXML, const QString gt_property = "", const QString distribution_property = ""); 37 + void EvalEER(const QString &predictedXML, const QString gt_property = "", const QString distribution_property = "");
38 struct Candidate 38 struct Candidate
39 { 39 {
40 size_t index; 40 size_t index;
openbr/openbr.cpp
@@ -150,9 +150,9 @@ void br_eval_knn(const char *knnGraph, const char *knnTruth, const char *csv) @@ -150,9 +150,9 @@ void br_eval_knn(const char *knnGraph, const char *knnTruth, const char *csv)
150 EvalKNN(knnGraph, knnTruth, csv); 150 EvalKNN(knnGraph, knnTruth, csv);
151 } 151 }
152 152
153 -void br_eval_Liveness(const char *predicted_xml, const char *gt_property, const char *distribution_property ) 153 +void br_eval_eer(const char *predicted_xml, const char *gt_property, const char *distribution_property )
154 { 154 {
155 - EvalLiveness(predicted_xml, gt_property, distribution_property); 155 + EvalEER(predicted_xml, gt_property, distribution_property);
156 } 156 }
157 157
158 void br_finalize() 158 void br_finalize()
openbr/openbr.h
@@ -66,7 +66,7 @@ BR_EXPORT void br_eval_regression(const char *predicted_gallery, const char *tru @@ -66,7 +66,7 @@ BR_EXPORT void br_eval_regression(const char *predicted_gallery, const char *tru
66 66
67 BR_EXPORT void br_eval_knn(const char *knnGraph, const char *knnTruth, const char *csv = ""); 67 BR_EXPORT void br_eval_knn(const char *knnGraph, const char *knnTruth, const char *csv = "");
68 68
69 -BR_EXPORT void br_eval_Liveness(const char *predicted_xml, const char *gt_property = "", const char *distribution_property = ""); 69 +BR_EXPORT void br_eval_eer(const char *predicted_xml, const char *gt_property = "", const char *distribution_property = "");
70 70
71 BR_EXPORT void br_finalize(); 71 BR_EXPORT void br_finalize();
72 72