Update README.md
Browse files
README.md
CHANGED
@@ -1,4 +1,64 @@
|
|
1 |
-
---
|
2 |
-
license: apache-2.0
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
license: apache-2.0
|
3 |
+
language:
|
4 |
+
- en
|
5 |
+
tags:
|
6 |
+
- instancediffusion,
|
7 |
+
- layout-to-image,
|
8 |
+
---
|
9 |
+
|
10 |
+
# Diffusers 🧨 port of [InstanceDiffusion: Instance-level Control for Image Generation (CVPR 2024)](https://arxiv.org/abs/2402.03290)
|
11 |
+
|
12 |
+
- Original authors: Xudong Wang, Trevor Darrell, Sai Saketh Rambhatla, Rohit Girdhar, Ishan Misra
|
13 |
+
- Original github repo by authors: https://github.com/frank-xwang/InstanceDiffusion
|
14 |
+
- Converted to Diffusers: Kyeongryeol Go
|
15 |
+
|
16 |
+
# Checkpoint
|
17 |
+
- original checkpoint: https://huggingface.co/xudongw/InstanceDiffusion/resolve/main/instancediffusion_sd15.pth
|
18 |
+
- original configuration yaml: https://github.com/frank-xwang/InstanceDiffusion/blob/main/configs/test_sd15.yaml
|
19 |
+
|
20 |
+
|
21 |
+
# Example Usage
|
22 |
+
|
23 |
+
```python
|
24 |
+
import torch
|
25 |
+
from diffusers import StableDiffusionINSTDIFFPipeline
|
26 |
+
|
27 |
+
pipe = StableDiffusionINSTDIFFPipeline.from_pretrained("kyeongry/instancediffusion_sd15")
|
28 |
+
pipe = pipe.to("cuda")
|
29 |
+
|
30 |
+
prompt = "a yellow American robin, brown Maltipoo dog, a gray British Shorthair in a stream, alongside with trees and rocks"
|
31 |
+
negative_prompt = "longbody, lowres, bad anatomy, bad hands, missing fingers, extra digit, fewer digits, cropped, worst quality, low quality"
|
32 |
+
|
33 |
+
# normalized (xmin,ymin,xmax,ymax)
|
34 |
+
boxes = [
|
35 |
+
[0.0, 0.099609375, 0.349609375, 0.548828125],
|
36 |
+
[0.349609375, 0.19921875, 0.6484375, 0.498046875],
|
37 |
+
[0.6484375, 0.19921875, 0.998046875, 0.697265625],
|
38 |
+
[0.0, 0.69921875, 1.0, 0.998046875],
|
39 |
+
]
|
40 |
+
phrases = [
|
41 |
+
"a gray British Shorthair standing on a rock in the woods",
|
42 |
+
"a yellow American robin standing on the rock",
|
43 |
+
"a brown Maltipoo dog standing on the rock",
|
44 |
+
"a close up of a small waterfall in the woods",
|
45 |
+
]
|
46 |
+
|
47 |
+
image = pipe(
|
48 |
+
prompt=prompt,
|
49 |
+
negative_prompt=negative_prompt,
|
50 |
+
instdiff_phrases=phrases,
|
51 |
+
instdiff_boxes=boxes,
|
52 |
+
instdiff_scheduled_sampling_alpha=0.8, # scale of gated-self-attention
|
53 |
+
instdiff_scheduled_sampling_beta=0.36, # multi-instance sampler
|
54 |
+
guidance_scale=7.5,
|
55 |
+
output_type="pil",
|
56 |
+
num_inference_steps=50,
|
57 |
+
).images[0]
|
58 |
+
|
59 |
+
image.save("./instancediffusion-sd15-layout2image-generation.jpg")
|
60 |
+
```
|
61 |
+
|
62 |
+
# Sample Output
|
63 |
+

|
64 |
+
|