Giter VIP home page Giter VIP logo

spcl's Introduction

SPCL

A New Framework for Domain Adaptive Semantic Segmentation via Semantic Prototype-based Contrastive Learning by Binhui Xie, Mingjia Li, Shuang Li.

Update

2021/11/25: arXiv version of SPCL is available.

2022/06/24: Code is released.

If you find it useful for your research, please cite

@article{xie2021spcl,
  title={SPCL: A New Framework for Domain Adaptive Semantic Segmentation via Semantic Prototype-based Contrastive},
  author={Binhui Xie, Mingjia Li, Shuang Li},
  journal={arXiv preprint arXiv:2111.12358},
  year={2021}
}

Prerequisites

  • Python 3.6
  • torch 1.7.1
  • torchvision 0.8.2
  • yacs
  • matplotlib
  • GCC >= 4.9
  • OpenCV
  • CUDA >= 9.1

Step-by-step installation

conda create --name spcl -y python=3.6
conda activate spcl

# this installs the right pip and dependencies for the fresh python
conda install -y ipython pip

pip install torch==1.7.1 torchvision==0.8.2 ninja yacs cython matplotlib tqdm opencv-python imageio mmcv

Getting started

ln -s /path_to_gta5_dataset datasets/gta5
ln -s /path_to_synthia_dataset datasets/synthia
ln -s /path_to_synscapes_dataset datasets/synscapes
ln -s /path_to_cityscapes_dataset datasets/cityscapes
  • Generate the label statics file for GTA5 and SYNTHIA Datasets by running
python datasets/generate_gta5_label_info.py -d datasets/gta5 -o datasets/gta5/
python datasets/generate_synthia_label_info.py -d datasets/synthia -o datasets/synthia/

The data folder should be structured as follows:

├── datasets/
│   ├── cityscapes/     
|   |   ├── gtFine/
|   |   ├── leftImg8bit/
│   ├── gta5/
|   |   ├── images/
|   |   ├── labels/
|   |   ├── gtav_label_info.p
│   ├── synthia/
|   |   ├── RAND_CITYSCAPES/
|   |   ├── synthia_label_info.p
│   ├── synscapes/
|   |   ├── img/rgb-2k
|   |   ├── img/class
│   └── 			
...

Train

We provide the training script using 4 Tesla V100 GPUs.

bash train_with_ssl.sh

Evaluate

Tip: For those who are interested in how performance change during the process of adversarial training, test.py also accepts directory as the input and the results will be stored in a csv file.

python test.py -cfg configs/deeplabv2_r101_tgt_ssl.yaml resume results/r101_g2c_ours_ssl/ OUTPUT_DIR results/r101_g2c_ours_ssl/ SOLVER.BATCH_SIZE 8

Acknowledgments

This project is based on the following open-source projects: FADA and SDCA. We thank authors for making the source code publically available.

spcl's People

Contributors

binhuixie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

spcl's Issues

Some question about temperature parameter

Very interesting work. But I want to ask a question, temperature is an important hyperparameter in contrastive learning, I found that in SDCA work, the temperature is set to 100, I want to know if the temperature in SPCL is the same as the SDCA setting, and if there is anything about the difference Temperatures lead to related experiments with different results.

Looking forward to your reply.

Best Regards,
Qianmo

Ask for release

Dear author, thanks for your great job, I really want to read your code. When will you release?

Question about paper

Hi, thanks for your awesome work on contrastive learning in UDA.

I have some questions about the T-SNE visualization in Figure 4 as follows:

  1. It seems that the T-SNE visualization results are about pixels in the shown image but not the whole target domain dataset, is my understanding correct?
  2. How can I apply the T-SNE visualization for the whole target domain dataset? Is it feasible to use feature prototype of each category in each target image?
  3. Can you provide the code about T-SNE visualization, it's very grateful. :-)

about warmup.py

Thank you for sharing your code!
I would like to ask why the warm-up phase uses adversarial learning? Isn't fully supervised learning of source domain images used for the warm-up?
Using the target domain for adversarial learning would introduce noise into the selection of the source domain prototype, wouldn't it!

about code

Thank you for sharing your paper, do you have any plans to open source your code?

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.