Giter Club home page Giter Club logo

lstm-sentinel2-landcover's Introduction

GitHub DOI

Code for Deep Learning for Land Cover Change Detection

This repo contains the code for the pre-processing, model training, and classification evaluation described in the article Deep Learning for Land Cover Change Detection. Using a land cover vector ground truth (GT) and freely available Sentinel-2 imagery, we train different neural network classifiers. We employ a U-Net based fully convolutional network (FCN) as a base model and present a method of adding a convolutional LSTM cell to make predictions on sequences of satellite images. This LSTM approach shows significant improvements on seasonally varying classes such as grassland or farmland. Other contributions include an approach to mask inconsistent water shorelines based on the NDWI and a method to prevent the exclusion of incomplete image tiles with a specially weighted loss function.

License: 3-Clause BSD license

Authors:

Citation: See citation and bibliography.bib.

Content

  1. Python Environment Setup
  2. Data Placement
  3. Pre-Processing
  4. Model Training
  5. Evaluation Metrics
  6. Citation

Python Environment Setup

To set up the Python environment, execute

  1. conda create -n n_env python=3.7 pip
  2. conda activate n_env
  3. pip install -r requirements.txt
  4. conda install --yes --file requirements_conda.txt (we recommend installing GDAL and Rasterio via conda)

Data Placement

  • Sentinel-2 images: data/raw/sentinel/
  • Ground Truth (GT) shapefile: data/raw/ground_truth/gt_shapefile/
  • shapefile of area of interest (AOI) = shape of GT as shapefile: data/raw/ground_truth/overallshape/

Pre-Processing

All pre-processing functionality is in src/data_processing/. The main features are:

  • clipping of Sentinel-2 image to the AOI (01_clip_sentinel.sh)
  • rasterization of the GT shapefile (02_rasterize_shapefile.sh)
  • creation of training data by merging image and GT (04_merge_tifs.sh)
  • creation of prediction data by merging image and AOI GeoTIFF file (04_merge_tifs.sh)
  • Tile Splitting to accomodate FCN structure

Model Training

Example models are in src/models/, the data generators used for training are in src/helpers/image_functions.py.

  • baseline_cnn.py is a simple FCN that trains on single images at a time (i.e. no sequences). It can be used as a pretrained base model for the LSTM models, as shown in e.g. lstm_fixed_seq.py.
  • lstm_fixed_seq.py is a FCN+LSTM that trains with sequences of images, however the images that build the sequence are fixed (``.
  • lstm_random_seq.py is also a FCN+LSTM that randomly builds a new sequence of images for each training batch.

Trained models are saved in models/. Tensorboard logs are saved in separate subdirectories of reports/logs/; this way they can be called via tensorboard --logdir=reports/logs (when in main directory).

Evaluation Metrics

To get the accuracy scores and the confusion matrix of a model, execute python metrics.py MODEL_NAME with MODEL_NAME being the filename of a model saved in the models directory (without .h5 file ending).

For easy use, model names should follow the name convention:

If the model uses temporal sequences as input data, the name must contain 'lstm'.
If it uses non-sequence input, the name should not contain 'lstm'.

An easy way to evaluate a model right after training is to add the function call get_metrics_and_cm($model_name) to the end of the training script. For this to work, the function should be imported as follows:

import sys
sys.path.append('../visualization')
from metrics import get_metrics_and_cm

Citation

Code:

@misc{sefrin2020code,
    author = {Sefrin, Oliver and Riese, Felix~M. and Keller, Sina},
    title = {{Code for Deep Learning for Land Cover Change Detection}},
    year = {2020},
    publisher = {Zenodo},
    doi = {10.5281/zenodo.4289079},
}

Paper:

Sefrin, Oliver; Riese, Felix M.; Keller, Sina. 2021. "Deep Learning for Land Cover Change Detection" Remote Sens. 13, no. 1: 78.

@article{sefrin2021deep,
    author = {Sefrin, Oliver and Riese, Felix~M. and Keller, Sina},
    title = {{Deep Learning for Land Cover Change Detection}},
    journal = {Remote Sensing},
    year = {2021},
    volume = {13},
    number = {1},
    article-number = {78},
    DOI = {10.3390/rs13010078 },
    publisher={Multidisciplinary Digital Publishing Institute},
}

lstm-sentinel2-landcover's People

Contributors

felixriese avatar oliversefrin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.