diff --git a/app/otbLabelImageSampleSelection.cxx b/app/otbLabelImageSampleSelection.cxx index e1e023fcc137aa04e6cd3b21282e9b52178629c3..41d77e12a048f44a26f956ae3afb8119cefe52ad 100644 --- a/app/otbLabelImageSampleSelection.cxx +++ b/app/otbLabelImageSampleSelection.cxx @@ -22,6 +22,7 @@ // image utils #include "otbTensorflowCommon.h" +#include namespace otb { @@ -211,7 +212,7 @@ public: // Check the smallest number of samples amongst classes IndexValueType min_elem_in_class = itk::NumericTraits::max(); for (LabelImageType::InternalPixelType classIdx = 0 ; classIdx < number_of_classes ; classIdx++) - min_elem_in_class = vcl_min(min_elem_in_class, number_of_samples[classIdx]); + min_elem_in_class = std::min(min_elem_in_class, number_of_samples[classIdx]); // If one class is empty, throw an error if (min_elem_in_class == 0) diff --git a/include/otbTensorflowMultisourceModelFilter.hxx b/include/otbTensorflowMultisourceModelFilter.hxx index dbed34f753eca958289e41313c9cf34681773981..b59752e66a67dafc4bdef0dd56158a96bddd4c66 100644 --- a/include/otbTensorflowMultisourceModelFilter.hxx +++ b/include/otbTensorflowMultisourceModelFilter.hxx @@ -224,8 +224,8 @@ TensorflowMultisourceModelFilter } // Set final size - m_OutputSize[0] = vcl_floor( (extentSup[0] - extentInf[0]) / vcl_abs(m_OutputSpacing[0]) ) + 1; - m_OutputSize[1] = vcl_floor( (extentSup[1] - extentInf[1]) / vcl_abs(m_OutputSpacing[1]) ) + 1; + m_OutputSize[0] = std::floor( (extentSup[0] - extentInf[0]) / std::abs(m_OutputSpacing[0]) ) + 1; + m_OutputSize[1] = std::floor( (extentSup[1] - extentInf[1]) / std::abs(m_OutputSpacing[1]) ) + 1; // Set final origin m_OutputOrigin[0] = extentInf[0]; diff --git a/include/otbTensorflowMultisourceModelLearningBase.h b/include/otbTensorflowMultisourceModelLearningBase.h index f5ada7f25c2a8a1859818887e8cc0f7463924492..f72f376430606a566be9b2970415a5fdc3b90782 100644 --- a/include/otbTensorflowMultisourceModelLearningBase.h +++ b/include/otbTensorflowMultisourceModelLearningBase.h @@ -14,6 +14,7 @@ #include "itkProcessObject.h" #include "itkNumericTraits.h" #include "itkSimpleDataObjectDecorator.h" +#include // Base #include "otbTensorflowMultisourceModelBase.h" diff --git a/include/otbTensorflowMultisourceModelLearningBase.hxx b/include/otbTensorflowMultisourceModelLearningBase.hxx index 55f0de33d555efe5f1a45528cb91bfa53c67d86f..e9ae6540d3c92080e6c93a134246323f7f76cfa3 100644 --- a/include/otbTensorflowMultisourceModelLearningBase.hxx +++ b/include/otbTensorflowMultisourceModelLearningBase.hxx @@ -124,7 +124,7 @@ TensorflowMultisourceModelLearningBase { // Batches loop - const IndexValueType nBatches = vcl_ceil(m_NumberOfSamples / m_BatchSize); + const IndexValueType nBatches = std::ceil(m_NumberOfSamples / m_BatchSize); const IndexValueType rest = m_NumberOfSamples % m_BatchSize; itk::ProgressReporter progress(this, 0, nBatches); diff --git a/tools/dockerfiles/bionic.tf-r1.14.otb-develop/Dockerfile b/tools/dockerfiles/bionic.tf-r1.14.otb-develop/Dockerfile new file mode 100644 index 0000000000000000000000000000000000000000..b2281f6b0ff0217e55bb40a8287a77ccf6451e99 --- /dev/null +++ b/tools/dockerfiles/bionic.tf-r1.14.otb-develop/Dockerfile @@ -0,0 +1,170 @@ +FROM ubuntu:18.04 + +MAINTAINER Remi Cresson + +RUN apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + ca-certificates \ + curl \ + make \ + cmake \ + g++ \ + gcc \ + git \ + libtool \ + swig \ + xvfb \ + wget \ + autoconf \ + automake \ + pkg-config \ + zip \ + zlib1g-dev \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# ---------------------------------------------------------------------------- +# OTB and TensorFlow dependencies +# ---------------------------------------------------------------------------- +RUN apt-get update -y \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + freeglut3-dev \ + libboost-date-time-dev \ + libboost-filesystem-dev \ + libboost-graph-dev \ + libboost-program-options-dev \ + libboost-system-dev \ + libboost-thread-dev \ + libcurl4-gnutls-dev \ + libexpat1-dev \ + libfftw3-dev \ + libgdal-dev \ + libgeotiff-dev \ + libglew-dev \ + libglfw3-dev \ + libgsl-dev \ + libinsighttoolkit4-dev \ + libkml-dev \ + libmuparser-dev \ + libmuparserx-dev \ + libopencv-core-dev \ + libopencv-ml-dev \ + libopenthreads-dev \ + libossim-dev \ + libpng-dev \ + libqt5opengl5-dev \ + libqwt-qt5-dev \ + libsvm-dev \ + libtinyxml-dev \ + qtbase5-dev \ + qttools5-dev \ + default-jdk \ + python3-pip \ + python3-dev \ + python3-mock \ + python3-numpy \ + python3-gdal \ + python3-setuptools \ + libxmu-dev \ + libxi-dev \ + qttools5-dev-tools \ + && rm -rf /var/lib/apt/lists/* \ + && ln -s /usr/bin/python3 /usr/bin/python \ + && pip3 install pip six numpy wheel mock keras + +# ---------------------------------------------------------------------------- +# Build TensorFlow +# ---------------------------------------------------------------------------- +RUN export TF_ROOT=/work/tf \ + && mkdir -p ${TF_ROOT}/bazel \ + && cd ${TF_ROOT}/bazel \ + && wget https://github.com/bazelbuild/bazel/releases/download/0.24.1/bazel-0.24.1-installer-linux-x86_64.sh \ + && chmod +x bazel-0.24.1-installer-linux-x86_64.sh \ + && ./bazel-0.24.1-installer-linux-x86_64.sh \ + && export PATH="$PATH:$HOME/bin" \ + && cd $TF_ROOT \ + && git clone https://github.com/tensorflow/tensorflow.git \ + && cd tensorflow \ + && git checkout r1.14 \ + && echo "\n\n\n\n\n\n\n\n\n" | ./configure \ + && bazel build //tensorflow:libtensorflow_framework.so //tensorflow:libtensorflow_cc.so //tensorflow/tools/pip_package:build_pip_package \ + && bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg \ + && pip3 install $(find /tmp/tensorflow_pkg/ -type f -iname "tensorflow*.whl") \ + && ./tensorflow/contrib/makefile/build_all_linux.sh \ + && mkdir -p /work/tf/installdir/lib \ + && mkdir -p /work/tf/installdir/include \ + && cp -v bazel-bin/tensorflow/libtensorflow_cc.so /work/tf/installdir/lib \ + && cp -v bazel-bin/tensorflow/libtensorflow_framework.so /work/tf/installdir/lib \ + && cp -v tensorflow/contrib/makefile/gen/protobuf/lib/libprotobuf.a /work/tf/installdir/lib \ + && cp -v tensorflow/contrib/makefile/downloads/nsync/builds/default.linux.c++11/*.a /work/tf/installdir/lib \ + && cp -rv bazel-genfiles/* /work/tf/installdir/include/ \ + && cp -rv tensorflow/cc /work/tf/installdir/include/tensorflow/ \ + && cp -rv tensorflow/core /work/tf/installdir/include/tensorflow/ \ + && cp -rv third_party /work/tf/installdir/include/ \ + && cp -rv tensorflow/contrib/makefile/gen/protobuf/include/* /work/tf/installdir/include/ \ + && cp -rv tensorflow/contrib/makefile/downloads/eigen/Eigen /work/tf/installdir/include/ \ + && cp -rv tensorflow/contrib/makefile/downloads/eigen/unsupported /work/tf/installdir/include/ \ + && cp -rv tensorflow/contrib/makefile/downloads/eigen/signature_of_eigen3_matrix_library /work/tf/installdir/include/ \ + && cd ${TF_ROOT}/tensorflow/tensorflow/contrib/makefile/downloads/absl \ + && find absl/ -name '*.h' -exec cp --parents \{\} /work/tf/installdir/include/ \; \ + && find absl/ -name '*.inc' -exec cp --parents \{\} /work/tf/installdir/include/ \; \ + && find /work/tf/installdir/ -name "*.cc" -type f -delete + +# ---------------------------------------------------------------------------- +# Build OTB +# ---------------------------------------------------------------------------- +RUN mkdir -p /work/otb/build \ + && cd /work/otb \ + && git clone https://gitlab.orfeo-toolbox.org/orfeotoolbox/otb.git otb \ + && cd otb \ + && git checkout 0df44b312d64d6c3890b65d3790d4a17d0fd5f23 \ + && cd /work/otb/build \ + && cmake /work/otb/otb/SuperBuild \ + -DUSE_SYSTEM_BOOST=ON \ + -DUSE_SYSTEM_CURL=ON \ + -DUSE_SYSTEM_EXPAT=ON \ + -DUSE_SYSTEM_FFTW=ON \ + -DUSE_SYSTEM_FREETYPE=ON \ + -DUSE_SYSTEM_GDAL=ON \ + -DUSE_SYSTEM_GEOS=ON \ + -DUSE_SYSTEM_GEOTIFF=ON \ + -DUSE_SYSTEM_GLEW=ON \ + -DUSE_SYSTEM_GLFW=ON \ + -DUSE_SYSTEM_GLUT=ON \ + -DUSE_SYSTEM_GSL=ON \ + -DUSE_SYSTEM_ITK=ON \ + -DUSE_SYSTEM_LIBKML=ON \ + -DUSE_SYSTEM_LIBSVM=ON \ + -DUSE_SYSTEM_MUPARSER=ON \ + -DUSE_SYSTEM_MUPARSERX=ON \ + -DUSE_SYSTEM_OPENCV=ON \ + -DUSE_SYSTEM_OPENTHREADS=ON \ + -DUSE_SYSTEM_OSSIM=ON \ + -DUSE_SYSTEM_PNG=ON \ + -DUSE_SYSTEM_QT5=ON \ + -DUSE_SYSTEM_QWT=ON \ + -DUSE_SYSTEM_TINYXML=ON \ + -DUSE_SYSTEM_ZLIB=ON \ + && cd /work/otb/otb/Modules/Remote \ + && git clone https://github.com/remicres/otbtf.git \ + && cd /work/otb/build/OTB/build \ + && cmake /work/otb/otb \ + -DModule_Mosaic=ON \ + -DModule_OTBTensorflow=ON \ + -DOTB_USE_TENSORFLOW=ON \ + -Dopencv_INCLUDE_DIR=/usr/include \ + -DTENSORFLOW_CC_LIB=/work/tf/installdir/lib/libtensorflow_cc.so \ + -DTENSORFLOW_FRAMEWORK_LIB=/work/tf/installdir/lib/libtensorflow_framework.so \ + -Dtensorflow_include_dir=/work/tf/installdir/include/ \ + && cd /work/otb/build/ \ + && make -j $(grep -c ^processor /proc/cpuinfo) + +RUN echo "Create symlinks for tensorflow libs" \ + && ln -s /work/tf/installdir/lib/libtensorflow_cc.so /work/tf/installdir/lib/libtensorflow_cc.so.1 \ + && ln -s /work/tf/installdir/lib/libtensorflow_framework.so /work/tf/installdir/lib/libtensorflow_framework.so.1 + +ENV PATH "$PATH:/work/otb/superbuild_install/bin/" +ENV LD_LIBRARY_PATH "$LD_LIBRARY_PATH:/work/otb/superbuild_install/lib/:/work/tf/installdir/lib/" +ENV PYTHONPATH "$PYTHONPATH:/work/otb/superbuild_install/lib/otb/python/"