🚀 软边缘控制网络(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) |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |
 |