Commit d24a5eb5 authored by Rashad Kanavath's avatar Rashad Kanavath

Merge remote-tracking branch 'origin/release-5.6' into develop

parents f077d9d7 4b2f0bc0
......@@ -61,6 +61,13 @@ public:
typedef otb::MachineLearningModelFactory<ValueType, LabelType> MachineLearningModelFactoryType;
typedef ClassificationFilterType::ConfidenceImageType ConfidenceImageType;
protected:
~ImageClassifier() ITK_OVERRIDE
{
MachineLearningModelFactoryType::CleanFactories();
}
private:
void DoInit() ITK_OVERRIDE
{
......
......@@ -102,6 +102,13 @@ public:
typedef ClassificationFilterType::LabelType LabelType;
typedef otb::MachineLearningModelFactory<ValueType, LabelType> MachineLearningModelFactoryType;
protected:
~PredictRegression() ITK_OVERRIDE
{
MachineLearningModelFactoryType::CleanFactories();
}
private:
void DoInit() ITK_OVERRIDE
{
......
......@@ -105,7 +105,8 @@ private:
// Doc example parameter settings
SetDocExampleParameterValue("in", "support_image.tif");
SetDocExampleParameterValue("vec", "sample_positions.sqlite");
SetDocExampleParameterValue("pre","band_");
SetDocExampleParameterValue("outfield","prefix");
SetDocExampleParameterValue("outfield.prefix.name","band_");
SetDocExampleParameterValue("field", "label");
SetDocExampleParameterValue("out","sample_values.sqlite");
}
......
......@@ -135,6 +135,8 @@ public:
protected:
LearningApplicationBase();
~LearningApplicationBase() ITK_OVERRIDE;
/** Generic method to train and save the machine learning model. This method
* uses specific train methods depending on the chosen model.*/
void Train(typename ListSampleType::Pointer trainingListSample,
......
......@@ -30,7 +30,14 @@ template <class TInputValue, class TOutputValue>
LearningApplicationBase<TInputValue,TOutputValue>
::LearningApplicationBase() : m_RegressionFlag(false)
{
}
}
template <class TInputValue, class TOutputValue>
LearningApplicationBase<TInputValue,TOutputValue>
::~LearningApplicationBase()
{
ModelFactoryType::CleanFactories();
}
template <class TInputValue, class TOutputValue>
void
......
......@@ -53,6 +53,8 @@ public:
/** Create the appropriate MachineLearningModel depending on the particulars of the file. */
static MachineLearningModelTypePointer CreateMachineLearningModel(const std::string& path, FileModeType mode);
static void CleanFactories();
protected:
MachineLearningModelFactory();
~MachineLearningModelFactory() ITK_OVERRIDE;
......
......@@ -120,4 +120,95 @@ MachineLearningModelFactory<TInputValue,TOutputValue>
itk::ObjectFactoryBase::RegisterFactory(factory);
}
template <class TInputValue, class TOutputValue>
void
MachineLearningModelFactory<TInputValue,TOutputValue>
::CleanFactories()
{
itk::MutexLockHolder<itk::SimpleMutexLock> lockHolder(mutex);
std::list<itk::ObjectFactoryBase*> factories = itk::ObjectFactoryBase::GetRegisteredFactories();
std::list<itk::ObjectFactoryBase*>::iterator itFac;
for (itFac = factories.begin(); itFac != factories.end() ; ++itFac)
{
#ifdef OTB_USE_LIBSVM
LibSVMMachineLearningModelFactory<TInputValue,TOutputValue> *libsvmFactory =
dynamic_cast<LibSVMMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (libsvmFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(libsvmFactory);
continue;
}
#endif
#ifdef OTB_USE_OPENCV
// RandomForest
RandomForestsMachineLearningModelFactory<TInputValue,TOutputValue> *rfFactory =
dynamic_cast<RandomForestsMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (rfFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(rfFactory);
continue;
}
// SVM
SVMMachineLearningModelFactory<TInputValue,TOutputValue> *svmFactory =
dynamic_cast<SVMMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (svmFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(svmFactory);
continue;
}
// Boost
BoostMachineLearningModelFactory<TInputValue,TOutputValue> *boostFactory =
dynamic_cast<BoostMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (boostFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(boostFactory);
continue;
}
// ANN
NeuralNetworkMachineLearningModelFactory<TInputValue,TOutputValue> *annFactory =
dynamic_cast<NeuralNetworkMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (annFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(annFactory);
continue;
}
// Bayes
NormalBayesMachineLearningModelFactory<TInputValue,TOutputValue> *bayesFactory =
dynamic_cast<NormalBayesMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (bayesFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(bayesFactory);
continue;
}
// Decision Tree
DecisionTreeMachineLearningModelFactory<TInputValue,TOutputValue> *dtFactory =
dynamic_cast<DecisionTreeMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (dtFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(dtFactory);
continue;
}
// Gradient Boosted tree
GradientBoostedTreeMachineLearningModelFactory<TInputValue,TOutputValue> *gbtFactory =
dynamic_cast<GradientBoostedTreeMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (gbtFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(gbtFactory);
continue;
}
// KNN
KNearestNeighborsMachineLearningModelFactory<TInputValue,TOutputValue> *knnFactory =
dynamic_cast<KNearestNeighborsMachineLearningModelFactory<TInputValue,TOutputValue> *>(*itFac);
if (knnFactory)
{
itk::ObjectFactoryBase::UnRegisterFactory(knnFactory);
continue;
}
#endif
}
}
} // end namespace otb
......@@ -74,6 +74,8 @@ CommandLineLauncher::CommandLineLauncher(const char *) /*:
CommandLineLauncher::~CommandLineLauncher()
{
this->DeleteWatcherList();
m_Application = ITK_NULLPTR;
ApplicationRegistry::CleanRegistry();
}
void CommandLineLauncher::DeleteWatcherList()
......
......@@ -10,6 +10,9 @@ SETUP_SUPERBUILD(QT4)
# message(STATUS " SuperBuild may fail to compile Qt4. If so, you should install it via package manager.")
# endif()
option(QT4_SB_ENABLE_GTK "Enable GTK+ stlye with qt using -gtkstlye. Default is OFF" OFF)
if(NOT DEFINED git_protocol)
set(git_protocol "git")
endif()
......@@ -30,8 +33,14 @@ if(UNIX)
if(APPLE)
set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-framework")
else() #Linux
set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -sm -xrender -xrandr -gtkstyle")
if(QT4_SB_ENABLE_GTK)
message(STATUS "QT4_SB_ENABLE_GTK is activated. QT4 build includes gtk+ and libfreetype, libpng (dependencies of gtk+ package)")
set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -sm -xrender -xrandr -gtkstyle")
else()
set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-gtkstyle")
endif()
endif()
#common for all unix
set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -no-nis -no-javascript-jit -v")
elseif(MSVC)
set(QT4_SB_CONFIG "${QT4_SB_CONFIG} -mp")
......
......@@ -150,8 +150,12 @@ if(UNIX)
endif()
endif()
set(SB_CMAKE_ARGS)
list(APPEND SB_CMAKE_ARGS "-G${CMAKE_GENERATOR}")
list(APPEND SB_CMAKE_ARGS "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
list(APPEND SB_CMAKE_ARGS "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
set(SB_CMAKE_COMMAND ${CMAKE_COMMAND} ${SB_CMAKE_ARGS})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment