wgan, wgan2(improved, gp), infogan, and dcgan implementation in lasagne, keras, pytorch

Overview

Generative Adversarial Notebooks

Collection of my Generative Adversarial Network implementations

Most codes are for python3, most notebooks works on

CycleGAN

  • CycleGAN-lasagne
  • CycleGAN-keras

CycleGAN results

Result after 3 hours and 58 epochs on a GTX 1080. From top to bottom: Input, Fake, Recreate of the input.

Face-off result. From top to bottom: Input, Fake, Recreate of the input. [youtube video](https://www.youtube.com/watch?v=Fea4kZq0oFQ)

pix2pix

  • pix2pix-keras: pix2pix GAN Keras implementation
  • pix2pix-lasagne: pix2pix GAN Lasagne implementation
  • pix2pix-torch: pix2pix GAN pytorch implementation

pix2pix sample results

Validation result of edges-to-shoes after 12 epochs. From top to bottom: Input, Ground truth, the result.

Validation result of facades dataset after 150 epochs using resnet. From top to bottom: Input, Ground truth, the result.

WGAN on CIFAR10

WGAN2 (improved WGAN/WGAN-gp)

  • wgan2-lasagne: improved WGAN Lasagne implementation (on CIFAR10)
  • wgan2-keras: improved WGAN Keras implementation (on CIFAR10)
  • wgan2-lasagne-anime: WGAN on anime face images, lasagne
  • wgan2-AC-lasagne: improved WGAN Lasagne implementation with Auxillary classfier

WGAN2 sample results

  • cifar10 dataset

  • cifar10 dataset with Auxillary classfier

  • anime face dataset

InfoGAN

  • mnist-infogan: InfoGAN Lasagne on MNIST dataset
  • mnist-infogan-paper-uniform: InfoGAN Lasagne on MNIST dataset (fllowing the paper implementation)

InfoGAN sample results

DCGAN

  • dcgan-lasagne: DCGAN in Lasagne

DCGAN sample results

Comments
  • loss function for D in wgan2-keras.py

    loss function for D in wgan2-keras.py

    Hi

    I think the loss function in wgan2-keras should be

    loss = loss_fake - loss_real + nz * λ * grad_penalty
    

    in your In[9]

    Because you called the loss_mixed = K.mean(netD(netD_mixed_input)) before, which divide nz, so you should make up here.

    Am I right?

    opened by jiangzidong 4
  • save weight of pix2pix-keras

    save weight of pix2pix-keras

    Hi tjwei, Thank for your wonderful code. could you please tell me how to save weight of that pix2pix-keras jupyter notebook after finish training? Thank you in advance.

    opened by shoutashi 2
  • KeyError: 'module name can\'t contain

    KeyError: 'module name can\'t contain "."'

    Hi, @tjwei when I execute the wgan2-AC-lasagne.ipynb in your repository, the following error appears:

    KeyError Traceback (most recent call last) in ----> 1 netG = DCGAN_G_nobn(imageSize, nz, nc, ngf, 1, n_extra_layers) 2 netG.apply(weights_init)

    in init(self, isize, nz, nc, ngf, ngpu, n_extra_layers) 59 main = nn.Sequential() 60 main.add_module('initial.{0}-{1}.convt'.format(nz, cngf), ---> 61 nn.ConvTranspose2d(nz, cngf, 4, 1, 0, bias=False)) 62 main.add_module('initial.{0}.relu'.format(cngf), 63 nn.ReLU(True))

    /opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py in add_module(self, name, module) 184 raise KeyError("attribute '{}' already exists".format(name)) 185 elif '.' in name: --> 186 raise KeyError("module name can't contain "."") 187 elif name == '': 188 raise KeyError("module name can't be empty string """)

    KeyError: 'module name can't contain "."'

    How can I solve this problom? Thanks a lot.

    opened by keenlykeenly 2
  • Change of Keras API

    Change of Keras API

    When I run pix2pix-keras.ipynb, in the fifth block

    if K._BACKEND == 'theano':
    

    raises

    AttributeError: module 'keras.backend' has no attribute '_BACKEND'
    

    In the current Keras version (2.2.5), the proper API has changed to K.backend(). Would you please fix that, or should I draft a PR?

    Besides, consider that the repo is created 2-3 years ago, there may be a lot of such API change and will be troublesome to fix them all. Would it be helpful to add a requirements.txt stating all the proper version of used packages, to avoiding such problems?

    Thanks!

    opened by Vopaaz 2
  • help in pix2pix-keras

    help in pix2pix-keras

    hello . i have got problem in pix2pix-keras

    i dont know what shall i download your structers dataset could you get me direct link to this dataset. i know this link http://cmp.felk.cvut.cz/~tylecr1/facade/ or http://vision.cs.utexas.edu/projects/finegrained/utzap50k/ but i dont know how prepare this dataset

    data = "edges2shoes" data = "facades" direction = 0 trainAB = load_data('pix2pix/{}/train/.jpg'.format(data)) valAB = load_data('pix2pix/{}/val/.jpg'.format(data)) assert len(trainAB) and len(valAB)

    opened by noronet 1
Owner
tjwei
the avatar is generated by my Quick-Neural-Art-Transfer with a picture of Hatsune Miku
tjwei
Bayesian dessert for Lasagne

Gelato Bayesian dessert for Lasagne Recent results in Bayesian statistics for constructing robust neural networks have proved that it is one of the be

Maxim Kochurov 84 May 11, 2020
Official implementation of "GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators" (NeurIPS 2020)

GS-WGAN This repository contains the implementation for GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators (NeurIPS

null 46 Nov 9, 2022
FuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space OptimizationFuseDream: Training-Free Text-to-Image Generationwith Improved CLIP+GAN Space Optimization

FuseDream This repo contains code for our paper (paper link): FuseDream: Training-Free Text-to-Image Generation with Improved CLIP+GAN Space Optimizat

XCL 191 Dec 31, 2022
Deeper DCGAN with AE stabilization

AEGeAN Deeper DCGAN with AE stabilization Parallel training of generative adversarial network as an autoencoder with dedicated losses for each stage.

Tyler Kvochick 36 Feb 17, 2022
This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras)

Yogi-Optimizer_Keras This is an implementation of Googles Yogi-Optimizer in Keras (tf.keras) The NeurIPS-Paper can be found here: http://papers.nips.c

null 14 Sep 13, 2022
Keras udrl - Keras implementation of Upside Down Reinforcement Learning

keras_udrl Keras implementation of Upside Down Reinforcement Learning This is me

Eder Santana 7 Jan 24, 2022
Classification models 1D Zoo - Keras and TF.Keras

Classification models 1D Zoo - Keras and TF.Keras This repository contains 1D variants of popular CNN models for classification like ResNets, DenseNet

Roman Solovyev 12 Jan 6, 2023
Example-custom-ml-block-keras - Custom Keras ML block example for Edge Impulse

Custom Keras ML block example for Edge Impulse This repository is an example on

Edge Impulse 8 Nov 2, 2022
The official PyTorch implementation of recent paper - SAINT: Improved Neural Networks for Tabular Data via Row Attention and Contrastive Pre-Training

This repository is the official PyTorch implementation of SAINT. Find the paper on arxiv SAINT: Improved Neural Networks for Tabular Data via Row Atte

Gowthami Somepalli 284 Dec 21, 2022
PyTorch implementation of Progressive Growing of GANs for Improved Quality, Stability, and Variation.

PyTorch implementation of Progressive Growing of GANs for Improved Quality, Stability, and Variation. Warning: the master branch might collapse. To ob

null 559 Dec 14, 2022
Official PyTorch Implementation of Embedding Transfer with Label Relaxation for Improved Metric Learning, CVPR 2021

Embedding Transfer with Label Relaxation for Improved Metric Learning Official PyTorch implementation of CVPR 2021 paper Embedding Transfer with Label

Sungyeon Kim 37 Dec 6, 2022
A pytorch implementation of Paper "Improved Training of Wasserstein GANs"

WGAN-GP An pytorch implementation of Paper "Improved Training of Wasserstein GANs". Prerequisites Python, NumPy, SciPy, Matplotlib A recent NVIDIA GPU

Marvin Cao 1.4k Dec 14, 2022
The PyTorch improved version of TPAMI 2017 paper: Face Alignment in Full Pose Range: A 3D Total Solution.

Face Alignment in Full Pose Range: A 3D Total Solution By Jianzhu Guo. [Updates] 2020.8.30: The pre-trained model and code of ECCV-20 are made public

Jianzhu Guo 3.4k Jan 2, 2023
Unofficial & improved implementation of NeRF--: Neural Radiance Fields Without Known Camera Parameters

[Unofficial code-base] NeRF--: Neural Radiance Fields Without Known Camera Parameters [ Project | Paper | Official code base ] ⬅️ Thanks the original

Jianfei Guo 239 Dec 22, 2022
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 360 Dec 10, 2022
Amazon Forest Computer Vision: Satellite Image tagging code using PyTorch / Keras with lots of PyTorch tricks

Amazon Forest Computer Vision Satellite Image tagging code using PyTorch / Keras Here is a sample of images we had to work with Source: https://www.ka

Mamy Ratsimbazafy 359 Jan 5, 2023
Puzzle-CAM: Improved localization via matching partial and full features.

Puzzle-CAM The official implementation of "Puzzle-CAM: Improved localization via matching partial and full features".

Sanghyun Jo 150 Nov 14, 2022
Stochastic Downsampling for Cost-Adjustable Inference and Improved Regularization in Convolutional Networks

Stochastic Downsampling for Cost-Adjustable Inference and Improved Regularization in Convolutional Networks (SDPoint) This repository contains the cod

Jason Kuen 17 Jul 4, 2022
ResNEsts and DenseNEsts: Block-based DNN Models with Improved Representation Guarantees

ResNEsts and DenseNEsts: Block-based DNN Models with Improved Representation Guarantees This repository is the official implementation of the empirica

Kuan-Lin (Jason) Chen 2 Oct 2, 2022