{"id":16233956,"url":"https://github.com/ashutosh1919/consistency-models","last_synced_at":"2025-06-20T15:39:15.477Z","repository":{"id":217597788,"uuid":"629277721","full_name":"ashutosh1919/consistency-models","owner":"ashutosh1919","description":"Ready to run PyTorch implementation of Consistency Models: One-Step Image Generation \u0026 Editing","archived":false,"fork":false,"pushed_at":"2023-04-19T01:55:27.000Z","size":1375,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-30T00:43:42.350Z","etag":null,"topics":["computer-vision","consistency-models","diffusion-models","generative-model","image-generation","monte-carlo-tree-search","pytorch","pytorch-implementation"],"latest_commit_sha":null,"homepage":"https://blog.paperspace.com/consistency-models","language":"Shell","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/ashutosh1919.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}},"created_at":"2023-04-18T01:54:46.000Z","updated_at":"2024-04-09T09:27:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc8539f5-5488-497e-9378-885e36831dfc","html_url":"https://github.com/ashutosh1919/consistency-models","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"139667e124c7f4adee384967e19ccbf17b616f79"},"previous_names":["ashutosh1919/consistency-models"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashutosh1919%2Fconsistency-models","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashutosh1919%2Fconsistency-models/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashutosh1919%2Fconsistency-models/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ashutosh1919%2Fconsistency-models/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ashutosh1919","download_url":"https://codeload.github.com/ashutosh1919/consistency-models/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243997127,"owners_count":20380981,"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":["computer-vision","consistency-models","diffusion-models","generative-model","image-generation","monte-carlo-tree-search","pytorch","pytorch-implementation"],"created_at":"2024-10-10T13:14:22.528Z","updated_at":"2025-03-19T15:30:21.146Z","avatar_url":"https://github.com/ashutosh1919.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Consistency Models\n\nConsistency-Models is entirely new paradigm for zero-shot image generation and editing. Diffusion models generate images with iterative sampling procedure which usually is very slow whereas consistency models aim to generate images in a single shot. This repository contains ready-to train models \u0026 demo to generate images. This repository utilizes original [Consistency-Models](https://github.com/openai/consistency_models) ([arxiv](https://arxiv.org/abs/2303.01469)) implementation. Moreover, we have created helper scripts to train the models and Gradio app to generate images using pre-trained models.\n\n\n## Run in a Free GPU powered Gradient Notebook\n[![Gradient](https://assets.paperspace.io/img/gradient-badge.svg)](https://console.paperspace.com/github/ashutosh1919/consistency-models?machine=Free-GPU)\n\n\n## Setup\n\nThe file `installations.sh` contains all the necessary code to install required dependencies. Note that your system must have CUDA to train Consistency models. Also, you may require different version of `torch` based on the version of CUDA. If you are running this on [Paperspace](https://www.paperspace.com/), then the default version of CUDA is 11.6 which is compatible with this code. If you are running it somewhere else, please check your CUDA version using `nvcc --version`. If the version differs from ours, you may want to change versions of PyTorch libraries in the first line of `installations.sh` by looking at [compatibility table](https://github.com/pytorch/pytorch/wiki/PyTorch-Versions).\n\nTo install all the dependencies, run below command:\n\n```bash\nbash installations.sh\n```\n\nAbove command also clones the original [Consistency-Models](https://github.com/openai/consistency_models) repository into `consistency_models` directory so that we can utilize the original model implementation for training \u0026 inference.\n\n\n## Downloading datasets \u0026 Start training (Optional)\n\n`datasets` directory in this repo contains necessary scripts to download the data and make it ready for training. Currently, this repository supports downloading [ImageNet](https://www.image-net.org/) and [LSUN Bedroom](https://www.yf.io/p/lsun) datasets that original authors used.\n\nWe have already setup bash scripts for you which will automatically download the dataset for you. `datasets` contains the code which will download the training \u0026 validation data to the same directory. To download the datasets, you can run below code:\n\n```bash\n# Download the ImageNet dataset\ncd datasets/imagenet/ \u0026\u0026 bash fetch_imagenet.sh\n\n# Download the LSUN Bedroom dataset\ncd datasets/lsun_bedroom/ \u0026\u0026 bash fetch_lsun_bedroom.sh\n```\n\nMoreover, we have provided scripts to train different types of models as authors have discussed in the paper. `scripts` directory contains different bash scripts to train the models. You can run scripts with below commands to train different models:\n\n```bash\n# EDM Model on ImageNet dataset\nbash scripts/train_edm/train_imagenet.sh\n\n# EDM Model on LSUN Bedroom dataset\nbash scripts/train_edm/train_lsun_bedroom.sh\n\n# Consistency Distillation Model on ImageNet dataset (L2 measure)\nbash scripts/train_cd/train_imagenet_l2.sh\n\n# Consistency Distillation Model on ImageNet dataset (LPIPS measure)\nbash scripts/train_cd/train_imagenet_lpips.sh\n\n# Consistency Distillation Model on LSUN Bedroom dataset (L2 measure)\nbash scripts/train_cd/train_lsun_bedroom_l2.sh\n\n# Consistency Distillation Model on LSUN Bedroom dataset (LPIPS measure)\nbash scripts/train_cd/train_lsun_bedroom_lpips.sh\n\n# Consistency Training Model on ImageNet dataset\nbash scripts/train_ct/train_imagenet.sh\n\n# Consistency Training Model on LSUN Bedroom dataset\nbash scripts/train_ct/train_lsun_bedroom.sh\n```\n\nThis bash script is compatible to the Paperspace workspace. But if you are running it elsewhere, then you will need to replace base path of the paths mentioned in the corresponding training script.\n\nNote that you will need to move `checkpoint.pt` file to `checkpoints` directory for inference at the end of training.\n\nDon't worry if you don't want to train the model. Below section illustrates downloading the pre-trained checkpoints for inference.\n\n\n## Running Gradio Demo\n\nPython script `app.py` contains Gradio demo which lets you generate images using pre-trained models. But before we do that, we need to download the pre-trained checkpoints into `checkpoints` directory.\n\nTo download existing checkpoints, run below command:\n\n```bash\nbash checkpoints/fetch_checkpoints.sh\n```\n\nNote that the latest version of code has the pre-trained checkpoints for 12 different model types. You can add the code in `fetch_checkpoints.sh` whenever you have the new checkpoints.\n\nNow, we are ready to launch Gradio demo. Run following command to launch demo:\n\n```bash\ngradio app.py\n```\n\nOpen the link in the browser and now you can generate inference from any of available models in `checkpoints` directory. Moreover, you can generate images by modifying different parameters like `dropout`, `generator`, and `steps`.\n\nYou should be able to generate images using different pre-trained models as shown below:\n\n![](./images/consistency_models.gif)\n\nHurray! 🎉🎉🎉  We have created demo to generate images using different pre-trained consistency models.\n\n\n## Original Code\n\n`consistency_models` directory contains the original code taken from [Consistency-Models](https://github.com/openai/consistency_models) repository. The code present in this directory is exactly same as the original code.\n\n\n## Reference\n\nConsistency Models -- https://arxiv.org/abs/2303.01469\n\n```\n@misc{song2023consistency,\n      title={Consistency Models}, \n      author={Yang Song and Prafulla Dhariwal and Mark Chen and Ilya Sutskever},\n      year={2023},\n      eprint={2303.01469},\n      archivePrefix={arXiv},\n      primaryClass={cs.LG}\n}\n```\n\n## License\n\nSee the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashutosh1919%2Fconsistency-models","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fashutosh1919%2Fconsistency-models","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fashutosh1919%2Fconsistency-models/lists"}