许可证:openrail
基础模型:runwayml/stable-diffusion-v1-5
标签:
- 艺术
- controlnet
- stable-diffusion
- controlnet-v1-1
- 图像到图像
复制来源:ControlNet-1-1-preview/control_v11f1e_sd15_tile
ControlNet - v1.1 - 分块版本
ControlNet v1.1 由 Lvmin Zhang 在 lllyasviel/ControlNet-v1-1 发布。
此检查点是将 原始检查点 转换为 diffusers
格式的版本。
它可以与 Stable Diffusion 结合使用,例如 runwayml/stable-diffusion-v1-5。
更多详情,请参阅 🧨 Diffusers 文档。
ControlNet 是一种通过添加额外条件来控制扩散模型的神经网络结构。

此检查点对应于基于 分块图像 的 ControlNet。从概念上讲,它类似于超分辨率模型,但其用途不仅限于此。它还可以生成与输入(条件)图像相同尺寸的细节。
此模型由 takuma104 贡献
模型详情
简介
ControlNet 由 Lvmin Zhang 和 Maneesh Agrawala 在 Adding Conditional Control to Text-to-Image Diffusion Models 中提出。
摘要如下:
我们提出了一种神经网络结构 ControlNet,用于通过添加额外的输入条件来控制预训练的大型扩散模型。
ControlNet 以端到端的方式学习任务特定条件,即使训练数据集较小(< 50k),学习也能保持稳健。
此外,训练 ControlNet 与微调扩散模型一样快速,并且可以在个人设备上进行训练。
或者,如果有强大的计算集群可用,模型可以扩展到大量(数百万到数十亿)数据。
我们报告称,像 Stable Diffusion 这样的大型扩散模型可以通过 ControlNet 增强,以支持边缘图、分割图、关键点等条件输入。
这可能会丰富控制大型扩散模型的方法,并进一步促进相关应用。
示例
建议将此检查点与 Stable Diffusion v1-5 结合使用,因为检查点已在其上训练。
实验上,该检查点也可以与其他扩散模型(如 dreamboothed stable diffusion)一起使用。
- 安装
diffusers
及相关包:
$ pip install diffusers transformers accelerate
- 运行代码:
import torch
from PIL import Image
from diffusers import ControlNetModel, DiffusionPipeline
from diffusers.utils import load_image
def resize_for_condition_image(input_image: Image, resolution: int):
input_image = input_image.convert("RGB")
W, H = input_image.size
k = float(resolution) / min(H, W)
H *= k
W *= k
H = int(round(H / 64.0)) * 64
W = int(round(W / 64.0)) * 64
img = input_image.resize((W, H), resample=Image.LANCZOS)
return img
controlnet = ControlNetModel.from_pretrained('lllyasviel/control_v11f1e_sd15_tile',
torch_dtype=torch.float16)
pipe = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5",
custom_pipeline="stable_diffusion_controlnet_img2img",
controlnet=controlnet,
torch_dtype=torch.float16).to('cuda')
pipe.enable_xformers_memory_efficient_attention()
source_image = load_image('https://huggingface.co/lllyasviel/control_v11f1e_sd15_tile/resolve/main/images/original.png')
condition_image = resize_for_condition_image(source_image, 1024)
image = pipe(prompt="最佳质量",
negative_prompt="模糊, 低分辨率, 解剖结构错误, 手部错误, 裁剪, 最差质量",
image=condition_image,
controlnet_conditioning_image=condition_image,
width=condition_image.size[0],
height=condition_image.size[1],
strength=1.0,
generator=torch.manual_seed(0),
num_inference_steps=32,
).images[0]
image.save('output.png')


其他发布的检查点 v1-1
作者发布了 14 个不同的检查点,每个检查点使用 Stable Diffusion v1-5 在不同类型的条件下训练: