diff --git a/openbr/core/core.cpp b/openbr/core/core.cpp index 5f97d70..b781c87 100644 --- a/openbr/core/core.cpp +++ b/openbr/core/core.cpp @@ -41,6 +41,7 @@ struct AlgorithmCore void train(const File &input, const QString &model) { + qDebug() << input; TemplateList data(TemplateList::fromGallery(input)); if (transform.isNull()) qFatal("Null transform."); @@ -393,6 +394,7 @@ void br::Convert(const File &fileType, const File &inputFile, const File &output QSharedPointer o(Factory::make(outputFile)); o->initialize(targetFiles, queryFiles); + qDebug() << m.rows << m.cols << targetFiles.size() << queryFiles.size(); for (int i=0; isetRelative(m.at(i,j), i, j); diff --git a/openbr/openbr_plugin.cpp b/openbr/openbr_plugin.cpp index 6330d63..9985bc8 100644 --- a/openbr/openbr_plugin.cpp +++ b/openbr/openbr_plugin.cpp @@ -386,16 +386,27 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) newTemplates = newTemplates.reduced(); const int crossValidate = gallery.get("crossValidate"); - if (crossValidate > 0) srand(0); - if (gallery.getBool("leaveOneOut", 0)) { - QStringList subjects = File::get(newTemplates.files(),"Subject","-1"); - subjects. - // Get QStringLists of unique subjects - - // For each list of unique subjects, decide randomly which to test on - for (int i = 0; i < subjects.size(); i++) { - if (subjects + if (gallery.getBool("leaveOneOut")) { + QStringList subjects; + for (int i = 0; i < newTemplates.size(); i++) { + QString subject = newTemplates.at(i).file.get("Subject"); + // Have we seen this subject before? + if (subjects.contains(subject)) { + subjects.append(subject); + // Get indices belonging to this subject + QList subjectIndices = newTemplates.find("Subject",subject); + for (int j = 0; j < subjectIndices.size(); j++) { + // Set subject partitions + newTemplates[subjectIndices[j]].file.set("Partition",j); + } + // Generate more templates if necessary + for (int j=0; j=0; i--) { diff --git a/openbr/openbr_plugin.h b/openbr/openbr_plugin.h index 4ae25a7..dbf69b4 100644 --- a/openbr/openbr_plugin.h +++ b/openbr/openbr_plugin.h @@ -509,6 +509,20 @@ struct TemplateList : public QList