Git Product home page Git Product logo

dsbn's Introduction

Domain-Specific Batch Normalization for Unsupervised Domain Adaptation (DSBN)

Pytorch implementation of Domain-Specific Batch Normalization for Unsupervised Domain Adaptation (CVPR2019). BN vs DSBN

Woong-Gi Chang, Tackgeun You, Seonguk Seo, Suha Kwak, Bohyung Han

The first author name has changed from Woong-Gi Chang to Woojae Chang.

Citation

If you want to cite our work, follow the link arXiv.

Installation

We recommand to create conda virtualenv nameded pytorch-py36

conda create -n pytorch-py36 python=3.6 
source activate pytorch-py36
  • Install PyTorch 1.3 with Python3.6, cuda10.1

  • Install other dependencies

conda install numpy scipy matplotlib cython h5py
conda install -c menpo opencv
  • For visualization using tensorboard
pip install tensorboardX
pip install tensorflow
  • For color log print
pip install coloredlogs

Dataset

data directory looks like below:

data
├── Office
│   └── domain_adaptation_images
│       ├── amazon
│       ├── dslr
│       └── webcam
├── Office-home
│   └── OfficeHomeDataset_10072016
│       ├── Art
│       ├── Clipart
│       ├── Product
│       └── RealWorld
└── VisDA
    ├── test
    ├── train
    └── validation

Datasets links to download.

VisDA-C dataset

  • Refer this site and download the dataset.

OFFICE-31

  • Download from here

OFFICE-HOME

  • Download from here. Change domain name from "Real World" to "RealWorld" (Remove space between two words).

Training Examples

VISDA2017

Stage1 Training (training existing UDA model with DSBN)

This is a example script for training MSTN on visda 2017 dataset for stage1. Use resnet101dsbn for resnet101 with domain-specific batchnorm

# DSCN
python trainval_multi.py --model-name resnet101dsbn --exp-setting visda --sm-loss --adv-loss --source-datasets train --target-datasets validation --batch-size 40 --save-dir output/resnet101dsbn_visda_stage1 --print-console
# cf. batchnorm
python trainval_multi.py --model-name resnet101 --exp-setting visda --sm-loss --adv-loss --source-datasets train --target-datasets validation --batch-size 40 --save-dir output/resnet101_visda_stage1 --print-console

After training you can get stage1 model at save-dir.

Stage2 Training (self-training a new model with the model trained on stage1)

Stage2 Training

For stage1, use finetune for single source unsupervised domain adaptation, and finetune_multi for multi source setting.

This is a example script for training MSTN on visda 2017 dataset for stage2.

# DSCN
python finetune_multi.py --model-name resnet101dsbn --exp-setting visda --source-dataset train --target-dataset validation --pseudo-target-loss default_ensemble --no-lambda --teacher-model-path output/resnet101dsbn_visda_stage1/best_resnet101dsbn+None+i0_train2validation.pth --learning-rate 5e-5 --batch-size 40 --save-dir output/resnet101dsbn_visda_stage2 --print-console
# cf. batchnorm
python finetune_multi.py --model-name resnet101 --exp-setting visda --source-dataset train --target-dataset validation --pseudo-target-loss default_ensemble --no-lambda --teacher-model-path output/resnet101_visda_stage1/best_resnet101+None+i0_train2validation.pth --learning-rate 5e-5 --batch-size 40 --save-dir output/resnet101_visda_stage2 --print-console

Testing

python evlauate_multi.py --model-path [model-path] # for multi-source setting

File name should follow the format: "best_{model_name}+{jitter}+{infeatures}_{source_dataset}2{target_dataset}.pth"

example: best_resnet101dsbn+None+i0_train2validation.pth

dsbn's People

Contributors

aadsah avatar woozch avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar

dsbn's Issues

t-sne issue

can we provide the code of t-sne figure in your paper?

One problem

Hello~ Thank you for your excellent work. I have a question.
In the result of multiple source domain (merged and separate) in your paper, what is the difference between BN and DSBN when the Domain is separated, do you design the same number of branch for BN , how to do BN in the separate case?

CDAN+DSBN

Hi, thanks for your sharing!
I attemp to add DSBN to CDAN, and the loss functions are the source domain cross-entropy loss and the conditional adversarial loss. I used the settings same as CDAN's except for the BN layer. However, the performance of 'CDAN+DSBN' even worse than 'CDAN + BN'.
I don't know why there is such a result. Did you ever conduct the experiments about 'CDAN+DSBN'?

Difference between DSBN and AdaBN

Hi,
After reading the paper, I am still puzzled about the difference between DSBN and AdaBN. I think the main difference between DSBN and AdaBN is an additional pseudo label loss in DSBN. However, I can't find the experiment results comparing DSBN and AdaBN in the paper. Have you reproduced AdaBN in your experiments?
Thanks.

run script in other exp setting

Hi, thank you for your excellent work.
I'm wondering if you can share the run script or train config in other experiments' settings, like Office-Home, Office-31, and domain-net. Thx a lot!

Can not reproduce the result

Thanks for your inspiring work! I wonder why I cannot reproduce the result of Office31(A->W) in stage1 without DSBN. In the paper it's 91.3 while my best acc is 88.68.
This is my command:
python trainval_multi.py --model-name resnet50 --exp-setting office --sm-loss --adv-loss --source-datasets amazon --target-datasets webcam --batch-size 40 --save-dir output/resnet50_office_stage1 --print-console
Is there any mistake? Looking forward to you!

dsbn

pred_s, f_s = model(x_s, src_idx * torch.ones(x_s.shape[0], dtype=torch.long).cuda(args.gpu), with_ft=True)
pred_t, f_t = model(x_t, trg_idx * torch.ones(x_t.shape[0], dtype=torch.long).cuda(args.gpu), with_ft=True)
I want to know what src_idx * torch.ones(x_s.shape[0], dtype=torch.long) and trg_idx * torch.ones(x_t.shape[0], dtype=torch.long) for

reproduce

Hi~ Thank you for your excellent work.
I just reproduced the experiment for VisDA dataset with MSTN by running the script in Readme. But I got 76.14% mean Acc and 91.91% 84.46% 75.78% 60.04% 94.91% 30.75% 89.29% 81.58% 90.06% 78.47% 84.28% 52.20% Class Acc which are relatively lower than that reported in your paper but similar with the result reported for CPUA. I run the code in a V100 without changing any hyper-parameter. I am wondering if there is something I missed in stage2 training. An early response would be appreciated.

Different domains in one batch

Hi,
thanks for the interesting work. I'm wondering how this works if there are images from different domains in one batch. Will different BN be used for each image individually or?
Thanks a lot?

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.