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 :-)
Get some data
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
python -m gan.cli dataset -h to see the options.
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
datadirectory (if it does not already exist). Note: You can put this data directory anywhere you like. The CLI expects a folder called
data, but you can specify a different location with the CLI:
- Put the downloaded file in your
datadirectory with the name
- Run the command
python -m gan.cli dataset cartoonwhich will take care of unzipping and organizing the contents of the cartoon dataset.
Run the training
python -m gan.cli train -d data/shapes
This command by default takes care of all the training.
python -m gan.cli train -h for options.
Training on GPU
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.