Commit ecc8d78e authored by Cédric Traizet's avatar Cédric Traizet

Merge branch 'optional_shark_dimensionality_reduction' into 'develop'

Make Shark Optional for the "OTBDimensionalityReductionLearning" module

See merge request !372
parents 58769573 09305996
......@@ -46,7 +46,7 @@ if(NOT OTB_USE_OPENCV)
SET(BANNED_HEADERS "${BANNED_HEADERS} otbDecisionTreeMachineLearningModelFactory.h otbDecisionTreeMachineLearningModel.h otbKNearestNeighborsMachineLearningModelFactory.h otbKNearestNeighborsMachineLearningModel.h otbRandomForestsMachineLearningModelFactory.h otbRandomForestsMachineLearningModel.h otbSVMMachineLearningModelFactory.h otbSVMMachineLearningModel.h otbGradientBoostedTreeMachineLearningModelFactory.h otbGradientBoostedTreeMachineLearningModel.h otbBoostMachineLearningModelFactory.h otbBoostMachineLearningModel.h otbNeuralNetworkMachineLearningModelFactory.h otbNeuralNetworkMachineLearningModel.h otbNormalBayesMachineLearningModelFactory.h otbNormalBayesMachineLearningModel.h otbRequiresOpenCVCheck.h otbOpenCVUtils.h otbCvRTreesWrapper.h")
endif()
if(NOT OTB_USE_SHARK)
SET(BANNED_HEADERS "${BANNED_HEADERS} otbSharkRandomForestsMachineLearningModel.h otbSharkRandomForestsMachineLearningModel.hxx otbSharkUtils.h otbRequiresSharkCheck.h otbSharkRandomForestsMachineLearningModelFactory.h otbSharkKMeansMachineLearningModel.h otbSharkKMeansMachineLearningModel.hxx otbSharkKMeansMachineLearningModelFactory.h otbSharkKMeansMachineLearningModelFactory.hxx")
SET(BANNED_HEADERS "${BANNED_HEADERS} otbSharkRandomForestsMachineLearningModel.h otbSharkRandomForestsMachineLearningModel.hxx otbSharkUtils.h otbRequiresSharkCheck.h otbSharkRandomForestsMachineLearningModelFactory.h otbSharkKMeansMachineLearningModel.h otbSharkKMeansMachineLearningModel.hxx otbSharkKMeansMachineLearningModelFactory.h otbSharkKMeansMachineLearningModelFactory.hxx otbPCAModel.h otbPCAModel.hxx otbPCAModelFactory.h otbPCAModelFactory.hxx otbAutoencoderModel.h otbAutoencoderModel.hxx otbAutoencoderModelFactory.h otbAutoencoderModelFactory.hxx")
endif()
if(NOT OTB_USE_LIBSVM)
SET(BANNED_HEADERS "${BANNED_HEADERS} otbLibSVMMachineLearningModel.h otbLibSVMMachineLearningModelFactory.h")
......
......@@ -106,9 +106,14 @@ private:
// Doc example parameter settings
SetDocExampleParameterValue("io.vd", "cuprite_samples.sqlite");
SetDocExampleParameterValue("io.out", "mode.ae");
SetDocExampleParameterValue("algorithm", "pca");
SetDocExampleParameterValue("algorithm.pca.dim", "8");
SetDocExampleParameterValue("io.out", "model.som");
SetDocExampleParameterValue("algorithm", "som");
SetDocExampleParameterValue("algorithm.som.s", "10 10");
SetDocExampleParameterValue("algorithm.som.n", "3 3");
SetDocExampleParameterValue("algorithm.som.ni", "5");
SetDocExampleParameterValue("algorithm.som.bi", "1");
SetDocExampleParameterValue("algorithm.som.bf", "0.1");
SetDocExampleParameterValue("algorithm.som.iv", "10");
SetDocExampleParameterValue("feat","value_0 value_1 value_2 value_3 value_4"
" value_5 value_6 value_7 value_8 value_9");
}
......
......@@ -39,19 +39,7 @@ otb_test_application(NAME apTvFEDimensionalityReductionPCA
${TEMP}/apTvChDimensionalityReductionPCA.tif)
#-------------------------------------------------------------------------------
set(algos ae pca som)
set(ae_params
-algorithm autoencoder
-algorithm.autoencoder.nbneuron 8
-algorithm.autoencoder.regularization 0.01
-algorithm.autoencoder.noise 0
-algorithm.autoencoder.rho 0
-algorithm.autoencoder.beta 0)
set(pca_params
-algorithm pca
-algorithm.pca.dim 8)
set(algos som)
set(som_params
-algorithm som
......@@ -59,6 +47,22 @@ set(som_params
-algorithm.som.n 3 3
-algorithm.som.ni 10)
if(OTB_USE_SHARK)
list(APPEND classifierList ae pca)
set(ae_params
-algorithm autoencoder
-algorithm.autoencoder.nbneuron 8
-algorithm.autoencoder.regularization 0.01
-algorithm.autoencoder.noise 0
-algorithm.autoencoder.rho 0
-algorithm.autoencoder.beta 0)
set(pca_params
-algorithm pca
-algorithm.pca.dim 8)
endif()
foreach(algo ${algos})
string(TOUPPER ${algo} ualgo)
#------------------ TrainDimensionalityReduction TESTS------------------------
......
......@@ -35,8 +35,10 @@
namespace otb
{
#ifdef OTB_USE_SHARK
template <class TInputValue, class TTargetValue>
using LogAutoencoderModelFactory = AutoencoderModelFactory<TInputValue, TTargetValue, shark::LogisticNeuron> ;
#endif
template <class TInputValue, class TTargetValue>
using SOM2DModelFactory = SOMModelFactory<TInputValue, TTargetValue, 2> ;
......
......@@ -23,11 +23,13 @@ otb_module(OTBDimensionalityReductionLearning
DEPENDS
OTBCommon
OTBITK
OTBShark
OTBBoost
OTBSOM
OTBLearningBase
OPTIONAL_DEPENDS
OTBShark
TEST_DEPENDS
OTBTestKernel
......
......@@ -22,49 +22,22 @@ otb_module_test()
set(OTBDimensionalityReductionLearningTests
otbDimensionalityReductionLearningTestDriver.cxx
otbAutoencoderModelTest.cxx
otbPCAModelTest.cxx
otbSOMModelTest.cxx
)
add_executable(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearningTests})
target_link_libraries(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearning-Test_LIBRARIES})
otb_module_target_label(otbDimensionalityReductionLearningTestDriver)
# Tests Declaration
# --------------- Autoencoder --------------------------------
otb_add_test(NAME leTvAutoencoderModelTrain COMMAND
otbDimensionalityReductionLearningTestDriver
otbAutoencoderModeTrain
${INPUTDATA}/letter_light.scale
${TEMP}/model.ae
)
otb_add_test(NAME leTvAutoencoderModelCanRead COMMAND
otbDimensionalityReductionLearningTestDriver
otbAutoencoderModelCanRead
${TEMP}/model.ae
)
set_property(TEST leTvAutoencoderModelCanRead APPEND PROPERTY DEPENDS leTvAutoencoderModelTrain)
# --------------- PCA --------------------------------
# Tests for classes using Shark
otb_add_test(NAME leTvPCAModelTrain COMMAND
otbDimensionalityReductionLearningTestDriver
otbPCAModeTrain
${INPUTDATA}/letter_light.scale
${TEMP}/model.pca
)
otb_add_test(NAME leTvPCAModelCanRead COMMAND
otbDimensionalityReductionLearningTestDriver
otbPCAModelCanRead
${TEMP}/model.pca
)
if(OTB_USE_SHARK)
set(OTBDimensionalityReductionLearningTests ${OTBDimensionalityReductionLearningTests}
otbPCAModelTest.cxx
otbAutoencoderModelTest.cxx
)
include(tests-shark.cmake)
endif()
set_property(TEST leTvPCAModelCanRead APPEND PROPERTY DEPENDS leTvPCAModelTrain)
# --------------- SOM --------------------------------
......@@ -88,3 +61,7 @@ otb_add_test(NAME leTvSOMModelCanRead COMMAND
)
set_property(TEST leTvSOMModelCanRead APPEND PROPERTY DEPENDS leTvSOMModelTrain)
add_executable(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearningTests})
target_link_libraries(otbDimensionalityReductionLearningTestDriver ${OTBDimensionalityReductionLearning-Test_LIBRARIES})
otb_module_target_label(otbDimensionalityReductionLearningTestDriver)
......@@ -22,10 +22,13 @@
void RegisterTests()
{
REGISTER_TEST(otbSOMModelCanRead);
REGISTER_TEST(otbSOMModeTrain);
#ifdef OTB_USE_SHARK
REGISTER_TEST(otbAutoencoderModelCanRead);
REGISTER_TEST(otbAutoencoderModeTrain);
REGISTER_TEST(otbPCAModelCanRead);
REGISTER_TEST(otbPCAModeTrain);
REGISTER_TEST(otbSOMModelCanRead);
REGISTER_TEST(otbSOMModeTrain);
#endif
}
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Tests Declaration
# --------------- Autoencoder --------------------------------
otb_add_test(NAME leTvAutoencoderModelTrain COMMAND
otbDimensionalityReductionLearningTestDriver
otbAutoencoderModeTrain
${INPUTDATA}/letter_light.scale
${TEMP}/model.ae
)
otb_add_test(NAME leTvAutoencoderModelCanRead COMMAND
otbDimensionalityReductionLearningTestDriver
otbAutoencoderModelCanRead
${TEMP}/model.ae
)
set_property(TEST leTvAutoencoderModelCanRead APPEND PROPERTY DEPENDS leTvAutoencoderModelTrain)
# --------------- PCA --------------------------------
otb_add_test(NAME leTvPCAModelTrain COMMAND
otbDimensionalityReductionLearningTestDriver
otbPCAModeTrain
${INPUTDATA}/letter_light.scale
${TEMP}/model.pca
)
otb_add_test(NAME leTvPCAModelCanRead COMMAND
otbDimensionalityReductionLearningTestDriver
otbPCAModelCanRead
${TEMP}/model.pca
)
set_property(TEST leTvPCAModelCanRead APPEND PROPERTY DEPENDS leTvPCAModelTrain)
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
project(OTBUnsupervised)
......
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
set(DOCUMENTATION "This module provides the Orfeo Toolbox unsupervised
classification and regression framework, currently based on Shark")
......
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
otb_module_test()
set(OTBUnsupervisedTests
otbUnsupervisedTestDriver.cxx
......
# kMeans Shark related tests
#
# Copyright (C) 2005-2019 Centre National d'Etudes Spatiales (CNES)
#
# This file is part of Orfeo Toolbox
#
# https://www.orfeo-toolbox.org/
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# kMeans Shark related tests
otb_add_test(NAME leTvSharkKMeansMachineLearningModel COMMAND otbUnsupervisedTestDriver
otbSharkKMeansMachineLearningModelTrain
......
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