模型:
CompVis/stable-diffusion-v1-3
稳定扩散是一种潜在的文本到图像扩散模型,能够根据任何文本输入生成逼真的图像。有关稳定扩散如何运作的更多信息,请参阅 ?'s Stable Diffusion with D?iffusers blog 。
稳定扩散 v1-3 的检查点是通过 Stable-Diffusion-v1-2 的权重进行初始化,并在 195,000 步的分辨率为 512x512 的 "laion-improved-aesthetics" 数据集上进行微调,同时在文本条件中丢弃 10% 的信息以提高 classifier-free guidance sampling 。更多信息,请参阅培训。
这里的权重是为了与 D?iffusers 库一起使用。如果您正在寻找加载到 CompVis 稳定扩散代码库中的权重,请参阅 come here 。
开发者:Robin Rombach、Patrick Esser
模型类型:基于扩散的文本到图像生成模型
语言:英语
许可证: The CreativeML OpenRAIL M license 是 Open RAIL M license 的修改版本,基于 BigScience 和 the RAIL Initiative 在负责任的 AI 许可领域共同进行的工作。另请参阅我们基于的 the article about the BLOOM Open RAIL license 许可证。
模型描述:这是一个用于根据文本提示生成和修改图像的模型。它是一个使用固定的预训练文本编码器 ( CLIP ViT-L/14 ) 的 Latent Diffusion Model 模型,如 Imagen paper 中建议的那样。
更多信息的资源: GitHub Repository 、 Paper 。
引用:
@InProceedings{Rombach_2022_CVPR, author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn}, title = {High-Resolution Image Synthesis With Latent Diffusion Models}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, month = {June}, year = {2022}, pages = {10684-10695} }
我们建议使用 ?'s Diffusers library 来运行 Stable Diffusion。
pip install --upgrade diffusers transformers scipy
使用默认的 PNDM 调度程序运行流水线:
import torch from torch import autocast from diffusers import StableDiffusionPipeline model_id = "CompVis/stable-diffusion-v1-3" device = "cuda" pipe = StableDiffusionPipeline.from_pretrained(model_id) pipe = pipe.to(device) prompt = "a photo of an astronaut riding a horse on mars" with autocast("cuda"): image = pipe(prompt, guidance_scale=7.5)["sample"][0] image.save("astronaut_rides_horse.png")
注意:如果您的 GPU 内存有限,只有不到 10GB 的 GPU RAM 可用,请确保以 float16 精度而不是默认的 float32 精度加载 StableDiffusionPipeline。您可以通过告诉 diffusers 预期权重为 float16 精度来实现这一点:
import torch pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) pipe = pipe.to(device) prompt = "a photo of an astronaut riding a horse on mars" with autocast("cuda"): image = pipe(prompt, guidance_scale=7.5)["sample"][0] image.save("astronaut_rides_horse.png")
要更换噪声调度程序,请将其传递给 from_pretrained:
from diffusers import StableDiffusionPipeline, LMSDiscreteScheduler model_id = "CompVis/stable-diffusion-v1-3" # Use the K-LMS scheduler here instead scheduler = LMSDiscreteScheduler(beta_start=0.00085, beta_end=0.012, beta_schedule="scaled_linear", num_train_timesteps=1000) pipe = StableDiffusionPipeline.from_pretrained(model_id, scheduler=scheduler, use_auth_token=True) pipe = pipe.to("cuda") prompt = "a photo of an astronaut riding a horse on mars" with autocast("cuda"): image = pipe(prompt, guidance_scale=7.5)["sample"][0] image.save("astronaut_rides_horse.png")
该模型仅用于研究目的。可能的研究领域和任务包括:
下面描述了不适用的用途。
注意:此部分摘自 DALLE-MINI model card ,但同样适用于 Stable Diffusion v1。
不应将该模型用于有意创建或传播对人们产生敌意或隔离环境的图像。这包括生成人们可以预见到的令人不安、苦恼或冒犯的图像;或传播历史上或当前的刻板印象的内容。
超出范围的使用该模型并不是旨在提供有关人们或事件的确切事实的内容,因此,将该模型用于生成这类内容超出了该模型的能力范围。
滥用和恶意使用将模型用于生成对个人残忍的内容是对该模型的滥用。这包括但不限于:
尽管图像生成模型的能力令人印象深刻,但它们也可能强化或加剧社会偏见。稳定扩散 v1 是在 LAION-2B(en) 的子集上进行训练的,该数据集主要包含了英文描述的图像。从其他使用其他语言的社区和文化的文本和图像来看,这些数据可能不足够。这会影响模型的整体输出,因为白人和西方文化通常被设定为默认值。此外,与使用英语提示相比,该模型生成非英文内容的能力明显较差。
模型开发者使用以下数据集训练了模型:
稳定扩散 v1-4 是一个潜在的扩散模型,它将自编码器与在自编码器的潜在空间中训练的扩散模型相结合。在训练期间,
我们目前提供了四个检查点,它们的训练如下:
使用不同的无分类器引导比例 (1.5、2.0、3.0、4.0、5.0、6.0、7.0、8.0) 和 50 个 PLMS 采样步骤对检查点进行了评估:
使用 50 个 PLMS 步骤和来自 COCO2017 验证集的 10000 个随机提示进行评估,评估分辨率为 512x512。不针对 FID 分数进行优化。
稳定扩散 v1 估计的排放量根据我们在 Lacoste et al. (2019) 中提供的信息,利用硬件、运行时间、云服务提供商和计算区域进行了碳排放估计。
@InProceedings{Rombach_2022_CVPR, author = {Rombach, Robin and Blattmann, Andreas and Lorenz, Dominik and Esser, Patrick and Ommer, Bj\"orn}, title = {High-Resolution Image Synthesis With Latent Diffusion Models}, booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)}, month = {June}, year = {2022}, pages = {10684-10695} }
此模型说明卡由 Robin Rombach 和 Patrick Esser 撰写,并基于 DALL-E Mini model card 提供的模板进行编写。