SDXL-Turbo 是一款快速生成式文本到图像模型,仅需一次网络推理即可根据文本提示合成逼真图像。
实时演示可在此处查看:http://clipdrop.co/stable-diffusion-turbo
SDXL-Turbo 是 SDXL 1.0 的蒸馏版本,专为实时合成而训练。 SDXL-Turbo 基于一种名为对抗扩散蒸馏(ADD)的新型训练方法(详见技术报告),该方法能够以 1 到 4 步采样生成高质量的大规模基础图像扩散模型。 此方法利用分数蒸馏技术,将大规模现成图像扩散模型作为教师信号,并结合对抗损失,确保即使在仅一到两步的低采样步数下也能实现高图像保真度。
出于研究目的,我们推荐使用 generative-models GitHub 仓库(https://github.com/Stability-AI/generative-models),
该仓库实现了最流行的扩散框架(包括训练和推理)。
上面的图表评估了用户对 SDXL-Turbo 相较于其他单步和多步模型的偏好。
在图像质量和提示遵循度方面,人类评估者更倾向于单步运行的 SDXL-Turbo,而非四步(或更少步数)运行的 LCM-XL。
此外,我们发现将 SDXL-Turbo 的采样步数增加到四时,性能会进一步提升。
有关用户研究的详细信息,请参考研究论文。
本模型仅用于研究目的。可能的研究领域和任务包括:
以下是排除的用途。
pip install diffusers transformers accelerate --upgradeSDXL-Turbo 不使用 guidance_scale 或 negative_prompt,我们通过设置 guidance_scale=0.0 将其禁用。
理想情况下,该模型生成 512x512 尺寸的图像,但也支持更高的图像尺寸。
仅需单步即可生成高质量图像。
from diffusers import AutoPipelineForText2Image
import torch
from openmind_hub import snapshot_download
model_dir = snapshot_download("PyTorch-NPU/sdxl-turbo")
pipe = AutoPipelineForText2Image.from_pretrained(model_dir, torch_dtype=torch.float16, variant="fp16")
pipe.to("npu")
prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe."
image = pipe(prompt=prompt, num_inference_steps=1, guidance_scale=0.0).images[0]
image.save("image.png")使用 SDXL-Turbo 进行图像到图像生成时,请确保 num_inference_steps * strength 大于或等于 1。图像到图像管道将运行 int(num_inference_steps * strength) 步,例如在下面的示例中 0.5 * 2.0 = 1 步。
from diffusers import AutoPipelineForImage2Image
from diffusers.utils import load_image
from openmind_hub import snapshot_download
model_dir = snapshot_download("PyTorch-NPU/sdxl-turbo)
pipe = AutoPipelineForImage2Image.from_pretrained(model_dir, variant="fp16")
init_image = load_image("image.png").resize((512, 512))
prompt = "A cinematic shot of a baby racoon wearing an intricate italian priest robe, gandalf, lord of the rings, detailed, fantasy, cute, adorable, Pixar, Disney, 8k"
image = pipe(prompt, image=init_image, num_inference_steps=2, strength=0.5, guidance_scale=0.0).images[0]
image.save("image1.png")本模型未针对生成真实或如实反映人物、事件的内容进行训练,因此使用本模型生成此类内容超出了其能力范围。
不得将本模型用于任何违反Stability AI《可接受使用政策》(https://stability.ai/use-policy)的用途。
本模型仅用于研究目的。