{"id":13689284,"url":"https://github.com/AntixK/PyTorch-VAE","last_synced_at":"2025-05-01T23:33:38.438Z","repository":{"id":37747411,"uuid":"233044521","full_name":"AntixK/PyTorch-VAE","owner":"AntixK","description":"A Collection of Variational Autoencoders (VAE) in PyTorch.","archived":false,"fork":false,"pushed_at":"2024-06-13T04:24:42.000Z","size":47596,"stargazers_count":6626,"open_issues_count":62,"forks_count":1063,"subscribers_count":43,"default_branch":"master","last_synced_at":"2024-11-04T17:12:08.264Z","etag":null,"topics":["architecture","beta-vae","celeba-dataset","deep-learning","dfc-vae","gumbel-softmax","iwae","paper-implementations","pytorch","pytorch-implementation","pytorch-vae","reproducible-research","vae","vae-implementation","variational-autoencoders","vqvae","wae"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AntixK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-01-10T12:41:23.000Z","updated_at":"2024-11-04T01:27:04.000Z","dependencies_parsed_at":"2022-07-10T03:00:26.680Z","dependency_job_id":"d660b808-c563-4e82-807b-ac4ecee03fc5","html_url":"https://github.com/AntixK/PyTorch-VAE","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FPyTorch-VAE","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FPyTorch-VAE/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FPyTorch-VAE/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AntixK%2FPyTorch-VAE/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AntixK","download_url":"https://codeload.github.com/AntixK/PyTorch-VAE/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224115831,"owners_count":17258238,"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":["architecture","beta-vae","celeba-dataset","deep-learning","dfc-vae","gumbel-softmax","iwae","paper-implementations","pytorch","pytorch-implementation","pytorch-vae","reproducible-research","vae","vae-implementation","variational-autoencoders","vqvae","wae"],"created_at":"2024-08-02T15:01:41.214Z","updated_at":"2025-05-01T23:33:38.430Z","avatar_url":"https://github.com/AntixK.png","language":"Python","funding_links":[],"categories":["Pytorch \u0026 related libraries｜Pytorch \u0026 相关库","Python","\u003cspan id=\"head50\"\u003e3.6. Probablistic Machine Learning and Deep Learning\u003c/span\u003e","Table of Contents","Pytorch \u0026 related libraries","Variational Auto-Encoder","图像生成","Generative Models — VAEs"],"sub_categories":["Other libraries｜其他库:","\u003cspan id=\"head53\"\u003e3.6.3. VAE\u003c/span\u003e","Other libraries:","资源传输下载"],"readme":"\u003ch1 align=\"center\"\u003e\n  \u003cb\u003ePyTorch VAE\u003c/b\u003e\u003cbr\u003e\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n      \u003ca href=\"https://www.python.org/\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/Python-3.5-ff69b4.svg\" /\u003e\u003c/a\u003e\n       \u003ca href= \"https://pytorch.org/\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/PyTorch-1.3-2BAF2B.svg\" /\u003e\u003c/a\u003e\n       \u003ca href= \"https://github.com/AntixK/PyTorch-VAE/blob/master/LICENSE.md\"\u003e\n        \u003cimg src=\"https://img.shields.io/badge/license-Apache2.0-blue.svg\" /\u003e\u003c/a\u003e\n         \u003ca href= \"https://twitter.com/intent/tweet?text=PyTorch-VAE:%20Collection%20of%20VAE%20models%20in%20PyTorch.\u0026url=https://github.com/AntixK/PyTorch-VAE\"\u003e\n        \u003cimg src=\"https://img.shields.io/twitter/url/https/shields.io.svg?style=social\" /\u003e\u003c/a\u003e\n\n\u003c/p\u003e\n\n**Update 22/12/2021:** Added support for PyTorch Lightning 1.5.6 version and cleaned up the code.\n\nA collection of Variational AutoEncoders (VAEs) implemented in pytorch with focus on reproducibility. The aim of this project is to provide\na quick and simple working example for many of the cool VAE models out there. All the models are trained on the [CelebA dataset](http://mmlab.ie.cuhk.edu.hk/projects/CelebA.html)\nfor consistency and comparison. The architecture of all the models are kept as similar as possible with the same layers, except for cases where the original paper necessitates \na radically different architecture (Ex. VQ VAE uses Residual layers and no Batch-Norm, unlike other models).\nHere are the [results](https://github.com/AntixK/PyTorch-VAE/blob/master/README.md#--results) of each model.\n\n### Requirements\n- Python \u003e= 3.5\n- PyTorch \u003e= 1.3\n- Pytorch Lightning \u003e= 0.6.0 ([GitHub Repo](https://github.com/PyTorchLightning/pytorch-lightning/tree/deb1581e26b7547baf876b7a94361e60bb200d32))\n- CUDA enabled computing device\n\n### Installation\n```\n$ git clone https://github.com/AntixK/PyTorch-VAE\n$ cd PyTorch-VAE\n$ pip install -r requirements.txt\n```\n\n### Usage\n```\n$ cd PyTorch-VAE\n$ python run.py -c configs/\u003cconfig-file-name.yaml\u003e\n```\n**Config file template**\n\n```yaml\nmodel_params:\n  name: \"\u003cname of VAE model\u003e\"\n  in_channels: 3\n  latent_dim: \n    .         # Other parameters required by the model\n    .\n    .\n\ndata_params:\n  data_path: \"\u003cpath to the celebA dataset\u003e\"\n  train_batch_size: 64 # Better to have a square number\n  val_batch_size:  64\n  patch_size: 64  # Models are designed to work for this size\n  num_workers: 4\n  \nexp_params:\n  manual_seed: 1265\n  LR: 0.005\n  weight_decay:\n    .         # Other arguments required for training, like scheduler etc.\n    .\n    .\n\ntrainer_params:\n  gpus: 1         \n  max_epochs: 100\n  gradient_clip_val: 1.5\n    .\n    .\n    .\n\nlogging_params:\n  save_dir: \"logs/\"\n  name: \"\u003cexperiment name\u003e\"\n```\n\n**View TensorBoard Logs**\n```\n$ cd logs/\u003cexperiment name\u003e/version_\u003cthe version you want\u003e\n$ tensorboard --logdir .\n```\n\n**Note:** The default dataset is CelebA. However, there has been many issues with downloading the dataset from google drive (owing to some file structure changes). So, the recommendation is to download the [file](https://drive.google.com/file/d/1m8-EBPgi5MRubrm6iQjafK2QMHDBMSfJ/view?usp=sharing) from google drive directly and extract to the path of your choice. The default path assumed in the config files is `Data/celeba/img_align_celeba'. But you can change it acording to your preference.\n\n\n----\n\u003ch2 align=\"center\"\u003e\n  \u003cb\u003eResults\u003c/b\u003e\u003cbr\u003e\n\u003c/h2\u003e\n\n\n| Model                                                                  | Paper                                            |Reconstruction | Samples |\n|------------------------------------------------------------------------|--------------------------------------------------|---------------|---------|\n| VAE ([Code][vae_code], [Config][vae_config])                           |[Link](https://arxiv.org/abs/1312.6114)           |    ![][2]     | ![][1]  |\n| Conditional VAE ([Code][cvae_code], [Config][cvae_config])             |[Link](https://openreview.net/forum?id=rJWXGDWd-H)|    ![][16]    | ![][15] |\n| WAE - MMD (RBF Kernel) ([Code][wae_code], [Config][wae_rbf_config])    |[Link](https://arxiv.org/abs/1711.01558)          |    ![][4]     | ![][3]  |\n| WAE - MMD (IMQ Kernel) ([Code][wae_code], [Config][wae_imq_config])    |[Link](https://arxiv.org/abs/1711.01558)          |    ![][6]     | ![][5]  |\n| Beta-VAE ([Code][bvae_code], [Config][bbvae_config])                   |[Link](https://openreview.net/forum?id=Sy2fzU9gl) |    ![][8]     | ![][7]  |\n| Disentangled Beta-VAE ([Code][bvae_code], [Config][bhvae_config])      |[Link](https://arxiv.org/abs/1804.03599)          |    ![][22]    | ![][21] |\n| Beta-TC-VAE ([Code][btcvae_code], [Config][btcvae_config])             |[Link](https://arxiv.org/abs/1802.04942)          |    ![][34]    | ![][33] |\n| IWAE (*K = 5*) ([Code][iwae_code], [Config][iwae_config])              |[Link](https://arxiv.org/abs/1509.00519)          |    ![][10]    | ![][9]  |\n| MIWAE (*K = 5, M = 3*) ([Code][miwae_code], [Config][miwae_config])    |[Link](https://arxiv.org/abs/1802.04537)          |    ![][30]    | ![][29] |\n| DFCVAE   ([Code][dfcvae_code], [Config][dfcvae_config])                |[Link](https://arxiv.org/abs/1610.00291)          |    ![][12]    | ![][11] |\n| MSSIM VAE    ([Code][mssimvae_code], [Config][mssimvae_config])        |[Link](https://arxiv.org/abs/1511.06409)          |    ![][14]    | ![][13] |\n| Categorical VAE   ([Code][catvae_code], [Config][catvae_config])       |[Link](https://arxiv.org/abs/1611.01144)          |    ![][18]    | ![][17] |\n| Joint VAE ([Code][jointvae_code], [Config][jointvae_config])           |[Link](https://arxiv.org/abs/1804.00104)          |    ![][20]    | ![][19] |\n| Info VAE   ([Code][infovae_code], [Config][infovae_config])            |[Link](https://arxiv.org/abs/1706.02262)          |    ![][24]    | ![][23] |\n| LogCosh VAE   ([Code][logcoshvae_code], [Config][logcoshvae_config])   |[Link](https://openreview.net/forum?id=rkglvsC9Ym)|    ![][26]    | ![][25] |\n| SWAE (200 Projections) ([Code][swae_code], [Config][swae_config])      |[Link](https://arxiv.org/abs/1804.01947)          |    ![][28]    | ![][27] |\n| VQ-VAE (*K = 512, D = 64*) ([Code][vqvae_code], [Config][vqvae_config])|[Link](https://arxiv.org/abs/1711.00937)          |    ![][31]    | **N/A** |\n| DIP VAE ([Code][dipvae_code], [Config][dipvae_config])                 |[Link](https://arxiv.org/abs/1711.00848)          |    ![][36]    | ![][35] |\n\n\n\u003c!-- | Gamma VAE             |[Link](https://arxiv.org/abs/1610.05683)          |    ![][16]    | ![][15] |--\u003e\n\n\u003c!--\n### TODO\n- [x] VanillaVAE\n- [x] Beta VAE\n- [x] DFC VAE\n- [x] MSSIM VAE\n- [x] IWAE\n- [x] MIWAE\n- [x] WAE-MMD\n- [x] Conditional VAE- [ ] PixelVAE\n- [x] Categorical VAE (Gumbel-Softmax VAE)\n- [x] Joint VAE\n- [x] Disentangled beta-VAE\n- [x] InfoVAE\n- [x] LogCosh VAE\n- [x] SWAE\n- [x] VQVAE\n- [x] Beta TC-VAE\n- [x] DIP VAE\n- [ ] Ladder VAE (Doesn't work well)\n- [ ] Gamma VAE (Doesn't work well) \n- [ ] Vamp VAE (Doesn't work well)\n--\u003e\n\n### Contributing\nIf you have trained a better model, using these implementations, by fine-tuning the hyper-params in the config file,\nI would be happy to include your result (along with your config file) in this repo, citing your name 😊.\n\nAdditionally, if you would like to contribute some models, please submit a PR.\n\n### License\n**Apache License 2.0**\n\n| Permissions      | Limitations       | Conditions                       |\n|------------------|-------------------|----------------------------------|\n| ✔️ Commercial use |  ❌  Trademark use |  ⓘ License and copyright notice | \n| ✔️ Modification   |  ❌  Liability     |  ⓘ State changes                |\n| ✔️ Distribution   |  ❌  Warranty      |                                  |\n| ✔️ Patent use     |                   |                                  |\n| ✔️ Private use    |                   |                                  |\n\n\n### Citation\n```\n@misc{Subramanian2020,\n  author = {Subramanian, A.K},\n  title = {PyTorch-VAE},\n  year = {2020},\n  publisher = {GitHub},\n  journal = {GitHub repository},\n  howpublished = {\\url{https://github.com/AntixK/PyTorch-VAE}}\n}\n```\n-----------\n\n[vae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/vanilla_vae.py\n[cvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/cvae.py\n[bvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/beta_vae.py\n[btcvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/betatc_vae.py\n[wae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/wae_mmd.py\n[iwae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/iwae.py\n[miwae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/miwae.py\n[swae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/swae.py\n[jointvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/joint_vae.py\n[dfcvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/dfcvae.py\n[mssimvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/mssim_vae.py\n[logcoshvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/logcosh_vae.py\n[catvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/cat_vae.py\n[infovae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/info_vae.py\n[vqvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/vq_vae.py\n[dipvae_code]: https://github.com/AntixK/PyTorch-VAE/blob/master/models/dip_vae.py\n\n[vae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/vae.yaml\n[cvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/cvae.yaml\n[bbvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/bbvae.yaml\n[bhvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/bhvae.yaml\n[btcvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/betatc_vae.yaml\n[wae_rbf_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/wae_mmd_rbf.yaml\n[wae_imq_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/wae_mmd_imq.yaml\n[iwae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/iwae.yaml\n[miwae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/miwae.yaml\n[swae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/swae.yaml\n[jointvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/joint_vae.yaml\n[dfcvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/dfc_vae.yaml\n[mssimvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/mssim_vae.yaml\n[logcoshvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/logcosh_vae.yaml\n[catvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/cat_vae.yaml\n[infovae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/infovae.yaml\n[vqvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/vq_vae.yaml\n[dipvae_config]: https://github.com/AntixK/PyTorch-VAE/blob/master/configs/dip_vae.yaml\n\n[1]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/Vanilla%20VAE_25.png\n[2]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_Vanilla%20VAE_25.png\n[3]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/WAE_RBF_18.png\n[4]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_WAE_RBF_19.png\n[5]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/WAE_IMQ_15.png\n[6]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_WAE_IMQ_15.png\n[7]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/BetaVAE_H_20.png\n[8]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_BetaVAE_H_20.png\n[9]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/IWAE_19.png\n[10]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_IWAE_19.png\n[11]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/DFCVAE_49.png\n[12]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_DFCVAE_49.png\n[13]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/MSSIMVAE_29.png\n[14]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_MSSIMVAE_29.png\n[15]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/ConditionalVAE_20.png\n[16]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_ConditionalVAE_20.png\n[17]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/CategoricalVAE_49.png\n[18]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_CategoricalVAE_49.png\n[19]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/JointVAE_49.png\n[20]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_JointVAE_49.png\n[21]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/BetaVAE_B_35.png\n[22]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_BetaVAE_B_35.png\n[23]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/InfoVAE_31.png\n[24]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_InfoVAE_31.png\n[25]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/LogCoshVAE_49.png\n[26]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_LogCoshVAE_49.png\n[27]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/SWAE_49.png\n[28]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_SWAE_49.png\n[29]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/MIWAE_29.png\n[30]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_MIWAE_29.png\n[31]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_VQVAE_29.png\n[33]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/BetaTCVAE_49.png\n[34]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_BetaTCVAE_49.png\n[35]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/DIPVAE_83.png\n[36]: https://github.com/AntixK/PyTorch-VAE/blob/master/assets/recons_DIPVAE_83.png\n\n[python-image]: https://img.shields.io/badge/Python-3.5-ff69b4.svg\n[python-url]: https://www.python.org/\n\n[pytorch-image]: https://img.shields.io/badge/PyTorch-1.3-2BAF2B.svg\n[pytorch-url]: https://pytorch.org/\n\n[twitter-image]:https://img.shields.io/twitter/url/https/shields.io.svg?style=social\n[twitter-url]:https://twitter.com/intent/tweet?text=Neural%20Blocks-Easy%20to%20use%20neural%20net%20blocks%20for%20fast%20prototyping.\u0026url=https://github.com/AntixK/NeuralBlocks\n\n\n[license-image]:https://img.shields.io/badge/license-Apache2.0-blue.svg\n[license-url]:https://github.com/AntixK/PyTorch-VAE/blob/master/LICENSE.md\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAntixK%2FPyTorch-VAE","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FAntixK%2FPyTorch-VAE","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FAntixK%2FPyTorch-VAE/lists"}