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