Buckets:

rtrm's picture
download
raw
16.1 kB
import{s as ne,n as ae,o as re}from"../chunks/scheduler.53228c21.js";import{S as se,i as ie,e as d,s as a,c as b,h as de,a as c,d as t,b as r,f as W,g as x,j as A,k as G,l as M,m as n,n as w,t as L,o as $,p as y}from"../chunks/index.100fac89.js";import{C as ce}from"../chunks/CopyLLMTxtMenu.5dcd659f.js";import{D as oe}from"../chunks/Docstring.8867d421.js";import{C as le}from"../chunks/CodeBlock.d30a6509.js";import{H as te,E as me}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.3fe6de9f.js";function fe(S){let i,N,k,q,m,E,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.',I,_,B="The model can be loaded with the following code snippet.",C,p,P,h,J,s,g,Y,V,K='A Transformer model for video-like data used in <a href="https://huggingface.co/Lightricks/LTX-Video" rel="nofollow">LTX</a>.',O,l,T,F,X,ee="Forward pass for LTX-2.0 audiovisual video transformer.",U,v,Z,z,j;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>)`,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:"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:"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'"}],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_13182/src/diffusers/models/transformers/transformer_ltx2.py#L862"}}),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:"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:"attention_kwargs",val:": dict[str, typing.Any] | 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.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.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.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_13182/src/diffusers/models/transformers/transformer_ltx2.py#L1095",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"),N=a(),k=d("p"),q=a(),b(m.$$.fragment),E=a(),b(f.$$.fragment),R=a(),u=d("p"),u.innerHTML=Q,I=a(),_=d("p"),_.textContent=B,C=a(),b(p.$$.fragment),P=a(),b(h.$$.fragment),J=a(),s=d("div"),b(g.$$.fragment),Y=a(),V=d("p"),V.innerHTML=K,O=a(),l=d("div"),b(T.$$.fragment),F=a(),X=d("p"),X.textContent=ee,U=a(),b(v.$$.fragment),Z=a(),z=d("p"),this.h()},l(e){const o=de("svelte-u9bgzb",document.head);i=c(o,"META",{name:!0,content:!0}),o.forEach(t),N=r(e),k=c(e,"P",{}),W(k).forEach(t),q=r(e),x(m.$$.fragment,e),E=r(e),x(f.$$.fragment,e),R=r(e),u=c(e,"P",{"data-svelte-h":!0}),A(u)!=="svelte-wkilr6"&&(u.innerHTML=Q),I=r(e),_=c(e,"P",{"data-svelte-h":!0}),A(_)!=="svelte-1vuni30"&&(_.textContent=B),C=r(e),x(p.$$.fragment,e),P=r(e),x(h.$$.fragment,e),J=r(e),s=c(e,"DIV",{class:!0});var D=W(s);x(g.$$.fragment,D),Y=r(D),V=c(D,"P",{"data-svelte-h":!0}),A(V)!=="svelte-6rnpr5"&&(V.innerHTML=K),O=r(D),l=c(D,"DIV",{class:!0});var H=W(l);x(T.$$.fragment,H),F=r(H),X=c(H,"P",{"data-svelte-h":!0}),A(X)!=="svelte-gfy8cw"&&(X.textContent=ee),H.forEach(t),D.forEach(t),U=r(e),x(v.$$.fragment,e),Z=r(e),z=c(e,"P",{}),W(z).forEach(t),this.h()},h(){G(i,"name","hf:doc:metadata"),G(i,"content",ue),G(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),G(s,"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){M(document.head,i),n(e,N,o),n(e,k,o),n(e,q,o),w(m,e,o),n(e,E,o),w(f,e,o),n(e,R,o),n(e,u,o),n(e,I,o),n(e,_,o),n(e,C,o),w(p,e,o),n(e,P,o),w(h,e,o),n(e,J,o),n(e,s,o),w(g,s,null),M(s,Y),M(s,V),M(s,O),M(s,l),w(T,l,null),M(l,F),M(l,X),n(e,U,o),w(v,e,o),n(e,Z,o),n(e,z,o),j=!0},p:ae,i(e){j||(L(m.$$.fragment,e),L(f.$$.fragment,e),L(p.$$.fragment,e),L(h.$$.fragment,e),L(g.$$.fragment,e),L(T.$$.fragment,e),L(v.$$.fragment,e),j=!0)},o(e){$(m.$$.fragment,e),$(f.$$.fragment,e),$(p.$$.fragment,e),$(h.$$.fragment,e),$(g.$$.fragment,e),$(T.$$.fragment,e),$(v.$$.fragment,e),j=!1},d(e){e&&(t(N),t(k),t(q),t(E),t(R),t(u),t(I),t(_),t(C),t(P),t(J),t(s),t(U),t(Z),t(z)),t(i),y(m,e),y(f,e),y(p,e),y(h,e),y(g),y(T),y(v,e)}}}const ue='{"title":"LTX2VideoTransformer3DModel","local":"ltx2videotransformer3dmodel","sections":[{"title":"LTX2VideoTransformer3DModel","local":"diffusers.LTX2VideoTransformer3DModel","sections":[],"depth":2}],"depth":1}';function _e(S){return re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends se{constructor(i){super(),ie(this,i,_e,fe,ne,{})}}export{xe as component};

Xet Storage Details

Size:
16.1 kB
·
Xet hash:
70473f99bbb5ce0c79022ef9463186e6c4e6946ce9e59ffefe0596b01389f8e5

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