|
@@ -20,8 +20,6 @@
|
|
|
#include <omp.h>
|
|
|
#include <iostream>
|
|
|
|
|
|
-#undef WRITEGLOB
|
|
|
-
|
|
|
#define DEBUG
|
|
|
|
|
|
using namespace OBJREC;
|
|
@@ -1164,37 +1162,6 @@ void SemSegContextTree::train (const MultiDataset *md)
|
|
|
|
|
|
}
|
|
|
|
|
|
-#ifdef WRITEGLOB
|
|
|
- ofstream outstream ("globtrain.feat");
|
|
|
-
|
|
|
- for (int i = 0; i < textonMap.size(); i++)
|
|
|
- {
|
|
|
- set<int> usedclasses;
|
|
|
- for (uint x = 0; x < labels[i].rows(); x++)
|
|
|
- {
|
|
|
- for (uint y = 0; y < labels[i].cols(); y++)
|
|
|
- {
|
|
|
- int classno = labels[i] (x, y);
|
|
|
-
|
|
|
- if (forbidden_classes.find (classno) != forbidden_classes.end())
|
|
|
- continue;
|
|
|
-
|
|
|
- usedclasses.insert (classno);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- cout << "labels.cols: " << labels[i].cols() << " labels.rows " << labels[i].rows() << endl;
|
|
|
- cout << "currentfeats : " << allfeats[i].width() << " allfeats[i].height(); " << allfeats[i].height() << endl;
|
|
|
-
|
|
|
- set<int>::iterator it;
|
|
|
- for (it = usedclasses.begin() ; it != usedclasses.end(); it++)
|
|
|
- outstream << *it << " ";
|
|
|
- outstream << endl;
|
|
|
- integralTexton[i] (integralTexton[i].width() - 1, integralTexton[i].height() - 1).store (outstream);
|
|
|
- }
|
|
|
-
|
|
|
- outstream.close();
|
|
|
-#endif
|
|
|
cout << "uniquenumber " << uniquenumber << endl;
|
|
|
//getchar();
|
|
|
#ifdef DEBUG
|
|
@@ -1562,80 +1529,10 @@ void SemSegContextTree::semanticseg (CachedExample *ce, NICE::Image & segresult,
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-#ifdef WRITEGLOB
|
|
|
- ofstream outstream ("globtest.feat", ofstream::app);
|
|
|
- outstream << 0 << endl;
|
|
|
- integralTexton (integralTexton.width() - 1, integralTexton.height() - 1).store (outstream);
|
|
|
- outstream.close();
|
|
|
-#endif
|
|
|
-
|
|
|
string cndir = conf->gS ("SSContextTree", "cndir", "");
|
|
|
|
|
|
int allClasses = (int)probabilities.channels();
|
|
|
vector<int> useclass (allClasses, 1);
|
|
|
-#ifdef WRITEGLOB
|
|
|
-
|
|
|
-
|
|
|
- std::vector< std::string > list;
|
|
|
- StringTools::split (currentFile, '/', list);
|
|
|
-
|
|
|
- string orgname = list.back();
|
|
|
-
|
|
|
- ofstream ostream ("filelist.txt", ofstream::app);
|
|
|
- ostream << orgname << ".dat" << endl;
|
|
|
- ostream.close();
|
|
|
-
|
|
|
- if (cndir != "")
|
|
|
- {
|
|
|
- useclass = vector<int> (allClasses, 0);
|
|
|
- ifstream infile ((cndir + "/" + orgname + ".dat").c_str());
|
|
|
-
|
|
|
-#undef OLD
|
|
|
-#ifdef OLD
|
|
|
- while (!infile.eof() && infile.good())
|
|
|
- {
|
|
|
- int tmp;
|
|
|
- infile >> tmp;
|
|
|
- assert (tmp >= 0 && tmp < allClasses);
|
|
|
- useclass[tmp] = 1;
|
|
|
- }
|
|
|
-#else
|
|
|
- int c = 0;
|
|
|
- vector<double> probs (allClasses, 0.0);
|
|
|
-
|
|
|
- while (!infile.eof() && infile.good())
|
|
|
- {
|
|
|
- infile >> probs[c];
|
|
|
- c++;
|
|
|
- }
|
|
|
-
|
|
|
- vector<double> sorted = probs;
|
|
|
- sort (sorted.begin(), sorted.end());
|
|
|
-
|
|
|
- double thr = sorted[10];
|
|
|
-
|
|
|
- if (thr < 0.0)
|
|
|
- thr = 0.0;
|
|
|
-
|
|
|
- for (int c = 0; c < allClasses; c++)
|
|
|
- {
|
|
|
- if (probs[c] < thr)
|
|
|
- {
|
|
|
- useclass[c] = 1;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-#endif
|
|
|
-
|
|
|
- for (int c = 0; c < allClasses; c++)
|
|
|
- {
|
|
|
- if (useclass[c] == 0)
|
|
|
- {
|
|
|
- probabilities.set (-numeric_limits< double >::max(), c);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-#endif
|
|
|
|
|
|
vector<int> classesInImg;
|
|
|
|
|
@@ -1654,7 +1551,8 @@ void SemSegContextTree::semanticseg (CachedExample *ce, NICE::Image & segresult,
|
|
|
}
|
|
|
cerr << "amount of classes: " << classes << " used classes: " << classesInImg.size() << endl;
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ if(classesInImg.size() == 0)
|
|
|
{
|
|
|
for (uint i = 0; i < classes; i++)
|
|
|
{
|