Commit
•
fcf7a9c
1
Parent(s):
43cbf18
Update README.md
Browse files
README.md
CHANGED
@@ -9,24 +9,25 @@ tags:
|
|
9 |
- PAG
|
10 |
---
|
11 |
|
12 |
-
# Perturbed-Attention Guidance
|
13 |
|
14 |
![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6601282b569b30694e67b886/27Lmuol8anwd6L6BLzyWf.jpeg)
|
15 |
|
16 |
[Project](https://ku-cvlab.github.io/Perturbed-Attention-Guidance/) / [arXiv](https://arxiv.org/abs/2403.17377) / [GitHub](https://github.com/KU-CVLAB/Perturbed-Attention-Guidance)
|
17 |
|
18 |
-
This repository is based on [Diffusers](https://huggingface.co/docs/diffusers/index). The pipeline is a modification of
|
|
|
19 |
|
20 |
## Quickstart
|
21 |
|
22 |
Loading Custom Piepline:
|
23 |
|
24 |
```
|
25 |
-
from diffusers import
|
26 |
|
27 |
-
pipe =
|
28 |
-
"
|
29 |
-
custom_pipeline="
|
30 |
torch_dtype=torch.float16
|
31 |
)
|
32 |
|
@@ -34,17 +35,15 @@ device="cuda"
|
|
34 |
pipe = pipe.to(device)
|
35 |
```
|
36 |
|
37 |
-
|
38 |
|
39 |
```
|
40 |
output = pipe(
|
41 |
-
|
42 |
-
width=512,
|
43 |
-
height=512,
|
44 |
num_inference_steps=50,
|
45 |
guidance_scale=0.0,
|
46 |
pag_scale=5.0,
|
47 |
-
|
48 |
).images
|
49 |
```
|
50 |
|
@@ -52,24 +51,24 @@ Sampling with PAG and CFG:
|
|
52 |
|
53 |
```
|
54 |
output = pipe(
|
55 |
-
|
56 |
-
|
57 |
-
height=512,
|
58 |
-
num_inference_steps=50,
|
59 |
guidance_scale=4.0,
|
60 |
pag_scale=3.0,
|
61 |
-
|
62 |
).images
|
63 |
```
|
64 |
|
65 |
## Parameters
|
66 |
|
67 |
-
guidance_scale : gudiance scale of CFG (ex: 7.5)
|
|
|
|
|
68 |
|
69 |
-
|
70 |
|
71 |
-
pag_applied_layers_index : index of the layer to apply perturbation (ex: ['m0'])
|
72 |
|
73 |
-
## Stable Diffusion Demo
|
74 |
|
75 |
To join a demo of PAG on Stable Diffusion, run [sd_pag_demo.ipynb](https://huggingface.co/hyoungwoncho/sd_perturbed_attention_guidance/blob/main/sd_pag_demo.ipynb).
|
|
|
9 |
- PAG
|
10 |
---
|
11 |
|
12 |
+
# Perturbed-Attention Guidance SDXL
|
13 |
|
14 |
![image/jpeg](https://cdn-uploads.huggingface.co/production/uploads/6601282b569b30694e67b886/27Lmuol8anwd6L6BLzyWf.jpeg)
|
15 |
|
16 |
[Project](https://ku-cvlab.github.io/Perturbed-Attention-Guidance/) / [arXiv](https://arxiv.org/abs/2403.17377) / [GitHub](https://github.com/KU-CVLAB/Perturbed-Attention-Guidance)
|
17 |
|
18 |
+
This repository is based on [Diffusers](https://huggingface.co/docs/diffusers/index). The pipeline is a modification of StableDiffusionXLPipeline to add Perturbed-Attention Guidance (PAG).
|
19 |
+
The original Perturbed-Attention Guidance by [Hyoungwon Cho](https://huggingface.co/hyoungwoncho) is availiable at [hyoungwoncho/sd_perturbed_attention_guidance](https://huggingface.co/hyoungwoncho/sd_perturbed_attention_guidance)
|
20 |
|
21 |
## Quickstart
|
22 |
|
23 |
Loading Custom Piepline:
|
24 |
|
25 |
```
|
26 |
+
from diffusers import StableDiffusionXLPipeline
|
27 |
|
28 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(
|
29 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
30 |
+
custom_pipeline="multimodalart/sdxl_perturbed_attention_guidance",
|
31 |
torch_dtype=torch.float16
|
32 |
)
|
33 |
|
|
|
35 |
pipe = pipe.to(device)
|
36 |
```
|
37 |
|
38 |
+
Unconditional sampling with PAG:
|
39 |
|
40 |
```
|
41 |
output = pipe(
|
42 |
+
"",
|
|
|
|
|
43 |
num_inference_steps=50,
|
44 |
guidance_scale=0.0,
|
45 |
pag_scale=5.0,
|
46 |
+
pag_applied_layers=['mid']
|
47 |
).images
|
48 |
```
|
49 |
|
|
|
51 |
|
52 |
```
|
53 |
output = pipe(
|
54 |
+
"the spirit of a tamagotchi wandering in the city of Vienna",
|
55 |
+
num_inference_steps=25,
|
|
|
|
|
56 |
guidance_scale=4.0,
|
57 |
pag_scale=3.0,
|
58 |
+
pag_applied_layers=['mid']
|
59 |
).images
|
60 |
```
|
61 |
|
62 |
## Parameters
|
63 |
|
64 |
+
`guidance_scale` : gudiance scale of CFG (ex: `7.5`)
|
65 |
+
|
66 |
+
`pag_scale` : gudiance scale of PAG (ex: `4.0`)
|
67 |
|
68 |
+
`pag_applied_layers`: layer to apply perturbation (ex: ['mid'])
|
69 |
|
70 |
+
`pag_applied_layers_index` : index of the layer to apply perturbation (ex: ['m0'])
|
71 |
|
72 |
+
## Stable Diffusion XL Demo
|
73 |
|
74 |
To join a demo of PAG on Stable Diffusion, run [sd_pag_demo.ipynb](https://huggingface.co/hyoungwoncho/sd_perturbed_attention_guidance/blob/main/sd_pag_demo.ipynb).
|