Commit 4887d291caac8925da1d7adc946ab7c4a9abf605
1 parent
41805575
Add some warnings if train gets called when it will do nothing.
Showing
3 changed files
with
9 additions
and
4 deletions
openbr/plugins/meta.cpp
| ... | ... | @@ -614,6 +614,11 @@ public: |
| 614 | 614 | |
| 615 | 615 | void train(const TemplateList &data) |
| 616 | 616 | { |
| 617 | + if (!transform->trainable) { | |
| 618 | + qWarning("Attempted to train untrainable transform, nothing will happen."); | |
| 619 | + return; | |
| 620 | + } | |
| 621 | + | |
| 617 | 622 | transform->train(data); |
| 618 | 623 | } |
| 619 | 624 | |
| ... | ... | @@ -628,7 +633,6 @@ public: |
| 628 | 633 | else dst = output[0]; |
| 629 | 634 | } |
| 630 | 635 | |
| 631 | - | |
| 632 | 636 | // For each input template, form a single element TemplateList, push all those |
| 633 | 637 | // lists through transform, and form dst by concatenating the results. |
| 634 | 638 | // Process the single elemnt templates in parallel if parallelism is enabled. |
| ... | ... | @@ -677,7 +681,6 @@ public: |
| 677 | 681 | |
| 678 | 682 | void init() |
| 679 | 683 | { |
| 680 | - | |
| 681 | 684 | if (transform && transform->timeVarying()) |
| 682 | 685 | transform = new br::TimeInvariantWrapperTransform(transform); |
| 683 | 686 | } | ... | ... |
openbr/plugins/openbr_internal.h
| ... | ... | @@ -122,7 +122,10 @@ public: |
| 122 | 122 | |
| 123 | 123 | TimeInvariantWrapperTransform(Transform * basis) : transformSource(new TransformCopier(basis)) |
| 124 | 124 | { |
| 125 | + if (!basis) | |
| 126 | + qFatal("TimeInvariantWrapper created with NULL transform"); | |
| 125 | 127 | baseTransform = basis; |
| 128 | + trainable = basis->trainable; | |
| 126 | 129 | } |
| 127 | 130 | |
| 128 | 131 | virtual void project(const Template &src, Template &dst) const |
| ... | ... | @@ -132,7 +135,6 @@ public: |
| 132 | 135 | transformSource.release(aTransform); |
| 133 | 136 | } |
| 134 | 137 | |
| 135 | - | |
| 136 | 138 | void project(const TemplateList &src, TemplateList &dst) const |
| 137 | 139 | { |
| 138 | 140 | Transform * aTransform = transformSource.acquire(); | ... | ... |
openbr/plugins/stream.cpp
| ... | ... | @@ -1025,7 +1025,7 @@ public: |
| 1025 | 1025 | void train(const TemplateList & data) |
| 1026 | 1026 | { |
| 1027 | 1027 | if (!trainable) { |
| 1028 | - qWarning("How did this happen? You're training a nontrainable transform."); | |
| 1028 | + qWarning("Attempted to train untrainable transform, nothing will happen."); | |
| 1029 | 1029 | return; |
| 1030 | 1030 | } |
| 1031 | 1031 | qFatal("Stream train is currently not implemented."); | ... | ... |