Skip to content

Commit

Permalink
Merge branch '29-add-a-model-class-in-otbtf' into 'develop'
Browse files Browse the repository at this point in the history
Resolve "Add a Model class in OTBTF"

Closes #18 and #29

See merge request remi.cresson/otbtf!51
  • Loading branch information
Cresson Remi committed Jul 28, 2022
2 parents 04a33ef + 316cf27 commit 01d13b0
Show file tree
Hide file tree
Showing 22 changed files with 969 additions and 163 deletions.
38 changes: 24 additions & 14 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
image: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME

variables:
OTBTF_VERSION: 3.2.1
OTBTF_VERSION: 3.3.0
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
ARTIFACT_TEST_DIR: $CI_PROJECT_DIR/testing
CRC_BOOK_TMP: /tmp/crc_book_tests_tmp
API_TEST_TMP: /tmp/api_tests_tmp
DATADIR: $CI_PROJECT_DIR/test/data
DOCKER_BUILDKIT: 1
DOCKER_DRIVER: overlay2
CACHE_IMAGE_BASE: $CI_REGISTRY_IMAGE:otbtf-base
CACHE_IMAGE_BUILDER: $CI_REGISTRY_IMAGE:builder
BRANCH_IMAGE: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
DEV_IMAGE: $CI_REGISTRY_IMAGE:cpu-basic-dev-testing
CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE/$OTBTF_VERSION
DOCKERHUB_IMAGE_BASE: mdl4eo/otbtf${OTBTF_VERSION}
CI_REGISTRY_PUBIMG: $CI_REGISTRY_IMAGE:$OTBTF_VERSION
DOCKERHUB_IMAGE_BASE: mdl4eo/otbtf:${OTBTF_VERSION}

workflow:
rules:
Expand Down Expand Up @@ -140,7 +142,7 @@ crc_book:
extends: .applications_test_base
script:
- mkdir -p $CRC_BOOK_TMP
- TMPDIR=$CRC_BOOK_TMP DATADIR=$CI_PROJECT_DIR/test/data python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml $OTBTF_SRC/test/tutorial_unittest.py
- TMPDIR=$CRC_BOOK_TMP python -m pytest --junitxml=$CI_PROJECT_DIR/report_tutorial.xml $OTBTF_SRC/test/tutorial_unittest.py
after_script:
- cp $CRC_BOOK_TMP/*.* $ARTIFACT_TEST_DIR/

Expand All @@ -157,6 +159,14 @@ sr4rs:
- export PYTHONPATH=$PYTHONPATH:$PWD/sr4rs
- python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_sr4rs.xml $OTBTF_SRC/test/sr4rs_unittest.py

otbtf_api:
extends: .applications_test_base
script:
- mkdir $API_TEST_TMP
- TMPDIR=$API_TEST_TMP python -m pytest --junitxml=$ARTIFACT_TEST_DIR/report_api.xml $OTBTF_SRC/test/api_unittest.py
after_script:
- cp $API_TEST_TMP/*.* $ARTIFACT_TEST_DIR/

deploy_cpu-dev-testing:
stage: Update dev image
extends: .docker_build_base
Expand All @@ -176,10 +186,10 @@ deploy_cpu-dev-testing:
deploy_cpu:
extends: .ship base
variables:
IMAGE_CPU: $CI_REGISTRY_PUBIMG:cpu
IMAGE_CPUDEV: $CI_REGISTRY_PUBIMG:cpu-dev
DOCKERHUB_CPU: $DOCKERHUB_IMAGE_BASE:cpu
DOCKERHUB_CPUDEV: $DOCKERHUB_IMAGE_BASE:cpu-dev
IMAGE_CPU: $CI_REGISTRY_PUBIMG-cpu
IMAGE_CPUDEV: $CI_REGISTRY_PUBIMG-cpu-dev
DOCKERHUB_CPU: $DOCKERHUB_IMAGE_BASE-cpu
DOCKERHUB_CPUDEV: $DOCKERHUB_IMAGE_BASE-cpu-dev
script:
# cpu
- docker build --network='host' --tag $IMAGE_CPU --build-arg BASE_IMG=ubuntu:20.04 --build-arg BZL_CONFIGS="" .
Expand All @@ -197,12 +207,12 @@ deploy_cpu:
deploy_gpu:
extends: .ship base
variables:
IMAGE_GPU: $CI_REGISTRY_PUBIMG:gpu
IMAGE_GPUDEV: $CI_REGISTRY_PUBIMG:gpu-dev
IMAGE_GPUOPT: $CI_REGISTRY_PUBIMG:gpu-opt
IMAGE_GPUOPTDEV: $CI_REGISTRY_PUBIMG:gpu-opt-dev
DOCKERHUB_GPU: $DOCKERHUB_IMAGE_BASE:gpu
DOCKERHUB_GPUDEV: $DOCKERHUB_IMAGE_BASE:gpu-dev
IMAGE_GPU: $CI_REGISTRY_PUBIMG-gpu
IMAGE_GPUDEV: $CI_REGISTRY_PUBIMG-gpu-dev
IMAGE_GPUOPT: $CI_REGISTRY_PUBIMG-gpu-opt
IMAGE_GPUOPTDEV: $CI_REGISTRY_PUBIMG-gpu-opt-dev
DOCKERHUB_GPU: $DOCKERHUB_IMAGE_BASE-gpu
DOCKERHUB_GPUDEV: $DOCKERHUB_IMAGE_BASE-gpu-dev
script:
# gpu-opt
- docker build --network='host' --tag $IMAGE_GPUOPT --build-arg BASE_IMG=nvidia/cuda:11.2.2-cudnn8-devel-ubuntu20.04 .
Expand Down
17 changes: 12 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# OTBTF: Orfeo ToolBox meets TensorFlow

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
[![pipeline status](https://gitlab.irstea.fr/remi.cresson/otbtf/badges/develop/pipeline.svg)](https://gitlab.irstea.fr/remi.cresson/otbtf/-/commits/develop)
[![pipeline status](https://gitlab.irstea.fr/remi.cresson/otbtf/badges/master/pipeline.svg)](https://gitlab.irstea.fr/remi.cresson/otbtf/-/commits/develop)

This remote module of the [Orfeo ToolBox](https://www.orfeo-toolbox.org) provides a generic, multi purpose deep learning framework, targeting remote sensing images processing.
It contains a set of new process objects that internally invoke [Tensorflow](https://www.tensorflow.org/), and a bunch of user-oriented applications to perform deep learning with real-world remote sensing images.
Expand All @@ -19,9 +19,12 @@ Applications can be used to build OTB pipelines from Python or C++ APIs.

### Python

`otbtf.py` targets python developers that want to train their own model from python with TensorFlow or Keras.
The `otbtf` module targets python developers that want to train their own model from python with TensorFlow or Keras.
It provides various classes for datasets and iterators to handle the _patches images_ generated from the `PatchesExtraction` OTB application.
For instance, the `otbtf.Dataset` class provides a method `get_tf_dataset()` which returns a `tf.dataset` that can be used in your favorite TensorFlow pipelines, or convert your patches into TFRecords.
For instance, the `otbtf.DatasetFromPatchesImages` can be instantiated from a set of _patches images_
and delivering samples as `tf.dataset` that can be used in your favorite TensorFlow pipelines, or convert your patches into TFRecords.
The `otbtf.TFRecords` enables you train networks from TFRecords files, which is quite suited for
distributed training. Read more in the [tutorial for keras](otbtf/examples/tensorflow_v2x/fcnn/README.md).

`tricks.py` is here for backward compatibility with codes based on OTBTF 1.x and 2.x.

Expand All @@ -36,6 +39,10 @@ Below are some screen captures of deep learning applications performed at large

![Super resolution](https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/supresol.png)

- Sentinel-2 reconstruction with Sentinel-1 VV/VH with the [Decloud software](https://github.com/CNES/decloud), which is based on OTBTF

![Decloud](https://github.com/CNES/decloud/raw/master/doc/images/cap2.jpg)
-
- Image to image translation (Spot-7 image --> Wikimedia Map using CGAN. So unnecessary but fun!)

![Pix2pix](https://gitlab.irstea.fr/remi.cresson/otbtf/-/raw/develop/doc/images/pix2pix.png)
Expand All @@ -46,9 +53,9 @@ For now you have two options: either use the existing **docker image**, or build

### Docker

Use the latest image from dockerhub:
Use the latest CPU or GPU-enabled image from dockerhub:
```
docker run mdl4eo/otbtf3.1:cpu-basic otbcli_PatchesExtraction -help
docker run mdl4eo/otbtf:3.3.0-cpu otbcli_PatchesExtraction -help
```

Read more in the [docker use documentation](doc/DOCKERUSE.md).
Expand Down
10 changes: 10 additions & 0 deletions RELEASE_NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
Version 3.3.0 (27 jul 2022)
----------------------------------------------------------------
* Improves the `dataset` classes (`DatasetFromPatchesImages`, `TFRecords`) to use them easily in keras
* Add the `ModelBase` class, which eases considerably the creation of deep nets for Keras/TF/TensorflowModelServe
* Add an example explaining how to use python classes to build and train models with Keras, and use models in OTB.
* Document the python API (`otbtf.dataset`, `otbtf.tfrecords`, `otbtf.ModelBase`)
* Test the python API in the CI, using the (XS, labels) patches of the Amsterdam dataset from CRC book
* Upgrade OTB to version 8.0.1
* Upgrade GDAL to version 3.4.2

Version 3.2.1 (1 jun 2022)
----------------------------------------------------------------
* Changing docker images naming convention (cpu/gpu-basic* --> cpu/gpu*, cpu/gpu* --> cpu/gpu-opt*) + only images without optimizations are pushed on dockerhub
Expand Down
Loading

0 comments on commit 01d13b0

Please sign in to comment.