Commit 259aa3f06c3753a6ad80071bcca3313e5448e609
1 parent
d6ae2849
Added landmark error plots
Showing
2 changed files
with
29 additions
and
9 deletions
openbr/core/eval.cpp
| ... | ... | @@ -1095,6 +1095,7 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle |
| 1095 | 1095 | QStringList lines; |
| 1096 | 1096 | lines.append("Plot,X,Y"); |
| 1097 | 1097 | |
| 1098 | + // Sample | |
| 1098 | 1099 | QFile exampleFile("landmarking_examples"); |
| 1099 | 1100 | QtUtils::touchDir(exampleFile); |
| 1100 | 1101 | lines.append("EX,landmarking_examples/"+truth[sampleIndex].file.fileName()+","+QString::number(truth[sampleIndex].file.points().size())); |
| ... | ... | @@ -1102,6 +1103,17 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle |
| 1102 | 1103 | // Alternatively, can we just pass this through a predetermined transform and write? |
| 1103 | 1104 | Enroll(truth[sampleIndex],"landmarking_examples"); |
| 1104 | 1105 | |
| 1106 | + // Error table | |
| 1107 | + for (int i=0; i<averagePointErrors.size(); i++) { | |
| 1108 | + lines.append(QString("AE,%1,%2").arg(QString::number(i),QString::number(averagePointErrors[i], 'f', 3))); | |
| 1109 | + lines.append(QString("ME,%1,%2").arg(QString::number(i),QString::number(medianPointErrors[i], 'f', 3))); | |
| 1110 | + lines.append(QString("SE,%1,%2").arg(QString::number(i),QString::number(stddevPointErrors[i], 'f', 3))); | |
| 1111 | + } | |
| 1112 | + | |
| 1113 | + lines.append(QString("AE,%1,%2").arg(QString::number(averagePointErrors.size()),QString::number(averagePointError, 'f', 3))); | |
| 1114 | + lines.append(QString("ME,%1,%2").arg(QString::number(averagePointErrors.size()),QString::number(medianPointError, 'f', 3))); | |
| 1115 | + lines.append(QString("SE,%1,%2").arg(QString::number(averagePointErrors.size()),QString::number(stddevPointError, 'f', 3))); | |
| 1116 | + | |
| 1105 | 1117 | for (int i=0; i<pointErrors.size(); i++) { |
| 1106 | 1118 | const QList<float> &pointError = pointErrors[i]; |
| 1107 | 1119 | const int keep = qMin(Max_Points, pointError.size()); |
| ... | ... | @@ -1113,12 +1125,6 @@ float EvalLandmarking(const QString &predictedGallery, const QString &truthGalle |
| 1113 | 1125 | |
| 1114 | 1126 | QtUtils::writeFile(csv, lines); |
| 1115 | 1127 | |
| 1116 | - for (int i=0; i<averagePointErrors.size(); i++) { | |
| 1117 | - qDebug("Average Error for point %d: %.3f", i, averagePointErrors[i]); | |
| 1118 | - qDebug("Median Error for point %d: %.3f", i, medianPointErrors[i]); | |
| 1119 | - qDebug("Standard Deviation of Error for point %d: %.3f", i, stddevPointErrors[i]); | |
| 1120 | - } | |
| 1121 | - | |
| 1122 | 1128 | qDebug("Average Error for all Points: %.3f", averagePointError); |
| 1123 | 1129 | qDebug("Average Median Error for all Points: %.3f", medianPointError); |
| 1124 | 1130 | qDebug("Average Standard Deviation of Error for all Points: %.3f", stddevPointError); | ... | ... |
openbr/core/plot.cpp
| ... | ... | @@ -469,16 +469,18 @@ bool PlotLandmarking(const QStringList &files, const File &destination, bool sho |
| 469 | 469 | qDebug("Plotting %d landmarking file(s) to %s", files.size(), qPrintable(destination)); |
| 470 | 470 | RPlot p(files, destination, false); |
| 471 | 471 | |
| 472 | - p.file.write("# Split data into individual plots\n" | |
| 472 | + p.file.write(qPrintable(QString("# Split data into individual plots\n" | |
| 473 | 473 | "plot_index = which(names(data)==\"Plot\")\n" |
| 474 | 474 | "Box <- data[grep(\"Box\",data$Plot),-c(1)]\n" |
| 475 | 475 | "EX <- data[grep(\"EX\",data$Plot),-c(1)]\n" |
| 476 | + "AE <- data[grep(\"AE\",data$Plot),-c(1)]\n" | |
| 477 | + "ME <- data[grep(\"ME\",data$Plot),-c(1)]\n" | |
| 478 | + "SE <- data[grep(\"SE\",data$Plot),-c(1)]\n" | |
| 476 | 479 | "EX$X <- as.character(EX$X)\n" |
| 477 | 480 | "EX$Y <- as.character(EX$Y)\n" |
| 478 | 481 | "rm(data)\n" |
| 479 | - "\n"); | |
| 482 | + "\n"))); | |
| 480 | 483 | |
| 481 | - // Load in the relevant libraries | |
| 482 | 484 | p.file.write(qPrintable(QString("if (nrow(EX) != 0) { \ |
| 483 | 485 | \n\tlibrary(jpeg) \ |
| 484 | 486 | \n\tlibrary(png) \ |
| ... | ... | @@ -531,6 +533,18 @@ bool PlotLandmarking(const QStringList &files, const File &destination, bool sho |
| 531 | 533 | + theme(axis.line=element_blank(), axis.title.y=element_blank(), axis.text.x=element_blank(), axis.text.y=element_blank(), line=element_blank(), axis.ticks=element_blank(), panel.background=element_blank()) \ |
| 532 | 534 | + labs(title=\"Sample Landmarks\") + xlab(sprintf(\"Total Landmarks: %s\",points)))\n\t\t}}\n"))); |
| 533 | 535 | |
| 536 | + p.file.write(qPrintable(QString("\n" | |
| 537 | + "# Code to format error table\n" | |
| 538 | + "l <- list(AE$Y,ME$Y,SE$Y)\n" | |
| 539 | + "mat <- matrix(do.call(rbind, l),nrow=nrow(AE),ncol=3,byrow=TRUE)\n" | |
| 540 | + "colnames(mat) <- c(\"Mean\",\"Median\",\"Std. Dev.\") \n" | |
| 541 | + "rownames(mat) <- c(seq(0,nrow(AE)-2),\"Average\")\n" | |
| 542 | + "ETable <- as.table(mat)\n"))); | |
| 543 | + | |
| 544 | + p.file.write(qPrintable(QString("\n" | |
| 545 | + "print(textplot(ETable))\n" | |
| 546 | + "print(title(expression(atop(\"Landmark Error Rates\", atop(italic(\"Average Normalization Distance: 91.419 (pixels)\"))))))\n"))); | |
| 547 | + | |
| 534 | 548 | p.file.write(qPrintable(QString("ggplot(Box, aes(Y,%1%2))").arg(p.major.size > 1 ? QString(", colour=%1").arg(p.major.header) : QString(), |
| 535 | 549 | p.minor.size > 1 ? QString(", linetype=%1").arg(p.minor.header) : QString()) + |
| 536 | 550 | QString(" + annotation_logticks(sides=\"b\") + stat_ecdf() + scale_x_log10(\"Normalized Error\", breaks=c(0.001,0.01,0.1,1,10)) + scale_y_continuous(\"Cumulative Density\", label=percent) + theme_minimal()\n\n"))); | ... | ... |