Diffusers documentation

KandinskyS2VTransformer3DModel

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.43.0).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

KandinskyS2VTransformer3DModel

Kandinsky S2V 1.0 的 Diffusion Transformer (DiT),以参考帧和语音轨道作为条件。

KandinskyS2VTransformer3DModel

class diffusers.KandinskyS2VTransformer3DModel

< >

( in_visual_dim: int = 16out_visual_dim: int = 16in_text_dim: int = 3584in_text_dim2: int = 768in_audio_dim: int = 3584time_dim: int = 512patch_size: tuple[int, int, int] = (1, 2, 2)frame_buckets: tuple[int, int, int] = (2, 4, 24)enable_framepack: bool = Trueindex_rope_ref_image: int = 40patch_proj1x_coef: tuple[int, int, int] = (1, 1, 1)patch_proj2x_coef: tuple[int, int, int] = (2, 2, 2)patch_proj4x_coef: tuple[int, int, int] = (4, 4, 4)model_dim: int = 1792ff_dim: int = 7168num_text_blocks: int = 2num_audio_blocks: int = 2num_visual_blocks: int = 32axes_dims: tuple[int, int, int] = (16, 24, 24)audio_inject_layers: tuple[int, ...] = ()text_rope_max_pos: int = 4096 )

语音到视频扩散 Transformer。

参数名称与训练检查点一致,因此转换后的 .safetensors 加载时无需进行键重映射。 推理的批处理大小为 1:序列经过打包,语音交叉注意力按帧对齐,因此 forward 接受一个前导批处理维度为 1 的输入,并将其压缩掉。

视觉流是一个打包序列 [memory | ref | visual]:

  • memory — 来自上一分块的 FramePack 上下文,经过 4x / 2x / 1x 时间下采样,放置在负的时间 RoPE 位置;
  • ref — 参考帧,固定于时间 RoPE 索引 index_rope_ref_image;
  • visual — 正在被去噪的含噪潜在变量。

memory 和 ref 是干净的,因此它们使用 t = 0 进行调制,而 visual 使用真实的时间步;调制同时包含两行,并通过索引按 token 进行选择。

forward

< >

( hidden_states: Tensorencoder_hidden_states: Tensoraudio_hidden_states: Tensorreference_hidden_states: Tensormemory_hidden_states: tuple[Tensor, Tensor, Tensor]timestep: Tensorpooled_projections: Tensorvisual_rope_pos: list[Tensor]reference_rope_pos: list[Tensor]memory_rope_pos: tuple[list[Tensor], list[Tensor], list[Tensor]]text_rope_pos: Tensoraudio_rope_pos: Tensorscale_factor: tuple[float, float, float] = (1.0, 1.0, 1.0)return_dict: bool = True ) → [~models.modeling_outputs.Transformer2DModelOutput] or tuple

参数

  • hidden_states — 带噪潜在变量,(1, T, H, W, C)。
  • encoder_hidden_states — 文本嵌入,(1, S_text, in_text_dim)。
  • audio_hidden_states — 语音特征,(1, S_audio, in_audio_dim)。
  • reference_hidden_states — 参考帧潜在表示,(1, 1, H, W, C)。
  • memory_hidden_states — 4x / 2x / 1x 的 FramePack 记忆,每个形状为 (1, T_i, H_i, W_i, C)。
  • timestep — 当前时间步,(1,)。
  • pooled_projections — 池化后的 CLIP 文本嵌入,(1, in_text_dim2)。
  • visual_rope_pos — 含噪潜在表示的逐轴 RoPE 位置。
  • reference_rope_pos — 参考帧的每个轴的 RoPE 位置。
  • memory_rope_pos — 每个 FramePack 内存尺度的各轴 RoPE 位置。
  • text_rope_pos — 文本 token 的一维 RoPE 位置。
  • audio_rope_pos — 每个语音 token 所属的潜在帧。
  • scale_factor — 每个轴的 RoPE 缩放因子,由分辨率桶决定。
  • return_dict — 返回 Transformer2DModelOutput 而不是元组。

返回值

[~models.modeling_outputs.Transformer2DModelOutput] 或 tuple

预测速度,其形状与 hidden_states相同。

对单个块进行去噪。

批处理大小必须为 1:序列是打包的,且语音交叉注意力是按帧对齐的。

Update on GitHub