A simple, typed, commented Pytorch implementation of StyleGAN2.
Project description
StyleGAN2 Pytorch - Typed, Commented, Installable :)
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.0.0.tar.gz
.
File metadata
- Download URL: stylegan2-torch-1.0.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4395a1121d3b14b9e350f839abdbc485784ff092e8f7472fc1b9542bb73d7d2 |
|
MD5 | 8ce62dd9fd43f555295c71ee83469665 |
|
BLAKE2b-256 | d143cd584b2ed6896853fc626727294dccbf357d42159b86e1120e268953b8c6 |
File details
Details for the file stylegan2_torch-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: stylegan2_torch-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.63.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68b05afb8f87d5913728b34c3f3bff36b0bd8c17d85f0380b7d03cfebf647caf |
|
MD5 | de3d1535921b5615c581e3415c89c06e |
|
BLAKE2b-256 | cbcf54dfb905822742af0afedbc2c081e4c6badff4c9bb04d010f5338fe9fcd7 |