import{s as ee,n as te,o as oe}from"../chunks/scheduler.8c3d61f6.js";import{S as ne,i as se,g as d,s,r as $,A as re,h as m,f as o,c as r,j as P,u as M,x as L,k as q,y as N,a as n,v as w,d as v,t as y,w as D}from"../chunks/index.da70eac4.js";import{D as K}from"../chunks/Docstring.dcbc19b1.js";import{C as ie}from"../chunks/CodeBlock.a9c4becf.js";import{H as Y,E as ae}from"../chunks/getInferenceSnippets.86beaec3.js";function de(X){let i,z,C,Z,l,J,f,S='A Diffusion Transformer model for 2D data from <a href="">CogView4</a>',H,c,A="The model can be loaded with the following code snippet.",R,u,k,p,E,h,g,U,_,W,a,b,B,x,Q='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',I,T,j,V,G;return l=new Y({props:{title:"CogView4Transformer2DModel",local:"cogview4transformer2dmodel",headingTag:"h1"}}),u=new ie({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZXc0VHJhbnNmb3JtZXIyRE1vZGVsJTBBJTBBdHJhbnNmb3JtZXIlMjAlM0QlMjBDb2dWaWV3NFRyYW5zZm9ybWVyMkRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyVEhVRE0lMkZDb2dWaWV3NC02QiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNikudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogView4Transformer2DModel

transformer = CogView4Transformer2DModel.from_pretrained(<span class="hljs-string">&quot;THUDM/CogView4-6B&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}}),p=new Y({props:{title:"CogView4Transformer2DModel",local:"diffusers.CogView4Transformer2DModel",headingTag:"h2"}}),g=new K({props:{name:"class diffusers.CogView4Transformer2DModel",anchor:"diffusers.CogView4Transformer2DModel",parameters:[{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 16"},{name:"out_channels",val:": int = 16"},{name:"num_layers",val:": int = 30"},{name:"attention_head_dim",val:": int = 40"},{name:"num_attention_heads",val:": int = 64"},{name:"text_embed_dim",val:": int = 4096"},{name:"time_embed_dim",val:": int = 512"},{name:"condition_dim",val:": int = 256"},{name:"pos_embed_max_size",val:": int = 128"},{name:"sample_size",val:": int = 128"},{name:"rope_axes_dim",val:": typing.Tuple[int, int] = (256, 256)"}],parametersDescription:[{anchor:"diffusers.CogView4Transformer2DModel.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.CogView4Transformer2DModel.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.CogView4Transformer2DModel.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.CogView4Transformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>40</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.CogView4Transformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.CogView4Transformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, defaults to <code>16</code>) &#x2014;
The number of channels in the output.`,name:"out_channels"},{anchor:"diffusers.CogView4Transformer2DModel.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.CogView4Transformer2DModel.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.CogView4Transformer2DModel.condition_dim",description:`<strong>condition_dim</strong> (<code>int</code>, defaults to <code>256</code>) &#x2014;
The embedding dimension of the input SDXL-style resolution conditions (original_size, target_size,
crop_coords).`,name:"condition_dim"},{anchor:"diffusers.CogView4Transformer2DModel.pos_embed_max_size",description:`<strong>pos_embed_max_size</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The maximum resolution of the positional embeddings, from which slices of shape <code>H x W</code> are taken and added
to input patched latents, where <code>H</code> and <code>W</code> are the latent height and width respectively. A value of 128
means that the maximum supported height and width for image generation is <code>128 * vae_scale_factor * patch_size =&gt; 128 * 8 * 2 =&gt; 2048</code>.`,name:"pos_embed_max_size"},{anchor:"diffusers.CogView4Transformer2DModel.sample_size",description:`<strong>sample_size</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The base resolution of input latents. If height/width is not provided during generation, this value is used
to determine the resolution as <code>sample_size * vae_scale_factor =&gt; 128 * 8 =&gt; 1024</code>`,name:"sample_size"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_cogview4.py#L585"}}),_=new Y({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),b=new K({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/main/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/main/src/diffusers/models/modeling_outputs.py#L20"}}),T=new ae({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogview4_transformer2d.md"}}),{c(){i=d("meta"),z=s(),C=d("p"),Z=s(),$(l.$$.fragment),J=s(),f=d("p"),f.innerHTML=S,H=s(),c=d("p"),c.textContent=A,R=s(),$(u.$$.fragment),k=s(),$(p.$$.fragment),E=s(),h=d("div"),$(g.$$.fragment),U=s(),$(_.$$.fragment),W=s(),a=d("div"),$(b.$$.fragment),B=s(),x=d("p"),x.innerHTML=Q,I=s(),$(T.$$.fragment),j=s(),V=d("p"),this.h()},l(e){const t=re("svelte-u9bgzb",document.head);i=m(t,"META",{name:!0,content:!0}),t.forEach(o),z=r(e),C=m(e,"P",{}),P(C).forEach(o),Z=r(e),M(l.$$.fragment,e),J=r(e),f=m(e,"P",{"data-svelte-h":!0}),L(f)!=="svelte-1qocnal"&&(f.innerHTML=S),H=r(e),c=m(e,"P",{"data-svelte-h":!0}),L(c)!=="svelte-1vuni30"&&(c.textContent=A),R=r(e),M(u.$$.fragment,e),k=r(e),M(p.$$.fragment,e),E=r(e),h=m(e,"DIV",{class:!0});var F=P(h);M(g.$$.fragment,F),F.forEach(o),U=r(e),M(_.$$.fragment,e),W=r(e),a=m(e,"DIV",{class:!0});var O=P(a);M(b.$$.fragment,O),B=r(O),x=m(O,"P",{"data-svelte-h":!0}),L(x)!=="svelte-1x8c0js"&&(x.innerHTML=Q),O.forEach(o),I=r(e),M(T.$$.fragment,e),j=r(e),V=m(e,"P",{}),P(V).forEach(o),this.h()},h(){q(i,"name","hf:doc:metadata"),q(i,"content",me),q(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),q(a,"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){N(document.head,i),n(e,z,t),n(e,C,t),n(e,Z,t),w(l,e,t),n(e,J,t),n(e,f,t),n(e,H,t),n(e,c,t),n(e,R,t),w(u,e,t),n(e,k,t),w(p,e,t),n(e,E,t),n(e,h,t),w(g,h,null),n(e,U,t),w(_,e,t),n(e,W,t),n(e,a,t),w(b,a,null),N(a,B),N(a,x),n(e,I,t),w(T,e,t),n(e,j,t),n(e,V,t),G=!0},p:te,i(e){G||(v(l.$$.fragment,e),v(u.$$.fragment,e),v(p.$$.fragment,e),v(g.$$.fragment,e),v(_.$$.fragment,e),v(b.$$.fragment,e),v(T.$$.fragment,e),G=!0)},o(e){y(l.$$.fragment,e),y(u.$$.fragment,e),y(p.$$.fragment,e),y(g.$$.fragment,e),y(_.$$.fragment,e),y(b.$$.fragment,e),y(T.$$.fragment,e),G=!1},d(e){e&&(o(z),o(C),o(Z),o(J),o(f),o(H),o(c),o(R),o(k),o(E),o(h),o(U),o(W),o(a),o(I),o(j),o(V)),o(i),D(l,e),D(u,e),D(p,e),D(g),D(_,e),D(b),D(T,e)}}}const me='{"title":"CogView4Transformer2DModel","local":"cogview4transformer2dmodel","sections":[{"title":"CogView4Transformer2DModel","local":"diffusers.CogView4Transformer2DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function le(X){return oe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ge extends ne{constructor(i){super(),se(this,i,le,de,ee,{})}}export{ge as component};
