Experiments with image generation using generative adversarial networks (GANs).
pip install -r requirements.txt
The requirement file has been reduced in size so if any of the scripts fail, just install the missing packages :-)
You can create some toy data or download a dataset. For example, to create a bunch of shapes (useful for testing that things are working):
python -m gan.cli dataset shapes
Use python -m gan.cli dataset -h
to see the options. Currently supports the following datasets:
shapes
: Shapes of random size, currently only ellipse shapes.cartoon
: Cartoon avatars (see below).coco
: Common Objects in Context. Currently only using the 2017 validation dataset (1GB download, 2.4GB unzipped), because it is limited in size.- This dataset also includes captions.
To use the cartoon avatar dataset:
- Download the dataset from here: https://google.github.io/cartoonset/download.html (Downloading this file via Python seems to not work).
- Create a
data
directory (if it does not already exist). Note: You can put this data directory anywhere you like. The CLI expects a folder calleddata
, but you can specify a different location with the CLI: - Put the downloaded file in your
data
directory with the namecartoon.tgz
. - Run the command
python -m gan.cli dataset cartoon
which will take care of unzipping and organizing the contents of the cartoon dataset.
python -m gan.cli train -d data/shapes
This command by default takes care of all the training.
Check python -m gan.cli train -h
for options.
The requirements.txt file refers to the CPU version of Tensorflow but manually uninstalling and installing the GPU version might work if you have everything set up with CUDA and stuff.
Otherwise, the easiest way to get GPU support is to use Docker which only requires the NVIDIA driver and toolkit. Instructions found here.
Start bash inside the container:
docker build -t gan-gpu .
docker run --rm -it --gpus all -v $PWD:/tf/src -u $(id -u):$(id -g) gan-gpu bash
Then all the above CLI commands should work as-is.
MIT License.
Parts of the code are modified from the DCGAN Tensorflow tutorial with the Apache License.