Buckets:
| # Flux2 | |
| Flux.2は、Black Forest Labsが最近発表した画像生成モデルのシリーズで、[Flux.1](./flux)シリーズに先立つものです。これは、新しいアーキテクチャを備え、ゼロから事前学習が行われた、まったく新しいモデルです。 | |
| Fluxの元のモデルチェックポイントは[こちら](https://huggingface.co/black-forest-labs)で確認できます。元の推論コードは[こちら](https://github.com/black-forest-labs/flux2)で確認できます。 | |
| > [!TIP] | |
| > Flux2 は、コンシューマー向けハードウェアで実行するとコストが高くなることがあります。ただし、一連の最適化を行うことで、より高速かつメモリ効率の良い実行が可能です。詳細については、[このセクション](https://huggingface.co/blog/sd3#memory-optimizations-for-sd3)を参照してください。また、Flux は量子化によってメモリ効率を向上させることができますが、推論レイテンシとのトレードオフが発生します。詳細については、[このブログ記事](https://huggingface.co/blog/quanto-diffusers)を参照してください。 | |
| > | |
| > [Caching](../../optimization/cache) は、中間出力を保存して再利用することで、推論の高速化にも貢献します。 | |
| ## キャプションのアップサンプリング | |
| Flux.2 は、より良いプロンプトを使用することで、より良い出力を生成する可能性があります。パイプライン呼び出しの引数で `caption_upsample_temperature` 引数を設定することにより、入力プロンプトを「アップサンプリング」できます。[公式実装](https://github.com/black-forest-labs/flux2/blob/5a5d316b1b42f6b59a8c9194b77c8256be848432/src/flux2/text_encoder.py#L140)では、この値を 0.15 とすることを推奨しています。 | |
| ## Flux2Pipeline[[diffusers.Flux2Pipeline]] | |
| #### diffusers.Flux2Pipeline[[diffusers.Flux2Pipeline]] | |
| ```python | |
| diffusers.Flux2Pipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLFlux2, text_encoder: Mistral3ForConditionalGeneration, tokenizer: AutoProcessor, transformer: Flux2Transformer2DModel) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2.py#L251) | |
| **パラメータ:** | |
| transformer ([Flux2Transformer2DModel](/docs/diffusers/main/ja/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel)) : エンコードされた画像潜在変数をデノイズするための条件付き Transformer (MMDiT) アーキテクチャ。 | |
| scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ja/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer` と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。 | |
| vae (`AutoencoderKLFlux2`) : 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ(VAE)モデルです。 | |
| text_encoder (`Mistral3ForConditionalGeneration`) : [Mistral3ForConditionalGeneration](https://huggingface.co/docs/transformers/en/model_doc/mistral3#transformers.Mistral3ForConditionalGeneration) | |
| tokenizer (`AutoProcessor`) : クラス [PixtralProcessor](https://huggingface.co/docs/transformers/en/model_doc/pixtral#transformers.PixtralProcessor) の Tokenizer。 | |
| テキストから画像を生成するためのFlux2パイプライン。 | |
| 参考: [https://bfl.ai/blog/flux-2](https://bfl.ai/blog/flux-2) | |
| #### __call__[[diffusers.Flux2Pipeline.__call__]] | |
| ```python | |
| __call__(image: PIL.Image.Image | list[PIL.Image.Image] | None = None, prompt: str | list[str] = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, sigmas: list[float] | None = None, guidance_scale: float | None = 4.0, num_images_per_prompt: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, text_encoder_out_layers: tuple[int] = (10, 20, 30), caption_upsample_temperature: float = None) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2.py#L746) | |
| **パラメータ:** | |
| image (`torch.Tensor`、`PIL.Image.Image`、`np.ndarray`、`list[torch.Tensor]`、`list[PIL.Image.Image]`、または `list[np.ndarray]`) : `Image`、numpy 配列、またはテンソル。開始点として使用される画像バッチを表します。numpy 配列および PyTorch テンソルの場合、想定される値の範囲は `[0, 1]` です。テンソルまたはテンソルのリストの場合、想定される形状は `(B, C, H, W)` または `(C, H, W)` です。numpy 配列または配列のリストの場合、想定される形状は `(B, H, W, C)` または `(H, W, C)` です。`image` として画像の潜在変数(latents)を受け取ることもできますが、潜在変数を直接渡す場合は、再度エンコードされません。 | |
| prompt (`str` または `list[str]`、*省略可*) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに `prompt_embeds` を渡す必要があります。 | |
| guidance_scale (`float`、*任意*、デフォルト値は 1.0) : `guidance_scale` > 1 に設定することで、埋め込み型 guidance scale が有効になります。`guidance_scale` を高くすると、`prompt` により一貫性のある画像を生成するようモデルを促しますが、画像の品質が低下する可能性があります。Guidance-distilled モデルは、`guidance_scale` > 1 の場合に、真の classifer-free guidance を近似します。詳細については、[論文](https://huggingface.co/papers/2210.03142)を参照してください。 | |
| height (`int`、*任意*、デフォルトは self.unet.config.sample_size * self.vae_scale_factor) : 生成される画像のピクセル単位の縦幅。最適な結果を得るため、デフォルトでは 1024 に設定されています。 | |
| width (`int`、*任意*、デフォルトは self.unet.config.sample_size * self.vae_scale_factor) : 生成される画像の幅(ピクセル単位)。最適な結果を得るため、デフォルトでは 1024 に設定されています。 | |
| num_inference_steps (`int`、*任意*、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 | |
| sigmas (`list[float]`, *任意*) : `set_timesteps` メソッドで `sigmas` 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムシグマ。`num_inference_steps` が渡された場合のデフォルトの動作が使用されます。 | |
| num_images_per_prompt (`int`、*任意*、デフォルトは 1) : プロンプトごとに生成する画像の数。 | |
| generator (`torch.Generator` または `list[torch.Generator]`、*任意*) : 生成を決定論的にするための [torch ジェネレーター](https://pytorch.org/docs/stable/generated/torch.Generator.html) 1 つまたはそのリスト。 | |
| latents (`torch.Tensor`, *任意*) : イメージ生成の入力として使用される、ガウス分布からサンプリングされた事前生成されたノイジー・ラテンツ。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムな`generator`を使用してサンプリングを行い、ラテンツのテンソルが生成されます。 | |
| prompt_embeds (`torch.Tensor`, *任意*) : 事前生成されたテキスト埋め込み。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`prompt` 入力引数からテキスト埋め込みが生成されます。 | |
| output_type (`str`、*任意*、デフォルトは `"pil"`) : 生成画像の出力形式。[PIL](https://pillow.readthedocs.io/en/stable/)(`PIL.Image.Image`)または `np.array` から選択します。 | |
| return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`~pipelines.qwenimage.QwenImagePipelineOutput`を返すかどうか。 | |
| attention_kwargs (`dict`, *任意*) : 指定された場合、[diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py) の `self.processor` で定義されている `AttentionProcessor` に渡される kwargs の辞書です。 | |
| 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`、デフォルトは 512) : `prompt` に使用する最大シーケンス長。 | |
| text_encoder_out_layers (`tuple[int]`) : `text_encoder`内で最終的なプロンプト埋め込みを導出するために使用するレイヤーのインデックス。 | |
| caption_upsample_temperature (`float`) : 指定した場合、出力の向上を目的としてキャプションのアップサンプリングを試みます。キャプションのアップサンプリングを行う場合は、0.15に設定することを推奨します。 | |
| **戻り値:** `~pipelines.flux2.Flux2PipelineOutput` または `tuple` | |
| `return_dict` が True の場合は `~pipelines.flux2.Flux2PipelineOutput`、それ以外の場合は `tuple` を返します。tuple を返す場合、最初の要素は生成された画像のリストです。 | |
| 生成用のパイプラインを呼び出したときに実行される関数。 | |
| 例: | |
| ```py | |
| >>> import torch | |
| >>> from diffusers import Flux2Pipeline | |
| >>> pipe = Flux2Pipeline.from_pretrained("black-forest-labs/FLUX.2-dev", torch_dtype=torch.bfloat16) | |
| >>> pipe.to("cuda") | |
| >>> prompt = "A cat holding a sign that says hello world" | |
| >>> # Depending on the variant being used, the pipeline call will slightly vary. | |
| >>> # Refer to the pipeline documentation for more details. | |
| >>> image = pipe(prompt, num_inference_steps=50, guidance_scale=2.5).images[0] | |
| >>> image.save("flux.png") | |
| ``` | |
| ## Flux2KleinPipeline[[diffusers.Flux2KleinPipeline]] | |
| #### diffusers.Flux2KleinPipeline[[diffusers.Flux2KleinPipeline]] | |
| ```python | |
| diffusers.Flux2KleinPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLFlux2, text_encoder: Qwen3ForCausalLM, tokenizer: Qwen2Tokenizer, transformer: Flux2Transformer2DModel, is_distilled: bool = False) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2_klein.py#L155) | |
| **パラメータ:** | |
| transformer ([Flux2Transformer2DModel](/docs/diffusers/main/ja/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel)) : エンコードされた画像潜在変数をデノイズするための条件付き Transformer (MMDiT) アーキテクチャ。 | |
| scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ja/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer` と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。 | |
| vae (`AutoencoderKLFlux2`) : 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ(VAE)モデルです。 | |
| text_encoder (`Qwen3ForCausalLM`) : [Qwen3ForCausalLM](https://huggingface.co/docs/transformers/en/model_doc/qwen3#transformers.Qwen3ForCausalLM) | |
| tokenizer (`Qwen2TokenizerFast`) : クラス [Qwen2TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/qwen2#transformers.Qwen2TokenizerFast) の Tokenizer。 | |
| テキストから画像を生成するためのFlux2 Kleinパイプライン。 | |
| 参考: [https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence](https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence) | |
| #### __call__[[diffusers.Flux2KleinPipeline.__call__]] | |
| ```python | |
| __call__(image: list[PIL.Image.Image] | PIL.Image.Image | None = None, prompt: str | list[str] = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, sigmas: list[float] | None = None, guidance_scale: float = 4.0, num_images_per_prompt: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: str | list[str] | None = None, output_type: str = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int, dict], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, text_encoder_out_layers: tuple[int] = (9, 18, 27)) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2_klein.py#L614) | |
| **パラメータ:** | |
| image (`torch.Tensor`、`PIL.Image.Image`、`np.ndarray`、`List[torch.Tensor]`、`List[PIL.Image.Image]`、または `List[np.ndarray]`) : `Image`、numpy 配列、またはテンソル。開始点として使用される画像のバッチを表します。numpy 配列および PyTorch テンソルの場合、想定される値の範囲は `[0, 1]` です。テンソルまたはテンソルのリストの場合、想定される形状は `(B, C, H, W)` または `(C, H, W)` です。numpy 配列または配列のリストの場合、想定される形状は `(B, H, W, C)` または `(H, W, C)` です。`image` として画像の潜在変数(latents)を受け取ることもできますが、潜在変数を直接渡す場合は、再度エンコードされません。 | |
| prompt (`str` または `List[str]`、*任意*) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに `prompt_embeds` を渡す必要があります。 | |
| guidance_scale (`float`、*任意*、デフォルト値は 4.0) : [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598) で定義されているガイダンススケールです。`guidance_scale` は、[Imagen Paper](https://huggingface.co/papers/2205.11487) の数式 2 の `w` として定義されています。`guidance_scale > 1` を設定することで、ガイダンススケールが有効になります。ガイダンススケールを高くすると、`prompt` のテキストと密接に関連した画像の生成が促されますが、通常は画像の品質が低下する傾向があります。ステップワイズ蒸留モデルの場合、`guidance_scale` は無視されます。 | |
| height (`int`、*任意*、デフォルトは self.unet.config.sample_size * self.vae_scale_factor) : 生成される画像のピクセル単位の縦幅。最適な結果を得るため、デフォルトでは 1024 に設定されています。 | |
| width (`int`、*任意*、デフォルトは self.unet.config.sample_size * self.vae_scale_factor) : 生成される画像の幅(ピクセル単位)。最適な結果を得るため、デフォルトでは 1024 に設定されています。 | |
| num_inference_steps (`int`、*任意*、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常はより高品質な画像が得られます。 | |
| sigmas (`List[float]`, *任意*) : `set_timesteps` メソッドで `sigmas` 引数をサポートするスケジューラーにおいて、デノイジングプロセスに使用するカスタムシグマ。`num_inference_steps` が渡された場合のデフォルトの動作が使用されます。 | |
| num_images_per_prompt (`int`、*任意*、デフォルトは 1) : プロンプトごとに生成する画像の数。 | |
| generator (`torch.Generator` または `List[torch.Generator]`、*任意*) : 生成を決定論的にするための [torch ジェネレーター](https://pytorch.org/docs/stable/generated/torch.Generator.html) 1 つまたはそのリスト。 | |
| latents (`torch.Tensor`, *任意*) : イメージ生成の入力として使用される、ガウス分布からサンプリングされた事前生成されたノイジー・ラテンツ。異なるプロンプトで同じ生成を調整するために使用できます。指定されない場合、指定されたランダムな`generator`を使用してサンプリングを行い、ラテンツのテンソルが生成されます。 | |
| prompt_embeds (`torch.Tensor`, *任意*) : 事前生成されたテキスト埋め込み。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`prompt` 入力引数からテキスト埋め込みが生成されます。 | |
| negative_prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたネガティブなテキスト埋め込み。このパイプラインでは、"" がネガティブプロンプトとして使用されます。指定されない場合、"" から生成されます。 | |
| output_type (`str`、*任意*、デフォルトは `"pil"`) : 生成画像の出力形式。[PIL](https://pillow.readthedocs.io/en/stable/)(`PIL.Image.Image`)または `np.array` から選択します。 | |
| return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく`~pipelines.qwenimage.QwenImagePipelineOutput`を返すかどうか。 | |
| attention_kwargs (`dict`, *任意*) : 指定された場合、[diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py) の `self.processor` で定義されている `AttentionProcessor` に渡される kwargs の辞書です。 | |
| 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`、デフォルトは 512) : `prompt` に使用する最大シーケンス長。 | |
| text_encoder_out_layers (`tuple[int]`) : `text_encoder`内で最終的なプロンプト埋め込みを導出するために使用するレイヤーのインデックス。 | |
| **戻り値:** `~pipelines.flux2.Flux2PipelineOutput` または `tuple` | |
| `return_dict` が True の場合は `~pipelines.flux2.Flux2PipelineOutput`、それ以外の場合は `tuple` を返します。tuple を返す場合、最初の要素は生成された画像のリストです。 | |
| 生成用のパイプラインを呼び出したときに実行される関数。 | |
| 例: | |
| ```py | |
| >>> import torch | |
| >>> from diffusers import Flux2KleinPipeline | |
| >>> pipe = Flux2KleinPipeline.from_pretrained( | |
| ... "black-forest-labs/FLUX.2-klein-base-9B", torch_dtype=torch.bfloat16 | |
| ... ) | |
| >>> pipe.to("cuda") | |
| >>> prompt = "A cat holding a sign that says hello world" | |
| >>> # Depending on the variant being used, the pipeline call will slightly vary. | |
| >>> # Refer to the pipeline documentation for more details. | |
| >>> image = pipe(prompt, num_inference_steps=50, guidance_scale=4.0).images[0] | |
| >>> image.save("flux2_output.png") | |
| ``` | |
| ## Flux2KleinKVPipeline[[diffusers.Flux2KleinKVPipeline]] | |
| #### diffusers.Flux2KleinKVPipeline[[diffusers.Flux2KleinKVPipeline]] | |
| ```python | |
| diffusers.Flux2KleinKVPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLFlux2, text_encoder: Qwen3ForCausalLM, tokenizer: Qwen2Tokenizer, transformer: Flux2Transformer2DModel, is_distilled: bool = True) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2_klein_kv.py#L155) | |
| **パラメータ:** | |
| transformer ([Flux2Transformer2DModel](/docs/diffusers/main/ja/api/models/flux2_transformer#diffusers.Flux2Transformer2DModel)) : エンコードされた画像潜在変数をデノイズするための条件付き Transformer (MMDiT) アーキテクチャ。 | |
| scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ja/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer` と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。 | |
| vae (`AutoencoderKLFlux2`) : 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ(VAE)モデルです。 | |
| text_encoder (`Qwen3ForCausalLM`) : [Qwen3ForCausalLM](https://huggingface.co/docs/transformers/en/model_doc/qwen3#transformers.Qwen3ForCausalLM) | |
| tokenizer (`Qwen2TokenizerFast`) : クラス [Qwen2TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/qwen2#transformers.Qwen2TokenizerFast) の Tokenizer。 | |
| KVキャッシュ付きの参照画像条件付けによるテキストから画像への生成を行うFlux2 Klein KVパイプライン。 | |
| 最初のノイズ除去ステップでは、参照画像のトークンがフォワードパスに含められ、そのアテンションのK/Vプロジェクションがキャッシュされます。その後のステップでは、再計算せずにキャッシュされたK/Vが再利用されるため、参照画像を使用する場合に推論が高速になります。 | |
| 参考: [https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence](https://bfl.ai/blog/flux2-klein-towards-interactive-visual-intelligence) | |
| #### __call__[[diffusers.Flux2KleinKVPipeline.__call__]] | |
| ```python | |
| __call__(image: list[PIL.Image.Image] | PIL.Image.Image | None = None, prompt: str | list[str] = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 4, sigmas: list[float] | None = None, num_images_per_prompt: int = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, output_type: str = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int, dict], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 512, text_encoder_out_layers: tuple[int] = (9, 18, 27)) | |
| ``` | |
| [ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/flux2/pipeline_flux2_klein_kv.py#L610) | |
| **パラメータ:** | |
| image (`PIL.Image.Image` または `List[PIL.Image.Image]`、*任意*) : 条件付け用の参照画像。最初のデノイジングステップでは、参照トークンがフォワードパスに含められ、そのアテンションの K/V がキャッシュされます。以降のステップでは、再計算せずにキャッシュされた K/V が再利用されます。 | |
| prompt (`str` または `List[str]`、*省略可能*) : 画像生成をガイドするためのプロンプトまたはプロンプトのリスト。 | |
| height (`int`, *任意*) : 生成される画像のピクセル単位の縦幅。 | |
| width (`int`, *optional*) : 生成される画像の幅(ピクセル単位)。 | |
| num_inference_steps (`int`、*optional*、デフォルトは 4) : デノイジングのステップ数です。 | |
| sigmas (`List[float]`, *任意*) : デノイジングスケジュール用のカスタムシグマ。 | |
| num_images_per_prompt (`int`、*任意*、デフォルトは 1) : プロンプトごとに生成する画像の数。 | |
| generator (`torch.Generator` または `List[torch.Generator]`、*任意*) : 決定論的な生成を行うためのジェネレーター。 | |
| latents (`torch.Tensor`, *任意*) : 事前生成されたノイズ付き潜在変数。 | |
| prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。 | |
| output_type (`str`、*任意*、デフォルトは`"pil"`) : 出力形式: `"pil"`または`"np"`。 | |
| return_dict (`bool`、*任意*、デフォルトは`True`) : `Flux2PipelineOutput`を返すか、通常のタプルを返すかを指定します。 | |
| attention_kwargs (`dict`, *任意*) : attention プロセッサに渡す追加の kwargs。 | |
| callback_on_step_end (`Callable`, *任意*) : 各デノイジングステップの終了時に呼び出されるコールバック関数。 | |
| callback_on_step_end_tensor_inputs (`List`、*任意*) : コールバック関数へのTensor入力。 | |
| max_sequence_length (`int`、デフォルトは 512) : プロンプトの最大シーケンス長。 | |
| text_encoder_out_layers (`tuple[int]`) : テキストエンコーダーの隠れ状態を抽出するためのレイヤーのインデックス。 | |
| **戻り値:** | |
| `~pipelines.flux2.Flux2PipelineOutput` または `tuple`。 | |
| 生成用のパイプラインを呼び出したときに実行される関数。 | |
| 例: | |
| ```py | |
| >>> import torch | |
| >>> from PIL import Image | |
| >>> from diffusers import Flux2KleinKVPipeline | |
| >>> pipe = Flux2KleinKVPipeline.from_pretrained( | |
| ... "black-forest-labs/FLUX.2-klein-9b-kv", torch_dtype=torch.bfloat16 | |
| ... ) | |
| >>> pipe.to("cuda") | |
| >>> ref_image = Image.open("reference.png") | |
| >>> image = pipe("A cat dressed like a wizard", image=ref_image, num_inference_steps=4).images[0] | |
| >>> image.save("flux2_kv_output.png") | |
| ``` | |
Xet Storage Details
- Size:
- 27.2 kB
- Xet hash:
- caebc5da1904d8291ae10468592d871fa14f23f46ddb2e78d62e1174efa84560
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.