Update README.md
Browse files
README.md
CHANGED
@@ -3,9 +3,9 @@
|
|
3 |
|
4 |
|
5 |
|
6 |
-
|
|
7 |
-
|
8 |
-
|<img src="./
|
9 |
|
10 |
|
11 |
# Install Diffusers-SD3-Controlnet
|
@@ -21,37 +21,25 @@ pip install -e .
|
|
21 |
# Demo
|
22 |
```python
|
23 |
import torch
|
|
|
|
|
24 |
from diffusers.utils import load_image
|
25 |
-
import sys, os
|
26 |
-
sys.path.append('/path/diffusers/examples/community')
|
27 |
-
from pipeline_stable_diffusion_3_controlnet import StableDiffusion3CommonPipeline
|
28 |
-
|
29 |
# load pipeline
|
30 |
-
|
31 |
-
pipe =
|
32 |
-
|
33 |
-
|
34 |
)
|
35 |
-
pipe.to(
|
|
|
|
|
36 |
prompt = 'Anime style illustration of a girl wearing a suit. A moon in sky. In the background we see a big rain approaching. text "InstantX" on image'
|
37 |
n_prompt = 'NSFW, nude, naked, porn, ugly'
|
38 |
-
# controlnet config
|
39 |
-
controlnet_conditioning = [
|
40 |
-
dict(
|
41 |
-
control_index=0,
|
42 |
-
control_image=load_image('https://huggingface.co/InstantX/SD3-Controlnet-Canny/resolve/main/canny.jpg'),
|
43 |
-
control_weight=0.7,
|
44 |
-
control_pooled_projections='zeros'
|
45 |
-
)
|
46 |
-
]
|
47 |
-
# infer
|
48 |
image = pipe(
|
49 |
-
prompt
|
50 |
-
negative_prompt=n_prompt,
|
51 |
-
|
52 |
-
|
53 |
-
guidance_scale=7.0,
|
54 |
-
height=1024,
|
55 |
-
width=1024,
|
56 |
).images[0]
|
|
|
57 |
```
|
|
|
3 |
|
4 |
|
5 |
|
6 |
+
| control image | weight=0.0 | weight=0.3 | weight=0.5 | weight=0.7 | weight=0.9 |
|
7 |
+
|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|:-------------------------:|
|
8 |
+
|<img src="./canny.jpg" width = "400" /> | <img src="./demo_0.jpg" width = "400" /> | <img src="./demo_3.jpg" width = "400" /> | <img src="./demo_5.jpg" width = "400" /> | <img src="./demo_7.jpg" width = "400" /> | <img src="./demo_9.jpg" width = "400" /> |
|
9 |
|
10 |
|
11 |
# Install Diffusers-SD3-Controlnet
|
|
|
21 |
# Demo
|
22 |
```python
|
23 |
import torch
|
24 |
+
from diffusers import StableDiffusion3ControlNetPipeline
|
25 |
+
from diffusers.models import SD3ControlNetModel, SD3MultiControlNetModel
|
26 |
from diffusers.utils import load_image
|
|
|
|
|
|
|
|
|
27 |
# load pipeline
|
28 |
+
controlnet = SD3ControlNetModel.from_pretrained("InstantX/SD3-Controlnet-Canny")
|
29 |
+
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
|
30 |
+
"stabilityai/stable-diffusion-3-medium-diffusers",
|
31 |
+
controlnet=controlnet
|
32 |
)
|
33 |
+
pipe.to("cuda", torch.float16)
|
34 |
+
# config
|
35 |
+
control_image = load_image("https://huggingface.co/InstantX/SD3-Controlnet-Canny/resolve/main/canny.jpg")
|
36 |
prompt = 'Anime style illustration of a girl wearing a suit. A moon in sky. In the background we see a big rain approaching. text "InstantX" on image'
|
37 |
n_prompt = 'NSFW, nude, naked, porn, ugly'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
image = pipe(
|
39 |
+
prompt,
|
40 |
+
negative_prompt=n_prompt,
|
41 |
+
control_image=canny_image,
|
42 |
+
controlnet_conditioning_scale=0.5,
|
|
|
|
|
|
|
43 |
).images[0]
|
44 |
+
image.save('image.jpg')
|
45 |
```
|