import{s as oe,n as ne,o as se}from"../chunks/scheduler.53228c21.js";import{S as re,i as ie,e as d,s,c as m,h as ae,a as l,d as o,b as r,f as q,g as f,j as Y,k as B,l as S,m as n,n as c,t as u,o as p,p as h}from"../chunks/index.100fac89.js";import{C as de}from"../chunks/CopyLLMTxtMenu.9360b11d.js";import{D as te}from"../chunks/Docstring.22cc8849.js";import{C as me}from"../chunks/CodeBlock.d30a6509.js";import{H as X,E as le}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c9001d7a.js";function fe(Q){let i,Z,V,J,g,H,_,R,b,A='A Diffusion Transformer model for 2D data from <a href="">CogView4</a>',k,T,F="The model can be loaded with the following code snippet.",E,$,U,M,W,w,y,I,v,j,a,x,N,C,K='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',L,D,G,z,O;return g=new de({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),_=new X({props:{title:"CogView4Transformer2DModel",local:"cogview4transformer2dmodel",headingTag:"h1"}}),$=new me({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}}),M=new X({props:{title:"CogView4Transformer2DModel",local:"diffusers.CogView4Transformer2DModel",headingTag:"h2"}}),y=new te({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#L619"}}),v=new X({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),x=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/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#L21"}}),D=new le({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogview4_transformer2d.md"}}),{c(){i=d("meta"),Z=s(),V=d("p"),J=s(),m(g.$$.fragment),H=s(),m(_.$$.fragment),R=s(),b=d("p"),b.innerHTML=A,k=s(),T=d("p"),T.textContent=F,E=s(),m($.$$.fragment),U=s(),m(M.$$.fragment),W=s(),w=d("div"),m(y.$$.fragment),I=s(),m(v.$$.fragment),j=s(),a=d("div"),m(x.$$.fragment),N=s(),C=d("p"),C.innerHTML=K,L=s(),m(D.$$.fragment),G=s(),z=d("p"),this.h()},l(e){const t=ae("svelte-u9bgzb",document.head);i=l(t,"META",{name:!0,content:!0}),t.forEach(o),Z=r(e),V=l(e,"P",{}),q(V).forEach(o),J=r(e),f(g.$$.fragment,e),H=r(e),f(_.$$.fragment,e),R=r(e),b=l(e,"P",{"data-svelte-h":!0}),Y(b)!=="svelte-1qocnal"&&(b.innerHTML=A),k=r(e),T=l(e,"P",{"data-svelte-h":!0}),Y(T)!=="svelte-1vuni30"&&(T.textContent=F),E=r(e),f($.$$.fragment,e),U=r(e),f(M.$$.fragment,e),W=r(e),w=l(e,"DIV",{class:!0});var ee=q(w);f(y.$$.fragment,ee),ee.forEach(o),I=r(e),f(v.$$.fragment,e),j=r(e),a=l(e,"DIV",{class:!0});var P=q(a);f(x.$$.fragment,P),N=r(P),C=l(P,"P",{"data-svelte-h":!0}),Y(C)!=="svelte-1x8c0js"&&(C.innerHTML=K),P.forEach(o),L=r(e),f(D.$$.fragment,e),G=r(e),z=l(e,"P",{}),q(z).forEach(o),this.h()},h(){B(i,"name","hf:doc:metadata"),B(i,"content",ce),B(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),B(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){S(document.head,i),n(e,Z,t),n(e,V,t),n(e,J,t),c(g,e,t),n(e,H,t),c(_,e,t),n(e,R,t),n(e,b,t),n(e,k,t),n(e,T,t),n(e,E,t),c($,e,t),n(e,U,t),c(M,e,t),n(e,W,t),n(e,w,t),c(y,w,null),n(e,I,t),c(v,e,t),n(e,j,t),n(e,a,t),c(x,a,null),S(a,N),S(a,C),n(e,L,t),c(D,e,t),n(e,G,t),n(e,z,t),O=!0},p:ne,i(e){O||(u(g.$$.fragment,e),u(_.$$.fragment,e),u($.$$.fragment,e),u(M.$$.fragment,e),u(y.$$.fragment,e),u(v.$$.fragment,e),u(x.$$.fragment,e),u(D.$$.fragment,e),O=!0)},o(e){p(g.$$.fragment,e),p(_.$$.fragment,e),p($.$$.fragment,e),p(M.$$.fragment,e),p(y.$$.fragment,e),p(v.$$.fragment,e),p(x.$$.fragment,e),p(D.$$.fragment,e),O=!1},d(e){e&&(o(Z),o(V),o(J),o(H),o(R),o(b),o(k),o(T),o(E),o(U),o(W),o(w),o(I),o(j),o(a),o(L),o(G),o(z)),o(i),h(g,e),h(_,e),h($,e),h(M,e),h(y),h(v,e),h(x),h(D,e)}}}const ce='{"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 ue(Q){return se(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class $e extends re{constructor(i){super(),ie(this,i,ue,fe,oe,{})}}export{$e as component};
