File size: 1,138 Bytes
bb778ec dc4db28 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 |
---
license: openrail
---
Converted Canny SD 2.1-base model from https://huggingface.co/thibaud/controlnet-sd21/ to diffusers format.
Saved only ControlNet weights
Usage:
```
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, DEISMultistepScheduler
import cv2
from PIL import Image
import numpy as np
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-2-1-base",
safety_checker=None,
# revision='fp16',
# torch_dtype=torch.float16,
controlnet=ControlNetModel.from_pretrained("thepowefuldeez/sd21-controlnet-canny")
).to('cuda')
pipe.scheduler = DEISMultistepScheduler.from_config(pipe.scheduler.config)
image = np.array(Image.open("10.png"))
low_threshold = 100
high_threshold = 200
image = cv2.Canny(image, low_threshold, high_threshold)
image = image[:, :, None]
image = np.concatenate([image, image, image], axis=2)
canny_image = Image.fromarray(image)
im = pipe(
"beautiful woman", image=canny_image, num_inference_steps=30,
negative_prompt="ugly, blurry, bad, deformed, bad anatomy",
generator=torch.manual_seed(42)
).images[0]
``` |