# Motif-Video

[技術レポート](https://arxiv.org/abs/2604.16503)

Motif-Video は、テキストから動画へ、および画像から動画への生成のために設計された 2B パラメータの拡散トランスフォーマーです。12 のデュアルストリーム + 16 のシングルストリーム + 8 の DDT デコーダー層からなる 3 段階アーキテクチャ、長い動画シーケンス下での安定したテキストと動画の整合性を保つ Shared Cross-Attention、T5Gemma2 テキストエンコーダー、そして速度予測のための rectified flow matching を備えています。

  

## テキストから動画の生成

テキストから動画を生成するには、`MotifVideoPipeline`を使用します:

```python
import torch
from diffusers import MotifVideoPipeline
from diffusers.utils import export_to_video

pipe = MotifVideoPipeline.from_pretrained(
    "Motif-Technologies/Motif-Video-2B",
    dtype=torch.bfloat16,
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

prompt = "A woman with long brown hair and light skin smiles at another woman with long blonde hair."
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

video = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    width=1280,
    height=736,
    num_frames=121,
    num_inference_steps=50,
).frames[0]
export_to_video(video, "output.mp4", fps=24)
```

## 画像から動画の生成

画像から動画の生成には、`MotifVideoImage2VideoPipeline`を使用します:

```python
import torch
from diffusers import MotifVideoImage2VideoPipeline
from diffusers.utils import export_to_video, load_image

pipe = MotifVideoImage2VideoPipeline.from_pretrained(
    "Motif-Technologies/Motif-Video-2B",
    dtype=torch.bfloat16,
)
pipe.to("cuda")  # or "mps", "xpu", "cpu"

image = load_image("input_image.png")
prompt = "A cinematic scene with vivid colors."
negative_prompt = "worst quality, blurry, jittery, distorted"

video = pipe(
    image=image,
    prompt=prompt,
    negative_prompt=negative_prompt,
    width=1280,
    height=736,
    num_frames=121,
    num_inference_steps=50,
).frames[0]
export_to_video(video, "i2v_output.mp4", fps=24)
```

### メモリ効率の良い推論

VRAMが30GB未満のGPU（例: RTX 4090）では、モデルのCPUオフロードを使用します:

```bash
export PYTORCH_CUDA_ALLOC_CONF=expandable_segments:True
```

```python
import torch
from diffusers import MotifVideoPipeline
from diffusers.utils import export_to_video

pipe = MotifVideoPipeline.from_pretrained(
    "Motif-Technologies/Motif-Video-2B",
    dtype=torch.bfloat16,
)
pipe.enable_model_cpu_offload()

prompt = "A woman with long brown hair and light skin smiles at another woman with long blonde hair."
negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

video = pipe(
    prompt=prompt,
    negative_prompt=negative_prompt,
    width=1280,
    height=736,
    num_frames=121,
    num_inference_steps=50,
).frames[0]
export_to_video(video, "output.mp4", fps=24)
```

## MotifVideoPipeline[[diffusers.MotifVideoPipeline]]

#### diffusers.MotifVideoPipeline[[diffusers.MotifVideoPipeline]]

```python
diffusers.MotifVideoPipeline(scheduler: SchedulerMixin, vae: AutoencoderKLWan, text_encoder: T5Gemma2Encoder, tokenizer: PreTrainedTokenizerBase, transformer: MotifVideoTransformer3DModel, guider: BaseGuidance, feature_extractor: typing.Optional[transformers.models.siglip.image_processing_pil_siglip.SiglipImageProcessorPil] = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/motif_video/pipeline_motif_video.py#L148)

**パラメータ:**

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

scheduler ([SchedulerMixin](/docs/diffusers/v0.43.0/ja/api/schedulers/overview#diffusers.SchedulerMixin)) : `transformer` と組み合わせて、エンコードされた動画の潜在変数をデノイズするために使用するスケジューラ。`SchedulerMixin` を継承するクラスのインスタンスである必要があります。例えば [DPMSolverMultistepScheduler](/docs/diffusers/v0.43.0/ja/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler) などです。指定されない場合、事前学習済みモデルに付随するスケジューラが使用されます。

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

text_encoder (`T5Gemma2Encoder`) : テキストプロンプトを埋め込みベクトルに変換するための主要なテキストエンコーダーです。

tokenizer (`PreTrainedTokenizerBase`) : 主要なテキストエンコーダーに対応するトークナイザー。

guider ([BaseGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.BaseGuidance)) : 使用するガイダンス手法。`BaseGuidance` を継承するクラスのインスタンスである必要があります。例えば [ClassifierFreeGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance)、[AdaptiveProjectedGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.AdaptiveProjectedGuidance)、または [SkipLayerGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.SkipLayerGuidance) などです。指定しない場合、デフォルトで `ClassifierFreeGuidance` が使用されます。

Motif-Video を使用したテキストから動画への生成を行う Pipeline です。

このモデルは [DiffusionPipeline](/docs/diffusers/v0.43.0/ja/api/pipelines/overview#diffusers.DiffusionPipeline) を継承しています。すべてのパイプラインに実装されている汎用的なメソッド（ダウンロード、保存、特定のデバイスでの実行など）については、スーパークラスのドキュメントを参照してください。

#### __call__[[diffusers.MotifVideoPipeline.__call__]]

```python
__call__(prompt: typing.Union[str, typing.List[str], NoneType] = None, negative_prompt: typing.Union[str, typing.List[str], NoneType] = None, height: int = 736, width: int = 1280, num_frames: int = 121, num_inference_steps: int = 50, timesteps: typing.Optional[typing.List[int]] = None, num_videos_per_prompt: typing.Optional[int] = 1, generator: typing.Union[torch.Generator, typing.List[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, output_type: typing.Optional[str] = 'pil', return_dict: bool = True, attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None, callback_on_step_end: typing.Union[typing.Callable[[int, int, typing.Dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: typing.List[str] = ['latents'], max_sequence_length: int = 512, vae_batch_size: int | None = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/motif_video/pipeline_motif_video.py#L492)

**パラメータ:**

prompt (`str` または `List[str]`、*任意*) : 動画生成をガイドするためのプロンプトです。未定義の場合、`prompt_embeds` を渡す必要があります。

negative_prompt (`str` または `List[str]`、*省略可*) : 動画生成をガイドしないためのプロンプトです。未定義の場合、代わりに `negative_prompt_embeds` を渡す必要があります。guidance を使用しない場合は無視されます。

height (`int`、デフォルトは`736`) : 生成される動画のピクセル単位の縦幅。

width (`int`、デフォルトは`1280`) : 生成される動画の幅（ピクセル単位）。

num_frames (`int`、デフォルトは`121`) : 生成する動画のフレーム数。

num_inference_steps (`int`、*optional*、デフォルト値は 50) : デノイジングのステップ数です。デノイジングのステップ数を増やすと、推論速度が遅くなる代わりに、通常、より高品質な動画が生成されます。

timesteps (`List[int]`、*任意*) : デノイジングプロセスに使用するカスタムタイムステップ。

num_videos_per_prompt (`int`、*optional*、デフォルトは 1) : プロンプトごとに生成する動画の数を指定します。

generator (`torch.Generator` または `List[torch.Generator]`、*任意*) : 決定論的な生成のための PyTorch Generator オブジェクト。

latents (`torch.Tensor`, *任意*) : 事前生成されたノイズ付き潜在変数。

prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。

prompt_attention_mask (`torch.Tensor`, *任意*) : テキスト埋め込み用の事前生成されたアテンションマスク。

negative_prompt_embeds (`torch.FloatTensor`、*任意*) : 事前に生成されたネガティブなテキスト埋め込み。

negative_prompt_attention_mask (`torch.FloatTensor`、*任意*) : 負のテキスト埋め込み用の事前生成済みアテンションマスク。

output_type (`str`、*任意*、デフォルトは`"pil"`) : 生成される動画の出力形式。`"pil"`、`"np"`、`"latent"`のいずれかを選択します。

return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく、[~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/ja/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput)を返すかどうかを指定します。

attention_kwargs (`dict`, *任意*) : attention プロセッサに渡される引数。

callback_on_step_end (`Callable`、*任意*) : 各デノイジングステップの終了時に呼び出される関数、または`PipelineCallback`または`MultiPipelineCallbacks`のサブクラス。

callback_on_step_end_tensor_inputs (`List`, *任意*) : `callback_on_step_end` 関数へのテンソル入力のリスト。

max_sequence_length (`int`、デフォルトは`512`) : トークナイザーの最大シーケンス長。

vae_batch_size (`int`, *optional*) : VAEデコードのバッチサイズ。指定され、かつlatentsのバッチサイズがそれより大きい場合、VAEデコードはチャンク単位で実行されます。

**戻り値:** [~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/ja/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) または `tuple`

`return_dict` が `True` の場合、[~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/ja/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) が返され、それ以外の場合は、最初の要素が生成された動画フレームのリストである `tuple` が返されます。

テキストから動画を生成するための pipeline の呼び出し関数です。

例:
```python
>>> import torch
>>> from diffusers import MotifVideoPipeline
>>> from diffusers.utils import export_to_video

>>> # Load the Motif-Video pipeline
>>> motif_video_model_id = "Motif-Technologies/Motif-Video-2B"
>>> pipe = MotifVideoPipeline.from_pretrained(motif_video_model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

>>> prompt = "A woman with long brown hair and light skin smiles at another woman with long blonde hair. The woman with brown hair wears a black jacket and has a small, barely noticeable mole on her right cheek. The camera angle is a close-up, focused on the woman with brown hair's face. The lighting is warm and natural, likely from the setting sun, casting a soft glow on the scene. The scene appears to be real-life footage"
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

>>> video = pipe(
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     width=1280,
...     height=736,
...     num_frames=121,
...     num_inference_steps=50,
... ).frames[0]
>>> export_to_video(video, "output.mp4", fps=24)
```

#### encode_prompt[[diffusers.MotifVideoPipeline.encode_prompt]]

```python
encode_prompt(prompt: typing.Union[str, typing.List[str]], negative_prompt: typing.Union[str, typing.List[str], NoneType] = None, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/motif_video/pipeline_motif_video.py#L247)

**パラメータ:**

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

negative_prompt (`str` または `List[str]`、*省略可能*) : 画像生成をガイドしないプロンプトです。未定義の場合、代わりに `negative_prompt_embeds` を渡す必要があります。ガイドを使用していない場合は無視されます（`guidance_scale` が `1` 未満の場合は無視されます）。

num_videos_per_prompt (`int`、*optional*、デフォルトは 1) : プロンプトごとに生成する動画の数。

prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。

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

prompt_attention_mask (`torch.Tensor`, *任意*) : テキスト埋め込み用の事前生成されたアテンションマスク。

negative_prompt_attention_mask (`torch.Tensor`, *任意*) : 負のテキスト埋め込み用の事前生成されたアテンションマスク。

max_sequence_length (`int`、デフォルト値は 512) : トークナイザーの最大シーケンス長。

device (`torch.device`, *任意*) : テンソスを配置するデバイス。

dtype (`torch.dtype`、*任意*) : テンソルのデータ型。

**戻り値:** `tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]`

以下の要素を含むタプル:
- `prompt_embeds`: ポジティブプロンプトのテキスト埋め込み
- `negative_prompt_embeds`: 負のプロンプトのテキスト埋め込み（ガイダンスを使用しない場合は None）
- `prompt_attention_mask`: ポジティブプロンプト用のアテンションマスク
- `negative_prompt_attention_mask`: 負のプロンプト用のアテンションマスク（ガイダンスを使用しない場合は None）

プロンプトをテキストエンコーダーの隠れ状態にエンコードします。

## MotifVideoImage2VideoPipeline[[diffusers.MotifVideoImage2VideoPipeline]]

#### diffusers.MotifVideoImage2VideoPipeline[[diffusers.MotifVideoImage2VideoPipeline]]

```python
diffusers.MotifVideoImage2VideoPipeline(scheduler: SchedulerMixin, vae: AutoencoderKLWan, text_encoder: T5Gemma2Encoder, tokenizer: PreTrainedTokenizerBase, transformer: MotifVideoTransformer3DModel, guider: BaseGuidance, feature_extractor: SiglipImageProcessorPil)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/motif_video/pipeline_motif_video_image2video.py#L157)

**パラメータ:**

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

scheduler ([SchedulerMixin](/docs/diffusers/v0.43.0/ja/api/schedulers/overview#diffusers.SchedulerMixin)) : `transformer` と組み合わせて、エンコードされた動画の潜在変数をデノイズするために使用するスケジューラ。`SchedulerMixin` を継承するクラスのインスタンスである必要があります。例えば [DPMSolverMultistepScheduler](/docs/diffusers/v0.43.0/ja/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler) などです。指定されない場合、事前学習済みモデルに付随するスケジューラが使用されます。

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

text_encoder (`T5Gemma2Encoder`) : テキストプロンプトを埋め込みベクトルに変換するための主要なテキストエンコーダーです。

tokenizer (`PreTrainedTokenizerBase`) : 主要なテキストエンコーダーに対応するトークナイザー。

feature_extractor (`SiglipImageProcessor`) : SigLIPビジョンエンコーダー用の画像プロセッサ。

guider ([BaseGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.BaseGuidance)) : 使用するガイダンス手法。`BaseGuidance` を継承するクラスのインスタンスである必要があります。例えば [ClassifierFreeGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance)、[AdaptiveProjectedGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.AdaptiveProjectedGuidance)、または [SkipLayerGuidance](/docs/diffusers/v0.43.0/ja/api/modular_diffusers/guiders#diffusers.SkipLayerGuidance) などです。指定しない場合、デフォルトで `ClassifierFreeGuidance` が使用されます。

Motif-Videoのファーストフレーム条件付けを用いた画像から動画への生成を行うPipelineです。

このモデルは [DiffusionPipeline](/docs/diffusers/v0.43.0/ja/api/pipelines/overview#diffusers.DiffusionPipeline) を継承しています。すべてのパイプラインに実装されている汎用的なメソッド（ダウンロード、保存、特定のデバイスでの実行など）については、スーパークラスのドキュメントを参照してください。

#### __call__[[diffusers.MotifVideoImage2VideoPipeline.__call__]]

```python
__call__(image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]], prompt: typing.Union[str, typing.List[str]], negative_prompt: typing.Union[str, typing.List[str], NoneType] = None, height: int = 736, width: int = 1280, num_frames: int = 121, num_inference_steps: int = 50, timesteps: typing.Optional[typing.List[int]] = None, num_videos_per_prompt: typing.Optional[int] = 1, generator: typing.Union[torch.Generator, typing.List[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, output_type: typing.Optional[str] = 'pil', return_dict: bool = True, attention_kwargs: typing.Optional[typing.Dict[str, typing.Any]] = None, callback_on_step_end: typing.Union[typing.Callable[[int, int, typing.Dict], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = None, callback_on_step_end_tensor_inputs: typing.List[str] = ['latents'], max_sequence_length: int = 512)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/motif_video/pipeline_motif_video_image2video.py#L620)

**パラメータ:**

image (`PipelineImageInput`) : 動画生成の最初のフレームとして使用する入力画像。

prompt (`str` または `List[str]`) : 動画生成をガイドするためのプロンプト、またはプロンプトのリスト。

negative_prompt (`str` または `List[str]`、*省略可能*) : 動画生成をガイドしないプロンプトまたはプロンプトのリスト。

height (`int`、デフォルトは`736`) : 生成される動画のピクセル単位の縦幅。

width (`int`、デフォルトは`1280`) : 生成される動画の幅（ピクセル単位）。

num_frames (`int`、デフォルトは`121`) : 生成する動画のフレーム数。

num_inference_steps (`int`、*任意*、デフォルトは 50) : デノイジングのステップ数。

timesteps (`List[int]`、*任意*) : デノイジングプロセスに使用するカスタムタイムステップ。

num_videos_per_prompt (`int`、*optional*、デフォルトは 1) : プロンプトごとに生成する動画の数を指定します。

generator (`torch.Generator` または `List[torch.Generator]`、*任意*) : 決定論的な生成のための PyTorch Generator オブジェクト。

latents (`torch.Tensor`, *任意*) : 事前生成されたノイズ付き潜在変数。

prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。

prompt_attention_mask (`torch.Tensor`, *任意*) : テキスト埋め込み用の事前生成されたアテンションマスク。

negative_prompt_embeds (`torch.FloatTensor`、*任意*) : 事前に生成されたネガティブなテキスト埋め込み。

negative_prompt_attention_mask (`torch.FloatTensor`、*任意*) : 負のテキスト埋め込み用の事前生成済みアテンションマスク。

output_type (`str`、*任意*、デフォルトは`"pil"`) : 生成される動画の出力形式。

return_dict (`bool`、*任意*、デフォルトは`True`) : プレーンなタプルではなく、[~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/ja/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput)を返すかどうかを指定します。

attention_kwargs (`dict`, *任意*) : attention プロセッサに渡される引数。

callback_on_step_end (`Callable`、*任意*) : 各デノイジングステップの終了時に呼び出される関数、または`PipelineCallback`のサブクラス。

callback_on_step_end_tensor_inputs (`List`, *任意*) : `callback_on_step_end` 関数へのテンソル入力のリスト。

max_sequence_length (`int`、デフォルトは`512`) : トークナイザーの最大シーケンス長。

**戻り値:** [~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/ja/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) または `tuple`

`return_dict` が `True` の場合、[~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/ja/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) が返され、それ以外の場合は、最初の要素が生成された動画フレームのリストである `tuple` が返されます。

画像から動画への変換を行う pipeline の呼び出し関数です。

例:
```python
>>> import torch
>>> from PIL import Image
>>> from diffusers import MotifVideoImage2VideoPipeline
>>> from diffusers.utils import export_to_video, load_image

>>> # Load the Motif-Video image-to-video pipeline
>>> motif_video_model_id = "Motif-Technologies/Motif-Video-2B"
>>> pipe = MotifVideoImage2VideoPipeline.from_pretrained(motif_video_model_id, torch_dtype=torch.bfloat16)
>>> pipe.to("cuda")

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

>>> prompt = "An astronaut is walking on the moon surface, kicking up dust with each step"
>>> negative_prompt = "worst quality, inconsistent motion, blurry, jittery, distorted"

>>> video = pipe(
...     image=image,
...     prompt=prompt,
...     negative_prompt=negative_prompt,
...     width=1280,
...     height=736,
...     num_frames=121,
...     num_inference_steps=50,
... ).frames[0]
>>> export_to_video(video, "output.mp4", fps=24)
```

#### encode_prompt[[diffusers.MotifVideoImage2VideoPipeline.encode_prompt]]

```python
encode_prompt(prompt: typing.Union[str, typing.List[str]], negative_prompt: typing.Union[str, typing.List[str], NoneType] = None, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 512, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None)
```

[ソース](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/pipelines/motif_video/pipeline_motif_video_image2video.py#L259)

**パラメータ:**

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

negative_prompt (`str` または `List[str]`、*省略可能*) : 画像生成をガイドしないプロンプトです。未定義の場合、代わりに `negative_prompt_embeds` を渡す必要があります。ガイドを使用していない場合は無視されます（`guidance_scale` が `1` 未満の場合は無視されます）。

num_videos_per_prompt (`int`、*optional*、デフォルトは 1) : プロンプトごとに生成する動画の数。

prompt_embeds (`torch.Tensor`, *任意*) : 事前に生成されたテキスト埋め込み。

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

prompt_attention_mask (`torch.Tensor`, *任意*) : テキスト埋め込み用の事前生成されたアテンションマスク。

negative_prompt_attention_mask (`torch.Tensor`, *任意*) : 負のテキスト埋め込み用の事前生成されたアテンションマスク。

max_sequence_length (`int`、デフォルト値は 512) : トークナイザーの最大シーケンス長。

device (`torch.device`, *任意*) : テンソスを配置するデバイス。

dtype (`torch.dtype`、*任意*) : テンソルのデータ型。

**戻り値:** `tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]`

以下の要素を含むタプル:
- `prompt_embeds`: ポジティブプロンプトのテキスト埋め込み
- `negative_prompt_embeds`: 負のプロンプトのテキスト埋め込み（ガイダンスを使用しない場合は None）
- `prompt_attention_mask`: ポジティブプロンプト用のアテンションマスク
- `negative_prompt_attention_mask`: 負のプロンプト用のアテンションマスク（ガイダンスを使用しない場合は None）

プロンプトをテキストエンコーダーの隠れ状態にエンコードします。

## MotifVideoPipelineOutput[[diffusers.MotifVideoPipelineOutput]]

#### diffusers.MotifVideoPipelineOutput[[diffusers.MotifVideoPipelineOutput]]

```python
diffusers.MotifVideoPipelineOutput(frames: Tensor)
```

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

**パラメータ:**

frames (`torch.Tensor`、`np.ndarray`、または List[List[PIL.Image.Image]]) : 動画出力のリスト - `batch_size,` の長さのネストされたリストであり、各サブリストには `num_frames.` の長さのノイズ除去済み PIL 画像シーケンスが含まれる場合があります。また、`(batch_size, num_frames, channels, height, width)` の形状の NumPy 配列または Torch テンソルである場合もあります。

Motif-Video パイプライン用の出力クラスです。

