DualGAN-tensorflow: tensorflow implementation of DualGAN

Overview

ICCV paper of DualGAN

DualGAN: unsupervised dual learning for image-to-image translation

please cite the paper, if the codes has been used for your research.

architecture of DualGAN

architecture

How to setup

Prerequisites

  • Linux

  • Python (2.7 or later)

  • numpy

  • scipy

  • NVIDIA GPU + CUDA 8.0 + CuDNN v5.1

  • TensorFlow 1.0 or later

Getting Started

steps

  • clone this repo:
git clone https://github.com/duxingren14/DualGAN.git

cd DualGAN
  • download datasets (e.g., sketch-photo), run:
bash ./datasets/download_dataset.sh sketch-photo
  • download pre-trained model (e.g., sketch-photo), run:
bash ./checkpoint/download_ckpt.sh sketch-photo
  • train the model:
python main.py --phase train --dataset_name sketch-photo --image_size 256 --lambda_A 1000.0 --lambda_B 1000.0 --epoch 100
  • test the model:
python main.py --phase test --dataset_name sketch-photo --image_size 256 --lambda_A 1000.0 --lambda_B 1000.0 --epoch 100

optional

Similarly, run experiments on facades dataset with the following commands:

bash ./datasets/download_dataset.sh facades

python main.py --phase train --dataset_name facades --lambda_A 1000.0 --lambda_B 1000.0 --epoch 100

python main.py --phase test --dataset_name facades --lambda_A 1000.0 --lambda_B 1000.0 --epoch 100

For thoese who cannot download datasets or pretrained models using the scripts, please try manual downloading from the link as below:

all datasets from google drive

pretrained models from google drive

Experimental results:

day2night da2ni la2ph ph2la sk2ph ph2sk ch2oi oi2ch

Acknowledgments

Codes are built on the top of pix2pix-tensorflow and DCGAN-tensorflow. Thanks for their precedent contributions!

Comments
  • Using custom datasets?

    Using custom datasets?

    Hello, I'd like to ask if I can use custom datasets to train and test the model?

    Currently, I had different dataset with different image size (126x126), but still had the same characteristics as your sketch-photo dataset (ie. having set A and B, both in train and val set)

    I once tricked the model by filling the val directory of sketch-photo dataset with my own dataset, and it worked. I just want to know is there a way to do this by just providing my dataset without reconfiguring the sketch-photo dataset directories

    opened by nobodykid 2
  • resume training

    resume training

    Thanks for providing the code. Just wondering, does the code support to resume training process? So I can continue the training process after a certain epoch without training from scratch again. Thanks.

    opened by popleyi 2
  • Why is session run twice in the optimizer?

    Why is session run twice in the optimizer?

    In model.py, why is the training step ran twice for the generators?

      def run_optim(self,batch_A_imgs, batch_B_imgs,  counter, start_time):
            _, Adfake,Adreal,Bdfake,Bdreal, Ad, Bd = self.sess.run(
                [self.d_optim, self.Ad_loss_fake, self.Ad_loss_real, self.Bd_loss_fake, self.Bd_loss_real, self.Ad_loss, self.Bd_loss], 
                feed_dict = {self.real_A: batch_A_imgs, self.real_B: batch_B_imgs})
            _, Ag, Bg, Aloss, Bloss = self.sess.run(
                [self.g_optim, self.Ag_loss, self.Bg_loss, self.A_loss, self.B_loss], 
                feed_dict={ self.real_A: batch_A_imgs, self.real_B: batch_B_imgs})
    
            _, Ag, Bg, Aloss, Bloss = self.sess.run(
                [self.g_optim, self.Ag_loss, self.Bg_loss, self.A_loss, self.B_loss], 
                feed_dict={ self.real_A: batch_A_imgs, self.real_B: batch_B_imgs})
    

    In the paper it says:

    To optimize the DualGAN networks, we follow the training procedure proposed in WGAN [1]; see Alg. 1. We train the discriminators ncritic steps, then one step on generators

    So, is the code doing the opposite (stepping generators twice and discriminator only once) ?

    opened by Cristy94 2
  • OOM errors?

    OOM errors?

    While the training is running (inside jenkins apparently) it keeps showing errors like:

    c_allocator.cc:696] 18 Chunks of size 819200 totalling 14.06MiB
    2017-08-27 20:07:53.768974: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 9 Chunks of size 1638400 totalling 14.06MiB
    2017-08-27 20:07:53.768996: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 19 Chunks of size 3276800 totalling 59.38MiB
    2017-08-27 20:07:53.769019: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 9 Chunks of size 6553600 totalling 56.25MiB
    2017-08-27 20:07:53.769041: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 19 Chunks of size 13107200 totalling 237.50MiB
    2017-08-27 20:07:53.769064: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 52 Chunks of size 26214400 totalling 1.27GiB
    2017-08-27 20:07:53.769157: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 1 Chunks of size 46343680 totalling 44.20MiB
    2017-08-27 20:07:53.769181: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:696] 27 Chunks of size 52428800 totalling 1.32GiB
    2017-08-27 20:07:53.769202: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:700] Sum Total of in-use chunks: 3.00GiB
    2017-08-27 20:07:53.769244: I C:\tf_jenkins\home\workspace\rel-win\M\windows-gpu\PY\35\tensorflow\core\common_runtime\b
    c_allocator.cc:702] Stats:
    Limit:                  3226265190
    InUse:                  3226265088
    MaxInUse:               3226265088
    NumAllocs:                     808
    MaxAllocSize:             52428800
    ...
     Resource exhausted: OOM when allocating tensor with shape[5,5,1,64]
    

    I am not familiar to jenkins, is this normal? (I am on Windows 10, with 16GB RAM and only 30% is in use and the GPU is 1050TI 4GB)

    LE: This doesn't seem to occur if I set --fcn_filter_dim 32

    opened by Cristy94 2
  • Do you use WGAN?

    Do you use WGAN?

    According to your paper, you use the loss format advocated by WGAN rather than the sigmoid cross-entropy loss used in the original GAN.

    But in this repo, it looks no WGAN. That's why?

    opened by jiujing23333 2
  • How to use labeled data

    How to use labeled data

    I run with the argument --use_labeled_data 'semi', and got an error : 'AttributeError: 'DualNet' object has no attribute 'C_d_vars' . I uncommented some code in the model.py, but still have problem running the code. Please give me some advice. Thanks.

    opened by daodaofr 2
  • Identity Loss

    Identity Loss

    Hi, This is great and very well engineered, well done. I do have a question about the identity loss which you see in a few papers on dual gans, loss( A2B, A ). I'm not sure I can see it there, is there a reason for this?

    opened by Lopside1 1
  • Unused arguments?

    Unused arguments?

    add_argument('--niter', dest='niter', type=int, default=30, help='# of iter at starting learning rate')

    This argument is added but seems to never be used. Should it be removed or be implemented?

    opened by Cristy94 1
  • I have no ideas that why the epoch be set 45 in test stage.

    I have no ideas that why the epoch be set 45 in test stage.

    I have no ideas that why the epoch be set 45 in test stage.Please give me some advice,thanks! python main.py --phase test --dataset_name sketch-photo --image_size 256 --epoch 45 --lambda_A 20.0 --lambda_B 20.0 --A_channels 1 --B_channels 1

    opened by JingangLang 0
  • Could I discard the discriminators and only use the

    Could I discard the discriminators and only use the "Reconstruction Error" during training?

    Hello, I'd like to know is it possible to train the Dual GAN without the discrinminator? which means I only need to minimize the "Reconstruction Error" during training?

    Many thanks!

    opened by ANYMS-A 0
  • segmentation fault

    segmentation fault

    when I was trying to train a sketch-photo model, it caused the segmentation fault. And I changed to another datasets, the fault happened, too.

    I used: python main.py --phase train --dataset_name sketch-photo --image_size 256 --epoch 45 --lambda_A 20.0 --lambda_B 20.0 --A_channels 1 --B_channels 1

    Could you please help me?

    opened by ghost 1
  • About the training loss

    About the training loss

    I read your code about the design for loss and found your implementation is different from that proposed in the paper. So you use the traditional loss of GAN instead of the WGAN loss? Does it mean WGAN loss might not be a good choice in practice?

    opened by wmyw96 4
Owner
Jack Yi
Jack Yi started programming in 2007. His mission is to make the creation of visual contents easier.
Jack Yi
TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

TensorFlow Ranking is a library for Learning-to-Rank (LTR) techniques on the TensorFlow platform

null 2.6k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Peter Lin 6.5k Jan 4, 2023
Robust Video Matting in PyTorch, TensorFlow, TensorFlow.js, ONNX, CoreML!

Robust Video Matting (RVM) English | 中文 Official repository for the paper Robust High-Resolution Video Matting with Temporal Guidance. RVM is specific

flow-dev 2 Aug 21, 2022
Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow

xRBM Library Implementation of Restricted Boltzmann Machine (RBM) and its variants in Tensorflow Installation Using pip: pip install xrbm Examples Tut

Omid Alemi 55 Dec 29, 2022
Functional TensorFlow Implementation of Singular Value Decomposition for paper Fast Graph Learning

tf-fsvd TensorFlow Implementation of Functional Singular Value Decomposition for paper Fast Graph Learning with Unique Optimal Solutions Cite If you f

Sami Abu-El-Haija 14 Nov 25, 2021
StyleGAN2 - Official TensorFlow Implementation

StyleGAN2 - Official TensorFlow Implementation

NVIDIA Research Projects 10.1k Dec 28, 2022
An efficient and effective learning to rank algorithm by mining information across ranking candidates. This repository contains the tensorflow implementation of SERank model. The code is developed based on TF-Ranking.

SERank An efficient and effective learning to rank algorithm by mining information across ranking candidates. This repository contains the tensorflow

Zhihu 44 Oct 20, 2022
Implementation of Perceiver, General Perception with Iterative Attention in TensorFlow

Perceiver This Python package implements Perceiver: General Perception with Iterative Attention by Andrew Jaegle in TensorFlow. This model builds on t

Rishit Dagli 84 Oct 15, 2022
Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow.

Denoised-Smoothing-TF Minimal implementation of Denoised Smoothing: A Provable Defense for Pretrained Classifiers in TensorFlow. Denoised Smoothing is

Sayak Paul 19 Dec 11, 2022
Unofficial Implementation of MLP-Mixer in TensorFlow

mlp-mixer-tf Unofficial Implementation of MLP-Mixer [abs, pdf] in TensorFlow. Note: This project may have some bugs in it. I'm still learning how to i

Rishabh Anand 24 Mar 23, 2022
Tensorflow implementation for Self-supervised Graph Learning for Recommendation

If the compilation is successful, the evaluator of cpp implementation will be called automatically. Otherwise, the evaluator of python implementation will be called.

null 152 Jan 7, 2023
Minimal implementation of PAWS (https://arxiv.org/abs/2104.13963) in TensorFlow.

PAWS-TF ?? Implementation of Semi-Supervised Learning of Visual Features by Non-Parametrically Predicting View Assignments with Support Samples (PAWS)

Sayak Paul 43 Jan 8, 2023
Unofficial TensorFlow implementation of the Keyword Spotting Transformer model

Keyword Spotting Transformer This is the unofficial TensorFlow implementation of the Keyword Spotting Transformer model. This model is used to train o

Intelligent Machines Limited 8 May 11, 2022
A tensorflow implementation of GCN-LPA

GCN-LPA This repository is the implementation of GCN-LPA (arXiv): Unifying Graph Convolutional Neural Networks and Label Propagation Hongwei Wang, Jur

Hongwei Wang 83 Nov 28, 2022
Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line Segment Detection"

M-LSD: Towards Light-weight and Real-time Line Segment Detection Official Tensorflow implementation of "M-LSD: Towards Light-weight and Real-time Line

NAVER/LINE Vision 357 Jan 4, 2023
Unofficial TensorFlow implementation of Protein Interface Prediction using Graph Convolutional Networks.

[TensorFlow] Protein Interface Prediction using Graph Convolutional Networks Unofficial TensorFlow implementation of Protein Interface Prediction usin

YeongHyeon Park 9 Oct 25, 2022
Tensorflow implementation of MIRNet for Low-light image enhancement

MIRNet Tensorflow implementation of the MIRNet architecture as proposed by Learning Enriched Features for Real Image Restoration and Enhancement. Lanu

Soumik Rakshit 91 Jan 6, 2023
Tensorflow python implementation of "Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos"

Learning High Fidelity Depths of Dressed Humans by Watching Social Media Dance Videos This repository is the official tensorflow python implementation

Yasamin Jafarian 287 Jan 6, 2023
Tensorflow implementation of Swin Transformer model.

Swin Transformer (Tensorflow) Tensorflow reimplementation of Swin Transformer model. Based on Official Pytorch implementation. Requirements tensorflow

null 167 Jan 8, 2023