diff --git a/openbr/plugins/svm.cpp b/openbr/plugins/svm.cpp index 826541c..97156ca 100644 --- a/openbr/plugins/svm.cpp +++ b/openbr/plugins/svm.cpp @@ -136,12 +136,12 @@ private: Mat data = OpenCVUtils::toMat(_data.data()); Mat lab; // If we are doing regression, the input variable should have float - // values + // values if (type == EPS_SVR || type == NU_SVR) { lab = OpenCVUtils::toMat(File::get(_data, inputVariable)); } // If we are doing classification, we should be dealing with discrete - // values. Map them and store the mapping data + // values. Map them and store the mapping data else { QList dataLabels = _data.indexProperty(inputVariable, labelMap, reverseLookup); lab = OpenCVUtils::toMat(dataLabels); diff --git a/openbr/plugins/template.cpp b/openbr/plugins/template.cpp index acfde7b..9dd7736 100644 --- a/openbr/plugins/template.cpp +++ b/openbr/plugins/template.cpp @@ -42,8 +42,8 @@ class RemoveTemplatesTransform : public UntrainableMetaTransform void project(const Template &src, Template &dst) const { const QRegularExpression re(regexp); - const QRegularExpressionMatch match = re.match(key.isEmpty() ? src.file.suffix() : src.file.get(key)); - if (match.hasMatch()) dst = Template(); + const QRegularExpressionMatch match = re.match(key.isEmpty() ? src.file.baseName() : src.file.get(key)); + if (!match.hasMatch()) dst = Template(); else dst = src; } }; @@ -95,19 +95,34 @@ BR_REGISTER(Transform, SelectPointsTransform) /*! * \ingroup transforms - * \brief Does nothing. + * \brief Converts Amazon MTurk labels + * \author Scott Klum \cite sklum */ -class NoneTransform : public UntrainableMetaTransform +class MTurkTransform : public UntrainableTransform { Q_OBJECT + Q_PROPERTY(QString inputVariable READ get_inputVariable WRITE set_inputVariable RESET reset_inputVariable STORED false) + Q_PROPERTY(float maxVotes READ get_maxVotes WRITE set_maxVotes RESET reset_maxVotes STORED false) + BR_PROPERTY(QString, inputVariable, QString()) + BR_PROPERTY(float, maxVotes, 1.) void project(const Template &src, Template &dst) const { dst = src; + + QMap map = dst.file.get >(inputVariable); + + bool ok; + + QMapIterator i(map); + while (i.hasNext()) { + i.next(); + dst.file.set(i.key(), i.value().toFloat(&ok)/maxVotes); + } } }; -BR_REGISTER(Transform, NoneTransform) +BR_REGISTER(Transform, MTurkTransform) } // namespace br