🚀 T2I-Adapter-SDXL - Depth-Zoe
T2I-Adapter-SDXL - Depth-Zoe是一个用于文生图扩散模型的增强组件,它能为StableDiffusion模型提供额外的深度条件控制,让图像生成更加精准和可控。该项目由腾讯ARC实验室和Hugging Face合作完成,为图像生成领域带来了更多的可能性。
🚀 快速开始
要开始使用T2I-Adapter-SDXL - Depth-Zoe,首先需要安装所需的依赖项:
pip install -U git+https://github.com/huggingface/diffusers.git
pip install -U controlnet_aux==0.0.7 timm==0.6.12
pip install transformers accelerate safetensors
操作步骤如下:
- 首先将图像下载为合适的“控制图像”格式。
- 将“控制图像”和“提示词”传递给
StableDiffusionXLAdapterPipeline
。
✨ 主要特性
- 额外条件控制:T2I Adapter网络为StableDiffusion提供额外的条件控制,每个t2i检查点接受不同类型的条件作为输入,并与特定的基础StableDiffusion检查点一起使用。
- 深度条件支持:此检查点为StableDiffusionXL检查点提供深度条件控制。
- 多方合作成果:由腾讯ARC和Hugging Face合作开发。
💻 使用示例
基础用法
from diffusers import StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteScheduler, AutoencoderKL
from diffusers.utils import load_image, make_image_grid
from controlnet_aux import ZoeDetector
import torch
adapter = T2IAdapter.from_pretrained(
"TencentARC/t2i-adapter-depth-zoe-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()
zoe_depth = ZoeDetector.from_pretrained(
"valhalla/t2iadapter-aux-models", filename="zoed_nk.pth", model_type="zoedepth_nk"
).to("cuda")
高级用法
url = "https://huggingface.co/Adapter/t2iadapter/resolve/main/figs_SDXLV1.0/org_zeo.jpg"
image = load_image(url)
image = zoe_depth(image, gamma_corrected=True, detect_resolution=512, image_resolution=1024)
prompt = "A photo of a orchid, 4k photo, highly detailed"
negative_prompt = "anime, cartoon, graphic, text, painting, crayon, graphite, abstract, glitch, deformed, mutated, ugly, disfigured"
gen_images = pipe(
prompt=prompt,
negative_prompt=negative_prompt,
image=image,
num_inference_steps=30,
adapter_conditioning_scale=1,
guidance_scale=7.5,
).images[0]
gen_images.save('out_zoe.png')
📚 详细文档
模型详情
- 开发者:T2I-Adapter: Learning Adapters to Dig out More Controllable Ability for Text-to-Image Diffusion Models
- 模型类型:基于扩散的文生图生成模型
- 语言:英语
- 许可证:Apache 2.0
- 更多信息资源:GitHub仓库,论文。
- 模型复杂度:
| | SD-V1.4/1.5 | SD-XL | T2I-Adapter | T2I-Adapter-SDXL |
| --- | --- | --- | --- | --- |
| 参数 | 8.6亿 | 26亿 | 7700万 | 7700万/7900万 |
- 引用格式:
@misc{
title={T2I-Adapter: Learning Adapters to Dig out More Controllable Ability for Text-to-Image Diffusion Models},
author={Chong Mou, Xintao Wang, Liangbin Xie, Yanze Wu, Jian Zhang, Zhongang Qi, Ying Shan, Xiaohu Qie},
year={2023},
eprint={2302.08453},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
检查点
训练信息
我们的训练脚本基于官方提供的训练脚本构建,可参考此处。
该模型在LAION-Aesthetics V2的300万高分辨率图像-文本对上进行训练,具体参数如下:
- 训练步数:25000
- 批量大小:数据并行,单GPU批量大小为
16
,总批量大小为256
。
- 学习率:恒定学习率
1e-5
。
- 混合精度:fp16
📄 许可证
本项目采用Apache 2.0许可证。