import{s as ye,n as we,o as Ne}from"../chunks/scheduler.53228c21.js";import{S as Te,i as Fe,e as l,s as r,c as d,h as Ze,a as i,d as o,b as s,f as z,g as c,j as J,k as D,l as g,m as n,n as m,t as f,o as p,p as u}from"../chunks/index.100fac89.js";import{C as Ue}from"../chunks/CopyLLMTxtMenu.4f0519ef.js";import{D as de}from"../chunks/Docstring.d02a9fa5.js";import{C as ke}from"../chunks/CodeBlock.d30a6509.js";import{H as ce,E as Ve}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.62dbb7c4.js";function Le(he){let h,H,X,I,x,Q,v,S,$,ge="FluxControlNetModel is an implementation of ControlNet for Flux.1.",A,C,_e='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.',q,M,be="The abstract from the paper is:",O,y,xe="<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>",B,w,Y,N,ve='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>.',K,T,ee,F,te,a,Z,me,_,U,fe,W,$e='The <a href="/docs/diffusers/main/en/api/models/flux_transformer#diffusers.FluxTransformer2DModel">FluxTransformer2DModel</a> forward method.',pe,b,k,ue,G,Ce="Sets the attention processor to use to compute attention.",oe,V,ne,L,j,re,E,se,P,le;return x=new Ue({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),v=new ce({props:{title:"FluxControlNetModel",local:"fluxcontrolnetmodel",headingTag:"h1"}}),w=new ce({props:{title:"Loading from the original format",local:"loading-from-the-original-format",headingTag:"h2"}}),T=new ke({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}}),F=new ce({props:{title:"FluxControlNetModel",local:"diffusers.FluxControlNetModel",headingTag:"h2"}}),Z=new de({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/main/src/diffusers/models/controlnets/controlnet_flux.py#L41"}}),U=new de({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/main/src/diffusers/models/controlnets/controlnet_flux.py#L213",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>
`}}),k=new de({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/controlnets/controlnet_flux.py#L147"}}),V=new ce({props:{title:"FluxControlNetOutput",local:"diffusers.models.controlnet_flux.FluxControlNetOutput",headingTag:"h2"}}),j=new de({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/main/src/diffusers/models/controlnet_flux.py#L25"}}),E=new Ve({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet_flux.md"}}),{c(){h=l("meta"),H=r(),X=l("p"),I=r(),d(x.$$.fragment),Q=r(),d(v.$$.fragment),S=r(),$=l("p"),$.textContent=ge,A=r(),C=l("p"),C.innerHTML=_e,q=r(),M=l("p"),M.textContent=be,O=r(),y=l("p"),y.innerHTML=xe,B=r(),d(w.$$.fragment),Y=r(),N=l("p"),N.innerHTML=ve,K=r(),d(T.$$.fragment),ee=r(),d(F.$$.fragment),te=r(),a=l("div"),d(Z.$$.fragment),me=r(),_=l("div"),d(U.$$.fragment),fe=r(),W=l("p"),W.innerHTML=$e,pe=r(),b=l("div"),d(k.$$.fragment),ue=r(),G=l("p"),G.textContent=Ce,oe=r(),d(V.$$.fragment),ne=r(),L=l("div"),d(j.$$.fragment),re=r(),d(E.$$.fragment),se=r(),P=l("p"),this.h()},l(e){const t=Ze("svelte-u9bgzb",document.head);h=i(t,"META",{name:!0,content:!0}),t.forEach(o),H=s(e),X=i(e,"P",{}),z(X).forEach(o),I=s(e),c(x.$$.fragment,e),Q=s(e),c(v.$$.fragment,e),S=s(e),$=i(e,"P",{"data-svelte-h":!0}),J($)!=="svelte-1iop38l"&&($.textContent=ge),A=s(e),C=i(e,"P",{"data-svelte-h":!0}),J(C)!=="svelte-1s65p96"&&(C.innerHTML=_e),q=s(e),M=i(e,"P",{"data-svelte-h":!0}),J(M)!=="svelte-1cwsb16"&&(M.textContent=be),O=s(e),y=i(e,"P",{"data-svelte-h":!0}),J(y)!=="svelte-fbiw6t"&&(y.innerHTML=xe),B=s(e),c(w.$$.fragment,e),Y=s(e),N=i(e,"P",{"data-svelte-h":!0}),J(N)!=="svelte-1jh70ee"&&(N.innerHTML=ve),K=s(e),c(T.$$.fragment,e),ee=s(e),c(F.$$.fragment,e),te=s(e),a=i(e,"DIV",{class:!0});var R=z(a);c(Z.$$.fragment,R),me=s(R),_=i(R,"DIV",{class:!0});var ie=z(_);c(U.$$.fragment,ie),fe=s(ie),W=i(ie,"P",{"data-svelte-h":!0}),J(W)!=="svelte-4l0nim"&&(W.innerHTML=$e),ie.forEach(o),pe=s(R),b=i(R,"DIV",{class:!0});var ae=z(b);c(k.$$.fragment,ae),ue=s(ae),G=i(ae,"P",{"data-svelte-h":!0}),J(G)!=="svelte-1o77hl2"&&(G.textContent=Ce),ae.forEach(o),R.forEach(o),oe=s(e),c(V.$$.fragment,e),ne=s(e),L=i(e,"DIV",{class:!0});var Me=z(L);c(j.$$.fragment,Me),Me.forEach(o),re=s(e),c(E.$$.fragment,e),se=s(e),P=i(e,"P",{}),z(P).forEach(o),this.h()},h(){D(h,"name","hf:doc:metadata"),D(h,"content",je),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(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){g(document.head,h),n(e,H,t),n(e,X,t),n(e,I,t),m(x,e,t),n(e,Q,t),m(v,e,t),n(e,S,t),n(e,$,t),n(e,A,t),n(e,C,t),n(e,q,t),n(e,M,t),n(e,O,t),n(e,y,t),n(e,B,t),m(w,e,t),n(e,Y,t),n(e,N,t),n(e,K,t),m(T,e,t),n(e,ee,t),m(F,e,t),n(e,te,t),n(e,a,t),m(Z,a,null),g(a,me),g(a,_),m(U,_,null),g(_,fe),g(_,W),g(a,pe),g(a,b),m(k,b,null),g(b,ue),g(b,G),n(e,oe,t),m(V,e,t),n(e,ne,t),n(e,L,t),m(j,L,null),n(e,re,t),m(E,e,t),n(e,se,t),n(e,P,t),le=!0},p:we,i(e){le||(f(x.$$.fragment,e),f(v.$$.fragment,e),f(w.$$.fragment,e),f(T.$$.fragment,e),f(F.$$.fragment,e),f(Z.$$.fragment,e),f(U.$$.fragment,e),f(k.$$.fragment,e),f(V.$$.fragment,e),f(j.$$.fragment,e),f(E.$$.fragment,e),le=!0)},o(e){p(x.$$.fragment,e),p(v.$$.fragment,e),p(w.$$.fragment,e),p(T.$$.fragment,e),p(F.$$.fragment,e),p(Z.$$.fragment,e),p(U.$$.fragment,e),p(k.$$.fragment,e),p(V.$$.fragment,e),p(j.$$.fragment,e),p(E.$$.fragment,e),le=!1},d(e){e&&(o(H),o(X),o(I),o(Q),o(S),o($),o(A),o(C),o(q),o(M),o(O),o(y),o(B),o(Y),o(N),o(K),o(ee),o(te),o(a),o(oe),o(ne),o(L),o(re),o(se),o(P)),o(h),u(x,e),u(v,e),u(w,e),u(T,e),u(F,e),u(Z),u(U),u(k),u(V,e),u(j),u(E,e)}}}const je='{"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 Ee(he){return Ne(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xe extends Te{constructor(h){super(),Fe(this,h,Ee,Le,ye,{})}}export{Xe as component};
