Commit e9f1e88d3690957994c53c3d4ac44ea4c5ff6f52

Authored by jklontz
2 parents 7d2c5ba7 2b6b533a

Merge pull request #46 from biometrics/label_subject_things

Address some issues with classification and regression
openbr/core/classify.cpp
@@ -45,8 +45,12 @@ void br::EvalClassification(const QString &predictedInput, const QString &truthI @@ -45,8 +45,12 @@ void br::EvalClassification(const QString &predictedInput, const QString &truthI
45 qFatal("Input order mismatch."); 45 qFatal("Input order mismatch.");
46 46
47 // Typically these lists will be of length one, but this generalization allows measuring multi-class labeling accuracy. 47 // Typically these lists will be of length one, but this generalization allows measuring multi-class labeling accuracy.
48 - QStringList predictedSubjects = predicted[i].file.get<QStringList>("Subject");  
49 - QStringList trueSubjects = truth[i].file.get<QStringList>("Subject"); 48 + QString predictedSubject = predicted[i].file.subject();
  49 + QString trueSubject = truth[i].file.subject();
  50 +
  51 + QStringList predictedSubjects(predictedSubject);
  52 + QStringList trueSubjects(trueSubject);
  53 +
50 foreach (const QString &subject, trueSubjects.toVector() /* Hack to copy the list. */) { 54 foreach (const QString &subject, trueSubjects.toVector() /* Hack to copy the list. */) {
51 if (predictedSubjects.contains(subject)) { 55 if (predictedSubjects.contains(subject)) {
52 counters[subject].truePositive++; 56 counters[subject].truePositive++;
openbr/openbr_plugin.cpp
@@ -183,6 +183,11 @@ float File::label() const @@ -183,6 +183,11 @@ float File::label() const
183 if (s.isNull()) return -1; 183 if (s.isNull()) return -1;
184 184
185 const QString subject = s.toString(); 185 const QString subject = s.toString();
  186 +
  187 + bool is_num = false;
  188 + float num = subject.toFloat(&is_num);
  189 + if (is_num) return num;
  190 +
186 static QMutex mutex; 191 static QMutex mutex;
187 QMutexLocker mutexLocker(&mutex); 192 QMutexLocker mutexLocker(&mutex);
188 if (!Globals->subjects.contains(subject)) 193 if (!Globals->subjects.contains(subject))
openbr/plugins/meta.cpp
@@ -76,7 +76,7 @@ class PipeTransform : public CompositeTransform @@ -76,7 +76,7 @@ class PipeTransform : public CompositeTransform
76 { 76 {
77 Q_OBJECT 77 Q_OBJECT
78 78
79 - void _projectPartial(Template *srcdst, int startIndex, int stopIndex) 79 + void _projectPartial(TemplateList *srcdst, int startIndex, int stopIndex)
80 { 80 {
81 for (int i=startIndex; i<stopIndex; i++) 81 for (int i=startIndex; i<stopIndex; i++)
82 *srcdst >> *transforms[i]; 82 *srcdst >> *transforms[i];
@@ -87,6 +87,14 @@ class PipeTransform : public CompositeTransform @@ -87,6 +87,14 @@ class PipeTransform : public CompositeTransform
87 if (!trainable) return; 87 if (!trainable) return;
88 88
89 TemplateList copy(data); 89 TemplateList copy(data);
  90 + QList<TemplateList> singleItemLists;
  91 + for (int i=0; i < copy.size(); i++)
  92 + {
  93 + TemplateList temp;
  94 + temp.append(copy[i]);
  95 + singleItemLists.append(temp);
  96 + }
  97 +
90 int i = 0; 98 int i = 0;
91 while (i < transforms.size()) { 99 while (i < transforms.size()) {
92 fprintf(stderr, "\n%s", qPrintable(transforms[i]->objectName())); 100 fprintf(stderr, "\n%s", qPrintable(transforms[i]->objectName()));
@@ -109,9 +117,14 @@ class PipeTransform : public CompositeTransform @@ -109,9 +117,14 @@ class PipeTransform : public CompositeTransform
109 117
110 fprintf(stderr, " projecting..."); 118 fprintf(stderr, " projecting...");
111 QFutureSynchronizer<void> futures; 119 QFutureSynchronizer<void> futures;
112 - for (int j=0; j<copy.size(); j++)  
113 - futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, &copy[j], i, nextTrainableTransform)); 120 + for (int j=0; j < singleItemLists.size(); j++)
  121 + futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, &singleItemLists[j], i, nextTrainableTransform));
114 futures.waitForFinished(); 122 futures.waitForFinished();
  123 +
  124 + copy.clear();
  125 + for (int j=0; j < singleItemLists.size(); j++)
  126 + copy.append(singleItemLists[j]);
  127 +
115 i = nextTrainableTransform; 128 i = nextTrainableTransform;
116 } 129 }
117 } 130 }
1 -Subproject commit c11ff0f0bb451fb5576bd4b8122c32278e52042a 1 +Subproject commit 1394fbec42897c1a53373443c32a6f62a010294f