ONNX 模型库
返回模型

说明文档

潜在一致性模型

论文 Latent Consistency Models 的官方仓库。

项目页面:https://latent-consistency-models.github.io

尝试我们的 Hugging Face 演示:

Hugging Face Spaces

模型描述:

Dreamshaper v7Stable-Diffusion v1-5 的微调版本)蒸馏而来,仅使用 4,000 次训练迭代(约 32 A100 GPU 小时)。

生成结果:

<p align="center"> <img src="teaser.png"> </p>

通过将无分类器引导蒸馏到模型的输入中,LCM 可以在非常短的推理时间内生成高质量图像。我们比较了在 768 x 768 分辨率、CFG 规模 w=8、批量大小为 4 的设置下,使用 A800 GPU 的推理时间。

<p align="center"> <img src="speed_fid.png"> </p>

使用方法

你可以直接在以下平台体验潜在一致性模型: Hugging Face Spaces

要自己运行模型,你可以使用 🧨 Diffusers 库:

  1. 安装库:
pip install --upgrade diffusers  # make sure to use at least diffusers >= 0.22
pip install transformers accelerate
  1. 运行模型:
from diffusers import DiffusionPipeline
import torch

pipe = DiffusionPipeline.from_pretrained("SimianLuo/LCM_Dreamshaper_v7")

# 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

更多信息,请查看官方文档: 👉 https://huggingface.co/docs/diffusers/api/pipelines/latent_consistency_models#latent-consistency-models

使用方法(已弃用)

  1. 安装库:
pip install diffusers transformers accelerate
  1. 运行模型:
from diffusers import DiffusionPipeline
import torch

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

# 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, 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}
}

SimianLuo/LCM_Dreamshaper_v7

作者 SimianLuo

text-to-image diffusers
↓ 116.3K ♥ 416

创建时间: 2023-10-14 08:26:52+00:00

更新时间: 2024-03-05 08:32:22+00:00

在 Hugging Face 上查看

文件 (30)

.gitattributes
LCM_Dreamshaper_v7_4k.safetensors
README.md
feature_extractor/preprocessor_config.json
inference.py
lcm_pipeline.py
lcm_scheduler.py
model_index.json
safety_checker/config.json
safety_checker/model.safetensors
scheduler/scheduler_config.json
speed_fid.png
teaser.png
text_encoder/config.json
text_encoder/model.onnx ONNX
text_encoder/model.safetensors
tokenizer/merges.txt
tokenizer/special_tokens_map.json
tokenizer/tokenizer_config.json
tokenizer/vocab.json
unet/config.json
unet/diffusion_pytorch_model.safetensors
unet/model.onnx ONNX
unet/model.onnx_data
vae/config.json
vae/diffusion_pytorch_model.safetensors
vae_decoder/config.json
vae_decoder/model.onnx ONNX
vae_encoder/config.json
vae_encoder/model.onnx ONNX