Buckets:

rtrm's picture
download
raw
17.4 kB
import{s as qe,o as ke,n as Xe}from"../chunks/scheduler.8c3d61f6.js";import{S as Ze,i as je,g as l,s,r as p,A as Pe,h as m,f as o,c as r,j as A,u,x as C,k as H,y as a,a as i,v as g,d as _,t as h,w as b}from"../chunks/index.da70eac4.js";import{T as we}from"../chunks/Tip.1d9b8c37.js";import{D as J}from"../chunks/Docstring.6b390b9a.js";import{C as Ue}from"../chunks/CodeBlock.00a903b3.js";import{H as $e,E as Ee}from"../chunks/EditOnGithub.1e64e623.js";function Ie(L){let n,v="This API is 🧪 experimental.";return{c(){n=l("p"),n.textContent=v},l(d){n=m(d,"P",{"data-svelte-h":!0}),C(n)!=="svelte-89q1io"&&(n.textContent=v)},m(d,D){i(d,n,D)},p:Xe,d(d){d&&o(n)}}}function ze(L){let n,v="This API is 🧪 experimental.";return{c(){n=l("p"),n.textContent=v},l(d){n=m(d,"P",{"data-svelte-h":!0}),C(n)!=="svelte-89q1io"&&(n.textContent=v)},m(d,D){i(d,n,D)},p:Xe,d(d){d&&o(n)}}}function Re(L){let n,v,d,D,X,B,q,Te='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,k,xe="The model can be loaded with the following code snippet.",ee,Z,te,j,oe,f,P,me,S,Me='A Transformer model for video-like data in <a href="https://github.com/THUDM/CogVideo" rel="nofollow">CogVideoX</a>.',fe,$,U,ce,O,Ce=`Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
are fused. For cross-attention modules, key and value projection matrices are fused.`,pe,y,ue,V,E,ge,G,De="Sets the attention processor to use to compute attention.",_e,T,I,he,N,ye="Disables the fused QKV projection if enabled.",be,w,ne,z,se,x,R,ve,Q,Ve='The output of <a href="/docs/diffusers/pr_9875/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',re,W,ae,Y,ie;return X=new $e({props:{title:"CogVideoXTransformer3DModel",local:"cogvideoxtransformer3dmodel",headingTag:"h1"}}),Z=new Ue({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}}),j=new $e({props:{title:"CogVideoXTransformer3DModel",local:"diffusers.CogVideoXTransformer3DModel",headingTag:"h2"}}),P=new J({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"},{name:"use_rotary_positional_embeddings",val:": bool = False"},{name:"use_learned_positional_embeddings",val:": bool = False"}],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_9875/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L156"}}),U=new J({props:{name:"fuse_qkv_projections",anchor:"diffusers.CogVideoXTransformer3DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L369"}}),y=new we({props:{warning:!0,$$slots:{default:[Ie]},$$scope:{ctx:L}}}),E=new J({props:{name:"set_attn_processor",anchor:"diffusers.CogVideoXTransformer3DModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.CogVideoXTransformer3DModel.set_attn_processor.processor",description:`<strong>processor</strong> (<code>dict</code> of <code>AttentionProcessor</code> or only <code>AttentionProcessor</code>) &#x2014;
The instantiated processor class or a dictionary of processor classes that will be set as the processor
for <strong>all</strong> <code>Attention</code> layers.</p>
<p>If <code>processor</code> is a dict, the key needs to define the path to the corresponding cross attention
processor. This is strongly recommended when setting trainable attention processors.`,name:"processor"}],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L334"}}),I=new J({props:{name:"unfuse_qkv_projections",anchor:"diffusers.CogVideoXTransformer3DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/cogvideox_transformer_3d.py#L395"}}),w=new we({props:{warning:!0,$$slots:{default:[ze]},$$scope:{ctx:L}}}),z=new $e({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),R=new J({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_9875/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_9875/src/diffusers/models/modeling_outputs.py#L20"}}),W=new Ee({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogvideox_transformer3d.md"}}),{c(){n=l("meta"),v=s(),d=l("p"),D=s(),p(X.$$.fragment),B=s(),q=l("p"),q.innerHTML=Te,K=s(),k=l("p"),k.textContent=xe,ee=s(),p(Z.$$.fragment),te=s(),p(j.$$.fragment),oe=s(),f=l("div"),p(P.$$.fragment),me=s(),S=l("p"),S.innerHTML=Me,fe=s(),$=l("div"),p(U.$$.fragment),ce=s(),O=l("p"),O.textContent=Ce,pe=s(),p(y.$$.fragment),ue=s(),V=l("div"),p(E.$$.fragment),ge=s(),G=l("p"),G.textContent=De,_e=s(),T=l("div"),p(I.$$.fragment),he=s(),N=l("p"),N.textContent=ye,be=s(),p(w.$$.fragment),ne=s(),p(z.$$.fragment),se=s(),x=l("div"),p(R.$$.fragment),ve=s(),Q=l("p"),Q.innerHTML=Ve,re=s(),p(W.$$.fragment),ae=s(),Y=l("p"),this.h()},l(e){const t=Pe("svelte-u9bgzb",document.head);n=m(t,"META",{name:!0,content:!0}),t.forEach(o),v=r(e),d=m(e,"P",{}),A(d).forEach(o),D=r(e),u(X.$$.fragment,e),B=r(e),q=m(e,"P",{"data-svelte-h":!0}),C(q)!=="svelte-2g99jo"&&(q.innerHTML=Te),K=r(e),k=m(e,"P",{"data-svelte-h":!0}),C(k)!=="svelte-1vuni30"&&(k.textContent=xe),ee=r(e),u(Z.$$.fragment,e),te=r(e),u(j.$$.fragment,e),oe=r(e),f=m(e,"DIV",{class:!0});var c=A(f);u(P.$$.fragment,c),me=r(c),S=m(c,"P",{"data-svelte-h":!0}),C(S)!=="svelte-98fbmm"&&(S.innerHTML=Me),fe=r(c),$=m(c,"DIV",{class:!0});var M=A($);u(U.$$.fragment,M),ce=r(M),O=m(M,"P",{"data-svelte-h":!0}),C(O)!=="svelte-1254b9i"&&(O.textContent=Ce),pe=r(M),u(y.$$.fragment,M),M.forEach(o),ue=r(c),V=m(c,"DIV",{class:!0});var de=A(V);u(E.$$.fragment,de),ge=r(de),G=m(de,"P",{"data-svelte-h":!0}),C(G)!=="svelte-1o77hl2"&&(G.textContent=De),de.forEach(o),_e=r(c),T=m(c,"DIV",{class:!0});var F=A(T);u(I.$$.fragment,F),he=r(F),N=m(F,"P",{"data-svelte-h":!0}),C(N)!=="svelte-1vhtc74"&&(N.textContent=ye),be=r(F),u(w.$$.fragment,F),F.forEach(o),c.forEach(o),ne=r(e),u(z.$$.fragment,e),se=r(e),x=m(e,"DIV",{class:!0});var le=A(x);u(R.$$.fragment,le),ve=r(le),Q=m(le,"P",{"data-svelte-h":!0}),C(Q)!=="svelte-1wodi43"&&(Q.innerHTML=Ve),le.forEach(o),re=r(e),u(W.$$.fragment,e),ae=r(e),Y=m(e,"P",{}),A(Y).forEach(o),this.h()},h(){H(n,"name","hf:doc:metadata"),H(n,"content",We),H($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),H(x,"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,t){a(document.head,n),i(e,v,t),i(e,d,t),i(e,D,t),g(X,e,t),i(e,B,t),i(e,q,t),i(e,K,t),i(e,k,t),i(e,ee,t),g(Z,e,t),i(e,te,t),g(j,e,t),i(e,oe,t),i(e,f,t),g(P,f,null),a(f,me),a(f,S),a(f,fe),a(f,$),g(U,$,null),a($,ce),a($,O),a($,pe),g(y,$,null),a(f,ue),a(f,V),g(E,V,null),a(V,ge),a(V,G),a(f,_e),a(f,T),g(I,T,null),a(T,he),a(T,N),a(T,be),g(w,T,null),i(e,ne,t),g(z,e,t),i(e,se,t),i(e,x,t),g(R,x,null),a(x,ve),a(x,Q),i(e,re,t),g(W,e,t),i(e,ae,t),i(e,Y,t),ie=!0},p(e,[t]){const c={};t&2&&(c.$$scope={dirty:t,ctx:e}),y.$set(c);const M={};t&2&&(M.$$scope={dirty:t,ctx:e}),w.$set(M)},i(e){ie||(_(X.$$.fragment,e),_(Z.$$.fragment,e),_(j.$$.fragment,e),_(P.$$.fragment,e),_(U.$$.fragment,e),_(y.$$.fragment,e),_(E.$$.fragment,e),_(I.$$.fragment,e),_(w.$$.fragment,e),_(z.$$.fragment,e),_(R.$$.fragment,e),_(W.$$.fragment,e),ie=!0)},o(e){h(X.$$.fragment,e),h(Z.$$.fragment,e),h(j.$$.fragment,e),h(P.$$.fragment,e),h(U.$$.fragment,e),h(y.$$.fragment,e),h(E.$$.fragment,e),h(I.$$.fragment,e),h(w.$$.fragment,e),h(z.$$.fragment,e),h(R.$$.fragment,e),h(W.$$.fragment,e),ie=!1},d(e){e&&(o(v),o(d),o(D),o(B),o(q),o(K),o(k),o(ee),o(te),o(oe),o(f),o(ne),o(se),o(x),o(re),o(ae),o(Y)),o(n),b(X,e),b(Z,e),b(j,e),b(P),b(U),b(y),b(E),b(I),b(w),b(z,e),b(R),b(W,e)}}}const We='{"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 Ae(L){return ke(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Qe extends Ze{constructor(n){super(),je(this,n,Ae,Re,qe,{})}}export{Qe as component};

Xet Storage Details

Size:
17.4 kB
·
Xet hash:
1dd1ec901ec386f74e7b2c20e342877a4fb2182d39c0eb2e860b6b553ddb5912

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