{"id":23155657,"url":"https://github.com/junhsss/consistency-models","last_synced_at":"2025-04-06T17:13:37.093Z","repository":{"id":144199856,"uuid":"617110735","full_name":"junhsss/consistency-models","owner":"junhsss","description":"A Toolkit for OpenAI's Consistency Models.","archived":false,"fork":false,"pushed_at":"2023-04-14T11:04:09.000Z","size":57732,"stargazers_count":204,"open_issues_count":6,"forks_count":13,"subscribers_count":7,"default_branch":"main","last_synced_at":"2025-03-30T16:12:05.312Z","etag":null,"topics":["consistency-models","diffusers","diffusion-models","generative-models","image-generation","pytorch","pytorch-lightning","stable-diffusion"],"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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/junhsss.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-21T18:09:28.000Z","updated_at":"2025-03-11T07:53:37.000Z","dependencies_parsed_at":"2023-05-19T17:30:16.343Z","dependency_job_id":null,"html_url":"https://github.com/junhsss/consistency-models","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junhsss%2Fconsistency-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junhsss%2Fconsistency-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junhsss%2Fconsistency-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/junhsss%2Fconsistency-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/junhsss","download_url":"https://codeload.github.com/junhsss/consistency-models/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517921,"owners_count":20951719,"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":["consistency-models","diffusers","diffusion-models","generative-models","image-generation","pytorch","pytorch-lightning","stable-diffusion"],"created_at":"2024-12-17T21:10:55.860Z","updated_at":"2025-04-06T17:13:37.074Z","avatar_url":"https://github.com/junhsss.png","language":"Python","readme":"# **Consistency Models** 🌃\n\n**Single-step** image generation with [Consistency Models](https://arxiv.org/abs/2303.01469).\n\n\u003cbr /\u003e\n\n\u003cimg src=\"./assets/training.gif\" /\u003e\n\n\u003cbr /\u003e\n\n**Consistency Models** are a new family of generative models that achieve high sample quality without adversarial training. They support _fast one-step generation_ by design, while still allowing for few-step sampling to trade compute for sample quality.\n\n\u003cbr /\u003e\n\n## Installation\n\n```sh\n$ pip install consistency\n```\n\n### Note\n\nYou **don't need to install** `consistency` for just trying things out:\n\n```python\nfrom diffusers import DiffusionPipeline\n\npipeline = DiffusionPipeline.from_pretrained(\n    \"consistency/cifar10-32-demo\",\n    custom_pipeline=\"consistency/pipeline\",\n)\n\npipeline().images[0]  # Super Fast Generation! 🤯\n```\n\n[**Try it yourself!**](https://colab.research.google.com/github/junhsss/consistency-models/blob/main/examples/sample.ipynb)\n\n\u003cbr /\u003e\n\n## Quickstart\n\n### Basic\n\nJust wrap your favorite _U-Net_ with `Consistency`.\n\n```python\nimport torch\nfrom diffusers import UNet2DModel\nfrom consistency import Consistency\nfrom consistency.loss import PerceptualLoss\n\nconsistency = Consistency(\n    model=UNet2DModel(sample_size=224),\n    loss_fn=PerceptualLoss(net_type=(\"vgg\", \"squeeze\"))\n)\n\nsamples = consistency.sample(16)\n\n# multi-step sampling, sample from the ema model\nsamples = consistency.sample(16, steps=5, use_ema=True)\n```\n\n`Consistency` is self-contained with the training logic and all necessary schedules.\n\nYou can train it with **PyTorch Lightning**'s `Trainer` 🚀\n\n```python\nfrom pytorch_lightning import Trainer\n\ntrainer = Trainer(max_epochs=8000, accelerator=\"auto\")\ntrainer.fit(consistency, some_dataloader)\n```\n\n### Push to HF Hub\n\nProvide your `model_id` and `token` to `Consistency`.\n\n```python\nconsistency = Consistency(\n    model=UNet2DModel(sample_size=224),\n    loss_fn=PerceptualLoss(net_type=(\"vgg\", \"squeeze\"))\n    model_id=\"your_model_id\",\n    token=\"your_token\"  # Not needed if logged in via huggingface-cli\n    push_every_n_steps=10000,\n)\n```\n\nYou can safely drop `consistency` afterwards. Good luck! 🤞\n\n```python\nfrom diffusers import DiffusionPipeline\n\npipeline = DiffusionPipeline.from_pretrained(\n    \"your_name/your_model_id\",\n    custom_pipeline=\"consistency/pipeline\",\n)\n\npipeline().images[0]\n```\n\nA complete example can be found in [**here**](https://github.com/junhsss/consistency-models/blob/main/examples/unconditional_image_generation) or in [this **colab notebook**](https://colab.research.google.com/github/junhsss/consistency-models/blob/main/examples/consistency_models.ipynb).\n\nCheckout [this **Wandb workspace**](https://wandb.ai/junhsss/consistency?workspace=user-junhsss) for some experiment results.\n\n\u003cbr /\u003e\n\n## Available Models\n\n| model_id                                                                                                                  | dataset                                                                                    |\n| ------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------ |\n| \u003ca href=\"https://huggingface.co/consistency/cifar10-32-demo\" target=\"_blank\"\u003e\u003ccode\u003econsistency/cifar10-32-demo\u003c/code\u003e\u003c/a\u003e | \u003ca href=\"https://huggingface.co/datasets/cifar10\" target=\"_blank\"\u003e\u003ccode\u003ecifar10\u003c/code\u003e\u003c/a\u003e |\n\nIf you've trained some checkpoints using `consistency`, **share with us! 🤗**\n\n\u003cbr /\u003e\n\n## Documentation\n\nIn progress... 🛠\n\n\u003cbr /\u003e\n\n## Reference\n\n```bibtex\n@misc{https://doi.org/10.48550/arxiv.2303.01469,\n  doi       = {10.48550/ARXIV.2303.01469},\n  url       = {https://arxiv.org/abs/2303.01469},\n  author    = {Song, Yang and Dhariwal, Prafulla and Chen, Mark and Sutskever, Ilya},\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  title     = {Consistency Models},\n  publisher = {arXiv},\n  year      = {2023},\n  copyright = {arXiv.org perpetual, non-exclusive license}\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunhsss%2Fconsistency-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjunhsss%2Fconsistency-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjunhsss%2Fconsistency-models/lists"}