Figure 1: Performance of SegFormer-B0 to SegFormer-B5.
SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers.
Enze Xie, Wenhai Wang, Zhiding Yu, Anima Anandkumar, Jose M. Alvarez, and Ping Luo.
Technical Report 2021.
This repository contains the PyTorch training/evaluation code and the pretrained models for SegFormer.
SegFormer is a simple, efficient and powerful semantic segmentation method, as shown in Figure 1.
We use MMSegmentation v0.13.0 as the codebase.
dockerfileでコンテナを作成した後 以下のコマンドで必要なものを入れていく
apt-get update && apt-get upgrade -y
apt-get install -y libgl1-mesa-dev
pip install mmsegmentation
or
pip install git+https://github.com/open-mmlab/mmsegmentation.git
pip install -e .
pip install -r requirements/optional.txt
pip install attrs
pip install timm
For install and data preparation, please refer to the guidelines in MMSegmentation v0.13.0.
Other requirements:
pip install timm==0.3.2
Download trained weights.
Example: evaluate SegFormer-B1
on ADE20K
:
# 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
事前学習済みモデル
mkdir pretrained
でディレクトリを作成してそこに入れる
Download weights pretrained on ImageNet-1K, and put them in a folder pretrained/
.
Example: train SegFormer-B1
on ADE20K
:
# 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>
./tools/dist_train.sh local_configs/segformer/B5/segformer.b5.1024x1024.city.160k.py 4
Please check the LICENSE file. SegFormer may be used non-commercially, meaning for research or evaluation purposes only. For business inquiries, please contact [email protected].
@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}
}