Giter Club home page Giter Club logo

ml_worldcup_2's Introduction

Satellite Image Segmentation with Convolutional Neural Networks

This repository contains the code and report produced by our team for the project 2 of the Machine Learning course at EPFL in 2018. It uses a modified UNet to do a road segmentation.

Our best result on crowd.ai is done with the username Mare, submission id: 25240

Detailed image of the UNet architecture

Table of Contents

Team Members

  • Marijana Peti
  • Loïc Wisniewski
  • Christophe Minutolo

Environment

As training a deep learning model takes a long time and needs powerful computers, we decided to use Google Colab to run our algorithms. We used the GPU runtime to accelerate the learning process. Moreover all useful libraries for deep learning are already available on Google Colab.

To reproduce results of this repository, you will have to put all the repository in Google Drive then run in Google Colab this:

from google.colab import drive
drive.mount('/content/drive')
%cd "your_path" # Path to your project folder in Google Drive
%pwd

Do not forget to set the accelerator on GPU in the runtime configuration of Google Colab. You will have to put in "your_path"/data/test_set_images all images from the test set (they should not have to be in sub-folders). You also have to put the saved weights in "your_path"/model_weights.hdf5. This weights are available here.

Once done, you can run in Google Colab this code:

from keras_prototyping import *
load_model_and_create_submission_file("./model_weights.hdf5", "./results.csv")

Or if you want to run it on your computer, you can just launch run.py in Google Colab with the command !python run.py

It will output predictions in "your_path"/results.csv.


If you want to recreate the model from scratch, you will have to download the training files available on crowd.ai. Put images from 001 to 090 in the "your_path"/data/training/train/images and respective groundtruth in folder "your_path"/data/training/train/groundtruth. Put the rest in "your_path"/data/training/validation/images and "your_path"/data/training/validation/groundtruth. Then you will be able to proceed to data augmentation and run the model generation:

from keras_prototyping import *
import datatools
datatools.generate_files()
usage_example()
load_model_and_create_submission_file("./model_weights.hdf5", "./results.csv")

It will output the weight in "your_path"/model_weights.hdf5

Libraries

This project use the following libraries:

  • Keras
  • TensorFlow
  • matplotlib
  • numpy
  • PIL
  • skimage

Technical problems

On Google Cloud as memory is limited, we ofter had many OOM errors. To reduce memory consumption, we decided to do all the data-augmentation before starting the training, and save all augmentation in the training folder. Once done we were able to write a custom data generator that gives to Keras data incrementally to avoid to fill the memory that are not useful for now. You can check in the code in datatools.py the function custom_image_generator.

Structure

  • keras_prototyping.py contains all the main function to launch models easily.
  • plotting.py contains plot functions, transformations from mask to images and from CSV to mask.
  • models.py contains the UNet models and some try to implement transfer learning.
  • losses.py contains all loss function (Dice, BCE + Loss) and monitor functions (Accuracy, F1 Score).
  • datatools.py contains function to do data augmentation.
  • submission.py contains functions to create CSV.

ml_worldcup_2's People

Contributors

lpwisniewski avatar marijana23 avatar minutolc 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.