import{s as re,n as se,o as ie}from"../chunks/scheduler.53228c21.js";import{S as de,i as me,e as m,s as a,c as u,h as le,a as l,d as t,b as r,f as Y,g as f,j as G,k as F,l as j,m as o,n as c,t as p,o as h,p as g}from"../chunks/index.100fac89.js";import{C as ue}from"../chunks/CopyLLMTxtMenu.999d3d86.js";import{D as ae}from"../chunks/Docstring.46d0934e.js";import{C as fe}from"../chunks/CodeBlock.d30a6509.js";import{H as A,E as ce}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.d27ae4df.js";function pe(K){let s,E,k,J,_,W,y,Z,T,ee='A Diffusion Transformer model for <a href="https://github.com/Tencent-Hunyuan/HunyuanImage-2.1" rel="nofollow">HunyuanImage2.1</a>.',C,b,ne="The model can be loaded with the following code snippet.",L,$,V,M,P,i,x,Q,I,te='The Transformer model used in <a href="https://github.com/Tencent-Hunyuan/HunyuanImage-2.1" rel="nofollow">HunyuanImage-2.1</a>.',R,H,q,d,D,B,w,oe='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',X,v,N,z,O;return _=new ue({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),y=new A({props:{title:"HunyuanImageTransformer2DModel",local:"hunyuanimagetransformer2dmodel",headingTag:"h1"}}),$=new fe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEh1bnl1YW5JbWFnZVRyYW5zZm9ybWVyMkRNb2RlbCUwQSUwQXRyYW5zZm9ybWVyJTIwJTNEJTIwSHVueXVhbkltYWdlVHJhbnNmb3JtZXIyRE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJodW55dWFudmlkZW8tY29tbXVuaXR5JTJGSHVueXVhbkltYWdlLTIuMS1EaWZmdXNlcnMlMjIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ0cmFuc2Zvcm1lciUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guYmZsb2F0MTYp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HunyuanImageTransformer2DModel

transformer = HunyuanImageTransformer2DModel.from_pretrained(<span class="hljs-string">&quot;hunyuanvideo-community/HunyuanImage-2.1-Diffusers&quot;</span>, subfolder=<span class="hljs-string">&quot;transformer&quot;</span>, torch_dtype=torch.bfloat16)`,wrap:!1}}),M=new A({props:{title:"HunyuanImageTransformer2DModel",local:"diffusers.HunyuanImageTransformer2DModel",headingTag:"h2"}}),x=new ae({props:{name:"class diffusers.HunyuanImageTransformer2DModel",anchor:"diffusers.HunyuanImageTransformer2DModel",parameters:[{name:"in_channels",val:": int = 64"},{name:"out_channels",val:": int = 64"},{name:"num_attention_heads",val:": int = 28"},{name:"attention_head_dim",val:": int = 128"},{name:"num_layers",val:": int = 20"},{name:"num_single_layers",val:": int = 40"},{name:"num_refiner_layers",val:": int = 2"},{name:"mlp_ratio",val:": float = 4.0"},{name:"patch_size",val:": typing.Tuple[int, int] = (1, 1)"},{name:"qk_norm",val:": str = 'rms_norm'"},{name:"guidance_embeds",val:": bool = False"},{name:"text_embed_dim",val:": int = 3584"},{name:"text_embed_2_dim",val:": typing.Optional[int] = None"},{name:"rope_theta",val:": float = 256.0"},{name:"rope_axes_dim",val:": typing.Tuple[int, ...] = (64, 64)"},{name:"use_meanflow",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.HunyuanImageTransformer2DModel.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.HunyuanImageTransformer2DModel.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.HunyuanImageTransformer2DModel.num_attention_heads",description:`<strong>num_attention_heads</strong> (<code>int</code>, defaults to <code>24</code>) &#x2014;
The number of heads to use for multi-head attention.`,name:"num_attention_heads"},{anchor:"diffusers.HunyuanImageTransformer2DModel.attention_head_dim",description:`<strong>attention_head_dim</strong> (<code>int</code>, defaults to <code>128</code>) &#x2014;
The number of channels in each head.`,name:"attention_head_dim"},{anchor:"diffusers.HunyuanImageTransformer2DModel.num_layers",description:`<strong>num_layers</strong> (<code>int</code>, defaults to <code>20</code>) &#x2014;
The number of layers of dual-stream blocks to use.`,name:"num_layers"},{anchor:"diffusers.HunyuanImageTransformer2DModel.num_single_layers",description:`<strong>num_single_layers</strong> (<code>int</code>, defaults to <code>40</code>) &#x2014;
The number of layers of single-stream blocks to use.`,name:"num_single_layers"},{anchor:"diffusers.HunyuanImageTransformer2DModel.num_refiner_layers",description:`<strong>num_refiner_layers</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
The number of layers of refiner blocks to use.`,name:"num_refiner_layers"},{anchor:"diffusers.HunyuanImageTransformer2DModel.mlp_ratio",description:`<strong>mlp_ratio</strong> (<code>float</code>, defaults to <code>4.0</code>) &#x2014;
The ratio of the hidden layer size to the input size in the feedforward network.`,name:"mlp_ratio"},{anchor:"diffusers.HunyuanImageTransformer2DModel.patch_size",description:`<strong>patch_size</strong> (<code>int</code>, defaults to <code>2</code>) &#x2014;
The size of the spatial patches to use in the patch embedding layer.`,name:"patch_size"},{anchor:"diffusers.HunyuanImageTransformer2DModel.patch_size_t",description:`<strong>patch_size_t</strong> (<code>int</code>, defaults to <code>1</code>) &#x2014;
The size of the tmeporal patches to use in the patch embedding layer.`,name:"patch_size_t"},{anchor:"diffusers.HunyuanImageTransformer2DModel.qk_norm",description:`<strong>qk_norm</strong> (<code>str</code>, defaults to <code>rms_norm</code>) &#x2014;
The normalization to use for the query and key projections in the attention layers.`,name:"qk_norm"},{anchor:"diffusers.HunyuanImageTransformer2DModel.guidance_embeds",description:`<strong>guidance_embeds</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Whether to use guidance embeddings in the model.`,name:"guidance_embeds"},{anchor:"diffusers.HunyuanImageTransformer2DModel.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.HunyuanImageTransformer2DModel.pooled_projection_dim",description:`<strong>pooled_projection_dim</strong> (<code>int</code>, defaults to <code>768</code>) &#x2014;
The dimension of the pooled projection of the text embeddings.`,name:"pooled_projection_dim"},{anchor:"diffusers.HunyuanImageTransformer2DModel.rope_theta",description:`<strong>rope_theta</strong> (<code>float</code>, defaults to <code>256.0</code>) &#x2014;
The value of theta to use in the RoPE layer.`,name:"rope_theta"},{anchor:"diffusers.HunyuanImageTransformer2DModel.rope_axes_dim",description:`<strong>rope_axes_dim</strong> (<code>Tuple[int]</code>, defaults to <code>(16, 56, 56)</code>) &#x2014;
The dimensions of the axes to use in the RoPE layer.`,name:"rope_axes_dim"},{anchor:"diffusers.HunyuanImageTransformer2DModel.image_condition_type",description:`<strong>image_condition_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
The type of image conditioning to use. If <code>None</code>, no image conditioning is used. If <code>latent_concat</code>, the
image is concatenated to the latent stream. If <code>token_replace</code>, the image is used to replace first-frame
tokens in the latent stream and apply conditioning.`,name:"image_condition_type"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/transformers/transformer_hunyuanimage.py#L619"}}),H=new A({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),D=new ae({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"}}),v=new ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/hunyuanimage_transformer_2d.md"}}),{c(){s=m("meta"),E=a(),k=m("p"),J=a(),u(_.$$.fragment),W=a(),u(y.$$.fragment),Z=a(),T=m("p"),T.innerHTML=ee,C=a(),b=m("p"),b.textContent=ne,L=a(),u($.$$.fragment),V=a(),u(M.$$.fragment),P=a(),i=m("div"),u(x.$$.fragment),Q=a(),I=m("p"),I.innerHTML=te,R=a(),u(H.$$.fragment),q=a(),d=m("div"),u(D.$$.fragment),B=a(),w=m("p"),w.innerHTML=oe,X=a(),u(v.$$.fragment),N=a(),z=m("p"),this.h()},l(e){const n=le("svelte-u9bgzb",document.head);s=l(n,"META",{name:!0,content:!0}),n.forEach(t),E=r(e),k=l(e,"P",{}),Y(k).forEach(t),J=r(e),f(_.$$.fragment,e),W=r(e),f(y.$$.fragment,e),Z=r(e),T=l(e,"P",{"data-svelte-h":!0}),G(T)!=="svelte-a51oc8"&&(T.innerHTML=ee),C=r(e),b=l(e,"P",{"data-svelte-h":!0}),G(b)!=="svelte-1vuni30"&&(b.textContent=ne),L=r(e),f($.$$.fragment,e),V=r(e),f(M.$$.fragment,e),P=r(e),i=l(e,"DIV",{class:!0});var S=Y(i);f(x.$$.fragment,S),Q=r(S),I=l(S,"P",{"data-svelte-h":!0}),G(I)!=="svelte-1e43fo9"&&(I.innerHTML=te),S.forEach(t),R=r(e),f(H.$$.fragment,e),q=r(e),d=l(e,"DIV",{class:!0});var U=Y(d);f(D.$$.fragment,U),B=r(U),w=l(U,"P",{"data-svelte-h":!0}),G(w)!=="svelte-1x8c0js"&&(w.innerHTML=oe),U.forEach(t),X=r(e),f(v.$$.fragment,e),N=r(e),z=l(e,"P",{}),Y(z).forEach(t),this.h()},h(){F(s,"name","hf:doc:metadata"),F(s,"content",he),F(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(d,"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,n){j(document.head,s),o(e,E,n),o(e,k,n),o(e,J,n),c(_,e,n),o(e,W,n),c(y,e,n),o(e,Z,n),o(e,T,n),o(e,C,n),o(e,b,n),o(e,L,n),c($,e,n),o(e,V,n),c(M,e,n),o(e,P,n),o(e,i,n),c(x,i,null),j(i,Q),j(i,I),o(e,R,n),c(H,e,n),o(e,q,n),o(e,d,n),c(D,d,null),j(d,B),j(d,w),o(e,X,n),c(v,e,n),o(e,N,n),o(e,z,n),O=!0},p:se,i(e){O||(p(_.$$.fragment,e),p(y.$$.fragment,e),p($.$$.fragment,e),p(M.$$.fragment,e),p(x.$$.fragment,e),p(H.$$.fragment,e),p(D.$$.fragment,e),p(v.$$.fragment,e),O=!0)},o(e){h(_.$$.fragment,e),h(y.$$.fragment,e),h($.$$.fragment,e),h(M.$$.fragment,e),h(x.$$.fragment,e),h(H.$$.fragment,e),h(D.$$.fragment,e),h(v.$$.fragment,e),O=!1},d(e){e&&(t(E),t(k),t(J),t(W),t(Z),t(T),t(C),t(b),t(L),t(V),t(P),t(i),t(R),t(q),t(d),t(X),t(N),t(z)),t(s),g(_,e),g(y,e),g($,e),g(M,e),g(x),g(H,e),g(D),g(v,e)}}}const he='{"title":"HunyuanImageTransformer2DModel","local":"hunyuanimagetransformer2dmodel","sections":[{"title":"HunyuanImageTransformer2DModel","local":"diffusers.HunyuanImageTransformer2DModel","sections":[],"depth":2},{"title":"Transformer2DModelOutput","local":"diffusers.models.modeling_outputs.Transformer2DModelOutput","sections":[],"depth":2}],"depth":1}';function ge(K){return ie(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class xe extends de{constructor(s){super(),me(this,s,ge,pe,re,{})}}export{xe as component};
