Update README.md
Browse files
README.md
CHANGED
|
@@ -1,43 +1,44 @@
|
|
| 1 |
-
---
|
| 2 |
-
license: apache-2.0
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
from diffusers
|
| 14 |
-
from diffusers.
|
| 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 |
-
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: apache-2.0
|
| 3 |
+
library_name: diffusers
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# SD3-ControlNet-Depth
|
| 7 |
+
|
| 8 |
+
<img src="./assets/teaser.png"/>
|
| 9 |
+
|
| 10 |
+
# Demo
|
| 11 |
+
```python
|
| 12 |
+
import torch
|
| 13 |
+
from diffusers import StableDiffusion3ControlNetPipeline
|
| 14 |
+
from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel
|
| 15 |
+
from diffusers.utils import load_image
|
| 16 |
+
|
| 17 |
+
# load pipeline
|
| 18 |
+
controlnet = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Depth")
|
| 19 |
+
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
|
| 20 |
+
"stabilityai/stable-diffusion-3-medium-diffusers",
|
| 21 |
+
controlnet=controlnet
|
| 22 |
+
)
|
| 23 |
+
pipe.to("cuda", torch.float16)
|
| 24 |
+
|
| 25 |
+
# config
|
| 26 |
+
control_image = load_image("https://huggingface.co/InstantX/SD3-Controlnet-Depth/resolve/main/images/depth.jpeg")
|
| 27 |
+
prompt = "a panda cub, captured in a close-up, in forest, is perched on a tree trunk. good composition, Photography, the cub's ears, a fluffy black, are tucked behind its head, adding a touch of whimsy to its appearance. a lush tapestry of green leaves in the background. depth of field, National Geographic"
|
| 28 |
+
n_prompt = "bad hands, blurry, NSFW, nude, naked, porn, ugly, bad quality, worst quality"
|
| 29 |
+
|
| 30 |
+
# to reproduce result in our example
|
| 31 |
+
generator = torch.Generator(device="cpu").manual_seed(4000)
|
| 32 |
+
image = pipe(
|
| 33 |
+
prompt,
|
| 34 |
+
negative_prompt=n_prompt,
|
| 35 |
+
control_image=control_image,
|
| 36 |
+
controlnet_conditioning_scale=0.5,
|
| 37 |
+
guidance_scale=7.0,
|
| 38 |
+
generator=generator
|
| 39 |
+
).images[0]
|
| 40 |
+
image.save('image.jpg')
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
# Limitation
|
| 44 |
+
Due to the fact that only 1024*1024 pixel resolution was used during the training phase, the inference performs best at this size, with other sizes yielding suboptimal results.
|