Buckets:
| import{s as Ie,o as Ne,n as Le}from"../chunks/scheduler.8c3d61f6.js";import{S as Oe,i as je,g as d,s,r as p,A as qe,h as l,f as o,c as a,j as k,u,x as D,k as C,y as t,a as c,v as _,d as h,t as g,w as x}from"../chunks/index.da70eac4.js";import{T as Ce}from"../chunks/Tip.1d9b8c37.js";import{D as Z}from"../chunks/Docstring.6b390b9a.js";import{H as ze,E as Ee}from"../chunks/EditOnGithub.1e64e623.js";function Fe(V){let n,b="This API is 🧪 experimental.";return{c(){n=d("p"),n.textContent=b},l(m){n=l(m,"P",{"data-svelte-h":!0}),D(n)!=="svelte-89q1io"&&(n.textContent=b)},m(m,P){c(m,n,P)},p:Le,d(m){m&&o(n)}}}function He(V){let n,b="This API is 🧪 experimental.";return{c(){n=d("p"),n.textContent=b},l(m){n=l(m,"P",{"data-svelte-h":!0}),D(n)!=="svelte-89q1io"&&(n.textContent=b)},m(m,P){c(m,n,P)},p:Le,d(m){m&&o(n)}}}function Se(V){let n,b,m,P,z,te,L,Te='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>.',ne,I,oe,i,N,de,U,De=`A 2D Transformer model as introduced in PixArt family of models (<a href="https://arxiv.org/abs/2310.00426" rel="nofollow">https://arxiv.org/abs/2310.00426</a>, | |
| <a href="https://arxiv.org/abs/2403.04692" rel="nofollow">https://arxiv.org/abs/2403.04692</a>).`,le,A,O,me,K,Pe='The <a href="/docs/diffusers/pr_9875/en/api/models/pixart_transformer2d#diffusers.PixArtTransformer2DModel">PixArtTransformer2DModel</a> forward method.',fe,v,j,ce,W,Ae=`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.`,pe,w,ue,M,q,_e,Q,we="Sets the attention processor to use to compute attention.",he,$,E,ge,B,Me="Disables custom attention processors and sets the default attention implementation.",xe,G,ye="Safe to just use <code>AttnProcessor()</code> as PixArt doesn’t have any exotic attention processors in default model.",be,T,F,ve,R,ke="Disables the fused QKV projection if enabled.",$e,y,re,H,se,ee,ae;return z=new ze({props:{title:"PixArtTransformer2DModel",local:"pixarttransformer2dmodel",headingTag:"h1"}}),I=new ze({props:{title:"PixArtTransformer2DModel",local:"diffusers.PixArtTransformer2DModel",headingTag:"h2"}}),N=new Z({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:": Optional = 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:": Optional = 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:": Optional = 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:": Optional = None"},{name:"use_additional_conditions",val:": Optional = None"},{name:"caption_channels",val:": Optional = None"},{name:"attention_type",val:": Optional = '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_9875/src/diffusers/models/transformers/pixart_transformer_2d.py#L32"}}),O=new Z({props:{name:"forward",anchor:"diffusers.PixArtTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Optional = None"},{name:"timestep",val:": Optional = None"},{name:"added_cond_kwargs",val:": Dict = None"},{name:"cross_attention_kwargs",val:": Dict = None"},{name:"attention_mask",val:": Optional = None"},{name:"encoder_attention_mask",val:": Optional = 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>. | |
| added_cond_kwargs — (<code>Dict[str, Any]</code>, <em>optional</em>): Additional conditions to be used as inputs.`,name:"timestep"},{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_9875/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_9875/src/diffusers/models/transformers/pixart_transformer_2d.py#L298",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> | |
| `}}),j=new Z({props:{name:"fuse_qkv_projections",anchor:"diffusers.PixArtTransformer2DModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/pixart_transformer_2d.py#L259"}}),w=new Ce({props:{warning:!0,$$slots:{default:[Fe]},$$scope:{ctx:V}}}),q=new Z({props:{name:"set_attn_processor",anchor:"diffusers.PixArtTransformer2DModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.PixArtTransformer2DModel.set_attn_processor.processor",description:`<strong>processor</strong> (<code>dict</code> of <code>AttentionProcessor</code> or only <code>AttentionProcessor</code>) — | |
| The instantiated processor class or a dictionary of processor classes that will be set as the processor | |
| for <strong>all</strong> <code>Attention</code> layers.</p> | |
| <p>If <code>processor</code> is a dict, the key needs to define the path to the corresponding cross attention | |
| processor. This is strongly recommended when setting trainable attention processors.`,name:"processor"}],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/pixart_transformer_2d.py#L216"}}),E=new Z({props:{name:"set_default_attn_processor",anchor:"diffusers.PixArtTransformer2DModel.set_default_attn_processor",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/pixart_transformer_2d.py#L250"}}),F=new Z({props:{name:"unfuse_qkv_projections",anchor:"diffusers.PixArtTransformer2DModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_9875/src/diffusers/models/transformers/pixart_transformer_2d.py#L285"}}),y=new Ce({props:{warning:!0,$$slots:{default:[He]},$$scope:{ctx:V}}}),H=new Ee({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/pixart_transformer2d.md"}}),{c(){n=d("meta"),b=s(),m=d("p"),P=s(),p(z.$$.fragment),te=s(),L=d("p"),L.innerHTML=Te,ne=s(),p(I.$$.fragment),oe=s(),i=d("div"),p(N.$$.fragment),de=s(),U=d("p"),U.innerHTML=De,le=s(),A=d("div"),p(O.$$.fragment),me=s(),K=d("p"),K.innerHTML=Pe,fe=s(),v=d("div"),p(j.$$.fragment),ce=s(),W=d("p"),W.textContent=Ae,pe=s(),p(w.$$.fragment),ue=s(),M=d("div"),p(q.$$.fragment),_e=s(),Q=d("p"),Q.textContent=we,he=s(),$=d("div"),p(E.$$.fragment),ge=s(),B=d("p"),B.textContent=Me,xe=s(),G=d("p"),G.innerHTML=ye,be=s(),T=d("div"),p(F.$$.fragment),ve=s(),R=d("p"),R.textContent=ke,$e=s(),p(y.$$.fragment),re=s(),p(H.$$.fragment),se=s(),ee=d("p"),this.h()},l(e){const r=qe("svelte-u9bgzb",document.head);n=l(r,"META",{name:!0,content:!0}),r.forEach(o),b=a(e),m=l(e,"P",{}),k(m).forEach(o),P=a(e),u(z.$$.fragment,e),te=a(e),L=l(e,"P",{"data-svelte-h":!0}),D(L)!=="svelte-p8z7gn"&&(L.innerHTML=Te),ne=a(e),u(I.$$.fragment,e),oe=a(e),i=l(e,"DIV",{class:!0});var f=k(i);u(N.$$.fragment,f),de=a(f),U=l(f,"P",{"data-svelte-h":!0}),D(U)!=="svelte-1pwq02h"&&(U.innerHTML=De),le=a(f),A=l(f,"DIV",{class:!0});var S=k(A);u(O.$$.fragment,S),me=a(S),K=l(S,"P",{"data-svelte-h":!0}),D(K)!=="svelte-rp48c4"&&(K.innerHTML=Pe),S.forEach(o),fe=a(f),v=l(f,"DIV",{class:!0});var J=k(v);u(j.$$.fragment,J),ce=a(J),W=l(J,"P",{"data-svelte-h":!0}),D(W)!=="svelte-1254b9i"&&(W.textContent=Ae),pe=a(J),u(w.$$.fragment,J),J.forEach(o),ue=a(f),M=l(f,"DIV",{class:!0});var ie=k(M);u(q.$$.fragment,ie),_e=a(ie),Q=l(ie,"P",{"data-svelte-h":!0}),D(Q)!=="svelte-1o77hl2"&&(Q.textContent=we),ie.forEach(o),he=a(f),$=l(f,"DIV",{class:!0});var X=k($);u(E.$$.fragment,X),ge=a(X),B=l(X,"P",{"data-svelte-h":!0}),D(B)!=="svelte-1lxcwhv"&&(B.textContent=Me),xe=a(X),G=l(X,"P",{"data-svelte-h":!0}),D(G)!=="svelte-1vivlhg"&&(G.innerHTML=ye),X.forEach(o),be=a(f),T=l(f,"DIV",{class:!0});var Y=k(T);u(F.$$.fragment,Y),ve=a(Y),R=l(Y,"P",{"data-svelte-h":!0}),D(R)!=="svelte-1vhtc74"&&(R.textContent=ke),$e=a(Y),u(y.$$.fragment,Y),Y.forEach(o),f.forEach(o),re=a(e),u(H.$$.fragment,e),se=a(e),ee=l(e,"P",{}),k(ee).forEach(o),this.h()},h(){C(n,"name","hf:doc:metadata"),C(n,"content",Ve),C(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),C(i,"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,r){t(document.head,n),c(e,b,r),c(e,m,r),c(e,P,r),_(z,e,r),c(e,te,r),c(e,L,r),c(e,ne,r),_(I,e,r),c(e,oe,r),c(e,i,r),_(N,i,null),t(i,de),t(i,U),t(i,le),t(i,A),_(O,A,null),t(A,me),t(A,K),t(i,fe),t(i,v),_(j,v,null),t(v,ce),t(v,W),t(v,pe),_(w,v,null),t(i,ue),t(i,M),_(q,M,null),t(M,_e),t(M,Q),t(i,he),t(i,$),_(E,$,null),t($,ge),t($,B),t($,xe),t($,G),t(i,be),t(i,T),_(F,T,null),t(T,ve),t(T,R),t(T,$e),_(y,T,null),c(e,re,r),_(H,e,r),c(e,se,r),c(e,ee,r),ae=!0},p(e,[r]){const f={};r&2&&(f.$$scope={dirty:r,ctx:e}),w.$set(f);const S={};r&2&&(S.$$scope={dirty:r,ctx:e}),y.$set(S)},i(e){ae||(h(z.$$.fragment,e),h(I.$$.fragment,e),h(N.$$.fragment,e),h(O.$$.fragment,e),h(j.$$.fragment,e),h(w.$$.fragment,e),h(q.$$.fragment,e),h(E.$$.fragment,e),h(F.$$.fragment,e),h(y.$$.fragment,e),h(H.$$.fragment,e),ae=!0)},o(e){g(z.$$.fragment,e),g(I.$$.fragment,e),g(N.$$.fragment,e),g(O.$$.fragment,e),g(j.$$.fragment,e),g(w.$$.fragment,e),g(q.$$.fragment,e),g(E.$$.fragment,e),g(F.$$.fragment,e),g(y.$$.fragment,e),g(H.$$.fragment,e),ae=!1},d(e){e&&(o(b),o(m),o(P),o(te),o(L),o(ne),o(oe),o(i),o(re),o(se),o(ee)),o(n),x(z,e),x(I,e),x(N),x(O),x(j),x(w),x(q),x(E),x(F),x(y),x(H,e)}}}const Ve='{"title":"PixArtTransformer2DModel","local":"pixarttransformer2dmodel","sections":[{"title":"PixArtTransformer2DModel","local":"diffusers.PixArtTransformer2DModel","sections":[],"depth":2}],"depth":1}';function Ue(V){return Ne(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends Oe{constructor(n){super(),je(this,n,Ue,Se,Ie,{})}}export{Re as component}; | |
Xet Storage Details
- Size:
- 19.6 kB
- Xet hash:
- f308a6ed934f8a6f7baa3637153364aac5c6855e39ebca76215b992a0cb3bc96
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.