Commit 6a1f4fa54aa2600e502322989e244706b8a0a487
1 parent
fa3fab2c
Make Pipes behave consistently between training and enrollment
When training transforms involving pipes, and projecting from one stage to the next, break the training data into single item templatelists (similarly to what is typically done by Distribute transforms durign training). This allows e.g. ExpandTransform to work as expected.
Showing
1 changed file
with
16 additions
and
3 deletions
openbr/plugins/meta.cpp
| @@ -76,7 +76,7 @@ class PipeTransform : public CompositeTransform | @@ -76,7 +76,7 @@ class PipeTransform : public CompositeTransform | ||
| 76 | { | 76 | { |
| 77 | Q_OBJECT | 77 | Q_OBJECT |
| 78 | 78 | ||
| 79 | - void _projectPartial(Template *srcdst, int startIndex, int stopIndex) | 79 | + void _projectPartial(TemplateList *srcdst, int startIndex, int stopIndex) |
| 80 | { | 80 | { |
| 81 | for (int i=startIndex; i<stopIndex; i++) | 81 | for (int i=startIndex; i<stopIndex; i++) |
| 82 | *srcdst >> *transforms[i]; | 82 | *srcdst >> *transforms[i]; |
| @@ -87,6 +87,14 @@ class PipeTransform : public CompositeTransform | @@ -87,6 +87,14 @@ class PipeTransform : public CompositeTransform | ||
| 87 | if (!trainable) return; | 87 | if (!trainable) return; |
| 88 | 88 | ||
| 89 | TemplateList copy(data); | 89 | TemplateList copy(data); |
| 90 | + QList<TemplateList> singleItemLists; | ||
| 91 | + for (int i=0; i < copy.size(); i++) | ||
| 92 | + { | ||
| 93 | + TemplateList temp; | ||
| 94 | + temp.append(copy[i]); | ||
| 95 | + singleItemLists.append(temp); | ||
| 96 | + } | ||
| 97 | + | ||
| 90 | int i = 0; | 98 | int i = 0; |
| 91 | while (i < transforms.size()) { | 99 | while (i < transforms.size()) { |
| 92 | fprintf(stderr, "\n%s", qPrintable(transforms[i]->objectName())); | 100 | fprintf(stderr, "\n%s", qPrintable(transforms[i]->objectName())); |
| @@ -109,9 +117,14 @@ class PipeTransform : public CompositeTransform | @@ -109,9 +117,14 @@ class PipeTransform : public CompositeTransform | ||
| 109 | 117 | ||
| 110 | fprintf(stderr, " projecting..."); | 118 | fprintf(stderr, " projecting..."); |
| 111 | QFutureSynchronizer<void> futures; | 119 | QFutureSynchronizer<void> futures; |
| 112 | - for (int j=0; j<copy.size(); j++) | ||
| 113 | - futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, ©[j], i, nextTrainableTransform)); | 120 | + for (int j=0; j < singleItemLists.size(); j++) |
| 121 | + futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, &singleItemLists[j], i, nextTrainableTransform)); | ||
| 114 | futures.waitForFinished(); | 122 | futures.waitForFinished(); |
| 123 | + | ||
| 124 | + copy.clear(); | ||
| 125 | + for (int j=0; j < singleItemLists.size(); j++) | ||
| 126 | + copy.append(singleItemLists[j]); | ||
| 127 | + | ||
| 115 | i = nextTrainableTransform; | 128 | i = nextTrainableTransform; |
| 116 | } | 129 | } |
| 117 | } | 130 | } |