You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -13,16 +15,12 @@ The code was tested on a Tesla V100 16GB but should work on other cards with at
13
15
14
16
## Quickstart
15
17
16
-
In order to get started, we recommend taking a look at our notebooks: **prompt-to-prompt_ldm** and **prompt-to-prompt_stable**.
17
-
The notebooks contain end-to-end examples of usage of prompt-to-prompt on top of *Latent Diffusion* and *Stable Diffusion* respectively. Take a look at these notebooks to learn how to use the different types of prompt edits and understand the API.
18
-
19
-
20
-
18
+
In order to get started, we recommend taking a look at our notebooks: [**prompt-to-prompt_ldm**][p2p-ldm] and [**prompt-to-prompt_stable**][p2p-stable]. The notebooks contain end-to-end examples of usage of prompt-to-prompt on top of *Latent Diffusion* and *Stable Diffusion* respectively. Take a look at these notebooks to learn how to use the different types of prompt edits and understand the API.
21
19
22
20
## Prompt Edits
23
21
24
22
In our notebooks, we perform our main logic by implementing the abstract class `AttentionControl` object, of the following form:
@@ -32,7 +30,8 @@ class AttentionControl(abc.ABC):
32
30
The `forward` method is called in each attention layer of the diffusion model during the image generation, and we use it to modify the weights of the attention. Our method (See Section 3 of our [paper](https://arxiv.org/abs/2208.01626)) edits images with the procedure above, and each different prompt edit type modifies the weights of the attention in a different manner.
33
31
34
32
The general flow of our code is as follows, with variations based on the attention control type:
35
-
```
33
+
34
+
```python
36
35
prompts = ["A painting of a squirrel eating a burger", ...]
37
36
controller = AttentionControl(prompts, ...)
38
37
run_and_display(prompts, controller, ...)
@@ -48,8 +47,8 @@ In this case, the user adds new tokens to the prompt, e.g., editing the prompt `
48
47
In this case, the user changes the weight of certain tokens in the prompt, e.g., for the prompt `"A photo of a poppy field at night"`, strengthen or weaken the extent to which the word `night` affects the resulting image. For this we define the class `AttentionReweight`.
49
48
50
49
51
-
## Attention Control Options
52
-
*`cross_replace_steps`: specifies the fraction of steps to edit the cross attention maps. Can also be set to a dictionary `[str:float]` which specifies fractions for different words in the prompt.
50
+
## Attention Control Options
51
+
*`cross_replace_steps`: specifies the fraction of steps to edit the cross attention maps. Can also be set to a dictionary `[str:float]` which specifies fractions for different words in the prompt.
53
52
*`self_replace_steps`: specifies the fraction of steps to replace the self attention masp.
54
53
*`local_blend` (optional): `LocalBlend` object which is used to make local edits. `LocalBlend` is initialized with the words from each prompt that correspond with the region in the image we want to edit.
55
54
*`equalizer`: used for attention Re-weighting only. A vector of coefficients to multiply each cross-attention weight
@@ -68,3 +67,6 @@ In this case, the user changes the weight of certain tokens in the prompt, e.g.,
68
67
## Disclaimer
69
68
70
69
This is not an officially supported Google product.
0 commit comments