许可协议: 其他
语言:
- 英文
任务标签: 文生图
标签:
- 稳定扩散
- 阿里妈妈创意
库名称: diffusers
更新动态
✨🎉 本模型已并入Diffusers库,现可便捷使用💡🎉✨
效果展示

身着白色夹克、黑色帽子与长裤的女子伫立田野,帽面标注"SD3"字样

穿白色运动鞋的人物手提印有"alibaba"字样的白色水桶
SD3控制网修复模型
基于sd3-medium微调的控制网修复模型具有以下优势:
- 依托SD3的16通道VAE和1024高分辨率生成能力,完美保持非修复区域(包括文字)的完整性
- 支持通过修复生成文字内容
- 在人像生成方面展现卓越的审美表现
与SDXL修复模型对比
从左至右:原始图像、掩膜图像、SDXL修复效果、本模型效果

公园长椅上的老虎

公园长椅上的小狗

身着蓝粉花卉连衣裙的年轻女性

田野中站立的白夹克女子,黑帽标注SD3字样

卧室墙壁悬挂的空调
Diffusers调用指南
源码安装并运行
pip uninstall diffusers
pip install git+https://github.com/huggingface/diffusers
import torch
from diffusers.utils import load_image, check_min_version
from diffusers.pipelines import StableDiffusion3ControlNetInpaintingPipeline
from diffusers.models.controlnet_sd3 import SD3ControlNetModel
controlnet = SD3ControlNetModel.from_pretrained(
"alimama-creative/SD3-Controlnet-Inpainting", use_safetensors=True, extra_conditioning_channels=1
)
pipe = StableDiffusion3ControlNetInpaintingPipeline.from_pretrained(
"stabilityai/stable-diffusion-3-medium-diffusers",
controlnet=controlnet,
torch_dtype=torch.float16,
)
pipe.text_encoder.to(torch.float16)
pipe.controlnet.to(torch.float16)
pipe.to("cuda")
image = load_image(
"https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog.png"
)
mask = load_image(
"https://huggingface.co/alimama-creative/SD3-Controlnet-Inpainting/resolve/main/images/dog_mask.png"
)
width = 1024
height = 1024
prompt = "一只猫与小狗并肩而坐"
generator = torch.Generator(device="cuda").manual_seed(24)
res_image = pipe(
negative_prompt="畸形、扭曲、残缺、解剖错误、多肢、缺肢、漂浮肢体、变异手足、断肢、突变、丑陋、模糊、截肢、NSFW内容",
prompt=prompt,
height=height,
width=width,
control_image=image,
control_mask=mask,
num_inference_steps=28,
generator=generator,
controlnet_conditioning_scale=0.95,
guidance_scale=7,
).images[0]
res_image.save(f"sd3.png")
训练细节
模型在1200万laion2B及内部源图像上训练2万步,分辨率1024x1024
- 混合精度: FP16
- 学习率: 1e-4
- 批大小: 192
- 时间步采样模式: 'logit_normal'
- 损失函数: 流匹配
局限性
因训练阶段仅使用1024*1024分辨率,该尺寸下推理效果最佳,其他尺寸表现欠佳。未来将启动多分辨率训练并开源新权重。
许可声明
本模型基于SD3微调,遵循原始SD3许可协议