🚀 SDXL-controlnet: Canny
SDXL-controlnet: Canny是基於Canny條件,在stabilityai/stable-diffusion-xl-base-1.0上訓練得到的ControlNet權重。以下是一些示例圖片:
示例圖片
提示詞 |
圖片 |
a couple watching a romantic sunset, 4k photo |
 |
ultrarealistic shot of a furry blue bird |
 |
a woman, close up, detailed, beautiful, street photography, photorealistic, detailed, Kodak ektar 100, natural, candid shot |
 |
Cinematic, neoclassical table in the living room, cinematic, contour, lighting, highly detailed, winter, golden hour |
 |
a tornado hitting grass field, 1980's film grain. overcast, muted colors. |
 |
🚀 快速開始
安裝依賴庫
首先,你需要安裝以下庫:
pip install accelerate transformers safetensors opencv-python diffusers
運行示例代碼
安裝完成後,就可以運行以下代碼:
from diffusers import ControlNetModel, StableDiffusionXLControlNetPipeline, AutoencoderKL
from diffusers.utils import load_image
from PIL import Image
import torch
import numpy as np
import cv2
prompt = "aerial view, a futuristic research complex in a bright foggy jungle, hard lighting"
negative_prompt = 'low quality, bad quality, sketches'
image = load_image("https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png")
controlnet_conditioning_scale = 0.5
controlnet = ControlNetModel.from_pretrained(
"diffusers/controlnet-canny-sdxl-1.0",
torch_dtype=torch.float16
)
vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
pipe = StableDiffusionXLControlNetPipeline.from_pretrained(
"stabilityai/stable-diffusion-xl-base-1.0",
controlnet=controlnet,
vae=vae,
torch_dtype=torch.float16,
)
pipe.enable_model_cpu_offload()
image = np.array(image)
image = cv2.Canny(image, 100, 200)
image = image[:, :, None]
image = np.concatenate([image, image, image], axis=2)
image = Image.fromarray(image)
images = pipe(
prompt, negative_prompt=negative_prompt, image=image, controlnet_conditioning_scale=controlnet_conditioning_scale,
).images
images[0].save(f"hug_lab.png")

更多詳細信息,請查看StableDiffusionXLControlNetPipeline
的官方文檔。
🔧 技術細節
訓練腳本
我們的訓練腳本基於此處提供的官方訓練腳本構建。
訓練數據
該檢查點首先在調整為最大最小尺寸為384的laion 6a數據集上訓練20,000步,然後在調整為最大最小尺寸為1024並過濾為僅包含最小尺寸為1024的圖像的laion 6a數據集上再訓練20,000步。我們發現進一步的高分辨率微調對於圖像質量是必要的。
計算資源
使用一臺配備8張A100顯卡的機器。
批量大小
採用數據並行,單GPU批量大小為8,總批量大小為64。
超參數
恆定學習率為1e-4,按批量大小縮放後總學習率為64e-4。
混合精度
採用fp16。
📄 許可證
本項目採用OpenRail++許可證。
信息表格
屬性 |
詳情 |
模型類型 |
SDXL-controlnet: Canny |
基礎模型 |
runwayml/stable-diffusion-v1-5 |
訓練數據 |
先在調整為最大最小尺寸為384的laion 6a數據集上訓練20,000步,再在調整為最大最小尺寸為1024並過濾為僅包含最小尺寸為1024的圖像的laion 6a數據集上訓練20,000步 |
計算資源 |
一臺配備8張A100顯卡的機器 |
批量大小 |
單GPU批量大小為8,總批量大小為64 |
超參數 |
恆定學習率為1e-4,按批量大小縮放後總學習率為64e-4 |
混合精度 |
fp16 |
許可證 |
OpenRail++ |