diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 358a167cc73ac4ffc32ab8bf9420561e4ebe7c9b..20f637753f11e0bea5c2af0d4122c3481a01f271 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,5 +1,5 @@ variables: - OTBTF_VERSION: 4.2.0 + OTBTF_VERSION: 4.2.1 OTB_BUILD: /src/otb/build/OTB/build # Local OTB build directory OTBTF_SRC: /src/otbtf # Local OTBTF source directory OTB_TEST_DIR: $OTB_BUILD/Testing/Temporary # OTB testing directory @@ -282,6 +282,7 @@ deploy_gpu: IMAGE_GPUOPTDEV: $CI_REGISTRY_PUBIMG-gpu-opt-dev DOCKERHUB_GPU: $DOCKERHUB_IMAGE_BASE-gpu DOCKERHUB_GPUDEV: $DOCKERHUB_IMAGE_BASE-gpu-dev + DOCKERHUB_GPULATEST: $DOCKERHUB_BASE:latest-gpu script: # gpu-opt - docker build --build-arg BZL_OPTIONS="--remote_cache=$BAZELCACHE" --tag $IMAGE_GPUOPT --build-arg BASE_IMG=$GPU_BASE_IMG . @@ -301,5 +302,7 @@ deploy_gpu: - docker push $DOCKERHUB_GPU - docker tag $IMAGE_GPUDEV $DOCKERHUB_GPUDEV - docker push $DOCKERHUB_GPUDEV - + # latest-gpu = gpu image + - docker tag $IMAGE_GPU $DOCKERHUB_GPULATEST + - docker push $DOCKERHUB_GPULATEST diff --git a/Dockerfile b/Dockerfile index 22f9bb19560d25d23b711ad5b593152e8de288d9..b4280b2d6239b34fb306744343a668eb71a9abe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -98,7 +98,7 @@ RUN cd tensorflow \ ### OTB ARG GUI=false -ARG OTB=5086d7601d80f2427f4d4d7f2398ec46e7efa300 +ARG OTB=8.1.2 ARG OTBTESTS=false RUN mkdir /src/otb diff --git a/README.md b/README.md index 585e8022a0ec66db074e13579edcbdcbe98e7450..29b83ad5e551e357ac3ddd811f76a61696d1822a 100644 --- a/README.md +++ b/README.md @@ -33,8 +33,8 @@ The documentation is available on [otbtf.readthedocs.io](https://otbtf.readthedo You can use our latest GPU enabled docker images. ```bash -docker run --runtime=nvidia -ti mdl4eo/otbtf:4.2.0-gpu otbcli_PatchesExtraction -docker run --runtime=nvidia -ti mdl4eo/otbtf:4.2.0-gpu python -c "import otbtf" +docker run --runtime=nvidia -ti mdl4eo/otbtf:latest-gpu otbcli_PatchesExtraction +docker run --runtime=nvidia -ti mdl4eo/otbtf:latest-gpu python -c "import otbtf" ``` You can also build OTBTF from sources (see the documentation) diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt index 97a790cdd5ee6a6fc6d6896314515bb17094c38e..219aa15b5c276a007b884bde976a27828dae4580 100644 --- a/RELEASE_NOTES.txt +++ b/RELEASE_NOTES.txt @@ -1,3 +1,9 @@ +Version 4.2.1 (5 oct 2023) +---------------------------------------------------------------- +* Fix a bug occuring when input images origins were not sharing the same pixel grid +* CI to push "latest-gpu" tag on dockerhub +* Move to OTB 8.2.1 + Version 4.2.0 (12 sep 2023) ---------------------------------------------------------------- * Add new python modules: `otbtf.layers` (with new classes `DilatedMask`, `ApplyMask`, `ScalarsTile`, `ArgMax`, `Max`) and `otbtf.ops` (`one_hot()`) diff --git a/doc/docker_use.md b/doc/docker_use.md index f7b81683f0d076d36b2a2044cf704eca6286945e..1194b35e415fa0b0c618e47325d061d23fcca915 100644 --- a/doc/docker_use.md +++ b/doc/docker_use.md @@ -5,13 +5,13 @@ We recommend to use OTBTF from official docker images. Latest CPU-only docker image: ```commandline -docker pull mdl4eo/otbtf:4.2.0-cpu +docker pull mdl4eo/otbtf:latest ``` Latest GPU-ready docker image: ```commandline -docker pull mdl4eo/otbtf:4.2.0-gpu +docker pull mdl4eo/otbtf:latest-gpu ``` Read more in the following sections. @@ -25,12 +25,12 @@ Since OTBTF >= 3.2.1 you can find the latest docker images on | Name | Os | TF | OTB | Description | Dev files | Compute capability | |------------------------------------------------------------------------------------| ------------- |-------|-------| ---------------------- | --------- | ------------------ | -| **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| -| **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| -| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-cpu** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-gpu** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.1-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.1-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.1-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.2 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| The list of older releases is available [here](#older-images). @@ -51,13 +51,13 @@ You can then use the OTBTF `gpu` tagged docker images with the **NVIDIA runtime* With Docker version earlier than 19.03 : ```bash -docker run --runtime=nvidia -ti mdl4eo/otbtf:4.2.0-gpu bash +docker run --runtime=nvidia -ti mdl4eo/otbtf:latest-gpu bash ``` With Docker version including and after 19.03 : ```bash -docker run --gpus all -ti mdl4eo/otbtf:4.2.0-gpu bash +docker run --gpus all -ti mdl4eo/otbtf:latest-gpu bash ``` You can find some details on the **GPU docker image** and some **docker tips @@ -80,7 +80,7 @@ See here how to install docker on Ubuntu 1. Install [WSL2](https://docs.microsoft.com/en-us/windows/wsl/install-win10#manual-installation-steps) (Windows Subsystem for Linux) 2. Install [docker desktop](https://www.docker.com/products/docker-desktop) 3. Start **docker desktop** and **enable WSL2** from *Settings* > *General* then tick the box *Use the WSL2 based engine* -3. Open a **cmd.exe** or **PowerShell** terminal, and type `docker create --name otbtf-cpu --interactive --tty mdl4eo/otbtf:4.2.0-cpu` +3. Open a **cmd.exe** or **PowerShell** terminal, and type `docker create --name otbtf-cpu --interactive --tty mdl4eo/otbtf:latest` 4. Open **docker desktop**, and check that the docker is running in the **Container/Apps** menu  5. From **docker desktop**, click on the icon highlighted as shown below, and use the bash terminal that should pop up! @@ -172,4 +172,10 @@ Here you can find the list of older releases of OTBTF: | **mdl4eo/otbtf:4.1.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| | **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.1.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-cpu** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-cpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | CPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-gpu** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization | no | 5.2,6.1,7.0,7.5,8.6| +| **mdl4eo/otbtf:4.2.0-gpu-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU, no optimization (dev) | yes | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. | no | 5.2,6.1,7.0,7.5,8.6| +| **gitlab.irstea.fr/remi.cresson/otbtf/container_registry/otbtf:4.2.0-gpu-opt-dev** | Ubuntu Jammy | r2.12 | 8.1.0 | GPU with opt. (dev) | yes | 5.2,6.1,7.0,7.5,8.6| diff --git a/include/otbTensorflowMultisourceModelFilter.hxx b/include/otbTensorflowMultisourceModelFilter.hxx index 0f32334ce18c3ef4ad25e8a30ab9a5e614973728..4a5fd011be2db98dce129dd2f1615a1759f5d52c 100644 --- a/include/otbTensorflowMultisourceModelFilter.hxx +++ b/include/otbTensorflowMultisourceModelFilter.hxx @@ -204,6 +204,24 @@ TensorflowMultisourceModelFilter<TInputImage, TOutputImage>::GenerateOutputInfor m_OutputSpacing[0] *= m_OutputSpacingScale; m_OutputSpacing[1] *= m_OutputSpacingScale; + // Check that inputs are aligned + if (m_FullyConvolutional) + { + for (unsigned int dim = 0; dim < OutputImageType::ImageDimension; ++dim) + { + const float ref_spc = this->GetInput(0)->GetSpacing()[dim]; + const float ref = this->GetInput(0)->GetOrigin()[dim] - 0.5 * ref_spc; + for (unsigned int imageIndex = 1; imageIndex < this->GetNumberOfInputs(); imageIndex++) + { + const float orig = this->GetInput(imageIndex)->GetOrigin()[dim] - 0.5 * this->GetInput(imageIndex)->GetSpacing()[dim]; + if (ref != orig) + otbLogMacro(Warning, << "Input #" << imageIndex << " origin does not match reference (first) input"); + if (std::fmod(ref - orig, ref_spc) != 0.0) + otbLogMacro(Warning, << "Input #" << imageIndex << " pixels are not aligned with reference (first) input"); + } // next input + } // next dim + } + // Compute the extent of each input images and update the extent or the output image. // The extent of the output image is the intersection of all input images extents. PointType extentInf, extentSup; @@ -226,6 +244,28 @@ TensorflowMultisourceModelFilter<TInputImage, TOutputImage>::GenerateOutputInfor } } + if (m_FullyConvolutional) + { + // Align extent over inputs pixel grid, so that the extent lies on the + // common pixel grid of all inputs. + // When this can't be done (i.e. shifted origins), a bug is likely to occur. + // However the warning issued previously should give a hint about the issue. + PointType alignedExtentInf, alignedExtentSup; + alignedExtentSup.Fill(itk::NumericTraits<double>::max()); + alignedExtentInf.Fill(itk::NumericTraits<double>::NonpositiveMin()); + for (unsigned int imageIndex = 0; imageIndex < this->GetNumberOfInputs(); imageIndex++) + for (unsigned int dim = 0; dim < OutputImageType::ImageDimension; ++dim) + { + const double spc = this->GetInput(imageIndex)->GetSpacing()[dim]; + const double ref = this->GetInput(imageIndex)->GetOrigin()[dim] - 0.5 * spc; + const double alignedInf = std::ceil((extentInf[dim] - ref) / spc) * spc + ref; + const double alignedSup = std::floor((extentSup[dim] - ref) / spc) * spc + ref; + alignedExtentInf[dim] = vnl_math_max(alignedInf, alignedExtentInf[dim]); + alignedExtentSup[dim] = vnl_math_min(alignedSup, alignedExtentSup[dim]); + } + extentInf = alignedExtentInf; + extentSup = alignedExtentSup; + } // Set final origin, aligned to the reference image grid. // Here we simply get back to the center of the pixel (extents are pixels corners coordinates) diff --git a/setup.py b/setup.py index 3222afc47e5bf2ea646222d7c6926412a4b300ed..e2ac3e5cf5592c42c1a6164beea990e38ea3faea 100644 --- a/setup.py +++ b/setup.py @@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh: setuptools.setup( name="otbtf", - version="4.2.0", + version="4.2.1", author="Remi Cresson", author_email="remi.cresson@inrae.fr", description="OTBTF: Orfeo ToolBox meets TensorFlow", diff --git a/tools/docker/build-flags-otb.txt b/tools/docker/build-flags-otb.txt index 95b8462cbc851ebf38c4b3a0c85d1e5b22f5e594..f72d7c7b2bb1bec6dfa6ffc9cc2991c87263e87e 100644 --- a/tools/docker/build-flags-otb.txt +++ b/tools/docker/build-flags-otb.txt @@ -17,3 +17,12 @@ -DUSE_SYSTEM_TINYXML=ON -DUSE_SYSTEM_ZLIB=ON -DUSE_SYSTEM_SWIG=ON + +-DOTB_USE_QT=OFF +-DOTB_USE_OPENGL=OFF +-DOTB_USE_GLUT=OFF +-DOTB_USE_GLEW=OFF +-DOTB_USE_GLFW=OFF + +-DGDAL_SB_EXTRA_OPTIONS=--with-geos +