Downloads · 30 days
3
4% of all-time downloads
alibaba-pai/pai-diffusion-general-large-zh-controlnet-canny
pai-diffusion-general-large-zh-controlnet-canny is a text-to-image model from alibaba-pai. Use it when you need an image from a text prompt. It is set up for diffusers. The card lists the license as apache-2.0.
我们开源了适配模型 alibaba-pai/pai-diffusion-general-large-zh 的 ControlNet,输入图像的 Canny 特征,进行可控的生成。
Downloads · 30 days
3
4% of all-time downloads
All-time downloads
75
Public
Repo size
1.4 GB
Likes
0
Public
Click a slice to open those files.
.bin1.4 GB · 100%
From the Hugging Face model README
我们开源了适配模型 alibaba-pai/pai-diffusion-general-large-zh 的 ControlNet,输入图像的 Canny 特征,进行可控的生成。
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel
from PIL import Image
import numpy as np
import cv2
def to_canny(image):
low_threshold = 100
high_threshold = 200
image = np.array(image)
image = cv2.Canny(image, low_threshold, high_threshold)
image = image[:, :, None]
image = np.concatenate([image, image, image], axis=2)
image = Image.fromarray(image)
return image
controlnet_id = "alibaba-pai/pai-diffusion-general-large-zh-controlnet-canny"
controlnet = ControlNetModel.from_pretrained(controlnet_id)
model_id = "alibaba-pai/pai-diffusion-general-large-zh"
pipe = StableDiffusionControlNetPipeline.from_pretrained(model_id, controlnet=controlnet)
pipe = pipe.to("cuda")
image = Image.open("bird.png")
image_canny = to_canny(image)
prompt = "白色羽毛的小鸟"
image = pipe(prompt, image_canny).images[0]
image.save("result.png")