import{s as Ae,o as Qe,n as Xe}from"../chunks/scheduler.8c3d61f6.js";import{S as Be,i as Ye,g as d,s as n,r as p,A as Ke,h as l,f as o,c as r,j as y,u,x as b,k as M,y as a,a as s,v as h,d as g,t as _,w as $}from"../chunks/index.589a98e8.js";import{T as Oe}from"../chunks/Tip.42aa8582.js";import{D as B}from"../chunks/Docstring.27406313.js";import{C as et}from"../chunks/CodeBlock.36627b28.js";import{H as ye,E as tt}from"../chunks/EditOnGithub.e5a8d9cb.js";function ot(Y){let i,v="This API is 🧪 experimental.";return{c(){i=d("p"),i.textContent=v},l(c){i=l(c,"P",{"data-svelte-h":!0}),b(i)!=="svelte-89q1io"&&(i.textContent=v)},m(c,D){s(c,i,D)},p:Xe,d(c){c&&o(i)}}}function nt(Y){let i,v="This API is 🧪 experimental.";return{c(){i=d("p"),i.textContent=v},l(c){i=l(c,"P",{"data-svelte-h":!0}),b(i)!=="svelte-89q1io"&&(i.textContent=v)},m(c,D){s(c,i,D)},p:Xe,d(c){c&&o(i)}}}function rt(Y){let i,v,c,D,j,ae,Z,Ee="SD3ControlNetModel is an implementation of ControlNet for Stable Diffusion 3.",de,L,Re='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.',le,z,Ue="The abstract from the paper is:",ce,P,Ie="<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>",fe,E,me,R,Ve='By default the <a href="/docs/diffusers/main/en/api/models/controlnet_sd3#diffusers.SD3ControlNetModel">SD3ControlNetModel</a> should be loaded with <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.from_pretrained">from_pretrained()</a>.',pe,U,ue,I,he,f,V,Me,x,G,De,K,Ge=`Sets the attention processor to use <a href="https://huggingface.co/blog/reformer#2-chunked-feed-forward-layers" rel="nofollow">feed forward
chunking</a>.`,xe,N,F,Ne,ee,Fe='The <a href="/docs/diffusers/main/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> forward method.',Te,C,W,Se,te,We=`Enables fused QKV projections. For self-attention modules, all projection matrices (i.e., query, key, value)
are fused. For cross-attention modules, key and value projection matrices are fused.`,ke,T,je,S,q,Ze,oe,qe="Sets the attention processor to use to compute attention.",Le,w,H,ze,ne,He="Disables the fused QKV projection if enabled.",Pe,k,ge,J,_e,O,X,$e,A,be,ie,ve;return j=new ye({props:{title:"SD3ControlNetModel",local:"sd3controlnetmodel",headingTag:"h1"}}),E=new ye({props:{title:"Loading from the original format",local:"loading-from-the-original-format",headingTag:"h2"}}),U=new et({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbjNDb250cm9sTmV0UGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLm1vZGVscyUyMGltcG9ydCUyMFNEM0NvbnRyb2xOZXRNb2RlbCUyQyUyMFNEM011bHRpQ29udHJvbE5ldE1vZGVsJTBBJTBBY29udHJvbG5ldCUyMCUzRCUyMFNEM0NvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIySW5zdGFudFglMkZTRDMtQ29udHJvbG5ldC1DYW5ueSUyMiklMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uM0NvbnRyb2xOZXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTMtbWVkaXVtLWRpZmZ1c2VycyUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0KQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusion3ControlNetPipeline
<span class="hljs-keyword">from</span> diffusers.models <span class="hljs-keyword">import</span> SD3ControlNetModel, SD3MultiControlNetModel

controlnet = SD3ControlNetModel.from_pretrained(<span class="hljs-string">&quot;InstantX/SD3-Controlnet-Canny&quot;</span>)
pipe = StableDiffusion3ControlNetPipeline.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-3-medium-diffusers&quot;</span>, controlnet=controlnet)`,wrap:!1}}),I=new ye({props:{title:"SD3ControlNetModel",local:"diffusers.SD3ControlNetModel",headingTag:"h2"}}),V=new B({props:{name:"class diffusers.SD3ControlNetModel",anchor:"diffusers.SD3ControlNetModel",parameters:[{name:"sample_size",val:": int = 128"},{name:"patch_size",val:": int = 2"},{name:"in_channels",val:": int = 16"},{name:"num_layers",val:": int = 18"},{name:"attention_head_dim",val:": int = 64"},{name:"num_attention_heads",val:": int = 18"},{name:"joint_attention_dim",val:": int = 4096"},{name:"caption_projection_dim",val:": int = 1152"},{name:"pooled_projection_dim",val:": int = 2048"},{name:"out_channels",val:": int = 16"},{name:"pos_embed_max_size",val:": int = 96"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_sd3.py#L41"}}),G=new B({props:{name:"enable_forward_chunking",anchor:"diffusers.SD3ControlNetModel.enable_forward_chunking",parameters:[{name:"chunk_size",val:": Optional = None"},{name:"dim",val:": int = 0"}],parametersDescription:[{anchor:"diffusers.SD3ControlNetModel.enable_forward_chunking.chunk_size",description:`<strong>chunk_size</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The chunk size of the feed-forward layers. If not specified, will run feed-forward layer individually
over each tensor of dim=<code>dim</code>.`,name:"chunk_size"},{anchor:"diffusers.SD3ControlNetModel.enable_forward_chunking.dim",description:`<strong>dim</strong> (<code>int</code>, <em>optional</em>, defaults to <code>0</code>) &#x2014;
The dimension over which the feed-forward computation should be chunked. Choose between dim=0 (batch)
or dim=1 (sequence length).`,name:"dim"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_sd3.py#L110"}}),F=new B({props:{name:"forward",anchor:"diffusers.SD3ControlNetModel.forward",parameters:[{name:"hidden_states",val:": FloatTensor"},{name:"controlnet_cond",val:": Tensor"},{name:"conditioning_scale",val:": float = 1.0"},{name:"encoder_hidden_states",val:": FloatTensor = None"},{name:"pooled_projections",val:": FloatTensor = None"},{name:"timestep",val:": LongTensor = None"},{name:"joint_attention_kwargs",val:": Optional = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.SD3ControlNetModel.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.SD3ControlNetModel.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.SD3ControlNetModel.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.SD3ControlNetModel.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.SD3ControlNetModel.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.SD3ControlNetModel.forward.timestep",description:`<strong>timestep</strong> ( <code>torch.LongTensor</code>) &#x2014;
Used to indicate denoising step.`,name:"timestep"},{anchor:"diffusers.SD3ControlNetModel.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.SD3ControlNetModel.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_sd3.py#L259",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>
`}}),W=new B({props:{name:"fuse_qkv_projections",anchor:"diffusers.SD3ControlNetModel.fuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_sd3.py#L200"}}),T=new Oe({props:{warning:!0,$$slots:{default:[ot]},$$scope:{ctx:Y}}}),q=new B({props:{name:"set_attn_processor",anchor:"diffusers.SD3ControlNetModel.set_attn_processor",parameters:[{name:"processor",val:": Union"}],parametersDescription:[{anchor:"diffusers.SD3ControlNetModel.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_sd3.py#L165"}}),H=new B({props:{name:"unfuse_qkv_projections",anchor:"diffusers.SD3ControlNetModel.unfuse_qkv_projections",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_sd3.py#L226"}}),k=new Oe({props:{warning:!0,$$slots:{default:[nt]},$$scope:{ctx:Y}}}),J=new ye({props:{title:"SD3ControlNetOutput",local:"diffusers.models.controlnet_sd3.SD3ControlNetOutput",headingTag:"h2"}}),X=new B({props:{name:"class diffusers.models.controlnet_sd3.SD3ControlNetOutput",anchor:"diffusers.models.controlnet_sd3.SD3ControlNetOutput",parameters:[{name:"controlnet_block_samples",val:": Tuple"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/controlnet_sd3.py#L36"}}),A=new tt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/models/controlnet_sd3.md"}}),{c(){i=d("meta"),v=n(),c=d("p"),D=n(),p(j.$$.fragment),ae=n(),Z=d("p"),Z.textContent=Ee,de=n(),L=d("p"),L.innerHTML=Re,le=n(),z=d("p"),z.textContent=Ue,ce=n(),P=d("p"),P.innerHTML=Ie,fe=n(),p(E.$$.fragment),me=n(),R=d("p"),R.innerHTML=Ve,pe=n(),p(U.$$.fragment),ue=n(),p(I.$$.fragment),he=n(),f=d("div"),p(V.$$.fragment),Me=n(),x=d("div"),p(G.$$.fragment),De=n(),K=d("p"),K.innerHTML=Ge,xe=n(),N=d("div"),p(F.$$.fragment),Ne=n(),ee=d("p"),ee.innerHTML=Fe,Te=n(),C=d("div"),p(W.$$.fragment),Se=n(),te=d("p"),te.textContent=We,ke=n(),p(T.$$.fragment),je=n(),S=d("div"),p(q.$$.fragment),Ze=n(),oe=d("p"),oe.textContent=qe,Le=n(),w=d("div"),p(H.$$.fragment),ze=n(),ne=d("p"),ne.textContent=He,Pe=n(),p(k.$$.fragment),ge=n(),p(J.$$.fragment),_e=n(),O=d("div"),p(X.$$.fragment),$e=n(),p(A.$$.fragment),be=n(),ie=d("p"),this.h()},l(e){const t=Ke("svelte-u9bgzb",document.head);i=l(t,"META",{name:!0,content:!0}),t.forEach(o),v=r(e),c=l(e,"P",{}),y(c).forEach(o),D=r(e),u(j.$$.fragment,e),ae=r(e),Z=l(e,"P",{"data-svelte-h":!0}),b(Z)!=="svelte-plv1v9"&&(Z.textContent=Ee),de=r(e),L=l(e,"P",{"data-svelte-h":!0}),b(L)!=="svelte-1s65p96"&&(L.innerHTML=Re),le=r(e),z=l(e,"P",{"data-svelte-h":!0}),b(z)!=="svelte-1cwsb16"&&(z.textContent=Ue),ce=r(e),P=l(e,"P",{"data-svelte-h":!0}),b(P)!=="svelte-fbiw6t"&&(P.innerHTML=Ie),fe=r(e),u(E.$$.fragment,e),me=r(e),R=l(e,"P",{"data-svelte-h":!0}),b(R)!=="svelte-i9x6qn"&&(R.innerHTML=Ve),pe=r(e),u(U.$$.fragment,e),ue=r(e),u(I.$$.fragment,e),he=r(e),f=l(e,"DIV",{class:!0});var m=y(f);u(V.$$.fragment,m),Me=r(m),x=l(m,"DIV",{class:!0});var Q=y(x);u(G.$$.fragment,Q),De=r(Q),K=l(Q,"P",{"data-svelte-h":!0}),b(K)!=="svelte-2m23sy"&&(K.innerHTML=Ge),Q.forEach(o),xe=r(m),N=l(m,"DIV",{class:!0});var Ce=y(N);u(F.$$.fragment,Ce),Ne=r(Ce),ee=l(Ce,"P",{"data-svelte-h":!0}),b(ee)!=="svelte-1fdt9lr"&&(ee.innerHTML=Fe),Ce.forEach(o),Te=r(m),C=l(m,"DIV",{class:!0});var re=y(C);u(W.$$.fragment,re),Se=r(re),te=l(re,"P",{"data-svelte-h":!0}),b(te)!=="svelte-1254b9i"&&(te.textContent=We),ke=r(re),u(T.$$.fragment,re),re.forEach(o),je=r(m),S=l(m,"DIV",{class:!0});var we=y(S);u(q.$$.fragment,we),Ze=r(we),oe=l(we,"P",{"data-svelte-h":!0}),b(oe)!=="svelte-1o77hl2"&&(oe.textContent=qe),we.forEach(o),Le=r(m),w=l(m,"DIV",{class:!0});var se=y(w);u(H.$$.fragment,se),ze=r(se),ne=l(se,"P",{"data-svelte-h":!0}),b(ne)!=="svelte-1vhtc74"&&(ne.textContent=He),Pe=r(se),u(k.$$.fragment,se),se.forEach(o),m.forEach(o),ge=r(e),u(J.$$.fragment,e),_e=r(e),O=l(e,"DIV",{class:!0});var Je=y(O);u(X.$$.fragment,Je),Je.forEach(o),$e=r(e),u(A.$$.fragment,e),be=r(e),ie=l(e,"P",{}),y(ie).forEach(o),this.h()},h(){M(i,"name","hf:doc:metadata"),M(i,"content",st),M(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),M(O,"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){a(document.head,i),s(e,v,t),s(e,c,t),s(e,D,t),h(j,e,t),s(e,ae,t),s(e,Z,t),s(e,de,t),s(e,L,t),s(e,le,t),s(e,z,t),s(e,ce,t),s(e,P,t),s(e,fe,t),h(E,e,t),s(e,me,t),s(e,R,t),s(e,pe,t),h(U,e,t),s(e,ue,t),h(I,e,t),s(e,he,t),s(e,f,t),h(V,f,null),a(f,Me),a(f,x),h(G,x,null),a(x,De),a(x,K),a(f,xe),a(f,N),h(F,N,null),a(N,Ne),a(N,ee),a(f,Te),a(f,C),h(W,C,null),a(C,Se),a(C,te),a(C,ke),h(T,C,null),a(f,je),a(f,S),h(q,S,null),a(S,Ze),a(S,oe),a(f,Le),a(f,w),h(H,w,null),a(w,ze),a(w,ne),a(w,Pe),h(k,w,null),s(e,ge,t),h(J,e,t),s(e,_e,t),s(e,O,t),h(X,O,null),s(e,$e,t),h(A,e,t),s(e,be,t),s(e,ie,t),ve=!0},p(e,[t]){const m={};t&2&&(m.$$scope={dirty:t,ctx:e}),T.$set(m);const Q={};t&2&&(Q.$$scope={dirty:t,ctx:e}),k.$set(Q)},i(e){ve||(g(j.$$.fragment,e),g(E.$$.fragment,e),g(U.$$.fragment,e),g(I.$$.fragment,e),g(V.$$.fragment,e),g(G.$$.fragment,e),g(F.$$.fragment,e),g(W.$$.fragment,e),g(T.$$.fragment,e),g(q.$$.fragment,e),g(H.$$.fragment,e),g(k.$$.fragment,e),g(J.$$.fragment,e),g(X.$$.fragment,e),g(A.$$.fragment,e),ve=!0)},o(e){_(j.$$.fragment,e),_(E.$$.fragment,e),_(U.$$.fragment,e),_(I.$$.fragment,e),_(V.$$.fragment,e),_(G.$$.fragment,e),_(F.$$.fragment,e),_(W.$$.fragment,e),_(T.$$.fragment,e),_(q.$$.fragment,e),_(H.$$.fragment,e),_(k.$$.fragment,e),_(J.$$.fragment,e),_(X.$$.fragment,e),_(A.$$.fragment,e),ve=!1},d(e){e&&(o(v),o(c),o(D),o(ae),o(Z),o(de),o(L),o(le),o(z),o(ce),o(P),o(fe),o(me),o(R),o(pe),o(ue),o(he),o(f),o(ge),o(_e),o(O),o($e),o(be),o(ie)),o(i),$(j,e),$(E,e),$(U,e),$(I,e),$(V),$(G),$(F),$(W),$(T),$(q),$(H),$(k),$(J,e),$(X),$(A,e)}}}const st='{"title":"SD3ControlNetModel","local":"sd3controlnetmodel","sections":[{"title":"Loading from the original format","local":"loading-from-the-original-format","sections":[],"depth":2},{"title":"SD3ControlNetModel","local":"diffusers.SD3ControlNetModel","sections":[],"depth":2},{"title":"SD3ControlNetOutput","local":"diffusers.models.controlnet_sd3.SD3ControlNetOutput","sections":[],"depth":2}],"depth":1}';function it(Y){return Qe(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pt extends Be{constructor(i){super(),Ye(this,i,it,rt,Ae,{})}}export{pt as component};
