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