🚀 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許可證。