Commit a13d2a987bf3e6895a7496d619e69b8a07e979a5
1 parent
18e65e13
Revert change to lmdb
Showing
1 changed file
with
12 additions
and
1 deletions
openbr/plugins/gallery/lmdb.cpp
| @@ -80,6 +80,8 @@ class lmdbGallery : public Gallery | @@ -80,6 +80,8 @@ class lmdbGallery : public Gallery | ||
| 80 | bool should_end; | 80 | bool should_end; |
| 81 | TemplateList data; | 81 | TemplateList data; |
| 82 | 82 | ||
| 83 | + QHash<QString, int> observedLabels; | ||
| 84 | + | ||
| 83 | static void commitLoop(lmdbGallery * base) | 85 | static void commitLoop(lmdbGallery * base) |
| 84 | { | 86 | { |
| 85 | QSharedPointer<caffe::db::Transaction> txn; | 87 | QSharedPointer<caffe::db::Transaction> txn; |
| @@ -111,7 +113,15 @@ class lmdbGallery : public Gallery | @@ -111,7 +113,15 @@ class lmdbGallery : public Gallery | ||
| 111 | // add current image to transaction | 113 | // add current image to transaction |
| 112 | caffe::Datum datum; | 114 | caffe::Datum datum; |
| 113 | caffe::CVMatToDatum(t.m(), &datum); | 115 | caffe::CVMatToDatum(t.m(), &datum); |
| 114 | - datum.set_label(t.file.get<int>("Label")); | 116 | + |
| 117 | + QVariant base_label = t.file.value("Label"); | ||
| 118 | + QString label_str = base_label.toString(); | ||
| 119 | + | ||
| 120 | + | ||
| 121 | + if (!base->observedLabels.contains(label_str) ) | ||
| 122 | + base->observedLabels[label_str] = base->observedLabels.size(); | ||
| 123 | + | ||
| 124 | + datum.set_label(base->observedLabels[label_str]); | ||
| 115 | 125 | ||
| 116 | std::string out; | 126 | std::string out; |
| 117 | datum.SerializeToString(&out); | 127 | datum.SerializeToString(&out); |
| @@ -133,6 +143,7 @@ class lmdbGallery : public Gallery | @@ -133,6 +143,7 @@ class lmdbGallery : public Gallery | ||
| 133 | if (!initialized) { | 143 | if (!initialized) { |
| 134 | db = QSharedPointer<caffe::db::DB> (caffe::db::GetDB("lmdb")); | 144 | db = QSharedPointer<caffe::db::DB> (caffe::db::GetDB("lmdb")); |
| 135 | db->Open(file.name.toStdString(), caffe::db::NEW); | 145 | db->Open(file.name.toStdString(), caffe::db::NEW); |
| 146 | + observedLabels.clear() | ||
| 136 | initialized = true; | 147 | initialized = true; |
| 137 | should_end = false; | 148 | should_end = false; |
| 138 | // fire thread | 149 | // fire thread |