/artGAN

GAN that makes art

Primary LanguagePython

artGAN

Keras-based implementation of a Deep Convolutional Generative Adversarial Network, based on code from Robbie Barrat, Soumith Chintala, and Felix Mohr.

Getting Started

kerasGANv8.py supports command line arguments.

usage: kerasGANv8.py [-h] --batchSize BATCHSIZE [--noiseSize NOISESIZE]
                     [--yDim YDIM] [--xDim XDIM] [--outputDir OUTPUTDIR]
                     [--trainingDir TRAININGDIR]

optional arguments:
  -h, --help            show this help message and exit

required arguments:
  --batchSize BATCHSIZE
                        batch size
  --noiseSize NOISESIZE
                        size of noise input
  --yDim YDIM           input y dimension
  --xDim XDIM           input x dimension
  --outputDir OUTPUTDIR
                        where to save generated imgs
  --trainingDir TRAININGDIR
                        training imgs directory

If training on a CPU, I've found the following options productive:

python3 kerasGANv8.py --xDim=64 --yDim=64 --batchSize=4 --noiseSize=4 --outputDir=[your/desired/output/directory] --trainingDir=[directory/with/training/imgs]

Dependencies

tensorflow
keras
numpy
matplotlib
scipy

Installing

Use install_dependencies.sh to prepare.

./install_dependencies.sh

Usage

python3 kerasGANv8.py
  • Change the options for x_dim, y_dim, trainingDir, and outputDir to match your training images and desired output location.

  • Adjust the batch size and noise size to the speed at which you want to your model to learn. This is very dependent on how powerful your computer is.

  • These files are intended for CPU training only.

Tips

  • For images with dimensions 256x256, having ngf=100 and ndf=15 has been optimal.
  • For images with dimensions 128x128 or 64x64, having ngf=160 and ndf=20 to 40 has been optimal.

Examples of output images and their training periods

MNIST Training

MNIST Digits Training

MNIST Final Output - 2900 training epochs

MNIST Final Output

gan128Paintings Training

128x128px Paintings Final Output - 9300 training epochs

gan128Paintings Output

gan256Impres Training

256x256px Impressionist Final Output - 14740 training epochs

gan256Impres Final Output

gan512Paintings Training

512x512px Paintings Final Output - 510 training epochs

gan512Paintings Final Output

256x256px Chuck Close Artwork Training

ganChuck256 Training

256x256px Chuck Close Final Output - 1200 training epochs

ganChuck256 Final Output

kerasGANv1 Training

kerasGanv1 Training

kerasGANv1 Final Output - 4900 training epochs

kerasGANv1 Final Output

256mainv2.lua Training

Final Output - 54 training epochs

256mainv2 Fianl Output

More output from my adaptation of main.lua

256mainv2.lua Portrait 256 Training

Final Output - 1 training epoch (3602 training steps)

256mainv2.lua Final Output

Summary of Results

My homemade revision of the neural network sequential structure that Soumith Chintala developed failed to produce high-quality images. I was able to get interesting results, but I would not classify the images my code generated as "artwork".

The slightly modified version of Barrat's code did produce cool results. The 64x64px generated landscapes came out cool. The 256x256px generated portraits also came out cool.

I am hoping to continue work on this, and eventually produce realistic artwork with my own revisions of Robbie Barrat's and Soumith Chintala's code.

Future Work

  • adapt for GPU calculations

Authors

Acknowledgments

Shoutout to the following people, whose code was invaluable while developing these neural networks.