• Stars
    star
    3,323
  • Rank 13,487 (Top 0.3 %)
  • Language
    Python
  • License
    MIT License
  • Created over 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Semantic Segmentation Architectures Implemented in PyTorch

pytorch-semseg

license pypi DOI

Semantic Segmentation Algorithms Implemented in PyTorch

This repository aims at mirroring popular semantic segmentation architectures in PyTorch.

Networks implemented

  • PSPNet - With support for loading pretrained models w/o caffe dependency
  • ICNet - With optional batchnorm and pretrained models
  • FRRN - Model A and B
  • FCN - All 1 (FCN32s), 2 (FCN16s) and 3 (FCN8s) stream variants
  • U-Net - With optional deconvolution and batchnorm
  • Link-Net - With multiple resnet backends
  • Segnet - With Unpooling using Maxpool indices

Upcoming

DataLoaders implemented

Requirements

  • pytorch >=0.4.0
  • torchvision ==0.2.0
  • scipy
  • tqdm
  • tensorboardX

One-line installation

pip install -r requirements.txt

Data

  • Download data for desired dataset(s) from list of URLs here.
  • Extract the zip / tar and modify the path appropriately in your config.yaml

Usage

Setup config file

# Model Configuration
model:
    arch: <name> [options: 'fcn[8,16,32]s, unet, segnet, pspnet, icnet, icnetBN, linknet, frrn[A,B]'
    <model_keyarg_1>:<value>

# Data Configuration
data:
    dataset: <name> [options: 'pascal, camvid, ade20k, mit_sceneparsing_benchmark, cityscapes, nyuv2, sunrgbd, vistas'] 
    train_split: <split_to_train_on>
    val_split: <spit_to_validate_on>
    img_rows: 512
    img_cols: 1024
    path: <path/to/data>
    <dataset_keyarg1>:<value>

# Training Configuration
training:
    n_workers: 64
    train_iters: 35000
    batch_size: 16
    val_interval: 500
    print_interval: 25
    loss:
        name: <loss_type> [options: 'cross_entropy, bootstrapped_cross_entropy, multi_scale_crossentropy']
        <loss_keyarg1>:<value>

    # Optmizer Configuration
    optimizer:
        name: <optimizer_name> [options: 'sgd, adam, adamax, asgd, adadelta, adagrad, rmsprop']
        lr: 1.0e-3
        <optimizer_keyarg1>:<value>

        # Warmup LR Configuration
        warmup_iters: <iters for lr warmup>
        mode: <'constant' or 'linear' for warmup'>
        gamma: <gamma for warm up>
       
    # Augmentations Configuration
    augmentations:
        gamma: x                                     #[gamma varied in 1 to 1+x]
        hue: x                                       #[hue varied in -x to x]
        brightness: x                                #[brightness varied in 1-x to 1+x]
        saturation: x                                #[saturation varied in 1-x to 1+x]
        contrast: x                                  #[contrast varied in 1-x to 1+x]
        rcrop: [h, w]                                #[crop of size (h,w)]
        translate: [dh, dw]                          #[reflective translation by (dh, dw)]
        rotate: d                                    #[rotate -d to d degrees]
        scale: [h,w]                                 #[scale to size (h,w)]
        ccrop: [h,w]                                 #[center crop of (h,w)]
        hflip: p                                     #[flip horizontally with chance p]
        vflip: p                                     #[flip vertically with chance p]

    # LR Schedule Configuration
    lr_schedule:
        name: <schedule_type> [options: 'constant_lr, poly_lr, multi_step, cosine_annealing, exp_lr']
        <scheduler_keyarg1>:<value>

    # Resume from checkpoint  
    resume: <path_to_checkpoint>

To train the model :

python train.py [-h] [--config [CONFIG]] 

--config                Configuration file to use

To validate the model :

usage: validate.py [-h] [--config [CONFIG]] [--model_path [MODEL_PATH]]
                       [--eval_flip] [--measure_time]

  --config              Config file to be used
  --model_path          Path to the saved model
  --eval_flip           Enable evaluation with flipped image | True by default
  --measure_time        Enable evaluation with time (fps) measurement | True
                        by default

To test the model w.r.t. a dataset on custom images(s):

python test.py [-h] [--model_path [MODEL_PATH]] [--dataset [DATASET]]
               [--dcrf [DCRF]] [--img_path [IMG_PATH]] [--out_path [OUT_PATH]]
 
  --model_path          Path to the saved model
  --dataset             Dataset to use ['pascal, camvid, ade20k etc']
  --dcrf                Enable DenseCRF based post-processing
  --img_path            Path of the input image
  --out_path            Path of the output segmap

If you find this code useful in your research, please consider citing:

@article{mshahsemseg,
    Author = {Meet P Shah},
    Title = {Semantic Segmentation Architectures Implemented in PyTorch.},
    Journal = {https://github.com/meetshah1995/pytorch-semseg},
    Year = {2017}
}

More Repositories

1

tf-3dgan

Tensorflow implementation of 3D Generative Adversarial Network.
Python
281
star
2

mit-ocw-dl

Download all video lectures from a MIT-OCW course with a single command.
Python
101
star
3

crnn-music-genre-classification

Tensorflow Implementation of Convolutional Recurrent Neural Networks for Music Genre Classification
Python
52
star
4

ConvolutionalNeuralNetwork

Convolutional Neural Networks for Object Classification done as a course project for CS663 Digital Image Processing
MATLAB
23
star
5

CS-663

Assignment Codes for CS663 Digital Image Processing
HTML
17
star
6

EE-702

Project codes for EE702 Computer Vision.
Python
12
star
7

CS-736

Assignment codes for CS736 Algorithms for Medical Image Processing.
HTML
10
star
8

config

My dotfiles
Python
9
star
9

TechFest2k15

Android Application Source for IIT-Bombay's TechFest 2015.
Java
7
star
10

CS-747

Assignment codes for CS747 Intelligent and Learning Agents
Python
5
star
11

CS-725

Assignment solutions for CS725 Machine Learning
Python
5
star
12

CS-229

Assignment Solutions to Coursera CS-229 Machine Learning by Stanford
MATLAB
5
star
13

glustup

Tools and Instruction Sets for GPU cluster setup.
4
star
14

ME-766

Assignment Solutions to course ME766 High Performance Scientific Computing.
C++
3
star
15

CS-749

Assignments for Course Digital Geometry Processing
C++
3
star
16

statistical-computing-interface

R based Statistical Computing Interface for easy statistical analysis and data visualization
JavaScript
3
star
17

EE-352

Solution codes for EE352 Digital Signal Processing Lab.
C
2
star
18

EE-340

Laboratory Files for course EE 340 Communications Lab
Python
2
star
19

EE-214

VHDL and Verilog Codes for Digital Lab.
VHDL
2
star
20

homepage

My Personal Webpage | Old, Redundant, Dirty and now depreciated.
CSS
2
star
21

EE-779

Assignment codes for EE779 Advanced Topics in Signal Processing
HTML
2
star
22

marching-cube-segmentation

Brain tumor segmentation using modified Marching Cubes segmentation algorithm
C++
2
star
23

EE-717

Assignment Solutions of Course EE717 Advanced Computing for Electrical Engineers
C++
2
star
24

fpmath

Automatically exported from code.google.com/p/fpmath
C++
2
star
25

CS-416

Assignment Solutions for Course Computer Network and Security.
HTML
2
star
26

auv_website

Website of Autonomous Underwater Vehicle Team IIT-Bombay
CSS
1
star
27

tf-devanagri

Convolutional Neural Networks to identify Devanagri characters implemented in Tensorflow
Python
1
star
28

sudoku-solver

Sudoku Solver written in lunch-break !
C++
1
star
29

EE-337

Assembly Codes for Microprocessors Laboratory
Assembly
1
star
30

EE-324

Solution codes and simulation files for EE324 Control Lab.
C
1
star
31

GMap-Fest-Scheduler

Generic Google Map based scheduling/routing framework that can be incorporated into any event or college fest Android app.
Java
1
star
32

dockerfiles

My public Dockerfiles
1
star
33

Vishynoid

Chess Robot ( BeagleBone )
C++
1
star
34

EE-338

Filter Design Assignment codes for course EE338 Digital Signal Processing
HTML
1
star
35

UFLDL-solutions

Programming Exercises Solutions for the Stanford Unsupervised Feature Learning and Deep Learning Tutorial
MATLAB
1
star
36

CS-213

Assignment Solutions for Course Data Structures and Algorithms..
C++
1
star