Buckets:

hf-doc-build/doc-dev / diffusers /pr_14385 /en /api /models /mochi_transformer3d.md
|
download
raw
4.82 kB

MochiTransformer3DModel

A Diffusion Transformer model for 3D video-like data was introduced in Mochi-1 Preview by Genmo.

The model can be loaded with the following code snippet.

from diffusers import MochiTransformer3DModel

transformer = MochiTransformer3DModel.from_pretrained("genmo/mochi-1-preview", subfolder="transformer", dtype=torch.float16).to("cuda")

MochiTransformer3DModel[[diffusers.MochiTransformer3DModel]]

diffusers.MochiTransformer3DModel[[diffusers.MochiTransformer3DModel]]

diffusers.MochiTransformer3DModel(patch_size: int = 2, num_attention_heads: int = 24, attention_head_dim: int = 128, num_layers: int = 48, pooled_projection_dim: int = 1536, in_channels: int = 12, out_channels: int | None = None, qk_norm: str = 'rms_norm', text_embed_dim: int = 4096, time_embed_dim: int = 256, activation_fn: str = 'swiglu', max_sequence_length: int = 256)

Source

Parameters:

patch_size (int, defaults to 2) : The size of the patches to use in the patch embedding layer.

num_attention_heads (int, defaults to 24) : The number of heads to use for multi-head attention.

attention_head_dim (int, defaults to 128) : The number of channels in each head.

num_layers (int, defaults to 48) : The number of layers of Transformer blocks to use.

in_channels (int, defaults to 12) : The number of channels in the input.

out_channels (int, optional, defaults to None) : The number of channels in the output.

qk_norm (str, defaults to "rms_norm") : The normalization layer to use.

text_embed_dim (int, defaults to 4096) : Input dimension of text embeddings from the text encoder.

time_embed_dim (int, defaults to 256) : Output dimension of timestep embeddings.

activation_fn (str, defaults to "swiglu") : Activation function to use in feed-forward.

max_sequence_length (int, defaults to 256) : The maximum sequence length of text embeddings supported.

A Transformer model for video-like data introduced in Mochi.

forward[[diffusers.MochiTransformer3DModel.forward]]

forward(hidden_states: Tensor, encoder_hidden_states: Tensor, timestep: LongTensor, encoder_attention_mask: Tensor, attention_kwargs: dict[str, typing.Any] | None = None, return_dict: bool = True)

Source

Parameters:

hidden_states (torch.Tensor of shape (batch_size, num_channels, num_frames, height, width)) : Input hidden_states.

encoder_hidden_states (torch.Tensor of shape (batch_size, sequence_len, embed_dims)) : Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.

timestep (torch.LongTensor) : Used to indicate denoising step.

encoder_attention_mask (torch.Tensor) : Mask applied to encoder_hidden_states during attention.

attention_kwargs (dict, optional) : A kwargs dictionary that if specified is passed along to the AttentionProcessor as defined under self.processor in diffusers.models.attention_processor.

return_dict (bool, optional, defaults to True) : Whether or not to return a ~models.transformer_2d.Transformer2DModelOutput instead of a plain tuple.

Returns: torch.Tensor

The denoised output tensor of shape (batch_size, out_channels, num_frames, height, width).

The MochiTransformer3DModel forward method.

Transformer2DModelOutput[[diffusers.models.modeling_outputs.Transformer2DModelOutput]]

diffusers.models.modeling_outputs.Transformer2DModelOutput[[diffusers.models.modeling_outputs.Transformer2DModelOutput]]

diffusers.models.modeling_outputs.Transformer2DModelOutput(sample: torch.Tensor)

Source

Parameters:

sample (torch.Tensor of shape (batch_size, num_channels, height, width) or (batch size, num_vector_embeds - 1, num_latent_pixels) if Transformer2DModel is discrete) : The hidden states output conditioned on the encoder_hidden_states input. If discrete, returns probability distributions for the unnoised latent pixels.

The output of Transformer2DModel.

Xet Storage Details

Size:
4.82 kB
·
Xet hash:
418adf07144d471db23f84883054b48c0fef85a70a7f6571af18e599865b88a1

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