Commit 47fc69c1 authored by Cédric Traizet's avatar Cédric Traizet
Browse files

BUG : SOMModel now herits from MachineLearningModel<TInput,...> instead of...

BUG : SOMModel now herits from MachineLearningModel<TInput,...> instead of MachineLearningModel<itk:variablelengthvector<TInput>,...>
parent ef7227bd
......@@ -60,7 +60,8 @@ private:
AddParameter(ParameterType_OutputFilename, "io.out", "Output model");
SetParameterDescription("io.out", "Output file containing the model estimated (.txt format).");
AddParameter(ParameterType_InputFilename, "io.stats", "Input XML image statistics file");
MandatoryOff("io.stats");
SetParameterDescription("io.stats", "XML file containing mean and variance of each feature.");
......
......@@ -116,6 +116,11 @@ class CbDimensionalityReductionVector : public Application
SetParameterDescription("pcadim","This optional parameter can be set to reduce the number of eignevectors used in the PCA model file."); //
MandatoryOff("pcadim");
AddParameter(ParameterType_String, "mode", "Writting mode"); //
SetParameterString("mode","overwrite", false);
SetParameterDescription("mode","This parameter determines if the output file is overwritten or updated [overwrite/update]"); //
// Doc example parameter settings
SetDocExampleParameterValue("in", "vectorData.shp");
SetDocExampleParameterValue("instat", "meanVar.xml");
......@@ -262,7 +267,19 @@ class CbDimensionalityReductionVector : public Application
if (IsParameterEnabled("out") && HasValue("out"))
{
// Create new OGRDataSource
output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite);
if (GetParameterString("mode")=="overwrite")
{
output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Overwrite);
}
else if (GetParameterString("mode")=="update")
{
output = ogr::DataSource::New(GetParameterString("out"), ogr::DataSource::Modes::Update_LayerCreateOnly );
}
else
{
otbAppLogFATAL(<< "Error when creating the output file" << GetParameterString("mode") << " : unsupported writting mode type [update/overwrite]");
}
otb::ogr::Layer newLayer = output->CreateLayer(GetParameterString("out"),
const_cast<OGRSpatialReference*>(layer.GetSpatialRef()),
layer.GetGeomType());
......
......@@ -87,16 +87,16 @@ public:
// Dimensionality reduction models
typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType;
typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 2> Map2DType;
typedef otb::SOMModel<InputValueType, 2> SOM2DModelType;
typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType;
typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 3> Map3DType;
typedef otb::SOMModel<InputValueType, 3> SOM3DModelType;
typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType;
typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 4> Map4DType;
typedef otb::SOMModel<InputValueType, 4> SOM4DModelType;
typedef SOMMap<itk::VariableLengthVector<TInputValue>,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType;
typedef SOMMap<TInputValue,itk::Statistics::EuclideanDistanceMetric<itk::VariableLengthVector<TInputValue>>, 5> Map5DType;
typedef otb::SOMModel<InputValueType, 5> SOM5DModelType;
......
......@@ -45,7 +45,7 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
AddDocTag(Tags::Learning);
// main choice parameter that will contain all dimensionality reduction options
AddParameter(ParameterType_Choice, "model", "moddel to use for the training");
AddParameter(ParameterType_Choice, "model", "model to use for the training");
SetParameterDescription("model", "Choice of the dimensionality reduction model to use for the training.");
......@@ -83,28 +83,28 @@ cbLearningApplicationBaseDR<TInputValue,TOutputValue>
if(modelName == "autoencoder")
{
#ifdef OTB_USE_SHARK
BeforeTrainAutoencoder(trainingListSample,modelPath);
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
#ifdef OTB_USE_SHARK
BeforeTrainAutoencoder(trainingListSample,modelPath);
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
}
if(modelName == "tiedautoencoder")
{
#ifdef OTB_USE_SHARK
TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath);
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
#ifdef OTB_USE_SHARK
TrainAutoencoder<TiedAutoencoderModelType>(trainingListSample,modelPath);
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
}
if(modelName == "pca")
{
#ifdef OTB_USE_SHARK
TrainPCA(trainingListSample,modelPath);
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
#ifdef OTB_USE_SHARK
TrainPCA(trainingListSample,modelPath);
#else
otbAppLogFATAL("Module SharkLearning is not installed. You should consider turning OTB_USE_SHARK on during cmake configuration.");
#endif
}
}
......
Supports Markdown
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