As a part of my independent study for Junior year, my final project was to recreate StyleGan in Python using Pytorch. I used some notes from a Coursera course I took, the original whitepapers, and looked at how others had implemented the same architecture in order to better understand how StyleGan worked.
- A Style-Based Generator Architecture for Generative Adversarial Networks
- Progressive Growing of GANs for Improved Quality, Stability, and Variation
Big thanks to these projects for helping me troubleshoot issues I had!
Thanks to Samuel Prevost for directly helping me troubleshoot issues.
Create a folder under /data
, name it however you want.
Place all of your dataset images into this new folder. It will work best if they are all 512x512.
Run python prep.py [path to images] [start size (4)] [end size (512)]
.
This script is SUPER dodgy and thrown together, so be prepared to tweak it in order to make it work. It essentially moves those original images into a new /data/[name]/original/images
folder. Then, it resizes every image to match progressive growth and saves it under separate datasets under /data/[name]/prepared
, where name
refers to the original folder (e.g. /data/art
).
Edit the config.txt
file and create a configuration setting to your liking. Use the two examples as a template. You can override any key, but do NOT delete anything under the DEFAULT
setting.
python main.py [config name] -c checkpoint.pth
For instance,
python main.py abstract-art
runs with the abstract-art
configuration.
python generate_samples.py ./checkpoints/checkpoint.pth 64 -o ./output/ -d cpu
will generate 64
images from the model saved at ./checkpoints/checkpoint.pth
and save them in the ./output
folder. It will use the CPU.
python generate_samples.py -h
for more info.
As my resources are limited, I was unable to run my program to completion. See Nvidia's implementation for higher fidelity Results.
However, for the time that I did run this program, I did get meaningful results that show that this implementation is indeed functional.
16 FFHQ images:
16 Abstract Art images: