From f11d53c21521ac7d40656206a8e41ad78ba1291a Mon Sep 17 00:00:00 2001 From: junyanz Date: Fri, 31 Mar 2017 02:24:21 -0700 Subject: [PATCH] update README.md and add comments --- README.md | 15 +++++++++------ options.lua | 41 ++++++++++++++++++++--------------------- test.sh | 38 -------------------------------------- 3 files changed, 29 insertions(+), 65 deletions(-) delete mode 100644 test.sh diff --git a/README.md b/README.md index cde3df0..2f03c8b 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # CycleGAN -### [[Project]](https://junyanz.github.io/CycleGAN/) [[Paper]](https://arxiv.org/pdf/1703.10593.pdf) -from Berkeley AI Research ([BAIR](http://bair.berkeley.edu/)) Lab. +### [[project page]](https://junyanz.github.io/CycleGAN/) [[paper]](https://arxiv.org/pdf/1703.10593.pdf) + Torch implementation for learning an image-to-image translation (i.e. **pix2pix**) without input-output pairs, for example: @@ -9,11 +9,14 @@ Torch implementation for learning an image-to-image translation (i.e. **pix2pix* -Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks +[Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks](https://junyanz.github.io/CycleGAN/) [Jun-Yan Zhu](https://people.eecs.berkeley.edu/~junyanz/)\*, [Taesung Park](https://taesung.me/)\*, [Phillip Isola](http://web.mit.edu/phillipi/), [Alexei A. Efros](https://people.eecs.berkeley.edu/~efros/) + Berkeley AI Research Lab, UC Berkeley In arxiv, 2017. (* equal contributions) -PyTorch version is coming soon (by April 7th). +This package includes CycleGAN, [pix2pix](https://github.com/phillipi/pix2pix), as well as other methods like [BiGAN](https://arxiv.org/abs/1605.09782)/[ALI](https://ishmaelbelghazi.github.io/ALI/) and Apple's paper [S+U learning](https://arxiv.org/pdf/1612.07828.pdf). +**PyTorch** version is coming soon (by April 7th). + ## Applications ### Monet Paintings to Photos @@ -148,13 +151,13 @@ Then open `http://(hostname):(port)/` in your browser to load the remote desktop ## Citation -If you use this code for your research, please cite our [paper](todo): +If you use this code for your research, please cite our [paper](https://junyanz.github.io/CycleGAN/): ``` @article{CycleGAN2017, title={Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networkss}, author={Zhu, Jun-Yan and Park, Taesung and Isola, Phillip and Efros, Alexei A}, - journal={arxiv}, + journal={arXiv preprint arXiv:1703.10593}, year={2017} } ``` diff --git a/options.lua b/options.lua index e3bdb29..111328d 100644 --- a/options.lua +++ b/options.lua @@ -35,18 +35,18 @@ local opt_train = { serial_batches = 0, -- if 1, takes images in order to make batches, otherwise takes them randomly checkpoints_dir = './checkpoints', -- models are saved here cudnn = 1, -- set to 0 to not use cudnn - which_model_netD = 'basic', -- selects model to use for netD + which_model_netD = 'basic', -- selects model to use for netD which_model_netG = 'resnet_6blocks', -- selects model to use for netG - norm = 'instance', -- batch or instance normalization - n_layers_D = 3, -- only used if which_model_netD=='n_layers' + norm = 'instance', -- batch or instance normalization + n_layers_D = 3, -- only used if which_model_netD=='n_layers' content_loss = 'pixel', -- content loss type: L1, conv-layer, edge layer_name = 'pixel', -- layer used in content loss - lambda_A = 10.0, -- weight for cycle loss (A -> B -> A) - lambda_B = 10.0, -- weight for cycle loss (B -> A -> B) - model = 'cycle_gan', -- which mode to run. 'cycle_gan', 'pix2pix', 'bigan', 'content_gan' - use_lsgan = 1, -- if 1, use least square GAN, if 0, use vanilla GAN - align_data = 0, -- if > 0, use the dataloader for where the images are aligned - pool_size = 50, -- the size of image buffer that stores previously generated images + lambda_A = 10.0, -- weight for cycle loss (A -> B -> A) + lambda_B = 10.0, -- weight for cycle loss (B -> A -> B) + model = 'cycle_gan', -- which mode to run. 'cycle_gan', 'pix2pix', 'bigan', 'content_gan' + use_lsgan = 1, -- if 1, use least square GAN, if 0, use vanilla GAN + align_data = 0, -- if > 0, use the dataloader for where the images are aligned + pool_size = 50, -- the size of image buffer that stores previously generated images resize_or_crop='resize_and_crop', -- resizing/cropping strategy identity = 0, -- use identity mapping } @@ -57,28 +57,27 @@ opt_test = { batchSize = 1, -- # images in batch loadSize = 256, -- scale images to this size fineSize = 256, -- then crop to this size - flip = 0, -- horizontal mirroring data augmentation + flip = 0, -- horizontal mirroring data augmentation display = 1, -- display samples while training. 0 = false display_id = 200, -- display window id. gpu = 1, -- gpu = 0 is CPU mode. gpu=X is GPU mode on GPU X how_many = 'all', -- how many test images to run (set to all to run on every image found in the data/phase folder) - phase = 'val', -- train, val, test ,etc for A + phase = 'val', -- train, val, test, etc preprocess = 'regular', -- for special purpose preprocessing, e.g., for colorization, change this (selects preprocessing functions in util.lua) aspect_ratio = 1.0, -- aspect ratio of result images - norm = 'instance', -- batchnorm or isntance norm + norm = 'instance', -- batchnorm or isntance norm name = '', -- name of experiment, selects which model to run, should generally should be passed on command line - input_nc = 3, -- # of input image channels - output_nc = 3, -- # of output image channels - serial_batches = 1, -- if 1, takes images in order to make batches, otherwise takes them randomly - cudnn = 1, -- set to 0 to not use cudnn (untested) + input_nc = 3, -- # of input image channels + output_nc = 3, -- # of output image channels + serial_batches = 1, -- if 1, takes images in order to make batches, otherwise takes them randomly + cudnn = 1, -- set to 0 to not use cudnn (untested) checkpoints_dir = './checkpoints', -- loads models from here results_dir='./results/', -- saves results here which_epoch = 'latest', -- which epoch to test? set to 'latest' to use latest cached model - model = 'cycle_gan', -- which mode to run. 'cycle_consistency' or 'autoencoder_gan' - align_data = 0, -- if > 0, use the dataloader for pix2pix - which_direction = 'AtoB', - resize_or_crop = 'resize_and_crop', - identity = 0, + model = 'cycle_gan', -- which mode to run. 'cycle_gan', 'pix2pix', 'bigan', 'content_gan'; to use pretrained model, select `one_direction_test` + align_data = 0, -- if > 0, use the dataloader for pix2pix + which_direction = 'AtoB', -- AtoB or BtoA + resize_or_crop = 'resize_and_crop', -- resizing/cropping strategy } -------------------------------------------------------------------------------- diff --git a/test.sh b/test.sh deleted file mode 100644 index d0da7fc..0000000 --- a/test.sh +++ /dev/null @@ -1,38 +0,0 @@ -DB_NAME=cityscapes -# EXPR_NAME=${DB_NAME}_ -# EXPR_NAMES=('resnet_unet128_basic_64_pix2pix') #'resnet_unet128_basic_64_content_gan_pixel_1' -# EXPR_NAMES=('resnet_unet128_basic_64_A10_B10') -# S=('simple_pix2pix_10') - -EXPR_NAMES=('gan_one_cycle_resnet_unet128_basic_64_10_backward') - -# EXPR_NAMES=('gan_cycle_resnet_unet128_basic_64_10') -# EXPR_NAMES=('resnet_unet128_basic_64_content_gan_pixel_1') -# resnet_unet128_basic_64_A10_B10 -# MODELS=('content_gan') - -# MODEL='simple_pix2pix' -MODEL='gan_one_cycle' -# MODEL='content_gan' -PHASES=('eva') -# EPOCHS=(50 100 150 200) -EPOCHS=(200) -# EPOCH=latest -GPU=2 -ASPECT_RATIO=1.0 - -# MODEL= - -for EXPR_NAME in ${EXPR_NAMES[@]}; do - for EPOCH in ${EPOCHS[@]}; do - for PHASE in ${PHASES[@]}; do - DATA_ROOT=../expr/$DB_NAME name=${DB_NAME}_${EXPR_NAME} \ - checkpoints_dir=../checkpoints/ align_data=1 model=$MODEL which_direction='AtoB' aspect_ratio=$ASPECT_RATIO \ - results_dir=../results/${DB_NAME}/ \ - phase=$PHASE which_epoch=$EPOCH how_many='all' \ - gpu=$GPU nThreads=1 flip=0 display_id=$DISPLAY_ID serial_batches=1 \ - loadSize=128 fineSize=128 \ - th test.lua - done - done -done