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,6 +614,11 @@ public: | ||
| 614 | 614 | ||
| 615 | void train(const TemplateList &data) | 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 | transform->train(data); | 622 | transform->train(data); |
| 618 | } | 623 | } |
| 619 | 624 | ||
| @@ -628,7 +633,6 @@ public: | @@ -628,7 +633,6 @@ public: | ||
| 628 | else dst = output[0]; | 633 | else dst = output[0]; |
| 629 | } | 634 | } |
| 630 | 635 | ||
| 631 | - | ||
| 632 | // For each input template, form a single element TemplateList, push all those | 636 | // For each input template, form a single element TemplateList, push all those |
| 633 | // lists through transform, and form dst by concatenating the results. | 637 | // lists through transform, and form dst by concatenating the results. |
| 634 | // Process the single elemnt templates in parallel if parallelism is enabled. | 638 | // Process the single elemnt templates in parallel if parallelism is enabled. |
| @@ -677,7 +681,6 @@ public: | @@ -677,7 +681,6 @@ public: | ||
| 677 | 681 | ||
| 678 | void init() | 682 | void init() |
| 679 | { | 683 | { |
| 680 | - | ||
| 681 | if (transform && transform->timeVarying()) | 684 | if (transform && transform->timeVarying()) |
| 682 | transform = new br::TimeInvariantWrapperTransform(transform); | 685 | transform = new br::TimeInvariantWrapperTransform(transform); |
| 683 | } | 686 | } |
openbr/plugins/openbr_internal.h
| @@ -122,7 +122,10 @@ public: | @@ -122,7 +122,10 @@ public: | ||
| 122 | 122 | ||
| 123 | TimeInvariantWrapperTransform(Transform * basis) : transformSource(new TransformCopier(basis)) | 123 | TimeInvariantWrapperTransform(Transform * basis) : transformSource(new TransformCopier(basis)) |
| 124 | { | 124 | { |
| 125 | + if (!basis) | ||
| 126 | + qFatal("TimeInvariantWrapper created with NULL transform"); | ||
| 125 | baseTransform = basis; | 127 | baseTransform = basis; |
| 128 | + trainable = basis->trainable; | ||
| 126 | } | 129 | } |
| 127 | 130 | ||
| 128 | virtual void project(const Template &src, Template &dst) const | 131 | virtual void project(const Template &src, Template &dst) const |
| @@ -132,7 +135,6 @@ public: | @@ -132,7 +135,6 @@ public: | ||
| 132 | transformSource.release(aTransform); | 135 | transformSource.release(aTransform); |
| 133 | } | 136 | } |
| 134 | 137 | ||
| 135 | - | ||
| 136 | void project(const TemplateList &src, TemplateList &dst) const | 138 | void project(const TemplateList &src, TemplateList &dst) const |
| 137 | { | 139 | { |
| 138 | Transform * aTransform = transformSource.acquire(); | 140 | Transform * aTransform = transformSource.acquire(); |
openbr/plugins/stream.cpp
| @@ -1025,7 +1025,7 @@ public: | @@ -1025,7 +1025,7 @@ public: | ||
| 1025 | void train(const TemplateList & data) | 1025 | void train(const TemplateList & data) |
| 1026 | { | 1026 | { |
| 1027 | if (!trainable) { | 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 | return; | 1029 | return; |
| 1030 | } | 1030 | } |
| 1031 | qFatal("Stream train is currently not implemented."); | 1031 | qFatal("Stream train is currently not implemented."); |