|
@@ -24,6 +24,8 @@
|
|
|
#undef WRITEGLOB
|
|
|
#undef TEXTONMAP
|
|
|
|
|
|
+#undef DEBUG
|
|
|
+
|
|
|
//#define LOCALFEATS
|
|
|
|
|
|
using namespace OBJREC;
|
|
@@ -276,8 +278,9 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
{
|
|
|
return 0.0;
|
|
|
}
|
|
|
-
|
|
|
- featsel.clear();
|
|
|
+
|
|
|
+ /** vector of all possible features */
|
|
|
+ std::vector<Operation*> featsel;
|
|
|
|
|
|
for ( int i = 0; i < featsPerSplit; i++ )
|
|
|
{
|
|
@@ -305,9 +308,9 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
y1 = (int)( (double)rand() / (double)RAND_MAX * (double)tmpws ) - tmpws / 2;
|
|
|
y2 = (int)( (double)rand() / (double)RAND_MAX * (double)tmpws ) - tmpws / 2;
|
|
|
|
|
|
- int f1 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) channelsPerType[ft].size() );
|
|
|
- int f2 = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) channelsPerType[ft].size() );
|
|
|
- int o = ( int ) ( ( double ) rand() / ( double ) RAND_MAX * ( double ) ops[ft].size() );
|
|
|
+ int f1 = ( int ) ( (double) rand() / (double) RAND_MAX * (double) channelsPerType[ft].size() );
|
|
|
+ int f2 = ( int ) ( (double) rand() / (double) RAND_MAX * (double) channelsPerType[ft].size() );
|
|
|
+ int o = ( int ) ( (double) rand() / (double) RAND_MAX * (double) ops[ft].size() );
|
|
|
|
|
|
Operation *op = ops[ft][o]->clone();
|
|
|
|
|
@@ -445,7 +448,7 @@ double SemSegContextTree::getBestSplit ( std::vector<NICE::MultiChannelImageT<do
|
|
|
}*/
|
|
|
|
|
|
|
|
|
-#ifdef debug
|
|
|
+#ifdef DEBUG
|
|
|
cout << "globent: " << globent << " bestig " << bestig << " splitval: " << splitval << endl;
|
|
|
|
|
|
#endif
|
|
@@ -587,6 +590,8 @@ inline double computeWeight ( const double &d, const double &dim )
|
|
|
|
|
|
void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
{
|
|
|
+ Timer timer;
|
|
|
+ timer.start();
|
|
|
const LabeledSet train = * ( *md ) ["train"];
|
|
|
const LabeledSet *trainp = &train;
|
|
|
|
|
@@ -710,7 +715,7 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
////////////////////////////////////////////////////
|
|
|
//define which featurextraction methods should be used for each channel
|
|
|
#ifdef LOCALFEATS
|
|
|
- rawChannels = 9;
|
|
|
+ rawChannels = 11;
|
|
|
#else
|
|
|
rawChannels = 3;
|
|
|
#endif
|
|
@@ -832,6 +837,10 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
bool allleaf = false;
|
|
|
//int baseFeatSize = allfeats[0].size();
|
|
|
|
|
|
+ timer.stop();
|
|
|
+ cerr << "preprocessing finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
|
+ timer.start();
|
|
|
+
|
|
|
while ( !allleaf && depth < maxDepth )
|
|
|
{
|
|
|
depth++;
|
|
@@ -842,8 +851,8 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
vector<MultiChannelImageT<unsigned short int> > lastfeats = currentfeats;
|
|
|
|
|
|
#if 1
|
|
|
- Timer timer;
|
|
|
- timer.start();
|
|
|
+ Timer timerDepth;
|
|
|
+ timerDepth.start();
|
|
|
#endif
|
|
|
|
|
|
double weight = computeWeight ( depth, maxDepth ) - computeWeight ( depth - 1, maxDepth );
|
|
@@ -853,20 +862,20 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
weight = computeWeight ( 1, maxDepth );
|
|
|
}
|
|
|
|
|
|
+#pragma omp parallel for
|
|
|
for ( int tree = 0; tree < nbTrees; tree++ )
|
|
|
{
|
|
|
int t = (int)forest[tree].size();
|
|
|
int s = startnode[tree];
|
|
|
startnode[tree] = t;
|
|
|
- //TODO vielleicht parallel wenn nächste schleife trotzdem noch parallelsiert würde, die hat mehr gewicht
|
|
|
- //#pragma omp parallel for
|
|
|
+#pragma omp parallel for
|
|
|
for ( int i = s; i < t; i++ )
|
|
|
{
|
|
|
if ( !forest[tree][i].isleaf && forest[tree][i].left < 0 )
|
|
|
{
|
|
|
Operation *splitfeat = NULL;
|
|
|
double splitval;
|
|
|
- double bestig = getBestSplit ( allfeats, lastfeats, labels, i, splitfeat, splitval, tree );
|
|
|
+ double bestig = getBestSplit(allfeats, lastfeats, labels, i, splitfeat, splitval, tree);
|
|
|
|
|
|
for ( int ii = 0; ii < lastfeats.size(); ii++ )
|
|
|
{
|
|
@@ -1047,11 +1056,15 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
}
|
|
|
|
|
|
#if 1
|
|
|
- timer.stop();
|
|
|
+ timerDepth.stop();
|
|
|
|
|
|
- cout << "time for depth " << depth << ": " << timer.getLast() << endl;
|
|
|
+ cout << "time for depth " << depth << ": " << timerDepth.getLastAbsolute() << endl;
|
|
|
#endif
|
|
|
}
|
|
|
+
|
|
|
+ timer.stop();
|
|
|
+ cerr << "learning finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
|
+ timer.start();
|
|
|
|
|
|
#ifdef WRITEGLOB
|
|
|
ofstream outstream ( "globtrain.feat" );
|
|
@@ -1128,8 +1141,11 @@ void SemSegContextTree::train ( const MultiDataset *md )
|
|
|
|
|
|
cout << "depth: " << d << " woContext: " << contextOverview[d][0] << " wContext: " << contextOverview[d][1] << endl;
|
|
|
}
|
|
|
-
|
|
|
#endif
|
|
|
+
|
|
|
+ timer.stop();
|
|
|
+ cerr << "rest finished in: " << timer.getLastAbsolute() << " seconds" << endl;
|
|
|
+ timer.start();
|
|
|
}
|
|
|
|
|
|
void SemSegContextTree::extractBasicFeatures ( NICE::MultiChannelImageT<double> &feats, const ColorImage &img, const string ¤tFile )
|
|
@@ -1214,7 +1230,7 @@ void SemSegContextTree::extractBasicFeatures ( NICE::MultiChannelImageT<double>
|
|
|
// copy standard image to double image
|
|
|
for ( uint y = 0 ; y < confidenceImage.height(); y++ )
|
|
|
for ( uint x = 0 ; x < confidenceImage.width(); x++ )
|
|
|
- feats ( x, y, currentChannel ) = ( double ) confidenceImage ( x, y );
|
|
|
+ feats ( x, y, currentChannel ) = (double) confidenceImage ( x, y );
|
|
|
}
|
|
|
}
|
|
|
}
|