Commit 93733b790109f861511daad65de37b64d93772f1
1 parent
03fe9a28
More verbose output in training
Also address an issue with retraining algorithms, using pre-trained submodules
Showing
1 changed file
with
18 additions
and
12 deletions
openbr/plugins/meta.cpp
| ... | ... | @@ -96,17 +96,15 @@ class PipeTransform : public CompositeTransform |
| 96 | 96 | |
| 97 | 97 | int i = 0; |
| 98 | 98 | while (i < transforms.size()) { |
| 99 | - fprintf(stderr, "\n%s", qPrintable(transforms[i]->objectName())); | |
| 100 | - | |
| 101 | 99 | // Conditional statement covers likely case that first transform is untrainable |
| 102 | 100 | if (transforms[i]->trainable) { |
| 103 | - fprintf(stderr, " training..."); | |
| 101 | + qDebug() << "Training " << transforms[i]->description() << "\n..."; | |
| 104 | 102 | transforms[i]->train(dataLines); |
| 105 | 103 | } |
| 106 | 104 | |
| 107 | 105 | // if the transform is time varying, we can't project it in parallel |
| 108 | 106 | if (transforms[i]->timeVarying()) { |
| 109 | - fprintf(stderr, "\n%s projecting...", qPrintable(transforms[i]->objectName())); | |
| 107 | + qDebug() << "Projecting " << transforms[i]->description() << "\n..."; | |
| 110 | 108 | for (int j=0; j < dataLines.size();j++) { |
| 111 | 109 | TemplateList junk; |
| 112 | 110 | splitFTEs(dataLines[j], junk); |
| ... | ... | @@ -132,7 +130,16 @@ class PipeTransform : public CompositeTransform |
| 132 | 130 | !transforms[nextTrainableTransform]->timeVarying()) |
| 133 | 131 | nextTrainableTransform++; |
| 134 | 132 | |
| 135 | - fprintf(stderr, " projecting..."); | |
| 133 | + // No more trainable transforms? Don't need any more projects then | |
| 134 | + if (nextTrainableTransform == transforms.size()) | |
| 135 | + break; | |
| 136 | + | |
| 137 | + fprintf(stderr, "Projecting %s", qPrintable(transforms[i]->description())); | |
| 138 | + for (int j=i+1; j < nextTrainableTransform; j++) | |
| 139 | + fprintf(stderr,"+%s", qPrintable(transforms[j]->description())); | |
| 140 | + fprintf(stderr, "\n...\n"); | |
| 141 | + fflush(stderr); | |
| 142 | + | |
| 136 | 143 | QFutureSynchronizer<void> futures; |
| 137 | 144 | for (int j=0; j < dataLines.size(); j++) |
| 138 | 145 | futures.addFuture(QtConcurrent::run(this, &PipeTransform::_projectPartial, &dataLines[j], i, nextTrainableTransform)); |
| ... | ... | @@ -512,7 +519,6 @@ class LoadStoreTransform : public MetaTransform |
| 512 | 519 | |
| 513 | 520 | public: |
| 514 | 521 | Transform *transform; |
| 515 | - QString baseName; | |
| 516 | 522 | |
| 517 | 523 | LoadStoreTransform() : transform(NULL) {} |
| 518 | 524 | |
| ... | ... | @@ -542,8 +548,8 @@ private: |
| 542 | 548 | void init() |
| 543 | 549 | { |
| 544 | 550 | if (transform != NULL) return; |
| 545 | - if (fileName.isEmpty()) baseName = QRegExp("^[_a-zA-Z0-9]+$").exactMatch(transformString) ? transformString : QtUtils::shortTextHash(transformString); | |
| 546 | - else baseName = fileName; | |
| 551 | + if (fileName.isEmpty()) fileName = QRegExp("^[_a-zA-Z0-9]+$").exactMatch(transformString) ? transformString : QtUtils::shortTextHash(transformString); | |
| 552 | + | |
| 547 | 553 | if (!tryLoad()) |
| 548 | 554 | transform = make(transformString); |
| 549 | 555 | else |
| ... | ... | @@ -562,9 +568,9 @@ private: |
| 562 | 568 | |
| 563 | 569 | transform->train(data); |
| 564 | 570 | |
| 565 | - qDebug("Storing %s", qPrintable(baseName)); | |
| 571 | + qDebug("Storing %s", qPrintable(fileName)); | |
| 566 | 572 | QtUtils::BlockCompression compressedOut; |
| 567 | - QFile fout(baseName); | |
| 573 | + QFile fout(fileName); | |
| 568 | 574 | QtUtils::touchDir(fout); |
| 569 | 575 | compressedOut.setBasis(&fout); |
| 570 | 576 | |
| ... | ... | @@ -606,8 +612,8 @@ private: |
| 606 | 612 | |
| 607 | 613 | QString getFileName() const |
| 608 | 614 | { |
| 609 | - if (QFileInfo(baseName).exists()) return baseName; | |
| 610 | - const QString file = Globals->sdkPath + "/share/openbr/models/transforms/" + baseName; | |
| 615 | + if (QFileInfo(fileName).exists()) return fileName; | |
| 616 | + const QString file = Globals->sdkPath + "/share/openbr/models/transforms/" + fileName; | |
| 611 | 617 | return QFileInfo(file).exists() ? file : QString(); |
| 612 | 618 | } |
| 613 | 619 | ... | ... |