From 968f94f3ae6c8be351e1fdc6e2887d991ef7772f Mon Sep 17 00:00:00 2001 From: Josh Klontz Date: Wed, 20 Mar 2013 22:32:49 -0400 Subject: [PATCH] tweaks to meta transforms to skip training when possible --- openbr/openbr_plugin.h | 7 +++---- openbr/plugins/meta.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 669965a..2f6dd80 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -1213,11 +1213,10 @@ public: void init() { isTimeVarying = false; + trainable = false; foreach (const br::Transform *transform, transforms) { - if (transform->timeVarying()) { - isTimeVarying = true; - break; - } + isTimeVarying = isTimeVarying || transform->timeVarying(); + trainable = trainable || transform->trainable; } } diff --git a/openbr/plugins/meta.cpp b/openbr/plugins/meta.cpp index 26771a4..805d179 100644 --- a/openbr/plugins/meta.cpp +++ b/openbr/plugins/meta.cpp @@ -73,7 +73,7 @@ static void _train(Transform *transform, const TemplateList *data) */ class PipeTransform : public CompositeTransform { - Q_OBJECT + Q_OBJECT void _projectPartial(Template *srcdst, int startIndex, int stopIndex) { @@ -83,6 +83,8 @@ class PipeTransform : public CompositeTransform void train(const TemplateList &data) { + if (!trainable) return; + TemplateList copy(data); int i = 0; while (i < transforms.size()) { @@ -285,6 +287,7 @@ class ForkTransform : public CompositeTransform void train(const TemplateList &data) { + if (!trainable) return; QFutureSynchronizer futures; for (int i=0; iparallelism) futures.addFuture(QtConcurrent::run(_train, transforms[i], &data)); @@ -415,6 +418,7 @@ public: private: void init() { + trainable = transform->trainable; if (!cache.isEmpty()) return; // Read from cache @@ -476,6 +480,7 @@ private: if (transform != NULL) return; baseName = QRegExp("^[a-zA-Z0-9]+$").exactMatch(description) ? description : QtUtils::shortTextHash(description); if (!tryLoad()) transform = make(description); + else trainable = false; } void train(const TemplateList &data) -- libgit2 0.21.4