许可证:apache-2.0
基础模型:stabilityai/stable-diffusion-xl-base-1.0
标签:
- stable-diffusion-xl
- stable-diffusion-xl-diffusers
- text-to-image
- diffusers
- controlnet
推理:false
语言:
- en
任务标签:text-to-image
Softedge ControlNet
EcomXL 包含一系列针对电商场景优化的文本到图像扩散模型,基于 Stable Diffusion XL 开发。
ControlNet 权重基于 stable-diffusion-xl-base-1.0 微调而成。
该模型在 SDXL 及基于 SDXL 的社区模型中表现良好。
训练数据涵盖通用数据和淘宝电商数据,因此在通用场景和电商场景中均具备优秀能力。
示例
以下案例使用 AUTOMATIC1111/stable-diffusion-webui 生成。
softedge |
weight-0.6 |
weight-0.8 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
Diffusers 使用指南
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="黄昏草原上的瓶子,置于地面,几株高草矗立在草丛中,日落,"
negative_prompt = "低质量,劣质,草图"
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 权重(controlnet_condition_scale)在 0.6 至 0.8 范围内时,模型表现最佳。
训练细节
混合精度:FP16
学习率:1e-5
批量大小:1024
噪声偏移:0.05
训练步数:37k 步
训练数据包含 1200 万张来自 laion2B 及内部来源的美学评分 6+ 图像,以及 300 万张淘宝电商图像。训练时随机选用 pidinet、hed、pidisafe 和 hedsafe 作为软边缘预处理器(均受 Automatic&&Mikubill 官方支持)。模型在权重 0.6~0.8 区间表现优异。