Buckets:

download
raw
20.2 kB
import{s as ne,n as ae,o as se}from"../chunks/scheduler.53228c21.js";import{S as re,i as ie,e as d,s as a,c as b,h as de,a as c,d as t,b as s,f as S,g as w,j as W,k as A,l as x,m as n,n as L,t as M,o as y,p as k}from"../chunks/index.cac5d66a.js";import{C as ce}from"../chunks/CopyLLMTxtMenu.127444ce.js";import{D as oe}from"../chunks/Docstring.3f02c614.js";import{C as le}from"../chunks/CodeBlock.606cbaf4.js";import{H as te,E as me}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.1e8e5da3.js";function fe(Y){let i,z,D,I,m,q,f,R,u,Q='A Diffusion Transformer model for 3D data from <a href="https://huggingface.co/Lightricks/LTX-2" rel="nofollow">LTX</a> was introduced by Lightricks.',E,_,B="The model can be loaded with the following code snippet.",U,p,P,h,C,r,g,j,X,K='A Transformer model for video-like data used in <a href="https://huggingface.co/Lightricks/LTX-Video" rel="nofollow">LTX</a>.',H,l,T,O,V,ee="Forward pass for LTX-2.0 audiovisual video transformer.",F,v,J,N,G;return m=new ce({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),f=new te({props:{title:"LTX2VideoTransformer3DModel",local:"ltx2videotransformer3dmodel",headingTag:"h1"}}),p=new le({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExUWDJWaWRlb1RyYW5zZm9ybWVyM0RNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwTFRYMlZpZGVvVHJhbnNmb3JtZXIzRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJMaWdodHJpY2tzJTJGTFRYLTIlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LTX2VideoTransformer3DModel
transformer = LTX2VideoTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;Lightricks/LTX-2&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,lang:"python",wrap:!1}}),h=new te({props:{title:"LTX2VideoTransformer3DModel",local:"diffusers.LTX2VideoTransformer3DModel",headingTag:"h2"}}),g=new oe({props:{name:"class diffusers.LTX2VideoTransformer3DModel",anchor:"diffusers.LTX2VideoTransformer3DModel",parameters:[{name:"in_channels",val:": int = 128"},{name:"out_channels",val:": int | None = 128"},{name:"patch_size",val:": int = 1"},{name:"patch_size_t",val:": int = 1"},{name:"num_attention_heads",val:": int = 32"},{name:"attention_head_dim",val:": int = 128"},{name:"cross_attention_dim",val:": int = 4096"},{name:"vae_scale_factors",val:": tuple = (8, 32, 32)"},{name:"pos_embed_max_pos",val:": int = 20"},{name:"base_height",val:": int = 2048"},{name:"base_width",val:": int = 2048"},{name:"gated_attn",val:": bool = False"},{name:"cross_attn_mod",val:": bool = False"},{name:"audio_in_channels",val:": int = 128"},{name:"audio_out_channels",val:": int | None = 128"},{name:"audio_patch_size",val:": int = 1"},{name:"audio_patch_size_t",val:": int = 1"},{name:"audio_num_attention_heads",val:": int = 32"},{name:"audio_attention_head_dim",val:": int = 64"},{name:"audio_cross_attention_dim",val:": int = 2048"},{name:"audio_scale_factor",val:": int = 4"},{name:"audio_pos_embed_max_pos",val:": int = 20"},{name:"audio_sampling_rate",val:": int = 16000"},{name:"audio_hop_length",val:": int = 160"},{name:"audio_gated_attn",val:": bool = False"},{name:"audio_cross_attn_mod",val:": bool = False"},{name:"num_layers",val:": int = 48"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"qk_norm",val:": str = 'rms_norm_across_heads'"},{name:"norm_elementwise_affine",val:": bool = False"},{name:"norm_eps",val:": float = 1e-06"},{name:"caption_channels",val:": int = 3840"},{name:"attention_bias",val:": bool = True"},{name:"attention_out_bias",val:": bool = True"},{name:"rope_theta",val:": float = 10000.0"},{name:"rope_double_precision",val:": bool = True"},{name:"causal_offset",val:": int = 1"},{name:"timestep_scale_multiplier",val:": int = 1000"},{name:"cross_attn_timestep_scale_multiplier",val:": int = 1000"},{name:"rope_type",val:": str = 'interleaved'"},{name:"use_prompt_embeddings",val:" = True"},{name:"perturbed_attn",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.LTX2VideoTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.LTX2VideoTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.LTX2VideoTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
The size of the spatial patches to use in the patch embedding layer.`,name:"patch_size"},{anchor:"diffusers.LTX2VideoTransformer3DModel.patch_size_t",description:`<strong>patch_size_t</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
The size of the tmeporal patches to use in the patch embedding layer.`,name:"patch_size_t"},{anchor:"diffusers.LTX2VideoTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>32</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.LTX2VideoTransformer3DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.LTX2VideoTransformer3DModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (<code>int</code>, defaults to <code>2048 </code>) &#x2014;
The number of channels for cross attention heads.`,name:"cross_attention_dim"},{anchor:"diffusers.LTX2VideoTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>28</code>) &#x2014;
The number of layers of Transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.LTX2VideoTransformer3DModel.activation_fn",description:`<strong>activation_fn</strong> (<code>str</code>, defaults to <code>&quot;gelu-approximate&quot;</code>) &#x2014;
Activation function to use in feed-forward.`,name:"activation_fn"},{anchor:"diffusers.LTX2VideoTransformer3DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>str</code>, defaults to <code>&quot;rms_norm_across_heads&quot;</code>) &#x2014;
The normalization layer to use.`,name:"qk_norm"}],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_ltx2.py#L1062"}}),T=new oe({props:{name:"forward",anchor:"diffusers.LTX2VideoTransformer3DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"audio_hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"audio_encoder_hidden_states",val:": Tensor"},{name:"timestep",val:": LongTensor"},{name:"audio_timestep",val:": torch.LongTensor | None = None"},{name:"sigma",val:": torch.Tensor | None = None"},{name:"audio_sigma",val:": torch.Tensor | None = None"},{name:"encoder_attention_mask",val:": torch.Tensor | None = None"},{name:"audio_encoder_attention_mask",val:": torch.Tensor | None = None"},{name:"num_frames",val:": int | None = None"},{name:"height",val:": int | None = None"},{name:"width",val:": int | None = None"},{name:"fps",val:": float = 24.0"},{name:"audio_num_frames",val:": int | None = None"},{name:"video_coords",val:": torch.Tensor | None = None"},{name:"audio_coords",val:": torch.Tensor | None = None"},{name:"isolate_modalities",val:": bool = False"},{name:"spatio_temporal_guidance_blocks",val:": list[int] | None = None"},{name:"perturbation_mask",val:": torch.Tensor | None = None"},{name:"use_cross_timestep",val:": bool = False"},{name:"attention_kwargs",val:": dict[str, typing.Any] | None = None"},{name:"video_self_attention_mask",val:": torch.Tensor | None = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Input patchified video latents of shape <code>(batch_size, num_video_tokens, in_channels)</code>.`,name:"hidden_states"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_hidden_states",description:`<strong>audio_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Input patchified audio latents of shape <code>(batch_size, num_audio_tokens, audio_in_channels)</code>.`,name:"audio_hidden_states"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Input video text embeddings of shape <code>(batch_size, text_seq_len, self.config.caption_channels)</code>.`,name:"encoder_hidden_states"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_encoder_hidden_states",description:`<strong>audio_encoder_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Input audio text embeddings of shape <code>(batch_size, text_seq_len, self.config.caption_channels)</code>.`,name:"audio_encoder_hidden_states"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.Tensor</code>) &#x2014;
Input timestep of shape <code>(batch_size, num_video_tokens)</code>. These should already be scaled by
<code>self.config.timestep_scale_multiplier</code>.`,name:"timestep"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_timestep",description:`<strong>audio_timestep</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Input timestep of shape <code>(batch_size,)</code> or <code>(batch_size, num_audio_tokens)</code> for audio modulation
params. This is only used by certain pipelines such as the I2V pipeline.`,name:"audio_timestep"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.sigma",description:`<strong>sigma</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Input scaled timestep of shape (batch_size,). Used for video prompt cross attention modulation in
models such as LTX-2.3.`,name:"sigma"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_sigma",description:`<strong>audio_sigma</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Input scaled timestep of shape (batch_size,). Used for audio prompt cross attention modulation in
models such as LTX-2.3. If <code>sigma</code> is supplied but <code>audio_sigma</code> is not, <code>audio_sigma</code> will be set to
the provided <code>sigma</code> value.`,name:"audio_sigma"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Optional multiplicative text attention mask of shape <code>(batch_size, text_seq_len)</code>.`,name:"encoder_attention_mask"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_encoder_attention_mask",description:`<strong>audio_encoder_attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Optional multiplicative text attention mask of shape <code>(batch_size, text_seq_len)</code> for audio modeling.`,name:"audio_encoder_attention_mask"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.num_frames",description:`<strong>num_frames</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The number of latent video frames. Used if calculating the video coordinates for RoPE.`,name:"num_frames"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The latent video height. Used if calculating the video coordinates for RoPE.`,name:"height"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The latent video width. Used if calculating the video coordinates for RoPE.`,name:"width"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.fps",description:`<strong>fps</strong> &#x2014; (<code>float</code>, <em>optional</em>, defaults to <code>24.0</code>):
The desired frames per second of the generated video. Used if calculating the video coordinates for
RoPE.`,name:"fps"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_num_frames",description:`<strong>audio_num_frames</strong> &#x2014; (<code>int</code>, <em>optional</em>):
The number of latent audio frames. Used if calculating the audio coordinates for RoPE.`,name:"audio_num_frames"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.video_coords",description:`<strong>video_coords</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
The video coordinates to be used when calculating the rotary positional embeddings (RoPE) of shape
<code>(batch_size, 3, num_video_tokens, 2)</code>. If not supplied, this will be calculated inside <code>forward</code>.`,name:"video_coords"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.audio_coords",description:`<strong>audio_coords</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
The audio coordinates to be used when calculating the rotary positional embeddings (RoPE) of shape
<code>(batch_size, 1, num_audio_tokens, 2)</code>. If not supplied, this will be calculated inside <code>forward</code>.`,name:"audio_coords"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.isolate_modalities",description:`<strong>isolate_modalities</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to isolate each modality by turning off cross-modality (audio-to-video and video-to-audio)
cross attention (for all blocks). Use for modality guidance in LTX-2.3.`,name:"isolate_modalities"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.spatio_temporal_guidance_blocks",description:`<strong>spatio_temporal_guidance_blocks</strong> (<code>list[int]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The transformer block indices at which to apply spatio-temporal guidance (STG), which shortcuts the
self-attention operations by simply using the values rather than the full scaled dot-product attention
(SDPA) operation. If <code>None</code> or empty, STG will not be applied to any block.`,name:"spatio_temporal_guidance_blocks"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.perturbation_mask",description:`<strong>perturbation_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Perturbation mask for STG of shape <code>(batch_size,)</code> or <code>(batch_size, 1, 1)</code>. Should be 0 at batch
elements where STG should be applied and 1 elsewhere. If STG is being used but <code>peturbation_mask</code> is
not supplied, will default to applying STG (perturbing) all batch elements.`,name:"perturbation_mask"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.use_cross_timestep",description:`<strong>use_cross_timestep</strong> (<code>bool</code> <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to use the cross modality (audio is the cross modality of video, and vice versa) sigma when
calculating the cross attention modulation parameters. <code>True</code> is the newer (e.g. LTX-2.3) behavior;
<code>False</code> is the legacy LTX-2.0 behavior.`,name:"use_cross_timestep"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict[str, Any]</code>, <em>optional</em>) &#x2014;
Optional dict of keyword args to be passed to the attention processor.`,name:"attention_kwargs"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.video_self_attention_mask",description:`<strong>video_self_attention_mask</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Optional multiplicative self-attention mask of shape <code>(batch_size, num_video_tokens, num_video_tokens)</code>
applied to the video self-attention in each transformer block. Values in <code>[0, 1]</code> where <code>1</code> means full
attention and <code>0</code> means masked. Used e.g. by the IC-LoRA pipeline to control attention strength between
noisy tokens and appended reference tokens. Audio self-attention is not affected.`,name:"video_self_attention_mask"},{anchor:"diffusers.LTX2VideoTransformer3DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to return a dict-like structured output of type <code>AudioVisualModelOutput</code> or a tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13751/src/diffusers/models/transformers/transformer_ltx2.py#L1321",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>If <code>return_dict</code> is <code>True</code>, returns a structured output of type <code>AudioVisualModelOutput</code>, otherwise a
<code>tuple</code> is returned where the first element is the denoised video latent patch sequence and the second
element is the denoised audio latent patch sequence.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>AudioVisualModelOutput</code> or <code>tuple</code></p>
`}}),v=new me({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/ltx2_video_transformer3d.md"}}),{c(){i=d("meta"),z=a(),D=d("p"),I=a(),b(m.$$.fragment),q=a(),b(f.$$.fragment),R=a(),u=d("p"),u.innerHTML=Q,E=a(),_=d("p"),_.textContent=B,U=a(),b(p.$$.fragment),P=a(),b(h.$$.fragment),C=a(),r=d("div"),b(g.$$.fragment),j=a(),X=d("p"),X.innerHTML=K,H=a(),l=d("div"),b(T.$$.fragment),O=a(),V=d("p"),V.textContent=ee,F=a(),b(v.$$.fragment),J=a(),N=d("p"),this.h()},l(e){const o=de("svelte-u9bgzb",document.head);i=c(o,"META",{name:!0,content:!0}),o.forEach(t),z=s(e),D=c(e,"P",{}),S(D).forEach(t),I=s(e),w(m.$$.fragment,e),q=s(e),w(f.$$.fragment,e),R=s(e),u=c(e,"P",{"data-svelte-h":!0}),W(u)!=="svelte-wkilr6"&&(u.innerHTML=Q),E=s(e),_=c(e,"P",{"data-svelte-h":!0}),W(_)!=="svelte-1vuni30"&&(_.textContent=B),U=s(e),w(p.$$.fragment,e),P=s(e),w(h.$$.fragment,e),C=s(e),r=c(e,"DIV",{class:!0});var $=S(r);w(g.$$.fragment,$),j=s($),X=c($,"P",{"data-svelte-h":!0}),W(X)!=="svelte-6rnpr5"&&(X.innerHTML=K),H=s($),l=c($,"DIV",{class:!0});var Z=S(l);w(T.$$.fragment,Z),O=s(Z),V=c(Z,"P",{"data-svelte-h":!0}),W(V)!=="svelte-gfy8cw"&&(V.textContent=ee),Z.forEach(t),$.forEach(t),F=s(e),w(v.$$.fragment,e),J=s(e),N=c(e,"P",{}),S(N).forEach(t),this.h()},h(){A(i,"name","hf:doc:metadata"),A(i,"content",ue),A(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(r,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,o){x(document.head,i),n(e,z,o),n(e,D,o),n(e,I,o),L(m,e,o),n(e,q,o),L(f,e,o),n(e,R,o),n(e,u,o),n(e,E,o),n(e,_,o),n(e,U,o),L(p,e,o),n(e,P,o),L(h,e,o),n(e,C,o),n(e,r,o),L(g,r,null),x(r,j),x(r,X),x(r,H),x(r,l),L(T,l,null),x(l,O),x(l,V),n(e,F,o),L(v,e,o),n(e,J,o),n(e,N,o),G=!0},p:ae,i(e){G||(M(m.$$.fragment,e),M(f.$$.fragment,e),M(p.$$.fragment,e),M(h.$$.fragment,e),M(g.$$.fragment,e),M(T.$$.fragment,e),M(v.$$.fragment,e),G=!0)},o(e){y(m.$$.fragment,e),y(f.$$.fragment,e),y(p.$$.fragment,e),y(h.$$.fragment,e),y(g.$$.fragment,e),y(T.$$.fragment,e),y(v.$$.fragment,e),G=!1},d(e){e&&(t(z),t(D),t(I),t(q),t(R),t(u),t(E),t(_),t(U),t(P),t(C),t(r),t(F),t(J),t(N)),t(i),k(m,e),k(f,e),k(p,e),k(h,e),k(g),k(T),k(v,e)}}}const ue='{"title":"LTX2VideoTransformer3DModel","local":"ltx2videotransformer3dmodel","sections":[{"title":"LTX2VideoTransformer3DModel","local":"diffusers.LTX2VideoTransformer3DModel","sections":[],"depth":2}],"depth":1}';function _e(Y){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class we extends re{constructor(i){super(),ie(this,i,_e,fe,ne,{})}}export{we as component};

Xet Storage Details

Size:
20.2 kB
·
Xet hash:
a318eca9bf7a52d4767b7d1e596bf2560a62cc1925aec19df07be9ac51ee35cd

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