Commit 1554801730aa0b590b124d29ae4b6f822535492a
1 parent
38bc1dcb
Added DownsampleMetadata
Showing
2 changed files
with
41 additions
and
5 deletions
openbr/core/eval.cpp
| @@ -993,12 +993,14 @@ void EvalRegression(const QString &predictedGallery, const QString &truthGallery | @@ -993,12 +993,14 @@ void EvalRegression(const QString &predictedGallery, const QString &truthGallery | ||
| 993 | if (predicted[i].file.name != truth[i].file.name) | 993 | if (predicted[i].file.name != truth[i].file.name) |
| 994 | qFatal("Input order mismatch."); | 994 | qFatal("Input order mismatch."); |
| 995 | 995 | ||
| 996 | - float difference = predicted[i].file.get<float>(predictedProperty) - truth[i].file.get<float>(truthProperty); | 996 | + if (predicted[i].file.contains(predictedProperty) && truth[i].file.contains(truthProperty)) { |
| 997 | + float difference = predicted[i].file.get<float>(predictedProperty) - truth[i].file.get<float>(truthProperty); | ||
| 997 | 998 | ||
| 998 | - rmsError += pow(difference, 2.f); | ||
| 999 | - maeError += fabsf(difference); | ||
| 1000 | - truthValues.append(QString::number(truth[i].file.get<float>(truthProperty))); | ||
| 1001 | - predictedValues.append(QString::number(predicted[i].file.get<float>(predictedProperty))); | 999 | + rmsError += pow(difference, 2.f); |
| 1000 | + maeError += fabsf(difference); | ||
| 1001 | + truthValues.append(QString::number(truth[i].file.get<float>(truthProperty))); | ||
| 1002 | + predictedValues.append(QString::number(predicted[i].file.get<float>(predictedProperty))); | ||
| 1003 | + } | ||
| 1002 | } | 1004 | } |
| 1003 | 1005 | ||
| 1004 | QStringList rSource; | 1006 | QStringList rSource; |
openbr/plugins/independent.cpp
| @@ -118,6 +118,40 @@ class DownsampleTrainingTransform : public Transform | @@ -118,6 +118,40 @@ class DownsampleTrainingTransform : public Transform | ||
| 118 | }; | 118 | }; |
| 119 | BR_REGISTER(Transform, DownsampleTrainingTransform) | 119 | BR_REGISTER(Transform, DownsampleTrainingTransform) |
| 120 | 120 | ||
| 121 | +class DownsampleMetadataTransform : public Transform | ||
| 122 | +{ | ||
| 123 | + Q_OBJECT | ||
| 124 | + Q_PROPERTY(br::Transform* transform READ get_transform WRITE set_transform RESET reset_transform STORED true) | ||
| 125 | + Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false) | ||
| 126 | + BR_PROPERTY(br::Transform*, transform, NULL) | ||
| 127 | + BR_PROPERTY(QString, inputVariable, "Label") | ||
| 128 | + | ||
| 129 | + Transform *simplify(bool &newTForm) | ||
| 130 | + { | ||
| 131 | + Transform *res = transform->simplify(newTForm); | ||
| 132 | + return res; | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + void project(const Template &src, Template &dst) const | ||
| 136 | + { | ||
| 137 | + transform->project(src,dst); | ||
| 138 | + } | ||
| 139 | + | ||
| 140 | + void train(const TemplateList &data) | ||
| 141 | + { | ||
| 142 | + if (!transform || !transform->trainable) | ||
| 143 | + return; | ||
| 144 | + | ||
| 145 | + TemplateList downsampled = data; | ||
| 146 | + for (int i=downsampled.size()-1; i>=0; i--) | ||
| 147 | + if (!downsampled[i].file.contains(inputVariable)) | ||
| 148 | + downsampled.removeAt(i); | ||
| 149 | + | ||
| 150 | + transform->train(downsampled); | ||
| 151 | + } | ||
| 152 | +}; | ||
| 153 | +BR_REGISTER(Transform, DownsampleMetadataTransform) | ||
| 154 | + | ||
| 121 | /*! | 155 | /*! |
| 122 | * \ingroup transforms | 156 | * \ingroup transforms |
| 123 | * \brief Clones the transform so that it can be applied independently. | 157 | * \brief Clones the transform so that it can be applied independently. |