# Motif-Video

[技术报告](https://arxiv.org/abs/2604.16503)

Motif-Video 是一个拥有 20 亿参数的扩散 Transformer，专为文本生成视频和图像生成视频而设计。它采用三阶段架构，包含 12 层双流 + 16 层单流 + 8 层 DDT 解码器层，具备用于在长视频序列下实现稳定文本-视频对齐的 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)
```

### 内存高效推理

对于显存小于 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/zh/api/models/motif_video_transformer_3d#diffusers.MotifVideoTransformer3DModel))：用于对编码后的视频潜在变量进行去噪的条件 Transformer 架构。

scheduler ([SchedulerMixin](/docs/diffusers/v0.43.0/zh/api/schedulers/overview#diffusers.SchedulerMixin))：用于与 `transformer` 配合，对编码后的视频潜变量进行去噪的调度器。应为继承自 `SchedulerMixin` 的类的实例，例如 [DPMSolverMultistepScheduler](/docs/diffusers/v0.43.0/zh/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler)。如果未提供，则使用预训练模型附带的调度器。

vae ([AutoencoderKLWan](/docs/diffusers/v0.43.0/zh/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan))：变分自编码器（VAE）模型，用于将视频编码为潜在表示，以及从潜在表示解码为视频。

text_encoder (`T5Gemma2Encoder`)：用于将文本提示编码为嵌入的主要文本编码器。

tokenizer (`PreTrainedTokenizerBase`)：与主文本编码器对应的分词器。

guider ([BaseGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.BaseGuidance))：要使用的引导方法。应为继承自 `BaseGuidance` 的类的实例，例如 [ClassifierFreeGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance)、[AdaptiveProjectedGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.AdaptiveProjectedGuidance) 或 [SkipLayerGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.SkipLayerGuidance)。如果未提供，则默认为 `ClassifierFreeGuidance`。

使用 Motif-Video 进行文本到视频生成的 Pipeline。

该模型继承自 [DiffusionPipeline](/docs/diffusers/v0.43.0/zh/api/pipelines/overview#diffusers.DiffusionPipeline)。有关为所有流水线实现的通用方法（下载、保存、在特定设备上运行等），请参阅父类文档。

#### __调用__[[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`。在未使用引导时将被忽略。

height (`int`，默认为 `736`)：生成视频的高度（以像素为单位）。

width (`int`，默认值为 `1280`)：生成视频的宽度（以像素为单位）。

num_frames (`int`，默认为 `121`)：要生成的视频帧数。

num_inference_steps (`int`, *可选*，默认为 50)：去噪步数。更多的去噪步数通常能带来更高质量的视频，但代价是推理速度变慢。

timesteps (`List[int]`, *可选*) : 用于去噪过程的自定义时间步。

num_videos_per_prompt (`int`，*可选*，默认为 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/zh/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) 而不是普通元组。

attention_kwargs (`dict`，*可选*)：传递给注意力处理器的参数。

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`, *可选*) : VAE 解码的批次大小。如果提供此参数且潜变量批次大小更大，则 VAE 解码将分块进行。

**返回：** [~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/zh/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) 或 `tuple`

如果 `return_dict` 为 `True`，则返回 [~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/zh/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput)；否则返回一个 `tuple`，其中第一个元素是生成的视频帧列表。

用于文本生成视频流水线的调用函数。

示例：
```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`，*可选*，默认为 1)：每个提示词生成的视频数量。

prompt_embeds (`torch.Tensor`, *可选*) : 预生成的文本嵌入。

negative_prompt_embeds (`torch.Tensor`, *可选*) : 预生成的负向文本嵌入。可用于轻松调整文本输入，*例如* 提示词权重。如果未提供，negative_prompt_embeds 将从 `negative_prompt` 输入参数生成。

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`：负面提示词（negative prompt）的文本嵌入（如果未使用 guidance，则为 None）
- `prompt_attention_mask`：正向提示词的注意力掩码
- `negative_prompt_attention_mask`：负面提示词的注意力掩码（如果未使用 guidance，则为 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/zh/api/models/motif_video_transformer_3d#diffusers.MotifVideoTransformer3DModel))：用于对编码后的视频潜在变量进行去噪的条件 Transformer 架构。

scheduler ([SchedulerMixin](/docs/diffusers/v0.43.0/zh/api/schedulers/overview#diffusers.SchedulerMixin))：用于与 `transformer` 配合，对编码后的视频潜变量进行去噪的调度器。应为继承自 `SchedulerMixin` 的类的实例，例如 [DPMSolverMultistepScheduler](/docs/diffusers/v0.43.0/zh/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler)。如果未提供，则使用预训练模型附带的调度器。

vae ([AutoencoderKLWan](/docs/diffusers/v0.43.0/zh/api/models/autoencoder_kl_wan#diffusers.AutoencoderKLWan))：变分自编码器（VAE）模型，用于将视频编码为潜在表示，以及从潜在表示解码为视频。

text_encoder (`T5Gemma2Encoder`)：用于将文本提示编码为嵌入的主要文本编码器。

tokenizer (`PreTrainedTokenizerBase`)：与主文本编码器对应的分词器。

feature_extractor (`SiglipImageProcessor`)：SigLIP 视觉编码器的图像处理器。

guider ([BaseGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.BaseGuidance))：要使用的引导方法。应为继承自 `BaseGuidance` 的类的实例，例如 [ClassifierFreeGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.ClassifierFreeGuidance)、[AdaptiveProjectedGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.AdaptiveProjectedGuidance) 或 [SkipLayerGuidance](/docs/diffusers/v0.43.0/zh/api/modular_diffusers/guiders#diffusers.SkipLayerGuidance)。如果未提供，则默认为 `ClassifierFreeGuidance`。

使用 Motif-Video 进行首帧条件控制，实现图像到视频生成的 Pipeline。

该模型继承自 [DiffusionPipeline](/docs/diffusers/v0.43.0/zh/api/pipelines/overview#diffusers.DiffusionPipeline)。有关为所有流水线实现的通用方法（下载、保存、在特定设备上运行等），请参阅父类文档。

#### __调用__[[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`，*可选*，默认为 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/zh/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) 而不是普通元组。

attention_kwargs (`dict`，*可选*)：传递给注意力处理器的参数。

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/zh/api/pipelines/motif_video#diffusers.MotifVideoPipelineOutput) 或 `tuple`

如果 `return_dict` 为 `True`，则返回 [~MotifVideoPipelineOutput](/docs/diffusers/v0.43.0/zh/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`，*可选*，默认为 1)：每个提示词生成的视频数量。

prompt_embeds (`torch.Tensor`, *可选*) : 预生成的文本嵌入。

negative_prompt_embeds (`torch.Tensor`, *可选*) : 预生成的负向文本嵌入。可用于轻松调整文本输入，*例如* 提示词权重。如果未提供，negative_prompt_embeds 将从 `negative_prompt` 输入参数生成。

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`：负面提示词（negative prompt）的文本嵌入（如果未使用 guidance，则为 None）
- `prompt_attention_mask`：正向提示词的注意力掩码
- `negative_prompt_attention_mask`：负面提示词的注意力掩码（如果未使用 guidance，则为 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 流水线的输出类。

