Views
No views yet

| Model Name | Control Image Overview | Control Image Example | Generated Image Example |
|---|---|---|---|
| lllyasviel/sd-controlnet-canny Trained with canny edge detection | A monochrome image with white edges on a black background. | ![]() | ![]() |
| lllyasviel/sd-controlnet-depth Trained with Midas depth estimation | A grayscale image with black representing deep areas and white representing shallow areas. | ![]() | ![]() |
| lllyasviel/sd-controlnet-hed Trained with HED edge detection (soft edge) | A monochrome image with white soft edges on a black background. | ![]() | ![]() |
| lllyasviel/sd-controlnet-mlsd Trained with M-LSD line detection | A monochrome image composed only of white straight lines on a black background. | ![]() | ![]() |
| lllyasviel/sd-controlnet-normal Trained with normal map | A normal mapped image. | ![]() | ![]() |
| lllyasviel/sd-controlnet_openpose Trained with OpenPose bone image | A OpenPose bone image. | ![]() | ![]() |
| lllyasviel/sd-controlnet_scribble Trained with human scribbles | A hand-drawn monochrome image with white outlines on a black background. | ![]() | ![]() |
| lllyasviel/sd-controlnet_seg Trained with semantic segmentation | An ADE20K's segmentation protocol image. | ![]() | ![]() |
$ pip install opencv-contrib-pythondiffusers and related packages:$ pip install diffusers transformers git+https://github.com/huggingface/accelerate.git1import cv2
2from PIL import Image
3from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
4import torch
5import numpy as np
6from diffusers.utils import load_image
7
8image = load_image("https://huggingface.co/lllyasviel/sd-controlnet-hed/resolve/main/images/bird.png")
9image = np.array(image)
10
11low_threshold = 100
12high_threshold = 200
13
14image = cv2.Canny(image, low_threshold, high_threshold)
15image = image[:, :, None]
16image = np.concatenate([image, image, image], axis=2)
17image = Image.fromarray(image)
18
19controlnet = ControlNetModel.from_pretrained(
20 "fusing/stable-diffusion-v1-5-controlnet-canny", torch_dtype=torch.float16
21)
22
23pipe = StableDiffusionControlNetPipeline.from_pretrained(
24 "runwayml/stable-diffusion-v1-5", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16
25)
26
27pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
28
29# Remove if you do not have xformers installed
30# see https://huggingface.co/docs/diffusers/v0.13.0/en/optimization/xformers#installing-xformers
31# for installation instructions
32pipe.enable_xformers_memory_efficient_attention()
33
34pipe.enable_model_cpu_offload()
35
36image = pipe("bird", image, num_inference_steps=20).images[0]
37
38image.save('images/bird_canny_out.png')

