Diffusers 文档

DiffEdit

Hugging Face's logo
加入 Hugging Face 社区

并获取增强的文档体验

开始使用

DiffEdit

DiffEdit: Diffusion-based semantic image editing with mask guidance is by Guillaume Couairon, Jakob Verbeek, Holger Schwenk, and Matthieu Cord.

论文摘要如下:

图像生成最近取得了巨大的进步,扩散模型允许为各种文本提示合成令人信服的图像。在本文中,我们提出了 DiffEdit,一种利用文本条件扩散模型进行语义图像编辑任务的方法,其目标是根据文本查询编辑图像。语义图像编辑是图像生成的扩展,但附加了一个约束,即生成的图像应尽可能与给定的输入图像相似。当前基于扩散模型的编辑方法通常需要提供一个掩码,这通过将其视为条件性图像修复任务而使任务变得容易得多。相比之下,我们的主要贡献是能够自动生成一个掩码,突出显示输入图像中需要编辑的区域,方法是对比在不同文本提示条件下扩散模型的预测。此外,我们依赖于潜在推理来保留感兴趣区域的内容,并展示了与基于掩码的扩散的出色协同作用。DiffEdit 在 ImageNet 上实现了最先进的编辑性能。此外,我们还在更具挑战性的设置中评估了语义图像编辑,使用了来自 COCO 数据集以及基于文本生成的图像。

原始代码库可以在 Xiang-cd/DiffEdit-stable-diffusion 找到,你可以在这个 demo 中试用它。

此 pipeline 由 clarencechen 贡献。 ❤️

提示

  • 该 pipeline 可以生成掩码,这些掩码可以被馈送到其他图像修复 pipeline 中。
  • 为了使用此 pipeline 生成图像,在调用 pipeline 生成最终编辑后的图像时,必须提供图像掩码(源提示和目标提示可以手动指定或生成,并传递给 generate_mask())和一组部分反转的潜在变量(使用 invert() 生成)作为参数。
  • 函数 generate_mask() 公开了两个提示参数,source_prompttarget_prompt,它们允许你控制最终要生成的图像中语义编辑的位置。假设你想从“猫”翻译成“狗”。在这种情况下,编辑方向将是“猫 -> 狗”。为了在生成的掩码中反映这一点,你只需将与包含“猫”的短语相关的嵌入设置为 source_prompt,并将“狗”设置为 target_prompt
  • 当使用 invert 生成部分反转的潜在变量时,将描述图像整体的标题或文本嵌入分配给 prompt 参数,以帮助引导逆潜在采样过程。在大多数情况下,源概念足以产生良好的结果,但请随意探索其他选择。
  • 当调用 pipeline 生成最终编辑后的图像时,将源概念分配给 negative_prompt,并将目标概念分配给 prompt。以上面的例子为例,你只需将与包含“猫”的短语相关的嵌入设置为 negative_prompt,并将“狗”设置为 prompt
  • 如果你想反转上面示例中的方向,即“狗 -> 猫”,那么建议你
    • generate_mask 的参数中交换 source_prompttarget_prompt
    • 更改 invert() 中的输入提示,使其包含“dog”。
    • 在调用 pipeline 生成最终编辑图像的参数中,交换 promptnegative_prompt
  • 源提示和目标提示,或其相应的嵌入,也可以自动生成。请参阅 DiffEdit 指南以获取更多详细信息。

StableDiffusionDiffEditPipeline

class diffusers.StableDiffusionDiffEditPipeline

< >

( vae: AutoencoderKL text_encoder: CLIPTextModel tokenizer: CLIPTokenizer unet: UNet2DConditionModel scheduler: KarrasDiffusionSchedulers safety_checker: StableDiffusionSafetyChecker feature_extractor: CLIPImageProcessor inverse_scheduler: DDIMInverseScheduler requires_safety_checker: bool = True )

参数

  • vae (AutoencoderKL) — 变分自编码器 (VAE) 模型,用于将图像编码和解码为潜在表示形式以及从潜在表示形式解码为图像。
  • text_encoder (CLIPTextModel) — 冻结的文本编码器 (clip-vit-large-patch14)。
  • tokenizer (CLIPTokenizer) — 用于标记文本的 CLIPTokenizer
  • unet (UNet2DConditionModel) — 用于对编码后的图像潜在变量进行去噪的 UNet2DConditionModel
  • scheduler (SchedulerMixin) — 调度器,与 unet 结合使用,以对编码后的图像潜在变量进行去噪。
  • inverse_scheduler (DDIMInverseScheduler) — 调度器,与 unet 结合使用,以填充输入潜在变量中未被掩码的部分。
  • safety_checker (StableDiffusionSafetyChecker) — 分类模块,用于评估生成的图像是否可能被认为具有攻击性或有害。有关模型潜在危害的更多详细信息,请参阅 模型卡
  • feature_extractor (CLIPImageProcessor) — CLIPImageProcessor,用于从生成的图像中提取特征;用作 safety_checker 的输入。

这是一个实验性功能!

使用 Stable Diffusion 和 DiffEdit 进行文本引导图像修复的 Pipeline。

此模型继承自 DiffusionPipeline。查看超类文档以了解为所有 pipeline 实现的通用方法(下载、保存、在特定设备上运行等)。

该 pipeline 还继承了以下加载和保存方法

generate_mask

< >

( image: typing.Union[torch.Tensor, PIL.Image.Image] = None target_prompt: typing.Union[str, typing.List[str], NoneType] = None target_negative_prompt: typing.Union[str, typing.List[str], NoneType] = None target_prompt_embeds: typing.Optional[torch.Tensor] = None target_negative_prompt_embeds: typing.Optional[torch.Tensor] = None source_prompt: typing.Union[str, typing.List[str], NoneType] = None source_negative_prompt: typing.Union[str, typing.List[str], NoneType] = None source_prompt_embeds: typing.Optional[torch.Tensor] = None source_negative_prompt_embeds: typing.Optional[torch.Tensor] = None num_maps_per_mask: typing.Optional[int] = 10 mask_encode_strength: typing.Optional[float] = 0.5 mask_thresholding_ratio: typing.Optional[float] = 3.0 num_inference_steps: int = 50 guidance_scale: float = 7.5 generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None output_type: typing.Optional[str] = 'np' cross_attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None ) List[PIL.Image.Image] or np.array

参数

  • image (PIL.Image.Image) — Image 或 tensor,表示用于计算掩码的图像批次。
  • target_prompt (strList[str], 可选) — 用于引导语义掩码生成的提示。如果未定义,则需要传递 prompt_embeds
  • target_negative_prompt (strList[str], 可选) — 用于引导图像生成中不包含的内容的提示。如果未定义,则需要传递 negative_prompt_embeds 代替。当不使用 guidance 时(guidance_scale < 1),将被忽略。
  • target_prompt_embeds (torch.Tensor, 可选) — 预生成的文本嵌入。可用于轻松调整文本输入(提示权重)。如果未提供,则从 prompt 输入参数生成文本嵌入。
  • target_negative_prompt_embeds (torch.Tensor, 可选) — 预生成的负面文本嵌入。可用于轻松调整文本输入(提示权重)。如果未提供,则从 negative_prompt 输入参数生成 negative_prompt_embeds
  • source_prompt (strList[str], 可选) — 用于引导使用 DiffEdit 生成语义掩码的提示。如果未定义,则需要传递 source_prompt_embedssource_image 代替。
  • source_negative_prompt (strList[str], 可选) — 用于引导语义掩码生成避免使用 DiffEdit 的提示。如果未定义,则需要传递 source_negative_prompt_embedssource_image 代替。
  • source_prompt_embeds (torch.Tensor, 可选) — 预生成的文本嵌入,用于引导语义掩码的生成。可用于轻松调整文本输入(提示权重)。如果未提供,则从 source_prompt 输入参数生成文本嵌入。
  • source_negative_prompt_embeds (torch.Tensor, 可选) — 预生成的文本嵌入,用于负向引导语义掩码的生成。可用于轻松调整文本输入(提示权重)。如果未提供,则从 source_negative_prompt 输入参数生成文本嵌入。
  • num_maps_per_mask (int, 可选, 默认为 10) — 采样用于使用 DiffEdit 生成语义掩码的噪声图的数量。
  • mask_encode_strength (float, 可选, 默认为 0.5) — 采样用于使用 DiffEdit 生成语义掩码的噪声图的强度。必须介于 0 和 1 之间。
  • mask_thresholding_ratio (float, 可选, 默认为 3.0) — 在掩模二值化之前,用于钳制语义引导图的最大均值绝对差倍数。
  • num_inference_steps (int, 可选, 默认为 50) — 去噪步骤的数量。更多的去噪步骤通常会带来更高质量的图像,但会牺牲推理速度。
  • guidance_scale (float, 可选, 默认为 7.5) — 更高的引导尺度值会鼓励模型生成与文本 prompt 紧密相关的图像,但这会以降低图像质量为代价。当 guidance_scale > 1 时,引导尺度被启用。
  • generator (torch.GeneratorList[torch.Generator], 可选) — torch.Generator,用于使生成过程具有确定性。
  • output_type (str, 可选, 默认为 "pil") — 生成图像的输出格式。在 PIL.Imagenp.array 之间选择。
  • cross_attention_kwargs (dict, 可选) — 一个关键字参数字典,如果指定,它将被传递给 AttnProcessor,定义在 self.processor 中。

返回

List[PIL.Image.Image]np.array

当返回 List[PIL.Image.Image] 时,该列表由一批单通道二值图像组成,其尺寸为 (height // self.vae_scale_factor, width // self.vae_scale_factor)。如果是 np.array,则形状为 (batch_size, height // self.vae_scale_factor, width // self.vae_scale_factor)

给定掩模提示词、目标提示词和图像,生成潜在掩模。

>>> import PIL
>>> import requests
>>> import torch
>>> from io import BytesIO

>>> from diffusers import StableDiffusionDiffEditPipeline


>>> def download_image(url):
...     response = requests.get(url)
...     return PIL.Image.open(BytesIO(response.content)).convert("RGB")


>>> img_url = "https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png"

>>> init_image = download_image(img_url).resize((768, 768))

>>> pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
...     "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16
... )

>>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.enable_model_cpu_offload()

>>> mask_prompt = "A bowl of fruits"
>>> prompt = "A bowl of pears"

>>> mask_image = pipeline.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt)
>>> image_latents = pipeline.invert(image=init_image, prompt=mask_prompt).latents
>>> image = pipeline(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[0]

invert

< >

( prompt: typing.Union[str, typing.List[str], NoneType] = None image: typing.Union[torch.Tensor, PIL.Image.Image] = None num_inference_steps: int = 50 inpaint_strength: float = 0.8 guidance_scale: float = 7.5 negative_prompt: typing.Union[str, typing.List[str], NoneType] = None generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None prompt_embeds: typing.Optional[torch.Tensor] = None negative_prompt_embeds: typing.Optional[torch.Tensor] = None decode_latents: bool = False output_type: typing.Optional[str] = 'pil' return_dict: bool = True callback: typing.Optional[typing.Callable[[int, int, torch.Tensor], NoneType]] = None callback_steps: typing.Optional[int] = 1 cross_attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None lambda_auto_corr: float = 20.0 lambda_kl: float = 20.0 num_reg_steps: int = 0 num_auto_corr_rolls: int = 5 )

参数

  • prompt (strList[str], 可选) — 用于引导图像生成的提示词。如果未定义,你需要传递 prompt_embeds
  • image (PIL.Image.Image) — `Image` 或张量,表示用于生成由 prompt 引导的反向潜在变量的图像批次。
  • inpaint_strength (float, 可选, 默认为 0.8) — 指示运行潜在变量反演的噪声处理程度。必须介于 0 和 1 之间。当 inpaint_strength 为 1 时,反演过程将运行完整数量的迭代次数,该次数在 num_inference_steps 中指定。image 用作反演过程的参考,增加更多噪声会增加 inpaint_strength。如果 inpaint_strength 为 0,则不进行图像修复。
  • num_inference_steps (int, 可选, 默认为 50) — 去噪步骤的数量。更多的去噪步骤通常会带来更高质量的图像,但会牺牲推理速度。
  • guidance_scale (float, 可选, 默认为 7.5) — 更高的引导尺度值会鼓励模型生成与文本 prompt 紧密相关的图像,但这会以降低图像质量为代价。当 guidance_scale > 1 时,引导尺度被启用。
  • negative_prompt (strList[str], 可选) — 用于引导图像生成中不应包含的内容的提示词。如果未定义,则需要传递 negative_prompt_embeds 代替。当不使用引导(guidance_scale < 1)时忽略。
  • generator (torch.Generator, 可选) — torch.Generator,用于使生成过程具有确定性。
  • prompt_embeds (torch.Tensor, 可选) — 预生成的文本嵌入。可用于轻松调整文本输入(提示词权重)。如果未提供,则从 prompt 输入参数生成文本嵌入。
  • negative_prompt_embeds (torch.Tensor, 可选) — 预生成的负面文本嵌入。可用于轻松调整文本输入(提示词权重)。如果未提供,则从 negative_prompt 输入参数生成 negative_prompt_embeds
  • decode_latents (bool, 可选, 默认为 False) — 是否将反向潜在变量解码为生成的图像。将此参数设置为 True 会将每个时间步的所有反向潜在变量解码为生成的图像列表。
  • output_type (str, 可选, 默认为 "pil") — 生成图像的输出格式。在 PIL.Imagenp.array 之间选择。
  • return_dict (bool, 可选, 默认为 True) — 是否返回 ~pipelines.stable_diffusion.DiffEditInversionPipelineOutput 而不是普通元组。
  • callback (Callable, 可选) — 一个函数,它在推理期间每 callback_steps 步调用一次。该函数使用以下参数调用:callback(step: int, timestep: int, latents: torch.Tensor)
  • callback_steps (int, 可选, 默认为 1) — 调用 callback 函数的频率。如果未指定,则在每一步都调用回调函数。
  • cross_attention_kwargs (dict, 可选) — 一个关键字参数字典,如果指定,它将被传递给 AttnProcessor,定义在 self.processor 中。
  • lambda_auto_corr (float, 可选, 默认为 20.0) — 用于控制自动校正的 Lambda 参数。
  • lambda_kl (float, 可选, 默认为 20.0) — 用于控制 Kullback-Leibler 散度输出的 Lambda 参数。
  • num_reg_steps (int, 可选, 默认为 0) — 正则化损失步骤的数量。
  • num_auto_corr_rolls (int, 可选, 默认为 5) — 自动校正滚动步骤的数量。

给定提示词和图像,生成反向潜在变量。

>>> import PIL
>>> import requests
>>> import torch
>>> from io import BytesIO

>>> from diffusers import StableDiffusionDiffEditPipeline


>>> def download_image(url):
...     response = requests.get(url)
...     return PIL.Image.open(BytesIO(response.content)).convert("RGB")


>>> img_url = "https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png"

>>> init_image = download_image(img_url).resize((768, 768))

>>> pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
...     "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16
... )

>>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.enable_model_cpu_offload()

>>> prompt = "A bowl of fruits"

>>> inverted_latents = pipeline.invert(image=init_image, prompt=prompt).latents

__call__

< >

( prompt: typing.Union[str, typing.List[str], NoneType] = None mask_image: typing.Union[torch.Tensor, PIL.Image.Image] = None image_latents: typing.Union[torch.Tensor, PIL.Image.Image] = None inpaint_strength: typing.Optional[float] = 0.8 num_inference_steps: int = 50 guidance_scale: float = 7.5 negative_prompt: typing.Union[str, typing.List[str], NoneType] = None num_images_per_prompt: typing.Optional[int] = 1 eta: float = 0.0 generator: typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None latents: typing.Optional[torch.Tensor] = None prompt_embeds: typing.Optional[torch.Tensor] = None negative_prompt_embeds: typing.Optional[torch.Tensor] = None output_type: typing.Optional[str] = 'pil' return_dict: bool = True callback: typing.Optional[typing.Callable[[int, int, torch.Tensor], NoneType]] = None callback_steps: int = 1 cross_attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None clip_skip: int = None ) StableDiffusionPipelineOutputtuple

参数

  • prompt (strList[str], 可选) — 用于引导图像生成的提示语或提示语列表。 如果未定义,则需要传递 prompt_embeds
  • mask_image (PIL.Image.Image) — Image 或 tensor,表示要蒙版生成图像的图像批次。 蒙版中的白色像素会被重新绘制,而黑色像素会被保留。 如果 mask_image 是 PIL 图像,则在使用前会将其转换为单通道(亮度)。 如果它是 tensor,则应包含一个颜色通道 (L) 而不是 3 个,因此预期的形状应为 (B, 1, H, W)
  • image_latents (PIL.Image.Imagetorch.Tensor) — 来自反演过程的部分噪声图像潜变量,用作图像生成的输入。
  • inpaint_strength (float, 可选, 默认为 0.8) — 指示对蒙版区域进行图像修复的程度。 必须介于 0 和 1 之间。 当 inpaint_strength 为 1 时,去噪过程会在蒙版区域上运行,迭代次数为 num_inference_steps 中指定的完整次数。 image_latents 用作蒙版区域的参考,对区域添加更多噪声会增加 inpaint_strength。 如果 inpaint_strength 为 0,则不会发生图像修复。
  • num_inference_steps (int, 可选, 默认为 50) — 去噪步骤的数量。 更多的去噪步骤通常会带来更高质量的图像,但会牺牲较慢的推理速度。
  • guidance_scale (float, 可选, 默认为 7.5) — 更高的引导尺度值会鼓励模型生成与文本 prompt 紧密相关的图像,但会牺牲较低的图像质量。 当 guidance_scale > 1 时,引导尺度会启用。
  • negative_prompt (strList[str], 可选) — 用于引导图像生成中不应包含的内容的提示语或提示语列表。 如果未定义,则需要改为传递 negative_prompt_embeds。 当不使用引导(guidance_scale < 1)时,将被忽略。
  • num_images_per_prompt (int, 可选, 默认为 1) — 每个提示语要生成的图像数量。
  • eta (float, 可选, 默认为 0.0) — 对应于 DDIM 论文中的参数 eta (η)。 仅适用于 DDIMScheduler,在其他调度器中将被忽略。
  • generator (torch.Generator, 可选) — 用于使生成具有确定性的 torch.Generator
  • latents (torch.Tensor, 可选) — 从高斯分布中采样的预生成噪声潜变量,用作图像生成的输入。 可用于使用不同的提示语调整相同的生成。 如果未提供,则会通过使用提供的随机 generator 进行采样来生成潜变量 tensor。
  • prompt_embeds (torch.Tensor, 可选) — 预生成的文本嵌入。 可用于轻松调整文本输入(提示语权重)。 如果未提供,则文本嵌入会从 prompt 输入参数生成。
  • negative_prompt_embeds (torch.Tensor, 可选) — 预生成的负面文本嵌入。 可用于轻松调整文本输入(提示语权重)。 如果未提供,则会从 negative_prompt 输入参数生成 negative_prompt_embeds
  • output_type (str, 可选, 默认为 "pil") — 生成图像的输出格式。 在 PIL.Imagenp.array 之间选择。
  • return_dict (bool, 可选, 默认为 True) — 是否返回 StableDiffusionPipelineOutput 而不是普通元组。
  • callback (Callable, 可选) — 在推理期间每 callback_steps 步调用一次的函数。 该函数使用以下参数调用: callback(step: int, timestep: int, latents: torch.Tensor)
  • callback_steps (int, 可选, 默认为 1) — 调用 callback 函数的频率。 如果未指定,则在每个步骤都调用回调。
  • cross_attention_kwargs (dict, 可选) — 一个 kwargs 字典,如果指定,则会传递给 self.processor 中定义的 AttentionProcessor
  • clip_skip (int, 可选) — 从 CLIP 中跳过的层数,用于计算提示语嵌入。 值 1 表示预最终层的输出将用于计算提示语嵌入。

返回

StableDiffusionPipelineOutputtuple

如果 return_dictTrue,则返回 StableDiffusionPipelineOutput,否则返回 tuple,其中第一个元素是包含生成图像的列表,第二个元素是 bool 列表,指示相应的生成图像是否包含“不适合工作场所观看”(nsfw)的内容。

用于生成的 pipeline 的调用函数。

>>> import PIL
>>> import requests
>>> import torch
>>> from io import BytesIO

>>> from diffusers import StableDiffusionDiffEditPipeline


>>> def download_image(url):
...     response = requests.get(url)
...     return PIL.Image.open(BytesIO(response.content)).convert("RGB")


>>> img_url = "https://github.com/Xiang-cd/DiffEdit-stable-diffusion/raw/main/assets/origin.png"

>>> init_image = download_image(img_url).resize((768, 768))

>>> pipeline = StableDiffusionDiffEditPipeline.from_pretrained(
...     "stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16
... )

>>> pipeline.scheduler = DDIMScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.inverse_scheduler = DDIMInverseScheduler.from_config(pipeline.scheduler.config)
>>> pipeline.enable_model_cpu_offload()

>>> mask_prompt = "A bowl of fruits"
>>> prompt = "A bowl of pears"

>>> mask_image = pipeline.generate_mask(image=init_image, source_prompt=prompt, target_prompt=mask_prompt)
>>> image_latents = pipeline.invert(image=init_image, prompt=mask_prompt).latents
>>> image = pipeline(prompt=prompt, mask_image=mask_image, image_latents=image_latents).images[0]

encode_prompt

< >

( prompt device num_images_per_prompt do_classifier_free_guidance negative_prompt = None prompt_embeds: typing.Optional[torch.Tensor] = None negative_prompt_embeds: typing.Optional[torch.Tensor] = None lora_scale: typing.Optional[float] = None clip_skip: typing.Optional[int] = None )

参数

  • prompt (strList[str], 可选) — 要编码的提示语
  • device — (torch.device): torch 设备
  • num_images_per_prompt (int) — 每个提示语应生成的图像数量
  • do_classifier_free_guidance (bool) — 是否使用无分类器引导(classifier free guidance)。
  • negative_prompt (strList[str], 可选) — 不用于引导图像生成的提示或提示列表。 如果未定义,则必须传递 negative_prompt_embeds。 当不使用引导时忽略(即,如果 guidance_scale 小于 1 则忽略)。
  • prompt_embeds (torch.Tensor, 可选) — 预生成的文本嵌入(embeddings)。 可用于轻松调整文本输入,例如 提示权重。 如果未提供,则将从 prompt 输入参数生成文本嵌入。
  • negative_prompt_embeds (torch.Tensor, 可选) — 预生成的负面文本嵌入。 可用于轻松调整文本输入,例如 提示权重。 如果未提供,则将从 negative_prompt 输入参数生成 negative_prompt_embeds。
  • lora_scale (float, 可选) — LoRA 缩放比例,如果加载了 LoRA 层,则将应用于文本编码器的所有 LoRA 层。
  • clip_skip (int, 可选) — 在计算提示嵌入时,要从 CLIP 跳过的层数。 值为 1 表示预倒数第二层的输出将用于计算提示嵌入。

将提示编码为文本编码器隐藏状态。

StableDiffusionPipelineOutput

class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput

< >

( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] nsfw_content_detected: typing.Optional[typing.List[bool]] )

参数

  • images (List[PIL.Image.Image]np.ndarray) — 长度为 batch_size 的去噪 PIL 图像列表,或形状为 (batch_size, height, width, num_channels) 的 NumPy 数组。
  • nsfw_content_detected (List[bool]) — 指示相应的生成图像是否包含“不适宜工作场所观看”(nsfw)内容的列表,如果无法执行安全检查,则为 None

Stable Diffusion 管道的输出类。

< > GitHub 上更新