#
# Apache License, Version 2.0（「ライセンス」）の下でライセンスされています。
# このファイルは、ライセンスに準拠した場合にのみ使用できます。
# ライセンスのコピーは以下から入手できます
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# 適用される法律で要求される場合、または書面による合意がある場合を除き、ソフトウェア
# ライセンスに基づき配布される本ソフトウェアは、「現状のまま」
# 明示的または黙示的を問わず、いかなる種類の保証や条件も付随しません。
# 権限を管理する特定の言語については、ライセンスを参照してください。
# ライセンスの下での制限。-->

# HunyuanImage2.1

HunyuanImage-2.1 は、2K（2048 x 2048）解像度の画像を生成できる 17B パラメータのテキストから画像を生成するモデルです

HunyuanImage-2.1には、以下のバリエーションがあります:

| モデルタイプ | モデルID |
|:----------:|:--------:|
| HunyuanImage-2.1 | [hunyuanvideo-community/HunyuanImage-2.1-Diffusers](https://huggingface.co/hunyuanvideo-community/HunyuanImage-2.1-Diffusers) |
| HunyuanImage-2.1-Distilled | [hunyuanvideo-community/HunyuanImage-2.1-Distilled-Diffusers](https://huggingface.co/hunyuanvideo-community/HunyuanImage-2.1-Distilled-Diffusers) |
| HunyuanImage-2.1-Refiner | [hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers](https://huggingface.co/hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers) |

> [!TIP]
> [Caching](../../optimization/cache) は、中間出力を保存して再利用することで、推論の高速化にも貢献します。

## HunyuanImage-2.1

HunyuanImage-2.1 は、デノイジングループにおいて [Adaptive Projected Guidance (APG)](https://huggingface.co/papers/2410.02416) と Classifier-Free Guidance (CFG) を組み合わせて適用します。`HunyuanImagePipeline` には `guider` コンポーネント（[Guider](../../using-diffusers/guiders) について詳しくはこちら）があり、実行時に `guidance_scale` パラメータを受け取りません。guider 関連のパラメータ（例: `guidance_scale`）を変更するには、代わりに `guider` の設定を更新できます。

```python
import torch
from diffusers import HunyuanImagePipeline

pipe = HunyuanImagePipeline.from_pretrained(
    "hunyuanvideo-community/HunyuanImage-2.1-Diffusers", 
    dtype=torch.bfloat16
)
pipe = pipe.to("cuda")  # or "mps", "xpu", "cpu"
``` 

`guider`オブジェクトを調べることができます。

```py
>>> pipe.guider
AdaptiveProjectedMixGuidance {
  "_class_name": "AdaptiveProjectedMixGuidance",
  "_diffusers_version": "0.36.0.dev0",
  "adaptive_projected_guidance_momentum": -0.5,
  "adaptive_projected_guidance_rescale": 10.0,
  "adaptive_projected_guidance_scale": 10.0,
  "adaptive_projected_guidance_start_step": 5,
  "enabled": true,
  "eta": 0.0,
  "guidance_rescale": 0.0,
  "guidance_scale": 3.5,
  "start": 0.0,
  "stop": 1.0,
  "use_original_formulation": false
}

State:
  step: None
  num_inference_steps: None
  timestep: None
  count_prepared: 0
  enabled: True
  num_conditions: 2
  momentum_buffer: None
  is_apg_enabled: False
  is_cfg_enabled: True
```

異なる設定でguiderを更新するには、`new()`メソッドを使用します。例えば、他のすべてのデフォルトのguidanceパラメータを維持したまま、`guidance_scale=5.0`で画像を生成するには:

```py
import torch
from diffusers import HunyuanImagePipeline

pipe = HunyuanImagePipeline.from_pretrained(
    "hunyuanvideo-community/HunyuanImage-2.1-Diffusers", 
    dtype=torch.bfloat16
)
pipe = pipe.to("cuda")  # or "mps", "xpu", "cpu"

# Update the guider configuration
pipe.guider = pipe.guider.new(guidance_scale=5.0)

prompt = (
    "A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, "
    "wearing a red knitted scarf and a red beret with the word 'Tencent' on it, holding a paintbrush with a "
    "focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."
)

image = pipe(
    prompt=prompt, 
    num_inference_steps=50, 
    height=2048, 
    width=2048,
).images[0]
image.save("image.png")
```

## HunyuanImage-2.1-Distilled

guidance-distilled チェックポイントでは、`distilled_guidance_scale` を使用してください。

```py
import torch
from diffusers import HunyuanImagePipeline
pipe = HunyuanImagePipeline.from_pretrained("hunyuanvideo-community/HunyuanImage-2.1-Distilled-Diffusers", dtype=torch.bfloat16)
pipe = pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt = (
    "A cute, cartoon-style anthropomorphic penguin plush toy with fluffy fur, standing in a painting studio, "
    "wearing a red knitted scarf and a red beret with the word 'Tencent' on it, holding a paintbrush with a "
    "focused expression as it paints an oil painting of the Mona Lisa, rendered in a photorealistic photographic style."
)

out = pipe(
    prompt,
    num_inference_steps=8,
    distilled_guidance_scale=3.25,
    height=2048,
    width=2048,
    generator=generator,
).images[0]

```

## HunyuanImagePipeline[[diffusers.HunyuanImagePipeline]]

#### diffusers.HunyuanImagePipeline[[diffusers.HunyuanImagePipeline]]

```python
diffusers.HunyuanImagePipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLHunyuanImage, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2Tokenizer, text_encoder_2: T5EncoderModel, tokenizer_2: ByT5Tokenizer, transformer: HunyuanImageTransformer2DModel, guider: AdaptiveProjectedMixGuidance | None = None, ocr_guider: AdaptiveProjectedMixGuidance | None = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage.py#L160)

**パラメータ:**

transformer ([HunyuanImageTransformer2DModel](/docs/diffusers/v0.43.0/ja/api/models/hunyuanimage_transformer_2d#diffusers.HunyuanImageTransformer2DModel)) : エンコードされた画像潜在変数をデノイズするための条件付き Transformer (MMDiT) アーキテクチャ。

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/v0.43.0/ja/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer` と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。

vae ([AutoencoderKLHunyuanImage](/docs/diffusers/v0.43.0/ja/api/models/autoencoder_kl_hunyuanimage#diffusers.AutoencoderKLHunyuanImage)) : 画像を潜在表現にエンコードし、潜在表現からデコードするための Variational Auto-Encoder (VAE) モデル。

text_encoder (`Qwen2.5-VL-7B-Instruct`) : [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)、具体的には [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct) バリアントです。

tokenizer (`Qwen2Tokenizer`) : クラス [Qwen2Tokenizer] の Tokenizer。

text_encoder_2 (`T5EncoderModel`) : [T5EncoderModel](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel) バリアント。

tokenizer_2 (`ByT5Tokenizer`) : [ByT5Tokenizer] クラスのトークナイザー

guider (`AdaptiveProjectedMixGuidance`) : 画像生成をガイドするために使用される [AdaptiveProjectedMixGuidance]。

ocr_guider (`AdaptiveProjectedMixGuidance`, *任意*) : テキストレンダリングが必要な場合に、画像生成をガイドするために使用される [AdaptiveProjectedMixGuidance]。

テキストから画像を生成するためのHunyuanImageパイプライン。

#### __call__[[diffusers.HunyuanImagePipeline.__call__]]

```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] = None, height: int | None = None, width: int | None = None, num_inference_steps: int = 50, distilled_guidance_scale: float | None = 3.25, sigmas: list[float] | None = None, num_images_per_prompt: int = 1, generator: torch.Generator | list[torch.Generator] | None = None, latents: torch.Tensor | None = None, prompt_embeds: torch.Tensor | None = None, prompt_embeds_mask: torch.Tensor | None = None, negative_prompt_embeds: torch.Tensor | None = None, negative_prompt_embeds_mask: torch.Tensor | None = None, prompt_embeds_2: torch.Tensor | None = None, prompt_embeds_mask_2: torch.Tensor | None = None, negative_prompt_embeds_2: torch.Tensor | None = None, negative_prompt_embeds_mask_2: torch.Tensor | None = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, Any] | None = None, callback_on_step_end: Callable[[int, int], None] | None = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'])
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage.py#L504)

**パラメータ:**

prompt (`str` または `list[str]`、*省略可*) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに `prompt_embeds` を渡す必要があります。

negative_prompt (`str` または `list[str]`、*任意*) : 画像生成をガイドしないプロンプトです。定義されておらず、negative_prompt_embeds も提供されていない場合、空のネガティブプロンプトが使用されます。ガイダンスを使用していない場合は無視されます。

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` が渡された場合のデフォルトの動作が使用されます。

distilled_guidance_scale (`float`、*任意*、デフォルトは None) : ガイダンス蒸留モデル用のガイダンススケール値です。従来の classifier-free guidance では、推論時にノイズ予測の再スケーリングを通じてガイダンススケールが適用されますが、ガイダンス蒸留モデルでは、フォワードパス中にガイダンススケールを直接入力パラメータとして受け取ります。`distilled_guidance_scale > 1` を設定することでガイダンスが有効になります。ガイダンススケールを高くすると、テキストの `prompt` と密接に関連する画像の生成が促されますが、通常は画像品質の低下を伴います。ガイダンス蒸留モデルでは、このパラメータは必須です。非蒸留モデルでは、このパラメータは無視されます。

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` 入力引数からテキスト埋め込みが生成されます。

prompt_embeds_mask (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込みマスク。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`prompt` 入力引数からテキスト埋め込みマスクが生成されます。

prompt_embeds_2 (`torch.Tensor`, *任意*) : ocr用の事前生成されたテキスト埋め込み。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うことができます。指定されない場合、`prompt` 入力引数から ocr用のテキスト埋め込みが生成されます。

prompt_embeds_mask_2 (`torch.Tensor`, *任意*) : ocr用の事前生成されたテキスト埋め込みマスク。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`prompt`入力引数からocr用のテキスト埋め込みマスクが生成されます。

negative_prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`negative_prompt` 入力引数から negative_prompt_embeds が生成されます。

negative_prompt_embeds_mask (`torch.Tensor`, *任意*) : 事前に生成されたネガティブテキスト埋め込みマスク。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`negative_prompt` 入力引数からネガティブテキスト埋め込みマスクが生成されます。

negative_prompt_embeds_2 (`torch.Tensor`, *任意*) : ocr用の事前生成されたネガティブテキスト埋め込み。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`negative_prompt` 入力引数からocr用のネガティブテキスト埋め込みが生成されます。

negative_prompt_embeds_mask_2 (`torch.Tensor`, *任意*) : ocr用の事前生成されたネガティブテキスト埋め込みマスクです。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`negative_prompt` 入力引数からocr用のネガティブテキスト埋め込みマスクが生成されます。

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` 属性にリストされている変数のみを包含できます。

**戻り値:** `~pipelines.hunyuan_image.HunyuanImagePipelineOutput` または `tuple`

`return_dict` が True の場合は `~pipelines.hunyuan_image.HunyuanImagePipelineOutput`、それ以外の場合は `tuple` を返します。tuple を返す場合、最初の要素は生成された画像のリストです。

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

例:
```py
>>> import torch
>>> from diffusers import HunyuanImagePipeline

>>> pipe = HunyuanImagePipeline.from_pretrained(
...     "hunyuanvideo-community/HunyuanImage-2.1-Diffusers", 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, negative_prompt="", num_inference_steps=50).images[0]
>>> image.save("hunyuanimage.png")
```

#### encode_prompt[[diffusers.HunyuanImagePipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str], device: torch.device | None = None, batch_size: int = 1, num_images_per_prompt: int = 1, prompt_embeds: torch.Tensor | None = None, prompt_embeds_mask: torch.Tensor | None = None, prompt_embeds_2: torch.Tensor | None = None, prompt_embeds_mask_2: torch.Tensor | None = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage.py#L296)

**パラメータ:**

prompt (`str` または `list[str]`、*省略可能*) : エンコードするプロンプト

device : (`torch.device`): torch デバイス

batch_size (`int`) : プロンプトのバッチサイズ。デフォルト値は 1 です

num_images_per_prompt (`int`) : プロンプトごとに生成すべき画像の数

prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。指定しない場合、`prompt` 入力引数からテキスト埋め込みが生成されます。

prompt_embeds_mask (`torch.Tensor`、*任意*) : 事前に生成されたテキストマスク。指定しない場合、`prompt` 入力引数からテキストマスクが生成されます。

prompt_embeds_2 (`torch.Tensor`, *任意*) : ByT5 によって事前生成されたグリフテキスト埋め込み。指定されない場合、`prompt` 入力引数から self.tokenizer_2 および self.text_encoder_2 を使用して生成されます。

prompt_embeds_mask_2 (`torch.Tensor`、*任意*) : ByT5 によって事前生成されたグリフテキストマスクです。指定されない場合、`prompt` 入力引数から self.tokenizer_2 および self.text_encoder_2 を使用して生成されます。

## HunyuanImageRefinerPipeline[[diffusers.HunyuanImageRefinerPipeline]]

#### diffusers.HunyuanImageRefinerPipeline[[diffusers.HunyuanImageRefinerPipeline]]

```python
diffusers.HunyuanImageRefinerPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLHunyuanImageRefiner, text_encoder: Qwen2_5_VLForConditionalGeneration, tokenizer: Qwen2Tokenizer, transformer: HunyuanImageTransformer2DModel, guider: AdaptiveProjectedMixGuidance | None = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage_refiner.py#L138)

**パラメータ:**

transformer ([HunyuanImageTransformer2DModel](/docs/diffusers/v0.43.0/ja/api/models/hunyuanimage_transformer_2d#diffusers.HunyuanImageTransformer2DModel)) : エンコードされた画像潜在変数をデノイズするための条件付き Transformer (MMDiT) アーキテクチャ。

scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/v0.43.0/ja/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer` と組み合わせて、エンコードされた画像の潜在変数をデノイズするために使用するスケジューラー。

vae ([AutoencoderKLHunyuanImageRefiner](/docs/diffusers/v0.43.0/ja/api/models/autoencoder_kl_hunyuanimage_refiner#diffusers.AutoencoderKLHunyuanImageRefiner)) : 画像を潜在表現にエンコードし、潜在表現からデコードするための変分オートエンコーダ（VAE）モデル。

text_encoder (`Qwen2.5-VL-7B-Instruct`) : [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct)、具体的には [Qwen2.5-VL-7B-Instruct](https://huggingface.co/Qwen/Qwen2.5-VL-7B-Instruct) バリアントです。

tokenizer (`Qwen2Tokenizer`) : クラス [Qwen2Tokenizer] の Tokenizer。

テキストから画像を生成するためのHunyuanImageパイプライン。

#### __call__[[diffusers.HunyuanImageRefinerPipeline.__call__]]

```python
__call__(prompt: str | list[str] = None, negative_prompt: str | list[str] = None, distilled_guidance_scale: float | None = 3.25, image: PipelineImageInput | None = 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: torch.Generator | list[torch.Generator] | None = None, latents: torch.Tensor | None = None, prompt_embeds: torch.Tensor | None = None, prompt_embeds_mask: torch.Tensor | None = None, negative_prompt_embeds: torch.Tensor | None = None, negative_prompt_embeds_mask: torch.Tensor | None = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, Any] | None = None, callback_on_step_end: Callable[[int, int], None] | None = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'])
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage_refiner.py#L436)

**パラメータ:**

prompt (`str` または `list[str]`、*省略可*) : 画像生成をガイドするためのプロンプトです。未定義の場合、代わりに `prompt_embeds` を渡す必要があります。

negative_prompt (`str` または `list[str]`、*省略可能*) : 画像生成をガイドしないプロンプトです。定義されていない場合、空のネガティブプロンプトが使用されます。ガイダンスを使用していない場合は無視されます。

distilled_guidance_scale (`float`、*任意*、デフォルトは None) : ガイダンス蒸留モデル用のガイダンススケール値です。従来の classifier-free guidance では、推論時にノイズ予測の再スケーリングを通じてガイダンススケールが適用されますが、ガイダンス蒸留モデルでは、フォワードパス中にガイダンススケールを直接入力パラメータとして受け取ります。`distilled_guidance_scale > 1` を設定することでガイダンスが有効になります。ガイダンススケールを高くすると、テキストの `prompt` と密接に関連する画像の生成が促されますが、通常は画像品質の低下を伴います。ガイダンス蒸留モデルでは、このパラメータは必須です。非蒸留モデルでは、このパラメータは無視されます。

image (`PipelineImageInput`, *任意*) : 精錬対象の入力画像。

num_images_per_prompt (`int`、*任意*、デフォルトは 1) --

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` 入力引数からテキスト埋め込みが生成されます。

prompt_embeds_mask (`torch.Tensor`, *任意*) : `prompt_embeds`用のアテンションマスク。

negative_prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたネガティブなテキスト埋め込み。テキスト入力の調整、*例えば*プロンプトの重み付けなどを容易に行うために使用できます。指定されない場合、`negative_prompt` 入力引数から negative_prompt_embeds が生成されます。

negative_prompt_embeds_mask (`torch.Tensor`, *任意*) : `negative_prompt_embeds` 用のアテンションマスク。

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` 属性にリストされている変数のみを包含できます。

**戻り値:** `~pipelines.hunyuan_image.HunyuanImagePipelineOutput` または `tuple`

`return_dict` が True の場合は `~pipelines.hunyuan_image.HunyuanImagePipelineOutput`、それ以外の場合は `tuple` を返します。tuple を返す場合、最初の要素は生成された画像のリストです。

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

例:
```py
>>> import torch
>>> from diffusers import HunyuanImageRefinerPipeline

>>> pipe = HunyuanImageRefinerPipeline.from_pretrained(
...     "hunyuanvideo-community/HunyuanImage-2.1-Refiner-Diffusers", torch_dtype=torch.bfloat16
... )
>>> pipe.to("cuda")
>>> prompt = "A cat holding a sign that says hello world"
>>> image = load_image("path/to/image.png")
>>> # Depending on the variant being used, the pipeline call will slightly vary.
>>> # Refer to the pipeline documentation for more details.
>>> image = pipe(prompt, image=image, num_inference_steps=4).images[0]
>>> image.save("hunyuanimage.png")
```

#### encode_prompt[[diffusers.HunyuanImageRefinerPipeline.encode_prompt]]

```python
encode_prompt(prompt: str | list[str] | None = None, device: torch.device | None = None, batch_size: int = 1, num_images_per_prompt: int = 1, prompt_embeds: torch.Tensor | None = None, prompt_embeds_mask: torch.Tensor | None = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_hunyuanimage_refiner.py#L225)

**パラメータ:**

prompt (`str` または `list[str]`、*省略可能*) : エンコードするプロンプト

device : (`torch.device`): torch デバイス

batch_size (`int`) : プロンプトのバッチサイズ。デフォルト値は 1 です

num_images_per_prompt (`int`) : プロンプトごとに生成すべき画像の数

prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。指定しない場合、`prompt` 入力引数からテキスト埋め込みが生成されます。

prompt_embeds_mask (`torch.Tensor`、*任意*) : 事前に生成されたテキストマスク。指定しない場合、`prompt` 入力引数からテキストマスクが生成されます。

prompt_embeds_2 (`torch.Tensor`, *任意*) : ByT5 によって事前生成されたグリフテキスト埋め込み。指定されない場合、`prompt` 入力引数から self.tokenizer_2 および self.text_encoder_2 を使用して生成されます。

prompt_embeds_mask_2 (`torch.Tensor`、*任意*) : ByT5 によって事前生成されたグリフテキストマスクです。指定されない場合、`prompt` 入力引数から self.tokenizer_2 および self.text_encoder_2 を使用して生成されます。

## HunyuanImagePipelineOutput[[diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput]]

#### diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput[[diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput]]

```python
diffusers.pipelines.hunyuan_image.pipeline_output.HunyuanImagePipelineOutput(images: list[PIL.Image.Image, numpy.ndarray])
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/hunyuan_image/pipeline_output.py#L10)

**パラメータ:**

images (`list[PIL.Image.Image]` または `np.ndarray`) : 長さ `batch_size` のデノイズ済み PIL イメージのリスト、または形状 `(batch_size, height, width, num_channels)` の numpy 配列。PIL イメージまたは numpy 配列は、拡散パイプラインのデノイズ済みイメージを表します。

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

