hyoungwoncho
commited on
Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
language:
|
3 |
+
- en
|
4 |
+
pipeline_tag: unconditional-image-generation
|
5 |
+
tags:
|
6 |
+
- Stable Diffusion
|
7 |
+
- Perturbed-Attention Guidance
|
8 |
+
- PAG
|
9 |
+
---
|
10 |
+
|
11 |
+
## Perturbed-Attention Guidance
|
12 |
+
|
13 |
+
This repository is based on [Diffusers](https://huggingface.co/docs/diffusers/index). StableDiffusionPAGPipeline is a modification of StableDiffusionPipeline to support Perturbed-Attention Guidance (PAG).
|
14 |
+
|
15 |
+
## Quickstart
|
16 |
+
|
17 |
+
Load StableDiffusionPAGPipeline as below:
|
18 |
+
|
19 |
+
```
|
20 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
21 |
+
"runwayml/stable-diffusion-v1-5",
|
22 |
+
custom_pipeline="hyoungwoncho/sd_perturbed_attention_guidance",
|
23 |
+
torch_dtype=torch.float16,
|
24 |
+
safety_checker=None
|
25 |
+
)
|
26 |
+
```
|
27 |
+
|
28 |
+
Sampling:
|
29 |
+
|
30 |
+
```
|
31 |
+
output_baseline = pipe(
|
32 |
+
prompts,
|
33 |
+
width=512,
|
34 |
+
height=512,
|
35 |
+
num_inference_steps=50,
|
36 |
+
guidance_scale=0.0,
|
37 |
+
pag_scale=4.5,
|
38 |
+
pag_applied_layers_index=pag_applied_layers_index
|
39 |
+
).images
|
40 |
+
```
|
41 |
+
|
42 |
+
Parameters:
|
43 |
+
|
44 |
+
pag_scale : gudiance scale of PAG (ex: 4.5)
|
45 |
+
pag_applied_layers_index = index of the layer to apply perturbation (ex: ['m0'])
|