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 | 231 | lines.append(qPrintable(QString("BC,0.001,%1").arg(QString::number(getTAR(operatingPoints, 0.001), 'f', 3)))); |
| 232 | 232 | lines.append(qPrintable(QString("BC,0.01,%1").arg(QString::number(result = getTAR(operatingPoints, 0.01), 'f', 3)))); |
| 233 | 233 | |
| 234 | + | |
| 234 | 235 | // Write SD & KDE |
| 235 | 236 | points = qMin(qMin(Max_Points, genuines.size()), impostors.size()); |
| 236 | 237 | QList<double> sampledGenuineScores; sampledGenuineScores.reserve(points); |
| 237 | 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 | 253 | const double hGenuine = Common::KernelDensityBandwidth(sampledGenuineScores); |
| ... | ... | @@ -257,6 +261,7 @@ float Evaluate(const Mat &simmat, const Mat &mask, const QString &csv) |
| 257 | 261 | // Write Cumulative Match Characteristic (CMC) curve |
| 258 | 262 | const int Max_Retrieval = 100; |
| 259 | 263 | const int Report_Retrieval = 5; |
| 264 | + | |
| 260 | 265 | float reportRetrievalRate = -1; |
| 261 | 266 | for (int i=1; i<=Max_Retrieval; i++) { |
| 262 | 267 | int realizedReturns = 0, possibleReturns = 0; | ... | ... |
openbr/openbr_plugin.cpp
| ... | ... | @@ -441,6 +441,8 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) |
| 441 | 441 | newTemplates[i].file.set("Cross_Validation_Partition", QVariant(0)); |
| 442 | 442 | for (int j=crossValidate-1; j>=1; j--) { |
| 443 | 443 | Template allPartitionTemplate = newTemplates[i]; |
| 444 | + allPartitionTemplate.file.append(gallery.localMetadata()); | |
| 445 | + allPartitionTemplate.file.append(file.localMetadata()); | |
| 444 | 446 | allPartitionTemplate.file.set("Cross_Validation_Partition", j); |
| 445 | 447 | allPartitionTemplate.file.set("Label", i+templates.size()); |
| 446 | 448 | // Insert templates for all the other partitions | ... | ... |