Giter Club home page Giter Club logo

latent-consistency-model's Introduction

Latent Consistency Models

Official Repository of the paper: Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference.

Project Page: https://latent-consistency-models.github.io

Try our πŸ€— Hugging Face Demos: Hugging Face Spaces πŸ”₯πŸ”₯πŸ”₯

News

  • (πŸ”₯New) 2023/10/21 We support local gradio demo now. You can run the LCM model locally!! Please refer to the "Local gradio Demos".
  • (πŸ”₯New) 2023/10/19 We provide a demo of LCM in πŸ€— Hugging Face Space. Try it here.
  • (πŸ”₯New) 2023/10/19 We provide the LCM model (Dreamshaper_v7) in πŸ€— Hugging Face. Download here.
  • (πŸ”₯New) 2023/10/19 LCM is integrated in 🧨 Diffusers library. Please refer to the "Usage".

πŸ”₯ Local gradio Demos:

To run the model locally, you can download the "local_gradio" folder:

  1. Install Pytorch (CUDA). MacOS system can download the "MPS" version of Pytorch. Please refer to: https://pytorch.org
  2. Install the main library:
pip install diffusers transformers accelerate gradio==3.48.0 
  1. Launch the gradio:
python app.py

Demos & Models Released

Ours Hugging Face Demo and Model are released ! Latent Consistency Models are supported in 🧨 diffusers.

Hugging Face Demo: Hugging Face Spaces

Replicate Demo: Replicate

LCM Model Download: LCM_Dreamshaper_v7

By distilling classifier-free guidance into the model's input, LCM can generate high-quality images in very short inference time. We compare the inference time at the setting of 768 x 768 resolution, CFG scale w=8, batchsize=4, using a A800 GPU.

Usage

You can try out Latency Consistency Models directly on: Hugging Face Spaces

To run the model yourself, you can leverage the 🧨 Diffusers library:

  1. Install the library:
pip install diffusers transformers accelerate
  1. Run the model:
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7", custom_pipeline="latent_consistency_txt2img", custom_revision="main")

# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
pipe.to(torch_device="cuda", torch_dtype=torch.float32)

prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"

# Can be set to 1~50 steps. LCM support fast inference even <= 4 steps. Recommend: 1~8 steps.
num_inference_steps = 4 

images = pipe(prompt=prompt, num_inference_steps=num_inference_steps, guidance_scale=8.0, lcm_origin_steps=50, output_type="pil").images

BibTeX

@misc{luo2023latent,
      title={Latent Consistency Models: Synthesizing High-Resolution Images with Few-Step Inference}, 
      author={Simian Luo and Yiqin Tan and Longbo Huang and Jian Li and Hang Zhao},
      year={2023},
      eprint={2310.04378},
      archivePrefix={arXiv},
      primaryClass={cs.CV}
}

latent-consistency-model's People

Contributors

luosiallen avatar tyq1024 avatar chenxwh avatar eltociear avatar patrickvonplaten avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.