Diffusers documentation

NucleusMoE-Image

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

NucleusMoE-Image

NucleusMoE-Image は、単一ストリームの DiT に Mixture-of-Experts フィードフォワード層、Qwen3-VL テキストエンコーダーへのクロスアテンション、および flow-matching Euler 離散スケジューラーを組み合わせるテキストから画像を生成するモデルです。

スケジューラーのトレードオフ、すなわち速度と品質のバランスをどのように探求するかを学ぶには、ガイドを必ずご確認ください。また、同じコンポーネントを複数のパイプラインに効率的に読み込む方法については、パイプライン間でコンポーネントを再利用するセクションを参照してください。

NucleusMoEImagePipeline

class diffusers.NucleusMoEImagePipeline

< >

( transformer: NucleusMoEImageTransformer2DModelscheduler: FlowMatchEulerDiscreteSchedulervae: AutoencoderKLQwenImagetext_encoder: Qwen3VLForConditionalGenerationprocessor: Qwen3VLProcessor )

パラメータ

  • transformer (NucleusMoEImageTransformer2DModel) — エンコードされた画像潜在変数に対するノイズ除去を行う、条件付き Transformer (MMDiT) アーキテクチャ。
  • scheduler (FlowMatchEulerDiscreteScheduler) — transformer と組み合わせて、エンコードされた画像の潜在変数からノイズを除去するために使用するスケジューラ。
  • vae (AutoencoderKLQwenImage) — 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ(VAE)モデル。
  • text_encoder (Qwen3VLForConditionalGeneration) — プロンプト埋め込みを計算するためのテキストエンコーダー。
  • processor (Qwen3VLProcessor) — テキスト入力をトークン化するためのプロセッサです。

NucleusMoE を使用したテキストから画像への生成を行う Pipeline。

このパイプラインは、単一ストリームのDiTとMixture-of-Expertsフィードフォワード層、Qwen3-VLテキストエンコーダーへのクロスアテンション、およびflow-matching Euler離散スケジューラを使用しています。

__call__

< >

( prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneguidance_scale: float = 4.0height: int | None = Nonewidth: int | None = Nonenum_inference_steps: int = 50sigmas: list[float] | None = Nonenum_images_per_prompt: int = 1max_sequence_length: int | None = Nonereturn_index: int | None = Nonegenerator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_embeds_mask: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds_mask: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'pil'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Optional[typing.Callable[[int, int, dict], NoneType]] = Nonecallback_on_step_end_tensor_inputs: list[str] = ['latents'] ) → NucleusMoEImagePipelineOutput or tuple

パラメータ

  • prompt (str または list[str]、任意) — 画像生成を導くプロンプトです。未定義の場合、prompt_embeds を渡す必要があります。
  • negative_prompt (str または list[str]、省略可) — 画像生成をガイドしないプロンプトです。定義されていない場合、true_cfg_scale > 1 のときは空の文字列が使用されます。
  • guidance_scale (float、任意、デフォルト値は 4.0)— Classifier-free guidance のスケールです。1 より大きい値を設定すると、CFG が有効になります。
  • return_index (int, 省略可) — プロンプト埋め込みに使用するテキストエンコーダーの出力のレイヤーインデックスです。
  • height (int、任意、デフォルトは self.default_sample_size * self.vae_scale_factor) — 生成される画像のピクセル単位の縦幅。
  • width (int、任意、デフォルトは self.default_sample_size * self.vae_scale_factor) — 生成される画像の幅(ピクセル単位)。
  • num_inference_steps (int、任意、デフォルト値は 50)— デノイジングのステップ数です。
  • sigmas (list[float]、任意) — デノイジングスケジュール用のカスタムシグマ。未定義の場合、線形スケジュールが使用されます。
  • num_images_per_prompt (int、任意、デフォルトは 1) — プロンプトごとに生成する画像の数。
  • generator (torch.Generator または list[torch.Generator]、省略可) — 生成を決定論的にするための torch ジェネレーター 1 つまたはリスト。
  • latents (torch.Tensor, 任意) — 画像生成の入力として使用する、事前生成されたノイズ付き潜在変数。
  • prompt_embeds (torch.Tensor, 任意) — 事前に生成されたテキスト埋め込み。
  • prompt_embeds_mask (torch.Tensor, 任意) — 事前生成されたテキスト埋め込み用のアテンションマスク。
  • negative_prompt_embeds (torch.Tensor, 任意) — 事前に生成されたネガティブテキストの埋め込みです。
  • negative_prompt_embeds_mask (torch.Tensor, 任意) — 事前生成されたネガティブテキスト埋め込み用のアテンションマスク。
  • output_type (str、任意、デフォルトは "pil") — 生成された画像の出力形式です。"pil"、"np"、または "latent" から選択してください。
  • return_dict (bool、省略可能、デフォルトは True) — NucleusMoEImagePipelineOutput を返すか、プレーンなタプルを返すかを指定します。
  • attention_kwargs (dict、省略可) — attention プロセッサに渡される Kwargs。
  • callback_on_step_end (Callable, 省略可) — 各デノイジングステップの終了時に呼び出される関数です。
  • callback_on_step_end_tensor_inputs (list、任意) — callback_on_step_end 関数へのテンソル入力です。
  • max_sequence_length (int、デフォルト値は 512) — テキストプロンプトの最大シーケンス長。

戻り値

NucleusMoEImagePipelineOutput または tuple

return_dict が True の場合は NucleusMoEImagePipelineOutput、それ以外の場合は tuple が返され、その最初の要素は生成された画像のリストです。

生成用のパイプラインを呼び出したときに実行される関数。

例:

>>> import torch
>>> from diffusers import NucleusMoEImagePipeline

>>> pipe = NucleusMoEImagePipeline.from_pretrained("NucleusAI/NucleusMoE-Image", torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")
>>> prompt = "A cat holding a sign that says hello world"
>>> image = pipe(prompt, num_inference_steps=50).images[0]
>>> image.save("nucleus_moe.png")

encode_prompt

< >

( prompt: str | list[str] = Nonedevice: typing.Optional[torch.device] = Nonenum_images_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Noneprompt_embeds_mask: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int | None = Nonereturn_index: int | None = None )

パラメータ

  • prompt (str または list[str]、省略可) — エンコードするプロンプトです。
  • device (torch.device、省略可) — 結果のテンソルに使用する Torch デバイス。
  • num_images_per_prompt (int、デフォルトは 1) — プロンプトごとに生成する画像の数。
  • prompt_embeds (torch.Tensor, 任意) — 事前に生成されたテキスト埋め込みです。指定された場合、エンコーディングをスキップします。
  • prompt_embeds_mask (torch.Tensor, 任意) — 事前生成された埋め込み用のアテンションマスクです。
  • max_sequence_length (int、デフォルト値は 1024) — エンコードされたプロンプトの最大トークン長。

Qwen3-VLのテキストエンコーダーを使用して、テキストプロンプトを埋め込みベクトルに変換します。

NucleusMoEImagePipelineOutput

class diffusers.pipelines.nucleusmoe_image.pipeline_output.NucleusMoEImagePipelineOutput

< >

( images: 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 配列は、拡散パイプラインによってノイズ除去された画像を表します。

NucleusMoE Image パイプライン用の出力クラスです。

Update on GitHub