Home

Awesome

Spatial and Temporal Evaluation of Deep Generative Models in Remote Sensing

Toy experimental setup for evaluating relevance of deep generative models in remote sensing applications

Getting Started

<p align="center"> <img src="https://github.com/Cervest/ds-gan-spatiotemporal-evaluation/blob/master/docs/source/img/latent_vs_derived.png" alt="Ideal image and derived coarser one" width="1000"/> </p>

Synthetic imagery generation

Setup YAML configuration files specifying generation and derivation steps. Templates are proposed here.

Execute generation as:

$ python run_toy_generation.py --cfg=path/to/generation/config.yaml --o=path/to/latent_product
Generation |################################| 31/31

$ python run_toy_derivation.py --cfg=path/to/derivation/config.yaml --o=path/to/derived_product
Derivation |#################               | 16/31

For generation as for derivation, created frames have an instance segmentation and classification annotation masks. Explicitely, output directories are structured as:

 ├── frames/           # 1 frame = 1 time step
 │   ├── frame_0.h5
 │   ├── ...
 │   └── frame_31.h5
 ├── annotations/      # frames associated annotation masks
 │   ├── annotation_0.h5
 │   ├── ...
 │   └── annotation_31.h5
 └── index.json
<p align="center"> <img src="https://github.com/Cervest/ds-gan-spatiotemporal-evaluation/blob/master/docs/source/img/latent_product.png" alt="Ideal product and annotation masks" width="700"/> </p>

Image Translation Model training

Setup YAML configuration files specifying training : dataset, model, optimizer, experiment. Examples are proposed here.

Execute training on, say GPU 0, as:

$ python run_training.py --cfg=path/to/config.yaml --o=output/directory --device=0

Spatiotemporal Evaluation of Image Translation Model

Specify reference classifier parameters and image translation model checkpoint to evaluate in YAML file previously defined for training execution.

Execute:

$ python make_reference_classifier.py --cfg=path/to/experiment/config.yaml --o=output/directory
$ python run_testing.py --cfg=path/to/experiment/config.yaml --o=output/directory --device=0

Existing experiments

ExperimentMAEMSEPSNRSSIMSAMJaccard GeneratedJaccard GroundtruthJaccard Ratio
cGAN Cloud Removal0.2460.12917.90.6870.1740.4930.9930.496
Frame-recurrent cGAN Cloud Removal0.2000.07421.20.8250.1470.5530.9930.556
cGAN Identity0.0430.00331.80.990.0920.9800.9930.986

Score table averaged for 5 distinct seeds over testing set; "Jaccard Generated": Average Jaccard Index of reference classifier when evaluated on generated images; "Jaccard Groundtruth": Average Jaccard Index of reference classifier when evaluated on groundtruth images; "Jaccard Ratio": Jaccard Generated / Jaccard Groundtruth

Overview

Organization

The repository is structured as follows :

├── data/
├── docs/
├── repro/
├── src/
├── tests/
├── utils/
├── make_reference_classifier.py
├── run_training.py
├── run_testing.py
├── run_toy_generation.py
└── run_toy_derivation.py

Directories :


src/ directory is then subdivided into :

Synthetic data generation :

.
└── toygeneration
    ├── config/
    ├── blob/
    ├── timeserie/
    ├── modules/
    ├── derivation.py
    ├── export.py
    └── product.py

Image-translation experiments :

.
└── rsgan/
    ├── config/
    ├── callbacks/
    ├── data/
    │   └── datasets/
    ├── evaluation
    │   └── metrics/
    ├── experiments
    │   ├── cloud_removal/
    │   ├── sar_to_optical/
    │   ├── experiment.py
    │   └── utils/
    └── models/

Installation

Code implemented in Python 3.8

Setting up environment

Clone and go to repository

$ git clone https://github.com/Cervest/ds-gan-spatiotemporal-evaluation.git
$ cd ds-gan-spatiotemporal-evaluation

Create and activate environment

$ pyenv virtualenv 3.8.2 gan-eval
$ pyenv activate gan-eval
$ (gan-eval)

Install dependencies

$ (gan-eval) pip install -r requirements.txt

Setting up dvc

From the environment and root project directory, you first need to build symlinks to data directories as:

$ (gan-eval) dvc init -q
$ (gan-eval) python repro/dvc.py --link=where/data/stored --cache=where/cache/stored

if no link specified, data will be stored by default into data/ directory and default cache is .dvc/cache.

To reproduce full pipeline, execute:

$ (gan-eval) dvc repro

In case pipeline is broken, hidden bash files are provided under repro directory

References