import{s as Ce,n as be,o as Te}from"../chunks/scheduler.53228c21.js";import{S as ve,i as De,e as i,s as n,c,h as xe,a,d as o,b as r,f as z,g as f,j as P,k as X,l as u,m as s,n as m,t as p,o as _,p as h}from"../chunks/index.100fac89.js";import{C as $e}from"../chunks/CopyLLMTxtMenu.9360b11d.js";import{D as ce}from"../chunks/Docstring.22cc8849.js";import{C as Me}from"../chunks/CodeBlock.d30a6509.js";import{H as fe,E as He}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.c9001d7a.js";function Ne(ue){let l,U,R,E,y,J,C,j,b,me='HunyuanDiT2DControlNetModel is an implementation of ControlNet for <a href="https://huggingface.co/papers/2405.08748" rel="nofollow">Hunyuan-DiT</a>.',Z,T,pe='ControlNet was introduced in <a href="https://huggingface.co/papers/2302.05543" rel="nofollow">Adding Conditional Control to Text-to-Image Diffusion Models</a> by Lvmin Zhang, Anyi Rao, and Maneesh Agrawala.',W,v,_e="With a ControlNet model, you can provide an additional control image to condition and control Hunyuan-DiT generation. For example, if you provide a depth map, the ControlNet model generates an image that’ll preserve the spatial information from the depth map. It is a more flexible and accurate way to control the image generation process.",K,D,he="The abstract from the paper is:",B,x,ge="<em>We present ControlNet, a neural network architecture to add spatial conditioning controls to large, pretrained text-to-image diffusion models. ControlNet locks the production-ready large diffusion models, and reuses their deep and robust encoding layers pretrained with billions of images as a strong backbone to learn a diverse set of conditional controls. The neural architecture is connected with “zero convolutions” (zero-initialized convolution layers) that progressively grow the parameters from zero and ensure that no harmful noise could affect the finetuning. We test various conditioning controls, eg, edges, depth, segmentation, human pose, etc, with Stable Diffusion, using single or multiple conditions, with or without prompts. We show that the training of ControlNets is robust with small (&lt;50k) and large (&gt;1m) datasets. Extensive results show that ControlNet may facilitate wider applications to control image diffusion models.</em>",q,$,Ae='This code is implemented by Tencent Hunyuan Team. You can find pre-trained checkpoints for Hunyuan-DiT ControlNets on <a href="https://huggingface.co/Tencent-Hunyuan" rel="nofollow">Tencent Hunyuan</a>.',Y,M,O,H,Q,N,ee,d,w,ie,g,F,ae,G,Pe='The <a href="/docs/diffusers/main/en/api/models/controlnet_hunyuandit#diffusers.HunyuanDiT2DControlNetModel">HunyuanDiT2DControlNetModel</a> forward method.',de,A,L,le,k,ye="Sets the attention processor to use to compute attention.",te,S,oe,I,se;return y=new $e({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),C=new fe({props:{title:"HunyuanDiT2DControlNetModel",local:"hunyuandit2dcontrolnetmodel",headingTag:"h1"}}),M=new fe({props:{title:"Example For Loading HunyuanDiT2DControlNetModel",local:"example-for-loading-hunyuandit2dcontrolnetmodel",headingTag:"h2"}}),H=new Me({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEh1bnl1YW5EaVQyRENvbnRyb2xOZXRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBY29udHJvbG5ldCUyMCUzRCUyMEh1bnl1YW5EaVQyRENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyVGVuY2VudC1IdW55dWFuJTJGSHVueXVhbkRpVC12MS4xLUNvbnRyb2xOZXQtRGlmZnVzZXJzLVBvc2UlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> HunyuanDiT2DControlNetModel
<span class="hljs-keyword">import</span> torch
controlnet = HunyuanDiT2DControlNetModel.from_pretrained(<span class="hljs-string">&quot;Tencent-Hunyuan/HunyuanDiT-v1.1-ControlNet-Diffusers-Pose&quot;</span>, torch_dtype=torch.float16)`,wrap:!1}}),N=new fe({props:{title:"HunyuanDiT2DControlNetModel",local:"diffusers.HunyuanDiT2DControlNetModel",headingTag:"h2"}}),w=new ce({props:{name:"class diffusers.HunyuanDiT2DControlNetModel",anchor:"diffusers.HunyuanDiT2DControlNetModel",parameters:[{name:"conditioning_channels",val:": int = 3"},{name:"num_attention_heads",val:": int = 16"},{name:"attention_head_dim",val:": int = 88"},{name:"in_channels",val:": typing.Optional[int] = None"},{name:"patch_size",val:": typing.Optional[int] = None"},{name:"activation_fn",val:": str = 'gelu-approximate'"},{name:"sample_size",val:" = 32"},{name:"hidden_size",val:" = 1152"},{name:"transformer_num_layers",val:": int = 40"},{name:"mlp_ratio",val:": float = 4.0"},{name:"cross_attention_dim",val:": int = 1024"},{name:"cross_attention_dim_t5",val:": int = 2048"},{name:"pooled_projection_dim",val:": int = 1024"},{name:"text_len",val:": int = 77"},{name:"text_len_t5",val:": int = 256"},{name:"use_style_cond_and_image_meta_size",val:": bool = True"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_hunyuan.py#L41"}}),F=new ce({props:{name:"forward",anchor:"diffusers.HunyuanDiT2DControlNetModel.forward",parameters:[{name:"hidden_states",val:""},{name:"timestep",val:""},{name:"controlnet_cond",val:": Tensor"},{name:"conditioning_scale",val:": float = 1.0"},{name:"encoder_hidden_states",val:" = None"},{name:"text_embedding_mask",val:" = None"},{name:"encoder_hidden_states_t5",val:" = None"},{name:"text_embedding_mask_t5",val:" = None"},{name:"image_meta_size",val:" = None"},{name:"style",val:" = None"},{name:"image_rotary_emb",val:" = None"},{name:"return_dict",val:" = True"}],parametersDescription:[{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.Tensor</code> of shape <code>(batch size, dim, height, width)</code>) &#x2014;
The input tensor.`,name:"hidden_states"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>, <em>optional</em>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.controlnet_cond",description:`<strong>controlnet_cond</strong> ( <code>torch.Tensor</code> ) &#x2014;
The conditioning input to ControlNet.`,name:"controlnet_cond"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.conditioning_scale",description:`<strong>conditioning_scale</strong> ( <code>float</code> ) &#x2014;
Indicate the conditioning scale.`,name:"conditioning_scale"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> ( <code>torch.Tensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. This is the output of <code>BertModel</code>.`,name:"encoder_hidden_states"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.text_embedding_mask",description:`<strong>text_embedding_mask</strong> &#x2014; torch.Tensor
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. This is the output
of <code>BertModel</code>.`,name:"text_embedding_mask"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.encoder_hidden_states_t5",description:`<strong>encoder_hidden_states_t5</strong> ( <code>torch.Tensor</code> of shape <code>(batch size, sequence len, embed dims)</code>, <em>optional</em>) &#x2014;
Conditional embeddings for cross attention layer. This is the output of T5 Text Encoder.`,name:"encoder_hidden_states_t5"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.text_embedding_mask_t5",description:`<strong>text_embedding_mask_t5</strong> &#x2014; torch.Tensor
An attention mask of shape <code>(batch, key_tokens)</code> is applied to <code>encoder_hidden_states</code>. This is the output
of T5 Text Encoder.`,name:"text_embedding_mask_t5"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.image_meta_size",description:`<strong>image_meta_size</strong> (torch.Tensor) &#x2014;
Conditional embedding indicate the image sizes`,name:"image_meta_size"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.style",description:`<strong>style</strong> &#x2014; torch.Tensor:
Conditional embedding indicate the style`,name:"style"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.image_rotary_emb",description:`<strong>image_rotary_emb</strong> (<code>torch.Tensor</code>) &#x2014;
The image rotary embeddings to apply on query and key tensors during attention calculation.`,name:"image_rotary_emb"},{anchor:"diffusers.HunyuanDiT2DControlNetModel.forward.return_dict",description:`<strong>return_dict</strong> &#x2014; bool
Whether to return a dictionary.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnets/controlnet_hunyuan.py#L216"}}),L=new ce({props:{name:"set_attn_processor",anchor:"diffusers.HunyuanDiT2DControlNetModel.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.HunyuanDiT2DControlNetModel.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. 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/controlnets/controlnet_hunyuan.py#L142"}}),S=new He({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet_hunyuandit.md"}}),{c(){l=i("meta"),U=n(),R=i("p"),E=n(),c(y.$$.fragment),J=n(),c(C.$$.fragment),j=n(),b=i("p"),b.innerHTML=me,Z=n(),T=i("p"),T.innerHTML=pe,W=n(),v=i("p"),v.textContent=_e,K=n(),D=i("p"),D.textContent=he,B=n(),x=i("p"),x.innerHTML=ge,q=n(),$=i("p"),$.innerHTML=Ae,Y=n(),c(M.$$.fragment),O=n(),c(H.$$.fragment),Q=n(),c(N.$$.fragment),ee=n(),d=i("div"),c(w.$$.fragment),ie=n(),g=i("div"),c(F.$$.fragment),ae=n(),G=i("p"),G.innerHTML=Pe,de=n(),A=i("div"),c(L.$$.fragment),le=n(),k=i("p"),k.textContent=ye,te=n(),c(S.$$.fragment),oe=n(),I=i("p"),this.h()},l(e){const t=xe("svelte-u9bgzb",document.head);l=a(t,"META",{name:!0,content:!0}),t.forEach(o),U=r(e),R=a(e,"P",{}),z(R).forEach(o),E=r(e),f(y.$$.fragment,e),J=r(e),f(C.$$.fragment,e),j=r(e),b=a(e,"P",{"data-svelte-h":!0}),P(b)!=="svelte-9kclxy"&&(b.innerHTML=me),Z=r(e),T=a(e,"P",{"data-svelte-h":!0}),P(T)!=="svelte-1v2xz23"&&(T.innerHTML=pe),W=r(e),v=a(e,"P",{"data-svelte-h":!0}),P(v)!=="svelte-w3tnjc"&&(v.textContent=_e),K=r(e),D=a(e,"P",{"data-svelte-h":!0}),P(D)!=="svelte-1cwsb16"&&(D.textContent=he),B=r(e),x=a(e,"P",{"data-svelte-h":!0}),P(x)!=="svelte-fbiw6t"&&(x.innerHTML=ge),q=r(e),$=a(e,"P",{"data-svelte-h":!0}),P($)!=="svelte-v5nvtj"&&($.innerHTML=Ae),Y=r(e),f(M.$$.fragment,e),O=r(e),f(H.$$.fragment,e),Q=r(e),f(N.$$.fragment,e),ee=r(e),d=a(e,"DIV",{class:!0});var V=z(d);f(w.$$.fragment,V),ie=r(V),g=a(V,"DIV",{class:!0});var ne=z(g);f(F.$$.fragment,ne),ae=r(ne),G=a(ne,"P",{"data-svelte-h":!0}),P(G)!=="svelte-1cqo8a3"&&(G.innerHTML=Pe),ne.forEach(o),de=r(V),A=a(V,"DIV",{class:!0});var re=z(A);f(L.$$.fragment,re),le=r(re),k=a(re,"P",{"data-svelte-h":!0}),P(k)!=="svelte-1o77hl2"&&(k.textContent=ye),re.forEach(o),V.forEach(o),te=r(e),f(S.$$.fragment,e),oe=r(e),I=a(e,"P",{}),z(I).forEach(o),this.h()},h(){X(l,"name","hf:doc:metadata"),X(l,"content",we),X(g,"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"),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")},m(e,t){u(document.head,l),s(e,U,t),s(e,R,t),s(e,E,t),m(y,e,t),s(e,J,t),m(C,e,t),s(e,j,t),s(e,b,t),s(e,Z,t),s(e,T,t),s(e,W,t),s(e,v,t),s(e,K,t),s(e,D,t),s(e,B,t),s(e,x,t),s(e,q,t),s(e,$,t),s(e,Y,t),m(M,e,t),s(e,O,t),m(H,e,t),s(e,Q,t),m(N,e,t),s(e,ee,t),s(e,d,t),m(w,d,null),u(d,ie),u(d,g),m(F,g,null),u(g,ae),u(g,G),u(d,de),u(d,A),m(L,A,null),u(A,le),u(A,k),s(e,te,t),m(S,e,t),s(e,oe,t),s(e,I,t),se=!0},p:be,i(e){se||(p(y.$$.fragment,e),p(C.$$.fragment,e),p(M.$$.fragment,e),p(H.$$.fragment,e),p(N.$$.fragment,e),p(w.$$.fragment,e),p(F.$$.fragment,e),p(L.$$.fragment,e),p(S.$$.fragment,e),se=!0)},o(e){_(y.$$.fragment,e),_(C.$$.fragment,e),_(M.$$.fragment,e),_(H.$$.fragment,e),_(N.$$.fragment,e),_(w.$$.fragment,e),_(F.$$.fragment,e),_(L.$$.fragment,e),_(S.$$.fragment,e),se=!1},d(e){e&&(o(U),o(R),o(E),o(J),o(j),o(b),o(Z),o(T),o(W),o(v),o(K),o(D),o(B),o(x),o(q),o($),o(Y),o(O),o(Q),o(ee),o(d),o(te),o(oe),o(I)),o(l),h(y,e),h(C,e),h(M,e),h(H,e),h(N,e),h(w),h(F),h(L),h(S,e)}}}const we='{"title":"HunyuanDiT2DControlNetModel","local":"hunyuandit2dcontrolnetmodel","sections":[{"title":"Example For Loading HunyuanDiT2DControlNetModel","local":"example-for-loading-hunyuandit2dcontrolnetmodel","sections":[],"depth":2},{"title":"HunyuanDiT2DControlNetModel","local":"diffusers.HunyuanDiT2DControlNetModel","sections":[],"depth":2}],"depth":1}';function Fe(ue){return Te(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends ve{constructor(l){super(),De(this,l,Fe,Ne,Ce,{})}}export{Ie as component};
