import{s as ne,n as se,o as re}from"../chunks/scheduler.8c3d61f6.js";import{S as ae,i as ie,g as l,s,r as v,A as de,h as m,f as t,c as r,j as A,u as M,x as G,k as N,y as Z,a as n,v as x,d as D,t as $,w as C}from"../chunks/index.da70eac4.js";import{D as te}from"../chunks/Docstring.ee4b6913.js";import{C as le}from"../chunks/CodeBlock.00a903b3.js";import{H as Q,E as me}from"../chunks/EditOnGithub.1e64e623.js";function fe(B){let a,U,X,q,f,z,c,F='A Diffusion Transformer model for 3D data from <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a> was introduced in <a href="https://github.com/THUDM/CogVideo/blob/main/resources/CogVideoX.pdf" rel="nofollow">CogVideoX: Text-to-Video Diffusion Models with An Expert Transformer</a> by Tsinghua University &amp; ZhipuAI.',k,p,K="The model can be loaded with the following code snippet.",E,u,R,_,W,i,h,Y,y,ee='A Transformer model for video-like data in <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a>.',H,g,j,d,T,J,V,oe='The output of <a href="/docs/diffusers/pr_7873/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',I,b,O,w,P;return f=new Q({props:{title:"CogVideoXTransformer3DModel",local:"cogvideoxtransformer3dmodel",headingTag:"h1"}}),u=new le({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZGVvWFRyYW5zZm9ybWVyM0RNb2RlbCUwQSUwQXZhZSUyMCUzRCUyMENvZ1ZpZGVvWFRyYW5zZm9ybWVyM0RNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyVEhVRE0lMkZDb2dWaWRlb1gtMmIlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogVideoXTransformer3DModel

vae = CogVideoXTransformer3DModel.from_pretrained(<span class="hljs-string">&quot;THUDM/CogVideoX-2b&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),_=new Q({props:{title:"CogVideoXTransformer3DModel",local:"diffusers.CogVideoXTransformer3DModel",headingTag:"h2"}}),h=new te({props:{name:"class diffusers.CogVideoXTransformer3DModel",anchor:"diffusers.CogVideoXTransformer3DModel",parameters:[{name:"num_attention_heads",val:": int = 30"},{name:"attention_head_dim",val:": int = 64"},{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": Optional = 16"},{name:"flip_sin_to_cos",val:": bool = True"},{name:"freq_shift",val:": int = 0"},{name:"time_embed_dim",val:": int = 512"},{name:"text_embed_dim",val:": int = 4096"},{name:"num_layers",val:": int = 30"},{name:"dropout",val:": float = 0.0"},{name:"attention_bias",val:": bool = True"},{name:"sample_width",val:": int = 90"},{name:"sample_height",val:": int = 60"},{name:"sample_frames",val:": int = 49"},{name:"patch_size",val:": int = 2"},{name:"temporal_compression_ratio",val:": int = 4"},{name:"max_text_seq_length",val:": int = 226"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"timestep_activation_fn",val:": str = 'silu'"},{name:"norm_elementwise_affine",val:": bool = True"},{name:"norm_eps",val:": float = 1e-05"},{name:"spatial_interpolation_scale",val:": float = 1.875"},{name:"temporal_interpolation_scale",val:": float = 1.0"}],parametersDescription:[{anchor:"diffusers.CogVideoXTransformer3DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>30</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.CogVideoXTransformer3DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.CogVideoXTransformer3DModel.flip_sin_to_cos",description:`<strong>flip_sin_to_cos</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to flip the sin to cos in the time embedding.`,name:"flip_sin_to_cos"},{anchor:"diffusers.CogVideoXTransformer3DModel.time_embed_dim",description:`<strong>time_embed_dim</strong> (<code>int</code>, defaults to <code>512</code>) &#x2014;
Output dimension of timestep embeddings.`,name:"time_embed_dim"},{anchor:"diffusers.CogVideoXTransformer3DModel.text_embed_dim",description:`<strong>text_embed_dim</strong> (<code>int</code>, defaults to <code>4096</code>) &#x2014;
Input dimension of text embeddings from the text encoder.`,name:"text_embed_dim"},{anchor:"diffusers.CogVideoXTransformer3DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>30</code>) &#x2014;
The number of layers of Transformer blocks to use.`,name:"num_layers"},{anchor:"diffusers.CogVideoXTransformer3DModel.dropout",description:`<strong>dropout</strong> (<code>float</code>, defaults to <code>0.0</code>) &#x2014;
The dropout probability to use.`,name:"dropout"},{anchor:"diffusers.CogVideoXTransformer3DModel.attention_bias",description:`<strong>attention_bias</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether or not to use bias in the attention projection layers.`,name:"attention_bias"},{anchor:"diffusers.CogVideoXTransformer3DModel.sample_width",description:`<strong>sample_width</strong> (<code>int</code>, defaults to <code>90</code>) &#x2014;
The width of the input latents.`,name:"sample_width"},{anchor:"diffusers.CogVideoXTransformer3DModel.sample_height",description:`<strong>sample_height</strong> (<code>int</code>, defaults to <code>60</code>) &#x2014;
The height of the input latents.`,name:"sample_height"},{anchor:"diffusers.CogVideoXTransformer3DModel.sample_frames",description:`<strong>sample_frames</strong> (<code>int</code>, defaults to <code>49</code>) &#x2014;
The number of frames in the input latents. Note that this parameter was incorrectly initialized to 49
instead of 13 because CogVideoX processed 13 latent frames at once in its default and recommended settings,
but cannot be changed to the correct value to ensure backwards compatibility. To create a transformer with
K latent frames, the correct value to pass here would be: ((K - 1) * temporal_compression_ratio + 1).`,name:"sample_frames"},{anchor:"diffusers.CogVideoXTransformer3DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
The size of the patches to use in the patch embedding layer.`,name:"patch_size"},{anchor:"diffusers.CogVideoXTransformer3DModel.temporal_compression_ratio",description:`<strong>temporal_compression_ratio</strong> (<code>int</code>, defaults to <code>4</code>) &#x2014;
The compression ratio across the temporal dimension. See documentation for <code>sample_frames</code>.`,name:"temporal_compression_ratio"},{anchor:"diffusers.CogVideoXTransformer3DModel.max_text_seq_length",description:`<strong>max_text_seq_length</strong> (<code>int</code>, defaults to <code>226</code>) &#x2014;
The maximum sequence length of the input text embeddings.`,name:"max_text_seq_length"},{anchor:"diffusers.CogVideoXTransformer3DModel.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.CogVideoXTransformer3DModel.timestep_activation_fn",description:`<strong>timestep_activation_fn</strong> (<code>str</code>, defaults to <code>&quot;silu&quot;</code>) &#x2014;
Activation function to use when generating the timestep embeddings.`,name:"timestep_activation_fn"},{anchor:"diffusers.CogVideoXTransformer3DModel.norm_elementwise_affine",description:`<strong>norm_elementwise_affine</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether or not to use elementwise affine in normalization layers.`,name:"norm_elementwise_affine"},{anchor:"diffusers.CogVideoXTransformer3DModel.norm_eps",description:`<strong>norm_eps</strong> (<code>float</code>, defaults to <code>1e-5</code>) &#x2014;
The epsilon value to use in normalization layers.`,name:"norm_eps"},{anchor:"diffusers.CogVideoXTransformer3DModel.spatial_interpolation_scale",description:`<strong>spatial_interpolation_scale</strong> (<code>float</code>, defaults to <code>1.875</code>) &#x2014;
Scaling factor to apply in 3D positional embeddings across spatial dimensions.`,name:"spatial_interpolation_scale"},{anchor:"diffusers.CogVideoXTransformer3DModel.temporal_interpolation_scale",description:`<strong>temporal_interpolation_scale</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
Scaling factor to apply in 3D positional embeddings across temporal dimensions.`,name:"temporal_interpolation_scale"}],source:"https://github.com/huggingface/diffusers/blob/vr_7873/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L152"}}),g=new Q({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),T=new te({props:{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",parameters:[{name:"sample",val:": torch.Tensor"}],parametersDescription:[{anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput.sample",description:`<strong>sample</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, num_channels, height, width)</code> or <code>(batch size, num_vector_embeds - 1, num_latent_pixels)</code> if <a href="/docs/diffusers/pr_7873/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a> is discrete) &#x2014;
The hidden states output conditioned on the <code>encoder_hidden_states</code> input. If discrete, returns probability
distributions for the unnoised latent pixels.`,name:"sample"}],source:"https://github.com/huggingface/diffusers/blob/vr_7873/src/diffusers/models/modeling_outputs.py#L20"}}),b=new me({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogvideox_transformer3d.md"}}),{c(){a=l("meta"),U=s(),X=l("p"),q=s(),v(f.$$.fragment),z=s(),c=l("p"),c.innerHTML=F,k=s(),p=l("p"),p.textContent=K,E=s(),v(u.$$.fragment),R=s(),v(_.$$.fragment),W=s(),i=l("div"),v(h.$$.fragment),Y=s(),y=l("p"),y.innerHTML=ee,H=s(),v(g.$$.fragment),j=s(),d=l("div"),v(T.$$.fragment),J=s(),V=l("p"),V.innerHTML=oe,I=s(),v(b.$$.fragment),O=s(),w=l("p"),this.h()},l(e){const o=de("svelte-u9bgzb",document.head);a=m(o,"META",{name:!0,content:!0}),o.forEach(t),U=r(e),X=m(e,"P",{}),A(X).forEach(t),q=r(e),M(f.$$.fragment,e),z=r(e),c=m(e,"P",{"data-svelte-h":!0}),G(c)!=="svelte-2g99jo"&&(c.innerHTML=F),k=r(e),p=m(e,"P",{"data-svelte-h":!0}),G(p)!=="svelte-1vuni30"&&(p.textContent=K),E=r(e),M(u.$$.fragment,e),R=r(e),M(_.$$.fragment,e),W=r(e),i=m(e,"DIV",{class:!0});var S=A(i);M(h.$$.fragment,S),Y=r(S),y=m(S,"P",{"data-svelte-h":!0}),G(y)!=="svelte-98fbmm"&&(y.innerHTML=ee),S.forEach(t),H=r(e),M(g.$$.fragment,e),j=r(e),d=m(e,"DIV",{class:!0});var L=A(d);M(T.$$.fragment,L),J=r(L),V=m(L,"P",{"data-svelte-h":!0}),G(V)!=="svelte-7g7pwr"&&(V.innerHTML=oe),L.forEach(t),I=r(e),M(b.$$.fragment,e),O=r(e),w=m(e,"P",{}),A(w).forEach(t),this.h()},h(){N(a,"name","hf:doc:metadata"),N(a,"content",ce),N(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(d,"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){Z(document.head,a),n(e,U,o),n(e,X,o),n(e,q,o),x(f,e,o),n(e,z,o),n(e,c,o),n(e,k,o),n(e,p,o),n(e,E,o),x(u,e,o),n(e,R,o),x(_,e,o),n(e,W,o),n(e,i,o),x(h,i,null),Z(i,Y),Z(i,y),n(e,H,o),x(g,e,o),n(e,j,o),n(e,d,o),x(T,d,null),Z(d,J),Z(d,V),n(e,I,o),x(b,e,o),n(e,O,o),n(e,w,o),P=!0},p:se,i(e){P||(D(f.$$.fragment,e),D(u.$$.fragment,e),D(_.$$.fragment,e),D(h.$$.fragment,e),D(g.$$.fragment,e),D(T.$$.fragment,e),D(b.$$.fragment,e),P=!0)},o(e){$(f.$$.fragment,e),$(u.$$.fragment,e),$(_.$$.fragment,e),$(h.$$.fragment,e),$(g.$$.fragment,e),$(T.$$.fragment,e),$(b.$$.fragment,e),P=!1},d(e){e&&(t(U),t(X),t(q),t(z),t(c),t(k),t(p),t(E),t(R),t(W),t(i),t(H),t(j),t(d),t(I),t(O),t(w)),t(a),C(f,e),C(u,e),C(_,e),C(h),C(g,e),C(T),C(b,e)}}}const ce='{"title":"CogVideoXTransformer3DModel","local":"cogvideoxtransformer3dmodel","sections":[{"title":"CogVideoXTransformer3DModel","local":"diffusers.CogVideoXTransformer3DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function pe(B){return re(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class be extends ae{constructor(a){super(),ie(this,a,pe,fe,ne,{})}}export{be as component};
