Views
No views yet
diffusers format.
It can be used in combination with Stable Diffusion, such as runwayml/stable-diffusion-v1-5.
$ pip install opencv-contrib-pythondiffusers and related packages:$ pip install diffusers transformers accelerate1import torch
2import os
3from huggingface_hub import HfApi
4from pathlib import Path
5from diffusers.utils import load_image
6import numpy as np
7import cv2
8from PIL import Image
9
10from diffusers import (
11 ControlNetModel,
12 StableDiffusionControlNetPipeline,
13 UniPCMultistepScheduler,
14)
15
16checkpoint = "lllyasviel/control_v11p_sd15_canny"
17
18image = load_image(
19 "https://huggingface.co/lllyasviel/control_v11p_sd15_canny/resolve/main/images/input.png"
20)
21
22image = np.array(image)
23
24low_threshold = 100
25high_threshold = 200
26
27image = cv2.Canny(image, low_threshold, high_threshold)
28image = image[:, :, None]
29image = np.concatenate([image, image, image], axis=2)
30control_image = Image.fromarray(image)
31
32control_image.save("./images/control.png")
33
34controlnet = ControlNetModel.from_pretrained(checkpoint, torch_dtype=torch.float16)
35pipe = StableDiffusionControlNetPipeline.from_pretrained(
36 "runwayml/stable-diffusion-v1-5", controlnet=controlnet, torch_dtype=torch.float16
37)
38
39pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
40pipe.enable_model_cpu_offload()
41
42generator = torch.manual_seed(33)
43image = pipe("a blue paradise bird in the jungle", num_inference_steps=20, generator=generator, image=control_image).images[0]
44
45image.save('images/image_out.png')


| Model Name | Control Image Overview | Condition Image | Control Image Example | Generated Image Example |
|---|---|---|---|---|
| lllyasviel/control_v11p_sd15_canny | Trained with canny edge detection | A monochrome image with white edges on a black background. | ||
| lllyasviel/control_v11e_sd15_ip2p | Trained with pixel to pixel instruction | No condition . | ||
| lllyasviel/control_v11p_sd15_inpaint | Trained with image inpainting | No condition. | ||
| lllyasviel/control_v11p_sd15_mlsd | Trained with multi-level line segment detection | An image with annotated line segments. | ||
| lllyasviel/control_v11f1p_sd15_depth | Trained with depth estimation | An image with depth information, usually represented as a grayscale image. | ||
| lllyasviel/control_v11p_sd15_normalbae | Trained with surface normal estimation | An image with surface normal information, usually represented as a color-coded image. | ||
| lllyasviel/control_v11p_sd15_seg | Trained with image segmentation | An image with segmented regions, usually represented as a color-coded image. | ||
| lllyasviel/control_v11p_sd15_lineart | Trained with line art generation | An image with line art, usually black lines on a white background. | ||
| lllyasviel/control_v11p_sd15s2_lineart_anime | Trained with anime line art generation | An image with anime-style line art. | ||
| lllyasviel/control_v11p_sd15_openpose | Trained with human pose estimation | An image with human poses, usually represented as a set of keypoints or skeletons. | ||
| lllyasviel/control_v11p_sd15_scribble | Trained with scribble-based image generation | An image with scribbles, usually random or user-drawn strokes. | ||
| lllyasviel/control_v11p_sd15_softedge | Trained with soft edge image generation | An image with soft edges, usually to create a more painterly or artistic effect. | ||
| lllyasviel/control_v11e_sd15_shuffle | Trained with image shuffling | An image with shuffled patches or regions. | ||
| lllyasviel/control_v11f1e_sd15_tile | Trained with image tiling | A blurry image or part of an image . |