Update README.md
Browse files
README.md
CHANGED
@@ -28,4 +28,46 @@ prompt: Cinematic, neoclassical table in the living room, cinematic, contour, li
|
|
28 |
![images_3)](./out_room.png)
|
29 |
|
30 |
prompt: a tornado hitting grass field, 1980's film grain. overcast, muted colors.
|
31 |
-
![images_0)](./out_tornado.png)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
![images_3)](./out_room.png)
|
29 |
|
30 |
prompt: a tornado hitting grass field, 1980's film grain. overcast, muted colors.
|
31 |
+
![images_0)](./out_tornado.png)
|
32 |
+
|
33 |
+
## Usage
|
34 |
+
|
35 |
+
```python
|
36 |
+
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
|
37 |
+
from diffusers.utils import load_image
|
38 |
+
from PIL import Image
|
39 |
+
import torch
|
40 |
+
import numpy as np
|
41 |
+
import cv2
|
42 |
+
|
43 |
+
prompt = "aerial view, a futuristic research complex in a bright foggy jungle, hard lighting"
|
44 |
+
negative_prompt = 'low quality, bad quality, sketches'
|
45 |
+
|
46 |
+
image = load_image("https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png")
|
47 |
+
|
48 |
+
controlnet_conditioning_scale = 0.5 # recommended for good generalization
|
49 |
+
|
50 |
+
controlnet = ControlNetModel.from_pretrained(
|
51 |
+
"diffusers/controlnet-sdxl-1.0", subfolder="checkpoint-3000/controlnet", torch_dtype=torch.float16
|
52 |
+
)
|
53 |
+
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
|
54 |
+
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
|
55 |
+
"stabilityai/stable-diffusion-xl-base-1.0",
|
56 |
+
controlnet=controlnet,
|
57 |
+
torch_dtype=torch.float16,
|
58 |
+
)
|
59 |
+
pipe.enable_model_cpu_offload()
|
60 |
+
|
61 |
+
image = np.array(image)
|
62 |
+
image = cv2.Canny(image, 100, 200)
|
63 |
+
image = image[:, :, None]
|
64 |
+
image = np.concatenate([image, image, image], axis=2)
|
65 |
+
image = Image.fromarray(image)
|
66 |
+
|
67 |
+
images = pipe(
|
68 |
+
prompt, image=image, controlnet_conditioning_scale=controlnet_conditioning_scale,
|
69 |
+
).images
|
70 |
+
|
71 |
+
image[0]_.save(f"hug_lab.png")
|
72 |
+
```
|
73 |
+
|