-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
707 changed files
with
34,366 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
data | ||
.vscode | ||
.idea | ||
|
||
# custom | ||
*.pkl | ||
*.pkl.json | ||
*.log.json | ||
work_dirs/ | ||
work_dirs | ||
pretrained | ||
pretrained/ | ||
# Pytorch | ||
*.pth | ||
trash/ | ||
trash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
NVIDIA Source Code License for SegFormer | ||
|
||
1. Definitions | ||
|
||
“Licensor” means any person or entity that distributes its Work. | ||
|
||
“Software” means the original work of authorship made available under this License. | ||
|
||
“Work” means the Software and any additions to or derivative works of the Software that are made available under | ||
this License. | ||
|
||
The terms “reproduce,” “reproduction,” “derivative works,” and “distribution” have the meaning as provided under | ||
U.S. copyright law; provided, however, that for the purposes of this License, derivative works shall not include | ||
works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work. | ||
|
||
Works, including the Software, are “made available” under this License by including in or with the Work either | ||
(a) a copyright notice referencing the applicability of this License to the Work, or (b) a copy of this License. | ||
|
||
2. License Grant | ||
|
||
2.1 Copyright Grant. Subject to the terms and conditions of this License, each Licensor grants to you a perpetual, | ||
worldwide, non-exclusive, royalty-free, copyright license to reproduce, prepare derivative works of, publicly | ||
display, publicly perform, sublicense and distribute its Work and any resulting derivative works in any form. | ||
|
||
3. Limitations | ||
|
||
3.1 Redistribution. You may reproduce or distribute the Work only if (a) you do so under this License, (b) you | ||
include a complete copy of this License with your distribution, and (c) you retain without modification any | ||
copyright, patent, trademark, or attribution notices that are present in the Work. | ||
|
||
3.2 Derivative Works. You may specify that additional or different terms apply to the use, reproduction, and | ||
distribution of your derivative works of the Work (“Your Terms”) only if (a) Your Terms provide that the use | ||
limitation in Section 3.3 applies to your derivative works, and (b) you identify the specific derivative works | ||
that are subject to Your Terms. Notwithstanding Your Terms, this License (including the redistribution | ||
requirements in Section 3.1) will continue to apply to the Work itself. | ||
|
||
3.3 Use Limitation. The Work and any derivative works thereof only may be used or intended for use | ||
non-commercially. Notwithstanding the foregoing, NVIDIA and its affiliates may use the Work and any derivative | ||
works commercially. As used herein, “non-commercially” means for research or evaluation purposes only. | ||
|
||
3.4 Patent Claims. If you bring or threaten to bring a patent claim against any Licensor (including any claim, | ||
cross-claim or counterclaim in a lawsuit) to enforce any patents that you allege are infringed by any Work, then | ||
your rights under this License from such Licensor (including the grant in Section 2.1) will terminate immediately. | ||
|
||
3.5 Trademarks. This License does not grant any rights to use any Licensor’s or its affiliates’ names, logos, | ||
or trademarks, except as necessary to reproduce the notices described in this License. | ||
|
||
3.6 Termination. If you violate any term of this License, then your rights under this License (including the | ||
grant in Section 2.1) will terminate immediately. | ||
|
||
4. Disclaimer of Warranty. | ||
|
||
THE WORK IS PROVIDED “AS IS” WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING | ||
WARRANTIES OR CONDITIONS OF M ERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT. YOU | ||
BEAR THE RISK OF UNDERTAKING ANY ACTIVITIES UNDER THIS LICENSE. | ||
|
||
5. Limitation of Liability. | ||
|
||
EXCEPT AS PROHIBITED BY APPLICABLE LAW, IN NO EVENT AND UNDER NO LEGAL THEORY, WHETHER IN TORT (INCLUDING | ||
NEGLIGENCE), CONTRACT, OR OTHERWISE SHALL ANY LICENSOR BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY DIRECT, | ||
INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF OR RELATED TO THIS LICENSE, THE USE OR | ||
INABILITY TO USE THE WORK (INCLUDING BUT NOT LIMITED TO LOSS OF GOODWILL, BUSINESS INTERRUPTION, LOST PROFITS OR | ||
DATA, COMPUTER FAILURE OR MALFUNCTION, OR ANY OTHER COMM ERCIAL DAMAGES OR LOSSES), EVEN IF THE LICENSOR HAS BEEN | ||
ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
[](https://github.com/NVlabs/SegFormer/blob/master/LICENSE) | ||
 | ||
|
||
# SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers | ||
|
||
<!--  --> | ||
<div align="center"> | ||
<img src="./resources/image.png" height="400"> | ||
</div> | ||
<p align="center"> | ||
Figure 1: Performance of SegFormer-B0 to SegFormer-B5. | ||
</p> | ||
|
||
### [Project page](https://github.com/NVlabs/SegFormer) | [Paper](https://arxiv.org/abs/2105.15203) | [Demo (Youtube)](https://www.youtube.com/watch?v=J0MoRQzZe8U) | [Demo (Bilibili)](https://www.bilibili.com/video/BV1MV41147Ko/) | ||
|
||
SegFormer: Simple and Efficient Design for Semantic Segmentation with Transformers.<br> | ||
[Enze Xie](https://xieenze.github.io/), [Wenhai Wang](https://whai362.github.io/), [Zhiding Yu](https://chrisding.github.io/), [Anima Anandkumar](http://tensorlab.cms.caltech.edu/users/anima/), [Jose M. Alvarez](https://rsu.data61.csiro.au/people/jalvarez/), and [Ping Luo](http://luoping.me/).<br> | ||
NeurIPS 2021. | ||
|
||
This repository contains the official Pytorch implementation of training & evaluation code and the pretrained models for [SegFormer](https://arxiv.org/abs/2105.15203). | ||
|
||
SegFormer is a simple, efficient and powerful semantic segmentation method, as shown in Figure 1. | ||
|
||
We use [MMSegmentation v0.13.0](https://github.com/open-mmlab/mmsegmentation/tree/v0.13.0) as the codebase. | ||
|
||
🔥🔥 SegFormer is on [MMSegmentation](https://github.com/open-mmlab/mmsegmentation/tree/master/configs/segformer). 🔥🔥 | ||
|
||
|
||
## Installation | ||
|
||
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). | ||
|
||
Other requirements: | ||
```pip install timm==0.3.2``` | ||
|
||
An example (works for me): ```CUDA 10.1``` and ```pytorch 1.7.1``` | ||
|
||
``` | ||
pip install torchvision==0.8.2 | ||
pip install timm==0.3.2 | ||
pip install mmcv-full==1.2.7 | ||
pip install opencv-python==4.5.1.48 | ||
cd SegFormer && pip install -e . --user | ||
``` | ||
|
||
## Evaluation | ||
|
||
Download [trained weights](https://drive.google.com/drive/folders/1GAku0G0iR9DsBxCbfENWMJ27c5lYUeQA?usp=sharing). | ||
|
||
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 | ||
``` | ||
|
||
## Training | ||
|
||
Download [weights](https://drive.google.com/drive/folders/1b7bwrInTW4VLEm27YawHOAMSMikga2Ia?usp=sharing) 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> | ||
``` | ||
|
||
## Visualize | ||
|
||
Here is a demo script to test a single image. More details refer to [MMSegmentation's Doc](https://mmsegmentation.readthedocs.io/en/latest/get_started.html). | ||
|
||
```shell | ||
python demo/image_demo.py ${IMAGE_FILE} ${CONFIG_FILE} ${CHECKPOINT_FILE} [--device ${DEVICE_NAME}] [--palette-thr ${PALETTE}] | ||
``` | ||
|
||
Example: visualize ```SegFormer-B1``` on ```CityScapes```: | ||
|
||
```shell | ||
python demo/image_demo.py demo/demo.png local_configs/segformer/B1/segformer.b1.512x512.ade.160k.py \ | ||
/path/to/checkpoint_file --device cuda:0 --palette cityscapes | ||
``` | ||
|
||
|
||
|
||
|
||
|
||
## License | ||
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]](mailto:[email protected]). | ||
|
||
|
||
## Citation | ||
``` | ||
@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} | ||
} | ||
``` |
Oops, something went wrong.