All Projects → eveningglow → BicycleGAN-pytorch

eveningglow / BicycleGAN-pytorch

Licence: other
Pytorch implementation of BicycleGAN with implementation details

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to BicycleGAN-pytorch

pytorch-CycleGAN
Pytorch implementation of CycleGAN.
Stars: ✭ 39 (-60.61%)
Mutual labels:  generative-adversarial-network, image-translation, cyclegan
multitask-CycleGAN
Pytorch implementation of multitask CycleGAN with auxiliary classification loss
Stars: ✭ 88 (-11.11%)
Mutual labels:  generative-adversarial-network, image-translation, cyclegan
BicycleGAN
Tensorflow implementation of the NIPS paper "Toward Multimodal Image-to-Image Translation"
Stars: ✭ 30 (-69.7%)
Mutual labels:  generative-adversarial-network, image-translation, bicyclegan
Cocosnet
Cross-domain Correspondence Learning for Exemplar-based Image Translation. (CVPR 2020 Oral)
Stars: ✭ 211 (+113.13%)
Mutual labels:  generative-adversarial-network, image-translation
Cyclegan
Software that can generate photos from paintings, turn horses into zebras, perform style transfer, and more.
Stars: ✭ 10,933 (+10943.43%)
Mutual labels:  generative-adversarial-network, cyclegan
Gesturegan
[ACM MM 2018 Oral] GestureGAN for Hand Gesture-to-Gesture Translation in the Wild
Stars: ✭ 136 (+37.37%)
Mutual labels:  generative-adversarial-network, image-translation
Sparsely Grouped Gan
Code for paper "Sparsely Grouped Multi-task Generative Adversarial Networks for Facial Attribute Manipulation"
Stars: ✭ 68 (-31.31%)
Mutual labels:  generative-adversarial-network, image-translation
cycleGAN-PyTorch
A clean and lucid implementation of cycleGAN using PyTorch
Stars: ✭ 107 (+8.08%)
Mutual labels:  image-translation, cyclegan
Pytorch Cyclegan And Pix2pix
Image-to-Image Translation in PyTorch
Stars: ✭ 16,477 (+16543.43%)
Mutual labels:  generative-adversarial-network, cyclegan
ganslate
Simple and extensible GAN image-to-image translation framework. Supports natural and medical images.
Stars: ✭ 17 (-82.83%)
Mutual labels:  image-translation, cyclegan
publications-arruda-ijcnn-2019
Cross-Domain Car Detection Using Unsupervised Image-to-Image Translation: From Day to Night
Stars: ✭ 59 (-40.4%)
Mutual labels:  generative-adversarial-network, cyclegan
Pixel2style2pixel
Official Implementation for "Encoding in Style: a StyleGAN Encoder for Image-to-Image Translation"
Stars: ✭ 1,395 (+1309.09%)
Mutual labels:  generative-adversarial-network, image-translation
Lggan
[CVPR 2020] Local Class-Specific and Global Image-Level Generative Adversarial Networks for Semantic-Guided Scene Generation
Stars: ✭ 97 (-2.02%)
Mutual labels:  generative-adversarial-network, image-translation
Gannotation
GANnotation (PyTorch): Landmark-guided face to face synthesis using GANs (And a triple consistency loss!)
Stars: ✭ 167 (+68.69%)
Mutual labels:  generative-adversarial-network, cyclegan
Alice
NIPS 2017: ALICE: Towards Understanding Adversarial Learning for Joint Distribution Matching
Stars: ✭ 80 (-19.19%)
Mutual labels:  generative-adversarial-network, image-translation
pytorch-gans
PyTorch implementation of GANs (Generative Adversarial Networks). DCGAN, Pix2Pix, CycleGAN, SRGAN
Stars: ✭ 21 (-78.79%)
Mutual labels:  generative-adversarial-network, cyclegan
gans-2.0
Generative Adversarial Networks in TensorFlow 2.0
Stars: ✭ 76 (-23.23%)
Mutual labels:  generative-adversarial-network, cyclegan
Cyclegan Tensorflow
An implementation of CycleGan using TensorFlow
Stars: ✭ 1,096 (+1007.07%)
Mutual labels:  generative-adversarial-network, cyclegan
Cyclegan Qp
Official PyTorch implementation of "Artist Style Transfer Via Quadratic Potential"
Stars: ✭ 59 (-40.4%)
Mutual labels:  generative-adversarial-network, cyclegan
CycleGAN-gluon-mxnet
this repo attemps to reproduce Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks(CycleGAN) use gluon reimplementation
Stars: ✭ 31 (-68.69%)
Mutual labels:  generative-adversarial-network, cyclegan

BicycleGAN-pytorch

Pytorch implementation of BicycleGAN : Toward Multimodal Image-to-Image Translation.

Result

Edges2Shoes

Image size is 128 x 128 and normal discriminator is used, not conditional discriminator. You can check what the conditional discriminator is in Advanced-BicycleGAN in this repository. It generates slightly more diverse, clear and realistic images than the ones below.

  • Random sampling

  • Linear interpolated sampling

Model description

cVAE-GAN

cVAE-GAN is an image reconstruction process. From this, the encoder can extract proper latent code z containing features of given image 'B'. Through this process, the generator can generate image which has features of 'B' but the generator also needs to be able to fool the discriminator. Futhermore, cVAE-GAN uses KL-divergence to make the generator be able to generate images using randomly sampled z from normal distribution at the test phase.

cLR-GAN

This is an latent code reconstruction process. If many latent codes correspond to a same output mode, this is called mode collapse. The main purpose of cLR-GAN is to make invertible mapping between B and z. It leads to bijective consistency between latent encoding and output modes that is significant in preventing model from mode collapse.

Prerequisites

Training step  

Before getting started, suppose that we want to optmize G which can convert domain A into B.

real_B : A real image of domain B from training data set
fake_B : A fake image of domain B made by the generator
encoded_z : Latent code z made by the encoder
random_z : Latent code z sampled randomly from normal distribution

1. Optimize D

  • Optimize D in cVAE-GAN using real_B and fake_B made with encoded_z(Adversarial loss).
  • Optimize D in cLR-GAN using real_B and fake_B made with random_z(Adversarial loss).

2. Optimize G or E

  • Optimize G and E in cVAE-GAN using fake_B made with encoded_z(Adversarial loss).
  • Optimize G and E in cVAE-GAN using real_B and fake_B made with encoded_z(Image reconstruction loss).
  • Optimize E in cVAE-GAN using the encoder outputs, mu and log_variance(KL-div loss).
  • Optimize G in cLR-GAN using fake_B made with random_z(Adversarial loss).

3. Optimize ONLY G(Do not update E)

  • Optimize G in cLR-GAN using random_z and the encoder output mu(Latent code reconstruction loss).

Implementation details

  • Multi discriminator
    First, two discriminators are used for two different last output sizes(PatchGAN); 14x14 and 30x30, for the discriminator to learn from two different scales.
    Second, each discriminator from above have two discriminators because of two images each made with encoded_z(cVAE-GAN) and random_z(cLR-GAN) from N(mu, std) and N(0, 1) respectively. Two discriminators are better than just one discriminator for both distributions.
    Totally, four discriminators are used; (cVAE-GAN, 14x14), (cVAE-GAN, 30x30), (cLR-GAN, 14x14) and (cLR-GAN, 30x30).

  • Encoder
    E_ResNet is used, not E_CNN. Residual block in the encoder is slightly different with the usual one. Check ResBlock class and Encoder class in model.py.

  • How to inject the latent code z to the generator
    Inject only to the input by concatenating, not to all intermediate layers

  • Training data
    Batch size is 1 for both cVAE-GAN and cLR-GAN which means that get two images from the dataloader and distribute to cVAE-GAN and cLR-GAN.

  • How to encode with encoder
    Encoder returns mu and log_variance. Reparameterization trick is used, so encoded_z = random_z * std + mu such that std = exp(log_variance / 2).

  • How to calculate KL divergence
    Following formula is from here. Also if you want to see simple and clean VAE code, you can check here.

From N(0, 1) get KL divergence, so it leads to following formula.

  • How to reconstruct z in cLR-GAN
    mu and log_variance are derived from the encoder in cLR-GAN. Use L1 loss between mu and random_z, not encoded_z and random_z. The reasons are the followings or you can check here.

    1. cLR-GAN is for point estimation not distribution estimation.
    2. If std is too big, L1 loss between encoded_z and random_z can be unstable.

Dataset

You can download many datasets for BicycleGAN from here.

  • Training images : data/edges2shoes/train
  • Test images : data/edges2shoes/test

How to use

Train

python train.py --root=data/edges2shoes --result_dir=result --weight_dir=weight

Test

Random sample

  • Most recent
    python test.py --sample_type=random --root=data/edges2shoes --result_dir=test --weight_dir=weight --img_num=5

  • Set epoch
    python test.py --sample_type=random --root=data/edges2shoes --result_dir=test --weight_dir=weight --img_num=5 --epoch=55

Interpolation

  • Most recent
    python test.py --sample_type=interpolation --root=data/edges2shoes --result_dir=test --weight_dir=weight --img_num=10

  • Set epoch
    python test.py --sample_type=interpolation --root=data/edges2shoes --result_dir=test --weight_dir=weight --img_num=10 --epoch=55

Future work

  • Training with other datasets.
  • New model using conditional discriminator is on the training now Check Advanced-BicycleGAN
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].