Coder Social home page Coder Social logo

geoyi / pixel-decoder Goto Github PK

View Code? Open in Web Editor NEW
78.0 6.0 18.0 2.9 MB

A tool for running deep learning algorithms for semantic segmentation with satellite imagery

License: MIT License

Python 97.37% Dockerfile 2.63%
satellite-imagery deep-learning segmentation computervision nerual-network nvidia-docker encoder-decoder pixel-decoder unet labelmaker

pixel-decoder's Introduction

Pixel Decoder

computervision In computer vision, there are three challenges: image classification, object detection and semantic segmentation. As you see above, semantic segmentation can segment an image into different parts and objects (e.g.grass, cat, tree, sky).

Pixel Decoder is a tool that contains several current available semantic segmentation algorithms. Pixel Decoder includes Standard Unet and its modified versions, Tiramisu and SegNet. SegNet is the algorithm that Skynet was built on. All the algorithms that live inside Pixel Decoder are convolutional neural networks are all in a structure that called encoder-decoder. encoder-decoder The encoder reads in the image pixels and compresses the information in vector, downsample to save computing memory; and the decoder works on reconstructing the pixels spatial information and output the desired outcome. Some UNet-like algorithms were adopted from SpaceNet challenge solutions.

All these algorithms are built with Tensorflow and Keras. These are some results for road segmentation from Pixel Decoder we got.

### Installation
git clone https://github.com/Geoyi/pixel-decoder
cd pixel-decoder
pip install -e .

Train

pixel_decoder train --batch_size=4 \
                    --imgs_folder=tiles \
                    --masks_folder=labels \
                    --models_folder=trained_models_out \
                    --model_id=resnet_unet \
                    --origin_shape_no=256 \
                    --border_no=32

It takes in the training dataset that created from Label Maker.

  • batch_size: batch size for the training;
  • imgs_folder: is the directory for RGB images to train;
  • masks_folder: is the directory for labeled mask to train;
  • model_id: is the neural net architecture to train with. We have - resnet_unet, inception_unet, linknet_unet, SegNet, Tiramisu as model_id live in Pixel Decoder.
  • origin_shape_no: 256 is the default image tile shape from Label Maker;
  • border_no: it's set to 32. It's a additional 32 pixel to add on 256 by 256 image tile to become 320 by 320 to get rid of U-Net's edge distortion.

Predict

After the model is trained and you see a trained model weight in your model directory, run:

pixel_decoder predict --imgs_folder=tiles \
                    --test_folder=test_images \
                    --models_folder=trained_models_out \
                    --pred_folder=predictions \
                    --model_id=resnet_unet \
                    --origin_shape_no=256 \  
                    --border_no=32
  • imgs_folder: is the directory for RGB images to train;
  • masks_folder: is the directory for labeled mask to train. It uses to get the stats, e.g. mean and standard deviation, from training images.
  • test_folder: is the directory for test images.
  • pred_folder: a directory that saved all the predicted test image from test_folder;
  • model_id: is the neural net architecture to train with. We have - resnet_unet, inception_unet, linknet_unet, SegNet, Tiramisu as model_id live in Pixel Decoder.
  • origin_shape_no: 256 is the default image tile shape from Label Maker;
  • border_no: it's set to 32. It's a additional 32 pixel to add on 256 by 256 image tile to become 320 by 320 to get rid of U-Net's edge distortion.

Run Pixel Decoder on AWS Deep Learning AMI instance with GUPs

Install Nvidia-Docker on your instance

  • Docker installation on AWS EC2. Instruction for Nvidia Docker installation here.

  • Build provide docker image from the Dockerfile

git clone https://github.com/Geoyi/pixel-decoder
cd pixel-decoder
nvidia-docker build -t pixel_decoder .
  • Run nvidia-docker and Pixel Decoder
nvidia-docker run -v $PWD:/work -it pixel_decoder bash
  • Install Pixel Decoder and train the model

Train

pixel_decoder train --batch_size=4 \
                    --imgs_folder=tiles \
                    --masks_folder=labels \
                    --models_folder=trained_models_out \
                    --model_id=resnet_unet \
                    --origin_shape_no=256 \
                    --border_no=32

Predict

pixel_decoder predict --imgs_folder=tiles \
                    --test_folder=test_images \
                    --models_folder=trained_models_out \
                    --pred_folder=predictions \
                    --model_id=resnet_unet \
                    --origin_shape_no=256 \  
                    --border_no=32

About

To run a neural net, e.g resnet_unet, you can create ready-to-train dataset from Label Maker. A detail walkthrough notebook will come soon. pixel_decoder was built on top of python-seed that created by Development Seed.

pixel-decoder's People

Contributors

dependabot[bot] avatar geoyi avatar pasquierjb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pixel-decoder's Issues

requirements.txt is broken

It looks like some stdout/stderr got logged to the requirement.txt file, so we're unable to install the needed deps.

Great project btw!

Problems with training.py

Hello,
I tried using pixel-decoder as you suggested in the readme file, however I am having problems with training my dataset. I use: train.train(batch_size=4, imgs_folder=imgs, masks_folder=masks, models_folder=models, model_id='resnet_unet', origin_shape_no=256, border_no=32) where imgs and masks are directories for label-maker data. However, after generating the first batch of results, I get the following ValueError: Cannot feed value of shape (4, 256, 256, 3, 1) for Tensor 'conv2d_22_target:0', which has shape '(?, ?, ?, ?)'.

From the Traceback, I believe this comes from the first instance of fit_generator, on lines 66-70. Specifically, the traceback points to line 70, the callback.

这个项目很好, 我很高兴!

Issue while Training

Loss and accuracy parameters just say NaN

loss: nan - dice_coef: nan - dice_coef_rounded: nan - binary_crossentropy: nan - val_loss: nan - val_dice_coef: nan - val_dice_coef_rounded: nan - val_binary_crossentropy: nan

screenshot from 2018-12-26 00-33-52

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.