Git Product home page Git Product logo

trans4pass's Introduction

Trans4PASS

Bending Reality: Distortion-aware Transformers for Adapting to Panoramic Semantic Segmentation

trans4pass

PWC

PWC

Introduction

To get around this domain difference and bring together semantic annotations from pinhole- and 360◦ surround-visuals, we propose to learn object deformations and panoramic image distortions in the Deformable Patch Embedding (DPE) and Deformable MLP (DMLP) components which blend into our Transformer for PAnoramic Semantic Segmentation (Trans4PASS) model.

More detailed can be found in our arxiv paper.

Environments

conda create -n trans4pass python=3.8
conda activate trans4pass
cd ~/path/to/trans4pass 
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
pip install mmcv-full==1.3.9 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.8.0/index.html
pip install -r requirements.txt
python setup.py develop --user
# Optional: install apex follow: https://github.com/NVIDIA/apex

Data Preparation

Prepare datasets: Cityscapes, Stanford2D3D, DensePASS.

datasets/
├── cityscapes
│   ├── gtFine
│   └── leftImg8bit
├── Stanford2D3D
│   ├── area_1
│   ├── area_2
│   ├── area_3
│   ├── area_4
│   ├── area_5a
│   ├── area_5b
│   └── area_6
├── DensePASS
│   ├── gtFine
│   └── leftImg8bit

Prepare pretrained weights, which can be found in the public repository of SegFormer.

pretrained/
├── mit_b1.pth
└── mit_b2.pth

Network Define

The code of Network pipeline is in segmentron/models/trans4pass.py.

The code of backbone is in segmentron/models/backbones/trans4pass.py.

The code of DMLP decoder is in segmentron/modules/dmlp.py.

Train

Our experiments are based on one machine with 4 1080Ti GPUs.

For example:

python -m torch.distributed.launch --nproc_per_node=4 tools/train.py --config-file configs/cityscapes/trans4pass_tiny_512x512.yaml
python -m torch.distributed.launch --nproc_per_node=4 tools/train_s2d3d.py --config-file configs/stanford2d3d/trans4pass_tiny_1080x1080.yaml

Test

Download the models from GoogleDrive and save in workdirs folder as:

├── workdirs
│   ├── cityscapes
│   │   ├── trans4pass_small_512x512
│   │   │   └── trans4pass_small_512x512.pth
│   │   └── trans4pass_tiny_512x512
│   │       └── trans4pass_tiny_512x512.pth
│   └── stanford2d3d
│   │   ├── trans4pass_small_1080x1080
│   │   │   └── trans4pass_small_1080x1080.pth
│   │   └── trans4pass_tiny_1080x1080
│   │       └── trans4pass_tiny_1080x1080.pth
│   └── stanford2d3d_pan
│       ├── trans4pass_small_1080x1080
│       │   └── trans4pass_small_pan_F1.pth
│       └── trans4pass_tiny_1080x1080
│           └── trans4pass_tiny_pan_F1.pth
python tools/eval.py --config-file configs/cityscapes/trans4pass_tiny_512x512.yaml
python tools/eval_stanford.py --config-file configs/stanford2d3d/trans4pass_tiny_1080x1080.yaml

Domain Adaptation

Train

After the model is trained on the source domain, the model can be further trained by the adversarial method for warm-up in the target domain.

cd adaptations
python train_warm.py

Then, use the warm up model to generate the pseudo label of the target damain.

python gen_pseudo_label.py

The proposed MPA method can be jointly used for perform domain adaptation.

# (optional) python train_ssl.py
python train_mpa.py

Test

Download the models from GoogleDrive and save in adaptations/snapshots folder as:

adaptations/snapshots/
├── CS2DensePASS_Trans4PASS_v1_MPA
│   └── BestCS2DensePASS_G.pth
├── CS2DensePASS_Trans4PASS_v2_MPA
│   └── BestCS2DensePASS_G.pth

Change the RESTORE_FROM in evaluate.py file. Or change the scales in evaluate.py for multi-scale evaluation.

cd adaptations
python evaluate.py

References

We appreciate the previous open-source works.

License

This repository is under the Apache-2.0 license. For commercial use, please contact with the authors.

Citations

If you are interested in this work, please cite the following work:

@article{zhang2022bending,
  title={Bending Reality: Distortion-aware Transformers for Adapting to Panoramic Semantic Segmentation},
  author={Zhang, Jiaming and Yang, Kailun and Ma, Chaoxiang and Rei{\ss}, Simon and Peng, Kunyu and Stiefelhagen, Rainer},
  journal={arXiv preprint arXiv:2203.01452},
  year={2022}
}

trans4pass's People

Contributors

jamycheung avatar elnino9ykl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.