add readme
Browse files
README.md
CHANGED
@@ -91,6 +91,34 @@ Which should give you an image like below:
|
|
91 |
|
92 |
![A girl sitting in a cafe](sample_result.png)
|
93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
### Preprocessing
|
96 |
|
|
|
91 |
|
92 |
![A girl sitting in a cafe](sample_result.png)
|
93 |
|
94 |
+
### Using Controlnets in Diffusers
|
95 |
+
|
96 |
+
Make sure you upgrade to the latest diffusers version: `pip install -U diffusers`. And then you can run:
|
97 |
+
|
98 |
+
```python
|
99 |
+
import torch
|
100 |
+
from diffusers import StableDiffusion3ControlNetPipeline, SD3ControlNetModel
|
101 |
+
from diffusers.utils import load_image
|
102 |
+
|
103 |
+
controlnet = SD3ControlNetModel.from_pretrained("stabilityai/stable-diffusion-3.5-large-controlnet-depth", torch_dtype=torch.float16)
|
104 |
+
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(
|
105 |
+
"stabilityai/stable-diffusion-3.5-large",
|
106 |
+
controlnet=controlnet,
|
107 |
+
torch_dtype=torch.float16,
|
108 |
+
).to("cuda")
|
109 |
+
|
110 |
+
control_image = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/marigold/marigold_einstein_lcm_depth.png")
|
111 |
+
generator = torch.Generator(device="cpu").manual_seed(0)
|
112 |
+
image = pipe(
|
113 |
+
prompt = "a photo of a man",
|
114 |
+
control_image=control_image,
|
115 |
+
guidance_scale=4.5,
|
116 |
+
num_inference_steps=40,
|
117 |
+
generator=generator,
|
118 |
+
max_sequence_length=77,
|
119 |
+
).images[0]
|
120 |
+
image.save('depth-8b.jpg')
|
121 |
+
```
|
122 |
|
123 |
### Preprocessing
|
124 |
|