Giter Club home page Giter Club logo

roadnetworkextraction-movehack's Introduction

Road Network Extraction using Satellite Imagery

MoveHack Global Mobility Hackathon 2018

Results of the implemented system on one of the Massachusetts Road Dataset test set image

Original Image Mask generated by the system Mask overlaid on original

Table of Contents

  1. About
  2. Massachusetts Roads Dataset Summary
  3. Installation
  4. Quick start
  5. Build on Google Colab
  6. References

About

In this work, we implement the U-Net segmentation architecture on the Mnih et. al. Massachusetts Roads Dataset for the task of road network extraction. The trained network achieves a mask accuracy of 95% on the test set. The network was trained on AWS P2.x instance. Inference time on a single K80 Tesla GPU(AWS P2.x instance) is 0.28 seconds and on CPU is 6 seconds.

Massachusetts Roads Dataset Summary

The Massachusetts Roads Dataset by Mnih et. al. is freely available at here. There is also a torrent link available here.

Description Size Files
mass_roads/train 9.5GB 1108
mass_roads/valid 150MB 14
mass_roads/test 450MB 49

Installation

NOTE: In case the installation does work as expected, move to Build on Google Colab to try the project without installing locally.

The following installation has been tested on MacOSX 10.13.6 and Ubuntu 16.04. (This project requires Python 3.6 and Conda which is an open source package management system and environment management system that runs on Windows, macOS and Linux. Before starting, make sure both are installed or follow the instructions below.)

Install Conda(A normal verification step would ask whether you would want to install Anaconda. Type yes so that the installation continues.)

chmod 777 conda.sh
./conda.sh
  1. Clone the repo
git clone https://github.com/akshaybhatia10/RoadNetworkExtraction-MoveHack.git
cd RoadNetworkExtraction-MoveHack/
  1. The project requires the fastai library. To install it, simply run the setup.sh script. (OPTIONAL: The default installation is for CPU. To install for GPU, in setup.sh file, change line 5 i.e conda env update -f environment-cpu.yml to conda env update.)
chmod 777 setup.sh
./setup.sh

This might take some time.

If for some reason fastai does not install/compile, install it using command(or follow here):

pip install fastai

Finally if using CPU version, run:

source activate fastai-cpu

For GPU version, run:

source activate fastai

To train the network, proceed with step 3 and then Quick start. To test using the pretrained model, simply skip to Quick start.

  1. Download the dataset from here or here. It is recommended to download the dataset using the torrent link since it downloads the files in the appropriate directories.

Quick start

You have 2 options-

Train

  1. To train the U-NET architecture on the dataset, make sure to download the dataset and follow the repo structure as:

The repo structure should be as follows:

RoadNetworkExtraction-MoveHack
|_ mass_roads/
|  |_ train/
|  |  |_sat/
|  |  |  |img1.tiff
|  |  |  |img2.tiff
|  |  |  |......
|  |  |_map/
|  |  |  |img2.tif
|  |  |  |img2.tif
|  |  |  |......
|  |_ valid/
|  |  |_sat/
|  |  |  |img1.tiff
|  |  |  |img2.tiff
|  |  |  |......
|  |  |_map/
|  |  |  |img2.tif
|  |  |  |img2.tif
|  |  |  |......
|  |_ test/
|  |  |_sat/
|  |  |  |img1.tiff
|  |  |  |img2.tiff
|  |  |  |......
|  |  |_map/
|  |  |  |img2.tif
|  |  |  |img2.tif
|  |  |  |......
|_ fastai
|_ dataset.py
|_ model.py
|_ models/
|_ ....
|_ (other files)

Now, start training with the following command- (NOTE: This will first set up the necessary folders and convert .tiff files to png and save them. Then it will start trained the u-net architecture for num_epochs(default is 1) and with cycle_len(default is 4). The trained model will be saved to the models/ directory. and achieves a mask accuracy of 95% on test set.)

python main.py --mode train

usage: main.py  [--data_dir] [--learning_rate] [--mode]
                [--model_dir] [--num_epoch] [--build_dataset] [--cycle_len]
                [--test_img]

Arguments:
  --data_dir		 Path to the dataset(REQUIRED if mode is train, DEFAULT mass_roads/)
  --build_dataset	 If True, builds dataset from .tiff files i.e converts and resizes images to 1024 and stores in 'mass_roads_new/'(DEFAULT True)
  --mode 	    	 One of train or test(DEFAULT test)
  --learning_rate        learning rate(OPTIONAL, DEFAULT 0.1)
  --model_dir            Path to save model files(OPTIONAL, DEFAULT models)
  --test_img             Path to test image for inference(OPTIONAL, DEFAULT test_images/10378780_15.png)
  --num_epoch            number of epochs(OPTIONAL, DEFAULT 1)
  --cycle_len            cycle length(OPTIONAL, DEFAULT 4)

The trained model will be saved in the models directory with the name '1024-Mnih-own'.

Test

  1. To run inference using the trained model available in the models directory(with mask accuracy score of 95%), run the following-
python main.py --mode test --test_img test_images/10378780_15.png

Change --test_img to path/to/image to run inference on other image.

This will output 3 different images in the current working directory- a 1024x1024 version of original image, 1024x1024 generated mask image(output of the system), 1024x1024 mask overlayed on original image.

Build on Google Colab

Google Colab lets us build the project without installing it locally. Simply check out the colab notebook for the project here. Installation of some libraries may take some time depending on your internet connection.

To get started, open the notebook in playground mode and run the cells(You must be logged in with your google account and provide additional authorization). To train, follow with Quick start.

References

  • Olaf Ronneberger, Philipp Fischer, Thomas Brox. U-Net: Convolutional Networks for Biomedical Image Segmentation. Medical Image Computing and Computer-Assisted Intervention (MICCAI), Springer. 2015.
  • Volodymyr Mnih. Machine Learning for Aerial Image Labeling. University of Toronto. 2013.
  • Jeremy Howard and others. fastai. GitHub. 2018.

roadnetworkextraction-movehack's People

Contributors

akshaybhatia10 avatar

Watchers

James Cloos 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.