Buckets:
| import{s as ye,n as ke,o as Ce}from"../chunks/scheduler.53228c21.js";import{S as Ne,i as Le,e as i,s as o,c as _,h as ze,a as d,d as n,b as r,f as q,g as h,j as g,k as x,l as t,m,n as b,t as v,o as T,p as $}from"../chunks/index.cac5d66a.js";import{C as Ie}from"../chunks/CopyLLMTxtMenu.0ef49226.js";import{D as G}from"../chunks/Docstring.9de32ff4.js";import{H as Me,E as je}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.48d5cb47.js";function qe(ge){let u,R,B,J,A,X,P,Y,w,xe='A Transformer model for image-like data from <a href="https://huggingface.co/papers/2310.00426" rel="nofollow">PixArt-Alpha</a> and <a href="https://huggingface.co/papers/2403.04692" rel="nofollow">PixArt-Sigma</a>.',Z,M,ee,a,y,se,E,be=`A 2D Transformer model as introduced in PixArt family of models (<a href="https://huggingface.co/papers/2310.00426" rel="nofollow">https://huggingface.co/papers/2310.00426</a>, | |
| <a href="https://huggingface.co/papers/2403.04692" rel="nofollow">https://huggingface.co/papers/2403.04692</a>).`,ae,D,k,ie,H,ve='The <a href="/docs/diffusers/pr_13921/en/api/models/pixart_transformer2d#diffusers.PixArtTransformer2DModel">PixArtTransformer2DModel</a> forward method.',de,f,C,le,F,Te=`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.`,me,N,$e="<p>> This API is 🧪 experimental.</p>",fe,c,L,ce,S,De="Disables custom attention processors and sets the default attention implementation.",pe,O,Ae="Safe to just use <code>AttnProcessor()</code> as PixArt doesn’t have any exotic attention processors in default model.",ue,p,z,_e,V,Pe="Disables the fused QKV projection if enabled.",he,I,we="<p>> This API is 🧪 experimental.</p>",te,j,ne,W,oe;return A=new Ie({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),P=new Me({props:{title:"PixArtTransformer2DModel",local:"pixarttransformer2dmodel",headingTag:"h1"}}),M=new Me({props:{title:"PixArtTransformer2DModel",local:"diffusers.PixArtTransformer2DModel",headingTag:"h2"}}),y=new G({props:{name:"class diffusers.PixArtTransformer2DModel",anchor:"diffusers.PixArtTransformer2DModel",parameters:[{name:"num_attention_heads",val:": int = 16"},{name:"attention_head_dim",val:": int = 72"},{name:"in_channels",val:": int = 4"},{name:"out_channels",val:": int | None = 8"},{name:"num_layers",val:": int = 28"},{name:"dropout",val:": float = 0.0"},{name:"norm_num_groups",val:": int = 32"},{name:"cross_attention_dim",val:": int | None = 1152"},{name:"attention_bias",val:": bool = True"},{name:"sample_size",val:": int = 128"},{name:"patch_size",val:": int = 2"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"num_embeds_ada_norm",val:": int | None = 1000"},{name:"upcast_attention",val:": bool = False"},{name:"norm_type",val:": str = 'ada_norm_single'"},{name:"norm_elementwise_affine",val:": bool = False"},{name:"norm_eps",val:": float = 1e-06"},{name:"interpolation_scale",val:": int | None = None"},{name:"use_additional_conditions",val:": bool | None = None"},{name:"caption_channels",val:": int | None = None"},{name:"attention_type",val:": str | None = 'default'"}],parametersDescription:[{anchor:"diffusers.PixArtTransformer2DModel.num_attention_heads",description:"<strong>num_attention_heads</strong> (int, optional, defaults to 16) — The number of heads to use for multi-head attention.",name:"num_attention_heads"},{anchor:"diffusers.PixArtTransformer2DModel.attention_head_dim",description:"<strong>attention_head_dim</strong> (int, optional, defaults to 72) — The number of channels in each head.",name:"attention_head_dim"},{anchor:"diffusers.PixArtTransformer2DModel.in_channels",description:"<strong>in_channels</strong> (int, defaults to 4) — The number of channels in the input.",name:"in_channels"},{anchor:"diffusers.PixArtTransformer2DModel.out_channels",description:`<strong>out_channels</strong> (int, optional) — | |
| The number of channels in the output. Specify this parameter if the output channel number differs from the | |
| input.`,name:"out_channels"},{anchor:"diffusers.PixArtTransformer2DModel.num_layers",description:"<strong>num_layers</strong> (int, optional, defaults to 28) — The number of layers of Transformer blocks to use.",name:"num_layers"},{anchor:"diffusers.PixArtTransformer2DModel.dropout",description:"<strong>dropout</strong> (float, optional, defaults to 0.0) — The dropout probability to use within the Transformer blocks.",name:"dropout"},{anchor:"diffusers.PixArtTransformer2DModel.norm_num_groups",description:`<strong>norm_num_groups</strong> (int, optional, defaults to 32) — | |
| Number of groups for group normalization within Transformer blocks.`,name:"norm_num_groups"},{anchor:"diffusers.PixArtTransformer2DModel.cross_attention_dim",description:`<strong>cross_attention_dim</strong> (int, optional) — | |
| The dimensionality for cross-attention layers, typically matching the encoder’s hidden dimension.`,name:"cross_attention_dim"},{anchor:"diffusers.PixArtTransformer2DModel.attention_bias",description:`<strong>attention_bias</strong> (bool, optional, defaults to True) — | |
| Configure if the Transformer blocks’ attention should contain a bias parameter.`,name:"attention_bias"},{anchor:"diffusers.PixArtTransformer2DModel.sample_size",description:`<strong>sample_size</strong> (int, defaults to 128) — | |
| The width of the latent images. This parameter is fixed during training.`,name:"sample_size"},{anchor:"diffusers.PixArtTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (int, defaults to 2) — | |
| Size of the patches the model processes, relevant for architectures working on non-sequential data.`,name:"patch_size"},{anchor:"diffusers.PixArtTransformer2DModel.activation_fn",description:`<strong>activation_fn</strong> (str, optional, defaults to “gelu-approximate”) — | |
| Activation function to use in feed-forward networks within Transformer blocks.`,name:"activation_fn"},{anchor:"diffusers.PixArtTransformer2DModel.num_embeds_ada_norm",description:`<strong>num_embeds_ada_norm</strong> (int, optional, defaults to 1000) — | |
| Number of embeddings for AdaLayerNorm, fixed during training and affects the maximum denoising steps during | |
| inference.`,name:"num_embeds_ada_norm"},{anchor:"diffusers.PixArtTransformer2DModel.upcast_attention",description:`<strong>upcast_attention</strong> (bool, optional, defaults to False) — | |
| If true, upcasts the attention mechanism dimensions for potentially improved performance.`,name:"upcast_attention"},{anchor:"diffusers.PixArtTransformer2DModel.norm_type",description:`<strong>norm_type</strong> (str, optional, defaults to “ada_norm_zero”) — | |
| Specifies the type of normalization used, can be ‘ada_norm_zero’.`,name:"norm_type"},{anchor:"diffusers.PixArtTransformer2DModel.norm_elementwise_affine",description:`<strong>norm_elementwise_affine</strong> (bool, optional, defaults to False) — | |
| If true, enables element-wise affine parameters in the normalization layers.`,name:"norm_elementwise_affine"},{anchor:"diffusers.PixArtTransformer2DModel.norm_eps",description:`<strong>norm_eps</strong> (float, optional, defaults to 1e-6) — | |
| A small constant added to the denominator in normalization layers to prevent division by zero.`,name:"norm_eps"},{anchor:"diffusers.PixArtTransformer2DModel.interpolation_scale",description:"<strong>interpolation_scale</strong> (int, optional) — Scale factor to use during interpolating the position embeddings.",name:"interpolation_scale"},{anchor:"diffusers.PixArtTransformer2DModel.use_additional_conditions",description:"<strong>use_additional_conditions</strong> (bool, optional) — If we’re using additional conditions as inputs.",name:"use_additional_conditions"},{anchor:"diffusers.PixArtTransformer2DModel.attention_type",description:"<strong>attention_type</strong> (str, optional, defaults to “default”) — Kind of attention mechanism to be used.",name:"attention_type"},{anchor:"diffusers.PixArtTransformer2DModel.caption_channels",description:`<strong>caption_channels</strong> (int, optional, defaults to None) — | |
| Number of channels to use for projecting the caption embeddings.`,name:"caption_channels"},{anchor:"diffusers.PixArtTransformer2DModel.use_linear_projection",description:`<strong>use_linear_projection</strong> (bool, optional, defaults to False) — | |
| Deprecated argument. Will be removed in a future version.`,name:"use_linear_projection"},{anchor:"diffusers.PixArtTransformer2DModel.num_vector_embeds",description:`<strong>num_vector_embeds</strong> (bool, optional, defaults to False) — | |
| Deprecated argument. Will be removed in a future version.`,name:"num_vector_embeds"}],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/pixart_transformer_2d.py#L32"}}),k=new G({props:{name:"forward",anchor:"diffusers.PixArtTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": torch.Tensor | None = None"},{name:"timestep",val:": torch.LongTensor | None = None"},{name:"added_cond_kwargs",val:": dict = None"},{name:"cross_attention_kwargs",val:": dict = None"},{name:"attention_mask",val:": torch.Tensor | None = None"},{name:"encoder_attention_mask",val:": torch.Tensor | None = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.PixArtTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, channel, height, width)</code>) — | |
| Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.PixArtTransformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) — | |
| Conditional embeddings for cross attention layer. If not given, cross-attention defaults to | |
| self-attention.`,name:"encoder_hidden_states"},{anchor:"diffusers.PixArtTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> (<code>torch.LongTensor</code>, <em>optional</em>) — | |
| Used to indicate denoising step. Optional timestep to be applied as an embedding in <code>AdaLayerNorm</code>.`,name:"timestep"},{anchor:"diffusers.PixArtTransformer2DModel.forward.added_cond_kwargs",description:"<strong>added_cond_kwargs</strong> — (<code>dict[str, Any]</code>, <em>optional</em>): Additional conditions to be used as inputs.",name:"added_cond_kwargs"},{anchor:"diffusers.PixArtTransformer2DModel.forward.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> ( <code>dict[str, Any]</code>, <em>optional</em>) — | |
| A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under | |
| <code>self.processor</code> in | |
| <a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.PixArtTransformer2DModel.forward.attention_mask",description:`<strong>attention_mask</strong> ( <code>torch.Tensor</code>, <em>optional</em>) — | |
| An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. If <code>1</code> the mask | |
| is kept, otherwise if <code>0</code> it is discarded. Mask will be converted into a bias, which adds large | |
| negative values to the attention scores corresponding to “discard” tokens.`,name:"attention_mask"},{anchor:"diffusers.PixArtTransformer2DModel.forward.encoder_attention_mask",description:`<strong>encoder_attention_mask</strong> ( <code>torch.Tensor</code>, <em>optional</em>) — | |
| Cross-attention mask applied to <code>encoder_hidden_states</code>. Two formats supported:</p> | |
| <ul> | |
| <li>Mask <code>(batch, sequence_length)</code> True = keep, False = discard.</li> | |
| <li>Bias <code>(batch, 1, sequence_length)</code> 0 = keep, -10000 = discard.</li> | |
| </ul> | |
| <p>If <code>ndim == 2</code>: will be interpreted as a mask, then converted into a bias consistent with the format | |
| above. This bias will be added to the cross-attention scores.`,name:"encoder_attention_mask"},{anchor:"diffusers.PixArtTransformer2DModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_13921/en/api/models/unet2d-cond#diffusers.models.unets.unet_2d_condition.UNet2DConditionOutput">UNet2DConditionOutput</a> instead of a plain | |
| tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/pixart_transformer_2d.py#L227",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is True, an <code>~models.transformer_2d.Transformer2DModelOutput</code> is returned, otherwise a | |
| <code>tuple</code> where the first element is the sample tensor.</p> | |
| `}}),C=new G({props:{name:"fuse_qkv_projections",anchor:"diffusers.PixArtTransformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/pixart_transformer_2d.py#L196"}}),L=new G({props:{name:"set_default_attn_processor",anchor:"diffusers.PixArtTransformer2DModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/pixart_transformer_2d.py#L187"}}),z=new G({props:{name:"unfuse_qkv_projections",anchor:"diffusers.PixArtTransformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_13921/src/diffusers/models/transformers/pixart_transformer_2d.py#L218"}}),j=new je({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/pixart_transformer2d.md"}}),{c(){u=i("meta"),R=o(),B=i("p"),J=o(),_(A.$$.fragment),X=o(),_(P.$$.fragment),Y=o(),w=i("p"),w.innerHTML=xe,Z=o(),_(M.$$.fragment),ee=o(),a=i("div"),_(y.$$.fragment),se=o(),E=i("p"),E.innerHTML=be,ae=o(),D=i("div"),_(k.$$.fragment),ie=o(),H=i("p"),H.innerHTML=ve,de=o(),f=i("div"),_(C.$$.fragment),le=o(),F=i("p"),F.textContent=Te,me=o(),N=i("blockquote"),N.innerHTML=$e,fe=o(),c=i("div"),_(L.$$.fragment),ce=o(),S=i("p"),S.textContent=De,pe=o(),O=i("p"),O.innerHTML=Ae,ue=o(),p=i("div"),_(z.$$.fragment),_e=o(),V=i("p"),V.textContent=Pe,he=o(),I=i("blockquote"),I.innerHTML=we,te=o(),_(j.$$.fragment),ne=o(),W=i("p"),this.h()},l(e){const s=ze("svelte-u9bgzb",document.head);u=d(s,"META",{name:!0,content:!0}),s.forEach(n),R=r(e),B=d(e,"P",{}),q(B).forEach(n),J=r(e),h(A.$$.fragment,e),X=r(e),h(P.$$.fragment,e),Y=r(e),w=d(e,"P",{"data-svelte-h":!0}),g(w)!=="svelte-p8z7gn"&&(w.innerHTML=xe),Z=r(e),h(M.$$.fragment,e),ee=r(e),a=d(e,"DIV",{class:!0});var l=q(a);h(y.$$.fragment,l),se=r(l),E=d(l,"P",{"data-svelte-h":!0}),g(E)!=="svelte-1v9f4ml"&&(E.innerHTML=be),ae=r(l),D=d(l,"DIV",{class:!0});var re=q(D);h(k.$$.fragment,re),ie=r(re),H=d(re,"P",{"data-svelte-h":!0}),g(H)!=="svelte-dilic3"&&(H.innerHTML=ve),re.forEach(n),de=r(l),f=d(l,"DIV",{class:!0});var U=q(f);h(C.$$.fragment,U),le=r(U),F=d(U,"P",{"data-svelte-h":!0}),g(F)!=="svelte-1254b9i"&&(F.textContent=Te),me=r(U),N=d(U,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),g(N)!=="svelte-6y4o4y"&&(N.innerHTML=$e),U.forEach(n),fe=r(l),c=d(l,"DIV",{class:!0});var K=q(c);h(L.$$.fragment,K),ce=r(K),S=d(K,"P",{"data-svelte-h":!0}),g(S)!=="svelte-1lxcwhv"&&(S.textContent=De),pe=r(K),O=d(K,"P",{"data-svelte-h":!0}),g(O)!=="svelte-1vivlhg"&&(O.innerHTML=Ae),K.forEach(n),ue=r(l),p=d(l,"DIV",{class:!0});var Q=q(p);h(z.$$.fragment,Q),_e=r(Q),V=d(Q,"P",{"data-svelte-h":!0}),g(V)!=="svelte-1vhtc74"&&(V.textContent=Pe),he=r(Q),I=d(Q,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),g(I)!=="svelte-6y4o4y"&&(I.innerHTML=we),Q.forEach(n),l.forEach(n),te=r(e),h(j.$$.fragment,e),ne=r(e),W=d(e,"P",{}),q(W).forEach(n),this.h()},h(){x(u,"name","hf:doc:metadata"),x(u,"content",Ee),x(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(N,"class","warning"),x(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(I,"class","warning"),x(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),x(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,s){t(document.head,u),m(e,R,s),m(e,B,s),m(e,J,s),b(A,e,s),m(e,X,s),b(P,e,s),m(e,Y,s),m(e,w,s),m(e,Z,s),b(M,e,s),m(e,ee,s),m(e,a,s),b(y,a,null),t(a,se),t(a,E),t(a,ae),t(a,D),b(k,D,null),t(D,ie),t(D,H),t(a,de),t(a,f),b(C,f,null),t(f,le),t(f,F),t(f,me),t(f,N),t(a,fe),t(a,c),b(L,c,null),t(c,ce),t(c,S),t(c,pe),t(c,O),t(a,ue),t(a,p),b(z,p,null),t(p,_e),t(p,V),t(p,he),t(p,I),m(e,te,s),b(j,e,s),m(e,ne,s),m(e,W,s),oe=!0},p:ke,i(e){oe||(v(A.$$.fragment,e),v(P.$$.fragment,e),v(M.$$.fragment,e),v(y.$$.fragment,e),v(k.$$.fragment,e),v(C.$$.fragment,e),v(L.$$.fragment,e),v(z.$$.fragment,e),v(j.$$.fragment,e),oe=!0)},o(e){T(A.$$.fragment,e),T(P.$$.fragment,e),T(M.$$.fragment,e),T(y.$$.fragment,e),T(k.$$.fragment,e),T(C.$$.fragment,e),T(L.$$.fragment,e),T(z.$$.fragment,e),T(j.$$.fragment,e),oe=!1},d(e){e&&(n(R),n(B),n(J),n(X),n(Y),n(w),n(Z),n(ee),n(a),n(te),n(ne),n(W)),n(u),$(A,e),$(P,e),$(M,e),$(y),$(k),$(C),$(L),$(z),$(j,e)}}}const Ee='{"title":"PixArtTransformer2DModel","local":"pixarttransformer2dmodel","sections":[{"title":"PixArtTransformer2DModel","local":"diffusers.PixArtTransformer2DModel","sections":[],"depth":2}],"depth":1}';function He(ge){return Ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ke extends Ne{constructor(u){super(),Le(this,u,He,qe,ye,{})}}export{Ke as component}; | |
Xet Storage Details
- Size:
- 18.3 kB
- Xet hash:
- c95f16ac8dcc989fb5591174b1c9b9d896a9380fe2133ac28d52c08442e5ce95
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.