import{s as ye,n as Pe,o as be}from"../chunks/scheduler.8c3d61f6.js";import{S as Ce,i as ve,g as i,s as n,r as m,A as Te,h as a,f as o,c as r,j as z,u as _,x as p,k as U,y as c,a as s,v as h,d as g,t as A,w as y}from"../chunks/index.da70eac4.js";import{D as de}from"../chunks/Docstring.6b390b9a.js";import{C as De}from"../chunks/CodeBlock.00a903b3.js";import{H as le,E as xe}from"../chunks/EditOnGithub.1e64e623.js";function $e(ce){let l,E,R,I,P,S,b,fe='HunyuanDiT2DControlNetModel is an implementation of ControlNet for <a href="https://arxiv.org/abs/2405.08748" rel="nofollow">Hunyuan-DiT</a>.',J,C,ue='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.',Z,v,me="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.",W,T,_e="The abstract from the paper is:",j,D,pe="<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>",K,x,he='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>.',B,$,Y,H,q,N,O,d,w,ne,f,M,re,k,ge='The <a href="/docs/diffusers/pr_10037/en/api/models/controlnet_hunyuandit#diffusers.HunyuanDiT2DControlNetModel">HunyuanDiT2DControlNetModel</a> forward method.',ie,u,F,ae,V,Ae="Sets the attention processor to use to compute attention.",Q,L,ee,X,te;return P=new le({props:{title:"HunyuanDiT2DControlNetModel",local:"hunyuandit2dcontrolnetmodel",headingTag:"h1"}}),$=new le({props:{title:"Example For Loading HunyuanDiT2DControlNetModel",local:"example-for-loading-hunyuandit2dcontrolnetmodel",headingTag:"h2"}}),H=new De({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 le({props:{title:"HunyuanDiT2DControlNetModel",local:"diffusers.HunyuanDiT2DControlNetModel",headingTag:"h2"}}),w=new de({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/vr_10037/src/diffusers/models/controlnets/controlnet_hunyuan.py#L41"}}),M=new de({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/vr_10037/src/diffusers/models/controlnets/controlnet_hunyuan.py#L216"}}),F=new de({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.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.MochiAttnProcessor2_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.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, 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.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.MochiAttnProcessor2_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.IPAdapterAttnProcessor, diffusers.models.attention_processor.IPAdapterAttnProcessor2_0, diffusers.models.attention_processor.IPAdapterXFormersAttnProcessor, 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/vr_10037/src/diffusers/models/controlnets/controlnet_hunyuan.py#L142"}}),L=new xe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet_hunyuandit.md"}}),{c(){l=i("meta"),E=n(),R=i("p"),I=n(),m(P.$$.fragment),S=n(),b=i("p"),b.innerHTML=fe,J=n(),C=i("p"),C.innerHTML=ue,Z=n(),v=i("p"),v.textContent=me,W=n(),T=i("p"),T.textContent=_e,j=n(),D=i("p"),D.innerHTML=pe,K=n(),x=i("p"),x.innerHTML=he,B=n(),m($.$$.fragment),Y=n(),m(H.$$.fragment),q=n(),m(N.$$.fragment),O=n(),d=i("div"),m(w.$$.fragment),ne=n(),f=i("div"),m(M.$$.fragment),re=n(),k=i("p"),k.innerHTML=ge,ie=n(),u=i("div"),m(F.$$.fragment),ae=n(),V=i("p"),V.textContent=Ae,Q=n(),m(L.$$.fragment),ee=n(),X=i("p"),this.h()},l(e){const t=Te("svelte-u9bgzb",document.head);l=a(t,"META",{name:!0,content:!0}),t.forEach(o),E=r(e),R=a(e,"P",{}),z(R).forEach(o),I=r(e),_(P.$$.fragment,e),S=r(e),b=a(e,"P",{"data-svelte-h":!0}),p(b)!=="svelte-r9b48f"&&(b.innerHTML=fe),J=r(e),C=a(e,"P",{"data-svelte-h":!0}),p(C)!=="svelte-1v2xz23"&&(C.innerHTML=ue),Z=r(e),v=a(e,"P",{"data-svelte-h":!0}),p(v)!=="svelte-w3tnjc"&&(v.textContent=me),W=r(e),T=a(e,"P",{"data-svelte-h":!0}),p(T)!=="svelte-1cwsb16"&&(T.textContent=_e),j=r(e),D=a(e,"P",{"data-svelte-h":!0}),p(D)!=="svelte-fbiw6t"&&(D.innerHTML=pe),K=r(e),x=a(e,"P",{"data-svelte-h":!0}),p(x)!=="svelte-v5nvtj"&&(x.innerHTML=he),B=r(e),_($.$$.fragment,e),Y=r(e),_(H.$$.fragment,e),q=r(e),_(N.$$.fragment,e),O=r(e),d=a(e,"DIV",{class:!0});var G=z(d);_(w.$$.fragment,G),ne=r(G),f=a(G,"DIV",{class:!0});var oe=z(f);_(M.$$.fragment,oe),re=r(oe),k=a(oe,"P",{"data-svelte-h":!0}),p(k)!=="svelte-14hws0m"&&(k.innerHTML=ge),oe.forEach(o),ie=r(G),u=a(G,"DIV",{class:!0});var se=z(u);_(F.$$.fragment,se),ae=r(se),V=a(se,"P",{"data-svelte-h":!0}),p(V)!=="svelte-1o77hl2"&&(V.textContent=Ae),se.forEach(o),G.forEach(o),Q=r(e),_(L.$$.fragment,e),ee=r(e),X=a(e,"P",{}),z(X).forEach(o),this.h()},h(){U(l,"name","hf:doc:metadata"),U(l,"content",He),U(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(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){c(document.head,l),s(e,E,t),s(e,R,t),s(e,I,t),h(P,e,t),s(e,S,t),s(e,b,t),s(e,J,t),s(e,C,t),s(e,Z,t),s(e,v,t),s(e,W,t),s(e,T,t),s(e,j,t),s(e,D,t),s(e,K,t),s(e,x,t),s(e,B,t),h($,e,t),s(e,Y,t),h(H,e,t),s(e,q,t),h(N,e,t),s(e,O,t),s(e,d,t),h(w,d,null),c(d,ne),c(d,f),h(M,f,null),c(f,re),c(f,k),c(d,ie),c(d,u),h(F,u,null),c(u,ae),c(u,V),s(e,Q,t),h(L,e,t),s(e,ee,t),s(e,X,t),te=!0},p:Pe,i(e){te||(g(P.$$.fragment,e),g($.$$.fragment,e),g(H.$$.fragment,e),g(N.$$.fragment,e),g(w.$$.fragment,e),g(M.$$.fragment,e),g(F.$$.fragment,e),g(L.$$.fragment,e),te=!0)},o(e){A(P.$$.fragment,e),A($.$$.fragment,e),A(H.$$.fragment,e),A(N.$$.fragment,e),A(w.$$.fragment,e),A(M.$$.fragment,e),A(F.$$.fragment,e),A(L.$$.fragment,e),te=!1},d(e){e&&(o(E),o(R),o(I),o(S),o(b),o(J),o(C),o(Z),o(v),o(W),o(T),o(j),o(D),o(K),o(x),o(B),o(Y),o(q),o(O),o(d),o(Q),o(ee),o(X)),o(l),y(P,e),y($,e),y(H,e),y(N,e),y(w),y(M),y(F),y(L,e)}}}const He='{"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 Ne(ce){return be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ve extends Ce{constructor(l){super(),ve(this,l,Ne,$e,ye,{})}}export{Ve as component};
