A pytorch implementation of CyCADA.
If you use this code in your research please consider citing
@inproceedings{Hoffman_cycada2017,
authors = {Judy Hoffman and Eric Tzeng and Taesung Park and Jun-Yan Zhu,
and Phillip Isola and Kate Saenko and Alexei A. Efros and Trevor Darrell},
title = {CyCADA: Cycle Consistent Adversarial Domain Adaptation},
booktitle = {International Conference on Machine Learning (ICML)},
year = 2018
}
- Check out the repo (recursively will also checkout the CyCADA fork of the CycleGAN repo).
git clone --recursive https://github.com/jhoffman/cycada_release.git cycada
- Install python requirements
- pip install -r requirements.txt
- Image adaptation builds on the work on CycleGAN. The submodule in this repo is a fork which also includes the semantic consistency loss.
- Pre-trained image results for digits may be downloaded here
- SVHN as MNIST (114MB)
- MNIST as USPS (6MB)
- USPS as MNIST (3MB)
- Producing SVHN as MNIST
- For an example of how to train image adaptation on SVHN->MNIST, see
cyclegan/train_cycada.sh
. From inside thecyclegan
subfolder runtrain_cycada.sh
. - The snapshots will be stored in
cyclegan/cycada_svhn2mnist_noIdentity
. Insidetest_cycada.sh
set the epoch value to the epoch you wish to use and then run the script to generate 50 transformed images (to preview quickly) or runtest_cycada.sh all
to generate the full ~73K SVHN images as MNIST digits. - Results are stored inside
cyclegan/results/cycada_svhn2mnist_noIdentity/train_75/images
. - Note we use a dataset of mnist_svhn and for this experiment run in the reverse direction (BtoA), so the source (SVHN) images translated to look like MNIST digits will be stored as
[label]_[imageId]_fake_B.png
. Hence when images from this directory will be loaded later we will only images which match that naming convention.
- For an example of how to train image adaptation on SVHN->MNIST, see
- The main script for feature adaptation can be found inside
scripts/train_adda.py
- Modify the data directory you which stores all digit datasets (or where they will be downloaded)
- Use the feature space adapt code with the data and models from image adaptation
- For example: to train for the SVHN to MNIST shift, set
src = 'svhn2mnist'
andtgt = 'mnist'
insidescripts/train_adda.py
- Either download the relevant images above or run image space adaptation code and extract transferred images
- Download GTA as CityScapes images (16GB).
- Download GTA DRN-26 model
- Download GTA as CityScapes DRN-26 model
- Adapt using
scripts/train_fcn_adda.sh
- Choose the desired
src
andtgt
anddatadir
. Make sure to download the corresponding base model and data. - The final DRN-26 CyCADA model from GTA to CityScapes can be downloaded here
- Choose the desired