File size: 2,254 Bytes
0f70bd5
 
 
 
 
 
 
 
 
 
 
 
 
 
f9b609c
0f70bd5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
---
base_model:
- CompVis/stable-diffusion-v1-4
pipeline_tag: text-to-image
tags:
- art
- biology
---
<h1 align="center">**The Superposition of Diffusion Models Using the It么 Density Estimator**: Pipeline</h1>

 <p align="center">
 <a href="https://arxiv.org/abs/2412.17762"><img src="https://img.shields.io/badge/Arxiv-2412.17762-red?style=for-the-badge&logo=Arxiv" alt="arXiv"/></a>
</p>

This pipeline shows how to superimpose different text prompts from [Stable Diffusion v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4) based the paper [The Superposition of Diffusion Models Using the It么 Density Estimator](https://www.arxiv.org/abs/2412.17762).

<p align="center">
<img src="https://huggingface.co/superdiff/pipeline/blob/main/superdiff_small.gif" alt="drawing" style="width:500px;">
</p>


## Example usage

```
from PIL import Image
from diffusers import DiffusionPipeline

image = pipeline("a flamingo", "a candy cane", seed=1, num_inference_steps=1000, batch_size=1)
image = Image.fromarray(image.cpu().numpy())
image.save("superdiff_output.png")
```

Arguments that can be set by user in `pipeline()`:

- `prompt_1`: text prompt describing first concept to superimpose (e.g. "a flamingo")
- `prompt_2`: text prompt describing second concept to superimpose (e.g. "a candy cane")
- `seed`: seed for random noise generator for reproducibility; for non-deterministic outputs, do not provide value
- `num_inference_steps`: number of denoising steps (we recommend 1000!)
- `batch_size`: batch size
- `lift`: bias value that favours generation towards one prompt over the other
- `guidance_scale`: scale for classifier-free guidance
- `height`, `width`: height and width of generated images

To replicate images from Section 4.2 of the paper, you can use the following:

```
image = pipeline(prompt_1, prompt_2, seed=1, num_inference_steps=1000, batch_size=20, lift=0.0, guidance_scale=7.5)
```

## Citation

**BibTeX:**

```
@article{skreta2024superposition,
  title={The Superposition of Diffusion Models Using the It$\backslash$\^{} o Density Estimator},
  author={Skreta, Marta and Atanackovic, Lazar and Bose, Avishek Joey and Tong, Alexander and Neklyudov, Kirill},
  journal={arXiv preprint arXiv:2412.17762},
  year={2024}
}
```