Commit e72aac7191227870bf0d47a3b541268adab02472
1 parent
ead85fdf
tweaks
Showing
6 changed files
with
21 additions
and
12 deletions
sdk/core/core.cpp
| @@ -300,7 +300,8 @@ bool br::IsClassifier(const QString &algorithm) | @@ -300,7 +300,8 @@ bool br::IsClassifier(const QString &algorithm) | ||
| 300 | 300 | ||
| 301 | void br::Train(const QString &inputs, const File &model) | 301 | void br::Train(const QString &inputs, const File &model) |
| 302 | { | 302 | { |
| 303 | - qDebug("Training on %s to %s", qPrintable(inputs), qPrintable(model.flat())); | 303 | + qDebug("Training on %s%s", qPrintable(inputs), |
| 304 | + model.isNull() ? "" : qPrintable(" to " + model.flat())); | ||
| 304 | AlgorithmManager::getAlgorithm(model.getString("algorithm"))->train(inputs, model); | 305 | AlgorithmManager::getAlgorithm(model.getString("algorithm"))->train(inputs, model); |
| 305 | } | 306 | } |
| 306 | 307 |
sdk/core/plot.cpp
| @@ -183,8 +183,9 @@ float Evaluate(const QString &simmat, const QString &mask, const QString &csv) | @@ -183,8 +183,9 @@ float Evaluate(const QString &simmat, const QString &mask, const QString &csv) | ||
| 183 | } | 183 | } |
| 184 | } | 184 | } |
| 185 | 185 | ||
| 186 | - if (operatingPoints.size() <= 2) qFatal("Insufficent genuines or impostors."); | ||
| 187 | - operatingPoints.takeLast(); // Remove point (1,1) | 186 | + if (operatingPoints.size() == 0) operatingPoints.append(OperatingPoint(1, 1, 1)); |
| 187 | + if (operatingPoints.size() == 1) operatingPoints.prepend(OperatingPoint(0, 0, 0)); | ||
| 188 | + if (operatingPoints.size() > 2) operatingPoints.takeLast(); // Remove point (1,1) | ||
| 188 | 189 | ||
| 189 | // Write Metadata table | 190 | // Write Metadata table |
| 190 | QStringList lines; | 191 | QStringList lines; |
| @@ -405,8 +406,8 @@ struct RPlot | @@ -405,8 +406,8 @@ struct RPlot | ||
| 405 | } | 406 | } |
| 406 | 407 | ||
| 407 | const QString &smooth = destination.getString("smooth", ""); | 408 | const QString &smooth = destination.getString("smooth", ""); |
| 408 | - major.smooth = !smooth.isEmpty() && (major.header == smooth); | ||
| 409 | - minor.smooth = !smooth.isEmpty() && (minor.header == smooth); | 409 | + major.smooth = !smooth.isEmpty() && (major.header == smooth) && (major.size > 1); |
| 410 | + minor.smooth = !smooth.isEmpty() && (minor.header == smooth) && (minor.size > 1); | ||
| 410 | if (major.smooth) major.size = 1; | 411 | if (major.smooth) major.size = 1; |
| 411 | if (minor.smooth) minor.size = 1; | 412 | if (minor.smooth) minor.size = 1; |
| 412 | if (major.size < minor.size) | 413 | if (major.size < minor.size) |
sdk/core/qtutils.cpp
| @@ -271,7 +271,9 @@ bool QtUtils::runRScript(const QString &file) | @@ -271,7 +271,9 @@ bool QtUtils::runRScript(const QString &file) | ||
| 271 | RScript.start("Rscript", QStringList() << file); | 271 | RScript.start("Rscript", QStringList() << file); |
| 272 | RScript.waitForFinished(-1); | 272 | RScript.waitForFinished(-1); |
| 273 | bool result = ((RScript.exitCode() == 0) && (RScript.error() == QProcess::UnknownError)); | 273 | bool result = ((RScript.exitCode() == 0) && (RScript.error() == QProcess::UnknownError)); |
| 274 | - if (!result) qDebug("Failed to run 'Rscript', did you forget to install R? See online documentation of 'br_plot' for required R packages."); | 274 | + if (!result) qDebug("Failed to run 'Rscript', did you forget to install R? " |
| 275 | + "See online documentation of 'br_plot' for required R packages. " | ||
| 276 | + "Otherwise, try running Rscript on %s to get the exact error.", qPrintable(file)); | ||
| 275 | return result; | 277 | return result; |
| 276 | } | 278 | } |
| 277 | 279 |
sdk/openbr_plugin.cpp
| @@ -424,6 +424,7 @@ TemplateList TemplateList::fromInput(const br::File &input) | @@ -424,6 +424,7 @@ TemplateList TemplateList::fromInput(const br::File &input) | ||
| 424 | QScopedPointer<Gallery> i(Gallery::make(file)); | 424 | QScopedPointer<Gallery> i(Gallery::make(file)); |
| 425 | TemplateList newTemplates = i->read(); | 425 | TemplateList newTemplates = i->read(); |
| 426 | const int crossValidate = input.getInt("crossValidate"); | 426 | const int crossValidate = input.getInt("crossValidate"); |
| 427 | + if (crossValidate > 0) srand(0); | ||
| 427 | 428 | ||
| 428 | // If input is a Format not a Gallery | 429 | // If input is a Format not a Gallery |
| 429 | if (newTemplates.isEmpty()) | 430 | if (newTemplates.isEmpty()) |
| @@ -434,8 +435,7 @@ TemplateList TemplateList::fromInput(const br::File &input) | @@ -434,8 +435,7 @@ TemplateList TemplateList::fromInput(const br::File &input) | ||
| 434 | newTemplates[i].file.append(input.localMetadata()); | 435 | newTemplates[i].file.append(input.localMetadata()); |
| 435 | newTemplates[i].file.append(file.localMetadata()); | 436 | newTemplates[i].file.append(file.localMetadata()); |
| 436 | newTemplates[i].file.insert("Input_Index", i+templates.size()); | 437 | newTemplates[i].file.insert("Input_Index", i+templates.size()); |
| 437 | - if (crossValidate > 0) | ||
| 438 | - newTemplates[i].file.insert("Cross_Validation_Partition", i*crossValidate/newTemplates.size()); | 438 | + if (crossValidate > 0) newTemplates[i].file.insert("Cross_Validation_Partition", rand()%crossValidate); |
| 439 | } | 439 | } |
| 440 | 440 | ||
| 441 | if (!templates.isEmpty() && input.getBool("merge")) { | 441 | if (!templates.isEmpty() && input.getBool("merge")) { |
sdk/plugins/eigen3.cpp
| @@ -266,9 +266,7 @@ class LDATransform : public Transform | @@ -266,9 +266,7 @@ class LDATransform : public Transform | ||
| 266 | 266 | ||
| 267 | void train(const TemplateList &_trainingSet) | 267 | void train(const TemplateList &_trainingSet) |
| 268 | { | 268 | { |
| 269 | - TemplateList trainingSet = _trainingSet; | ||
| 270 | - trainingSet = TemplateList::relabel(trainingSet); | ||
| 271 | - | 269 | + TemplateList trainingSet = TemplateList::relabel(_trainingSet); |
| 272 | int instances = trainingSet.size(); | 270 | int instances = trainingSet.size(); |
| 273 | 271 | ||
| 274 | // Perform PCA dimensionality reduction | 272 | // Perform PCA dimensionality reduction |
sdk/plugins/misc.cpp
| @@ -123,6 +123,11 @@ BR_REGISTER(Transform, PrintTransform) | @@ -123,6 +123,11 @@ BR_REGISTER(Transform, PrintTransform) | ||
| 123 | class CheckTransform : public UntrainableMetaTransform | 123 | class CheckTransform : public UntrainableMetaTransform |
| 124 | { | 124 | { |
| 125 | Q_OBJECT | 125 | Q_OBJECT |
| 126 | + static int count; | ||
| 127 | + int index; | ||
| 128 | + | ||
| 129 | + public: | ||
| 130 | + CheckTransform() : index(count++) {} | ||
| 126 | 131 | ||
| 127 | void project(const Template &src, Template &dst) const | 132 | void project(const Template &src, Template &dst) const |
| 128 | { | 133 | { |
| @@ -134,11 +139,13 @@ class CheckTransform : public UntrainableMetaTransform | @@ -134,11 +139,13 @@ class CheckTransform : public UntrainableMetaTransform | ||
| 134 | const float *data = (const float*)fm.data; | 139 | const float *data = (const float*)fm.data; |
| 135 | for (int i=0; i<elements; i++) | 140 | for (int i=0; i<elements; i++) |
| 136 | if (data[i] != data[i]) | 141 | if (data[i] != data[i]) |
| 137 | - qFatal("%s NaN check failed!", qPrintable(src.file.flat())); | 142 | + qFatal("%s NaN check %d failed!", qPrintable(src.file.flat()), index); |
| 138 | } | 143 | } |
| 139 | } | 144 | } |
| 140 | }; | 145 | }; |
| 141 | 146 | ||
| 147 | +int CheckTransform::count = 0; | ||
| 148 | + | ||
| 142 | BR_REGISTER(Transform, CheckTransform) | 149 | BR_REGISTER(Transform, CheckTransform) |
| 143 | 150 | ||
| 144 | /*! | 151 | /*! |