🚀 Controlnet - 深度版本
ControlNet是一種神經網絡結構,通過添加額外條件來控制擴散模型。此檢查點對應於基於深度估計的ControlNet,可與Stable Diffusion結合使用。

✨ 主要特性
- 能夠為預訓練的大型擴散模型添加額外輸入條件,支持如邊緣圖、分割圖、關鍵點等多種條件輸入。
- 以端到端的方式學習特定任務條件,即使訓練數據集較小(< 50k),學習過程也很穩健。
- 訓練速度與微調擴散模型相當,可在個人設備上進行訓練,也能在強大的計算集群上處理大量數據。
📦 安裝指南
若要使用該模型,需安裝diffusers
及相關依賴包:
$ pip install diffusers transformers accelerate
💻 使用示例
基礎用法
from transformers import pipeline
from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
from PIL import Image
import numpy as np
import torch
from diffusers.utils import load_image
depth_estimator = pipeline('depth-estimation')
image = load_image("https://huggingface.co/lllyasviel/sd-controlnet-depth/resolve/main/images/stormtrooper.png")
image = depth_estimator(image)['depth']
image = np.array(image)
image = image[:, :, None]
image = np.concatenate([image, image, image], axis=2)
image = Image.fromarray(image)
controlnet = ControlNetModel.from_pretrained(
"lllyasviel/sd-controlnet-depth", torch_dtype=torch.float16
)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
"runwayml/stable-diffusion-v1-5", controlnet=controlnet, safety_checker=None, torch_dtype=torch.float16
)
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
pipe.enable_xformers_memory_efficient_attention()
pipe.enable_model_cpu_offload()
image = pipe("Stormtrooper's lecture", image, num_inference_steps=20).images[0]
image.save('./images/stormtrooper_depth_out.png')



📚 詳細文檔
模型詳情
發佈的檢查點
作者發佈了8種不同的檢查點,每種都基於 Stable Diffusion v1 - 5 在不同類型的條件下進行訓練:
訓練情況
深度模型在300萬個深度圖像 - 標題對上進行訓練。深度圖像使用Midas生成。該模型以Stable Diffusion 1.5為基礎模型,使用Nvidia A100 80G GPU訓練了500小時。
博客文章
如需更多信息,請查看 ControlNet官方博客文章。
📄 許可證
本模型採用 The CreativeML OpenRAIL M license。