/DeepMoon

Convolutional neural network code for extracting Lunar craters from Digital Elevation Maps (DEMs).

Primary LanguagePythonMIT LicenseMIT

DeepMoon - Lunar Crater Counting Through Deep Learning

Center for Planetary Sciences / Department of Astronomy & Astrophysics / Canadian Institute for Theoretical Astrophysics University of Toronto

DeepMoon is a TensorFlow-based pipeline for training a convolutional neural network (CNN) to recognize craters on the Moon, and determine their positions and radii. It is the companion repo to the paper Lunar Crater Identification via Deep Learning, which describes the motivation and development of the code, as well as results.

Getting Started

Overview

The DeepMoon pipeline trains a neural net using data derived from a global digital elevation map (DEM) and catalogue of craters. The code is divided into three parts. The first generates a set images of the Moon randomly cropped from the DEM, with corresponding crater positions and radii. The second trains a convnet using this data. The third validates the convnet's predictions.

To first order, our CNN activates regions with high negative gradients, i.e. pixels that decrease in value as you move across the image. Below illustrates two examples of this, the first is a genuine DEM Lunar image from our dataset, the second is a sample image taken from the web. CNN1 CNN2

Dependences

DeepMoon requires the following packages to function:

  • Python version 2.7 or 3.5+
  • Cartopy >= 0.14.2. Cartopy itself has a number of dependencies, including the GEOS and Proj.4.x libraries. (For Ubuntu systems, these can be installed through the libgeos++-dev and libproj-dev packages, respectively.)
  • h5py >= 2.6.0
  • Keras 1.2.2 (documentation); also tested with Keras >= 2.0.2
  • Numpy >= 1.12
  • OpenCV >= 3.2.0.6
  • pandas >= 0.19.1
  • Pillow >= 3.1.2
  • PyTables >=3.4.2
  • TensorFlow 0.10.0rc0, also tested with TensorFlow >= 1.0

This list can also be found in the requirements.txt.

Data Sources

Our train, validation and test datasets, global DEM, post-processed crater distribution on the test set, best model, and sample output images can be found on Zenodo.

Examples of how to read these data can be found in the docs/Using Zenodo Data.ipynb IPython notebook.

Digital Elevation Maps

We use the LRO-Kaguya merged 59 m/pixel DEM. The DEM was downsampled to 118 m/pixel and converted to 16-bit GeoTiff with the USGS Astrogeology Cloud Processing service, and then rescaled to 8-bit PNG using the GDAL library:

gdal_translate -of PNG -scale -21138 21138 -co worldfile=no 
    LunarLROLrocKaguya_118mperpix_int16.tif LunarLROLrocKaguya_118mperpix.png

Crater Catalogues

For the ground truth longitude / latitude locations and sizes of craters, we combine the LROC Craters 5 to 20 km diameter dataset with the Head et al. 2010 >= 20 km diameter one (alternate download link). The LROC dataset was converted from ESRI shapefile to .csv. They can be found under the catalogues folder of the repo, and have had their formatting slightly modified to be read into pandas.

During initial testing, we also used the Salamunićcar LU78287GT catalogue.

Running DeepMoon

Each stage of DeepMoon has a corresponding script: run_input_data_gen.py for generating input data, run_model_training.py to build and train the convnet, and run_get_unique_craters.py to validate predictions and generate a crater atlas. User-defined parameters, and instructions on on how to use each script, can be found in the scripts themselves.

We recommend copying these scripts into a new working directory (and appending this repo to your Python path) instead of modifying them in the repo.

Our model with default parameters was trained on a 16GB Tesla P100 GPU, however 12GB GPUs are more standard. Therefore, our default model may not run on many systems without reducing the batch size, number of filters, etc., which can affect final model convergence.

Quick Usage

See docs/Using Zenodo Data.ipynb for basic examples on generating sample datasets, loading a pre-trained CNN and using it to make predictions on samples.

Authors

  • Ari Silburt - convnet architecture, crater extraction and post-processing silburt
  • Charles Zhu - input image generation, data ingestion and post-processing cczhu

Contributors

License

Copyright 2018 Ari Silburt, Charles Zhu and contributors.

DeepMoon is free software made available under the MIT License. For details see the LICENSE.md file.