A simple, typed, commented Pytorch implementation of StyleGAN2.
Project description
StyleGAN2 Pytorch - Typed, Commented, Installable :)
A simple, typed, commented Pytorch implementation of StyleGAN2.
This implementation is adapted from here. This implementation seems more stable and editable than the over-engineered official implementation.
The focus of this repository is simplicity and readability. If there are any bugs / issues, please kindly let me know or submit a pull request!
Refer to my blog post for an explanation on the custom CUDA kernels. The profiling code to optimize the custom operations is here.
Installation
pip install stylegan2-torch
Training Tips
- Use a multi-GPU setup. An RTX 3090 can handle batch size of up to 8 at 1024 resolution. Based on experience, batch size of 8 works but 16 or 32 should be safer.
- Use LMDB dataset + SSD storage + multiple dataloader workers (and a big enough prefetch factor to cache at least one batch ahead). You never know how much time you waste on dataloading until you optimize it. For me, that shorted the training time by 30% (more time-saving than the custom CUDA kernels).
Known Issues
Pytorch is known to cause random reboots when using non-deterministic algorithms. Set torch.use_deterministic_algorithms(True)
if you encounter that.
To Dos / Won't Dos
- Tidy up
conv2d_gradfix.py
andfused_act.py
. These were just copied over from the original repo so they are still ugly and untidy. - Provide pretrained model conversion method (not that hard tbh, just go map the state_dict keys).
- Clean up util functions to aid training loop design.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file stylegan2-torch-1.3.0.tar.gz
.
File metadata
- Download URL: stylegan2-torch-1.3.0.tar.gz
- Upload date:
- Size: 20.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2abcc04090380f03dfc861cb1bad8c85433df7d46e8bee9a6e3310886dc7d8e8 |
|
MD5 | b79ae8b15dc47b68c3286eb914395362 |
|
BLAKE2b-256 | d892e958e4998d8f253036b0677a978e97bad5036339a153ad6551a2797e7ec9 |
File details
Details for the file stylegan2_torch-1.3.0-py3-none-any.whl
.
File metadata
- Download URL: stylegan2_torch-1.3.0-py3-none-any.whl
- Upload date:
- Size: 25.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.13 CPython/3.8.12 Linux/5.11.0-1028-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab3de10e3f370a407f60f7bbd3dcb9dcd289b231f3c02564f9d5cb84f25a8ef3 |
|
MD5 | c000493aabc4a93ddb0753c20a8331e2 |
|
BLAKE2b-256 | 7079d0522ea9bf3693f9568c5e5c5549adcb090fe46b85a02275e2b8afa3cc68 |