模型:
CompVis/stable-diffusion-v1-1
Stable Diffusion 是一种潜在的文本到图像扩散模型,可以根据任意文本输入生成逼真的图像。有关 Stable Diffusion 的详细功能信息,请参阅 ?'s Stable Diffusion with D?iffusers blog 。
Stable-Diffusion-v1-1 在 laion2B-en 上以 256x256 的分辨率训练了 237,000 步,然后在 laion-high-resolution 上以 512x512 的分辨率进行了 194,000 步训练(使用 LAION-5B 中超过 170M 个分辨率 >= 1024x1024 的示例)。更多信息,请参阅 训练 。
这里的权重预期用于 D?iffusers 库。如果您正在寻找要加载到 CompVis Stable Diffusion 代码库中的权重,请参考 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 。
模型描述:这是一个可以用于根据文本提示生成和修改图像的模型。它是一个 Latent Diffusion Model ,使用一个固定的、预训练的文本编码器( CLIP ViT-L/14 )作为 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-1" 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)["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-1" # 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。
该模型不应用于故意创建或传播可能对人们产生敌对或疏远环境的图像。这包括生成人们预计会感到恶心、痛苦或冒犯的图像,或者传播历史上的或当前的刻板印象的内容。
超出范围的使用模型不是为了成为关于人或事件真实表示的事实依据,因此使用模型生成此类内容超出了模型的能力范围。
不当和恶意使用使用模型生成虐待个人的内容是对该模型的不当使用。这包括但不限于:
尽管图像生成模型的能力令人印象深刻,但它们也可能强化或加剧社会偏见。Stable Diffusion v1 是在 LAION-2B(en) 的子集上进行训练的,该数据集主要包含英文描述的图像。来自使用其他语言的社区和文化的文本和图像可能未能得到充分考虑。这会影响模型的整体输出,因为白人和西方文化往往被设定为默认值。此外,与使用英语提示相比,模型以非英语提示生成内容的能力明显较差。
模型开发者使用以下数据集训练模型:
Stable Diffusion 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 分数进行优化。
Stable Diffusion v1 估计的排放量基于使用 Machine Learning Impact calculator 在 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 编写。