SegFormer/README.md

68 lines
2.3 KiB
Markdown
Raw Normal View History

2021-06-13 00:32:37 +08:00
# SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers
2021-06-13 00:56:27 +08:00
This repo contains the supported code and configuration files to reproduce [SegFormer](https://arxiv.org/abs/2105.15203).
2021-06-13 00:32:37 +08:00
We use [MMSegmentation v0.13.0](https://github.com/open-mmlab/mmsegmentation/tree/v0.13.0) as the codebase.
2021-06-13 01:03:57 +08:00
<!-- ![image](resources/image.png) -->
<div align="center">
2021-06-13 01:05:25 +08:00
<img src="./resources/image.png" height="400">
2021-06-13 01:03:57 +08:00
</div>
<p align="center">
Figure 1: Performance of SegFormer-B0 to SegFormer-B5.
</p>
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
## Install
For install and data preparation, please refer to the guidelines in [MMSegmentation v0.13.0](https://github.com/open-mmlab/mmsegmentation/tree/v0.13.0).
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
## Evaluation
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
Download [trained weights](https://drive.google.com/drive/folders/1GAku0G0iR9DsBxCbfENWMJ27c5lYUeQA?usp=sharing).
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
Example: evaluate ```SegFormer-B1``` on ```ADE20K```:
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
```
# single-gpu testing
python tools/test.py local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py /path/to/checkpoint_file
# multi-gpu testing
./tools/dist_test.sh local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py /path/to/checkpoint_file <GPU_NUM>
# multi-gpu, multi-scale testing
tools/dist_test.sh local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py /path/to/checkpoint_file <GPU_NUM> --aug-test
```
## Training
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
Download [pre-trained weights](https://drive.google.com/drive/folders/1b7bwrInTW4VLEm27YawHOAMSMikga2Ia?usp=sharing) pretrained on ImageNet-1K, and put them in a folder ```pretrained/```.
2021-06-13 00:32:37 +08:00
2021-06-13 00:56:27 +08:00
Example: train ```SegFormer-B1``` on ```ADE20K```:
2021-06-13 00:32:37 +08:00
```
2021-06-13 00:56:27 +08:00
# single-gpu training
python tools/train.py local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py
# multi-gpu training
./tools/dist_train.sh local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py <GPU_NUM>
2021-06-13 00:32:37 +08:00
```
2021-06-13 00:56:27 +08:00
## License
Please check the LICENSE file. SegFormer may be used non-commercially, meaning for research or
evaluation purposes only. For business inquiries, please contact
[researchinquiries@nvidia.com](mailto:researchinquiries@nvidia.com).
## Citing SegFormer
```
@article{xie2021segformer,
title={SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers},
author={Xie, Enze and Wang, Wenhai and Yu, Zhiding and Anandkumar, Anima and Alvarez, Jose M and Luo, Ping},
journal={arXiv preprint arXiv:2105.15203},
year={2021}
}
```