Buckets:

download
raw
11.6 kB
import"../chunks/DsnmJJEf.js";import{i as y,h as V,C,H as r,a as z,D as n,E as P,s as U}from"../chunks/BtE7mKSK.js";import{p as Z,o as J,s as e,f as R,a as T,b as k,c as t,d as b,n as i,r as a}from"../chunks/jDjavuwI.js";const I='{"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}';var L=b('<meta name="hf:doc:metadata"/>'),G=b(`<p></p> <!> <!> <p>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 & ZhipuAI.</p> <p>The model can be loaded with the following code snippet.</p> <!> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>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>.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The <a href="/docs/diffusers/pr_14409/en/api/models/cogview3plus_transformer2d#diffusers.CogView3PlusTransformer2DModel">CogView3PlusTransformer2DModel</a> forward method.</p></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>The output of <a href="/docs/diffusers/pr_14409/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.</p></div> <!> <p></p>`,1);function W(w,v){Z(v,!1),J(()=>{new URLSearchParams(window.location.search).get("fw")}),y();var d=G();V("1j3sr0i",g=>{var _=L();U(_,"content",I),T(g,_)});var c=e(R(d),2);C(c,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var l=e(c,2);r(l,{title:"CogView3PlusTransformer2DModel",local:"cogview3plustransformer2dmodel",headingTag:"h1"});var m=e(l,6);z(m,{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMENvZ1ZpZXczUGx1c1RyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwQ29nVmlldzNQbHVzVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJUSFVETSUyRkNvZ1ZpZXczUGx1cy0zYiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwZHR5cGUlM0R0b3JjaC5iZmxvYXQxNikudG8oJTIyY3VkYSUyMik=",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>, dtype=torch.bfloat16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,lang:"python",wrap:!1});var f=e(m,2);r(f,{title:"CogView3PlusTransformer2DModel",local:"diffusers.CogView3PlusTransformer2DModel",headingTag:"h2"});var o=e(f,2),u=t(o);n(u,{name:"class diffusers.CogView3PlusTransformer2DModel",anchor:"diffusers.CogView3PlusTransformer2DModel",source:"https://github.com/huggingface/diffusers/blob/vr_14409/src/diffusers/models/transformers/transformer_cogview3plus.py#L126",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"}]});var p=e(u,4),D=t(p);n(D,{name:"forward",anchor:"diffusers.CogView3PlusTransformer2DModel.forward",source:"https://github.com/huggingface/diffusers/blob/vr_14409/src/diffusers/models/transformers/transformer_cogview3plus.py#L225",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"}],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>
`}),i(2),a(p),a(o);var h=e(o,2);r(h,{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"});var s=e(h,2),M=t(s);n(M,{name:"class diffusers.models.modeling_outputs.Transformer2DModelOutput",anchor:"diffusers.models.modeling_outputs.Transformer2DModelOutput",source:"https://github.com/huggingface/diffusers/blob/vr_14409/src/diffusers/models/modeling_outputs.py#L21",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_14409/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"}]}),i(2),a(s);var x=e(s,2);P(x,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/cogview3plus_transformer2d.md"}),i(2),T(w,d),k()}export{W as component};

Xet Storage Details

Size:
11.6 kB
·
Xet hash:
b647f28adff4075b3358a02232667a350ee2dc274713999e7ed0d99dd26812fa

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