Buckets:

download
raw
14.2 kB
import{s as fe,n as ue,o as pe}from"../chunks/scheduler.53228c21.js";import{S as ge,i as he,e as a,s,c,h as _e,a as d,d as t,b as r,f as k,g as f,j as J,k as R,l as u,m as n,n as p,t as g,o as h,p as _}from"../chunks/index.cac5d66a.js";import{C as Te}from"../chunks/CopyLLMTxtMenu.0ef49226.js";import{D as se}from"../chunks/Docstring.9de32ff4.js";import{C as we}from"../chunks/CodeBlock.606cbaf4.js";import{H as re,E as be}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.48d5cb47.js";function ve(ie){let l,E,Z,G,w,S,b,O,v,ae='A Diffusion Transformer model for 2D data from <a href="https://github.com/THUDM/CogView3" rel="nofollow">CogView3Plus</a> was introduced in <a href="https://huggingface.co/papers/2403.05121" rel="nofollow">CogView3: Finer and Faster Text-to-Image Generation via Relay Diffusion</a> by Tsinghua University &amp; ZhipuAI.',W,$,de="The model can be loaded with the following code snippet.",q,M,X,x,Y,i,D,ee,z,le=`The Transformer model introduced in <a href="https://huggingface.co/papers/2403.05121" rel="nofollow">CogView3: Finer and Faster Text-to-Image Generation via Relay
Diffusion</a>.`,oe,T,y,te,L,me='The <a href="/docs/diffusers/pr_13921/en/api/models/cogview3plus_transformer2d#diffusers.CogView3PlusTransformer2DModel">CogView3PlusTransformer2DModel</a> forward method.',j,C,N,m,V,ne,U,ce='The output of <a href="/docs/diffusers/pr_13921/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',Q,P,F,I,A;return w=new Te({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),b=new re({props:{title:"CogView3PlusTransformer2DModel",local:"cogview3plustransformer2dmodel",headingTag:"h1"}}),M=new we({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZXczUGx1c1RyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwQ29nVmlldzNQbHVzVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJUSFVETSUyRkNvZ1ZpZXczUGx1cy0zYiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNikudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> CogView3PlusTransformer2DModel
transformer = CogView3PlusTransformer2DModel.from_pretrained(<span class="hljs-string">&quot;THUDM/CogView3Plus-3b&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,lang:"python",wrap:!1}}),x=new re({props:{title:"CogView3PlusTransformer2DModel",local:"diffusers.CogView3PlusTransformer2DModel",headingTag:"h2"}}),D=new se({props:{name:"class diffusers.CogView3PlusTransformer2DModel",anchor:"diffusers.CogView3PlusTransformer2DModel",parameters:[{name:"patch_size",val:": int = 2"},{name:"in_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:"out_channels",val:": int = 16"},{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"}],parametersDescription:[{anchor:"diffusers.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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.CogView3PlusTransformer2DModel.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/vr_13921/src/diffusers/models/transformers/transformer_cogview3plus.py#L126"}}),y=new se({props:{name:"forward",anchor:"diffusers.CogView3PlusTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor"},{name:"timestep",val:": LongTensor"},{name:"original_size",val:": Tensor"},{name:"target_size",val:": Tensor"},{name:"crop_coords",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Input <code>hidden_states</code> of shape <code>(batch size, channel, height, width)</code>.`,name:"hidden_states"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) of shape
<code>(batch_size, sequence_len, text_embed_dim)</code>`,name:"encoder_hidden_states"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.original_size",description:`<strong>original_size</strong> (<code>torch.Tensor</code>) &#x2014;
CogView3 uses SDXL-like micro-conditioning for original image size as explained in section 2.2 of
<a href="https://huggingface.co/papers/2307.01952" rel="nofollow">https://huggingface.co/papers/2307.01952</a>.`,name:"original_size"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.target_size",description:`<strong>target_size</strong> (<code>torch.Tensor</code>) &#x2014;
CogView3 uses SDXL-like micro-conditioning for target image size as explained in section 2.2 of
<a href="https://huggingface.co/papers/2307.01952" rel="nofollow">https://huggingface.co/papers/2307.01952</a>.`,name:"target_size"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.crop_coords",description:`<strong>crop_coords</strong> (<code>torch.Tensor</code>) &#x2014;
CogView3 uses SDXL-like micro-conditioning for crop coordinates as explained in section 2.2 of
<a href="https://huggingface.co/papers/2307.01952" rel="nofollow">https://huggingface.co/papers/2307.01952</a>.`,name:"crop_coords"},{anchor:"diffusers.CogView3PlusTransformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~models.transformer_2d.Transformer2DModelOutput</code> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/transformer_cogview3plus.py#L225",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>
<p>The denoised latents using provided inputs as conditioning.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>
<p><code>torch.Tensor</code> or <code>~models.transformer_2d.Transformer2DModelOutput</code></p>
`}}),C=new re({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),V=new se({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_13921/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_13921/src/diffusers/models/modeling_outputs.py#L21"}}),P=new be({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogview3plus_transformer2d.md"}}),{c(){l=a("meta"),E=s(),Z=a("p"),G=s(),c(w.$$.fragment),S=s(),c(b.$$.fragment),O=s(),v=a("p"),v.innerHTML=ae,W=s(),$=a("p"),$.textContent=de,q=s(),c(M.$$.fragment),X=s(),c(x.$$.fragment),Y=s(),i=a("div"),c(D.$$.fragment),ee=s(),z=a("p"),z.innerHTML=le,oe=s(),T=a("div"),c(y.$$.fragment),te=s(),L=a("p"),L.innerHTML=me,j=s(),c(C.$$.fragment),N=s(),m=a("div"),c(V.$$.fragment),ne=s(),U=a("p"),U.innerHTML=ce,Q=s(),c(P.$$.fragment),F=s(),I=a("p"),this.h()},l(e){const o=_e("svelte-u9bgzb",document.head);l=d(o,"META",{name:!0,content:!0}),o.forEach(t),E=r(e),Z=d(e,"P",{}),k(Z).forEach(t),G=r(e),f(w.$$.fragment,e),S=r(e),f(b.$$.fragment,e),O=r(e),v=d(e,"P",{"data-svelte-h":!0}),J(v)!=="svelte-1vlmqph"&&(v.innerHTML=ae),W=r(e),$=d(e,"P",{"data-svelte-h":!0}),J($)!=="svelte-1vuni30"&&($.textContent=de),q=r(e),f(M.$$.fragment,e),X=r(e),f(x.$$.fragment,e),Y=r(e),i=d(e,"DIV",{class:!0});var H=k(i);f(D.$$.fragment,H),ee=r(H),z=d(H,"P",{"data-svelte-h":!0}),J(z)!=="svelte-1y8vmfa"&&(z.innerHTML=le),oe=r(H),T=d(H,"DIV",{class:!0});var B=k(T);f(y.$$.fragment,B),te=r(B),L=d(B,"P",{"data-svelte-h":!0}),J(L)!=="svelte-hg501y"&&(L.innerHTML=me),B.forEach(t),H.forEach(t),j=r(e),f(C.$$.fragment,e),N=r(e),m=d(e,"DIV",{class:!0});var K=k(m);f(V.$$.fragment,K),ne=r(K),U=d(K,"P",{"data-svelte-h":!0}),J(U)!=="svelte-2clpd6"&&(U.innerHTML=ce),K.forEach(t),Q=r(e),f(P.$$.fragment,e),F=r(e),I=d(e,"P",{}),k(I).forEach(t),this.h()},h(){R(l,"name","hf:doc:metadata"),R(l,"content",$e),R(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),R(m,"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){u(document.head,l),n(e,E,o),n(e,Z,o),n(e,G,o),p(w,e,o),n(e,S,o),p(b,e,o),n(e,O,o),n(e,v,o),n(e,W,o),n(e,$,o),n(e,q,o),p(M,e,o),n(e,X,o),p(x,e,o),n(e,Y,o),n(e,i,o),p(D,i,null),u(i,ee),u(i,z),u(i,oe),u(i,T),p(y,T,null),u(T,te),u(T,L),n(e,j,o),p(C,e,o),n(e,N,o),n(e,m,o),p(V,m,null),u(m,ne),u(m,U),n(e,Q,o),p(P,e,o),n(e,F,o),n(e,I,o),A=!0},p:ue,i(e){A||(g(w.$$.fragment,e),g(b.$$.fragment,e),g(M.$$.fragment,e),g(x.$$.fragment,e),g(D.$$.fragment,e),g(y.$$.fragment,e),g(C.$$.fragment,e),g(V.$$.fragment,e),g(P.$$.fragment,e),A=!0)},o(e){h(w.$$.fragment,e),h(b.$$.fragment,e),h(M.$$.fragment,e),h(x.$$.fragment,e),h(D.$$.fragment,e),h(y.$$.fragment,e),h(C.$$.fragment,e),h(V.$$.fragment,e),h(P.$$.fragment,e),A=!1},d(e){e&&(t(E),t(Z),t(G),t(S),t(O),t(v),t(W),t($),t(q),t(X),t(Y),t(i),t(j),t(N),t(m),t(Q),t(F),t(I)),t(l),_(w,e),_(b,e),_(M,e),_(x,e),_(D),_(y),_(C,e),_(V),_(P,e)}}}const $e='{"title":"CogView3PlusTransformer2DModel","local":"cogview3plustransformer2dmodel","sections":[{"title":"CogView3PlusTransformer2DModel","local":"diffusers.CogView3PlusTransformer2DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function Me(ie){return pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ze extends ge{constructor(l){super(),he(this,l,Me,ve,fe,{})}}export{ze as component};

Xet Storage Details

Size:
14.2 kB
·
Xet hash:
db0ceaa3bcb70bf887c0950150c2de18a85d7a3ec3cbdc0930728579b3c1ab41

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