Skip to main content

A simple, typed, commented Pytorch implementation of StyleGAN2.

Project description

StyleGAN2 Pytorch - Typed, Commented, Installable :)

action pypi anaconda platform codecov docs

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

  1. 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.
  2. 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

  1. Tidy up conv2d_gradfix.py and fused_act.py. These were just copied over from the original repo so they are still ugly and untidy.
  2. Provide pretrained model conversion method (not that hard tbh, just go map the state_dict keys).
  3. Clean up util functions to aid training loop design.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stylegan2-torch-1.0.2.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

stylegan2_torch-1.0.2-py2.py3-none-any.whl (14.5 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file stylegan2-torch-1.0.2.tar.gz.

File metadata

  • Download URL: stylegan2-torch-1.0.2.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

Hashes for stylegan2-torch-1.0.2.tar.gz
Algorithm Hash digest
SHA256 d54ab697c81a3142d92de2d862bcb0582ba0ec6e443fcf02efc851a02cd61b77
MD5 4a97820dbc3303cc72dcf13abe935754
BLAKE2b-256 290824bc7c7ef1feee798e42e32a98ef1288efbf6cc9893fd2042eb57cb03353

See more details on using hashes here.

File details

Details for the file stylegan2_torch-1.0.2-py2.py3-none-any.whl.

File metadata

  • Download URL: stylegan2_torch-1.0.2-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

Hashes for stylegan2_torch-1.0.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 010129161af5887eaf143da37ebe188f57e7575b26ba13fed26937e12ea3df2c
MD5 d528e79a8b643d70dbd64ab44d79a025
BLAKE2b-256 84f796b9fb4309fa5e2ff00d25b0b92bdc545dd91180c8d408065b5f95ece367

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page