jyoung105 commited on
Commit
4cb560f
1 Parent(s): 10f9783

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +84 -3
README.md CHANGED
@@ -1,3 +1,84 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license:
3
+ - apache-2.0
4
+ language:
5
+ - en
6
+ tags:
7
+ - Diffusion Models
8
+ - Stable Diffusion XL
9
+ - Perturbed-Attention Guidance
10
+ - PAG
11
+ ---
12
+ # Perturbed-Attention Guidance for SDXL (i2i)
13
+
14
+ <div style="display:flex">
15
+ <video width=50% autoplay loop controls>
16
+ <source src="https://huggingface.co/multimodalart/sdxl_perturbed_attention_guidance/resolve/main/pag_sdxl.mp4" type="video/mp4">
17
+ </video>
18
+ <video width=50% autoplay loop controls>
19
+ <source src="https://huggingface.co/multimodalart/sdxl_perturbed_attention_guidance/resolve/main/pag_uncond.mp4" type="video/mp4">
20
+ </video>
21
+ </div>
22
+ The original Perturbed-Attention Guidance for unconditional models and SD1.5 by [Hyoungwon Cho](https://huggingface.co/hyoungwoncho) is availiable at [hyoungwoncho/sd_perturbed_attention_guidance](https://huggingface.co/hyoungwoncho/sd_perturbed_attention_guidance)
23
+
24
+ [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)
25
+
26
+ Also there is an extra implementation of the Perturbed-Attention Guidance (PAG) on Stable Diffusion XL (SDXL) for the 🧨 diffusers library by [multimodalart](https://huggingface.co/multimodalart)
27
+ [code](https://huggingface.co/multimodalart/sdxl_perturbed_attention_guidance) / [demo](https://huggingface.co/spaces/multimodalart/perturbed-attention-guidance-sdxl)
28
+
29
+ This repository is just a simple implementation of the Perturbed-Attention Guidance (PAG) on Stable Diffusion XL (SDXL) for the 🧨 diffusers library to "i2i".
30
+
31
+
32
+ ## Quickstart
33
+
34
+ Loading Custom Pipeline:
35
+
36
+ ```py
37
+ from diffusers import StableDiffusionXLImg2ImgPipeline
38
+ pipe = StableDiffusionXLImg2ImgPipeline.from_pretrained(
39
+ "stabilityai/stable-diffusion-xl-base-1.0",
40
+ custom_pipeline="jyoung105/sdxl_perturbed_attention_guidance_i2i",
41
+ torch_dtype=torch.float16
42
+ )
43
+ device="cuda"
44
+ pipe = pipe.to(device)
45
+ ```
46
+
47
+ Unconditional sampling with PAG:
48
+ ![image/jpeg](uncond_generation_pag.jpg)
49
+
50
+ ```py
51
+ output = pipe(
52
+ "",
53
+ image=init_image,
54
+ strength=0.9,
55
+ num_inference_steps=50,
56
+ guidance_scale=0.0,
57
+ pag_scale=5.0,
58
+ pag_applied_layers=['mid']
59
+ ).images
60
+ ```
61
+
62
+ Sampling with PAG and CFG:
63
+ ![image/jpeg](cfgpag.jpg)
64
+ ```py
65
+ output = pipe(
66
+ "the spirit of a tamagotchi wandering in the city of Vienna",
67
+ image=init_image,
68
+ strength=0.9,
69
+ num_inference_steps=25,
70
+ guidance_scale=4.0,
71
+ pag_scale=3.0,
72
+ pag_applied_layers=['mid']
73
+ ).images
74
+ ```
75
+
76
+ ## Parameters
77
+
78
+ `guidance_scale` : guidance scale of CFG (ex: `7.5`)
79
+
80
+ `pag_scale` : guidance scale of PAG (ex: `4.0`)
81
+
82
+ `pag_applied_layers`: layer to apply perturbation (ex: ['mid'])
83
+
84
+ `pag_applied_layers_index` : index of the layers to apply perturbation (ex: ['m0', 'm1'])