Giter Club home page Giter Club logo

pytorch-u-net-segmentation's Introduction

This repository is an implementation on the U-Net Paper.

  • The script/getdataset.sh downloads the The Inria Aerial Image Labeling.This is not the best data set if you want to do aerial image segmentation on your own computer, because of computational limits because of 5k Images.
  • This Repo contains a hot encoder which encodes the dataset of n classes to a one hot encoded matrix of n* height* width for every class. The encoder can be seen at utils/ .
  • To use train it, put the Images and the gt file locations in the config.json folder and execute train.py, a .pth file will be saved for the following model in the working directory.
  • Ch/ foler includes the example for creating a N class hot encoded image

Working

  • git clone https://github.com/madhavkhoslaa/Pytorch-U-Net-Segmentation
  • Open the config.json file and put the location of your dataset in the json files and put the resolution of the Images(you cannot train model with different sized images and a single batch size because of PyTorch collate)
  • Then edit the train.py file and esit the file extensions.
  • Train the model, by running train.py

Using just the hot encoder

  • img= skimage.io.imread("someimage.jpeg")

Load your Image

  • encoder= HotEncoder(dir= '', extension="tif", is_binary= False)

Make an encoder object for you dataset.

  • classes= encoder.gen_colors()

This generates the number of classes from the number of colors in your annotated data.

  • ClassMatrix= encoder.PerPixelClassMatrix(image)

This method returns a martrix of the same size height and width but single channel, depecting class of each pixel in the Image.

  • encoded= encoder.HotEncode(ClassMatrix)

This encodes your Image to n channel matrix of same height and width You also might want to view each channel depecting every class for an Image, to split the n channel matrix to n single channel matrices.

  • ch= encoder.channelSplit(encoded)

This returns n number of matrices depecting each class in an Image. This method is also used to encode the Image in the dataloader.

Known Issues

  • Single Channel tif files cannot be hot encoded right now. If you have a single channel tif file for the annotation, convert it into a png or a 3 channel tif file
  • Predict.py not tested

___

If you feel any need to contribute don’t feel shy to do a pull request or contact me:D

To Understand Repo structure

Credits:

milesial's UNET Repository for the U-Net Model for the model file

pytorch-u-net-segmentation's People

Contributors

madhavkhoslaa avatar snyk-bot avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

pytorch-u-net-segmentation's Issues

Add only forward pass way.

Trained model is saved as a pt file. Make a way so that the weights can be loaded up and its easier to use it.

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.