Commit 05f1045c219a118b3b5a7111d896496f955510d6

Authored by Scott Klum
1 parent 5b392f42

Cross validation bug fix

openbr/core/bee.cpp
@@ -278,6 +278,8 @@ cv::Mat BEE::makeMask(const br::FileList &targets, const br::FileList &queries, @@ -278,6 +278,8 @@ cv::Mat BEE::makeMask(const br::FileList &targets, const br::FileList &queries,
278 } 278 }
279 } 279 }
280 280
  281 + qDebug() << targetLabels;
  282 +
281 return mask; 283 return mask;
282 } 284 }
283 285
openbr/openbr_plugin.cpp
@@ -134,7 +134,7 @@ void File::set(const QString &amp;key, const QVariant &amp;value) @@ -134,7 +134,7 @@ void File::set(const QString &amp;key, const QVariant &amp;value)
134 then it was probably intended to be a string UID 134 then it was probably intended to be a string UID
135 and that it's numerical value is not relevant. */ 135 and that it's numerical value is not relevant. */
136 if (value.canConvert(QVariant::Double) && 136 if (value.canConvert(QVariant::Double) &&
137 - (!valueString.startsWith('0') || (valueString == "0"))) 137 + (!valueString.startsWith('0') || (valueString == "0")))
138 value.toFloat(&ok); 138 value.toFloat(&ok);
139 139
140 if (!ok && !Globals->classes.contains(valueString)) 140 if (!ok && !Globals->classes.contains(valueString))
@@ -427,16 +427,19 @@ TemplateList TemplateList::fromGallery(const br::File &amp;gallery) @@ -427,16 +427,19 @@ TemplateList TemplateList::fromGallery(const br::File &amp;gallery)
427 newTemplates[i].file.append(gallery.localMetadata()); 427 newTemplates[i].file.append(gallery.localMetadata());
428 newTemplates[i].file.append(file.localMetadata()); 428 newTemplates[i].file.append(file.localMetadata());
429 newTemplates[i].file.set("Index", i+templates.size()); 429 newTemplates[i].file.set("Index", i+templates.size());
430 - if (newTemplates[i].file.getBool("allPartitions") && crossValidate > 0) {  
431 - // Set template to the first parition  
432 - newTemplates[i].file.set("Cross_Validation_Partition", QVariant(0));  
433 - for (int j=crossValidate-1; j>=1; j--) {  
434 - Template allPartitionTemplate = newTemplates[i];  
435 - allPartitionTemplate.file.set("Cross_Validation_Partition", j);  
436 - allPartitionTemplate.file.set("Label", i+templates.size());  
437 - // Insert templates for all the other partitions  
438 - newTemplates.insert(i+1, allPartitionTemplate); 430 + if (newTemplates[i].file.getBool("allPartitions")) {
  431 + if (crossValidate > 0) {
  432 + // Set template to the first parition
  433 + newTemplates[i].file.set("Cross_Validation_Partition", QVariant(0));
  434 + for (int j=crossValidate-1; j>=1; j--) {
  435 + Template allPartitionTemplate = newTemplates[i];
  436 + allPartitionTemplate.file.set("Cross_Validation_Partition", j);
  437 + allPartitionTemplate.file.set("Label", i+templates.size());
  438 + // Insert templates for all the other partitions
  439 + newTemplates.insert(i+1, allPartitionTemplate);
  440 + }
439 } 441 }
  442 + else newTemplates[i].file.set("Label", i+templates.size());
440 } 443 }
441 else if (crossValidate > 0) newTemplates[i].file.set("Cross_Validation_Partition", rand()%crossValidate); 444 else if (crossValidate > 0) newTemplates[i].file.set("Cross_Validation_Partition", rand()%crossValidate);
442 } 445 }
@@ -675,7 +678,7 @@ void Object::setProperty(const QString &amp;name, const QString &amp;value) @@ -675,7 +678,7 @@ void Object::setProperty(const QString &amp;name, const QString &amp;value)
675 678
676 if (!QObject::setProperty(qPrintable(name), variant) && !type.isEmpty()) 679 if (!QObject::setProperty(qPrintable(name), variant) && !type.isEmpty())
677 qFatal("Failed to set %s::%s to: %s %s", 680 qFatal("Failed to set %s::%s to: %s %s",
678 - metaObject()->className(), qPrintable(name), qPrintable(value), qPrintable(type)); 681 + metaObject()->className(), qPrintable(name), qPrintable(value), qPrintable(type));
679 } 682 }
680 683
681 QStringList br::Object::parse(const QString &string, char split) 684 QStringList br::Object::parse(const QString &string, char split)
@@ -924,17 +927,17 @@ void br::Context::messageHandler(QtMsgType type, const QMessageLogContext &amp;conte @@ -924,17 +927,17 @@ void br::Context::messageHandler(QtMsgType type, const QMessageLogContext &amp;conte
924 927
925 QString txt; 928 QString txt;
926 switch (type) { 929 switch (type) {
927 - case QtDebugMsg: 930 + case QtDebugMsg:
928 if (Globals->quiet) return; 931 if (Globals->quiet) return;
929 txt = QString("%1\n").arg(msg); 932 txt = QString("%1\n").arg(msg);
930 break; 933 break;
931 - case QtWarningMsg: 934 + case QtWarningMsg:
932 txt = QString("Warning: %1\n").arg(msg); 935 txt = QString("Warning: %1\n").arg(msg);
933 break; 936 break;
934 - case QtCriticalMsg: 937 + case QtCriticalMsg:
935 txt = QString("Critical: %1\n").arg(msg); 938 txt = QString("Critical: %1\n").arg(msg);
936 break; 939 break;
937 - case QtFatalMsg: 940 + case QtFatalMsg:
938 txt = QString("Fatal: %1\n").arg(msg); 941 txt = QString("Fatal: %1\n").arg(msg);
939 break; 942 break;
940 } 943 }
@@ -1074,8 +1077,8 @@ static TemplateList Downsample(const TemplateList &amp;templates, const Transform *t @@ -1074,8 +1077,8 @@ static TemplateList Downsample(const TemplateList &amp;templates, const Transform *t
1074 { 1077 {
1075 // Return early when no downsampling is required 1078 // Return early when no downsampling is required
1076 if ((transform->classes == std::numeric_limits<int>::max()) && 1079 if ((transform->classes == std::numeric_limits<int>::max()) &&
1077 - (transform->instances == std::numeric_limits<int>::max()) &&  
1078 - (transform->fraction >= 1)) 1080 + (transform->instances == std::numeric_limits<int>::max()) &&
  1081 + (transform->fraction >= 1))
1079 return templates; 1082 return templates;
1080 1083
1081 const bool atLeast = transform->instances < 0; 1084 const bool atLeast = transform->instances < 0;
@@ -1134,12 +1137,12 @@ class Independent : public MetaTransform @@ -1134,12 +1137,12 @@ class Independent : public MetaTransform
1134 Q_PROPERTY(QList<Transform*> transforms READ get_transforms WRITE set_transforms STORED false) 1137 Q_PROPERTY(QList<Transform*> transforms READ get_transforms WRITE set_transforms STORED false)
1135 BR_PROPERTY(QList<Transform*>, transforms, QList<Transform*>()) 1138 BR_PROPERTY(QList<Transform*>, transforms, QList<Transform*>())
1136 1139
1137 -public:  
1138 - /*!  
1139 - * \brief Independent  
1140 - * \param transform  
1141 - */  
1142 - Independent(Transform *transform) 1140 + public:
  1141 + /*!
  1142 + * \brief Independent
  1143 + * \param transform
  1144 + */
  1145 + Independent(Transform *transform)
1143 { 1146 {
1144 transform->setParent(this); 1147 transform->setParent(this);
1145 transforms.append(transform); 1148 transforms.append(transform);