Commit 6c187349522faa9ae9bf880c4fbc1846318428ce
1 parent
90093920
Maybe fixed cross validation bug?
Showing
2 changed files
with
16 additions
and
9 deletions
openbr/core/plot.cpp
| @@ -231,19 +231,23 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | @@ -231,19 +231,23 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 231 | lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); | 231 | lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); |
| 232 | lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3)))); | 232 | lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3)))); |
| 233 | 233 | ||
| 234 | + | ||
| 234 | // Write SD & KDE | 235 | // Write SD & KDE |
| 235 | points = qMin(qMin(Max_Points, genuines.size()), impostors.size()); | 236 | points = qMin(qMin(Max_Points, genuines.size()), impostors.size()); |
| 236 | QList<double> sampledGenuineScores; sampledGenuineScores.reserve(points); | 237 | QList<double> sampledGenuineScores; sampledGenuineScores.reserve(points); |
| 237 | QList<double> sampledImpostorScores; sampledImpostorScores.reserve(points); | 238 | QList<double> sampledImpostorScores; sampledImpostorScores.reserve(points); |
| 238 | - for (int i=0; i<points; i++) { | ||
| 239 | - float genuineScore = genuines[double(i) / double(points-1) * double(genuines.size()-1)]; | ||
| 240 | - float impostorScore = impostors[double(i) / double(points-1) * double(impostors.size()-1)]; | ||
| 241 | - if (genuineScore == -std::numeric_limits<float>::max()) genuineScore = minGenuineScore; | ||
| 242 | - if (impostorScore == -std::numeric_limits<float>::max()) impostorScore = minImpostorScore; | ||
| 243 | - lines.append(QString("SD,%1,Genuine").arg(QString::number(genuineScore))); | ||
| 244 | - lines.append(QString("SD,%1,Impostor").arg(QString::number(impostorScore))); | ||
| 245 | - sampledGenuineScores.append(genuineScore); | ||
| 246 | - sampledImpostorScores.append(impostorScore); | 239 | + |
| 240 | + if (points > 1) { | ||
| 241 | + for (int i=0; i<points; i++) { | ||
| 242 | + float genuineScore = genuines[double(i) / double(points-1) * double(genuines.size()-1)]; | ||
| 243 | + float impostorScore = impostors[double(i) / double(points-1) * double(impostors.size()-1)]; | ||
| 244 | + if (genuineScore == -std::numeric_limits<float>::max()) genuineScore = minGenuineScore; | ||
| 245 | + if (impostorScore == -std::numeric_limits<float>::max()) impostorScore = minImpostorScore; | ||
| 246 | + lines.append(QString("SD,%1,Genuine").arg(QString::number(genuineScore))); | ||
| 247 | + lines.append(QString("SD,%1,Impostor").arg(QString::number(impostorScore))); | ||
| 248 | + sampledGenuineScores.append(genuineScore); | ||
| 249 | + sampledImpostorScores.append(impostorScore); | ||
| 250 | + } | ||
| 247 | } | 251 | } |
| 248 | 252 | ||
| 249 | const double hGenuine = Common::KernelDensityBandwidth(sampledGenuineScores); | 253 | const double hGenuine = Common::KernelDensityBandwidth(sampledGenuineScores); |
| @@ -257,6 +261,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | @@ -257,6 +261,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) | ||
| 257 | // Write Cumulative Match Characteristic (CMC) curve | 261 | // Write Cumulative Match Characteristic (CMC) curve |
| 258 | const int Max_Retrieval = 100; | 262 | const int Max_Retrieval = 100; |
| 259 | const int Report_Retrieval = 5; | 263 | const int Report_Retrieval = 5; |
| 264 | + | ||
| 260 | float reportRetrievalRate = -1; | 265 | float reportRetrievalRate = -1; |
| 261 | for (int i=1; i<=Max_Retrieval; i++) { | 266 | for (int i=1; i<=Max_Retrieval; i++) { |
| 262 | int realizedReturns = 0, possibleReturns = 0; | 267 | int realizedReturns = 0, possibleReturns = 0; |
openbr/openbr_plugin.cpp
| @@ -441,6 +441,8 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) | @@ -441,6 +441,8 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) | ||
| 441 | newTemplates[i].file.set("Cross_Validation_Partition", QVariant(0)); | 441 | newTemplates[i].file.set("Cross_Validation_Partition", QVariant(0)); |
| 442 | for (int j=crossValidate-1; j>=1; j--) { | 442 | for (int j=crossValidate-1; j>=1; j--) { |
| 443 | Template allPartitionTemplate = newTemplates[i]; | 443 | Template allPartitionTemplate = newTemplates[i]; |
| 444 | + allPartitionTemplate.file.append(gallery.localMetadata()); | ||
| 445 | + allPartitionTemplate.file.append(file.localMetadata()); | ||
| 444 | allPartitionTemplate.file.set("Cross_Validation_Partition", j); | 446 | allPartitionTemplate.file.set("Cross_Validation_Partition", j); |
| 445 | allPartitionTemplate.file.set("Label", i+templates.size()); | 447 | allPartitionTemplate.file.set("Label", i+templates.size()); |
| 446 | // Insert templates for all the other partitions | 448 | // Insert templates for all the other partitions |