许可证:Apache-2.0
基础模型:stabilityai/stable-diffusion-xl-base-1.0
标签:
- 艺术
- t2i-adapter
- 图像到图像
- stable-diffusion-xl-diffusers
- stable-diffusion-xl
T2I-Adapter-SDXL - 草图版
T2I Adapter 是一种为稳定扩散模型提供额外条件控制的网络。每个T2I检查点接收不同类型的条件输入,并与特定的基础稳定扩散检查点配合使用。
本检查点专为StableDiffusionXL模型提供草图条件控制功能。该项目由腾讯ARC与Hugging Face合作开发。
模型详情
-
开发者: T2I-Adapter: 通过适配器挖掘文本到图像扩散模型的更多可控能力
-
模型类型: 基于扩散的文本到图像生成模型
-
支持语言: 英语
-
许可证: Apache 2.0
-
更多资源: GitHub仓库、论文
-
模型复杂度对比:
| | SD-V1.4/1.5 | SD-XL | T2I-Adapter | T2I-Adapter-SDXL |
| --- | --- |--- |--- |--- |
| 参数量 | 860M | 2.6B |77 M | 77/79 M |
-
引用格式:
@misc{
title={T2I-Adapter: 通过适配器挖掘文本到图像扩散模型的更多可控能力},
author={牟冲, 王新涛, 谢良彬, 吴彦泽, 张健, 齐中阳, 单瀛, 邱晓虎},
year={2023},
eprint={2302.08453},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
检查点概览
在线演示:
在Doodly Space中尝试用自己的手绘草图生成图像!

使用示例
首先安装依赖:
pip install -U git+https://github.com/huggingface/diffusers.git
pip install -U controlnet_aux==0.0.7
pip install transformers accelerate safetensors
- 将图像预处理为对应的控制图像格式
- 将控制图像和提示词传入
StableDiffusionXLAdapterPipeline
以下是使用线稿适配器的简单示例:
from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler, AutoencoderKL
from diffusers.utils import load_image, make_image_grid
from controlnet_aux.pidi import PidiNetDetector
import torch
adapter = T2IAdapter.from_pretrained(
"TencentARC/t2i-adapter-sketch-sdxl-1.0", torch_dtype=torch.float16, varient="fp16"
).to("cuda")
model_id = 'stabilityai/stable-diffusion-xl-base-1.0'
euler_a = EulerAncestralDiscreteScheduler.from_pretrained(model_id, subfolder="scheduler")
vae=AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
model_id, vae=vae, adapter=adapter, scheduler=euler_a, torch_dtype=torch.float16, variant="fp16",
).to("cuda")
pipe.enable_xformers_memory_efficient_attention()
pidinet = PidiNetDetector.from_pretrained("lllyasviel/Annotators").to("cuda")
url = "https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_sketch.png"
image = load_image(url)
image = pidinet(
image, detect_resolution=1024, image_resolution=1024, apply_filter=True
)

prompt = "机器人,背景是富士山,4K高清照片,细节丰富"
negative_prompt = "多余数字,缺少数字,裁剪,低质量,劣质,故障,变形,丑陋,畸形"
gen_images = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
image=image,
num_inference_steps=30,
adapter_conditioning_scale=0.9,
guidance_scale=7.5,
).images[0]
gen_images.save('out_sketch.png')

训练过程
我们的训练脚本基于官方提供的训练方案开发。
模型在LAION-Aesthetics V2的300万张高清图文对上训练,参数如下:
- 训练步数:20000
- 批量大小:单GPU批量16,总批量256(数据并行)
- 学习率:恒定1e-5
- 混合精度:fp16