Diffusers 文件
DiffEdit
並獲得增強的文件體驗
開始使用
DiffEdit
DiffEdit: 基於擴散的帶掩模引導的語義影像編輯由Guillaume Couairon、Jakob Verbeek、Holger Schwenk和Matthieu Cord撰寫。
論文摘要如下:
影像生成最近取得了巨大進展,擴散模型能夠為各種文字提示合成令人信服的影像。在本文中,我們提出了DiffEdit,這是一種利用文字條件擴散模型進行語義影像編輯任務的方法,其目標是根據文字查詢編輯影像。語義影像編輯是影像生成的擴充套件,額外限制是生成的影像應儘可能與給定輸入影像相似。當前基於擴散模型的編輯方法通常需要提供掩模,這使得任務透過將其視為條件修復任務而變得容易得多。相比之下,我們的主要貢獻在於能夠透過對比擴散模型在不同文字提示下預測的結果,自動生成突出顯示輸入影像中需要編輯區域的掩模。此外,我們依賴潛在推理來保留這些感興趣區域中的內容,並展示了與基於掩模的擴散的卓越協同作用。DiffEdit在ImageNet上實現了最先進的編輯效能。此外,我們還在更具挑戰性的設定中評估了語義影像編輯,使用了來自COCO資料集的影像以及基於文字生成的影像。
原始程式碼庫可在Xiang-cd/DiffEdit-stable-diffusion找到,您可以在此演示中試用它。
此管道由clarencechen貢獻。❤️
提示
- 該管道可以生成可饋送到其他影像修復管道的掩碼。
- 要使用此管道生成影像,必須提供影像掩碼(源和目標提示可以手動指定或生成,並傳遞給generate_mask())和一組部分反轉的潛在值(使用invert()生成)作為引數,以在呼叫管道生成最終編輯影像時使用。
- 函式generate_mask()公開了兩個提示引數:
source_prompt
和target_prompt
,讓您可以控制最終生成影像中語義編輯的位置。假設您想將“貓”轉換為“狗”。在這種情況下,編輯方向將是“貓 -> 狗”。為了在生成的掩碼中反映這一點,您只需將包含“貓”的短語相關的嵌入設定為source_prompt
,將包含“狗”的短語相關的嵌入設定為target_prompt
。 - 使用
invert
生成部分反轉的潛在值時,將描述整個影像的標題或文字嵌入分配給prompt
引數,以幫助引導反向潛在取樣過程。在大多數情況下,源概念足以產生良好的結果,但請隨意探索其他選項。 - 在呼叫管道生成最終編輯影像時,將源概念分配給
negative_prompt
,將目標概念分配給prompt
。以上述示例為例,您只需將包含“貓”的短語相關的嵌入設定為negative_prompt
,將包含“狗”的短語相關的嵌入設定為prompt
。 - 如果您想反轉上述示例中的方向,即“狗 -> 貓”,那麼建議您:
- 在
generate_mask
的引數中交換source_prompt
和target_prompt
。 - 將invert()中的輸入提示更改為包含“狗”。
- 在呼叫管道生成最終編輯影像時,交換
prompt
和negative_prompt
的引數。
- 在
- 源和目標提示,或其對應的嵌入,也可以自動生成。有關更多詳細資訊,請參閱DiffEdit指南。
StableDiffusionDiffEditPipeline
類 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進行文字引導影像修復的管道。
該模型繼承自DiffusionPipeline。有關所有管道實現的通用方法(下載、儲存、在特定裝置上執行等),請檢視超類文件。
該管道還繼承了以下載入和儲存方法:
- load_textual_inversion() 用於載入文字反演嵌入
- load_lora_weights() 用於載入 LoRA 權重
- save_lora_weights() 用於儲存 LoRA 權重
生成掩碼
< 源 >( 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]
或 np.array
引數
- image (
PIL.Image.Image
) — 用於計算掩碼的影像或表示影像批次的張量。 - target_prompt (
str
或List[str]
, 可選) — 用於引導語義掩碼生成的提示。如果未定義,您需要傳遞prompt_embeds
。 - target_negative_prompt (
str
或List[str]
, 可選) — 用於引導不包含在影像生成中的提示。如果未定義,您需要傳遞negative_prompt_embeds
。當不使用引導時 (guidance_scale < 1
),此引數將被忽略。 - target_prompt_embeds (
torch.Tensor
, 可選) — 預先生成的文字嵌入。可用於輕鬆調整文字輸入(提示加權)。如果未提供,則從prompt
輸入引數生成文字嵌入。 - target_negative_prompt_embeds (
torch.Tensor
, 可選) — 預先生成的負面文字嵌入。可用於輕鬆調整文字輸入(提示加權)。如果未提供,則從negative_prompt
輸入引數生成negative_prompt_embeds
。 - source_prompt (
str
或List[str]
, 可選) — 用於使用DiffEdit引導語義掩碼生成的提示。如果未定義,您需要傳遞source_prompt_embeds
或source_image
。 - source_negative_prompt (
str
或List[str]
, 可選) — 用於使用DiffEdit引導語義掩碼生成遠離的提示。如果未定義,您需要傳遞source_negative_prompt_embeds
或source_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.Generator
或List[torch.Generator]
, 可選) —torch.Generator
,用於使生成具有確定性。 - output_type (
str
, 可選, 預設為"pil"
) — 生成影像的輸出格式。在PIL.Image
或np.array
之間選擇。 - cross_attention_kwargs (
dict
, 可選) — 一個kwargs字典,如果指定,將傳遞給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]
反轉
< source >( 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 (
str
或List[str]
, 可選) — 用於引導影像生成的提示詞。如果未定義,則需要傳入prompt_embeds
。 - image (
PIL.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 (
str
或List[str]
, 可選) — 引導影像生成時不包含的提示詞。如果未定義,則需要傳入negative_prompt_embeds
。當不使用引導時(guidance_scale < 1
)會被忽略。 - generator (
torch.Generator
, 可選) — 一個torch.Generator
用於使生成具有確定性。 - prompt_embeds (
torch.Tensor
, 可選) — 預先生成的文字嵌入。可用於輕鬆調整文字輸入(提示詞權重)。如果未提供,則文字嵌入將從prompt
輸入引數生成。 - negative_prompt_embeds (
torch.Tensor
, 可選) — 預先生成的負面文字嵌入。可用於輕鬆調整文字輸入(提示詞權重)。如果未提供,negative_prompt_embeds
將從negative_prompt
輸入引數生成。 - decode_latents (
bool
, 可選, 預設為False
) — 是否將反轉的潛在值解碼為生成的影像。將此引數設定為True
會將每個時間步的所有反轉潛在值解碼為生成的影像列表。 - output_type (
str
, 可選, 預設為"pil"
) — 生成影像的輸出格式。選擇PIL.Image
或np.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
, 可選) — 一個 kwargs 字典,如果指定,將傳遞給 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__
< source >( 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 ) → StableDiffusionPipelineOutput 或 tuple
引數
- prompt (
str
或List[str]
, 可選) — 用於引導影像生成的提示詞。如果未定義,則需要傳入prompt_embeds
。 - mask_image (
PIL.Image.Image
) — 用於遮罩生成影像的影像或張量批次。遮罩中的白色畫素將被重新繪製,而黑色畫素將被保留。如果mask_image
是 PIL 影像,它在使用前將轉換為單通道(亮度)。如果它是張量,它應該包含一個顏色通道 (L) 而不是 3 個,所以預期的形狀是(B, 1, H, W)
。 - image_latents (
PIL.Image.Image
或torch.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 (
str
或List[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
進行取樣來生成潛在值張量。 - prompt_embeds (
torch.Tensor
, 可選) — 預生成的文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,文字嵌入將從prompt
輸入引數生成。 - negative_prompt_embeds (
torch.Tensor
, 可選) — 預生成的負面文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,negative_prompt_embeds
將從negative_prompt
輸入引數生成。 - output_type (
str
, 可選, 預設為"pil"
) — 生成影像的輸出格式。選擇PIL.Image
或np.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 表示將使用倒數第二層的輸出計算提示詞嵌入。
返回
StableDiffusionPipelineOutput 或 tuple
如果 return_dict
為 True
,則返回 StableDiffusionPipelineOutput,否則返回一個 tuple
,其中第一個元素是生成的影像列表,第二個元素是指示相應生成的影像是否包含“不適合工作”(nsfw) 內容的 bool
列表。
用於生成的管道的呼叫函式。
>>> 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
< source >( 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 (
str
或List[str]
, 可選) — 要編碼的提示詞 - device — (
torch.device
): torch 裝置 - num_images_per_prompt (
int
) — 每個提示詞應生成的影像數量 - do_classifier_free_guidance (
bool
) — 是否使用分類器自由引導 - negative_prompt (
str
或List[str]
, 可選) — 不引導影像生成的提示詞。如果未定義,則必須傳入negative_prompt_embeds
。當不使用引導時(即,如果guidance_scale
小於1
)將被忽略。 - prompt_embeds (
torch.Tensor
, 可選) — 預生成的文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,文字嵌入將從prompt
輸入引數生成。 - negative_prompt_embeds (
torch.Tensor
, 可選) — 預生成的負面文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,negative_prompt_embeds
將從negative_prompt
輸入引數生成。 - lora_scale (
float
, 可選) — 將應用於文字編碼器所有 LoRA 層的 LoRA 比例(如果 LoRA 層已載入)。 - clip_skip (
int
, 可選) — 在計算提示詞嵌入時跳過 CLIP 的層數。值為 1 表示將使用倒數第二層的輸出計算提示詞嵌入。
將提示編碼為文字編碼器隱藏狀態。
StableDiffusionPipelineOutput
class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput
< source >( images: typing.Union[typing.List[PIL.Image.Image], numpy.ndarray] nsfw_content_detected: typing.Optional[typing.List[bool]] )
Stable Diffusion 管道的輸出類。