Commit 725e25b445e6dbd171c1414a3626938f57298ace
1 parent
04df7bef
Added some things related to leave one out cv
Showing
3 changed files
with
7 additions
and
3 deletions
openbr/core/bee.cpp
| ... | ... | @@ -305,11 +305,14 @@ cv::Mat BEE::makeMask(const br::FileList &targets, const br::FileList &queries, |
| 305 | 305 | QList<int> targetPartitions = targets.crossValidationPartitions(); |
| 306 | 306 | QList<int> queryPartitions = queries.crossValidationPartitions(); |
| 307 | 307 | |
| 308 | + QList<bool> targetsOnly = File::get<bool>(queries, "targetOnly", false); | |
| 309 | + | |
| 308 | 310 | Mat mask(queries.size(), targets.size(), CV_8UC1); |
| 309 | 311 | for (int i=0; i<queries.size(); i++) { |
| 310 | 312 | const QString &fileA = queries[i]; |
| 311 | 313 | const QString labelA = queryLabels[i]; |
| 312 | 314 | const int partitionA = queryPartitions[i]; |
| 315 | + const bool targetOnly = targetsOnly[i]; | |
| 313 | 316 | |
| 314 | 317 | for (int j=0; j<targets.size(); j++) { |
| 315 | 318 | const QString &fileB = targets[j]; |
| ... | ... | @@ -318,6 +321,7 @@ cv::Mat BEE::makeMask(const br::FileList &targets, const br::FileList &queries, |
| 318 | 321 | |
| 319 | 322 | Mask_t val; |
| 320 | 323 | if (fileA == fileB) val = DontCare; |
| 324 | + else if (targetOnly) val = DontCare; | |
| 321 | 325 | else if (labelA == "-1") val = DontCare; |
| 322 | 326 | else if (labelB == "-1") val = DontCare; |
| 323 | 327 | else if (partitionA != partition) val = DontCare; | ... | ... |
openbr/openbr_plugin.cpp
| ... | ... | @@ -419,7 +419,7 @@ TemplateList TemplateList::fromGallery(const br::File &gallery) |
| 419 | 419 | Template leaveOneImageOutTemplate = newTemplates[labelIndices[j]]; |
| 420 | 420 | if (k!=leaveOneImageOutTemplate.file.get<int>("Partition")) { |
| 421 | 421 | leaveOneImageOutTemplate.file.set("Partition", k); |
| 422 | - leaveOneImageOutTemplate.file.set("testOnly", true); | |
| 422 | + leaveOneImageOutTemplate.file.set("targetOnly", true); | |
| 423 | 423 | newTemplates.insert(i+1,leaveOneImageOutTemplate); |
| 424 | 424 | } |
| 425 | 425 | } | ... | ... |
openbr/plugins/validate.cpp
| ... | ... | @@ -65,9 +65,9 @@ class CrossValidateTransform : public MetaTransform |
| 65 | 65 | const QString label = partitionedData.at(j).file.get<QString>("Label"); |
| 66 | 66 | QList<int> subjectIndices = partitionedData.find("Label",label); |
| 67 | 67 | QList<int> removed; |
| 68 | - // Remove test only data | |
| 68 | + // Remove target only data | |
| 69 | 69 | for (int k=subjectIndices.size()-1; k>=0; k--) |
| 70 | - if (partitionedData[subjectIndices[k]].file.getBool("testOnly")) { | |
| 70 | + if (partitionedData[subjectIndices[k]].file.getBool("targetOnly")) { | |
| 71 | 71 | removed.append(subjectIndices[k]); |
| 72 | 72 | subjectIndices.removeAt(k); |
| 73 | 73 | } | ... | ... |