Giter Site home page Giter Site logo

ybzh / contrastive-adaptation-network-for-unsupervised-domain-adaptation Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kgl-prml/contrastive-adaptation-network-for-unsupervised-domain-adaptation

0.0 0.0 0.0 45 KB

pytorch implementation for Contrastive Adaptation Network

Python 99.01% Shell 0.99%

contrastive-adaptation-network-for-unsupervised-domain-adaptation's Introduction

Contrastive Adaptation Network

This is the Pytorch implementation for our CVPR 2019 paper Contrastive Adaptation Network for Unsupervised Domain Adaptation. As we reorganized our code based on a new pytorch version, some hyper-parameters are slightly different from the paper.

Requirements

  • Python 3.7
  • Pytorch 1.1
  • PyYAML 5.1.1

Dataset

The structure of the dataset should be like

Office-31
|_ category.txt
|_ amazon
|  |_ back_pack
|     |_ <im-1-name>.jpg
|     |_ ...
|     |_ <im-N-name>.jpg
|  |_ bike
|     |_ <im-1-name>.jpg
|     |_ ...
|     |_ <im-N-name>.jpg
|  |_ ...
|_ dslr
|  |_ back_pack
|     |_ <im-1-name>.jpg
|     |_ ...
|     |_ <im-N-name>.jpg
|  |_ bike
|     |_ <im-1-name>.jpg
|     |_ ...
|     |_ <im-N-name>.jpg
|  |_ ...
|_ ...

The "category.txt" contains the names of all the categories, which is like

back_pack
bike
bike_helmet
...

Training

./experiments/scripts/train.sh ${config_yaml} ${gpu_ids} ${adaptation_method} ${experiment_name}

For example, for the Office-31 dataset,

./experiments/scripts/train.sh ./experiments/config/Office-31/CAN/office31_train_amazon2dslr_cfg.yaml 0 CAN office31_a2d

for the VisDA-2017 dataset,

./experiments/scripts/train.sh ./experiments/config/VisDA-2017/CAN/visda17_train_train2val_cfg.yaml 0 CAN visda17_train2val

The experiment log file and the saved checkpoints will be stored at ./experiments/ckpt/${experiment_name}

Test

./experiments/scripts/test.sh ${config_yaml} 0 ${if_adapted} ${experiment_name}

Example:

./experiments/scripts/test.sh ./experiments/config/Office-31/office31_test_amazon_cfg.yaml 0 True visda17_test

Citing

Please cite our paper if you use our code in your research:

@inproceedings{kang2019contrastive,
  title={Contrastive Adaptation Network for Unsupervised Domain Adaptation},
  author={Kang, Guoliang and Jiang, Lu and Yang, Yi and Hauptmann, Alexander G},
  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},
  pages={4893--4902},
  year={2019}
}

Contact

If you have any questions, please contact me via [email protected].

Thanks to third party

The way of setting configurations is inspired by https://github.com/rbgirshick/py-faster-rcnn.

contrastive-adaptation-network-for-unsupervised-domain-adaptation's People

Contributors

kgl-prml 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.