PyTorch implementation for semantic segmentation (DeepLabV3+, UNet, etc.)
PyTorch implementation for semantic segmentation (DeepLabV3+, UNet, etc.)
This repository implements general network for semantic segmentation.
You can train various networks like DeepLabV3+, PSPNet, UNet, etc., just by writing the config file.
You can run pretrained model converted from official tensorflow model.
$ cd tf_model
$ wget http://download.tensorflow.org/models/deeplabv3_cityscapes_train_2018_02_06.tar.gz
$ tar -xvf deeplabv3_cityscapes_train_2018_02_06.tar.gz
$ cd ../src
$ python -m converter.convert_xception65 ../tf_model/deeplabv3_cityscapes_train/model.ckpt 19 ../model/cityscapes_deeplab_v3_plus/model.pthThen you can test the performance of trained network.
$ python eval_cityscapes.py --ttamIoU of cityscapes
$ pip install cityscapesScripts
$ export CITYSCAPES_RESULTS=../output/cityscapes_val/cityscapes_deeplab_v3_plus_tta
$ export CITYSCAPES_DATASET=../data/cityscapes
$ csEvalPixelLevelSemanticLabeling …$ cd tf_model
$ wget http://download.tensorflow.org/models/deeplabv3_mnv2_cityscapes_train_2018_02_05.tar.gz
$ tar -xvf deeplabv3_mnv2_cityscapes_train_2018_02_05.tar.gz
$ cd ../src
$ python -m converter.convert_mobilenetv2 ../tf_model/deeplabv3_mnv2_cityscapes_train/model.ckpt 19 ../model/cityscapes_mobilnetv2/model.pthIn order to train model, you have only to setup config file.
For example, write config file as below and save it as config/pascal_unet_res18_scse.yaml.
Net:
enc_type: 'resnet18'
dec_type: 'unet_scse'
num_filters: 8
pretrained: True
Data:
dataset: 'pascal'
target_size: (512, 512)
Train:
max_epoch: 20
batch_size: 2
fp16: True
resume: False
pretrained_path:
Loss:
loss_type: 'Lovasz'
ignore_index: 255
Optimizer:
mode: 'adam'
base_lr: 0.001
t_max: 10Then you can train this model by:
$ python train.py ../config/pascal_unet_res18_scse.yaml.
├── config
├── data
│ ├── cityscapes
│ │ ├── gtFine
│ │ └── leftImg8bit
│ └── pascal_voc_2012
│ └── VOCdevkit
│ └── VOC2012
│ ├── JPEGImages
│ ├── SegmentationClass
│ └── SegmentationClassAug
├── logs
├── model
└── src
├── dataset
├── logger
├── losses
│ ├── binary
│ └── multi
├── models
└── utilsif you want to train models in fp16
No open issues yet, or sync has not completed.