Skip to content
Snippets Groups Projects
Commit 053a239e authored by Ludovic Hussonnois's avatar Ludovic Hussonnois
Browse files

REFAC: Rename Clustering to Unsupervised and update dependencies.

parent baeffe2d
No related branches found
No related tags found
No related merge requests found
Showing
with 44 additions and 47 deletions
......@@ -51,8 +51,8 @@ otb_create_application(
LINK_LIBRARIES ${${otb-module}_LIBRARIES})
otb_create_application(
NAME TrainVectorClustering
SOURCES otbTrainVectorClustering.cxx
NAME TrainVectorUnsupervised
SOURCES otbTrainVectorUnsupervised.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES})
otb_create_application(
......@@ -81,8 +81,8 @@ otb_create_application(
LINK_LIBRARIES ${${otb-module}_LIBRARIES})
otb_create_application(
NAME TrainImagesClustering
SOURCES otbTrainImagesClustering.cxx
NAME TrainImagesUnsupervised
SOURCES otbTrainImagesUnsupervised.cxx
LINK_LIBRARIES ${${otb-module}_LIBRARIES})
otb_create_application(
......
......@@ -5,10 +5,10 @@ namespace otb
namespace Wrapper
{
class TrainImagesClustering : public TrainImagesBase
class TrainImagesUnsupervised : public TrainImagesBase
{
public:
typedef TrainImagesClustering Self;
typedef TrainImagesUnsupervised Self;
typedef TrainImagesBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -17,7 +17,7 @@ public:
void DoInit() ITK_OVERRIDE
{
SetName( "TrainImagesClustering" );
SetName( "TrainImagesUnsupervised" );
SetDescription( "Train a classifier from multiple pairs of images and optional input training vector data." );
// Documentation
......@@ -168,4 +168,4 @@ private :
}
}
OTB_APPLICATION_EXPORT( otb::Wrapper::TrainImagesClustering )
\ No newline at end of file
OTB_APPLICATION_EXPORT( otb::Wrapper::TrainImagesUnsupervised )
\ No newline at end of file
......@@ -21,10 +21,10 @@ namespace otb
namespace Wrapper
{
class TrainVectorClustering : public TrainVectorBase
class TrainVectorUnsupervised : public TrainVectorBase
{
public:
typedef TrainVectorClustering Self;
typedef TrainVectorUnsupervised Self;
typedef TrainVectorBase Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
......@@ -37,7 +37,7 @@ public:
typedef Superclass::TargetListSampleType TargetListSampleType;
protected :
TrainVectorClustering() : TrainVectorBase()
TrainVectorUnsupervised() : TrainVectorBase()
{
m_ClassifierCategory = Unsupervised;
}
......@@ -45,10 +45,10 @@ protected :
private:
void DoTrainInit()
{
SetName( "TrainVectorClustering" );
SetName( "TrainVectorUnsupervised" );
SetDescription( "Train a classifier based on labeled or unlabeled geometries and a list of features to consider." );
SetDocName( "Train Vector Clustering" );
SetDocName( "Train Vector Unsupervised" );
SetDocLongDescription( "This application trains a classifier based on "
"labeled or unlabeled geometries and a list of features to consider for classification." );
SetDocLimitations( " " );
......@@ -83,4 +83,4 @@ private:
}
}
OTB_APPLICATION_EXPORT( otb::Wrapper::TrainVectorClustering )
OTB_APPLICATION_EXPORT( otb::Wrapper::TrainVectorUnsupervised )
......@@ -159,7 +159,7 @@ protected:
if( supervised )
AddApplication( "TrainVectorClassifier", "training", "Model training" );
else
AddApplication( "TrainVectorClustering", "training", "Model training" );
AddApplication( "TrainVectorUnsupervised", "training", "Model training" );
AddParameter( ParameterType_InputVectorDataList, "io.valid", "Validation Vector Data List" );
SetParameterDescription( "io.valid", "A list of vector data to select the training samples." );
......
......@@ -11,6 +11,7 @@ otb_module(OTBAppClassification
OTBMajorityVoting
OTBVectorDataIO
OTBSOM
OTBLearningBase
OTBSupervised
OTBUnsupervised
OTBApplicationEngine
......
......@@ -225,19 +225,19 @@ foreach(classifier ${classifierList})
endforeach()
#----------- TrainImagesClustering TESTS ----------------
#----------- TrainImagesUnsupervised TESTS ----------------
set(sharkkm_output_format ".txt")
set(sharkkm_parameters "")
if(OTB_USE_SHARK)
list(APPEND clusteringList "SHARKKM")
list(APPEND UnsupervisedList "SHARKKM")
endif()
list(APPEND classifier_without_baseline "SHARKKM")
# Loop on classifiers
foreach(classifier ${clusteringList})
foreach(classifier ${UnsupervisedList})
string(TOLOWER ${classifier} lclassifier)
# Derive output file name
......@@ -254,7 +254,7 @@ foreach(classifier ${clusteringList})
otb_test_application(
NAME apTvClTrainMethod${classifier}ImagesClassifierQB1
APP TrainImagesClustering
APP TrainImagesUnsupervised
OPTIONS -io.il ${INPUTDATA}/Classification/QB_1_ortho${raster_input_format}
-io.vd ${INPUTDATA}/Classification/VectorData_${${lclassifier}_input}QB1${vector_input_format}
-io.imstat ${INPUTDATA}/Classification/clImageStatisticsQB1${stat_input_format}
......@@ -275,7 +275,7 @@ foreach(classifier ${clusteringList})
otb_test_application(
NAME apTvClTrainMethod${classifier}ImagesClassifierQB1_OutXML1
APP TrainImagesClustering
APP TrainImagesUnsupervised
OPTIONS -io.il ${INPUTDATA}/Classification/QB_1_ortho${raster_input_format}
-io.vd ${INPUTDATA}/Classification/VectorData_${${lclassifier}_input}QB1${vector_input_format}
-io.imstat ${INPUTDATA}/Classification/clImageStatisticsQB1${stat_input_format}
......@@ -297,7 +297,7 @@ foreach(classifier ${clusteringList})
otb_test_application(
NAME apTvClTrainMethod${classifier}ImagesClassifierQB1_InXML1
APP TrainImagesClustering
APP TrainImagesUnsupervised
OPTIONS -inxml ${INPUTDATA}/cl${classifier}_OutXML1.xml
-io.il ${INPUTDATA}/Classification/QB_1_ortho${raster_input_format}
-io.vd ${INPUTDATA}/Classification/VectorData_${${lclassifier}_input}QB1${vector_input_format}
......@@ -1051,17 +1051,17 @@ if(OTB_USE_OPENCV)
${TEMP}/apTvClTrainVectorClassifierModel.rf)
endif()
#----------- TrainVectorClustering TESTS ----------------
#----------- TrainVectorUnsupervised TESTS ----------------
if(OTB_USE_SHARK)
otb_test_application(NAME apTvClTrainVectorClustering
APP TrainVectorClustering
otb_test_application(NAME apTvClTrainVectorUnsupervised
APP TrainVectorUnsupervised
OPTIONS -io.vd ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite
-feat value_0 value_1 value_2 value_3
-classifier sharkkm
-io.out ${TEMP}/apTvClTrainVectorClusteringModel.txt)
otb_test_application(NAME apTvClTrainVectorClusteringWithClass
APP TrainVectorClustering
otb_test_application(NAME apTvClTrainVectorUnsupervisedWithClass
APP TrainVectorUnsupervised
OPTIONS -io.vd ${INPUTDATA}/Classification/apTvClSampleExtractionOut.sqlite
-feat value_0 value_1 value_2 value_3
-cfield class
......
......@@ -42,8 +42,6 @@
#pragma GCC diagnostic pop
#endif
using namespace shark;
/** \class SharkKMeansMachineLearningModel
* \brief Shark version of Random Forests algorithm
*
......@@ -64,10 +62,10 @@ class ITK_EXPORT SharkKMeansMachineLearningModel : public MachineLearningModel<T
{
public:
/** Standard class typedefs. */
typedef SharkKMeansMachineLearningModel Self;
typedef SharkKMeansMachineLearningModel Self;
typedef MachineLearningModel<TInputValue, TTargetValue> Superclass;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef itk::SmartPointer<Self> Pointer;
typedef itk::SmartPointer<const Self> ConstPointer;
typedef typename Superclass::InputValueType InputValueType;
typedef typename Superclass::InputSampleType InputSampleType;
......@@ -80,8 +78,8 @@ public:
typedef typename Superclass::ConfidenceListSampleType ConfidenceListSampleType;
typedef HardClusteringModel<RealVector> ClusteringModelType;
typedef ClusteringModelType::OutputType ClusteringOutputType;
typedef shark::HardClusteringModel<shark::RealVector> ClusteringModelType;
typedef ClusteringModelType::OutputType ClusteringOutputType;
/** Run-time type information (and related methods). */
itkNewMacro( Self );
......@@ -152,7 +150,7 @@ private:
/** Centroids results form kMeans */
Centroids m_Centroids;
shark::Centroids m_Centroids;
/** shark Model could be SoftClusteringModel or HardClusteringModel */
......
......@@ -68,16 +68,16 @@ SharkKMeansMachineLearningModel<TInputValue, TOutputValue>
::Train()
{
// Parse input data and convert to Shark Data
std::vector<RealVector> vector_data;
Shark::ListSampleToSharkVector( this->GetInputListSample(), vector_data );
Data<RealVector> data = createDataFromRange( vector_data );
std::vector<shark::RealVector> vector_data;
otb::Shark::ListSampleToSharkVector( this->GetInputListSample(), vector_data );
shark::Data<shark::RealVector> data = shark::createDataFromRange( vector_data );
// Normalized input value if necessary
if( m_Normalized )
data = NormalizeData( data );
// Use a Hard Clustering Model for classification
kMeans( data, m_K, m_Centroids, m_MaximumNumberOfIterations );
shark::kMeans( data, m_K, m_Centroids, m_MaximumNumberOfIterations );
m_ClusteringModel = boost::shared_ptr<ClusteringModelType>(new ClusteringModelType( &m_Centroids ));
}
......@@ -99,7 +99,7 @@ typename SharkKMeansMachineLearningModel<TInputValue, TOutputValue>
SharkKMeansMachineLearningModel<TInputValue, TOutputValue>
::DoPredict(const InputSampleType &value, ConfidenceValueType *quality) const
{
RealVector data( value.Size());
shark::RealVector data( value.Size());
for( size_t i = 0; i < value.Size(); i++ )
{
data.push_back( value[i] );
......@@ -143,11 +143,11 @@ SharkKMeansMachineLearningModel<TInputValue, TOutputValue>
}
// Convert input list of features to shark data format
std::vector<RealVector> features;
Shark::ListSampleRangeToSharkVector( input, features, startIndex, size );
Data<RealVector> inputSamples = shark::createDataFromRange( features );
std::vector<shark::RealVector> features;
otb::Shark::ListSampleRangeToSharkVector( input, features, startIndex, size );
shark::Data<shark::RealVector> inputSamples = shark::createDataFromRange( features );
Data<ClusteringOutputType> clusters;
shark::Data<ClusteringOutputType> clusters;
try
{
clusters = ( *m_ClusteringModel )( inputSamples );
......@@ -175,7 +175,6 @@ SharkKMeansMachineLearningModel<TInputValue, TOutputValue>
quality->SetMeasurementVector( qid, static_cast<ConfidenceValueType>(1.) );
}
}
}
......
......@@ -16,7 +16,6 @@ otb_module(OTBUnsupervised
OTBImageIO
OTBImageBase
OTBLearningBase
OTBSupervised
OTBShark
DESCRIPTION
......
otb_module_test()
set(OTBUnsupervisedTests
otbUnsupervisedTestDriver.cxx
otbMachineLearningClusteringModelCanRead.cxx
otbTrainMachineLearningClusteringModel.cxx
otbMachineLearningUnsupervisedModelCanRead.cxx
otbTrainMachineLearningUnsupervisedModel.cxx
)
# Tests Declaration
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment