import{s as Me,n as $e,o as we}from"../chunks/scheduler.8c3d61f6.js";import{S as ye,i as Ne,g as l,s as r,r as d,A as Te,h as i,f as o,c as s,j as R,u as c,x as E,k as D,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 ie}from"../chunks/Docstring.6b390b9a.js";import{C as Fe}from"../chunks/CodeBlock.00a903b3.js";import{H as ae,E as Ze}from"../chunks/EditOnGithub.1e64e623.js";function Ue(ue){let h,P,z,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.',A,M,ge="The abstract from the paper is:",S,$,_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/pr_10056/en/api/models/controlnet_flux#diffusers.FluxControlNetModel">FluxControlNetModel</a> should be loaded with <a href="/docs/diffusers/pr_10056/en/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a>.',B,N,Y,T,K,a,F,de,_,Z,ce,J,xe='The <a href="/docs/diffusers/pr_10056/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,re;return x=new ae({props:{title:"FluxControlNetModel",local:"fluxcontrolnetmodel",headingTag:"h1"}}),w=new ae({props:{title:"Loading from the original format",local:"loading-from-the-original-format",headingTag:"h2"}}),N=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}}),T=new ae({props:{title:"FluxControlNetModel",local:"diffusers.FluxControlNetModel",headingTag:"h2"}}),F=new ie({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:": typing.List[int] = [16, 56, 56]"},{name:"num_mode",val:": int = None"},{name:"conditioning_embedding_channels",val:": int = None"}],source:"https://github.com/huggingface/diffusers/blob/vr_10056/src/diffusers/models/controlnets/controlnet_flux.py#L41"}}),Z=new ie({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:": typing.Optional[typing.Dict[str, typing.Any]] = 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.`,name:"timestep"},{anchor:"diffusers.FluxControlNetModel.forward.block_controlnet_hidden_states",description:`<strong>block_controlnet_hidden_states</strong> &#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:"block_controlnet_hidden_states"},{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/vr_10056/src/diffusers/models/controlnets/controlnet_flux.py#L217",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 ie({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/vr_10056/src/diffusers/models/controlnets/controlnet_flux.py#L147"}}),k=new ae({props:{title:"FluxControlNetOutput",local:"diffusers.models.controlnet_flux.FluxControlNetOutput",headingTag:"h2"}}),j=new ie({props:{name:"class diffusers.models.controlnet_flux.FluxControlNetOutput",anchor:"diffusers.models.controlnet_flux.FluxControlNetOutput",parameters:[{name:"*args",val:""},{name:"**kwargs",val:""}],source:"https://github.com/huggingface/diffusers/blob/vr_10056/src/diffusers/models/controlnet_flux.py#L25"}}),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=r(),z=l("p"),H=r(),d(x.$$.fragment),I=r(),v=l("p"),v.textContent=pe,Q=r(),C=l("p"),C.innerHTML=he,A=r(),M=l("p"),M.textContent=ge,S=r(),$=l("p"),$.innerHTML=_e,q=r(),d(w.$$.fragment),O=r(),y=l("p"),y.innerHTML=be,B=r(),d(N.$$.fragment),Y=r(),d(T.$$.fragment),K=r(),a=l("div"),d(F.$$.fragment),de=r(),_=l("div"),d(Z.$$.fragment),ce=r(),J=l("p"),J.innerHTML=xe,me=r(),b=l("div"),d(U.$$.fragment),fe=r(),W=l("p"),W.textContent=ve,ee=r(),d(k.$$.fragment),te=r(),V=l("div"),d(j.$$.fragment),oe=r(),d(L.$$.fragment),ne=r(),X=l("p"),this.h()},l(e){const t=Te("svelte-u9bgzb",document.head);h=i(t,"META",{name:!0,content:!0}),t.forEach(o),P=s(e),z=i(e,"P",{}),R(z).forEach(o),H=s(e),c(x.$$.fragment,e),I=s(e),v=i(e,"P",{"data-svelte-h":!0}),E(v)!=="svelte-1iop38l"&&(v.textContent=pe),Q=s(e),C=i(e,"P",{"data-svelte-h":!0}),E(C)!=="svelte-1s65p96"&&(C.innerHTML=he),A=s(e),M=i(e,"P",{"data-svelte-h":!0}),E(M)!=="svelte-1cwsb16"&&(M.textContent=ge),S=s(e),$=i(e,"P",{"data-svelte-h":!0}),E($)!=="svelte-fbiw6t"&&($.innerHTML=_e),q=s(e),c(w.$$.fragment,e),O=s(e),y=i(e,"P",{"data-svelte-h":!0}),E(y)!=="svelte-16n8ygi"&&(y.innerHTML=be),B=s(e),c(N.$$.fragment,e),Y=s(e),c(T.$$.fragment,e),K=s(e),a=i(e,"DIV",{class:!0});var G=R(a);c(F.$$.fragment,G),de=s(G),_=i(G,"DIV",{class:!0});var se=R(_);c(Z.$$.fragment,se),ce=s(se),J=i(se,"P",{"data-svelte-h":!0}),E(J)!=="svelte-1os5856"&&(J.innerHTML=xe),se.forEach(o),me=s(G),b=i(G,"DIV",{class:!0});var le=R(b);c(U.$$.fragment,le),fe=s(le),W=i(le,"P",{"data-svelte-h":!0}),E(W)!=="svelte-1o77hl2"&&(W.textContent=ve),le.forEach(o),G.forEach(o),ee=s(e),c(k.$$.fragment,e),te=s(e),V=i(e,"DIV",{class:!0});var Ce=R(V);c(j.$$.fragment,Ce),Ce.forEach(o),oe=s(e),c(L.$$.fragment,e),ne=s(e),X=i(e,"P",{}),R(X).forEach(o),this.h()},h(){D(h,"name","hf:doc:metadata"),D(h,"content",ke),D(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),D(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),D(a,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),D(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,z,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,A,t),n(e,M,t),n(e,S,t),n(e,$,t),n(e,q,t),m(w,e,t),n(e,O,t),n(e,y,t),n(e,B,t),m(N,e,t),n(e,Y,t),m(T,e,t),n(e,K,t),n(e,a,t),m(F,a,null),g(a,de),g(a,_),m(Z,_,null),g(_,ce),g(_,J),g(a,me),g(a,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),re=!0},p:$e,i(e){re||(f(x.$$.fragment,e),f(w.$$.fragment,e),f(N.$$.fragment,e),f(T.$$.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),re=!0)},o(e){u(x.$$.fragment,e),u(w.$$.fragment,e),u(N.$$.fragment,e),u(T.$$.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),re=!1},d(e){e&&(o(P),o(z),o(H),o(I),o(v),o(Q),o(C),o(A),o(M),o(S),o($),o(q),o(O),o(y),o(B),o(Y),o(K),o(a),o(ee),o(te),o(V),o(oe),o(ne),o(X)),o(h),p(x,e),p(w,e),p(N,e),p(T,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(),Ne(this,h,Ve,Ue,Me,{})}}export{Ge as component};
