Home

Awesome

pytorch-generative-model-collections

Original : [Tensorflow version]

Pytorch implementation of various GANs.

This repository was re-implemented with reference to tensorflow-generative-model-collections by Hwalsuk Lee

I tried to implement this repository as much as possible with tensorflow-generative-model-collections, But some models are a little different.

This repository is included code for CPU mode Pytorch, but i did not test. I tested only in GPU mode Pytorch.

Dataset

I only tested the code on MNIST and Fashion-MNIST.

Generative Adversarial Networks (GANs)

Lists (Table is borrowed from tensorflow-generative-model-collections)

NamePaper LinkValue Function
GANArxiv<img src = 'assets/equations/GAN.png' height = '70px'>
LSGANArxiv<img src = 'assets/equations/LSGAN.png' height = '70px'>
WGANArxiv<img src = 'assets/equations/WGAN.png' height = '105px'>
WGAN_GPArxiv<img src = 'assets/equations/WGAN_GP.png' height = '70px'>
DRAGANArxiv<img src = 'assets/equations/DRAGAN.png' height = '70px'>
CGANArxiv<img src = 'assets/equations/CGAN.png' height = '70px'>
infoGANArxiv<img src = 'assets/equations/infoGAN.png' height = '70px'>
ACGANArxiv<img src = 'assets/equations/ACGAN.png' height = '70px'>
EBGANArxiv<img src = 'assets/equations/EBGAN.png' height = '70px'>
BEGANArxiv<img src = 'assets/equations/BEGAN.png' height = '105px'>

Variants of GAN structure (Figures are borrowed from tensorflow-generative-model-collections)

<img src = 'assets/etc/GAN_structure.png' height = '600px'>

Results for mnist

Network architecture of generator and discriminator is the exaclty sames as in infoGAN paper.
For fair comparison of core ideas in all gan variants, all implementations for network architecture are kept same except EBGAN and BEGAN. Small modification is made for EBGAN/BEGAN, since those adopt auto-encoder strucutre for discriminator. But I tried to keep the capacity of discirminator.

The following results can be reproduced with command:

python main.py --dataset mnist --gan_type <TYPE> --epoch 50 --batch_size 64

Fixed generation

All results are generated from the fixed noise vector.

NameEpoch 1Epoch 25Epoch 50GIF
GAN<img src = 'assets/mnist_results/GAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/GAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/GAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/GAN_generate_animation.gif' height = '200px'>
LSGAN<img src = 'assets/mnist_results/LSGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/LSGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/LSGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/LSGAN_generate_animation.gif' height = '200px'>
WGAN<img src = 'assets/mnist_results/WGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/WGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/WGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/WGAN_generate_animation.gif' height = '200px'>
WGAN_GP<img src = 'assets/mnist_results/WGAN_GP_epoch001.png' height = '200px'><img src = 'assets/mnist_results/WGAN_GP_epoch025.png' height = '200px'><img src = 'assets/mnist_results/WGAN_GP_epoch050.png' height = '200px'><img src = 'assets/mnist_results/WGAN_GP_generate_animation.gif' height = '200px'>
DRAGAN<img src = 'assets/mnist_results/DRAGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/DRAGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/DRAGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/DRAGAN_generate_animation.gif' height = '200px'>
EBGAN<img src = 'assets/mnist_results/EBGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/EBGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/EBGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/EBGAN_generate_animation.gif' height = '200px'>
BEGAN<img src = 'assets/mnist_results/BEGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/BEGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/BEGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/BEGAN_generate_animation.gif' height = '200px'>

Conditional generation

Each row has the same noise vector and each column has the same label condition.

NameEpoch 1Epoch 25Epoch 50GIF
CGAN<img src = 'assets/mnist_results/CGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/CGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/CGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/CGAN_generate_animation.gif' height = '200px'>
ACGAN<img src = 'assets/mnist_results/ACGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/ACGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/ACGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/ACGAN_generate_animation.gif' height = '200px'>
infoGAN<img src = 'assets/mnist_results/infoGAN_epoch001.png' height = '200px'><img src = 'assets/mnist_results/infoGAN_epoch025.png' height = '200px'><img src = 'assets/mnist_results/infoGAN_epoch050.png' height = '200px'><img src = 'assets/mnist_results/infoGAN_generate_animation.gif' height = '200px'>

InfoGAN : Manipulating two continous codes

All results have the same noise vector and label condition, but have different continous vector.

NameEpoch 1Epoch 25Epoch 50GIF
infoGAN<img src = 'assets/mnist_results/infoGAN_cont_epoch001.png' height = '200px'><img src = 'assets/mnist_results/infoGAN_cont_epoch025.png' height = '200px'><img src = 'assets/mnist_results/infoGAN_cont_epoch050.png' height = '200px'><img src = 'assets/mnist_results/infoGAN_cont_generate_animation.gif' height = '200px'>

Loss plot

NameLoss
GAN<img src = 'assets/mnist_results/GAN_loss.png' height = '230px'>
LSGAN<img src = 'assets/mnist_results/LSGAN_loss.png' height = '230px'>
WGAN<img src = 'assets/mnist_results/WGAN_loss.png' height = '230px'>
WGAN_GP<img src = 'assets/mnist_results/WGAN_GP_loss.png' height = '230px'>
DRAGAN<img src = 'assets/mnist_results/DRAGAN_loss.png' height = '230px'>
EBGAN<img src = 'assets/mnist_results/EBGAN_loss.png' height = '230px'>
BEGAN<img src = 'assets/mnist_results/BEGAN_loss.png' height = '230px'>
CGAN<img src = 'assets/mnist_results/CGAN_loss.png' height = '230px'>
ACGAN<img src = 'assets/mnist_results/ACGAN_loss.png' height = '230px'>
infoGAN<img src = 'assets/mnist_results/infoGAN_loss.png' height = '230px'>

Results for fashion-mnist

Comments on network architecture in mnist are also applied to here.
Fashion-mnist is a recently proposed dataset consisting of a training set of 60,000 examples and a test set of 10,000 examples. Each example is a 28x28 grayscale image, associated with a label from 10 classes. (T-shirt/top, Trouser, Pullover, Dress, Coat, Sandal, Shirt, Sneaker, Bag, Ankle boot)

The following results can be reproduced with command:

python main.py --dataset fashion-mnist --gan_type <TYPE> --epoch 50 --batch_size 64

Fixed generation

All results are generated from the fixed noise vector.

NameEpoch 1Epoch 25Epoch 50GIF
GAN<img src = 'assets/fashion_mnist_results/GAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/GAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/GAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/GAN_generate_animation.gif' height = '200px'>
LSGAN<img src = 'assets/fashion_mnist_results/LSGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/LSGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/LSGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/LSGAN_generate_animation.gif' height = '200px'>
WGAN<img src = 'assets/fashion_mnist_results/WGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/WGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/WGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/WGAN_generate_animation.gif' height = '200px'>
WGAN_GP<img src = 'assets/fashion_mnist_results/WGAN_GP_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/WGAN_GP_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/WGAN_GP_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/WGAN_GP_generate_animation.gif' height = '200px'>
DRAGAN<img src = 'assets/fashion_mnist_results/DRAGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/DRAGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/DRAGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/DRAGAN_generate_animation.gif' height = '200px'>
EBGAN<img src = 'assets/fashion_mnist_results/EBGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/EBGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/EBGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/EBGAN_generate_animation.gif' height = '200px'>
BEGAN<img src = 'assets/fashion_mnist_results/BEGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/BEGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/BEGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/BEGAN_generate_animation.gif' height = '200px'>

Conditional generation

Each row has the same noise vector and each column has the same label condition.

NameEpoch 1Epoch 25Epoch 50GIF
CGAN<img src = 'assets/fashion_mnist_results/CGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/CGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/CGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/CGAN_generate_animation.gif' height = '200px'>
ACGAN<img src = 'assets/fashion_mnist_results/ACGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/ACGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/ACGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/ACGAN_generate_animation.gif' height = '200px'>
infoGAN<img src = 'assets/fashion_mnist_results/infoGAN_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/infoGAN_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/infoGAN_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/infoGAN_generate_animation.gif' height = '200px'>

InfoGAN : Manipulating two continous codes

All results have the same noise vector and label condition, but have different continous vector.

NameEpoch 1Epoch 25Epoch 50GIF
infoGAN<img src = 'assets/fashion_mnist_results/infoGAN_cont_epoch001.png' height = '200px'><img src = 'assets/fashion_mnist_results/infoGAN_cont_epoch025.png' height = '200px'><img src = 'assets/fashion_mnist_results/infoGAN_cont_epoch050.png' height = '200px'><img src = 'assets/fashion_mnist_results/infoGAN_cont_generate_animation.gif' height = '200px'>

Loss plot

NameLoss
GAN<img src = 'assets/fashion_mnist_results/GAN_loss.png' height = '230px'>
LSGAN<img src = 'assets/fashion_mnist_results/LSGAN_loss.png' height = '230px'>
WGAN<img src = 'assets/fashion_mnist_results/WGAN_loss.png' height = '230px'>
WGAN_GP<img src = 'assets/fashion_mnist_results/WGAN_GP_loss.png' height = '230px'>
DRAGAN<img src = 'assets/fashion_mnist_results/DRAGAN_loss.png' height = '230px'>
EBGAN<img src = 'assets/fashion_mnist_results/EBGAN_loss.png' height = '230px'>
BEGAN<img src = 'assets/fashion_mnist_results/BEGAN_loss.png' height = '230px'>
CGAN<img src = 'assets/fashion_mnist_results/CGAN_loss.png' height = '230px'>
ACGAN<img src = 'assets/fashion_mnist_results/ACGAN_loss.png' height = '230px'>
infoGAN<img src = 'assets/fashion_mnist_results/infoGAN_loss.png' height = '230px'>

Folder structure

The following shows basic folder structure.

├── main.py # gateway
├── data
│   ├── mnist # mnist data (not included in this repo)
│   ├── ...
│   ├── ...
│   └── fashion-mnist # fashion-mnist data (not included in this repo)
│
├── GAN.py # vainilla GAN
├── utils.py # utils
├── dataloader.py # dataloader
├── models # model files to be saved here
└── results # generation results to be saved here

Development Environment

Acknowledgements

This implementation has been based on tensorflow-generative-model-collections and tested with Pytorch 0.4.0 on Ubuntu 16.04 using GPU.