import{s as $e,n as Me,o as we}from"../chunks/scheduler.8c3d61f6.js";import{S as ye,i as Te,g as l,s,r as d,A as Ne,h as a,f as o,c as r,j as R,u as c,x as E,k as z,y as g,a as n,v as m,d as f,t as u,w as p}from"../chunks/index.da70eac4.js";import{D as ae}from"../chunks/Docstring.6b390b9a.js";import{C as Fe}from"../chunks/CodeBlock.00a903b3.js";import{H as ie,E as Ze}from"../chunks/EditOnGithub.1e64e623.js";function Ue(ue){let h,P,D,H,x,I,v,pe="FluxControlNetModel is an implementation of ControlNet for Flux.1.",Q,C,he='The ControlNet model 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, Maneesh Agrawala. It provides a greater degree of control over text-to-image generation by conditioning the model on additional inputs such as edge maps, depth maps, segmentation maps, and keypoints for pose detection.',S,$,ge="The abstract from the paper is:",A,M,_e="<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,w,O,y,be='By default the <a href="/docs/diffusers/main/en/api/models/controlnet_flux#diffusers.FluxControlNetModel">FluxControlNetModel</a> should be loaded with <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a>.',B,T,Y,N,K,i,F,de,_,Z,ce,J,xe='The <a href="/docs/diffusers/main/en/api/models/flux_transformer#diffusers.FluxTransformer2DModel">FluxTransformer2DModel</a> forward method.',me,b,U,fe,W,ve="Sets the attention processor to use to compute attention.",ee,k,te,V,j,oe,L,ne,X,se;return x=new ie({props:{title:"FluxControlNetModel",local:"fluxcontrolnetmodel",headingTag:"h1"}}),w=new ie({props:{title:"Loading from the original format",local:"loading-from-the-original-format",headingTag:"h2"}}),T=new Fe({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEZsdXhDb250cm9sTmV0UGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLm1vZGVscyUyMGltcG9ydCUyMEZsdXhDb250cm9sTmV0TW9kZWwlMkMlMjBGbHV4TXVsdGlDb250cm9sTmV0TW9kZWwlMEElMEFjb250cm9sbmV0JTIwJTNEJTIwRmx1eENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIySW5zdGFudFglMkZGTFVYLjEtZGV2LUNvbnRyb2xuZXQtQ2FubnklMjIpJTBBcGlwZSUyMCUzRCUyMEZsdXhDb250cm9sTmV0UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmJsYWNrLWZvcmVzdC1sYWJzJTJGRkxVWC4xLWRldiUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0KSUwQSUwQWNvbnRyb2xuZXQlMjAlM0QlMjBGbHV4Q29udHJvbE5ldE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJJbnN0YW50WCUyRkZMVVguMS1kZXYtQ29udHJvbG5ldC1DYW5ueSUyMiklMEFjb250cm9sbmV0JTIwJTNEJTIwRmx1eE11bHRpQ29udHJvbE5ldE1vZGVsKCU1QmNvbnRyb2xuZXQlNUQpJTBBcGlwZSUyMCUzRCUyMEZsdXhDb250cm9sTmV0UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMmJsYWNrLWZvcmVzdC1sYWJzJTJGRkxVWC4xLWRldiUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0KQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FluxControlNetPipeline
<span class="hljs-keyword">from</span> diffusers.models <span class="hljs-keyword">import</span> FluxControlNetModel, FluxMultiControlNetModel

controlnet = FluxControlNetModel.from_pretrained(<span class="hljs-string">&quot;InstantX/FLUX.1-dev-Controlnet-Canny&quot;</span>)
pipe = FluxControlNetPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/FLUX.1-dev&quot;</span>, controlnet=controlnet)

controlnet = FluxControlNetModel.from_pretrained(<span class="hljs-string">&quot;InstantX/FLUX.1-dev-Controlnet-Canny&quot;</span>)
controlnet = FluxMultiControlNetModel([controlnet])
pipe = FluxControlNetPipeline.from_pretrained(<span class="hljs-string">&quot;black-forest-labs/FLUX.1-dev&quot;</span>, controlnet=controlnet)`,wrap:!1}}),N=new ie({props:{title:"FluxControlNetModel",local:"diffusers.FluxControlNetModel",headingTag:"h2"}}),F=new ae({props:{name:"class diffusers.FluxControlNetModel",anchor:"diffusers.FluxControlNetModel",parameters:[{name:"patch_size",val:": int = 1"},{name:"in_channels",val:": int = 64"},{name:"num_layers",val:": int = 19"},{name:"num_single_layers",val:": int = 38"},{name:"attention_head_dim",val:": int = 128"},{name:"num_attention_heads",val:": int = 24"},{name:"joint_attention_dim",val:": int = 4096"},{name:"pooled_projection_dim",val:": int = 768"},{name:"guidance_embeds",val:": bool = False"},{name:"axes_dims_rope",val:": List = [16, 56, 56]"},{name:"num_mode",val:": int = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_flux.py#L41"}}),Z=new ae({props:{name:"forward",anchor:"diffusers.FluxControlNetModel.forward",parameters:[{name:"hidden_states",val:": Tensor"},{name:"controlnet_cond",val:": Tensor"},{name:"controlnet_mode",val:": Tensor = None"},{name:"conditioning_scale",val:": float = 1.0"},{name:"encoder_hidden_states",val:": Tensor = None"},{name:"pooled_projections",val:": Tensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"img_ids",val:": Tensor = None"},{name:"txt_ids",val:": Tensor = None"},{name:"guidance",val:": Tensor = None"},{name:"joint_attention_kwargs",val:": Optional = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.FluxControlNetModel.forward.hidden_states",description:`<strong>hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, channel, height, width)</code>) &#x2014;
Input <code>hidden_states</code>.`,name:"hidden_states"},{anchor:"diffusers.FluxControlNetModel.forward.controlnet_cond",description:`<strong>controlnet_cond</strong> (<code>torch.Tensor</code>) &#x2014;
The conditional input tensor of shape <code>(batch_size, sequence_length, hidden_size)</code>.`,name:"controlnet_cond"},{anchor:"diffusers.FluxControlNetModel.forward.controlnet_mode",description:`<strong>controlnet_mode</strong> (<code>torch.Tensor</code>) &#x2014;
The mode tensor of shape <code>(batch_size, 1)</code>.`,name:"controlnet_mode"},{anchor:"diffusers.FluxControlNetModel.forward.conditioning_scale",description:`<strong>conditioning_scale</strong> (<code>float</code>, defaults to <code>1.0</code>) &#x2014;
The scale factor for ControlNet outputs.`,name:"conditioning_scale"},{anchor:"diffusers.FluxControlNetModel.forward.encoder_hidden_states",description:`<strong>encoder_hidden_states</strong> (<code>torch.FloatTensor</code> of shape <code>(batch size, sequence_len, embed_dims)</code>) &#x2014;
Conditional embeddings (embeddings computed from the input conditions such as prompts) to use.`,name:"encoder_hidden_states"},{anchor:"diffusers.FluxControlNetModel.forward.pooled_projections",description:`<strong>pooled_projections</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, projection_dim)</code>) &#x2014; Embeddings projected
from the embeddings of input conditions.`,name:"pooled_projections"},{anchor:"diffusers.FluxControlNetModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.
block_controlnet_hidden_states &#x2014; (<code>list</code> of <code>torch.Tensor</code>):
A list of tensors that if specified are added to the residuals of transformer blocks.`,name:"timestep"},{anchor:"diffusers.FluxControlNetModel.forward.joint_attention_kwargs",description:`<strong>joint_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined under
<code>self.processor</code> in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow">diffusers.models.attention_processor</a>.`,name:"joint_attention_kwargs"},{anchor:"diffusers.FluxControlNetModel.forward.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <code>~models.transformer_2d.Transformer2DModelOutput</code> instead of a plain
tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_flux.py#L209",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is True, an <code>~models.transformer_2d.Transformer2DModelOutput</code> is returned, otherwise a
<code>tuple</code> where the first element is the sample tensor.</p>
`}}),U=new ae({props:{name:"set_attn_processor",anchor:"diffusers.FluxControlNetModel.set_attn_processor",parameters:[{name:"processor",val:""}],parametersDescription:[{anchor:"diffusers.FluxControlNetModel.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/controlnet_flux.py#L139"}}),k=new ie({props:{title:"FluxControlNetOutput",local:"diffusers.models.controlnet_flux.FluxControlNetOutput",headingTag:"h2"}}),j=new ae({props:{name:"class diffusers.models.controlnet_flux.FluxControlNetOutput",anchor:"diffusers.models.controlnet_flux.FluxControlNetOutput",parameters:[{name:"controlnet_block_samples",val:": Tuple"},{name:"controlnet_single_block_samples",val:": Tuple"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_flux.py#L35"}}),L=new Ze({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet_flux.md"}}),{c(){h=l("meta"),P=s(),D=l("p"),H=s(),d(x.$$.fragment),I=s(),v=l("p"),v.textContent=pe,Q=s(),C=l("p"),C.innerHTML=he,S=s(),$=l("p"),$.textContent=ge,A=s(),M=l("p"),M.innerHTML=_e,q=s(),d(w.$$.fragment),O=s(),y=l("p"),y.innerHTML=be,B=s(),d(T.$$.fragment),Y=s(),d(N.$$.fragment),K=s(),i=l("div"),d(F.$$.fragment),de=s(),_=l("div"),d(Z.$$.fragment),ce=s(),J=l("p"),J.innerHTML=xe,me=s(),b=l("div"),d(U.$$.fragment),fe=s(),W=l("p"),W.textContent=ve,ee=s(),d(k.$$.fragment),te=s(),V=l("div"),d(j.$$.fragment),oe=s(),d(L.$$.fragment),ne=s(),X=l("p"),this.h()},l(e){const t=Ne("svelte-u9bgzb",document.head);h=a(t,"META",{name:!0,content:!0}),t.forEach(o),P=r(e),D=a(e,"P",{}),R(D).forEach(o),H=r(e),c(x.$$.fragment,e),I=r(e),v=a(e,"P",{"data-svelte-h":!0}),E(v)!=="svelte-1iop38l"&&(v.textContent=pe),Q=r(e),C=a(e,"P",{"data-svelte-h":!0}),E(C)!=="svelte-1s65p96"&&(C.innerHTML=he),S=r(e),$=a(e,"P",{"data-svelte-h":!0}),E($)!=="svelte-1cwsb16"&&($.textContent=ge),A=r(e),M=a(e,"P",{"data-svelte-h":!0}),E(M)!=="svelte-fbiw6t"&&(M.innerHTML=_e),q=r(e),c(w.$$.fragment,e),O=r(e),y=a(e,"P",{"data-svelte-h":!0}),E(y)!=="svelte-1jh70ee"&&(y.innerHTML=be),B=r(e),c(T.$$.fragment,e),Y=r(e),c(N.$$.fragment,e),K=r(e),i=a(e,"DIV",{class:!0});var G=R(i);c(F.$$.fragment,G),de=r(G),_=a(G,"DIV",{class:!0});var re=R(_);c(Z.$$.fragment,re),ce=r(re),J=a(re,"P",{"data-svelte-h":!0}),E(J)!=="svelte-4l0nim"&&(J.innerHTML=xe),re.forEach(o),me=r(G),b=a(G,"DIV",{class:!0});var le=R(b);c(U.$$.fragment,le),fe=r(le),W=a(le,"P",{"data-svelte-h":!0}),E(W)!=="svelte-1o77hl2"&&(W.textContent=ve),le.forEach(o),G.forEach(o),ee=r(e),c(k.$$.fragment,e),te=r(e),V=a(e,"DIV",{class:!0});var Ce=R(V);c(j.$$.fragment,Ce),Ce.forEach(o),oe=r(e),c(L.$$.fragment,e),ne=r(e),X=a(e,"P",{}),R(X).forEach(o),this.h()},h(){z(h,"name","hf:doc:metadata"),z(h,"content",ke),z(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(i,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),z(V,"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){g(document.head,h),n(e,P,t),n(e,D,t),n(e,H,t),m(x,e,t),n(e,I,t),n(e,v,t),n(e,Q,t),n(e,C,t),n(e,S,t),n(e,$,t),n(e,A,t),n(e,M,t),n(e,q,t),m(w,e,t),n(e,O,t),n(e,y,t),n(e,B,t),m(T,e,t),n(e,Y,t),m(N,e,t),n(e,K,t),n(e,i,t),m(F,i,null),g(i,de),g(i,_),m(Z,_,null),g(_,ce),g(_,J),g(i,me),g(i,b),m(U,b,null),g(b,fe),g(b,W),n(e,ee,t),m(k,e,t),n(e,te,t),n(e,V,t),m(j,V,null),n(e,oe,t),m(L,e,t),n(e,ne,t),n(e,X,t),se=!0},p:Me,i(e){se||(f(x.$$.fragment,e),f(w.$$.fragment,e),f(T.$$.fragment,e),f(N.$$.fragment,e),f(F.$$.fragment,e),f(Z.$$.fragment,e),f(U.$$.fragment,e),f(k.$$.fragment,e),f(j.$$.fragment,e),f(L.$$.fragment,e),se=!0)},o(e){u(x.$$.fragment,e),u(w.$$.fragment,e),u(T.$$.fragment,e),u(N.$$.fragment,e),u(F.$$.fragment,e),u(Z.$$.fragment,e),u(U.$$.fragment,e),u(k.$$.fragment,e),u(j.$$.fragment,e),u(L.$$.fragment,e),se=!1},d(e){e&&(o(P),o(D),o(H),o(I),o(v),o(Q),o(C),o(S),o($),o(A),o(M),o(q),o(O),o(y),o(B),o(Y),o(K),o(i),o(ee),o(te),o(V),o(oe),o(ne),o(X)),o(h),p(x,e),p(w,e),p(T,e),p(N,e),p(F),p(Z),p(U),p(k,e),p(j),p(L,e)}}}const ke='{"title":"FluxControlNetModel","local":"fluxcontrolnetmodel","sections":[{"title":"Loading from the original format","local":"loading-from-the-original-format","sections":[],"depth":2},{"title":"FluxControlNetModel","local":"diffusers.FluxControlNetModel","sections":[],"depth":2},{"title":"FluxControlNetOutput","local":"diffusers.models.controlnet_flux.FluxControlNetOutput","sections":[],"depth":2}],"depth":1}';function Ve(ue){return we(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ge extends ye{constructor(h){super(),Te(this,h,Ve,Ue,$e,{})}}export{Ge as component};
