🚀 軟邊緣控制網絡(Softedge ControlNet)
EcomXL 包含一系列為電商場景優化的文本到圖像擴散模型,它基於 Stable Diffusion XL 開發。控制網絡的權重是在 stable-diffusion-xl-base-1.0 的基礎上進行微調的。它在 SDXL 以及基於 SDXL 的社區模型上都能有出色的表現。該模型在通用數據和淘寶電商數據上進行訓練,在通用場景和電商場景中都具備良好的能力。
✨ 主要特性
- 基於 Stable Diffusion XL 開發,適用於電商場景。
- 控制網絡權重經過微調,在 SDXL 及相關社區模型上表現良好。
- 在通用數據和淘寶電商數據上訓練,兼顧通用和電商場景。
💻 使用示例
基礎用法
from diffusers import (
ControlNetModel,
StableDiffusionXLControlNetPipeline,
DPMSolverMultistepScheduler,
AutoencoderKL
)
from diffusers.utils import load_image
from controlnet_aux import PidiNetDetector, HEDdetector
import torch
from PIL import Image
controlnet = ControlNetModel.from_pretrained(
"alimama-creative/EcomXL_controlnet_softedge", torch_dtype=torch.float16, use_safetensors=True
)
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.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
pipe.to(device="cuda", dtype=torch.float16)
pipe.enable_vae_slicing()
image = load_image(
"https://huggingface.co/alimama-creative/EcomXL_controlnet_softedge/resolve/main/images/1_1.png"
)
edge_processor = PidiNetDetector.from_pretrained('lllyasviel/Annotators')
edge_image = edge_processor(image, safe=False)
prompt="a bottle on the Twilight Grassland, Sitting on the ground, a couple of tall grass sitting in a field of tall grass, sunset,"
negative_prompt = "low quality, bad quality, sketches"
output = pipe(
prompt,
negative_prompt=negative_prompt,
image=edge_image,
num_inference_steps=25,
controlnet_conditioning_scale=0.6,
guidance_scale=7,
width=1024,
height=1024,
).images[0]
output.save(f'test_edge.png')
高級用法
該模型在控制網絡權重(controlnet_condition_scale)處於 0.6 到 0.8 的範圍內時表現良好。可以根據實際需求調整該權重值以獲得更好的效果。
🔧 技術細節
- 混合精度:FP16
- 學習率:1e-5
- 批量大小:1024
- 噪聲偏移:0.05
- 訓練步數:37k
訓練數據包括 1200 萬條 laion2B 和內部來源的美學評分為 6 分以上的圖像,以及 300 萬條淘寶電商圖像。訓練期間的軟邊緣預處理器從 Automatic&&Mikubill 官方支持的 pidinet、hed、pidisafe 和 hedsafe 中隨機選擇。當權重在 0.6~0.8 之間時,模型表現良好。
📄 許可證
本項目採用 Apache-2.0 許可證。
示例展示
這些案例是使用 AUTOMATIC1111/stable-diffusion-webui 生成的。
軟邊緣(softedge) |
權重 0.6(weight-0.6) |
權重 0.8(weight-0.8) |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |