Commit e7c3e62ce5faf29e9dbaa6523d2f8245ff670bab
Merge branch 'master' of https://github.com/biometrics/openbr
Showing
8 changed files
with
77 additions
and
3 deletions
CHANGELOG.md
openbr/core/eval.cpp
| ... | ... | @@ -380,7 +380,7 @@ static QStringList computeDetectionResults(const QList<ResolvedDetection> &detec |
| 380 | 380 | for (int i=0; i<keep; i++) { |
| 381 | 381 | const DetectionOperatingPoint &point = points[double(i) / double(keep-1) * double(points.size()-1)]; |
| 382 | 382 | lines.append(QString("%1ROC, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.FalsePositives), QString::number(point.Recall))); |
| 383 | - lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Precision), QString::number(point.Recall))); | |
| 383 | + lines.append(QString("%1PR, %2, %3").arg(discrete ? "Discrete" : "Continuous", QString::number(point.Recall), QString::number(point.Precision))); | |
| 384 | 384 | } |
| 385 | 385 | return lines; |
| 386 | 386 | } | ... | ... |
openbr/core/plot.cpp
| ... | ... | @@ -238,7 +238,6 @@ bool Plot(const QStringList &files, const File &destination, bool show) |
| 238 | 238 | (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + |
| 239 | 239 | QString(" + scale_x_log10(labels=percent) + scale_y_log10(labels=percent) + annotation_logticks()\n\n"))); |
| 240 | 240 | |
| 241 | - | |
| 242 | 241 | p.file.write(qPrintable(QString("qplot(X, data=SD, geom=\"histogram\", fill=Y, position=\"identity\", alpha=I(1/2)") + |
| 243 | 242 | QString(", xlab=\"Score%1\"").arg((p.flip ? p.major.size : p.minor.size) > 1 ? " / " + (p.flip ? p.major.header : p.minor.header) : QString()) + |
| 244 | 243 | QString(", ylab=\"Frequency%1\"").arg((p.flip ? p.minor.size : p.major.size) > 1 ? " / " + (p.flip ? p.minor.header : p.major.header) : QString()) + |
| ... | ... | @@ -278,6 +277,39 @@ bool PlotDetection(const QStringList &files, const File &destination, bool show) |
| 278 | 277 | |
| 279 | 278 | RPlot p(files, destination, false); |
| 280 | 279 | |
| 280 | + p.file.write("# Split data into individual plots\n" | |
| 281 | + "plot_index = which(names(data)==\"Plot\")\n" | |
| 282 | + "DiscreteROC <- data[grep(\"DiscreteROC\",data$Plot),-c(1)]\n" | |
| 283 | + "ContinuousROC <- data[grep(\"ContinuousROC\",data$Plot),-c(1)]\n" | |
| 284 | + "DiscretePR <- data[grep(\"DiscretePR\",data$Plot),-c(1)]\n" | |
| 285 | + "ContinuousPR <- data[grep(\"ContinuousPR\",data$Plot),-c(1)]\n" | |
| 286 | + "Overlap <- data[grep(\"Overlap\",data$Plot),-c(1)]\n" | |
| 287 | + "rm(data)\n" | |
| 288 | + "\n"); | |
| 289 | + | |
| 290 | + foreach (const QString &type, QStringList() << "Discrete" << "Continuous") | |
| 291 | + p.file.write(qPrintable(QString("qplot(X, Y, data=%1ROC%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") + | |
| 292 | + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | |
| 293 | + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + | |
| 294 | + QString(", xlab=\"False Accepts\", ylab=\"True Accept Rate\") + theme_minimal()") + | |
| 295 | + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 296 | + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | |
| 297 | + QString(" + scale_x_log10() + scale_y_continuous(labels=percent) + annotation_logticks(sides=\"b\") + ggtitle(\"%1\")\n\n").arg(type))); | |
| 298 | + | |
| 299 | + foreach (const QString &type, QStringList() << "Discrete" << "Continuous") | |
| 300 | + p.file.write(qPrintable(QString("qplot(X, Y, data=%1PR%2").arg(type, (p.major.smooth || p.minor.smooth) ? ", geom=\"smooth\", method=loess, level=0.99" : ", geom=\"line\"") + | |
| 301 | + (p.major.size > 1 ? QString(", colour=factor(%1)").arg(p.major.header) : QString()) + | |
| 302 | + (p.minor.size > 1 ? QString(", linetype=factor(%1)").arg(p.minor.header) : QString()) + | |
| 303 | + QString(", xlab=\"Recall\", ylab=\"Precision\") + theme_minimal()") + | |
| 304 | + (p.major.size > 1 ? getScale("colour", p.major.header, p.major.size) : QString()) + | |
| 305 | + (p.minor.size > 1 ? QString(" + scale_linetype_discrete(\"%1\")").arg(p.minor.header) : QString()) + | |
| 306 | + QString(" + scale_x_continuous(labels=percent) + scale_y_continuous(labels=percent) + ggtitle(\"%1\")\n\n").arg(type))); | |
| 307 | + | |
| 308 | + p.file.write(qPrintable(QString("qplot(X, data=Overlap, geom=\"histogram\", position=\"identity\", xlab=\"Overlap\", ylab=\"Frequency\")") + | |
| 309 | + QString(" + theme_minimal() + scale_x_continuous(minor_breaks=NULL) + scale_y_continuous(minor_breaks=NULL) + theme(axis.text.y=element_blank(), axis.ticks=element_blank(), axis.text.x=element_text(angle=-90, hjust=0))") + | |
| 310 | + (p.major.size > 1 ? (p.minor.size > 1 ? QString(" + facet_grid(%2 ~ %1, scales=\"free\")").arg(p.minor.header, p.major.header) : QString(" + facet_wrap(~ %1, scales = \"free\")").arg(p.major.header)) : QString()) + | |
| 311 | + QString(" + theme(aspect.ratio=1)\n\n"))); | |
| 312 | + | |
| 281 | 313 | return p.finalize(show); |
| 282 | 314 | } |
| 283 | 315 | ... | ... |
openbr/openbr.h
| ... | ... | @@ -268,6 +268,18 @@ BR_EXPORT bool br_plot(int num_files, const char *files[], const char *destinati |
| 268 | 268 | |
| 269 | 269 | /*! |
| 270 | 270 | * \brief Renders detection performance figures for a set of <tt>.csv</tt> files created by \ref br_eval_detection. |
| 271 | + * | |
| 272 | + * In order of their output, the figures are: | |
| 273 | + * -# Discrete Receiver Operating Characteristic (DiscreteROC) | |
| 274 | + * -# Continuous Receiver Operating Characteristic (ContinuousROC) | |
| 275 | + * -# Discrete Precision Recall (DiscretePR) | |
| 276 | + * -# Continuous Precision Recall (ContinuousPR) | |
| 277 | + * -# Bounding Box Overlap Histogram (Overlap) | |
| 278 | + * | |
| 279 | + * Detection accuracy is measured with <i>overlap fraction = bounding box intersection / union</i>. | |
| 280 | + * When computing <i>discrete</i> curves, an overlap >= 0.5 is considered a true positive, otherwise it is considered a false negative. | |
| 281 | + * When computing <i>continuous</i> curves, true positives and false negatives are measured fractionally as <i>overlap</i> and <i>1-overlap</i> respectively. | |
| 282 | + * | |
| 271 | 283 | * \see br_plot |
| 272 | 284 | */ |
| 273 | 285 | BR_EXPORT bool br_plot_detection(int num_files, const char *files[], const char *destination, bool show = false); | ... | ... |
openbr/openbr_plugin.cpp
| ... | ... | @@ -1166,7 +1166,8 @@ void Transform::project(const TemplateList &src, TemplateList &dst) const |
| 1166 | 1166 | dst.append(Template()); |
| 1167 | 1167 | QFutureSynchronizer<void> futures; |
| 1168 | 1168 | for (int i=0; i<dst.size(); i++) |
| 1169 | - futures.addFuture(QtConcurrent::run(_project, this, &src[i], &dst[i])); | |
| 1169 | + if (Globals->parallelism > 1) futures.addFuture(QtConcurrent::run(_project, this, &src[i], &dst[i])); | |
| 1170 | + else _project(this, &src[i], &dst[i]); | |
| 1170 | 1171 | futures.waitForFinished(); |
| 1171 | 1172 | } |
| 1172 | 1173 | ... | ... |
openbr/plugins/frames.cpp
openbr/plugins/independent.cpp
| ... | ... | @@ -99,6 +99,8 @@ class IndependentTransform : public MetaTransform |
| 99 | 99 | return independentTransform; |
| 100 | 100 | } |
| 101 | 101 | |
| 102 | + bool timeVarying() const { return transform->timeVarying(); } | |
| 103 | + | |
| 102 | 104 | static void _train(Transform *transform, const TemplateList *data) |
| 103 | 105 | { |
| 104 | 106 | transform->train(*data); |
| ... | ... | @@ -143,6 +145,27 @@ class IndependentTransform : public MetaTransform |
| 143 | 145 | dst.append(mats); |
| 144 | 146 | } |
| 145 | 147 | |
| 148 | + void projectUpdate(const Template &src, Template &dst) | |
| 149 | + { | |
| 150 | + dst.file = src.file; | |
| 151 | + QList<Mat> mats; | |
| 152 | + for (int i=0; i<src.size(); i++) { | |
| 153 | + transforms[i%transforms.size()]->projectUpdate(Template(src.file, src[i]), dst); | |
| 154 | + mats.append(dst); | |
| 155 | + dst.clear(); | |
| 156 | + } | |
| 157 | + dst.append(mats); | |
| 158 | + } | |
| 159 | + | |
| 160 | + void projectUpdate(const TemplateList &src, TemplateList &dst) | |
| 161 | + { | |
| 162 | + dst.reserve(src.size()); | |
| 163 | + foreach (const Template &t, src) { | |
| 164 | + dst.append(Template()); | |
| 165 | + projectUpdate(t, dst.last()); | |
| 166 | + } | |
| 167 | + } | |
| 168 | + | |
| 146 | 169 | void store(QDataStream &stream) const |
| 147 | 170 | { |
| 148 | 171 | const int size = transforms.size(); | ... | ... |
scripts/downloadDatasets.sh