DCGAN LSGAN WGAN-GP DRAGAN PyTorch

Overview

Recommendation

  • Our GAN based work for facial attribute editing - AttGAN.

News

  • 8 April 2019: We re-implement these GANs by Tensorflow 2! The old version is here: v1 or in the "v1" directory.
  • PyTorch Version


GANs - Tensorflow 2

Tensorflow 2 implementations of DCGAN, LSGAN, WGAN-GP and DRAGAN.

Exemplar results

Fashion-MNIST

DCGAN LSGAN WGAN-GP DRAGAN

CelebA

DCGAN LSGAN
WGAN-GP DRAGAN

Anime

WGAN-GP DRAGAN

Usage

  • Environment

    • Python 3.6

    • TensorFlow 2.2, TensorFlow Addons 0.10.0

    • OpenCV, scikit-image, tqdm, oyaml

    • we recommend Anaconda or Miniconda, then you can create the TensorFlow 2.2 environment with commands below

      conda create -n tensorflow-2.2 python=3.6
      
      source activate tensorflow-2.2
      
      conda install scikit-image tqdm tensorflow-gpu=2.2
      
      conda install -c conda-forge oyaml
      
      pip install tensorflow-addons==0.10.0
    • NOTICE: if you create a new conda environment, remember to activate it before any other command

      source activate tensorflow-2.2
  • Datasets

  • Examples of training

    • Fashion-MNIST DCGAN

      CUDA_VISIBLE_DEVICES=0 python train.py --dataset=fashion_mnist --epoch=25 --adversarial_loss_mode=gan
    • CelebA DRAGAN

      CUDA_VISIBLE_DEVICES=0 python train.py --dataset=celeba --epoch=25 --adversarial_loss_mode=gan --gradient_penalty_mode=dragan
    • Anime WGAN-GP

      CUDA_VISIBLE_DEVICES=0 python train.py --dataset=anime --epoch=200 --adversarial_loss_mode=wgan --gradient_penalty_mode=wgan-gp --n_d=5
    • see more training exampls in commands.sh

    • tensorboard for loss visualization

      tensorboard --logdir ./output/fashion_mnist_gan/summaries --port 6006
Comments
  • GPU is full

    GPU is full

    Hello, when the code runs, the memory is full. What happened? My python version is 3.6, tensorflow version is 1.11, my GPU is 1080ti, thanks! the error is as follow: An error ocurred while starting the kernel 2019󈚥󈚦 08:40:45.229298: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2019󈚥󈚦 08:40:45.601632: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties: name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.582 pciBusID: 0000:65:00.0 totalMemory: 11.00GiB freeMemory: 9.10GiB 2019󈚥󈚦 08:40:45.603929: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0 2019󈚥󈚦 08:40:46.556261: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix: 2019󈚥󈚦 08:40:46.558110: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977] 0 2019󈚥󈚦 08:40:46.558407: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0: N 2019󈚥󈚦 08:40:46.558836: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8789 MB memory) ‑> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:65:00.0, compute capability: 6.1)

    opened by lixingbao 9
  • About problem with generating image size

    About problem with generating image size

    Hello,can your code only generate 64×64 images? Can I generate an image of the specified size? For example: 256 × 256, if you can, what parameters need to be modified?thank you!

    opened by lixingbao 6
  • WGAN-GP does not work!!!

    WGAN-GP does not work!!!

    I have updated the code from TensorFlow 2.0-alpha to TensorFlow 2.0, everything works well except for WGAN-GP (it works in tf2.0-alpha). In tf2.0, The gradient penalty seems very unstable, but I cannot find out the problem. Does anybody help? I will be grateful.

    help wanted 
    opened by LynnHo 3
  • how about 3D data?

    how about 3D data?

    Hi!

    cartoon faces original size is [96, 96, 3],the number 3 means 3 channel RGB data. But if I have grayscale data with 3 slices, i.e the size is [121,145,3], Can I simply use this code? If not, what should I change based on this code?

    Thanks for your work! Look forward to your response.

    opened by KakaVlasic 3
  • c_iter isn't used

    c_iter isn't used

    c_iter is defined but not used in all of the WGAN files. What is the correct behaviour? i.e should the critic be optimised heavily initially or not?

    Also, can you confirm that you use a learning rate parameter of 0.0002, regardless of whether RMSProp or Adam is used as the optimiser?

    opened by davidADSP 3
  • About n_critic = 5

    About n_critic = 5

    i use the code whitch be used to train cartoon pictures with WGAN-GP. i don't know what the mean of n_critic = 5 , and why do you to set it. thanks.

    opened by tuoniaoren 3
  • Error while using celeba dataset

    Error while using celeba dataset

    I am getting this error while running train.py TypeError: Input 'filename' of 'ReadFile' Op has type float32 that does not match expected type of string. Please help with this. Thanks in advance

    opened by yksolanki9 2
  • Where do you freeze the gradient descent?

    Where do you freeze the gradient descent?

    Hello, I am confused about how do you freeze the gradient descent to the other model. When training d_step, I suppose the generator should be freezed, as f_logit is based on generator and used in d_loss; similarly, when training g_step, I suppose the discriminator should be freezed, as f_logit depens on discriminator.

    However, I do not see where you stop those gradients flowing to the unwanted part, either generator or discriminator. Would you please provide some hints for me? Thank you.

    opened by ybsave 2
  • do you try to use Resnet in wgan-gp?

    do you try to use Resnet in wgan-gp?

    Have you compared the difference between the network structure of DCGAN and the structure of Resnet in WGAN-GP?Is the effect of Resnet will be better than the structure of DCGAN.

    opened by tuoniaoren 2
  • running question

    running question

    do you meet the program stop without mistakes when the code running for some time ,and the GPU stops work.I changed the value of num_threads。(from 16 to 10)。i run it again.i don't know Is it because the value is too high。

    opened by tuoniaoren 2
  • License

    License

    Hi Zhenliang He, I wonder whether you would be willing to please license this code under an open source license? If so please add a license, or if not please just close this request. Thanks, Connelly

    opened by connellybarnes 2
  • A problem for your DCGAN architecture

    A problem for your DCGAN architecture

    Hi, - Your work is really interesting. But I have found there is a problem for your DCGAN that I didn't understand. You generate noise twice when train discriminator and generator for each iteration, like the blue lines in the following picture. In soumith code (includes some official DCGAN code), he only generate noise once: https://github.com/soumith/dcgan.torch. Could you please tell me the reason?

    image

    opened by RayGuo-C 1
  • NameError: name 'shape' is not defined

    NameError: name 'shape' is not defined

    Traceback (most recent call last): File "D:/github/DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2-master/DCGAN-LSGAN-WGAN-GP-DRAGAN-Tensorflow-2-master/train.py", line 91, in G = module.ConvGenerator(input_shape=(1, 1, args.z_dim), output_channels=shape[-1], n_upsamplings=n_G_upsamplings, name='G_%s' % args.dataset) NameError: name 'shape' is not defined please tell me why

    opened by Tonyztj 0
Releases(v1)
Owner
Zhenliang He
Zhenliang He
MacroTools provides a library of tools for working with Julia code and expressions.

MacroTools.jl MacroTools provides a library of tools for working with Julia code and expressions. This includes a powerful template-matching system an

FluxML 278 Dec 11, 2022
Learning Skeletal Articulations with Neural Blend Shapes

This repository provides an end-to-end library for automatic character rigging and blend shapes generation as well as a visualization tool. It is based on our work Learning Skeletal Articulations wit

Peizhuo 504 Dec 30, 2022
Tool for live presentations using manim

manim-presentation Tool for live presentations using manim Install pip install manim-presentation opencv-python Usage Use the class Slide as your sce

Federico Galatolo 146 Jan 06, 2023
PyTorch package for the discrete VAE used for DALL·E.

Overview [Blog] [Paper] [Model Card] [Usage] This is the official PyTorch package for the discrete VAE used for DALL·E. Installation Before running th

OpenAI 9.5k Jan 05, 2023
Python scripts for performing object detection with the 1000 labels of the ImageNet dataset in ONNX.

Python scripts for performing object detection with the 1000 labels of the ImageNet dataset in ONNX. The repository combines a class agnostic object localizer to first detect the objects in the image

Ibai Gorordo 24 Nov 14, 2022
Relative Uncertainty Learning for Facial Expression Recognition

Relative Uncertainty Learning for Facial Expression Recognition The official implementation of the following paper at NeurIPS2021: Title: Relative Unc

35 Dec 28, 2022
Ludwig is a toolbox that allows to train and evaluate deep learning models without the need to write code.

Translated in 🇰🇷 Korean/ Ludwig is a toolbox that allows users to train and test deep learning models without the need to write code. It is built on

Ludwig 8.7k Dec 31, 2022
ViSD4SA, a Vietnamese Span Detection for Aspect-based sentiment analysis dataset

UIT-ViSD4SA PACLIC 35 General Introduction This repository contains the data of the paper: Span Detection for Vietnamese Aspect-Based Sentiment Analys

Nguyễn Thị Thanh Kim 5 Nov 13, 2022
A customisable game where you have to quickly click on black tiles in order of appearance while avoiding clicking on white squares.

W.I.P-Aim-Memory-Game A customisable game where you have to quickly click on black tiles in order of appearance while avoiding clicking on white squar

dE_soot 1 Dec 08, 2021
This repository is for Contrastive Embedding Distribution Refinement and Entropy-Aware Attention Network (CEDR)

CEDR This repository is for Contrastive Embedding Distribution Refinement and Entropy-Aware Attention Network (CEDR) introduced in the following paper

phoenix 3 Feb 27, 2022
🧠 A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation.', ECCV 2016

Deep CORAL A PyTorch implementation of 'Deep CORAL: Correlation Alignment for Deep Domain Adaptation. B Sun, K Saenko, ECCV 2016' Deep CORAL can learn

Andy Hsu 200 Dec 25, 2022
KoRean based ELECTRA pre-trained models (KR-ELECTRA) for Tensorflow and PyTorch

KoRean based ELECTRA (KR-ELECTRA) This is a release of a Korean-specific ELECTRA model with comparable or better performances developed by the Computa

12 Jun 03, 2022
PGPortfolio: Policy Gradient Portfolio, the source code of "A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem"(https://arxiv.org/pdf/1706.10059.pdf).

This is the original implementation of our paper, A Deep Reinforcement Learning Framework for the Financial Portfolio Management Problem (arXiv:1706.1

Zhengyao Jiang 1.5k Dec 29, 2022
kapre: Keras Audio Preprocessors

Kapre Keras Audio Preprocessors - compute STFT, ISTFT, Melspectrogram, and others on GPU real-time. Tested on Python 3.6 and 3.7 Why Kapre? vs. Pre-co

Keunwoo Choi 867 Dec 29, 2022
Film review classification

Film review classification Решение задачи классификации отзывов на фильмы на положительные и отрицательные с помощью рекуррентных нейронных сетей 1. З

Nikita Dukin 3 Jan 21, 2022
[UNMAINTAINED] Automated machine learning for analytics & production

auto_ml Automated machine learning for production and analytics Installation pip install auto_ml Getting started from auto_ml import Predictor from au

Preston Parry 1.6k Jan 02, 2023
Easy to use Python camera interface for NVIDIA Jetson

JetCam JetCam is an easy to use Python camera interface for NVIDIA Jetson. Works with various USB and CSI cameras using Jetson's Accelerated GStreamer

NVIDIA AI IOT 358 Jan 02, 2023
Pydantic models for pywttr and aiopywttr.

Pydantic models for pywttr and aiopywttr.

Almaz 2 Dec 08, 2022
Unsupervised Real-World Super-Resolution: A Domain Adaptation Perspective

Unofficial pytorch implementation of the paper "Unsupervised Real-World Super-Resolution: A Domain Adaptation Perspective"

16 Nov 21, 2022
Show Me the Whole World: Towards Entire Item Space Exploration for Interactive Personalized Recommendations

HierarchicyBandit Introduction This is the implementation of WSDM 2022 paper : Show Me the Whole World: Towards Entire Item Space Exploration for Inte

yu song 5 Sep 09, 2022