Create README.md
Browse files
README.md
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
base_model:
|
3 |
+
- CompVis/stable-diffusion-v1-4
|
4 |
+
pipeline_tag: text-to-image
|
5 |
+
tags:
|
6 |
+
- art
|
7 |
+
- biology
|
8 |
+
---
|
9 |
+
<h1 align="center">**The Superposition of Diffusion Models Using the It么 Density Estimator**: Pipeline</h1>
|
10 |
+
|
11 |
+
<p align="center">
|
12 |
+
<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>
|
13 |
+
</p>
|
14 |
+
|
15 |
+
This pipeline shows how to superimpose different text prompts from [Stable Diffusion v1-4](https://huggingface.co/CompVis/stable-diffusion-v1-4) based on theorems from the paper [The Superposition of Diffusion Models Using the It么 Density Estimator](https://www.arxiv.org/abs/2412.17762).
|
16 |
+
|
17 |
+
<p align="center">
|
18 |
+
<img src="https://huggingface.co/superdiff/pipeline/blob/main/superdiff_small.gif" alt="drawing" style="width:500px;">
|
19 |
+
</p>
|
20 |
+
|
21 |
+
|
22 |
+
## Example usage
|
23 |
+
|
24 |
+
```
|
25 |
+
from PIL import Image
|
26 |
+
from diffusers import DiffusionPipeline
|
27 |
+
|
28 |
+
image = pipeline("a flamingo", "a candy cane", seed=1, num_inference_steps=1000, batch_size=1)
|
29 |
+
image = Image.fromarray(image.cpu().numpy())
|
30 |
+
image.save("superdiff_output.png")
|
31 |
+
```
|
32 |
+
|
33 |
+
Arguments that can be set by user in `pipeline()`:
|
34 |
+
|
35 |
+
- `prompt_1`: text prompt describing first concept to superimpose (e.g. "a flamingo")
|
36 |
+
- `prompt_2`: text prompt describing second concept to superimpose (e.g. "a candy cane")
|
37 |
+
- `seed`: seed for random noise generator for reproducibility; for non-deterministic outputs, do not provide value
|
38 |
+
- `num_inference_steps`: number of denoising steps (we recommend 1000!)
|
39 |
+
- `batch_size`: batch size
|
40 |
+
- `lift`: bias value that favours generation towards one prompt over the other
|
41 |
+
- `guidance_scale`: scale for classifier-free guidance
|
42 |
+
- `height`, `width`: height and width of generated images
|
43 |
+
|
44 |
+
To replicate images from Section 4.2 of the paper, you can use the following:
|
45 |
+
|
46 |
+
```
|
47 |
+
image = pipeline(prompt_1, prompt_2, seed=1, num_inference_steps=1000, batch_size=20, lift=0.0, guidance_scale=7.5)
|
48 |
+
```
|
49 |
+
|
50 |
+
## Citation
|
51 |
+
|
52 |
+
**BibTeX:**
|
53 |
+
|
54 |
+
```
|
55 |
+
@article{skreta2024superposition,
|
56 |
+
title={The Superposition of Diffusion Models Using the It$\backslash$\^{} o Density Estimator},
|
57 |
+
author={Skreta, Marta and Atanackovic, Lazar and Bose, Avishek Joey and Tong, Alexander and Neklyudov, Kirill},
|
58 |
+
journal={arXiv preprint arXiv:2412.17762},
|
59 |
+
year={2024}
|
60 |
+
}
|
61 |
+
```
|