Diffusers documentation

LTXVideoTransformer3DModel

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

and get access to the augmented documentation experience

to get started

LTXVideoTransformer3DModel

Một mô hình Diffusion Transformer cho dữ liệu 3D từ LTX đã được giới thiệu bởi Lightricks.

Mô hình có thể được tải bằng đoạn mã sau.

from diffusers import LTXVideoTransformer3DModel

transformer = LTXVideoTransformer3DModel.from_pretrained("Lightricks/LTX-Video", subfolder="transformer", dtype=torch.bfloat16).to("cuda")  # or "mps", "xpu", "cpu"

LTXVideoTransformer3DModel

lớp diffusers.LTXVideoTransformer3DModel

< >

( in_channels: int = 128out_channels: int = 128patch_size: int = 1patch_size_t: int = 1num_attention_heads: int = 32attention_head_dim: int = 64cross_attention_dim: int = 2048num_layers: int = 28activation_fn: str = 'gelu-approximate'qk_norm: str = 'rms_norm_across_heads'norm_elementwise_affine: bool = Falsenorm_eps: float = 1e-06caption_channels: int = 4096attention_bias: bool = Trueattention_out_bias: bool = True )

Tham số

  • in_channels (int, mặc định là 128) — Số lượng kênh trong đầu vào.
  • out_channels (int, mặc định là 128) — Số lượng kênh trong đầu ra.
  • patch_size (int, mặc định là 1) — Kích thước của các patch không gian được sử dụng trong lớp nhúng patch.
  • patch_size_t (int, mặc định là 1) — Kích thước của các patch thời gian (temporal patches) được sử dụng trong lớp nhúng patch (patch embedding layer).
  • num_attention_heads (int, mặc định là 32) — Số lượng đầu (heads) được sử dụng cho cơ chế chú ý đa đầu (multi-head attention).
  • attention_head_dim (int, mặc định là 64) — Số lượng kênh trong mỗi head.
  • cross_attention_dim (int, mặc định là 2048 ) — Số lượng kênh cho các đầu chú ý chéo (cross attention).
  • num_layers (int, mặc định là 28) — Số lượng lớp khối Transformer cần sử dụng.
  • activation_fn (str, mặc định là "gelu-approximate") — Hàm kích hoạt được sử dụng trong mạng truyền thẳng.
  • qk_norm (str, mặc định là "rms_norm_across_heads") — Lớp chuẩn hóa cần sử dụng.

Một mô hình Transformer cho dữ liệu dạng video được sử dụng trong LTX.

forward

< >

( hidden_states: Tensorencoder_hidden_states: Tensortimestep: LongTensorencoder_attention_mask: Tensornum_frames: int | None = Noneheight: int | None = Nonewidth: int | None = Nonerope_interpolation_scale: typing.Union[tuple[float, float, float], torch.Tensor, NoneType] = Nonevideo_coords: typing.Optional[torch.Tensor] = Noneattention_kwargs: dict[str, typing.Any] | None = Nonereturn_dict: bool = True ) → torch.Tensor

Tham số

  • hidden_states (torch.Tensor có hình dạng (batch_size, sequence_length, in_channels)) — hidden_states đầu vào.
  • encoder_hidden_states (torch.Tensor có hình dạng (batch_size, sequence_len, embed_dims)) — Các embedding điều kiện (embedding được tính từ các điều kiện đầu vào như prompt) cần sử dụng.
  • timestep (torch.LongTensor) — Dùng để chỉ bước khử nhiễu.
  • encoder_attention_mask (torch.Tensor) — Mặt nạ được áp dụng cho encoder_hidden_states trong quá trình chú ý.
  • num_frames (int, tùy chọn) — Số lượng khung hình trong video được sử dụng để tính các nhúng vị trí quay (rotary positional embeddings).
  • height (int, tùy chọn) — Chiều cao của latent được dùng để tính các nhúng vị trí quay (rotary positional embeddings).
  • width (int, tùy chọn) — Chiều rộng của latent được dùng để tính các nhúng vị trí quay (rotary positional embeddings).
  • rope_interpolation_scale (tuple của float hoặc torch.Tensor, tùy chọn) — Thang nội suy được sử dụng bởi các nhúng vị trí quay (rotary positional embeddings).
  • video_coords (torch.Tensor, tùy chọn) — Tọa độ video đã được tính trước, được sử dụng bởi các nhúng vị trí quay (rotary positional embeddings).
  • attention_kwargs (dict, tùy chọn) — Một từ điển kwargs, nếu được chỉ định, sẽ được truyền đến AttentionProcessor như đã định nghĩa dưới self.processor trong diffusers.models.attention_processor.
  • return_dict (bool, tùy chọn, mặc định là True) — Có nên trả về một ~models.transformer_2d.Transformer2DModelOutput thay vì một tuple thông thường hay không.

Trả về

torch.Tensor

Tensor đầu ra đã khử nhiễu có hình dạng (batch_size, sequence_length, out_channels).

Phương thức forward của LTXVideoTransformer3DModel.

Transformer2DModelOutput

lớp diffusers.models.modeling_outputs.Transformer2DModelOutput

< >

( sample: torch.Tensor )

Tham số

  • sample (torch.Tensor có hình dạng (batch_size, num_channels, height, width) hoặc (batch size, num_vector_embeds - 1, num_latent_pixels) nếu Transformer2DModel là rời rạc) — Trạng thái ẩn đầu ra được điều kiện bởi đầu vào encoder_hidden_states. Nếu là rời rạc, trả về các phân phối xác suất cho các pixel tiềm ẩn không nhiễu.

Đầu ra của Transformer2DModel.

Update on GitHub