{"id":13579151,"url":"https://github.com/ptrblck/prog_gans_pytorch_inference","last_synced_at":"2025-06-29T09:33:25.401Z","repository":{"id":134661443,"uuid":"108682711","full_name":"ptrblck/prog_gans_pytorch_inference","owner":"ptrblck","description":"PyTorch inference for \"Progressive Growing of GANs\" with CelebA snapshot","archived":false,"fork":false,"pushed_at":"2017-11-04T15:55:22.000Z","size":86558,"stargazers_count":321,"open_issues_count":0,"forks_count":38,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-04-13T05:31:57.126Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ptrblck.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":"2017-10-28T20:41:40.000Z","updated_at":"2025-03-26T13:15:32.000Z","dependencies_parsed_at":"2023-08-16T17:17:26.417Z","dependency_job_id":null,"html_url":"https://github.com/ptrblck/prog_gans_pytorch_inference","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ptrblck/prog_gans_pytorch_inference","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptrblck%2Fprog_gans_pytorch_inference","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptrblck%2Fprog_gans_pytorch_inference/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptrblck%2Fprog_gans_pytorch_inference/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptrblck%2Fprog_gans_pytorch_inference/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ptrblck","download_url":"https://codeload.github.com/ptrblck/prog_gans_pytorch_inference/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ptrblck%2Fprog_gans_pytorch_inference/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259719716,"owners_count":22901239,"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-08-01T15:01:36.963Z","updated_at":"2025-06-13T21:05:42.397Z","avatar_url":"https://github.com/ptrblck.png","language":"Python","funding_links":[],"categories":["Python","Paper implementations｜论文实现","Paper implementations"],"sub_categories":["Other libraries｜其他库:","Other libraries:"],"readme":"# Progressive Growing of GANs inference in PyTorch with CelebA training snapshot\n\n\n## Description\nThis is an inference sample written in [PyTorch](http://pytorch.org/) of the original Theano/Lasagne code.\n\nI recreated the network as described in the paper of [Karras et al.](http://research.nvidia.com/publication/2017-10_Progressive-Growing-of) \nSince some layers seemed to be missing in PyTorch, these were implemented as well. \nThe network and the layers can be found in `model.py`.\n\nFor the demo, a [100-celeb-hq-1024x1024-ours snapshot](https://drive.google.com/drive/folders/0B4qLcYyJmiz0bWJ5bHdKT0d6UXc) was used, which was made publicly available by the authors.\nSince I couldn't find any model converter between Theano/Lasagne and PyTorch, I used a quick and dirty script to transfer the weights between the models (`transfer_weights.py`).\n\nThis repo does not provide the code for training the networks.\n\n### Simple inference\nTo run the demo, simply execute `predict.py`.\nYou can specify other weights with the `--weights` flag.\n\nExample image:\n\n![Example image](https://raw.githubusercontent.com/ptrblck/prog_gans_pytorch_inference/master/example_small.png)\n\n\n### Latent space interpolation\nTo try the latent space interpolation, use `latent_interp.py`.\nAll output images will be saved in `./interp`.\n\nYou can chose between the \"gaussian interpolation\" introduced in the original paper\nand the \"slerp interpolation\" introduced by Tom White in his paper [Sampling Generative Networks](https://arxiv.org/abs/1609.04468v3)\nusing the `--type` argument.\n\nUse `--filter` to change the gaussian filter size for the gaussian interpolation and `--interp` for the interpolation steps\nfor the slerp interpolation.\n\nThe following arguments are defined:\n\n  * `--weights` - path to pretrained PyTorch state dict\n  * `--output` - Directory for storing interpolated images\n  * `--batch_size` - batch size for `DataLoader`\n  * `--num_workers` - number of workers for `DataLoader`\n  * `--type` {gauss, slerp} - interpolation type\n  * `--nb_latents` - number of latent vectors to generate\n  * `--filter` - gaussian filter length for interpolating latent space (gauss interpolation)\n  * `--interp` - interpolation length between each latent vector (slerp interpolation)\n  * `--seed` - random seed for numpy and PyTorch\n  * `--cuda` - use GPU \n\nThe total number of generated frames depends on the used interpolation technique.\n\nFor gaussian interpolation the number of generated frames equals `nb_latents`, while the slerp interpolation generates `nb_latents * interp` frames.\n\nExample interpolation:\n\n![Example interpolation](https://raw.githubusercontent.com/ptrblck/prog_gans_pytorch_inference/master/example_interp.gif)\n\n### Live latent space interpolation\nA live demo of the latent space interpolation using PyGame can be seen in `pygame_interp_demo.py`.\n\nUse the `--size` argument to change the output window size.\n\nThe following arguments are defined:\n\n  * `--weights` - path to pretrained PyTorch state dict\n  * `--num_workers` - number of workers for `DataLoader`\n  * `--type` {gauss, slerp} - interpolation type\n  * `--nb_latents` - number of latent vectors to generate\n  * `--filter` - gaussian filter length for interpolating latent space (gauss interpolation)\n  * `--interp` - interpolation length between each latent vector (slerp interpolation)\n  * `--size` - PyGame window size\n  * `--seed` - random seed for numpy and PyTorch\n  * `--cuda` - use GPU \n\n### Transferring weights\nThe pretrained lasagne weights can be transferred to a PyTorch state dict using `transfer_weights.py`.\n\nTo transfer other snapshots from the paper (other than CelebA), you have to modify the model architecture accordingly and use the corresponding weights.\n\n### Environment\nThe code was tested on Ubuntu 16.04 with an NVIDIA GTX 1080 using PyTorch v.0.2.0_4.\n\n  * `transfer_weights.py` needs Theano and Lasagne to load the pretrained weights.\n  * `pygame_interp_demo.py` needs PyGame to visualize the output\n\nA single forward pass took approx. 0.031 seconds.\n\n\n## Links\n\n* [Original code (Theano/Lasagne implementation)](https://github.com/tkarras/progressive_growing_of_gans)\n\n* [Paper (research.nvidia.com)](http://research.nvidia.com/publication/2017-10_Progressive-Growing-of)\n\n\n## License\n\nThis code is a modified form of the original code under the [CC BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) license with the following copyright notice:\n\n```\n# Copyright (c) 2017, NVIDIA CORPORATION. All rights reserved.\n#\n# This work is licensed under the Creative Commons Attribution-NonCommercial\n# 4.0 International License. To view a copy of this license, visit\n# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to\n# Creative Commons, PO Box 1866, Mountain View, CA 94042, USA.\n```\n\nAccording the Section 3, I hereby identify [Tero Karras et al. and NVIDIA](https://github.com/tkarras) as the original authors of the material.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptrblck%2Fprog_gans_pytorch_inference","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fptrblck%2Fprog_gans_pytorch_inference","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fptrblck%2Fprog_gans_pytorch_inference/lists"}