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
A program that uses computer vision to detect hand gestures, used for controlling movie players.

HandGestureDetection This program uses a Haar Cascade algorithm to detect the presence of your hand, and then passes it on to a self-created and self-

2 Nov 22, 2022
Next-gen Rowhammer fuzzer that uses non-uniform, frequency-based patterns.

Blacksmith Rowhammer Fuzzer This repository provides the code accompanying the paper Blacksmith: Scalable Rowhammering in the Frequency Domain that is

Computer Security Group @ ETH Zurich 173 Nov 16, 2022
Adversarial Robustness Toolbox (ART) - Python Library for Machine Learning Security - Evasion, Poisoning, Extraction, Inference - Red and Blue Teams

Adversarial Robustness Toolbox (ART) is a Python library for Machine Learning Security. ART provides tools that enable developers and researchers to defend and evaluate Machine Learning models and ap

3.4k Jan 04, 2023
Hard cater examples from Hopper ICLR paper

CATER-h Honglu Zhou*, Asim Kadav, Farley Lai, Alexandru Niculescu-Mizil, Martin Renqiang Min, Mubbasir Kapadia, Hans Peter Graf (*Contact: honglu.zhou

NECLA ML Group 6 May 11, 2021
Tensorflow/Keras Plug-N-Play Deep Learning Models Compilation

DeepBay This project was created with the objective of compile Machine Learning Architectures created using Tensorflow or Keras. The architectures mus

Whitman Bohorquez 4 Sep 26, 2022
Контрольная работа по математическим методам машинного обучения

ML-MathMethods-Test Контрольная работа по математическим методам машинного обучения. Вычисление основных статистик, диаграмм и графиков, проверка разл

Stas Ivanovskii 1 Jan 06, 2022
eXPeditious Data Transfer

xpdt: eXPeditious Data Transfer About xpdt is (yet another) language for defining data-types and generating code for serializing and deserializing the

Gianni Tedesco 3 Jan 06, 2022
Augmentation for Single-Image-Super-Resolution

SRAugmentation Augmentation for Single-Image-Super-Resolution Implimentation CutBlur Cutout CutMix Cutup CutMixup Blend RGBPermutation Identity OneOf

Yubo 6 Jun 27, 2022
Official Implementation of VAT

Semantic correspondence Few-shot segmentation Cost Aggregation Is All You Need for Few-Shot Segmentation For more information, check out project [Proj

Hamacojr 114 Dec 27, 2022
A novel method to tune language models. Codes and datasets for paper ``GPT understands, too''.

P-tuning A novel method to tune language models. Codes and datasets for paper ``GPT understands, too''. How to use our code We have released the code

THUDM 562 Dec 27, 2022
A PyTorch Extension: Tools for easy mixed precision and distributed training in Pytorch

Introduction This is a Python package available on PyPI for NVIDIA-maintained utilities to streamline mixed precision and distributed training in Pyto

Artit 'Art' Wangperawong 5 Sep 29, 2021
Look Closer: Bridging Egocentric and Third-Person Views with Transformers for Robotic Manipulation

Look Closer: Bridging Egocentric and Third-Person Views with Transformers for Robotic Manipulation Official PyTorch implementation for the paper Look

Rishabh Jangir 20 Nov 24, 2022
(CVPR 2022) Energy-based Latent Aligner for Incremental Learning

Energy-based Latent Aligner for Incremental Learning Accepted to CVPR 2022 We illustrate an Incremental Learning model trained on a continuum of tasks

Joseph K J 37 Jan 03, 2023
Blind Video Temporal Consistency via Deep Video Prior

deep-video-prior (DVP) Code for NeurIPS 2020 paper: Blind Video Temporal Consistency via Deep Video Prior PyTorch implementation | paper | project web

Chenyang LEI 272 Dec 21, 2022
AFLNet: A Greybox Fuzzer for Network Protocols

AFLNet: A Greybox Fuzzer for Network Protocols AFLNet is a greybox fuzzer for protocol implementations. Unlike existing protocol fuzzers, it takes a m

626 Jan 06, 2023
This repository collects project-relevant Isabelle/HOL formalizations.

Isabelle/HOL formalizations related to the AuReLeE project Formalization of Abstract Argumentation Frameworks See AbstractArgumentation folder for the

AuReLeE project 1 Sep 10, 2022
Reaction SMILES-AA mapping via language modelling

rxn-aa-mapper Reactions SMILES-AA sequence mapping setup conda env create -f conda.yml conda activate rxn_aa_mapper In the following we consider on ex

16 Dec 13, 2022
Dynamic Divide-and-Conquer Adversarial Training for Robust Semantic Segmentation (ICCV2021)

Dynamic Divide-and-Conquer Adversarial Training for Robust Semantic Segmentation This is a pytorch project for the paper Dynamic Divide-and-Conquer Ad

DV Lab 29 Nov 21, 2022
This is the official source code of "BiCAT: Bi-Chronological Augmentation of Transformer for Sequential Recommendation".

BiCAT This is our TensorFlow implementation for the paper: "BiCAT: Sequential Recommendation with Bidirectional Chronological Augmentation of Transfor

John 15 Dec 06, 2022
Fine-grained Post-training for Improving Retrieval-based Dialogue Systems - NAACL 2021

Fine-grained Post-training for Multi-turn Response Selection Implements the model described in the following paper Fine-grained Post-training for Impr

Janghoon Han 83 Dec 20, 2022