T2iadapter Seg Sd14v1
T2I適配器是為穩定擴散模型提供額外條件控制的網絡架構,本檢查點專為穩定擴散1.4版本提供語義分割條件控制。
下載量 21
發布時間 : 7/14/2023
模型概述
該模型通過適配器架構為穩定擴散模型添加語義分割條件控制能力,能夠根據輸入的分割圖生成符合語義結構的圖像。
模型特點
語義分割控制
能夠根據輸入的語義分割圖精確控制生成圖像的佈局和結構
輕量級適配器
採用輕量級適配器架構,不改變原有穩定擴散模型參數
高兼容性
專為穩定擴散1.4版本設計,可與基礎模型無縫配合使用
模型能力
語義分割條件圖像生成
圖像佈局精確控制
文本到圖像轉換
使用案例
創意設計
概念藝術創作
設計師可以通過繪製語義分割草圖快速生成概念藝術圖像
快速可視化設計概念,提高創作效率
建築可視化
建築方案展示
根據建築平面分割圖生成逼真的建築外觀效果
快速生成多種風格建築效果圖
🚀 T2I Adapter - Segment
T2I Adapter是一個為Stable Diffusion提供額外條件控制的網絡。每個T2I檢查點以不同類型的條件作為輸入,並與特定的基礎Stable Diffusion檢查點一起使用。此檢查點為Stable Diffusion 1.4檢查點提供語義分割條件控制。
🚀 快速開始
依賴安裝
pip install diffusers transformers
運行代碼
import torch
from PIL import Image
import numpy as np
from transformers import AutoImageProcessor, UperNetForSemanticSegmentation
from diffusers import (
T2IAdapter,
StableDiffusionAdapterPipeline
)
ada_palette = np.asarray([
[0, 0, 0],
[120, 120, 120],
[180, 120, 120],
[6, 230, 230],
[80, 50, 50],
[4, 200, 3],
[120, 120, 80],
[140, 140, 140],
[204, 5, 255],
[230, 230, 230],
[4, 250, 7],
[224, 5, 255],
[235, 255, 7],
[150, 5, 61],
[120, 120, 70],
[8, 255, 51],
[255, 6, 82],
[143, 255, 140],
[204, 255, 4],
[255, 51, 7],
[204, 70, 3],
[0, 102, 200],
[61, 230, 250],
[255, 6, 51],
[11, 102, 255],
[255, 7, 71],
[255, 9, 224],
[9, 7, 230],
[220, 220, 220],
[255, 9, 92],
[112, 9, 255],
[8, 255, 214],
[7, 255, 224],
[255, 184, 6],
[10, 255, 71],
[255, 41, 10],
[7, 255, 255],
[224, 255, 8],
[102, 8, 255],
[255, 61, 6],
[255, 194, 7],
[255, 122, 8],
[0, 255, 20],
[255, 8, 41],
[255, 5, 153],
[6, 51, 255],
[235, 12, 255],
[160, 150, 20],
[0, 163, 255],
[140, 140, 140],
[250, 10, 15],
[20, 255, 0],
[31, 255, 0],
[255, 31, 0],
[255, 224, 0],
[153, 255, 0],
[0, 0, 255],
[255, 71, 0],
[0, 235, 255],
[0, 173, 255],
[31, 0, 255],
[11, 200, 200],
[255, 82, 0],
[0, 255, 245],
[0, 61, 255],
[0, 255, 112],
[0, 255, 133],
[255, 0, 0],
[255, 163, 0],
[255, 102, 0],
[194, 255, 0],
[0, 143, 255],
[51, 255, 0],
[0, 82, 255],
[0, 255, 41],
[0, 255, 173],
[10, 0, 255],
[173, 255, 0],
[0, 255, 153],
[255, 92, 0],
[255, 0, 255],
[255, 0, 245],
[255, 0, 102],
[255, 173, 0],
[255, 0, 20],
[255, 184, 184],
[0, 31, 255],
[0, 255, 61],
[0, 71, 255],
[255, 0, 204],
[0, 255, 194],
[0, 255, 82],
[0, 10, 255],
[0, 112, 255],
[51, 0, 255],
[0, 194, 255],
[0, 122, 255],
[0, 255, 163],
[255, 153, 0],
[0, 255, 10],
[255, 112, 0],
[143, 255, 0],
[82, 0, 255],
[163, 255, 0],
[255, 235, 0],
[8, 184, 170],
[133, 0, 255],
[0, 255, 92],
[184, 0, 255],
[255, 0, 31],
[0, 184, 255],
[0, 214, 255],
[255, 0, 112],
[92, 255, 0],
[0, 224, 255],
[112, 224, 255],
[70, 184, 160],
[163, 0, 255],
[153, 0, 255],
[71, 255, 0],
[255, 0, 163],
[255, 204, 0],
[255, 0, 143],
[0, 255, 235],
[133, 255, 0],
[255, 0, 235],
[245, 0, 255],
[255, 0, 122],
[255, 245, 0],
[10, 190, 212],
[214, 255, 0],
[0, 204, 255],
[20, 0, 255],
[255, 255, 0],
[0, 153, 255],
[0, 41, 255],
[0, 255, 204],
[41, 0, 255],
[41, 255, 0],
[173, 0, 255],
[0, 245, 255],
[71, 0, 255],
[122, 0, 255],
[0, 255, 184],
[0, 92, 255],
[184, 255, 0],
[0, 133, 255],
[255, 214, 0],
[25, 194, 194],
[102, 255, 0],
[92, 0, 255],
])
image_processor = AutoImageProcessor.from_pretrained("openmmlab/upernet-convnext-small")
image_segmentor = UperNetForSemanticSegmentation.from_pretrained("openmmlab/upernet-convnext-small")
checkpoint = "lllyasviel/control_v11p_sd15_seg"
image = Image.open('./images/seg_input.jpeg')
pixel_values = image_processor(image, return_tensors="pt").pixel_values
with torch.no_grad():
outputs = image_segmentor(pixel_values)
seg = image_processor.post_process_semantic_segmentation(outputs, target_sizes=[image.size[::-1]])[0]
color_seg = np.zeros((seg.shape[0], seg.shape[1], 3), dtype=np.uint8) # height, width, 3
for label, color in enumerate(ada_palette):
color_seg[seg == label, :] = color
color_seg = color_seg.astype(np.uint8)
control_image = Image.fromarray(color_seg)
control_image.save("./images/segment_image.png")
adapter = T2IAdapter.from_pretrained("TencentARC/t2iadapter_seg_sd14v1", torch_dtype=torch.float16)
pipe = StableDiffusionAdapterPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4", adapter=adapter, safety_checker=None, torch_dtype=torch.float16, variant="fp16"
)
pipe.to('cuda')
generator = torch.Generator().manual_seed(0)
sketch_image_out = pipe(prompt="motorcycles driving", image=control_image, generator=generator).images[0]
sketch_image_out.save('./images/seg_image_out.png')
✨ 主要特性
- 為Stable Diffusion提供額外的條件控制,增強圖像生成的可控性。
- 不同的檢查點支持不同類型的條件輸入,適用於多樣化的圖像生成場景。
📚 詳細文檔
模型詳情
屬性 | 詳情 |
---|---|
開發者 | 《T2I-Adapter: Learning Adapters to Dig out More Controllable Ability for Text-to-Image Diffusion Models》 |
模型類型 | 基於擴散模型的文本到圖像生成模型 |
語言 | 英文 |
許可證 | Apache 2.0 |
更多信息資源 | GitHub倉庫,論文 |
引用方式 | @misc{ |
檢查點
模型名稱 | 控制圖像概述 | 控制圖像示例 | 生成圖像示例 |
---|---|---|---|
TencentARC/t2iadapter_color_sd14v1 使用空間顏色調色板訓練 |
帶有8x8顏色調色板的圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_canny_sd14v1 使用Canny邊緣檢測訓練 |
黑色背景上帶有白色邊緣的單色圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_sketch_sd14v1 使用PidiNet邊緣檢測訓練 |
黑色背景上帶有白色輪廓的手繪單色圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_depth_sd14v1 使用Midas深度估計訓練 |
黑色代表深區域,白色代表淺區域的灰度圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_openpose_sd14v1 使用OpenPose骨骼圖像訓練 |
OpenPose骨骼圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_keypose_sd14v1 使用mmpose骨架圖像訓練 |
mmpose骨架圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_seg_sd14v1 使用語義分割訓練 |
自定義分割協議圖像。 | ![]() |
![]() |
TencentARC/t2iadapter_canny_sd15v2 | |||
TencentARC/t2iadapter_depth_sd15v2 | |||
TencentARC/t2iadapter_sketch_sd15v2 | |||
TencentARC/t2iadapter_zoedepth_sd15v1 |
💻 使用示例
基礎用法
上述快速開始部分的代碼展示瞭如何使用T2I Adapter進行語義分割條件下的圖像生成,包括依賴安裝、模型加載、圖像分割處理和圖像生成等步驟。
高級用法
你可以根據具體需求調整代碼中的參數,如修改提示詞prompt
、隨機種子seed
等,以生成不同風格和內容的圖像。同時,嘗試使用不同的檢查點和條件輸入,探索更多的圖像生成可能性。
📄 許可證
本項目採用Apache 2.0許可證。詳細信息請參考許可證文件。
Stable Diffusion V1 5
Openrail
穩定擴散是一種潛在的文本到圖像擴散模型,能夠根據任何文本輸入生成逼真的圖像。
圖像生成
S
stable-diffusion-v1-5
3.7M
518
Stable Diffusion Inpainting
Openrail
基於穩定擴散的文本到圖像生成模型,具備圖像修復能力
圖像生成
S
stable-diffusion-v1-5
3.3M
56
Stable Diffusion Xl Base 1.0
SDXL 1.0是基於擴散的文本生成圖像模型,採用專家集成的潛在擴散流程,支持高分辨率圖像生成
圖像生成
S
stabilityai
2.4M
6,545
Stable Diffusion V1 4
Openrail
穩定擴散是一種潛在文本到圖像擴散模型,能夠根據任意文本輸入生成逼真圖像。
圖像生成
S
CompVis
1.7M
6,778
Stable Diffusion Xl Refiner 1.0
SD-XL 1.0優化器模型是Stability AI開發的圖像生成模型,專為提升SDXL基礎模型生成的圖像質量而設計,特別擅長最終去噪步驟處理。
圖像生成
S
stabilityai
1.1M
1,882
Stable Diffusion 2 1
基於擴散的文本生成圖像模型,支持通過文本提示生成和修改圖像
圖像生成
S
stabilityai
948.75k
3,966
Stable Diffusion Xl 1.0 Inpainting 0.1
基於Stable Diffusion XL的潛在文本到圖像擴散模型,具備通過遮罩進行圖像修復的功能
圖像生成
S
diffusers
673.14k
334
Stable Diffusion 2 Base
基於擴散的文生圖模型,可根據文本提示生成高質量圖像
圖像生成
S
stabilityai
613.60k
349
Playground V2.5 1024px Aesthetic
其他
開源文生圖模型,能生成1024x1024分辨率及多種縱橫比的美學圖像,在美學質量上處於開源領域領先地位。
圖像生成
P
playgroundai
554.94k
723
Sd Turbo
SD-Turbo是一款高速文本生成圖像模型,僅需單次網絡推理即可根據文本提示生成逼真圖像。該模型作為研究原型發佈,旨在探索小型蒸餾文本生成圖像模型。
圖像生成
S
stabilityai
502.82k
380
精選推薦AI模型
Llama 3 Typhoon V1.5x 8b Instruct
專為泰語設計的80億參數指令模型,性能媲美GPT-3.5-turbo,優化了應用場景、檢索增強生成、受限生成和推理任務
大型語言模型
Transformers 支持多種語言

L
scb10x
3,269
16
Cadet Tiny
Openrail
Cadet-Tiny是一個基於SODA數據集訓練的超小型對話模型,專為邊緣設備推理設計,體積僅為Cosmo-3B模型的2%左右。
對話系統
Transformers 英語

C
ToddGoldfarb
2,691
6
Roberta Base Chinese Extractive Qa
基於RoBERTa架構的中文抽取式問答模型,適用於從給定文本中提取答案的任務。
問答系統 中文
R
uer
2,694
98