README.md 5.3 KB
Newer Older
R
Rosun 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
# SemSegPaddle: A Paddle-based Framework for Deep Learning in Semantic Segmentation

This is a Paddle implementation of semantic segmentation models on multiple datasets, including Cityscapes, Pascal Context, and ADE20K.

## Updates

- [**2020/01/08**] We release ***PSPNet-ResNet101*** and ***GloRe-ResNet101*** models on Pascal Context and Cityscapes datasets.

## Highlights

Synchronized Batch Normlization is important for segmenation.
  - The implementation is easy to use as it is pure-python, no any C++ extra extension libs.
   
  - Paddle provides sync_batch_norm.
   
   
## Support models

We split our models into backbone and decoder network, where backbone network are transfered from classification networks.

Backbone:
  - ResNet
  - ResNeXt
  - HRNet
  - EfficientNet
  
Decoder:
  - PSPNet: [Pyramid Scene Parsing Network](http://openaccess.thecvf.com/content_cvpr_2017/papers/Zhao_Pyramid_Scene_Parsing_CVPR_2017_paper.pdf)
  - DeepLabv3: [Rethinking Atrous Convolution for Semantic Image Segmentation](https://arxiv.org/abs/1706.05587)
  - GloRe: [Graph-Based Global Reasoning Networks](http://openaccess.thecvf.com/content_CVPR_2019/papers/Chen_Graph-Based_Global_Reasoning_Networks_CVPR_2019_paper.pdf)
  - GINet: [GINet: Graph Interaction Netowrk for Scene Parsing]()
  


## Peformance

 - Performance of Cityscapes validation set.

**Method**  | **Backbone** | **lr**     | **BatchSize**  | **epoch**    | **mean IoU (Single-scale)** |  **Trained weights**   |
------------|:------------:|:----------:|:--------------:|:------------:|:---------------------------:|------------------------|
PSPNet      | resnet101    |     0.01   |        8       | 80           | 78.1                        |  [pspnet_resnet_cityscapes_epoch_80.pdparams](https://pan.baidu.com/s/1adfvtq2JnLKRv_j7lOmW1A)|
GloRe      | resnet101    |     0.01   |        8       | 80           |  78.4                        |  [pspnet_resnet_pascalcontext_epoch_80.pdparams](https://pan.baidu.com/s/1r4SbrYKbVk38c0dXZLAi9w)              |


 - Performance of Pascal-context validation set.

**Method**  | **Backbone** | **lr**     | **BatchSize**  | **epoch**    | **mean IoU (Single-scale)** |  **Trained weights**   |
------------|:------------:|:----------:|:--------------:|:------------:|:---------------------------:|:----------------------:|
PSPNet       | resnet101    | 0.005       |   16            | 80           |   48.9                   |  [glore_resnet_cityscapes_epoch_80.pdparams](https://pan.baidu.com/s/1l7-sqt2DsUunD9l4YivgQw)                       |
GloRe       | resnet101    | 0.005       |   16            | 80           |    48.4                   |  [glore_resnet_pascalcontext_epoch_80.pdparams](https://pan.baidu.com/s/1rVuk7OfSj-AXR3ZCFGNmKg)                |


## Environment

This repo is developed under the following configurations:

 - Hardware: 4 GPUs for training, 1 GPU for testing
 - Software: Centos 6.10, ***CUDA>=9.2 Python>=3.6, Paddle>=1.6***


## Quick start: training and testing models

### 1. Preparing data

Download the [Cityscapes](https://www.cityscapes-dataset.com/) dataset. It should have this basic structure:

      cityscapes/
      ├── cityscapes_list
      │   ├── test.lst
      │   ├── train.lst
      │   ├── train+.lst
      │   ├── train++.lst
      │   ├── trainval.lst
      │   └── val.lst
      ├── gtFine
      │   ├── test
      │   ├── train
      │   └── val
      ├── leftImg8bit
      │   ├── test
      │   ├── train
      │   └── val
      ├── license.txt
      └── README
   
 Download Pascal-Context dataset. It should have this basic structure:  

      pascalContext/
      ├── GroundTruth_trainval_mat
      ├── GroundTruth_trainval_png
      ├── JPEGImages
      ├── pascal_context_train.txt
      ├── pascal_context_val.txt
      ├── README.md
      └── VOCdevkit

 Then, create symlinks for the Cityscapes and Pascal-Context datasets
 ```
 cd SemSegPaddle/data
 ln -s $cityscapes ./
 ln -s $pascalContext ./
 ```
 
### 2. Download pretrained weights
  Downlaod pretrained [resnet-101](https://pan.baidu.com/s/1niXBDZnLlUIulB7FY068DQ) weights file, and put it into the directory: ***./pretrained_model***
  
  Then, run the following command:
```
  tar -zxvf  ./repretrained/resnet101_v2.tgz -C pretrained_model 
```

### 3. Training

select confiure file for training according to the DECODER\_NAME, BACKBONE\_NAME and DATASET\_NAME.
```
CUDA_VISIBLE_DEVICES=0,1,2,3 python -m paddle.distributed.launch train.py  --use_gpu --use_mpio \
                                  --cfg ./configs/pspnet_res101_cityscapes.yaml 
```

### 4. Testing 
select confiure file for testing according to the DECODER\_NAME, BACKBONE\_NAME and DATASET\_NAME.

Single-scale testing:
```
CUDA_VISIBLE_DEVICES=0 python  eval.py --use_gpu \
                                       --use_mpio \
                                       --cfg ./configs/pspnet_res101_cityscapes.yaml 
```

Multi-scale testing:
```
CUDA_VISIBLE_DEVICES=0 python  eval.py --use_gpu \
                                       --use_mpio \
                                       --multi_scales \
                                       --cfg ./configs/pspnet_res101_cityscapes.yaml 
```

## Contact
If you have any questions regarding the repo, please create an issue.