GithubHelp home page GithubHelp logo

bentengma / intrada Goto Github PK

View Code? Open in Web Editor NEW

This project forked from feipanir/intrada

0.0 1.0 0.0 5.02 MB

Unsupervised Intra-domain Adaptation for Semantic Segmentation through Self-Supervision (CVPR 2020 Oral)

Home Page: https://arxiv.org/pdf/2004.07703.pdf

License: MIT License

Python 100.00%

intrada's Introduction

Unsupervised Intra-domain Adaptation for Semantic Segmentation through Self-Supervision

Paper

Unsupervised Intra-domain Adaptation for Semantic Segmentation through Self-Supervision

Fei Pan, Inkyu Shin, Francois Rameau, Seokju Lee, In So Kweon KAIST, Korea

IEEE Conference on Computer Vision and Pattern Recoginition (CVPR), 2020 (Oral)

If you find this paper or code useful for your research, please cite our paper:

@InProceedings{pan2020unsupervised,
  title = {Unsupervised Intra-domain Adaptation for Semantic Segmentation through Self-Supervision},
  author = {Pan, Fei and Shin, Inkyu and Rameau, Francois and Lee, Seokju and Kweon, In So},
  booktitle = {IEEE Conference on Computer Vision and Pattern Recoginition (CVPR)},
  year = {2020}
}

Abstract

Convolutional neural network-based approaches have achieved remarkable progress in semantic segmentation. However, these approaches heavily rely on annotated data which are labor intensive. To cope with this limitation, automatically annotated data generated from graphic engines are used to train segmentation models. However, the models trained from synthetic data are difficult to transfer to real images. To tackle this issue, previous works have considered directly adapting models from the source data to the unlabeled target data (to reduce the inter-domain gap). Nonetheless, these techniques do not consider the large distribution gap among the target data itself (intra-domain gap). In this work, we propose a two-step self-supervised domain adaptation approach to minimize the inter-domain and intra-domain gap together. First, we conduct the inter-domain adaptation of the model; from this adaptation, we separate the target domain into an easy and hard split using an entropy-based ranking function. Finally, to decrease the intra-domain gap, we propose to employ a self-supervised adaptation technique from the easy to the hard split. Experimental results on numerous benchmark datasets highlight the effectiveness of our method against existing state-of-the-art approaches.

Acknowledgement

This work is supported by BOSCH.

This repo is heavily borrowed from ADVENT, AdaptSegNet, and Pytorch-Deeplab.

Pre-requsites

  • Python 3.7
  • Pytorch >= 0.4.1
  • CUDA 9.0 or higher

Installation

  1. Clone the repo:
$ git clone --recursive https://github.com/feipan664/IntraDA.git
$ cd IntraDA
  1. Install OpenCV if you don't already have it:
$ conda install -c menpo opencv

if it doesn't work, please try to use conda pip

$ which pip    # should be $HOME/anaconda3/bin/pip, be sure to use conda pip
$ pip install opencv-python 
  1. Install ADVENT submodule and the dependices using pip: if you use
$ pip install -e <root_dir/ADVENT>

With this, you can edit the ADVENT code on the fly and import function and classes of ADVENT in other project as well.

Datasets

We follow set-ups from ADVENT. The datasets are put into <root_dir>/ADVENT/data. Symlinks to hook the ADVENT codebase to the dataset is recommended. An alternative option is to explicitlly specify the parameters DATA_DIRECTORY_SOURCE and DATA_DIRECTORY_TARGET in YML configuration files.

  • GTA5: Please follow the instructions here to download images and semantic segmentation annotations. The GTA5 dataset directory should have this basic structure:
<root_dir>/ADVENT/data/GTA5/                               % GTA dataset root
<root_dir>/ADVENT/data/GTA5/images/                        % GTA images
<root_dir>/ADVENT/data/GTA5/labels/                        % Semantic segmentation labels
...
  • Cityscapes: Please follow the instructions in Cityscape to download the images and validation ground-truths. The Cityscapes dataset directory should have this basic structure:
<root_dir>/ADVENT/data/Cityscapes/                         % Cityscapes dataset root
<root_dir>/ADVENT/data/Cityscapes/leftImg8bit              % Cityscapes images
<root_dir>/ADVENT/data/Cityscapes/leftImg8bit/val
<root_dir>/ADVENT/data/Cityscapes/gtFine                   % Semantic segmentation labels
<root_dir>/ADVENT/data/Cityscapes/gtFine/val
...

Pre-trained models

Pretrained models can be downloaded here and put in <root_dir>/ADVENT/pretrained_models

Running the code

For evaluation, execute:

$ cd <root_dir>/intrada
$ python test.py --cfg intrada_trained.yml 
$ python test.py --cfg intrada_trained_withnorm.yml # test on models trained wih entropy normalization

Training

Our training environment is based on pytorch 0.4.1 and CUDA 9.0. To reach to the comparable performance you may need to train a few times. By default, logs and snapshots are stored in <root_dir>/experiments with this structure:

<root_dir>/ADVENT/experiments/logs
<root_dir>/ADVENT/experiments/snapshots

Step 1. Conduct inter-domain adaptation by training ADVENT:

$ cd <root_dir>/ADVENT/advent/scripts
$ python train.py --cfg ./config/advent.yml 
$ python train.py --cfg ./config/advent.yml --tensorboard % using tensorboard

After inter-domain training, it is needed to get best IoU iteration by runing:

$ cd <root_dir>/ADVENT/advent/scripts
$ python test.py --cfg ./config/advent.yml

The best IoU iteration BEST_ID will be a parameter to step 2.

Step 2. Entropy-based ranking to split Cityscapes training set into easy split and hard split:

$ cd <root_dir>/entropy_rank
$ python entropy.py --best_iter BEST_ID --normalize False --lambda1 0.67 

You will see the pseudo labels generated in color_masks, the easy split file names in easy_split.txt, and the hard split file names in hard_split.txt.

Step 3. Conduct intra-domain adaptation by runing:

$ cd <root_dir>/intrada
$ python train.py --cfg ./intrada.yml
$ python train.py --cfg ./intrada.yml --tensorboard % using tensorboard

Testing

To test the performance from intrada, run:

$ cd <root_dir>/intrada
$ python test.py --cfg ./intrada.yml

Examples of 8 low entropy images and 8 high entropy images from Cityscapes training set.

License

IntraDA is released under MIT License.

intrada's People

Watchers

 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.