import{s as me,n as le,o as ce}from"../chunks/scheduler.53228c21.js";import{S as fe,i as ue,e as d,s,c,h as pe,a as i,d as n,b as r,f as Z,g as f,j as A,k as j,l as u,m as o,n as p,t as g,o as h,p as _}from"../chunks/index.100fac89.js";import{C as ge}from"../chunks/CopyLLMTxtMenu.494046bd.js";import{D as ne}from"../chunks/Docstring.9bbf7d33.js";import{C as he}from"../chunks/CodeBlock.d30a6509.js";import{H as oe,E as _e}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8999c127.js";function Te(se){let m,q,L,N,b,O,w,R,$,re="The model can be loaded with the following code snippet.",W,y,P,M,E,a,D,B,k,ae="The Transformer model introduced in Qwen.",K,T,v,ee,C,de="The <code>QwenTransformer2DModel</code> forward method.",H,x,V,l,I,te,J,ie='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',G,Q,Y,U,S;return b=new ge({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),w=new oe({props:{title:"QwenImageTransformer2DModel",local:"qwenimagetransformer2dmodel",headingTag:"h1"}}),y=new he({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFF3ZW5JbWFnZVRyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwUXdlbkltYWdlVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJRd2VuJTJGUXdlbkltYWdlLTIwQiUyMiUyQyUyMHN1YmZvbGRlciUzRCUyMnRyYW5zZm9ybWVyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5iZmxvYXQxNik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> QwenImageTransformer2DModel

transformer = QwenImageTransformer2DModel.from_pretrained(<span class="hljs-string">&quot;Qwen/QwenImage-20B&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,wrap:!1}}),M=new oe({props:{title:"QwenImageTransformer2DModel",local:"diffusers.QwenImageTransformer2DModel",headingTag:"h2"}}),D=new ne({props:{name:"class diffusers.QwenImageTransformer2DModel",anchor:"diffusers.QwenImageTransformer2DModel",parameters:[{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 64"},{name:"out_channels",val:": typing.Optional[int] = 16"},{name:"num_layers",val:": int = 60"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 24"},{name:"joint_attention_dim",val:": int = 3584"},{name:"guidance_embeds",val:": bool = False"},{name:"axes_dims_rope",val:": typing.Tuple[int, int, int] = (16, 56, 56)"}],parametersDescription:[{anchor:"diffusers.QwenImageTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
Patch size to turn the input data into small patches.`,name:"patch_size"},{anchor:"diffusers.QwenImageTransformer2DModel.in_channels",description:`<strong>in_channels</strong> (<code>int</code>, defaults to <code>64</code>) &#x2014;
The number of channels in the input.`,name:"in_channels"},{anchor:"diffusers.QwenImageTransformer2DModel.out_channels",description:`<strong>out_channels</strong> (<code>int</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The number of channels in the output. If not specified, it defaults to <code>in_channels</code>.`,name:"out_channels"},{anchor:"diffusers.QwenImageTransformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>60</code>) &#x2014;
The number of layers of dual stream DiT blocks to use.`,name:"num_layers"},{anchor:"diffusers.QwenImageTransformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of dimensions to use for each attention head.`,name:"attention_head_dim"},{anchor:"diffusers.QwenImageTransformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>24</code>) &#x2014;
The number of attention heads to use.`,name:"num_attention_heads"},{anchor:"diffusers.QwenImageTransformer2DModel.joint_attention_dim",description:`<strong>joint_attention_dim</strong> (<code>int</code>, defaults to <code>3584</code>) &#x2014;
The number of dimensions to use for the joint attention (embedding/channel dimension of
<code>encoder_hidden_states</code>).`,name:"joint_attention_dim"},{anchor:"diffusers.QwenImageTransformer2DModel.guidance_embeds",description:`<strong>guidance_embeds</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to use guidance embeddings for guidance-distilled variant of the model.`,name:"guidance_embeds"},{anchor:"diffusers.QwenImageTransformer2DModel.axes_dims_rope",description:`<strong>axes_dims_rope</strong> (<code>Tuple[int]</code>, defaults to <code>(16, 56, 56)</code>) &#x2014;
The dimensions to use for the rotary positional embeddings.`,name:"axes_dims_rope"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_qwenimage.py#L479"}}),v=new ne({props:{name:"forward",anchor:"diffusers.QwenImageTransformer2DModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"encoder_hidden_states",val:": Tensor = None"},{name:"encoder_hidden_states_mask",val:": Tensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"img_shapes",val:": typing.Optional[typing.List[typing.Tuple[int, int, int]]] = None"},{name:"txt_seq_lens",val:": typing.Optional[typing.List[int]] = None"},{name:"guidance",val:": Tensor = None"},{name:"attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = None"},{name:"controlnet_block_samples",val:" = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.QwenImageTransformer2DModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, image_sequence_length, in_channels)</code>) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, text_sequence_length, joint_attention_dim)</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.encoder_hidden_states_mask",description:`<strong>encoder_hidden_states_mask</strong> (<code>torch.Tensor</code> of shape <code>(batch_size, text_sequence_length)</code>) &#x2014;
Mask of the input conditions.`,name:"encoder_hidden_states_mask"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.QwenImageTransformer2DModel.forward.attention_kwargs",description:`<strong>attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
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:"attention_kwargs"},{anchor:"diffusers.QwenImageTransformer2DModel.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/main/src/diffusers/models/transformers/transformer_qwenimage.py#L566",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>
`}}),x=new oe({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),I=new ne({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"}}),Q=new _e({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/qwenimage_transformer2d.md"}}),{c(){m=d("meta"),q=s(),L=d("p"),N=s(),c(b.$$.fragment),O=s(),c(w.$$.fragment),R=s(),$=d("p"),$.textContent=re,W=s(),c(y.$$.fragment),P=s(),c(M.$$.fragment),E=s(),a=d("div"),c(D.$$.fragment),B=s(),k=d("p"),k.textContent=ae,K=s(),T=d("div"),c(v.$$.fragment),ee=s(),C=d("p"),C.innerHTML=de,H=s(),c(x.$$.fragment),V=s(),l=d("div"),c(I.$$.fragment),te=s(),J=d("p"),J.innerHTML=ie,G=s(),c(Q.$$.fragment),Y=s(),U=d("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);m=i(t,"META",{name:!0,content:!0}),t.forEach(n),q=r(e),L=i(e,"P",{}),Z(L).forEach(n),N=r(e),f(b.$$.fragment,e),O=r(e),f(w.$$.fragment,e),R=r(e),$=i(e,"P",{"data-svelte-h":!0}),A($)!=="svelte-1vuni30"&&($.textContent=re),W=r(e),f(y.$$.fragment,e),P=r(e),f(M.$$.fragment,e),E=r(e),a=i(e,"DIV",{class:!0});var z=Z(a);f(D.$$.fragment,z),B=r(z),k=i(z,"P",{"data-svelte-h":!0}),A(k)!=="svelte-1kyfnic"&&(k.textContent=ae),K=r(z),T=i(z,"DIV",{class:!0});var F=Z(T);f(v.$$.fragment,F),ee=r(F),C=i(F,"P",{"data-svelte-h":!0}),A(C)!=="svelte-htyx6t"&&(C.innerHTML=de),F.forEach(n),z.forEach(n),H=r(e),f(x.$$.fragment,e),V=r(e),l=i(e,"DIV",{class:!0});var X=Z(l);f(I.$$.fragment,X),te=r(X),J=i(X,"P",{"data-svelte-h":!0}),A(J)!=="svelte-1x8c0js"&&(J.innerHTML=ie),X.forEach(n),G=r(e),f(Q.$$.fragment,e),Y=r(e),U=i(e,"P",{}),Z(U).forEach(n),this.h()},h(){j(m,"name","hf:doc:metadata"),j(m,"content",be),j(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),j(l,"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){u(document.head,m),o(e,q,t),o(e,L,t),o(e,N,t),p(b,e,t),o(e,O,t),p(w,e,t),o(e,R,t),o(e,$,t),o(e,W,t),p(y,e,t),o(e,P,t),p(M,e,t),o(e,E,t),o(e,a,t),p(D,a,null),u(a,B),u(a,k),u(a,K),u(a,T),p(v,T,null),u(T,ee),u(T,C),o(e,H,t),p(x,e,t),o(e,V,t),o(e,l,t),p(I,l,null),u(l,te),u(l,J),o(e,G,t),p(Q,e,t),o(e,Y,t),o(e,U,t),S=!0},p:le,i(e){S||(g(b.$$.fragment,e),g(w.$$.fragment,e),g(y.$$.fragment,e),g(M.$$.fragment,e),g(D.$$.fragment,e),g(v.$$.fragment,e),g(x.$$.fragment,e),g(I.$$.fragment,e),g(Q.$$.fragment,e),S=!0)},o(e){h(b.$$.fragment,e),h(w.$$.fragment,e),h(y.$$.fragment,e),h(M.$$.fragment,e),h(D.$$.fragment,e),h(v.$$.fragment,e),h(x.$$.fragment,e),h(I.$$.fragment,e),h(Q.$$.fragment,e),S=!1},d(e){e&&(n(q),n(L),n(N),n(O),n(R),n($),n(W),n(P),n(E),n(a),n(H),n(V),n(l),n(G),n(Y),n(U)),n(m),_(b,e),_(w,e),_(y,e),_(M,e),_(D),_(v),_(x,e),_(I),_(Q,e)}}}const be='{"title":"QwenImageTransformer2DModel","local":"qwenimagetransformer2dmodel","sections":[{"title":"QwenImageTransformer2DModel","local":"diffusers.QwenImageTransformer2DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function we(se){return ce(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends fe{constructor(m){super(),ue(this,m,we,Te,me,{})}}export{Ie as component};
