Buckets:

mishig's picture
|
download
raw
32.1 kB
#
# Apache License, Version 2.0(「ライセンス」)の下でライセンスされています。
# このファイルは、ライセンスに準拠した場合にのみ使用できます。
# ライセンスのコピーは以下から入手できます
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# 適用される法律で要求される場合、または書面による合意がある場合を除き、ソフトウェア
# ライセンスに基づき配布される本ソフトウェアは、「現状のまま」
# 明示的または黙示的を問わず、いかなる種類の保証や条件も付随しません。
# 権限を管理する特定の言語については、ライセンスを参照してください。
# ライセンスの下での制限。-->
# FLUX 3 Image Klein
FLUX 3 Image Klein は、Black Forest Labs による 5.6B パラメータの画像生成モデルです。単一の Transformer([Flux3Transformer2DModel](/docs/diffusers/main/ja/api/models/flux3_transformer#diffusers.Flux3Transformer2DModel))が、テキストプロンプトから、単独または 1 つ以上の参照画像と組み合わせて画像を生成します。テキストの条件付けは Qwen3-VL から取得され、画像には FLUX.2 packed autoencoder(`AutoencoderKLFlux2`)が使用されます。
FLUX 3 Image Klein は [モジュール型パイプライン](../../modular_diffusers/overview)として提供されています。テキストから画像を生成する処理から始めましょう:
```python
import torch
from diffusers import ModularPipeline
pipe = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein-base")
pipe.load_components(dtype={"vae": torch.float32, "default": torch.bfloat16})
pipe.to("cuda")
image = pipe(
prompt="A red fox in a snow-covered forest clearing at golden hour",
generator=torch.Generator().manual_seed(0),
output="images",
)[0]
image.save("fox.png")
```
`prompt` は唯一必須の入力です。パイプラインは推奨されるサンプリング設定(ステップ数 50、guidance scale 3.5、scheduler shift 6.93)を保持し、デフォルトでは 1024 x 1024 の画像を生成します。1 回の呼び出しにつき 1 つのプロンプトを受け取ります。同じプロンプトで複数の画像を生成するには、`num_images_per_prompt` を使用してください。
上記の例に示すように、`DiffusionPipeline` とは少し異なります。読み込みは遅延実行です。[from_pretrained()](/docs/diffusers/main/ja/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained) はパイプラインを構築するだけで、重みの読み込みには [load_components()](/docs/diffusers/main/ja/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components) を呼び出します。呼び出しはパイプラインの状態を返し、`output` で必要なものを指定します。ここでは `output="images"` ですが、プロンプトアップサンプラーが生成したキャプションも取得するには `output=["images", "prompt"]` とします。
> [!TIP]
> 初めて`ModularPipeline`を使用される場合は、[クイックスタート](../../modular_diffusers/quickstart)をお読みください。標準的なパイプラインに精通している場合は、[DiffusionPipelineからの移行](../../modular_diffusers/coming_from_diffusion_pipeline)も参照してください。読み込みと出力のほかに、[ガイダンス](#guidance-scale)、[コールバック](#per-step-callbacks)、[オフローディング](#memory)の3点についても、動作が異なります。
## プロンプトのアップサンプリング
プロンプトの重要性: FLUX 3 Image Klein は、短いプロンプトではなく、被写体、構図、ライティング、雰囲気を記述した完全なシーンキャプションを要求します。そのまま入力された短いリクエストでは、汎用的な出力しか得られません。そのため、このパイプラインでは、テキストから画像生成や編集を問わず、すべてのリクエストに対して最初にプロンプトアップサンプラーを実行します。これは Black Forest Labs による別個の 9B モデル ([black-forest-labs/flux-3-image-klein-pup](https://huggingface.co/black-forest-labs/flux-3-image-klein-pup)) で、テキストエンコーダーに渡す前に `prompt` をそのようなキャプションに拡張します。したがって、短いプロンプトを入力するだけで十分です。
プロンプトアップサマーは、短いリクエストと、編集時の参照画像を、モデルが受け取る完全なシーンキャプションに変換します。キャプションには、ミディアムとスタイル、シーン、ライティングとカメラ、各被写体の色・素材・フレーム内での位置が含まれます。1つのモデルで、テキストから画像への生成、参照画像を用いた編集、ボックスを用いたレイアウトに対応します。生成されたキャプションは`prompt`出力として返されます。上記の例では、画像と一緒にリクエストすることで、画像モデルが受け取った内容を確認できます。
```python
out = pipe(
prompt="A red fox in a snow-covered forest clearing at golden hour",
generator=torch.Generator().manual_seed(0),
output=["images", "prompt"],
)
print(out["prompt"])
```
```
Full-color outdoor wildlife photograph taken from a low eye-level perspective in a snow-covered forest clearing at golden hour. In the center foreground, a red fox stands in profile facing left, its body turned toward the viewer and its head raised as it looks across the clearing. The fox has dense rust-red winter fur, a white throat and chest, black lower legs, pointed ears with dark tips, and a long bushy tail ending in white. ...
```
キャプション全体は約240語に及びます。`max_new_tokens`はキャプションの長さを制限します(デフォルト値は3584)。
ステップの`doc`を出力すると、そのステップが受け取る引数と書き出す内容を確認できます。
```python
print(pipe.blocks.sub_blocks["prompt_upsampler"].doc)
```
```
Inputs:
prompt (`str`):
The edit instruction to expand into the full caption (one per call).
image (`Image | list`, *optional*):
The reference image(s) of the edit, at most 10; the same ones the pipeline receives.
boxes (`list`, *optional*):
Layout boxes, each {'id', 'desc', 'from', 'src_bbox', 'tgt_bbox'} with the boxes as [y_min, x_min, y_max, x_max] in
0-1: ...
max_new_tokens (`int`, *optional*, defaults to 3584):
The most tokens the upsampler may generate for the caption.
Outputs:
prompt (`str`):
The full caption, replacing the request.
```
パイプラインの他のブロックと同様に、`prompt_upsampler`ブロックも単独で実行されます。推奨される方法は、ブロックからこれをポップアウトすることです。ポップアウトされたブロックはスタンドアロンのアップサンプラーとなり、残りのブロックは、拡張されたキャプションを`prompt`として受け取るパイプラインになります。
```python
blocks = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein-base").blocks
pup_block = blocks.sub_blocks.pop("prompt_upsampler")
pup = pup_block.init_pipeline("black-forest-labs/flux-3-image-klein-base")
pup.load_components(dtype=torch.bfloat16)
pup.to("cuda")
caption = pup(prompt="A red fox in a snow-covered forest clearing at golden hour", output="prompt")
pipe = blocks.init_pipeline("black-forest-labs/flux-3-image-klein-base")
pipe.load_components(dtype={"vae": torch.float32, "default": torch.bfloat16})
pipe.to("cuda")
image = pipe(prompt=caption, generator=torch.Generator().manual_seed(0), output="images")[0]
```
この方式により、アップサマーを独立したステージとして、専用の GPU 上で、または専用のエンドポイントの背後で提供できます。UI では、アップサマーが生成したキャプションを表示し、生成前にユーザーが編集できるようにします。アップサマーの代わりに他の LLM を使用することも可能で、システムプロンプトは同じです。アップサマーのリポジトリから `system_prompts["t2i"]`(または、ユーザーメッセージの先頭に参照画像を配置する `"i2i"`)をシステムプロンプトとして、リクエストをユーザーメッセージとして渡します。返されたキャプションを `prompt` として `pipe` に渡してください。
## 画像から画像へ
`image` に 1 つ以上の参照画像を渡します。参照が 1 つの場合は、画像全体が保持されます。4 メガピクセルを超える場合のみ縮小され、16 ピクセルのグリッドにパディングされ、生成サイズはデフォルトでそのサイズに設定されるため、編集結果は入力と同じサイズで返されます。参照が複数ある場合は、それぞれ 1 メガピクセル以下に調整され、グリッドに合わせてクロップされ、生成サイズはデフォルトで最初の参照のサイズに設定されます。指定した `height`/`width` がデフォルトを上書きします。*ターゲット* 画像は、1 行の指示ではなく、編集内容を組み込んだ参照画像の完全なキャプションとして記述するか、[プロンプトアップサンプラー](#prompt-upsampling) に指示と参照から記述させます:
```python
night = pipe(
prompt="the same scene at night under a full moon",
image=image,
generator=torch.Generator().manual_seed(0),
output=["images", "prompt"],
)
```
複数の参照画像がある場合は、`image` に渡された順序に従って、1 枚目の画像、2 枚目の画像、…と呼びます。キャプションでは、画像モデルに対して `<ref_image_0>`、`<ref_image_1>`、…と名前を付けます。
```python
combined = pipe(
prompt="the fox from the first image sitting on the wooden bench from the second image",
image=[image, bench],
height=768,
width=1360,
output="images",
)[0]
```
`height` および/または `width` を渡すことで、導出されたサイズを上書きできます。
## レイアウトの制御
コンテンツを明示的に配置するには、`boxes` を渡します。各要素について、`id`、短い `desc`、および 0〜1 の範囲で左上を原点とする `bbox`(`[y_min, x_min, y_max, x_max]`)を指定します。これにより、出力サイズに依存しないようになります。アップサンプラーはそれらの周囲にキャプションを書き込み、各要素を `<id>` として参照し、ボックスの表を末尾に追加します。指定したボックスはそのまま保持されます。
```python
boxes = [
{"id": "balloon_1", "desc": "a red and yellow striped hot-air balloon", "bbox": [0.08, 0.06, 0.48, 0.38]},
{"id": "balloon_2", "desc": "a small blue hot-air balloon", "bbox": [0.20, 0.62, 0.42, 0.80]},
]
out = pipe(prompt="hot-air balloons over a green valley at sunrise", boxes=boxes, output=["images", "prompt"])
```
編集時、ボックスは`from`によってソースを指定します。`"target"`に`tgt_bbox`を指定すると、そこに新しい要素が追加され、`"ref_image_0"`に`src_bbox`と`tgt_bbox`を指定すると、その参照画像の要素が移動します(ボックスが同じ場合は、その場で保持されます)。
```python
boxes = [{"id": "cactus", "desc": "a small potted cactus", "from": "target", "src_bbox": None, "tgt_bbox": [0.55, 0.62, 0.85, 0.85]}]
out = pipe(prompt="add a small potted cactus in the marked spot", image=mug, boxes=boxes, output=["images", "prompt"])
boxes = [{"id": "knight", "desc": "the knight figure", "from": "ref_image_0", "src_bbox": [0.50, 0.15, 0.85, 0.35], "tgt_bbox": [0.19, 0.06, 0.54, 0.26]}]
out = pipe(prompt="move the knight up and to the left, keep the rest unchanged", image=knight, boxes=boxes, output=["images", "prompt"])
```
画像モデルが読み取るキャプションには、テキスト内の要素が`<id>`でタグ付けされ、テーブルがJSON形式で付加されています。ボックスは0〜1000のキャンバス上に配置されます。`prompt`の出力を表示すると、その内容を確認できます。手動でその形式で記述されたキャプションは、[Prompt upsampling](#prompt-upsampling)と同様に、このステップなしでパイプラインに渡されます。
## ガイダンススケール
パイプラインは`guider`コンポーネントを介してclassifier-free guidanceを適用し、呼び出し時に`guidance_scale`引数を受け取りません。デフォルトのguiderは`guidance_scale=3.5`の[ClassifierFreeGuidance](/docs/diffusers/main/ja/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance)であり、これは両方のワークフローに推奨される設定です。変更するには、guiderの更新されたコピーを作成します。
```python
pipe.guider = pipe.guider.new(guidance_scale=5.0)
```
別のガイダンス手法に切り替えるには、[ガイダーのガイド](../../using-diffusers/guiders)を参照してください。
## ステップ蒸留モデル
ステップ蒸留されたチェックポイントは、classifier-free guidanceなしで16ステップで生成します。そのtransformerはフローマップであり、各ステップで現在のタイムステップと、そのステップがジャンプ先とするタイムステップが与えられます。ベースモデルと同様にロードされます(リポジトリの`modular_model_index.json`は[Flux3DistilledModularPipeline](/docs/diffusers/main/ja/api/pipelines/flux3#diffusers.Flux3DistilledModularPipeline)と[Flux3DistilledAutoBlocks](/docs/diffusers/main/ja/api/pipelines/flux3#diffusers.Flux3DistilledAutoBlocks)に解決されます)。このパイプラインには`guider`がなく、`negative_prompt`を受け取りません。
```python
pipe = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein")
pipe.load_components(dtype=torch.bfloat16)
pipe.to("cuda")
image = pipe(prompt=prompt, generator=torch.Generator().manual_seed(0), output="images")[0]
```
ベースモデルと同様に、2つのワークフローに対応しています。`num_inference_steps`のデフォルト値は16です。モデルは4ステップから16ステップで学習されています。
## 再現可能な生成
`generator` は、パイプラインがサンプリングするノイズを固定します([再現性](../../using-diffusers/reusing_seeds)を参照)。他の場所でサンプリングしたノイズを再利用するには、`latents` として、形状が `(batch_size, 128, height // 16, width // 16)` のテンソルを渡します。例えば、[BFL の実装](https://github.com/black-forest-labs/flux-3-image-klein) では、CPU 上でノイズを画像トークンとしてサンプリングし、bf16 にキャストしています。これにより、指定されたシードに対するサンプルを再現できます。
```python
height, width = 1024, 1024
h, w = height // 16, width // 16
noise = torch.randn((h * w, 128), generator=torch.Generator().manual_seed(0)).to(torch.bfloat16)
latents = noise.T.reshape(1, 128, h, w)
image = pipe(prompt=prompt, latents=latents, height=height, width=width, output="images")[0]
```
## ワークフロー
パイプラインは `text2image` と `image_conditioned` の2つのワークフローに対応しています。実行されるワークフローは入力によって選択され、`image` が指定されると image-to-image が選択されます。[from_pretrained()](/docs/diffusers/main/ja/api/modular_diffusers/pipeline#diffusers.ModularPipeline.from_pretrained) は `workflow` 引数を用いることで、特定のワークフロー用のパイプラインを構築することもできます。この場合、そのワークフローに必要なコンポーネントのみが期待され、読み込まれます。
```python
from diffusers.modular_pipelines import Flux3AutoBlocks
print(Flux3AutoBlocks().available_workflows)
# ["text2image", "image_conditioned"]
t2i = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein-base", workflow="text2image")
print(t2i.blocks.doc)
```
## ステップごとのコールバック
既存のコールバック関数を使用するには、デノイジングループにブロックを挿入します。[コールバックのガイド](../../using-diffusers/callback#modular-pipelines)には、`CallbackOnStepEnd`ブロックと`walk_denoise_loops`ヘルパーを使ったシンプルな例が記載されています。
```python
blocks = Flux3AutoBlocks() # or Flux3DistilledAutoBlocks
for loop in walk_denoise_loops(blocks):
loop.sub_blocks["callback"] = CallbackOnStepEnd()
pipe = blocks.init_pipeline("black-forest-labs/flux-3-image-klein-base")
image = pipe(prompt=caption, callback_on_step_end=my_callback, output="images")[0]
```
早期に停止するには、コールバックから例外を送出します。`interrupt` フラグはありません。
## メモリ
bf16 ですべてを読み込むと、重みのサイズは約 39 GB になります。transformer は 5.5B パラメータ、Qwen3-VL-4B テキストエンコーダーは 4B、[prompt upsampler](#prompt-upsampling) は 9B(単体で約 19 GB)であり、画像 VAE は fp32 で読み込まれます。upsampler ステップなしで構築されたパイプライン(詳細はそちらを参照)は、約 20 GB を読み込みます。メモリが少ない GPU を使用する場合、コンポーネントのオフローディングを有効にしてください。マネージャーは、各ステップの必要に応じてコンポーネントを CPU と GPU の間で移動します。upsampler も含みます。
```python
from diffusers import ComponentsManager, ModularPipeline
manager = ComponentsManager()
pipe = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein-base", components_manager=manager)
pipe.load_components(dtype={"vae": torch.float32, "default": torch.bfloat16})
manager.enable_auto_cpu_offload(device="cuda")
```
## 単一ファイルの読み込み
[Flux3Transformer2DModel](/docs/diffusers/main/ja/api/models/flux3_transformer#diffusers.Flux3Transformer2DModel) は、[from_single_file()](/docs/diffusers/main/ja/api/loaders/single_file#diffusers.loaders.FromOriginalModelMixin.from_single_file) を使用して、Black Forest Labs のモデルパッケージから transformer を直接読み込みます。パッケージ内の `config.json` は読み込まれないため、diffusers の設定を `config` と `subfolder` で渡してください。
```python
import torch
from diffusers import Flux3Transformer2DModel, ModularPipeline
transformer = Flux3Transformer2DModel.from_single_file(
"https://huggingface.co/black-forest-labs/flux-3-image-klein-base/blob/main/model.safetensors",
config="black-forest-labs/flux-3-image-klein-base",
subfolder="transformer",
dtype=torch.bfloat16,
)
pipe = ModularPipeline.from_pretrained("black-forest-labs/flux-3-image-klein-base")
pipe.load_components(dtype={"vae": torch.float32, "default": torch.bfloat16})
pipe.update_components(transformer=transformer)
pipe.to("cuda")
```
まず、他のコンポーネントを名前によって読み込みます: `names` を指定せずに [load_components()](/docs/diffusers/main/ja/api/modular_diffusers/pipeline#diffusers.ModularPipeline.load_components) を呼び出すと、パイプラインのリポジトリから transformer も読み込まれてしまいます。
FP8rおよびNVFP4の単一ファイルチェックポイントの読み込みもサポートされています。両方とも、[BFLQuantizationConfig](/docs/diffusers/main/ja/api/quantization#diffusers.BFLQuantizationConfig)を指定して同じ呼び出しで読み込みます。各スキームのカーネル要件については、[BFL量子化ガイド](../../quantization/bfl)を参照してください。
```python
from diffusers import BFLQuantizationConfig
transformer = Flux3Transformer2DModel.from_single_file(
"https://huggingface.co/black-forest-labs/flux-3-image-klein-base/blob/main/variants/nvfp4/model.safetensors",
config="black-forest-labs/flux-3-image-klein-base",
subfolder="transformer",
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)
```
ステップ蒸留されたチェックポイントを読み込む際は、その設定(`flow_map=True`)が必要です。
```python
transformer = Flux3Transformer2DModel.from_single_file(
"https://huggingface.co/black-forest-labs/flux-3-image-klein/blob/main/variants/nvfp4/model.safetensors",
config="black-forest-labs/flux-3-image-klein",
subfolder="transformer",
quantization_config=BFLQuantizationConfig(compute_dtype=torch.bfloat16),
dtype=torch.bfloat16,
)
```
## Flux3ModularPipeline[[diffusers.Flux3ModularPipeline]]
#### diffusers.Flux3ModularPipeline[[diffusers.Flux3ModularPipeline]]
```python
diffusers.Flux3ModularPipeline(blocks: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None, pretrained_model_name_or_path: str | os.PathLike | None = None, components_manager: diffusers.modular_pipelines.components_manager.ComponentsManager | None = None, collection: str | None = None, workflow: str | None = None, modular_config_dict: dict[str, typing.Any] | None = None, config_dict: dict[str, typing.Any] | None = None, **kwargs)
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_pipeline.py#L24)
FLUX.3用のModularPipeline。
## Flux3AutoBlocks[[diffusers.Flux3AutoBlocks]]
#### diffusers.Flux3AutoBlocks[[diffusers.Flux3AutoBlocks]]
```python
diffusers.Flux3AutoBlocks()
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_blocks_flux3.py#L339)
FLUX.3 を使用してテキストから画像、および画像から画像の生成を行う Auto ブロックです。`prompt` はまずプロンプトアップサマーを通過します。`prompt_upsampler` ステップを削除すると、指定されたままエンコードされます。
サポートされているワークフロー:
- `text2image`: `prompt` が必要です
- `image_conditioned`: `prompt`と`image`が必要です
コンポーネント: prompt_upsampler (`Qwen3_5ForConditionalGeneration`): プロンプトアップサンプラー。 prompt_upsampler_processor (`AutoProcessor`): そのプロセッサー。 text_encoder (`Qwen3VLForConditionalGeneration`) tokenizer (`AutoProcessor`) image_processor (`Flux3ImageProcessor`) vae (`AutoencoderKLFlux2`) transformer (`Flux3Transformer2DModel`) scheduler (`FlowMatchEulerDiscreteScheduler`) guider (`ClassifierFreeGuidance`)
Inputs: prompt (`str`): 完全なキャプションに展開する編集指示(1回の呼び出しにつき1つ)。 image (`Image | list`, *任意*): 編集の参照画像(最大10枚)。パイプラインが受け取るものと同じです。 boxes (`list`, *任意*): レイアウトボックス。各要素は {'id', 'desc', 'from', 'src_bbox', 'tgt_bbox'} の形式で、ボックスは 0-1 の範囲で [y_min, x_min, y_max, x_max] として指定します。'from': 'target' で `tgt_bbox` を指定すると、その位置に要素を追加します。'from': 'ref_image_0', ... で `src_bbox` と `tgt_bbox` を指定すると、参照画像から要素を移動します。 max_new_tokens (`int`, *任意*, デフォルトは 3584): upsampler がキャプションとして生成し得る最大トークン数。 negative_prompt (`str`, *任意*): 生成を導かないためのプロンプト。 max_sequence_length (`int`, *任意*, デフォルトは 8192): プロンプトの最大トークン数。これを超えるプロンプトは切り詰められます。 text_encoder_out_layers (`tuple`, *任意*, デフォルトは (4, 8, 12, 16, 20, 24, 28, 32)): テキストエンコーダーの隠れ層のインデックス。これらの状態をスタックしてテキスト埋め込みを形成します。 num_images_per_prompt (`int`, *任意*, デフォルトは 1): 1つのプロンプトごとに生成する画像の数。 image_cond_latents (`list`, *任意*): 参照画像の正規化済みパックされた潜在変数。画像ごとに1つのテンソルで、形状は (B, C, height_i//16, width_i//16) です。 height (`int`, *任意*, ワークフローに応じてデフォルトは None または 1024): 生成画像の高さ(ピクセル単位)。デフォルトでは最初の参照画像の高さになります。 width (`int`, *任意*, ワークフローに応じてデフォルトは None または 1024): 生成画像の幅(ピクセル単位)。デフォルトでは最初の参照画像の幅になります。 reference_crop (`list | NoneType`, *任意*): 各参照について、パディング済みキャンバス内の参照のボックス、または None。preprocess ステップから取得します。 latents (`Tensor`): 画像生成用の事前生成されたノイズ付き潜在変数。 generator (`Generator`, *任意*): 決定論的な生成のための Torch ジェネレーター。 num_inference_steps (`int`): 去噪ステップの数。 timesteps (`Tensor`): 去噪プロセス用のタイムステップ。指定された場合、`num_inference_steps` を上書きします。 sigmas (`list`, *任意*): 去噪プロセス用のカスタムシグマ。指定された場合、`num_inference_steps` を上書きします。 **denoiser_input_fields (`None`, *任意*): デノイザー用の条件付きモデル入力。例: prompt_embeds, negative_prompt_embeds など。 attention_kwargs (`dict`, *任意*): アテンションプロセッサー用の追加キーワード引数。 output_type (`str`, *任意*, デフォルトは pil): 出力形式: 'pil', 'np', 'pt'。
出力: images (`list`): 生成された画像。latents (`Tensor`): ノイズ除去された潜在変数。
## Flux3DistilledAutoBlocks[[diffusers.Flux3DistilledAutoBlocks]]
#### diffusers.Flux3DistilledAutoBlocks[[diffusers.Flux3DistilledAutoBlocks]]
```python
diffusers.Flux3DistilledAutoBlocks()
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_blocks_flux3_distilled.py#L258)
ステップ蒸留された FLUX.3 モデル(16 ステップ、classifier-free guidance なし)を使用して、テキストから画像および画像から画像の生成を行う Auto ブロックです。`prompt` はまずプロンプトアップサンプラーを通過します。`prompt_upsampler` ステップを削除すると、指定されたままエンコードされます。
サポートされているワークフロー:
- `text2image`: `prompt` が必要です
- `image_conditioned`: `prompt`と`image`が必要です
コンポーネント: prompt_upsampler (`Qwen3_5ForConditionalGeneration`): プロンプトアップサンプラー。 prompt_upsampler_processor (`AutoProcessor`): そのプロセッサー。 text_encoder (`Qwen3VLForConditionalGeneration`) tokenizer (`AutoProcessor`) image_processor (`Flux3ImageProcessor`) vae (`AutoencoderKLFlux2`) transformer (`Flux3Transformer2DModel`) scheduler (`FlowMatchEulerDiscreteScheduler`)
Inputs: prompt (`str`): 完全なキャプションに展開する編集指示(1回の呼び出しにつき1つ)。 image (`Image | list`, *任意*): 編集の参照画像(最大10枚)。パイプラインが受け取るものと同じです。 boxes (`list`, *任意*): レイアウトボックス。各要素は {'id', 'desc', 'from', 'src_bbox', 'tgt_bbox'} の形式で、ボックスは 0-1 の範囲で [y_min, x_min, y_max, x_max] を表します。'from': 'target' で `tgt_bbox` を指定すると、その位置に要素を追加します。'from': 'ref_image_0', ... で `src_bbox` と `tgt_bbox` を指定すると、参照画像から要素を移動します。 max_new_tokens (`int`, *任意*, デフォルト 3584): upsampler がキャプションとして生成し得る最大トークン数。 max_sequence_length (`int`, *任意*, デフォルト 8192): プロンプトの最大トークン数。これを超えるプロンプトは切り詰められます。 text_encoder_out_layers (`tuple`, *任意*, デフォルト (4, 8, 12, 16, 20, 24, 28, 32)): テキスト埋め込みを形成するためにスタックする、テキストエンコーダーの隠れ層のインデックス。 num_images_per_prompt (`int`, *任意*, デフォルト 1): 1つのプロンプトごとに生成する画像の数。 image_cond_latents (`list`, *任意*): 参照画像の正規化済みパックされた潜在変数。画像ごとに1つのテンソルで、形状は (B, C, height_i//16, width_i//16) です。 height (`int`, *任意*, ワークフローに応じてデフォルトは None または 1024): 生成画像の高さ(ピクセル単位)。デフォルトでは最初の参照画像の高さになります。 width (`int`, *任意*, ワークフローに応じてデフォルトは None または 1024): 生成画像の幅(ピクセル単位)。デフォルトでは最初の参照画像の幅になります。 reference_crop (`list | NoneType`, *任意*): 各参照について、パディング済みキャンバス内の参照のボックス、または None。preprocess ステップから取得します。 latents (`Tensor`): 画像生成用の事前生成されたノイズ付き潜在変数。 generator (`Generator`, *任意*): 決定論的な生成のための Torch ジェネレーター。 num_inference_steps (`int`): 去噪ステップの数。 timesteps (`Tensor`): 去噪プロセス用のタイムステップ。(指定された場合、`num_inference_steps` を上書きします) sigmas (`list`, *任意*): 去噪プロセス用のカスタムシグマ。(指定された場合、`num_inference_steps` を上書きします) **denoiser_input_fields (`None`, *任意*): デノイザー用の条件付きモデル入力。例: prompt_embeds, negative_prompt_embeds など。 output_type (`str`, *任意*, デフォルト pil): 出力形式: 'pil', 'np', 'pt'。
出力: images (`list`): 生成された画像。latents (`Tensor`): ノイズ除去された潜在変数。
## Flux3DistilledModularPipeline[[diffusers.Flux3DistilledModularPipeline]]
#### diffusers.Flux3DistilledModularPipeline[[diffusers.Flux3DistilledModularPipeline]]
```python
diffusers.Flux3DistilledModularPipeline(blocks: diffusers.modular_pipelines.modular_pipeline.ModularPipelineBlocks | None = None, pretrained_model_name_or_path: str | os.PathLike | None = None, components_manager: diffusers.modular_pipelines.components_manager.ComponentsManager | None = None, collection: str | None = None, workflow: str | None = None, modular_config_dict: dict[str, typing.Any] | None = None, config_dict: dict[str, typing.Any] | None = None, **kwargs)
```
[ソース](https://github.com/huggingface/diffusers/blob/main/src/diffusers/modular_pipelines/flux3/modular_pipeline.py#L52)
ステップ蒸留された FLUX.3 モデル(16 ステップ、classifier-free guidance なし)用の ModularPipeline です。

Xet Storage Details

Size:
32.1 kB
·
Xet hash:
ffe62feed25d2a4380dd51fa1c2a2588f6ee3135b0dedc63408a8d1856fcec33

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.