{"id":18600797,"url":"https://github.com/autonomousvision/projected-gan","last_synced_at":"2025-05-16T15:03:55.411Z","repository":{"id":37308237,"uuid":"423511844","full_name":"autonomousvision/projected-gan","owner":"autonomousvision","description":"[NeurIPS'21] Projected GANs Converge Faster","archived":false,"fork":false,"pushed_at":"2024-06-04T11:35:25.000Z","size":766,"stargazers_count":895,"open_issues_count":22,"forks_count":98,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-04-03T10:13:09.300Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/autonomousvision.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-11-01T15:13:19.000Z","updated_at":"2025-03-29T09:10:40.000Z","dependencies_parsed_at":"2024-12-13T11:11:35.083Z","dependency_job_id":"9f6e4b70-1ee5-4ff3-af26-fb8ddcc2ad63","html_url":"https://github.com/autonomousvision/projected-gan","commit_stats":{"total_commits":21,"total_committers":5,"mean_commits":4.2,"dds":0.5238095238095238,"last_synced_commit":"e1c246b8bdce4fac3c2bfcb69df309fc27df9b86"},"previous_names":["autonomousvision/projected_gan"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fprojected-gan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fprojected-gan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fprojected-gan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/autonomousvision%2Fprojected-gan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/autonomousvision","download_url":"https://codeload.github.com/autonomousvision/projected-gan/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248564826,"owners_count":21125412,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-07T02:05:37.650Z","updated_at":"2025-04-12T11:49:16.533Z","avatar_url":"https://github.com/autonomousvision.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cimg src=\"media/banner.png\"\u003e\n\n#### [[Project]](https://sites.google.com/view/projected-gan/) [[PDF]](http://www.cvlibs.net/publications/Sauer2021NEURIPS.pdf) [[Supplementary]](http://www.cvlibs.net/publications/Sauer2021NEURIPS_supplementary.pdf) [[Talk]](https://recorder-v3.slideslive.com/#/share?share=50538\u0026s=bf7a6393-410c-49d9-8edf-c61fa486c354) [[CGP Summary]](https://www.casualganpapers.com/data-efficient-fast-gan-training-small-datasets/ProjectedGAN-explained.html) [[Replicate Demo]](https://replicate.com/xl-sr/projected_gan) [[Hugging Face Spaces Demo]](https://huggingface.co/spaces/autonomousvision/projected_gan)\n\nFor a quick start, try the Colab: \u0026nbsp; [![Projected GAN Quickstart](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/gist/xl-sr/757757ff8709ad1721c6d9462efdc347/projected_gan.ipynb)\n\nThis repository contains the code for our NeurIPS 2021 paper \"Projected GANs Converge Faster\"\n\nby [Axel Sauer](https://axelsauer.com/), [Kashyap Chitta](https://kashyap7x.github.io/), [Jens Müller](https://hci.iwr.uni-heidelberg.de/users/jmueller), and [Andreas Geiger](http://www.cvlibs.net/).\n\nIf you find our code or paper useful, please cite\n```bibtex\n@InProceedings{Sauer2021NEURIPS,\n  author         = {Axel Sauer and Kashyap Chitta and Jens M{\\\"{u}}ller and Andreas Geiger},\n  title          = {Projected GANs Converge Faster},\n  booktitle      = {Advances in Neural Information Processing Systems (NeurIPS)},\n  year           = {2021},\n}\n```\n## Related Projects ##\n- [StyleGAN-XL: Scaling StyleGAN to Large Diverse Datasets](https://github.com/autonomousvision/stylegan_xl)\n\n## ToDos\n- [x] Initial code release\n- [x] Easy-to-use colab\n- [x] StyleGAN3 support (moved  to https://github.com/autonomousvision/stylegan_xl)\n- [x] Providing pretrained models\n\n## Requirements ##\n- 64-bit Python 3.8 and PyTorch 1.9.0 (or later). See https://pytorch.org for PyTorch install instructions.\n- Use the following commands with Miniconda3 to create and activate your PG Python environment:\n  - ```conda env create -f environment.yml```\n  - ```conda activate pg```\n- The StyleGAN2 generator relies on custom CUDA kernels, which are compiled on the fly. Hence you need:\n  - CUDA toolkit 11.1 or later.\n  - GCC 7 or later compilers. Recommended GCC version depends on CUDA version, see for example CUDA 11.4 system requirements.\n  - If you run into problems when setting up for the custom CUDA kernels, we refer to the [Troubleshooting docs](https://github.com/NVlabs/stylegan3/blob/main/docs/troubleshooting.md#why-is-cuda-toolkit-installation-necessary) of the original StyleGAN repo. When using the FastGAN generator you will not need the custom kernels.\n\n## Data Preparation ##\nFor a quick start, you can download the few-shot datasets provided by the authors of [FastGAN](https://github.com/odegeasslbc/FastGAN-pytorch). You can download them [here](https://drive.google.com/file/d/1aAJCZbXNHyraJ6Mi13dSbe7pTyfPXha0/view). To prepare the dataset at the respective resolution, run for example\n```\npython dataset_tool.py --source=./data/pokemon --dest=./data/pokemon256.zip \\\n  --resolution=256x256 --transform=center-crop\n```\nYou can get the datasets we used in our paper at their respective websites: \n\n[CLEVR](https://cs.stanford.edu/people/jcjohns/clevr/), [FFHQ](https://github.com/NVlabs/ffhq-dataset), [Cityscapes](https://www.cityscapes-dataset.com/), [LSUN](https://github.com/fyu/lsun), [AFHQ](https://github.com/clovaai/stargan-v2), [Landscape](https://www.kaggle.com/arnaud58/landscape-pictures).\n\n## Training ##\n\nTraining your own PG on LSUN church using 8 GPUs:\n```\npython train.py --outdir=./training-runs/ --cfg=fastgan --data=./data/pokemon256.zip \\\n  --gpus=8 --batch=64 --mirror=1 --snap=50 --batch-gpu=8 --kimg=10000\n```\n```--batch``` specifies the overall batch size, ```--batch-gpu``` specifies the batch size per GPU.  If you use fewer GPUs, the training loop will automatically accumulate gradients, until the overall batch size is reached.\n\nIf you want to use the StyleGAN2 generator, pass ```--cfg=stylegan2```.\nWe also added a lightweight version of FastGAN (```--cfg=fastgan_lite```). This backbone trains fast regarding wallclock\ntime and yields better results on small datasets like Pokemon.\nSamples and metrics are saved in ```outdir```. To monitor the training progress, you can inspect fid50k_full.json or run tensorboard in training-runs.\n\n## Generating Samples \u0026 Interpolations ##\n\nTo generate samples and interpolation videos, run\n```\npython gen_images.py --outdir=out --trunc=1.0 --seeds=10-15 \\\n  --network=PATH_TO_NETWORK_PKL\n```\nand\n```\npython gen_video.py --output=lerp.mp4 --trunc=1.0 --seeds=0-31 --grid=4x2 \\\n  --network=PATH_TO_NETWORK_PKL\n```\n\nWe provide the following pretrained models (pass the url as `PATH_TO_NETWORK_PKL`):\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/art_painting.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/church.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/bedroom.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/cityscapes.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/clevr.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/ffhq.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/flowers.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/landscape.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \u003e \u003csub\u003e`https://s3.eu-central-1.amazonaws.com/avg-projects/projected_gan/models/pokemon.pkl`\u003c/sub\u003e\u003cbr\u003e\n  \n## Quality Metrics ##\nPer default, ```train.py``` tracks FID50k during training. To calculate metrics for a specific network snapshot, run\n\n```\npython calc_metrics.py --metrics=fid50k_full --network=PATH_TO_NETWORK_PKL\n```\n\nTo see the available metrics, run\n```\npython calc_metrics.py --help\n```\n\n## Using PG in your own project ##\n\nOur implementation is modular, so it is straightforward to use PG in your own codebase. Simply copy the ```pg_modules``` folder to your project.\nThen, to get the projected multi-scale discriminator, run\n```\nfrom pg_modules.discriminator import ProjectedDiscriminator\nD = ProjectedDiscriminator()\n```\nThe only thing you still need to do is to make sure that the feature network is not trained, i.e., explicitly set\n```\nD.feature_network.requires_grad_(False)\n```\nin your training loop.\n\n## Acknowledgments ##\nOur codebase build and extends the awesome [StyleGAN2-ADA repo](https://github.com/NVlabs/stylegan2-ada-pytorch) and [StyleGAN3 repo](https://github.com/NVlabs/stylegan3), both by Karras et al.\n\nFurthermore, we use parts of the code of [FastGAN](https://github.com/odegeasslbc/FastGAN-pytorch) and [MiDas](https://github.com/isl-org/MiDaS).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautonomousvision%2Fprojected-gan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fautonomousvision%2Fprojected-gan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fautonomousvision%2Fprojected-gan/lists"}