/dem-fill

Void Filling of Digital Elevation Models with Deep Generative Models

Primary LanguagePythonOtherNOASSERTION

Void Filling of Digital Elevation Models with Deep Generative Models

This GitHub repository implements and evaluates the method described in the paper [1], which is an adaptation to the context of Digital Elevation Models (DEMs) from the method DeepFill described in [2]. In addition pre-trained models are provided, as well as the DEMs used for the evaluation of the method.

[1] K. Gavriil, O.J.D. Barrowclough, G. Muntingh, Void Filling of Digital Elevation Models with Deep Generative Models, available on the ArXiv.

[2] J. Yu, Z. Lin, J. Yang, X. Shen, X. Lu, and T. S. Huang, Generative image inpainting with contextual attention, in The IEEE Conference on Computer Vision and Pattern Recognition (CVPR), June 2018.


Selection of results of the DeepDEMFill void filling method for Digital Elevation Models.


Setup

  • Install python3.
  • Install tensorflow (tested on Release 1.3.0, 1.4.0, 1.5.0, 1.6.0, 1.7.0).
  • Install tensorflow toolkit neuralgym (run pip install git+https://github.com/konstantg/neuralgym).
  • Clone the repository git clone https://github.com/konstantg/dem-fill.git

Other dependencies: opencv-python, PyYAML

Testing pretrained models

Norway Landscape | Norway Cities

Download the desired model(s), create a model_logs/ directory in the dem-fill/ directory and extract the zip folder there. Specifically, to run the examples below, the extracted files (checkpoint etc.) should be in either the model_logs/norway_land/ or the model_logs/norway_cities/ directory respectively.

Model norway_land was trained on 10m-resolution DEMs of Western and Eastern Norway while norway_cities was trained on 2m-resolution DEMs of the three largest cities in Norway, namely Oslo, Trondheim, and Bergen. The input in both cases are DEMs of size 256x256. The size of the void ranges from 64x64 up to 128x128 (not necessarily rectangular) and is randomly placed over the DEM.

To run:

# Norway Landscape
python test.py --image data/land01.tif --mask data/land01mask.png --output data/land01out.tif --checkpoint_dir model_logs/norway_land/

# Norway Cities
python test.py --image data/city01.tif --mask data/city01mask.png --output data/city01out.tif --checkpoint_dir model_logs/norway_cities/

Note: If you do not have a TIF viewer, IrfanView is recommended for Windows.

Results

We compared our results with two other void-filling methods, namely inverse distance weighting (solution provided by gdal_fillnodata.py) and LR B-spline interpolation. The 50 random urban and 50 random rural DEMs, along with the randomly generated masks and the void-filling results, used in the comparison can be downloaded here.

Training

For training on your DEMs, please modify accordingly the data_from_fnames.py file from the installed neuralgym package to accept your files. For example, it was more efficient to use an h5py data structure to store and sample the Norway landscape dataset, while for the Norway cities dataset we preload the Oslo, Bergen and Trondheim DEMs to memory for sampling. Please refer to the data_from_fnames.py file for these examples.

  1. Training:
    • Modify the data data_from_fnames.py file accordingly.
    • Modify inpaint.yml to set LOG_DIR, IMG_SHAPES and other parameters.
    • Run python train.py.
  2. Resume training:
    • Modify MODEL_RESTORE flag in inpaint.yml. E.g., MODEL_RESTORE: 20181119115621405562_norway_cities.
    • Run python train.py.
  3. Testing:
    • Run python test.py --image examples/input.tif --mask examples/mask.png --output examples/output.tif --checkpoint model_logs/your_model_dir.

License

CC 4.0 Attribution-NonCommercial International

The software is for educational and academic research purpose only.

Acknowledgements

We adapted the GitHub repository generative_inpainting to the setting of Digital Elevation Models. The open source C++ library GoTools was used for generating the LR B-spline data. Data provided courtesy Norwegian Mapping Authorities (www.hoydedata.no), copyright Kartverket (CC BY 4.0). This project has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No 675789. This projected was also supported by an IKTPLUSS grant, project number 270922, from the Research Council of Norway.

Citing

@article{1811.12693,
author = {Konstantinos Gavriil and Georg Muntingh and Oliver J. D. Barrowclough},
title = {Void Filling of Digital Elevation Models with Deep Generative Models},
year = {2018},
eprint = {arXiv:1811.12693},
}