Code for the ICCV 2021 Workshop paper: A Unified Efficient Pyramid Transformer for Semantic Segmentation.

Overview

Unified-EPT

Code for the ICCV 2021 Workshop paper: A Unified Efficient Pyramid Transformer for Semantic Segmentation.

Installation

  • Linux, CUDA>=10.0, GCC>=5.4
  • Python>=3.7
  • Create a conda environment:
    conda create -n unept python=3.7 pip

Then, activate the environment:

    conda activate unept
  • PyTorch>=1.5.1, torchvision>=0.6.1 (following instructions here)

For example:

conda install pytorch==1.5.1 torchvision==0.6.1 cudatoolkit=10.2 -c pytorch
pip install -r requirements.txt

Data Preparation

Please following the code from openseg to generate ground truth for boundary refinement.

The data format should be like this.

ADE20k

You can download the processed dt_offset file here.

path/to/ADEChallengeData2016/
  images/
    training/
    validation/
  annotations/ 
    training/
    validation/
  dt_offset/
    training/
    validation/

PASCAL-Context

You can download the processed dataset here.

path/to/PASCAL-Context/
  train/
    image/
    label/
    dt_offset/
  val/
    image/
    label/
    dt_offset/

Usage

Training

The default is for multi-gpu, DistributedDataParallel training.

python -m torch.distributed.launch --nproc_per_node=8 \ # specify gpu number
--master_port=29500  \
train.py  --launcher pytorch \
--config /path/to/config_file 
  • specify the data_root in the config file;
  • log dir will be created in ./work_dirs;
  • download the DeiT pretrained model and specify the pretrained path in the config file.

Evaluation

# single-gpu testing
python test.py --checkpoint /path/to/checkpoint \
--config /path/to/config_file \
--eval mIoU \
[--out ${RESULT_FILE}] [--show] \
--aug-test \ # for multi-scale flip aug

# multi-gpu testing (4 gpus, 1 sample per gpu)
python -m torch.distributed.launch --nproc_per_node=4 --master_port=29500 \
test.py  --launcher pytorch --eval mIoU \
--config_file /path/to/config_file \
--checkpoint /path/to/checkpoint \
--aug-test \ # for multi-scale flip aug

Results

We report results on validation sets.

Backbone Crop Size Batch Size Dataset Lr schd Mem(GB) mIoU(ms+flip) config
Res-50 480x480 16 ADE20K 160K 7.0G 46.1 config
DeiT 480x480 16 ADE20K 160K 8.5G 50.5 config
DeiT 480x480 16 PASCAL-Context 160K 8.5G 55.2 config

Security

See CONTRIBUTING for more information.

License

This project is licensed under the Apache-2.0 License.

Citation

If you use this code and models for your research, please consider citing:

@article{zhu2021unified,
  title={A Unified Efficient Pyramid Transformer for Semantic Segmentation},
  author={Zhu, Fangrui and Zhu, Yi and Zhang, Li and Wu, Chongruo and Fu, Yanwei and Li, Mu},
  journal={arXiv preprint arXiv:2107.14209},
  year={2021}
}

Acknowledgment

We thank the authors and contributors of MMCV, MMSegmentation, timm and Deformable DETR.

You might also like...
An official implementation of "Exploiting a Joint Embedding Space for Generalized Zero-Shot Semantic Segmentation" (ICCV 2021) in PyTorch.

Exploiting a Joint Embedding Space for Generalized Zero-Shot Semantic Segmentation This is an official implementation of the paper "Exploiting a Joint

[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

[ICCV 2021] A Simple Baseline for Semi-supervised Semantic Segmentation with Strong Data Augmentation

Vision-Language Transformer and Query Generation for Referring Segmentation (ICCV 2021)

Vision-Language Transformer and Query Generation for Referring Segmentation Please consider citing our paper in your publications if the project helps

EPSANet:An Efficient Pyramid Split Attention Block on Convolutional Neural Network

EPSANet:An Efficient Pyramid Split Attention Block on Convolutional Neural Network This repo contains the official Pytorch implementaion code and conf

Code release for ICCV 2021 paper
Code release for ICCV 2021 paper "Anticipative Video Transformer"

Anticipative Video Transformer Ranked first in the Action Anticipation task of the CVPR 2021 EPIC-Kitchens Challenge! (entry: AVT-FB-UT) [project page

 Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks
Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks

This is the code associated with the paper Predicting Semantic Map Representations from Images with Pyramid Occupancy Networks, published at CVPR 2020.

PyTorch code of my ICDAR 2021 paper Vision Transformer for Fast and Efficient Scene Text Recognition (ViTSTR)
PyTorch code of my ICDAR 2021 paper Vision Transformer for Fast and Efficient Scene Text Recognition (ViTSTR)

Vision Transformer for Fast and Efficient Scene Text Recognition (ICDAR 2021) ViTSTR is a simple single-stage model that uses a pre-trained Vision Tra

VSR-Transformer - This paper proposes a new Transformer for video super-resolution (called VSR-Transformer).
VSR-Transformer - This paper proposes a new Transformer for video super-resolution (called VSR-Transformer).

VSR-Transformer By Jiezhang Cao, Yawei Li, Kai Zhang, Luc Van Gool This paper proposes a new Transformer for video super-resolution (called VSR-Transf

Code for the paper One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation, CVPR 2021.

One Thing One Click One Thing One Click: A Self-Training Approach for Weakly Supervised 3D Semantic Segmentation (CVPR2021) Code for the paper One Thi

Comments
  • first commit

    first commit

    The code of UN-EPT. Next: dataset link and model links.

    By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

    opened by fangruizhu 0
  • training problem

    training problem

    How to solve the following problems when I train? thanks!

    (unept) lhj@zhouwei-SYS-4028GR-TR2:~/unified-ept$ CUDA_VISIBLE_DEVICES="0,1,2,3,4,5,6,7" python -m torch.distributed.launch --nproc_per_node=8 --master_port=29500 train.py --launcher pytorch --config /home/lhj/unified-ept/configs/res50_unept_ade20k.py /home/lhj/.local/lib/python3.7/site-packages/torch/distributed/launch.py:186: FutureWarning: The module torch.distributed.launch is deprecated and will be removed in future. Use torchrun. Note that --use_env is set by default in torchrun. If your script expects --local_rank argument to be set, please change it to read from os.environ['LOCAL_RANK'] instead. See https://pytorch.org/docs/stable/distributed.html#launch-utility for further instructions

    FutureWarning, WARNING:torch.distributed.run:


    Setting OMP_NUM_THREADS environment variable for each process to be 1 in default, to avoid your system being overloaded, please further tune the variable for optimal performance in your application as needed.


    Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. Traceback (most recent call last): File "train.py", line 21, in from modified_mmseg.apis import set_random_seed, train_segmentor File "/home/lhj/unified-ept/modified_mmseg/init.py", line 27, in f'MMCV=={mmcv.version} is used but incompatible. '
    AssertionError: MMCV==1.3.18 is used but incompatible. Please install mmcv>=[1, 1, 4], <=[1, 3, 0]. ERROR:torch.distributed.elastic.multiprocessing.api:failed (exitcode: 1) local_rank: 0 (pid: 3704) of binary: /home/lhj/.conda/envs/unept/bin/python Traceback (most recent call last): File "/home/lhj/.conda/envs/unept/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec) File "/home/lhj/.conda/envs/unept/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals) File "/home/lhj/.local/lib/python3.7/site-packages/torch/distributed/launch.py", line 193, in main() File "/home/lhj/.local/lib/python3.7/site-packages/torch/distributed/launch.py", line 189, in main launch(args) File "/home/lhj/.local/lib/python3.7/site-packages/torch/distributed/launch.py", line 174, in launch run(args) File "/home/lhj/.local/lib/python3.7/site-packages/torch/distributed/run.py", line 713, in run )(*cmd_args) File "/home/lhj/.local/lib/python3.7/site-packages/torch/distributed/launcher/api.py", line 131, in call return launch_agent(self._config, self._entrypoint, list(args)) File "/home/lhj/.local/lib/python3.7/site-packages/torch/distributed/launcher/api.py", line 261, in launch_agent failures=result.failures, torch.distributed.elastic.multiprocessing.errors.ChildFailedError:

    train.py FAILED

    Failures: [1]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 1 (local_rank: 1) exitcode : 1 (pid: 3705) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html [2]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 2 (local_rank: 2) exitcode : 1 (pid: 3706) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html [3]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 3 (local_rank: 3) exitcode : 1 (pid: 3707) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html [4]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 4 (local_rank: 4) exitcode : 1 (pid: 3708) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html [5]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 5 (local_rank: 5) exitcode : 1 (pid: 3709) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html [6]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 6 (local_rank: 6) exitcode : 1 (pid: 3710) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html [7]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 7 (local_rank: 7) exitcode : 1 (pid: 3711) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

    Root Cause (first observed failure): [0]: time : 2021-12-17_17:25:25 host : zhouwei-SYS-4028GR-TR2 rank : 0 (local_rank: 0) exitcode : 1 (pid: 3704) error_file: <N/A> traceback : To enable traceback see: https://pytorch.org/docs/stable/elastic/errors.html

    opened by geovsion 0
Owner
null
nnFormer: Interleaved Transformer for Volumetric Segmentation Code for paper "nnFormer: Interleaved Transformer for Volumetric Segmentation "

nnFormer: Interleaved Transformer for Volumetric Segmentation Code for paper "nnFormer: Interleaved Transformer for Volumetric Segmentation ". Please

jsguo 610 Dec 28, 2022
Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation)

Recall Loss for Semantic Segmentation (This repo implements the paper: Recall Loss for Semantic Segmentation) Download Synthia dataset The model uses

null 32 Sep 21, 2022
Adaptive Pyramid Context Network for Semantic Segmentation (APCNet CVPR'2019)

Adaptive Pyramid Context Network for Semantic Segmentation (APCNet CVPR'2019) Introduction Official implementation of Adaptive Pyramid Context Network

null 21 Nov 9, 2022
Tracking code for the winner of track 1 in the MMP-Tracking Challenge at ICCV 2021 Workshop.

Tracking Code for the winner of track1 in MMP-Trakcing challenge This repository contains our tracking code for the Multi-camera Multiple People Track

DamoCV 29 Nov 13, 2022
[ICCV 2021] FaPN: Feature-aligned Pyramid Network for Dense Image Prediction

FaPN: Feature-aligned Pyramid Network for Dense Image Prediction [arXiv] [Project Page] @inproceedings{ huang2021fapn, title={{FaPN}: Feature-alig

Shihua Huang 23 Jul 22, 2022
Official and maintained implementation of the paper "OSS-Net: Memory Efficient High Resolution Semantic Segmentation of 3D Medical Data" [BMVC 2021].

OSS-Net: Memory Efficient High Resolution Semantic Segmentation of 3D Medical Data Christoph Reich, Tim Prangemeier, Özdemir Cetin & Heinz Koeppl | Pr

Christoph Reich 23 Sep 21, 2022
Image transformations designed for Scene Text Recognition (STR) data augmentation. Published at ICCV 2021 Workshop on Interactive Labeling and Data Augmentation for Vision.

Data Augmentation for Scene Text Recognition (ICCV 2021 Workshop) (Pronounced as "strog") Paper Arxiv Why it matters? Scene Text Recognition (STR) req

Rowel Atienza 152 Dec 28, 2022
The official implementation of paper Siamese Transformer Pyramid Networks for Real-Time UAV Tracking, accepted by WACV22

SiamTPN Introduction This is the official implementation of the SiamTPN (WACV2022). The tracker intergrates pyramid feature network and transformer in

Robotics and Intelligent Systems Control @ NYUAD 28 Nov 25, 2022
Code for the ICCV 2021 paper "Pixel Difference Networks for Efficient Edge Detection" (Oral).

Pixel Difference Convolution This repository contains the PyTorch implementation for "Pixel Difference Networks for Efficient Edge Detection" by Zhuo

Alex 236 Dec 21, 2022
(IEEE TIP 2021) Regularized Densely-connected Pyramid Network for Salient Instance Segmentation

RDPNet IEEE TIP 2021: Regularized Densely-connected Pyramid Network for Salient Instance Segmentation PyTorch training and testing code are available.

Yu-Huan Wu 41 Oct 21, 2022