• Stars
    star
    2,762
  • Rank 16,490 (Top 0.4 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 5 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 on PyTorch (include FCN, PSPNet, Deeplabv3, Deeplabv3+, DANet, DenseASPP, BiSeNet, EncNet, DUNet, ICNet, ENet, OCNet, CCNet, PSANet, CGNet, ESPNet, LEDNet, DFANet)

Semantic Segmentation on PyTorch

English | ็ฎ€ไฝ“ไธญๆ–‡

python-image pytorch-image lic-image

This project aims at providing a concise, easy-to-use, modifiable reference implementation for semantic segmentation models using PyTorch.

Installation

# semantic-segmentation-pytorch dependencies
pip install ninja tqdm

# follow PyTorch installation in https://pytorch.org/get-started/locally/
conda install pytorch torchvision -c pytorch

# install PyTorch Segmentation
git clone https://github.com/Tramac/awesome-semantic-segmentation-pytorch.git

Usage

Train


  • Single GPU training
# for example, train fcn32_vgg16_pascal_voc:
python train.py --model fcn32s --backbone vgg16 --dataset pascal_voc --lr 0.0001 --epochs 50
  • Multi-GPU training
# for example, train fcn32_vgg16_pascal_voc with 4 GPUs:
export NGPUS=4
python -m torch.distributed.launch --nproc_per_node=$NGPUS train.py --model fcn32s --backbone vgg16 --dataset pascal_voc --lr 0.0001 --epochs 50

Evaluation


  • Single GPU evaluating
# for example, evaluate fcn32_vgg16_pascal_voc
python eval.py --model fcn32s --backbone vgg16 --dataset pascal_voc
  • Multi-GPU evaluating
# for example, evaluate fcn32_vgg16_pascal_voc with 4 GPUs:
export NGPUS=4
python -m torch.distributed.launch --nproc_per_node=$NGPUS eval.py --model fcn32s --backbone vgg16 --dataset pascal_voc

Demo

cd ./scripts
#for new users:
python demo.py --model fcn32s_vgg16_voc --input-pic ../tests/test_img.jpg
#you should add 'test.jpg' by yourself
python demo.py --model fcn32s_vgg16_voc --input-pic ../datasets/test.jpg
.{SEG_ROOT}
โ”œโ”€โ”€ scripts
โ”‚ย ย  โ”œโ”€โ”€ demo.py
โ”‚ย ย  โ”œโ”€โ”€ eval.py
โ”‚ย ย  โ””โ”€โ”€ train.py

Support

Model

DETAILS for model & backbone.

.{SEG_ROOT}
โ”œโ”€โ”€ core
โ”‚ย ย  โ”œโ”€โ”€ models
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ bisenet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ danet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ deeplabv3.py
โ”‚   โ”‚   โ”œโ”€โ”€ deeplabv3+.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ denseaspp.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ dunet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ encnet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ fcn.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pspnet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ icnet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ enet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ocnet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ psanet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ cgnet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ espnet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ lednet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ dfanet.py
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ......

Dataset

You can run script to download dataset, such as:

cd ./core/data/downloader
python ade20k.py --download-dir ../datasets/ade
Dataset training set validation set testing set
VOC2012 1464 1449 โœ˜
VOCAug 11355 2857 โœ˜
ADK20K 20210 2000 โœ˜
Cityscapes 2975 500 โœ˜
COCO
SBU-shadow 4085 638 โœ˜
LIP(Look into Person) 30462 10000 10000
.{SEG_ROOT}
โ”œโ”€โ”€ core
โ”‚ย ย  โ”œโ”€โ”€ data
โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ dataloader
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ ade.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ cityscapes.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ mscoco.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pascal_aug.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ pascal_voc.py
โ”‚ย ย  โ”‚ย ย  โ”‚ย ย  โ”œโ”€โ”€ sbu_shadow.py
โ”‚ย ย  โ”‚ย ย  โ””โ”€โ”€ downloader
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ ade20k.py
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ cityscapes.py
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ mscoco.py
โ”‚ย ย  โ”‚ย ย      โ”œโ”€โ”€ pascal_voc.py
โ”‚ย ย  โ”‚ย ย      โ””โ”€โ”€ sbu_shadow.py

Result

  • PASCAL VOC 2012
Methods Backbone TrainSet EvalSet crops_size epochs JPU Mean IoU pixAcc
FCN32s vgg16 train val 480 60 โœ˜ 47.50 85.39
FCN16s vgg16 train val 480 60 โœ˜ 49.16 85.98
FCN8s vgg16 train val 480 60 โœ˜ 48.87 85.02
FCN32s resnet50 train val 480 50 โœ˜ 54.60 88.57
PSPNet resnet50 train val 480 60 โœ˜ 63.44 89.78
DeepLabv3 resnet50 train val 480 60 โœ˜ 60.15 88.36

Note: lr=1e-4, batch_size=4, epochs=80.

Overfitting Test

See TEST for details.

.{SEG_ROOT}
โ”œโ”€โ”€ tests
โ”‚ย ย  โ””โ”€โ”€ test_model.py

To Do

  • add train script
  • remove syncbn
  • train & evaluate
  • test distributed training
  • fix syncbn (Why SyncBN?)
  • add distributed (How DIST?)

References

More Repositories

1

Fast-SCNN-pytorch

A PyTorch Implementation of Fast-SCNN: Fast Semantic Segmentation Network
Python
373
star
2

Lightweight-Segmentation

Lightweight models for real-time semantic segmentation(include mobilenetv1-v3, shufflenetv1-v2, igcv3, efficientnet).
Python
342
star
3

torchscope

Model Scope in PyTorch (include Params, FLOPs, Madds).
Python
121
star
4

mobilenetv3-segmentation

MobileNetV3 for Semantic Segmentation.
Python
95
star
5

paper-reading-note

ๅ’ŒๆŽๆฒไธ€่ตท่ฏป่ฎบๆ–‡
81
star
6

tiny-kinetics-400

Tiny Kinetics-400 for test
Python
78
star
7

pytorch-cam

Class Activation Map (CAM) Visualizations in PyTorch.
Python
30
star
8

tensorrt-tutorial

TensorRT็ฎ€ๆ˜Žๆ•™็จ‹
23
star
9

DenseVoxNet-tensorflow

DenseVoxNet in TensorFlow
Python
21
star
10

Effective-Cpp

ๆ”นๅ–„็จ‹ๅบไธŽ่ฎพ่ฎก็š„55ไธชๅ…ทไฝ“ๅšๆณ•๏ผˆ็ฌฌไธ‰็‰ˆ๏ผ‰
C++
16
star
11

sth-2-sth

ไธ€ไธชๅŸบไบŽๅ†…ๅฎน็š„ๅ›พๅƒๆฃ€็ดข็ณป็ปŸ
CSS
13
star
12

awesome-video-feature-extractor

Video feature extractor in PyTorch.
Python
7
star
13

MaiHaHi-pytorch

่š‚่šๅ‘€ๅ˜ฟ
Python
5
star
14

Non-local-tensorflow

Non-local Block for Semantic Segmentation
Python
3
star
15

AdaBound-tensorflow

A tensorflow/keras version of AdaBound optimizer.
Python
3
star
16

video-dataloader

Some dataloader for video datasets.
Python
2
star
17

Convert_To_TFRecord

Tutorial:Convert your data to tfrecord
Python
2
star
18

MURA

MURA challenge
Python
1
star
19

paper-reading-list

Some papers read.
1
star