Diffusers 文件

SANA-Sprint

Hugging Face's logo
加入 Hugging Face 社群

並獲得增強的文件體驗

開始使用

SANA-Sprint

LoRA

SANA-Sprint:帶連續時間一致性蒸餾的一步擴散,由NVIDIA、MIT HAN Lab和Hugging Face的Junsong Chen、Shuchen Xue、Yuyang Zhao、Jincheng Yu、Sayak Paul、Junyu Chen、Han Cai、Enze Xie、Song Han撰寫

論文摘要如下:

本文介紹了SANA-Sprint,一種用於超快速文字到影像(T2I)生成的有效擴散模型。SANA-Sprint建立在預訓練基礎模型之上,並輔以混合蒸餾,將推理步驟從20步顯著減少到1-4步。我們引入了三項關鍵創新:(1)我們提出了一種免訓練方法,將預訓練的流匹配模型用於連續時間一致性蒸餾(sCM),消除了從頭開始訓練的高昂成本,並實現了高訓練效率。我們的混合蒸餾策略將sCM與潛在對抗蒸餾(LADD)結合起來:sCM確保與教師模型對齊,而LADD增強了單步生成保真度。(2)SANA-Sprint是一個統一的步長自適應模型,可在1-4步內實現高質量生成,消除了針對特定步長的訓練,提高了效率。(3)我們將ControlNet與SANA-Sprint整合,實現即時互動式影像生成,為使用者互動提供即時視覺反饋。SANA-Sprint在速度-質量權衡方面建立了新的帕累託前沿,僅用1步就實現了最先進的效能,FID為7.59,GenEval為0.74——優於FLUX-schnell(FID為7.94 / GenEval為0.71),同時速度快10倍(H100上0.1秒 vs 1.1秒)。它還在H100上實現了1024×1024影像的0.1秒(T2I)和0.25秒(ControlNet)延遲,以及在RTX 4090上0.31秒(T2I)的延遲,展示了其卓越的效率和AI驅動的消費級應用(AIPC)的潛力。程式碼和預訓練模型將開源。

請務必檢視排程器指南,瞭解如何探索排程器速度和質量之間的權衡,並參閱跨管道重用元件部分,瞭解如何有效地將相同元件載入到多個管道中。

此管道由lawrence-cjshuchen XueEnze Xie貢獻。原始程式碼庫可在此處找到。原始權重可在hf.co/Efficient-Large-Model下找到。

可用模型

模型 推薦資料型別
Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers torch.bfloat16
Efficient-Large-Model/Sana_Sprint_0.6B_1024px_diffusers torch.bfloat16

更多資訊請參考集合。

注意:推薦的資料型別是指Transformer權重。文字編碼器必須保持為torch.bfloat16,VAE權重必須保持為torch.bfloat16torch.float32,模型才能正常工作。請參閱下面的推理示例,瞭解如何使用推薦的資料型別載入模型。

量化

量化有助於透過以較低精度資料型別儲存模型權重來減少大型模型的記憶體需求。但是,量化對影片質量的影響可能因影片模型而異。

請參閱量化概述,瞭解更多支援的量化後端以及如何選擇支援您用例的量化後端。下面的示例演示瞭如何使用bitsandbytes載入量化的SanaSprintPipeline進行推理。

import torch
from diffusers import BitsAndBytesConfig as DiffusersBitsAndBytesConfig, SanaTransformer2DModel, SanaSprintPipeline
from transformers import BitsAndBytesConfig as BitsAndBytesConfig, AutoModel

quant_config = BitsAndBytesConfig(load_in_8bit=True)
text_encoder_8bit = AutoModel.from_pretrained(
    "Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers",
    subfolder="text_encoder",
    quantization_config=quant_config,
    torch_dtype=torch.bfloat16,
)

quant_config = DiffusersBitsAndBytesConfig(load_in_8bit=True)
transformer_8bit = SanaTransformer2DModel.from_pretrained(
    "Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers",
    subfolder="transformer",
    quantization_config=quant_config,
    torch_dtype=torch.bfloat16,
)

pipeline = SanaSprintPipeline.from_pretrained(
    "Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers",
    text_encoder=text_encoder_8bit,
    transformer=transformer_8bit,
    torch_dtype=torch.bfloat16,
    device_map="balanced",
)

prompt = "a tiny astronaut hatching from an egg on the moon"
image = pipeline(prompt).images[0]
image.save("sana.png")

設定max_timesteps

使用者可以調整max_timesteps的值以實驗生成輸出的視覺質量。預設的max_timesteps值是透過推理時間搜尋過程獲得的。有關其更多詳細資訊,請檢視論文。

影像到影像

SanaSprintImg2ImgPipeline是一個用於影像到影像生成的管道。它接收一張輸入影像和一個提示,並根據輸入影像和提示生成一張新影像。

import torch
from diffusers import SanaSprintImg2ImgPipeline
from diffusers.utils.loading_utils import load_image

image = load_image(
    "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png"
)

pipe = SanaSprintImg2ImgPipeline.from_pretrained(
    "Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers", 
    torch_dtype=torch.bfloat16)
pipe.to("cuda")

image = pipe(
    prompt="a cute pink bear", 
    image=image, 
    strength=0.5, 
    height=832, 
    width=480
).images[0]
image.save("output.png")

SanaSprintPipeline

diffusers.SanaSprintPipeline

< >

( tokenizer: typing.Union[transformers.models.gemma.tokenization_gemma.GemmaTokenizer, transformers.models.gemma.tokenization_gemma_fast.GemmaTokenizerFast] text_encoder: Gemma2PreTrainedModel vae: AutoencoderDC transformer: SanaTransformer2DModel scheduler: DPMSolverMultistepScheduler )

使用SANA-Sprint進行文字到影像生成的管道。

__call__

< >

( prompt: typing.Union[str, typing.List[str]] = None num_inference_steps: int = 2 timesteps: typing.List[int] = None max_timesteps: float = 1.5708 intermediate_timesteps: float = 1.3 guidance_scale: float = 4.5 num_images_per_prompt: typing.Optional[int] = 1 height: int = 1024 width: int = 1024 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 prompt_attention_mask: typing.Optional[torch.Tensor] = None output_type: typing.Optional[str] = 'pil' return_dict: bool = True clean_caption: bool = False use_resolution_binning: bool = True attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None callback_on_step_end: typing.Optional[typing.Callable[[int, int, typing.Dict], NoneType]] = None callback_on_step_end_tensor_inputs: typing.List[str] = ['latents'] max_sequence_length: int = 300 complex_human_instruction: typing.List[str] = ["Given a user prompt, generate an 'Enhanced prompt' that provides detailed visual descriptions suitable for image generation. Evaluate the level of detail in the user prompt:", '- If the prompt is simple, focus on adding specifics about colors, shapes, sizes, textures, and spatial relationships to create vivid and concrete scenes.', '- If the prompt is already detailed, refine and enhance the existing details slightly without overcomplicating.', 'Here are examples of how to transform or refine prompts:', '- User Prompt: A cat sleeping -> Enhanced: A small, fluffy white cat curled up in a round shape, sleeping peacefully on a warm sunny windowsill, surrounded by pots of blooming red flowers.', '- User Prompt: A busy city street -> Enhanced: A bustling city street scene at dusk, featuring glowing street lamps, a diverse crowd of people in colorful clothing, and a double-decker bus passing by towering glass skyscrapers.', 'Please generate only the enhanced description for the prompt below and avoid including any additional commentary or evaluations:', 'User Prompt: '] ) SanaPipelineOutput元組

引數

  • prompt (strList[str], 可選) — 用於引導影像生成的提示詞或提示詞列表。如果未定義,則必須傳入prompt_embeds
  • num_inference_steps (int, 可選, 預設為 20) — 去噪步驟的數量。更多的去噪步驟通常會帶來更高質量的影像,但推理速度會變慢。
  • max_timesteps (float, 可選, 預設為 1.57080) — SCM排程器中使用的最大時間步值。
  • intermediate_timesteps (float, 可選, 預設為 1.3) — SCM排程器中使用的中間時間步值(僅在num_inference_steps=2時使用)。
  • timesteps (List[int], 可選) — 用於去噪過程的自定義時間步,適用於其set_timesteps方法支援timesteps引數的排程器。如果未定義,將使用傳入num_inference_steps時的預設行為。必須按降序排列。
  • guidance_scale (float, 可選, 預設為 4.5) — 在Classifier-Free Diffusion Guidance中定義的引導比例。guidance_scale被定義為Imagen Paper的公式2中的w。透過設定guidance_scale > 1啟用引導比例。較高的引導比例鼓勵生成與文字prompt緊密相關的影像,但通常會犧牲影像質量。
  • num_images_per_prompt (int, 可選, 預設為 1) — 每個提示詞生成的影像數量。
  • height (int, 可選, 預設為 self.unet.config.sample_size) — 生成影像的高度(畫素)。
  • width (int, 可選, 預設為 self.unet.config.sample_size) — 生成影像的寬度(畫素)。
  • eta (float, 可選, 預設為 0.0) — 對應於DDIM論文中的引數eta (η):https://huggingface.co/papers/2010.02502。僅適用於schedulers.DDIMScheduler,對其他排程器將被忽略。
  • generator (torch.GeneratorList[torch.Generator], 可選) — 一個或多個torch生成器,用於使生成過程具有確定性。
  • latents (torch.Tensor, 可選) — 預生成的噪聲潛變數,從高斯分佈中取樣,用作影像生成的輸入。可用於使用不同的提示調整相同的生成。如果未提供,將使用提供的隨機generator取樣生成一個潛變數張量。
  • prompt_embeds (torch.Tensor, 可選) — 預生成的文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,將從prompt輸入引數生成文字嵌入。
  • prompt_attention_mask (torch.Tensor, 可選) — 預生成的文字嵌入的注意力掩碼。
  • output_type (str, 可選, 預設為 "pil") — 生成影像的輸出格式。在PIL: PIL.Image.Imagenp.array之間選擇。
  • return_dict (bool, 可選, 預設為 True) — 是否返回 ~pipelines.stable_diffusion.IFPipelineOutput 而不是普通元組。
  • attention_kwargs — 一個kwargs字典,如果指定,將作為self.processor中定義的AttentionProcessor的引數傳遞,詳見diffusers.models.attention_processor
  • clean_caption (bool, 可選, 預設為 True) — 是否在建立嵌入之前清理標題。需要安裝beautifulsoup4ftfy。如果未安裝依賴項,嵌入將從原始提示建立。
  • use_resolution_binning (bool 預設為 True) — 如果設定為True,請求的高度和寬度將首先使用ASPECT_RATIO_1024_BIN對映到最接近的解析度。生成的潛在變數解碼為影像後,再將其大小調整回請求的解析度。對於生成非正方形影像很有用。
  • callback_on_step_end (Callable, 可選) — 在推理過程中每個去噪步驟結束時呼叫的函式。該函式將使用以下引數呼叫:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)callback_kwargs將包含callback_on_step_end_tensor_inputs中指定的所有張量列表。
  • callback_on_step_end_tensor_inputs (List, 可選) — callback_on_step_end函式的張量輸入列表。列表中指定的張量將作為callback_kwargs引數傳遞。您只能包含管道類._callback_tensor_inputs屬性中列出的變數。
  • max_sequence_length (int 預設為 300) — 用於prompt的最大序列長度。
  • complex_human_instruction (List[str], 可選) — 複雜人類注意力的指令:https://github.com/NVlabs/Sana/blob/main/configs/sana_app_config/Sana_1600M_app.yaml#L55

返回

SanaPipelineOutputtuple

如果 return_dictTrue,則返回 SanaPipelineOutput,否則返回一個 tuple,其中第一個元素是生成的影像列表

呼叫管道進行生成時呼叫的函式。

示例

>>> import torch
>>> from diffusers import SanaSprintPipeline

>>> pipe = SanaSprintPipeline.from_pretrained(
...     "Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.to("cuda")

>>> image = pipe(prompt="a tiny astronaut hatching from an egg on the moon")[0]
>>> image[0].save("output.png")

disable_vae_slicing

< >

( )

停用切片 VAE 解碼。如果之前啟用了 enable_vae_slicing,此方法將返回一步計算解碼。

disable_vae_tiling

< >

( )

停用平鋪 VAE 解碼。如果之前啟用了 enable_vae_tiling,此方法將恢復一步計算解碼。

enable_vae_slicing

< >

( )

啟用切片 VAE 解碼。啟用此選項後,VAE 會將輸入張量分片,分步計算解碼。這有助於節省一些記憶體並允許更大的批次大小。

enable_vae_tiling

< >

( )

啟用平鋪 VAE 解碼。啟用此選項後,VAE 將把輸入張量分割成瓦片,分多步計算編碼和解碼。這對於節省大量記憶體和處理更大的影像非常有用。

encode_prompt

< >

( prompt: typing.Union[str, typing.List[str]] num_images_per_prompt: int = 1 device: typing.Optional[torch.device] = None prompt_embeds: typing.Optional[torch.Tensor] = None prompt_attention_mask: typing.Optional[torch.Tensor] = None clean_caption: bool = False max_sequence_length: int = 300 complex_human_instruction: typing.Optional[typing.List[str]] = None lora_scale: typing.Optional[float] = None )

引數

  • prompt (strList[str], 可選) — 要編碼的提示詞
  • num_images_per_prompt (int, 可選, 預設為 1) — 每個提示詞應生成的影像數量
  • device — (torch.device, 可選): 放置結果嵌入的 torch 裝置
  • prompt_embeds (torch.Tensor, 可選) — 預生成的文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,將從 prompt 輸入引數生成文字嵌入。
  • clean_caption (bool, 預設為 False) — 如果為 True,函式將在編碼前預處理並清理提供的字幕。
  • max_sequence_length (int, 預設為 300) — 用於提示詞的最大序列長度。
  • complex_human_instruction (list[str], 預設為 complex_human_instruction) — 如果 complex_human_instruction 不為空,函式將使用複雜的“人類指令”作為提示詞。

將提示編碼為文字編碼器隱藏狀態。

SanaSprintImg2ImgPipeline

class diffusers.SanaSprintImg2ImgPipeline

< >

( tokenizer: typing.Union[transformers.models.gemma.tokenization_gemma.GemmaTokenizer, transformers.models.gemma.tokenization_gemma_fast.GemmaTokenizerFast] text_encoder: Gemma2PreTrainedModel vae: AutoencoderDC transformer: SanaTransformer2DModel scheduler: DPMSolverMultistepScheduler )

使用SANA-Sprint進行文字到影像生成的管道。

__call__

< >

( prompt: typing.Union[str, typing.List[str]] = None num_inference_steps: int = 2 timesteps: typing.List[int] = None max_timesteps: float = 1.5708 intermediate_timesteps: float = 1.3 guidance_scale: float = 4.5 image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, typing.List[PIL.Image.Image], typing.List[numpy.ndarray], typing.List[torch.Tensor]] = None strength: float = 0.6 num_images_per_prompt: typing.Optional[int] = 1 height: int = 1024 width: int = 1024 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 prompt_attention_mask: typing.Optional[torch.Tensor] = None output_type: typing.Optional[str] = 'pil' return_dict: bool = True clean_caption: bool = False use_resolution_binning: bool = True attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None callback_on_step_end: typing.Optional[typing.Callable[[int, int, typing.Dict], NoneType]] = None callback_on_step_end_tensor_inputs: typing.List[str] = ['latents'] max_sequence_length: int = 300 complex_human_instruction: typing.List[str] = ["Given a user prompt, generate an 'Enhanced prompt' that provides detailed visual descriptions suitable for image generation. Evaluate the level of detail in the user prompt:", '- If the prompt is simple, focus on adding specifics about colors, shapes, sizes, textures, and spatial relationships to create vivid and concrete scenes.', '- If the prompt is already detailed, refine and enhance the existing details slightly without overcomplicating.', 'Here are examples of how to transform or refine prompts:', '- User Prompt: A cat sleeping -> Enhanced: A small, fluffy white cat curled up in a round shape, sleeping peacefully on a warm sunny windowsill, surrounded by pots of blooming red flowers.', '- User Prompt: A busy city street -> Enhanced: A bustling city street scene at dusk, featuring glowing street lamps, a diverse crowd of people in colorful clothing, and a double-decker bus passing by towering glass skyscrapers.', 'Please generate only the enhanced description for the prompt below and avoid including any additional commentary or evaluations:', 'User Prompt: '] ) SanaPipelineOutputtuple

引數

  • prompt (strList[str], 可選) — 用於引導影像生成的提示詞。如果未定義,則必須傳入 prompt_embeds
  • num_inference_steps (int, 可選, 預設為 20) — 去噪步數。更多的去噪步數通常會帶來更高質量的影像,但推理速度會變慢。
  • max_timesteps (float, 可選, 預設為 1.57080) — SCM 排程器中使用的最大時間步值。
  • intermediate_timesteps (float, 可選, 預設為 1.3) — SCM 排程器中使用的中間時間步值(僅當 num_inference_steps=2 時使用)。
  • timesteps (List[int], 可選) — 用於去噪過程的自定義時間步,適用於其 set_timesteps 方法支援 timesteps 引數的排程器。如果未定義,將使用傳入 num_inference_steps 時的預設行為。必須按降序排列。
  • guidance_scale (float, 可選, 預設為 4.5) — 如 Classifier-Free Diffusion Guidance 中定義的引導比例。guidance_scale 定義為 Imagen Paper 方程 2 中的 w。透過設定 guidance_scale > 1 啟用引導比例。更高的引導比例鼓勵生成與文字 prompt 密切相關的影像,通常以犧牲較低影像質量為代價。
  • num_images_per_prompt (int, 可選, 預設為 1) — 每個提示詞要生成的影像數量。
  • height (int, 可選, 預設為 self.unet.config.sample_size) — 生成影像的畫素高度。
  • width (int, 可選, 預設為 self.unet.config.sample_size) — 生成影像的畫素寬度。
  • eta (float, 可選, 預設為 0.0) — 對應於 DDIM 論文中的引數 eta (η):https://arxiv.org/abs/2010.02502。僅適用於 schedulers.DDIMScheduler,對其他排程器將被忽略。
  • generator (torch.GeneratorList[torch.Generator], 可選) — 一個或多個 torch 生成器,用於使生成具有確定性。
  • latents (torch.Tensor, 可選) — 預先生成的噪聲潛像,從高斯分佈中取樣,用作影像生成的輸入。可用於透過不同提示詞調整同一生成。如果未提供,將使用提供的隨機 generator 取樣生成潛像張量。
  • prompt_embeds (torch.Tensor, 可選) — 預生成的文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,文字嵌入將從 prompt 輸入引數生成。
  • prompt_attention_mask (torch.Tensor, 可選) — 文字嵌入的預生成注意力掩碼。
  • output_type (str, 可選, 預設為 "pil") — 生成影像的輸出格式。在 PIL: PIL.Image.Imagenp.array 之間選擇。
  • return_dict (bool, 可選, 預設為 True) — 是否返回 ~pipelines.stable_diffusion.IFPipelineOutput 而不是普通元組。
  • attention_kwargs — 如果指定,將作為 kwargs 字典傳遞給 diffusers.models.attention_processorself.processor 下定義的 AttentionProcessor
  • clean_caption (bool, 可選, 預設為 True) — 是否在建立嵌入前清理字幕。需要安裝 beautifulsoup4ftfy。如果未安裝依賴項,則將從原始提示詞建立嵌入。
  • use_resolution_binning (bool 預設為 True) — 如果設定為 True,請求的高度和寬度將首先使用 ASPECT_RATIO_1024_BIN 對映到最接近的解析度。生成潛像解碼為影像後,將它們的大小調整回請求的解析度。對於生成非方形影像很有用。
  • callback_on_step_end (Callable, 可選) — 在推理過程中每個去噪步驟結束時呼叫的函式。該函式將使用以下引數呼叫:callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict)callback_kwargs 將包含 callback_on_step_end_tensor_inputs 指定的所有張量列表。
  • callback_on_step_end_tensor_inputs (List, 可選) — callback_on_step_end 函式的張量輸入列表。列表中指定的張量將作為 callback_kwargs 引數傳遞。您只能包含管道類 ._callback_tensor_inputs 屬性中列出的變數。
  • max_sequence_length (int 預設為 300) — 與 prompt 一起使用的最大序列長度。
  • complex_human_instruction (List[str], 可選) — 複雜人類注意力的指令:https://github.com/NVlabs/Sana/blob/main/configs/sana_app_config/Sana_1600M_app.yaml#L55

返回

SanaPipelineOutputtuple

如果 return_dictTrue,則返回 SanaPipelineOutput,否則返回一個 tuple,其中第一個元素是生成的影像列表

呼叫管道進行生成時呼叫的函式。

示例

>>> import torch
>>> from diffusers import SanaSprintImg2ImgPipeline
>>> from diffusers.utils.loading_utils import load_image

>>> pipe = SanaSprintImg2ImgPipeline.from_pretrained(
...     "Efficient-Large-Model/Sana_Sprint_1.6B_1024px_diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.to("cuda")

>>> image = load_image(
...     "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/penguin.png"
... )


>>> image = pipe(prompt="a cute pink bear", image=image, strength=0.5, height=832, width=480).images[0]
>>> image[0].save("output.png")

disable_vae_slicing

< >

( )

停用切片 VAE 解碼。如果之前啟用了 enable_vae_slicing,此方法將返回一步計算解碼。

disable_vae_tiling

< >

( )

停用平鋪 VAE 解碼。如果之前啟用了 enable_vae_tiling,此方法將恢復一步計算解碼。

enable_vae_slicing

< >

( )

啟用切片 VAE 解碼。啟用此選項後,VAE 會將輸入張量分片,分步計算解碼。這有助於節省一些記憶體並允許更大的批次大小。

enable_vae_tiling

< >

( )

啟用平鋪 VAE 解碼。啟用此選項後,VAE 將把輸入張量分割成瓦片,分多步計算編碼和解碼。這對於節省大量記憶體和處理更大的影像非常有用。

encode_prompt

< >

( prompt: typing.Union[str, typing.List[str]] num_images_per_prompt: int = 1 device: typing.Optional[torch.device] = None prompt_embeds: typing.Optional[torch.Tensor] = None prompt_attention_mask: typing.Optional[torch.Tensor] = None clean_caption: bool = False max_sequence_length: int = 300 complex_human_instruction: typing.Optional[typing.List[str]] = None lora_scale: typing.Optional[float] = None )

引數

  • prompt (strList[str], 可選) — 要編碼的提示詞
  • num_images_per_prompt (int, 可選, 預設為 1) — 每個提示詞應生成的影像數量
  • device — (torch.device, 可選): 用於放置結果嵌入的torch裝置。
  • prompt_embeds (torch.Tensor, 可選) — 預生成的文字嵌入。可用於輕鬆調整文字輸入,例如提示詞權重。如果未提供,將從 prompt 輸入引數生成文字嵌入。
  • clean_caption (bool, 預設為 False) — 如果為 True,函式將在編碼前預處理並清理提供的標題。
  • max_sequence_length (int, 預設為 300) — 用於提示詞的最大序列長度。
  • complex_human_instruction (list[str], 預設為 complex_human_instruction) — 如果 complex_human_instruction 不為空,函式將使用複雜的人類指令作為提示詞。

將提示編碼為文字編碼器隱藏狀態。

SanaPipelineOutput

class diffusers.pipelines.sana.pipeline_output.SanaPipelineOutput

< >

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

引數

  • images (List[PIL.Image.Image]np.ndarray) — 長度為 batch_size 的去噪 PIL 影像列表或形狀為 (batch_size, height, width, num_channels) 的 numpy 陣列。PIL 影像或 numpy 陣列表示擴散管道的去噪影像。

Sana 管道的輸出類。

< > 在 GitHub 上更新

© . This site is unofficial and not affiliated with Hugging Face, Inc.