Update README.md
Browse files
README.md
CHANGED
@@ -1,3 +1,70 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
library_name: diffusers
|
6 |
+
pipeline_tag: text-to-image
|
7 |
+
---
|
8 |
+
|
9 |
+
# Target-Driven Distillation
|
10 |
+
|
11 |
+
<div align="center">
|
12 |
+
|
13 |
+
[**Project Page**](https://tdd.github.io/tdd) **|** [**Paper**](https://arxiv.org/abs) **|** [**Code**](https://github.com/RedAIGC/Target-Driven-Distillation) **|** [🤗 **Gradio demo**](https://huggingface.co/spaces)
|
14 |
+
|
15 |
+
|
16 |
+
</div>
|
17 |
+
|
18 |
+
## Introduction
|
19 |
+
|
20 |
+
Target-Driven Distillation: Consistency Distillation with Target Timestep Selection and Decoupled Guidance
|
21 |
+
|
22 |
+
<div align="center">
|
23 |
+
<img src='teaser.jpg'>
|
24 |
+
</div>
|
25 |
+
|
26 |
+
## Update
|
27 |
+
[2024.08.22]:Upload the TDD LoRA weights of Stable Diffusion XL, YamerMIX and RealVisXL-V4.0, fast text-to-image generation.
|
28 |
+
- sdxl_tdd_lora_weights.safetensors
|
29 |
+
- yamermix_tdd_lora_weights.safetensors
|
30 |
+
- realvis_tdd_sdxl_lora_weights.safetensors
|
31 |
+
|
32 |
+
Thanks to [Yamer](https://civitai.com/user/Yamer) and [SG_161222](https://civitai.com/user/SG_161222) for developing [YamerMIX](https://civitai.com/models/84040?modelVersionId=395107) and [RealVisXL V4.0](https://civitai.com/models/139562/realvisxl-v40) respectively.
|
33 |
+
## Usage
|
34 |
+
|
35 |
+
You can directly download the model in this repository.
|
36 |
+
You also can download the model in python script:
|
37 |
+
|
38 |
+
```python
|
39 |
+
from huggingface_hub import hf_hub_download
|
40 |
+
hf_hub_download(repo_id="RedAIGC/TDD", filename="sdxl_tdd_lora_weights.safetensors", local_dir="./tdd_lora")
|
41 |
+
```
|
42 |
+
|
43 |
+
```python
|
44 |
+
# !pip install opencv-python transformers accelerate
|
45 |
+
import torch
|
46 |
+
import diffusers
|
47 |
+
from diffusers import StableDiffusionXLPipeline
|
48 |
+
from tdd_scheduler import TDDScheduler
|
49 |
+
|
50 |
+
device = "cuda"
|
51 |
+
tdd_lora_path = "tdd_lora/sdxl_tdd_lora_weights.safetensors"
|
52 |
+
|
53 |
+
pipe = StableDiffusionXLPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-1.0", torch_dtype=torch.float16, variant="fp16").to(device)
|
54 |
+
|
55 |
+
pipe.scheduler = TDDSchedulerPlus.from_config(pipe.scheduler.config)
|
56 |
+
pipe.load_lora_weights(tdd_lora_path, adapter_name="accelerate")
|
57 |
+
pipe.fuse_lora()
|
58 |
+
|
59 |
+
prompt = "A photo of a cat made of water."
|
60 |
+
|
61 |
+
image = pipe(
|
62 |
+
prompt=prompt,
|
63 |
+
num_inference_steps=4,
|
64 |
+
guidance_scale=1.7,
|
65 |
+
eta=0.2,
|
66 |
+
generator=torch.Generator(device=device).manual_seed(546237),
|
67 |
+
).images[0]
|
68 |
+
|
69 |
+
image.save("tdd.png")
|
70 |
+
```
|