├── Dockerfile ├── LICENSE └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | # Dockerfile to run StyleGAN2 ADA - Copyright 2020 by Jeff Heaton 2 | # Licensed under the MIT license 3 | # GitHub: https://github.com/jeffheaton/docker-stylegan2-ada 4 | # DockerHub: https://hub.docker.com/r/heatonresearch/stylegan2-ada 5 | # 6 | FROM nvcr.io/nvidia/tensorflow:21.06-tf1-py3 7 | 8 | ENV DNNLIB_CACHE_DIR=/home/.cache 9 | 10 | RUN apt-get update && \ 11 | apt-get -y install git && \ 12 | mkdir /home/.cache && \ 13 | chmod 777 /home/.cache && \ 14 | apt-get clean && \ 15 | rm -rf /var/lib/apt/lists/* && \ 16 | rm -Rf /tmp/* 17 | 18 | RUN cd /home && \ 19 | git clone https://github.com/NVlabs/stylegan2-ada.git 20 | 21 | RUN pip install --upgrade pip && \ 22 | pip install scipy==1.3.3 requests==2.22.0 Pillow==6.2.1 h5py==2.9.0 imageio==2.9.0 \ 23 | imageio-ffmpeg==0.4.2 tqdm==4.49.0 boto3==1.16.25 && \ 24 | rm -Rf /tmp/* 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Jeff Heaton 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Docker file to run StyleGAN2 ADA, docker-stylegan2-ada 2 | * Licensed under the MIT license 3 | * GitHub: https://github.com/jeffheaton/docker-stylegan2-ada 4 | * DockerHub: https://hub.docker.com/r/heatonresearch/stylegan2-ada 5 | 6 | [Jeff Heaton's](http://www.heatonresearch.com) Docker image for running Stylegan2 ADA with GPU. This dockerfile is intended to be run from [NVIDIA Docker](https://github.com/NVIDIA/nvidia-docker). To start a container from this image run something similar to the following: 7 | 8 | ``` 9 | nvidia-docker run -it -u $(id -u):$(id -g) -v /home/username/:/mnt --device /dev/nvidia0:/dev/nvidia0 --device /dev/nvidiactl:/dev/nvidiactl --device /dev/nvidia-uvm:/dev/nvidia-uvm heatonresearch/stylegan2-ada /bin/bash 10 | ``` 11 | 12 | The above command establishes the following: 13 | 14 | * **-u $(id -u):$(id -g)** - This causes the user to be logged into Docker to be the same as the user running the Docker command. This ensures that all permissions and ownerships are correct on the mounted volumes. 15 | * **/home/username/:/mnt** - You should mount a volume to access your images and store results to. 16 | * **/bin/bash** - We start the BASH shell to allow you to execute commands. 17 | 18 | # Convert Image Data 19 | 20 | Your images must be converted to TFRecords. It is very important that all of your images be of the same size, be square, and of the same color depth. You cannot mix color and greyscale images. The following command converts a data set named "fish". The source JPEGs should be in the /mnt/data/fish and the resulting TFRecords will be written to /mnt/datasets/fish. 21 | 22 | ``` 23 | cd /home/stylegan2-ada/ 24 | python dataset_tool.py create_from_images /mnt/datasets/fish /mnt/data/fish 25 | ``` 26 | 27 | # Train GANs 28 | 29 | To actually train your GAN use a command similar to the following. 30 | 31 | ``` 32 | cd /home/stylegan2-ada/ 33 | python train.py --gpus=1 --data=/mnt/datasets/fish --mirror=1 --kimg 3000 --outdir=/mnt/results --aug=ada 34 | ``` 35 | 36 | You must provide an input directory that contains your image TFRecords. You must also provide an output results directory. The results directory will contain snapshots of your generator, sample images as training progresses, and a log. --------------------------------------------------------------------------------