{"id":21135257,"url":"https://github.com/cloneofsimo/consistency_models","last_synced_at":"2025-04-13T09:51:43.313Z","repository":{"id":117401817,"uuid":"610017746","full_name":"cloneofsimo/consistency_models","owner":"cloneofsimo","description":"Unofficial Implementation of Consistency Models in pytorch","archived":false,"fork":false,"pushed_at":"2023-03-07T16:52:10.000Z","size":535,"stargazers_count":253,"open_issues_count":3,"forks_count":11,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-03-27T01:12:48.878Z","etag":null,"topics":["generative-model","pytorch"],"latest_commit_sha":null,"homepage":"https://arxiv.org/abs/2303.01469","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/cloneofsimo.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":"2023-03-05T22:35:23.000Z","updated_at":"2025-03-21T07:19:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"09f15994-2cee-41af-9818-d88cec1c3226","html_url":"https://github.com/cloneofsimo/consistency_models","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/cloneofsimo%2Fconsistency_models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fconsistency_models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fconsistency_models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cloneofsimo%2Fconsistency_models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cloneofsimo","download_url":"https://codeload.github.com/cloneofsimo/consistency_models/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248695301,"owners_count":21146952,"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":["generative-model","pytorch"],"created_at":"2024-11-20T06:46:57.870Z","updated_at":"2025-04-13T09:51:43.293Z","avatar_url":"https://github.com/cloneofsimo.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003c!-- #region --\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg  src=\"contents/mainfigure.png\"\u003e\n\u003c/p\u003e\n\u003c!-- #endregion --\u003e\n\n\n# Consistency Models\n\n\u003c!-- #region --\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg  src=\"contents/_ct_sample_2step_30.png\"\u003e\n\u003c/p\u003e\n\u003c!-- #endregion --\u003e\n\n\u003e 30 Epoch, Consistency Model with 2 step. Using $t_1 = 2, t_2 = 80$.\n\n\u003c!-- #region --\u003e\n\u003cp align=\"center\"\u003e\n\u003cimg  src=\"contents/_ct_sample_5step_30.png\"\u003e\n\u003c/p\u003e\n\u003c!-- #endregion --\u003e\n\n\u003e 30 Epoch, Consistency Model with 5 step. Using $t_i \\in \\{5, 10, 20,40, 80\\}$.\n\n\n\n\nUnofficial Implementation of Consistency Models  ([paper](https://arxiv.org/abs/2303.01469)) in pytorch.\n\nThree days ago, legendary man [Yang Song](https://yang-song.net/) released entirely new set of generative model, called consistency models. There aren't yet any open implementations, so here is my attempt at it.\n\n\n## What are they?\n\nDiffusion models are amazing, because they enable you to sample high fidelity + high diversity images. Downside is, you need lots of steps, something at least 20.\n\nProgressive Distillation (Salimans \u0026 Ho, 2022) solves this with distillating 2-steps of the diffusion model down to single step. Doing this N times boosts sampling speed by $2^N$. But is this the only way? Do we need to train diffusion model and distill it $n$ times? Yang didn't think so. Consistency model solves this by mainly trianing a model to make a consistent denosing for different timesteps (Ok I'm obviously simplifying)\n\n\n## Usage\n\nInstall the package with\n\n```bash\npip install git+https://github.com/cloneofsimo/consistency_models.git\n```\n\nThis repo mainly implements consistency training:\n\n$$\nL(\\theta) = \\mathbb{E}[d(f_\\theta(x + t_{n + 1}z, t_{n + 1}), f_{\\theta_{-}}(x + t_n z, t_n))]\n$$\n\nAnd sampling:\n\n$$\n\\begin{align}\nz \u0026\\sim \\mathcal{N}(0, I) \\\\\nx \u0026\\leftarrow x + \\sqrt{t_n ^2 - \\epsilon^2} z \\\\\nx \u0026\\leftarrow f_\\theta(x, t_n) \\\\\n\\end{align}\n$$\n\n\nThere is a self-contained MNIST training example on the root `main.py`.\n\n```bash\npython main.py\n```\n\n## Todo\n\n- [x] EMA\n- [x] CIFAR10 Example\n- [x] Samples are sooo fuzzy... try to get a crisp result.\n- [ ] Consistency Distillation\n\n# Reference\n\n```bibtex\n@misc{https://doi.org/10.48550/arxiv.2303.01469,\n  doi = {10.48550/ARXIV.2303.01469},\n  \n  url = {https://arxiv.org/abs/2303.01469},\n  \n  author = {Song, Yang and Dhariwal, Prafulla and Chen, Mark and Sutskever, Ilya},\n  \n  keywords = {Machine Learning (cs.LG), Computer Vision and Pattern Recognition (cs.CV), Machine Learning (stat.ML), FOS: Computer and information sciences, FOS: Computer and information sciences},\n  \n  title = {Consistency Models},\n  \n  publisher = {arXiv},\n  \n  year = {2023},\n  \n  copyright = {arXiv.org perpetual, non-exclusive license}\n}\n```\n\n```bibtex\n@misc{https://doi.org/10.48550/arxiv.2202.00512,\n  doi = {10.48550/ARXIV.2202.00512},\n  \n  url = {https://arxiv.org/abs/2202.00512},\n  \n  author = {Salimans, Tim and Ho, Jonathan},\n  \n  keywords = {Machine Learning (cs.LG), Artificial Intelligence (cs.AI), Machine Learning (stat.ML), FOS: Computer and information sciences, FOS: Computer and information sciences},\n  \n  title = {Progressive Distillation for Fast Sampling of Diffusion Models},\n  \n  publisher = {arXiv},\n  \n  year = {2022},\n  \n  copyright = {arXiv.org perpetual, non-exclusive license}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fconsistency_models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcloneofsimo%2Fconsistency_models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcloneofsimo%2Fconsistency_models/lists"}