Skip to content

bzhong2/tensorflow-DCGAN

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deep Convolutional Generative Adversarial Networks (DCGAN)

Requirements

Usage

Config path

All directories are setup in config.py.

  • Before training, put all the training images in config.data_dir.
  • Trained model will be saved every 100 steps in config.model_dir.
  • Sample generated images will be saved every 100 training steps in config.infer_dir.
  • Images generated during testing will be saved in config.result_dir.

Please note, all the images should have the same size.

Run script

  • You can run this script on CIFAR10, MNIST dataset as well as your own dataset in format of Matlab .mat files and image files.

To train a model on CIFAR10 and MNIST dataset:

$ python DCGAN.py --train --cifar --batch_size 64
$ python DCGAN.py --train --mnist --batch_size 64

To train on your own dataset:

.mat files:

$ python DCGAN.py --train --matlab --batch_size 64 --mat_name MAT_NAME_IN_MAT_FILE

images files:

$ python DCGAN.py --train --image --batch_size 64 --type IMAGE_FILE_EXTENSION(start with '.')

To test using an existing model, size and channels of images used for training the model need to be specified, and the batch size has to be the same as training:

$ python DCGAN.py --predict --batch_size SAME_AS_TRAINING --h IMAGE_HEIGHT\
 --w IMAGE_WIDTH --input_channel NUM_INPUT_CHANNEL

Training Details

  • Both discriminator and generator use learning rate 0.0002
  • To avoid small discriminator loss, update generator twice for each update of discriminator, as suggested here.
  • init

Default Summary

Summary is written every 10 steps.

Scalar:

  • loss of generator and discriminator

Histogram:

  • gradients of generator and discriminator
  • discriminator output for real image and generated image

Image

  • real image and generated image

Custom Configuration

details can be found in docs (coming soon)

Available callbacks:

  • TrainSummary()
  • CheckScalar()
  • GANInference()

Available inferencer:

  • InferImages()

Results

CIFAR10

cifar_result1

MNIST

MNIST_result1

More results will be added later.

Training Details

Author

Qian Ge

About

A TensorFlow implementation of DCGAN

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%