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 | 80 | bool should_end; |
| 81 | 81 | TemplateList data; |
| 82 | 82 | |
| 83 | + QHash<QString, int> observedLabels; | |
| 84 | + | |
| 83 | 85 | static void commitLoop(lmdbGallery * base) |
| 84 | 86 | { |
| 85 | 87 | QSharedPointer<caffe::db::Transaction> txn; |
| ... | ... | @@ -111,7 +113,15 @@ class lmdbGallery : public Gallery |
| 111 | 113 | // add current image to transaction |
| 112 | 114 | caffe::Datum datum; |
| 113 | 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 | 126 | std::string out; |
| 117 | 127 | datum.SerializeToString(&out); |
| ... | ... | @@ -133,6 +143,7 @@ class lmdbGallery : public Gallery |
| 133 | 143 | if (!initialized) { |
| 134 | 144 | db = QSharedPointer<caffe::db::DB> (caffe::db::GetDB("lmdb")); |
| 135 | 145 | db->Open(file.name.toStdString(), caffe::db::NEW); |
| 146 | + observedLabels.clear() | |
| 136 | 147 | initialized = true; |
| 137 | 148 | should_end = false; |
| 138 | 149 | // fire thread | ... | ... |