# pytorch-semseg **Repository Path**: marenan_admin/pytorch-semseg ## Basic Information - **Project Name**: pytorch-semseg - **Description**: Semantic Segmentation Architectures Implemented in PyTorch - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-05-29 - **Last Updated**: 2021-03-14 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # pytorch-semseg [![license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/meetshah1995/pytorch-semseg/blob/master/LICENSE) [![pypi](https://img.shields.io/pypi/v/pytorch_semseg.svg)](https://pypi.python.org/pypi/pytorch-semseg/0.1.2) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.1185075.svg)](https://doi.org/10.5281/zenodo.1185075) ## Semantic Segmentation Algorithms Implemented in PyTorch This repository aims at mirroring popular semantic segmentation architectures in PyTorch.

### Networks implemented * [PSPNet](https://arxiv.org/abs/1612.01105) - With support for loading pretrained models w/o caffe dependency * [ICNet](https://arxiv.org/pdf/1704.08545.pdf) - With optional batchnorm and pretrained models * [FRRN](https://arxiv.org/abs/1611.08323) - Model A and B * [FCN](https://arxiv.org/abs/1411.4038) - All 1 (FCN32s), 2 (FCN16s) and 3 (FCN8s) stream variants * [U-Net](https://arxiv.org/abs/1505.04597) - With optional deconvolution and batchnorm * [Link-Net](https://codeac29.github.io/projects/linknet/) - With multiple resnet backends * [Segnet](https://arxiv.org/abs/1511.00561) - With Unpooling using Maxpool indices #### Upcoming * [E-Net](https://arxiv.org/abs/1606.02147) * [RefineNet](https://arxiv.org/abs/1611.06612) ### DataLoaders implemented * [CamVid](http://mi.eng.cam.ac.uk/research/projects/VideoRec/CamVid/) * [Pascal VOC](http://host.robots.ox.ac.uk/pascal/VOC/voc2012/segexamples/index.html) * [ADE20K](http://groups.csail.mit.edu/vision/datasets/ADE20K/) * [MIT Scene Parsing Benchmark](http://data.csail.mit.edu/places/ADEchallenge/ADEChallengeData2016.zip) * [Cityscapes](https://www.cityscapes-dataset.com/) * [NYUDv2](http://cs.nyu.edu/~silberman/datasets/nyu_depth_v2.html) * [Sun-RGBD](http://rgbd.cs.princeton.edu/) ### 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](https://meetshah1995.github.io/semantic-segmentation/deep-learning/pytorch/visdom/2017/06/01/semantic-segmentation-over-the-years.html#sec_datasets). * Extract the zip / tar and modify the path appropriately in your `config.yaml` ### Usage **Setup config file** ```yaml # Model Configuration model: arch: [options: 'fcn[8,16,32]s, unet, segnet, pspnet, icnet, icnetBN, linknet, frrn[A,B]' : # Data Configuration data: dataset: [options: 'pascal, camvid, ade20k, mit_sceneparsing_benchmark, cityscapes, nyuv2, sunrgbd, vistas'] train_split: val_split: img_rows: 512 img_cols: 1024 path: : # Training Configuration training: n_workers: 64 train_iters: 35000 batch_size: 16 val_interval: 500 print_interval: 25 loss: name: [options: 'cross_entropy, bootstrapped_cross_entropy, multi_scale_crossentropy'] : # Optmizer Configuration optimizer: name: [options: 'sgd, adam, adamax, asgd, adadelta, adagrad, rmsprop'] lr: 1.0e-3 : # Warmup LR Configuration warmup_iters: mode: <'constant' or 'linear' for warmup'> gamma: # 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: [options: 'constant_lr, poly_lr, multi_step, cosine_annealing, exp_lr'] : # Resume from checkpoint resume: ``` **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} } ```