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 156f042..f19e4cc 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,7 +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)); @@ -416,6 +418,7 @@ public: private: void init() { + trainable = transform->trainable; if (!cache.isEmpty()) return; // Read from cache @@ -477,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)