diff --git a/CMake/OTBModuleHeaderTest.cmake b/CMake/OTBModuleHeaderTest.cmake index 938c4787631dfa7cf8cdbd5f6c1cfa455b1b3893..2191be7c721734b249aa6d87796bdeeb7c333867 100644 --- a/CMake/OTBModuleHeaderTest.cmake +++ b/CMake/OTBModuleHeaderTest.cmake @@ -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") diff --git a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx index 551a043e8e88156ca718361932a50fa4fc19e0ae..8fdbd022f265bd5314300197cc76d3bb9708a466 100644 --- a/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx +++ b/Modules/Applications/AppDimensionalityReduction/app/otbTrainDimensionalityReduction.cxx @@ -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"); } diff --git a/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt b/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt index 57c99b6220bfa3de2b28e1da4f96eea177c2059c..e4037adcb0a388f34ae1ba4cc49a70200bab4d08 100644 --- a/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt +++ b/Modules/Applications/AppDimensionalityReduction/test/CMakeLists.txt @@ -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------------------------ diff --git a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx index b7d4115d01451a8baad287b204279228ceed4fc9..6fad411f58b621348c901edcdd5f6e6d767b8343 100644 --- a/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx +++ b/Modules/Learning/DimensionalityReductionLearning/include/otbDimensionalityReductionModelFactory.hxx @@ -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> ; diff --git a/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake index 587ef4efa40f2872acec6ff57198bc5f26f4728f..935690c1b57692c0a3b01b6008420ee014b7e77d 100644 --- a/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake +++ b/Modules/Learning/DimensionalityReductionLearning/otb-module.cmake @@ -23,11 +23,13 @@ otb_module(OTBDimensionalityReductionLearning DEPENDS OTBCommon OTBITK - OTBShark OTBBoost OTBSOM OTBLearningBase + OPTIONAL_DEPENDS + OTBShark + TEST_DEPENDS OTBTestKernel diff --git a/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt b/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt index d81d85cb378520ac7f55f6b6c15b1e7a0be468e8..21458c5fac1b25d43db6a91d01e53dffd891c9f9 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt +++ b/Modules/Learning/DimensionalityReductionLearning/test/CMakeLists.txt @@ -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) diff --git a/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx b/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx index a9daf79ccafba7b5f507ee18681d523576c7ef77..a4b82268aefac1e8606b8706528d8194ee383c25 100644 --- a/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx +++ b/Modules/Learning/DimensionalityReductionLearning/test/otbDimensionalityReductionLearningTestDriver.cxx @@ -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 } diff --git a/Modules/Learning/DimensionalityReductionLearning/test/tests-shark.cmake b/Modules/Learning/DimensionalityReductionLearning/test/tests-shark.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f48799ccbfc98db749aa8b023271946c81bfdfee --- /dev/null +++ b/Modules/Learning/DimensionalityReductionLearning/test/tests-shark.cmake @@ -0,0 +1,55 @@ +# +# 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) + diff --git a/Modules/Learning/Unsupervised/CMakeLists.txt b/Modules/Learning/Unsupervised/CMakeLists.txt index e83c272cd617b09367dce57c8ed038757904d14c..ff3dcf3cbed448210deb2d147166593d378c0e53 100644 --- a/Modules/Learning/Unsupervised/CMakeLists.txt +++ b/Modules/Learning/Unsupervised/CMakeLists.txt @@ -1,3 +1,23 @@ +# +# 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) diff --git a/Modules/Learning/Unsupervised/otb-module.cmake b/Modules/Learning/Unsupervised/otb-module.cmake index edaf52212e6bd849bf0b385bd3657bbc27b072c6..18009fac8c050c4a15d23058b2c7fcdf4e6b84b9 100644 --- a/Modules/Learning/Unsupervised/otb-module.cmake +++ b/Modules/Learning/Unsupervised/otb-module.cmake @@ -1,3 +1,23 @@ +# +# 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") diff --git a/Modules/Learning/Unsupervised/test/CMakeLists.txt b/Modules/Learning/Unsupervised/test/CMakeLists.txt index b13df48917c7210178e85e13144705d16d39a1a6..ad186592915e1474befc12d50cab56cdfbeb166e 100644 --- a/Modules/Learning/Unsupervised/test/CMakeLists.txt +++ b/Modules/Learning/Unsupervised/test/CMakeLists.txt @@ -1,3 +1,23 @@ +# +# 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 diff --git a/Modules/Learning/Unsupervised/test/tests-shark.cmake b/Modules/Learning/Unsupervised/test/tests-shark.cmake index c817a318b0ab97049baee27313f545a23328c516..f43b11a99070e0bc393f5b4116670cc6ae8310db 100644 --- a/Modules/Learning/Unsupervised/test/tests-shark.cmake +++ b/Modules/Learning/Unsupervised/test/tests-shark.cmake @@ -1,6 +1,24 @@ -# 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