Commit 82fa59c1a73c5aa0f901cf78431e08b4923d8303
1 parent
3d060770
Handle FTEs without crash in landmark eval
Showing
1 changed file
with
8 additions
and
1 deletions
openbr/core/eval.cpp
| @@ -572,6 +572,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -572,6 +572,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 572 | const QStringList predictedNames = File::get<QString>(predicted, "name"); | 572 | const QStringList predictedNames = File::get<QString>(predicted, "name"); |
| 573 | const QStringList truthNames = File::get<QString>(truth, "name"); | 573 | const QStringList truthNames = File::get<QString>(truth, "name"); |
| 574 | 574 | ||
| 575 | + int skipped = 0; | ||
| 575 | QList< QList<float> > pointErrors; | 576 | QList< QList<float> > pointErrors; |
| 576 | for (int i=0; i<predicted.size(); i++) { | 577 | for (int i=0; i<predicted.size(); i++) { |
| 577 | const QString &predictedName = predictedNames[i]; | 578 | const QString &predictedName = predictedNames[i]; |
| @@ -579,7 +580,10 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -579,7 +580,10 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 579 | if (truthIndex == -1) qFatal("Could not identify ground truth for file: %s", qPrintable(predictedName)); | 580 | if (truthIndex == -1) qFatal("Could not identify ground truth for file: %s", qPrintable(predictedName)); |
| 580 | const QList<QPointF> predictedPoints = predicted[i].file.points(); | 581 | const QList<QPointF> predictedPoints = predicted[i].file.points(); |
| 581 | const QList<QPointF> truthPoints = truth[truthIndex].file.points(); | 582 | const QList<QPointF> truthPoints = truth[truthIndex].file.points(); |
| 582 | - if (predictedPoints.size() != truthPoints.size()) qFatal("Points size mismatch for file: %s", qPrintable(predictedName)); | 583 | + if (predictedPoints.size() != truthPoints.size()) { |
| 584 | + skipped++; | ||
| 585 | + continue; | ||
| 586 | + } | ||
| 583 | while (pointErrors.size() < predictedPoints.size()) | 587 | while (pointErrors.size() < predictedPoints.size()) |
| 584 | pointErrors.append(QList<float>()); | 588 | pointErrors.append(QList<float>()); |
| 585 | if (normalizationIndexA >= truthPoints.size()) qFatal("Normalization index A is out of range."); | 589 | if (normalizationIndexA >= truthPoints.size()) qFatal("Normalization index A is out of range."); |
| @@ -588,6 +592,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -588,6 +592,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 588 | for (int j=0; j<predictedPoints.size(); j++) | 592 | for (int j=0; j<predictedPoints.size(); j++) |
| 589 | pointErrors[j].append(QtUtils::euclideanLength(predictedPoints[j] - truthPoints[j])/normalizedLength); | 593 | pointErrors[j].append(QtUtils::euclideanLength(predictedPoints[j] - truthPoints[j])/normalizedLength); |
| 590 | } | 594 | } |
| 595 | + qDebug() << "Skipped " << skipped << " files do to point size mismatch."; | ||
| 591 | 596 | ||
| 592 | QList<float> averagePointErrors; averagePointErrors.reserve(pointErrors.size()); | 597 | QList<float> averagePointErrors; averagePointErrors.reserve(pointErrors.size()); |
| 593 | for (int i=0; i<pointErrors.size(); i++) { | 598 | for (int i=0; i<pointErrors.size(); i++) { |
| @@ -605,6 +610,8 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | @@ -605,6 +610,8 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle | ||
| 605 | lines.append(QString("Box,%1,%2").arg(QString::number(i), QString::number(pointError[j*(pointError.size()-1)/(keep-1)]))); | 610 | lines.append(QString("Box,%1,%2").arg(QString::number(i), QString::number(pointError[j*(pointError.size()-1)/(keep-1)]))); |
| 606 | } | 611 | } |
| 607 | 612 | ||
| 613 | + lines.append(QString("AvgError,0,%1").arg(averagePointError)); | ||
| 614 | + | ||
| 608 | QtUtils::writeFile(csv, lines); | 615 | QtUtils::writeFile(csv, lines); |
| 609 | qDebug("Average Error: %.3f", averagePointError); | 616 | qDebug("Average Error: %.3f", averagePointError); |
| 610 | return averagePointError; | 617 | return averagePointError; |