Update README.md
Browse files
README.md
CHANGED
@@ -33,7 +33,30 @@ These are controlnet weights trained on stabilityai/stable-diffusion-2-1-base wi
|
|
33 |
#### How to use
|
34 |
|
35 |
```python
|
36 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
```
|
38 |
|
39 |
#### Limitations and bias
|
|
|
33 |
#### How to use
|
34 |
|
35 |
```python
|
36 |
+
from PIL import Image
|
37 |
+
from diffusers import (
|
38 |
+
ControlNetModel,
|
39 |
+
StableDiffusionControlNetPipeline,
|
40 |
+
UniPCMultistepScheduler,
|
41 |
+
)
|
42 |
+
|
43 |
+
checkpoint = "liuch37/controlnet-sd-2-1-base-v1"
|
44 |
+
|
45 |
+
prompt = "YOUR_FAVORITE_PROMPT"
|
46 |
+
|
47 |
+
control_image = Image.open("YOUR_SEMANTIC_IMAGE")
|
48 |
+
|
49 |
+
controlnet = ControlNetModel.from_pretrained(checkpoint, torch_dtype=torch.float32)
|
50 |
+
pipe = StableDiffusionControlNetPipeline.from_pretrained(
|
51 |
+
"stabilityai/stable-diffusion-2-1-base", controlnet=controlnet, torch_dtype=torch.float32
|
52 |
+
)
|
53 |
+
|
54 |
+
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
|
55 |
+
|
56 |
+
generator = torch.manual_seed(0)
|
57 |
+
image = pipe(prompt, num_inference_steps=30, generator=generator, image=control_image).images[0]
|
58 |
+
|
59 |
+
image.save("YOUR_OUTPUT_IMAGE")
|
60 |
```
|
61 |
|
62 |
#### Limitations and bias
|