模型简介
模型特点
模型能力
使用案例
🚀 Controlnet - v1.1 - Tile版本
Controlnet v1.1是一种神经网络结构,可通过添加额外条件来控制扩散模型。本版本基于平铺图像进行条件控制,可与Stable Diffusion结合使用,实现图像生成等功能。
🚀 快速开始
ControlNet v1.1由Lvmin Zhang在lllyasviel/ControlNet-v1-1中发布。此检查点是将原始检查点转换为diffusers
格式,可与Stable Diffusion(如runwayml/stable-diffusion-v1-5)结合使用。
更多详细信息,请查看🧨 Diffusers文档。
ControlNet是一种通过添加额外条件来控制扩散模型的神经网络结构。
此检查点对应于基于平铺图像进行条件控制的ControlNet。从概念上讲,它类似于超分辨率模型,但用途不仅限于此,也可以生成与输入(条件)图像相同大小的细节。
此模型由 takuma104 贡献
✨ 主要特性
- 条件控制:通过添加额外条件,灵活控制扩散模型的生成结果。
- 结合Stable Diffusion:可与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="best quality",
negative_prompt="blur, lowres, bad anatomy, bad hands, cropped, worst quality",
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')
📚 详细文档
模型详情
属性 | 详情 |
---|---|
开发者 | Lvmin Zhang, Maneesh Agrawala |
模型类型 | 基于扩散的文本到图像生成模型 |
语言 | 英文 |
许可证 | CreativeML OpenRAIL M许可证 是一种 Open RAIL M许可证,改编自 BigScience 和 RAIL Initiative 在负责任的人工智能许可领域的合作成果。有关我们许可证所基于的 BLOOM Open RAIL许可证的文章 也可供参考。 |
更多信息资源 | GitHub仓库,论文 |
引用方式 | @misc{zhang2023adding, title={Adding Conditional Control to Text-to-Image Diffusion Models}, author={Lvmin Zhang and Maneesh Agrawala}, year={2023}, eprint={2302.05543}, archivePrefix={arXiv}, primaryClass={cs.CV} } |
模型介绍
Controlnet由Lvmin Zhang和Maneesh Agrawala在 Adding Conditional Control to Text-to-Image Diffusion Models 中提出。
摘要如下:
我们提出了一种神经网络结构ControlNet,用于控制预训练的大型扩散模型,以支持额外的输入条件。ControlNet以端到端的方式学习特定任务的条件,即使训练数据集较小(< 50k),学习过程也很稳健。此外,训练ControlNet的速度与微调扩散模型的速度一样快,并且可以在个人设备上进行训练。或者,如果有强大的计算集群,模型可以扩展到处理大量(数百万到数十亿)的数据。我们报告称,像Stable Diffusion这样的大型扩散模型可以通过ControlNet进行增强,以支持边缘图、分割图、关键点等条件输入。这可能会丰富控制大型扩散模型的方法,并进一步促进相关应用的发展。
其他已发布的v1-1检查点
作者发布了14种不同的检查点,每种都基于Stable Diffusion v1-5在不同类型的条件下进行训练:
模型名称 | 控制图像概述 | 控制图像示例 | 生成图像示例 |
---|---|---|---|
lllyasviel/control_v11p_sd15_canny 基于Canny边缘检测训练 |
黑色背景上带有白色边缘的单色图像。 | ![]() |
![]() |
lllyasviel/control_v11e_sd15_ip2p 基于像素到像素指令训练 |
无特定条件。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_inpaint 基于图像修复训练 |
无特定条件。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_mlsd 基于多级线段检测训练 |
带有注释线段的图像。 | ![]() |
![]() |
lllyasviel/control_v11f1p_sd15_depth 基于深度估计训练 |
带有深度信息的图像,通常表示为灰度图像。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_normalbae 基于表面法线估计训练 |
带有表面法线信息的图像,通常表示为彩色编码图像。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_seg 基于图像分割训练 |
带有分割区域的图像,通常表示为彩色编码图像。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_lineart 基于线稿生成训练 |
带有线稿的图像,通常是白色背景上的黑色线条。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15s2_lineart_anime 基于动漫线稿生成训练 |
带有动漫风格线稿的图像。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_openpose 基于人体姿态估计训练 |
带有人体姿态的图像,通常表示为一组关键点或骨架。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_scribble 基于涂鸦式图像生成训练 |
带有涂鸦的图像,通常是随机或用户绘制的笔触。 | ![]() |
![]() |
lllyasviel/control_v11p_sd15_softedge 基于软边缘图像生成训练 |
带有软边缘的图像,通常用于创建更具绘画感或艺术效果的图像。 | ![]() |
![]() |
lllyasviel/control_v11e_sd15_shuffle 基于图像打乱训练 |
带有打乱的补丁或区域的图像。 | ![]() |
![]() |
lllyasviel/control_v11f1e_sd15_tile 基于图像平铺训练 |
用于绘制细节的基础图像。 | ![]() |
![]() |
更多信息
如需更多信息,请查看 Diffusers ControlNet博客文章 和 官方文档。
📄 许可证
本模型使用 CreativeML OpenRAIL M许可证。

