import{s as ue,n as le,o as pe}from"../chunks/scheduler.53228c21.js";import{S as _e,i as he,e as i,s as r,c as m,h as ge,a as d,d as s,b as n,f as V,g as u,j as X,k as J,l,m as t,n as p,t as _,o as h,p as g}from"../chunks/index.100fac89.js";import{C as Ae}from"../chunks/CopyLLMTxtMenu.fb2ec027.js";import{D as re}from"../chunks/Docstring.86a664ae.js";import{C as Pe}from"../chunks/CodeBlock.d30a6509.js";import{H as ne,E as ye}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.09d4dba9.js";function Te(ae){let f,k,S,R,P,z,y,j,T,ie='A Diffusion Transformer model for <a href="https://github.com/Tencent-Hunyuan/HunyuanImage-2.1" rel="nofollow">HunyuanImage2.1</a>.',U,b,de="The model can be loaded with the following code snippet.",E,M,N,$,W,a,x,ee,F,fe='The Transformer model used in <a href="https://github.com/Tencent-Hunyuan/HunyuanImage-2.1" rel="nofollow">HunyuanImage-2.1</a>.',oe,A,I,se,C,ce="Sets the attention processor to use to compute attention.",Z,D,q,c,H,te,w,me='The output of <a href="/docs/diffusers/main/en/api/models/transformer2d#diffusers.Transformer2DModel">Transformer2DModel</a>.',K,v,O,G,Y;return P=new Ae({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),y=new ne({props:{title:"HunyuanImageTransformer2DModel",local:"hunyuanimagetransformer2dmodel",headingTag:"h1"}}),M=new Pe({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}}),$=new ne({props:{title:"HunyuanImageTransformer2DModel",local:"diffusers.HunyuanImageTransformer2DModel",headingTag:"h2"}}),x=new re({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"}}),I=new re({props:{name:"set_attn_processor",anchor:"diffusers.HunyuanImageTransformer2DModel.set_attn_processor",parameters:[{name:"processor",val:": typing.Union[diffusers.models.attention_processor.AttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor2_0, diffusers.models.attention_processor.JointAttnProcessor2_0, diffusers.models.attention_processor.PAGJointAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGJointAttnProcessor2_0, diffusers.models.attention_processor.FusedJointAttnProcessor2_0, diffusers.models.attention_processor.AllegroAttnProcessor2_0, diffusers.models.attention_processor.AuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FusedAuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.CogVideoXAttnProcessor2_0, diffusers.models.attention_processor.FusedCogVideoXAttnProcessor2_0, diffusers.models.attention_processor.XFormersAttnAddedKVProcessor, diffusers.models.attention_processor.XFormersAttnProcessor, diffusers.models.attention_processor.XLAFlashAttnProcessor2_0, diffusers.models.attention_processor.AttnProcessorNPU, diffusers.models.attention_processor.AttnProcessor2_0, diffusers.models.attention_processor.MochiVaeAttnProcessor2_0, diffusers.models.attention_processor.MochiAttnProcessor2_0, diffusers.models.attention_processor.StableAudioAttnProcessor2_0, diffusers.models.attention_processor.HunyuanAttnProcessor2_0, diffusers.models.attention_processor.FusedHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.LuminaAttnProcessor2_0, diffusers.models.attention_processor.FusedAttnProcessor2_0, diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor2_0, diffusers.models.attention_processor.SlicedAttnProcessor, diffusers.models.attention_processor.SlicedAttnAddedKVProcessor, diffusers.models.attention_processor.SanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleLinearAttention, diffusers.models.attention_processor.SanaMultiscaleAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleAttentionProjection, diffusers.models.attention_processor.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, diffusers.models.attention_processor.SD3IPAdapterJointAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.LoRAAttnProcessor, diffusers.models.attention_processor.LoRAAttnProcessor2_0, diffusers.models.attention_processor.LoRAXFormersAttnProcessor, diffusers.models.attention_processor.LoRAAttnAddedKVProcessor, typing.Dict[str, typing.Union[diffusers.models.attention_processor.AttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor, diffusers.models.attention_processor.AttnAddedKVProcessor2_0, diffusers.models.attention_processor.JointAttnProcessor2_0, diffusers.models.attention_processor.PAGJointAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGJointAttnProcessor2_0, diffusers.models.attention_processor.FusedJointAttnProcessor2_0, diffusers.models.attention_processor.AllegroAttnProcessor2_0, diffusers.models.attention_processor.AuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FusedAuraFlowAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0, diffusers.models.attention_processor.FluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0, diffusers.models.attention_processor.FusedFluxAttnProcessor2_0_NPU, diffusers.models.attention_processor.CogVideoXAttnProcessor2_0, diffusers.models.attention_processor.FusedCogVideoXAttnProcessor2_0, diffusers.models.attention_processor.XFormersAttnAddedKVProcessor, diffusers.models.attention_processor.XFormersAttnProcessor, diffusers.models.attention_processor.XLAFlashAttnProcessor2_0, diffusers.models.attention_processor.AttnProcessorNPU, diffusers.models.attention_processor.AttnProcessor2_0, diffusers.models.attention_processor.MochiVaeAttnProcessor2_0, diffusers.models.attention_processor.MochiAttnProcessor2_0, diffusers.models.attention_processor.StableAudioAttnProcessor2_0, diffusers.models.attention_processor.HunyuanAttnProcessor2_0, diffusers.models.attention_processor.FusedHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGHunyuanAttnProcessor2_0, diffusers.models.attention_processor.LuminaAttnProcessor2_0, diffusers.models.attention_processor.FusedAttnProcessor2_0, diffusers.models.attention_processor.CustomDiffusionXFormersAttnProcessor, diffusers.models.attention_processor.CustomDiffusionAttnProcessor2_0, diffusers.models.attention_processor.SlicedAttnProcessor, diffusers.models.attention_processor.SlicedAttnAddedKVProcessor, diffusers.models.attention_processor.SanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGSanaLinearAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySanaLinearAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleLinearAttention, diffusers.models.attention_processor.SanaMultiscaleAttnProcessor2_0, diffusers.models.attention_processor.SanaMultiscaleAttentionProjection, diffusers.models.attention_processor.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, diffusers.models.attention_processor.SD3IPAdapterJointAttnProcessor2_0, diffusers.models.attention_processor.PAGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.PAGCFGIdentitySelfAttnProcessor2_0, diffusers.models.attention_processor.LoRAAttnProcessor, diffusers.models.attention_processor.LoRAAttnProcessor2_0, diffusers.models.attention_processor.LoRAXFormersAttnProcessor, diffusers.models.attention_processor.LoRAAttnAddedKVProcessor]]]"}],parametersDescription:[{anchor:"diffusers.HunyuanImageTransformer2DModel.set_attn_processor.processor",description:`<strong>processor</strong> (<code>dict</code> of <code>AttentionProcessor</code> or only <code>AttentionProcessor</code>) &#x2014;
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/main/src/diffusers/models/transformers/transformer_hunyuanimage.py#L772"}}),D=new ne({props:{title:"Transformer2DModelOutput",local:"diffusers.models.modeling_outputs.Transformer2DModelOutput",headingTag:"h2"}}),H=new re({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 ye({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/hunyuanimage_transformer_2d.md"}}),{c(){f=i("meta"),k=r(),S=i("p"),R=r(),m(P.$$.fragment),z=r(),m(y.$$.fragment),j=r(),T=i("p"),T.innerHTML=ie,U=r(),b=i("p"),b.textContent=de,E=r(),m(M.$$.fragment),N=r(),m($.$$.fragment),W=r(),a=i("div"),m(x.$$.fragment),ee=r(),F=i("p"),F.innerHTML=fe,oe=r(),A=i("div"),m(I.$$.fragment),se=r(),C=i("p"),C.textContent=ce,Z=r(),m(D.$$.fragment),q=r(),c=i("div"),m(H.$$.fragment),te=r(),w=i("p"),w.innerHTML=me,K=r(),m(v.$$.fragment),O=r(),G=i("p"),this.h()},l(e){const o=ge("svelte-u9bgzb",document.head);f=d(o,"META",{name:!0,content:!0}),o.forEach(s),k=n(e),S=d(e,"P",{}),V(S).forEach(s),R=n(e),u(P.$$.fragment,e),z=n(e),u(y.$$.fragment,e),j=n(e),T=d(e,"P",{"data-svelte-h":!0}),X(T)!=="svelte-a51oc8"&&(T.innerHTML=ie),U=n(e),b=d(e,"P",{"data-svelte-h":!0}),X(b)!=="svelte-1vuni30"&&(b.textContent=de),E=n(e),u(M.$$.fragment,e),N=n(e),u($.$$.fragment,e),W=n(e),a=d(e,"DIV",{class:!0});var L=V(a);u(x.$$.fragment,L),ee=n(L),F=d(L,"P",{"data-svelte-h":!0}),X(F)!=="svelte-1e43fo9"&&(F.innerHTML=fe),oe=n(L),A=d(L,"DIV",{class:!0});var Q=V(A);u(I.$$.fragment,Q),se=n(Q),C=d(Q,"P",{"data-svelte-h":!0}),X(C)!=="svelte-1o77hl2"&&(C.textContent=ce),Q.forEach(s),L.forEach(s),Z=n(e),u(D.$$.fragment,e),q=n(e),c=d(e,"DIV",{class:!0});var B=V(c);u(H.$$.fragment,B),te=n(B),w=d(B,"P",{"data-svelte-h":!0}),X(w)!=="svelte-1x8c0js"&&(w.innerHTML=me),B.forEach(s),K=n(e),u(v.$$.fragment,e),O=n(e),G=d(e,"P",{}),V(G).forEach(s),this.h()},h(){J(f,"name","hf:doc:metadata"),J(f,"content",be),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(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(c,"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,o){l(document.head,f),t(e,k,o),t(e,S,o),t(e,R,o),p(P,e,o),t(e,z,o),p(y,e,o),t(e,j,o),t(e,T,o),t(e,U,o),t(e,b,o),t(e,E,o),p(M,e,o),t(e,N,o),p($,e,o),t(e,W,o),t(e,a,o),p(x,a,null),l(a,ee),l(a,F),l(a,oe),l(a,A),p(I,A,null),l(A,se),l(A,C),t(e,Z,o),p(D,e,o),t(e,q,o),t(e,c,o),p(H,c,null),l(c,te),l(c,w),t(e,K,o),p(v,e,o),t(e,O,o),t(e,G,o),Y=!0},p:le,i(e){Y||(_(P.$$.fragment,e),_(y.$$.fragment,e),_(M.$$.fragment,e),_($.$$.fragment,e),_(x.$$.fragment,e),_(I.$$.fragment,e),_(D.$$.fragment,e),_(H.$$.fragment,e),_(v.$$.fragment,e),Y=!0)},o(e){h(P.$$.fragment,e),h(y.$$.fragment,e),h(M.$$.fragment,e),h($.$$.fragment,e),h(x.$$.fragment,e),h(I.$$.fragment,e),h(D.$$.fragment,e),h(H.$$.fragment,e),h(v.$$.fragment,e),Y=!1},d(e){e&&(s(k),s(S),s(R),s(z),s(j),s(T),s(U),s(b),s(E),s(N),s(W),s(a),s(Z),s(q),s(c),s(K),s(O),s(G)),s(f),g(P,e),g(y,e),g(M,e),g($,e),g(x),g(I),g(D,e),g(H),g(v,e)}}}const be='{"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 Me(ae){return pe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Fe extends _e{constructor(f){super(),he(this,f,Me,Te,ue,{})}}export{Fe as component};
