Create README.md
Browse files
README.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: mit
|
| 3 |
+
language:
|
| 4 |
+
- en
|
| 5 |
+
pipeline_tag: text-to-image
|
| 6 |
+
tags:
|
| 7 |
+
- text-to-image
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
# Latent Consistency Models
|
| 11 |
+
|
| 12 |
+
Official Repository of the paper: *[Latent Consistency Models](https://arxiv.org/abs/2310.04378)*.
|
| 13 |
+
|
| 14 |
+
Project Page: https://latent-consistency-models.github.io
|
| 15 |
+
|
| 16 |
+
## Model Descriptions:
|
| 17 |
+
Copied from [SimianLuo/LCM_Dreamshaper_v7](https://huggingface.co/SimianLuo/LCM_Dreamshaper_v7) to experiment with quantization.
|
| 18 |
+
Originally distilled from [Dreamshaper v7](https://huggingface.co/Lykon/dreamshaper-7) fine-tune of [Stable-Diffusion v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) with only 4,000 training iterations (~32 A100 GPU Hours).
|
| 19 |
+
|
| 20 |
+
## Usage
|
| 21 |
+
|
| 22 |
+
To run the model yourself, you can leverage the 🧨 Diffusers library:
|
| 23 |
+
1. Install the library:
|
| 24 |
+
```
|
| 25 |
+
pip install --upgrade diffusers # make sure to use at least diffusers >= 0.22
|
| 26 |
+
pip install transformers accelerate
|
| 27 |
+
```
|
| 28 |
+
|
| 29 |
+
2. Run the model:
|
| 30 |
+
```py
|
| 31 |
+
from diffusers import DiffusionPipeline
|
| 32 |
+
import torch
|
| 33 |
+
|
| 34 |
+
pipe = DiffusionPipeline.from_pretrained("TobDeBer/lcm_dream7")
|
| 35 |
+
|
| 36 |
+
# To save GPU memory, torch.float16 can be used, but it may compromise image quality.
|
| 37 |
+
pipe.to(torch_device="cuda", torch_dtype=torch.float32)
|
| 38 |
+
|
| 39 |
+
prompt = "Self-portrait oil painting, a beautiful cyborg with golden hair, 8k"
|
| 40 |
+
|
| 41 |
+
# Can be set to 1~50 steps. LCM support fast inference even <= 4 steps. Recommend: 1~8 steps.
|
| 42 |
+
num_inference_steps = 4
|
| 43 |
+
|
| 44 |
+
images = pipe(prompt=prompt, num_inference_steps=num_inference_steps, guidance_scale=8.0, lcm_origin_steps=50, output_type="pil").images
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
For more information, please have a look at the official docs:
|
| 48 |
+
👉 https://huggingface.co/docs/diffusers/api/pipelines/latent_consistency_models#latent-consistency-models
|