Buckets:
hf-doc-build/doc / diffusers /main /en /_app /pages /using-diffusers /controlnet.mdx-hf-doc-builder.js
| import{S as Lp,i as Pp,s as qp,e as a,k as c,w as h,t as r,M as Kp,c as s,d as l,m as d,a as o,x as y,h as p,b as m,N as _,G as t,g as i,y as M,q as g,o as b,B as J,v as Op}from"../../chunks/vendor-hf-doc-builder.js";import{T as Tn}from"../../chunks/Tip-hf-doc-builder.js";import{I as Cl}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as v}from"../../chunks/CodeBlock-hf-doc-builder.js";function em(F){let f,T,u,w,C,U,Z,j,G,V,$,de,N,k,B,x,Ce,X,R,Y;return{c(){f=a("p"),T=r("Check out Section 3.5 of the "),u=a("a"),w=r("ControlNet"),C=r(" paper for a list of ControlNet implementations on various conditioning inputs. You can find the official Stable Diffusion ControlNet conditioned models on "),U=a("a"),Z=r("lllyasviel"),j=r("\u2019s Hub profile, and more "),G=a("a"),V=r("community-trained"),$=r(" ones on the Hub."),de=c(),N=a("p"),k=r("For Stable Diffusion XL (SDXL) ControlNet models, you can find them on the \u{1F917} "),B=a("a"),x=r("Diffusers"),Ce=r(" Hub organization, or you can browse "),X=a("a"),R=r("community-trained"),Y=r(" ones on the Hub."),this.h()},l(I){f=s(I,"P",{});var W=o(f);T=p(W,"Check out Section 3.5 of the "),u=s(W,"A",{href:!0,rel:!0});var Nl=o(u);w=p(Nl,"ControlNet"),Nl.forEach(l),C=p(W," paper for a list of ControlNet implementations on various conditioning inputs. You can find the official Stable Diffusion ControlNet conditioned models on "),U=s(W,"A",{href:!0,rel:!0});var Il=o(U);Z=p(Il,"lllyasviel"),Il.forEach(l),j=p(W,"\u2019s Hub profile, and more "),G=s(W,"A",{href:!0,rel:!0});var Gl=o(G);V=p(Gl,"community-trained"),Gl.forEach(l),$=p(W," ones on the Hub."),W.forEach(l),de=d(I),N=s(I,"P",{});var E=o(N);k=p(E,"For Stable Diffusion XL (SDXL) ControlNet models, you can find them on the \u{1F917} "),B=s(E,"A",{href:!0,rel:!0});var El=o(B);x=p(El,"Diffusers"),El.forEach(l),Ce=p(E," Hub organization, or you can browse "),X=s(E,"A",{href:!0,rel:!0});var fe=o(X);R=p(fe,"community-trained"),fe.forEach(l),Y=p(E," ones on the Hub."),E.forEach(l),this.h()},h(){m(u,"href","https://huggingface.co/papers/2302.05543"),m(u,"rel","nofollow"),m(U,"href","https://huggingface.co/lllyasviel"),m(U,"rel","nofollow"),m(G,"href","https://huggingface.co/models?other=stable-diffusion&other=controlnet"),m(G,"rel","nofollow"),m(B,"href","https://huggingface.co/diffusers"),m(B,"rel","nofollow"),m(X,"href","https://huggingface.co/models?other=stable-diffusion-xl&other=controlnet"),m(X,"rel","nofollow")},m(I,W){i(I,f,W),t(f,T),t(f,u),t(u,w),t(f,C),t(f,U),t(U,Z),t(f,j),t(f,G),t(G,V),t(f,$),i(I,de,W),i(I,N,W),t(N,k),t(N,B),t(B,x),t(N,Ce),t(N,X),t(X,R),t(N,Y)},d(I){I&&l(f),I&&l(de),I&&l(N)}}}function lm(F){let f,T;return{c(){f=a("p"),T=r("Guess mode does not have any impact on prompt conditioning and you can still provide a prompt if you want.")},l(u){f=s(u,"P",{});var w=o(f);T=p(w,"Guess mode does not have any impact on prompt conditioning and you can still provide a prompt if you want."),w.forEach(l)},m(u,w){i(u,f,w),t(f,T)},d(u){u&&l(f)}}}function tm(F){let f,T,u,w,C,U;return{c(){f=a("p"),T=r("The "),u=a("a"),w=a("code"),C=r("controlnet_conditioning_scale"),U=r(" parameter determines how much weight to assign to the conditioning inputs. A value of 0.5 is recommended for good generalization, but feel free to experiment with this number!"),this.h()},l(Z){f=s(Z,"P",{});var j=o(f);T=p(j,"The "),u=s(j,"A",{href:!0,rel:!0});var G=o(u);w=s(G,"CODE",{});var V=o(w);C=p(V,"controlnet_conditioning_scale"),V.forEach(l),G.forEach(l),U=p(j," parameter determines how much weight to assign to the conditioning inputs. A value of 0.5 is recommended for good generalization, but feel free to experiment with this number!"),j.forEach(l),this.h()},h(){m(u,"href","https://huggingface.co/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetPipeline.__call__.controlnet_conditioning_scale"),m(u,"rel","nofollow")},m(Z,j){i(Z,f,j),t(f,T),t(f,u),t(u,w),t(w,C),t(f,U)},d(Z){Z&&l(f)}}}function am(F){let f,T,u,w,C;return{c(){f=a("p"),T=r("Replace the SDXL model with a model like "),u=a("a"),w=r("runwayml/stable-diffusion-v1-5"),C=r(" to use multiple conditioning inputs with Stable Diffusion models."),this.h()},l(U){f=s(U,"P",{});var Z=o(f);T=p(Z,"Replace the SDXL model with a model like "),u=s(Z,"A",{href:!0,rel:!0});var j=o(u);w=p(j,"runwayml/stable-diffusion-v1-5"),j.forEach(l),C=p(Z," to use multiple conditioning inputs with Stable Diffusion models."),Z.forEach(l),this.h()},h(){m(u,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),m(u,"rel","nofollow")},m(U,Z){i(U,f,Z),t(f,T),t(f,u),t(u,w),t(f,C)},d(U){U&&l(f)}}}function sm(F){let f,T,u,w,C,U,Z,j,G,V,$,de,N,k,B,x,Ce,X,R,Y,I,W,Nl,Il,Gl,E,El,fe,Zn,vn,wa,kl,jn,Ua,Bl,Wn,Ta,Xl,_n,Za,Ne,va,O,ue,Dt,Ie,Cn,Ht,Nn,ja,Rl,In,Wa,he,Gn,Ge,En,kn,_a,Ee,Ca,ee,ke,Sl,er,Bn,Vl,Xn,Rn,Be,Yl,lr,Sn,Fl,Vn,Na,Q,Yn,$l,Fn,$n,xl,xn,Qn,Ia,Xe,Ga,Ql,zn,Ea,Re,ka,Se,Lt,tr,Ba,le,ye,Pt,Ve,An,qt,Dn,Xa,zl,Hn,Ra,z,Ln,Al,Pn,qn,Dl,Kn,On,Sa,A,eo,Kt,lo,to,Ye,ao,so,Va,Fe,Ya,D,no,Hl,oo,io,Ll,ro,po,Fa,$e,$a,Pl,mo,xa,xe,Qa,te,Qe,ql,ar,co,Kl,fo,uo,ze,Ol,sr,ho,et,yo,za,ae,Me,Ot,Ae,Mo,ea,go,Aa,lt,bo,Da,tt,Jo,Ha,De,La,H,wo,la,Uo,To,ta,Zo,vo,Pa,He,qa,se,Le,at,nr,jo,st,Wo,_o,Pe,nt,or,Co,ot,No,Ka,L,Io,it,Go,Eo,rt,ko,Bo,Oa,qe,es,pt,Xo,ls,Ke,ts,Oe,aa,ir,as,ne,ge,sa,el,Ro,na,So,ss,ll,tl,Vo,Yo,ns,P,Fo,oa,$o,xo,ia,Qo,zo,os,be,is,S,Ao,ra,Do,Ho,al,Lo,Po,pa,qo,Ko,rs,sl,ps,oe,nl,mt,rr,Oo,ct,ei,li,ol,dt,pr,ti,ft,ai,ms,ie,Je,ma,il,si,ca,ni,cs,we,oi,rl,ii,ri,ds,ut,pi,fs,pl,us,re,ml,ht,mr,mi,yt,ci,di,cl,Mt,cr,fi,gt,ui,hs,Ue,hi,bt,yi,Mi,ys,dl,Ms,Jt,gi,gs,Te,bs,fl,Js,ul,wt,dr,ws,q,bi,Ut,Ji,wi,da,Ui,Ti,Us,hl,Ts,pe,Ze,fa,yl,Zi,ua,vi,Zs,ve,vs,je,ji,ha,Wi,_i,js,We,ya,Ci,Ni,Ml,Ii,gl,Ma,Gi,Ei,Ws,Tt,ki,_s,Zt,Bi,Cs,bl,Ns,me,Jl,vt,fr,Xi,jt,Ri,Si,wl,Wt,ur,Vi,_t,Yi,Is,Ct,Fi,Gs,Ul,Es,ce,Tl,Nt,hr,$i,It,xi,Qi,Zl,Gt,yr,zi,Et,Ai,ks,K,Di,kt,Hi,Li,Bt,Pi,qi,Bs,vl,Xs,Xt,Ki,Rs,jl,Ss,Wl,Rt,Mr,Vs;return U=new Cl({}),k=new Tn({props:{$$slots:{default:[em]},$$scope:{ctx:F}}}),Ne=new v({props:{code:"JTIzJTIwdW5jb21tZW50JTIwdG8lMjBpbnN0YWxsJTIwdGhlJTIwbmVjZXNzYXJ5JTIwbGlicmFyaWVzJTIwaW4lMjBDb2xhYiUwQSUyMyFwaXAlMjBpbnN0YWxsJTIwZGlmZnVzZXJzJTIwdHJhbnNmb3JtZXJzJTIwYWNjZWxlcmF0ZSUyMHNhZmV0ZW5zb3JzJTIwb3BlbmN2LXB5dGhvbg==",highlighted:`<span class="hljs-comment"># uncomment to install the necessary libraries in Colab</span> | |
| <span class="hljs-comment">#!pip install diffusers transformers accelerate safetensors opencv-python</span>`}}),Ie=new Cl({}),Ee=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRQaXBlbGluZSUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwY3YyJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaGYuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmlucHV0X2ltYWdlX3Zlcm1lZXIucG5nJTIyJTBBKSUwQSUwQWltYWdlJTIwJTNEJTIwbnAuYXJyYXkoaW1hZ2UpJTBBJTBBbG93X3RocmVzaG9sZCUyMCUzRCUyMDEwMCUwQWhpZ2hfdGhyZXNob2xkJTIwJTNEJTIwMjAwJTBBJTBBaW1hZ2UlMjAlM0QlMjBjdjIuQ2FubnkoaW1hZ2UlMkMlMjBsb3dfdGhyZXNob2xkJTJDJTIwaGlnaF90aHJlc2hvbGQpJTBBaW1hZ2UlMjAlM0QlMjBpbWFnZSU1QiUzQSUyQyUyMCUzQSUyQyUyME5vbmUlNUQlMEFpbWFnZSUyMCUzRCUyMG5wLmNvbmNhdGVuYXRlKCU1QmltYWdlJTJDJTIwaW1hZ2UlMkMlMjBpbWFnZSU1RCUyQyUyMGF4aXMlM0QyKSUwQWNhbm55X2ltYWdlJTIwJTNEJTIwSW1hZ2UuZnJvbWFycmF5KGltYWdlKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline | |
| <span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-keyword">import</span> cv2 | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| image = load_image( | |
| <span class="hljs-string">"https://hf.co/datasets/huggingface/documentation-images/resolve/main/diffusers/input_image_vermeer.png"</span> | |
| ) | |
| image = np.array(image) | |
| low_threshold = <span class="hljs-number">100</span> | |
| high_threshold = <span class="hljs-number">200</span> | |
| image = cv2.Canny(image, low_threshold, high_threshold) | |
| image = image[:, :, <span class="hljs-literal">None</span>] | |
| image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>) | |
| canny_image = Image.fromarray(image)`}}),Xe=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRQaXBlbGluZSUyQyUyMENvbnRyb2xOZXRNb2RlbCUyQyUyMFVuaVBDTXVsdGlzdGVwU2NoZWR1bGVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEFjb250cm9sbmV0JTIwJTNEJTIwQ29udHJvbE5ldE1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJsbGx5YXN2aWVsJTJGc2QtY29udHJvbG5ldC1jYW5ueSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjBjb250cm9sbmV0JTNEY29udHJvbG5ldCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBVbmlQQ011bHRpc3RlcFNjaGVkdWxlci5mcm9tX2NvbmZpZyhwaXBlLnNjaGVkdWxlci5jb25maWcpJTBBcGlwZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| controlnet = ControlNetModel.from_pretrained(<span class="hljs-string">"lllyasviel/sd-controlnet-canny"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionControlNetPipeline.from_pretrained( | |
| <span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span>, controlnet=controlnet, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload()`}}),Re=new v({props:{code:"b3V0cHV0JTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjJ0aGUlMjBtb25hJTIwbGlzYSUyMiUyQyUyMGltYWdlJTNEY2FubnlfaW1hZ2UlMEEpLmltYWdlcyU1QjAlNUQ=",highlighted:`output = pipe( | |
| <span class="hljs-string">"the mona lisa"</span>, image=canny_image | |
| ).images[<span class="hljs-number">0</span>]`}}),Ve=new Cl({}),Fe=new v({props:{code:"aW1wb3J0JTIwdG9yY2glMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMEElMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwcGlwZWxpbmUlMEFmcm9tJTIwZGlmZnVzZXJzLnV0aWxzJTIwaW1wb3J0JTIwbG9hZF9pbWFnZSUwQSUwQWltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZjb250cm9sbmV0LWltZzJpbWcuanBnJTIyJTBBKS5yZXNpemUoKDc2OCUyQyUyMDc2OCkpJTBBJTBBJTBBZGVmJTIwZ2V0X2RlcHRoX21hcChpbWFnZSUyQyUyMGRlcHRoX2VzdGltYXRvciklM0ElMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMGRlcHRoX2VzdGltYXRvcihpbWFnZSklNUIlMjJkZXB0aCUyMiU1RCUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwbnAuYXJyYXkoaW1hZ2UpJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBpbWFnZSU1QiUzQSUyQyUyMCUzQSUyQyUyME5vbmUlNUQlMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMG5wLmNvbmNhdGVuYXRlKCU1QmltYWdlJTJDJTIwaW1hZ2UlMkMlMjBpbWFnZSU1RCUyQyUyMGF4aXMlM0QyKSUwQSUyMCUyMCUyMCUyMGRldGVjdGVkX21hcCUyMCUzRCUyMHRvcmNoLmZyb21fbnVtcHkoaW1hZ2UpLmZsb2F0KCklMjAlMkYlMjAyNTUuMCUwQSUyMCUyMCUyMCUyMGRlcHRoX21hcCUyMCUzRCUyMGRldGVjdGVkX21hcC5wZXJtdXRlKDIlMkMlMjAwJTJDJTIwMSklMEElMjAlMjAlMjAlMjByZXR1cm4lMjBkZXB0aF9tYXAlMEElMEFkZXB0aF9lc3RpbWF0b3IlMjAlM0QlMjBwaXBlbGluZSglMjJkZXB0aC1lc3RpbWF0aW9uJTIyKSUwQWRlcHRoX21hcCUyMCUzRCUyMGdldF9kZXB0aF9tYXAoaW1hZ2UlMkMlMjBkZXB0aF9lc3RpbWF0b3IpLnVuc3F1ZWV6ZSgwKS5oYWxmKCkudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| <span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> pipeline | |
| <span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| image = load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-img2img.jpg"</span> | |
| ).resize((<span class="hljs-number">768</span>, <span class="hljs-number">768</span>)) | |
| <span class="hljs-keyword">def</span> <span class="hljs-title function_">get_depth_map</span>(<span class="hljs-params">image, depth_estimator</span>): | |
| image = depth_estimator(image)[<span class="hljs-string">"depth"</span>] | |
| image = np.array(image) | |
| image = image[:, :, <span class="hljs-literal">None</span>] | |
| image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>) | |
| detected_map = torch.from_numpy(image).<span class="hljs-built_in">float</span>() / <span class="hljs-number">255.0</span> | |
| depth_map = detected_map.permute(<span class="hljs-number">2</span>, <span class="hljs-number">0</span>, <span class="hljs-number">1</span>) | |
| <span class="hljs-keyword">return</span> depth_map | |
| depth_estimator = pipeline(<span class="hljs-string">"depth-estimation"</span>) | |
| depth_map = get_depth_map(image, depth_estimator).unsqueeze(<span class="hljs-number">0</span>).half().to(<span class="hljs-string">"cuda"</span>)`}}),$e=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRJbWcySW1nUGlwZWxpbmUlMkMlMjBDb250cm9sTmV0TW9kZWwlMkMlMjBVbmlQQ011bHRpc3RlcFNjaGVkdWxlciUwQWltcG9ydCUyMHRvcmNoJTBBJTBBY29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIybGxseWFzdmllbCUyRmNvbnRyb2xfdjExZjFwX3NkMTVfZGVwdGglMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25Db250cm9sTmV0SW1nMkltZ1BpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0JTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlLnNjaGVkdWxlciUyMCUzRCUyMFVuaVBDTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetImg2ImgPipeline, ControlNetModel, UniPCMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| controlnet = ControlNetModel.from_pretrained(<span class="hljs-string">"lllyasviel/control_v11f1p_sd15_depth"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionControlNetImg2ImgPipeline.from_pretrained( | |
| <span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span>, controlnet=controlnet, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload()`}}),xe=new v({props:{code:"b3V0cHV0JTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjJsZWdvJTIwYmF0bWFuJTIwYW5kJTIwcm9iaW4lMjIlMkMlMjBpbWFnZSUzRGltYWdlJTJDJTIwY29udHJvbF9pbWFnZSUzRGRlcHRoX21hcCUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`output = pipe( | |
| <span class="hljs-string">"lego batman and robin"</span>, image=image, control_image=depth_map, | |
| ).images[<span class="hljs-number">0</span>]`}}),Ae=new Cl({}),De=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRJbnBhaW50UGlwZWxpbmUlMkMlMjBDb250cm9sTmV0TW9kZWwlMkMlMjBVbmlQQ011bHRpc3RlcFNjaGVkdWxlciUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEElMEFpbml0X2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZjb250cm9sbmV0LWlucGFpbnQuanBnJTIyJTBBKSUwQWluaXRfaW1hZ2UlMjAlM0QlMjBpbml0X2ltYWdlLnJlc2l6ZSgoNTEyJTJDJTIwNTEyKSklMEElMEFtYXNrX2ltYWdlJTIwJTNEJTIwbG9hZF9pbWFnZSglMEElMjAlMjAlMjAlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZodWdnaW5nZmFjZSUyRmRvY3VtZW50YXRpb24taW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZkaWZmdXNlcnMlMkZjb250cm9sbmV0LWlucGFpbnQtbWFzay5qcGclMjIlMEEpJTBBbWFza19pbWFnZSUyMCUzRCUyMG1hc2tfaW1hZ2UucmVzaXplKCg1MTIlMkMlMjA1MTIpKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetInpaintPipeline, ControlNetModel, UniPCMultistepScheduler | |
| <span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| <span class="hljs-keyword">import</span> torch | |
| init_image = load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-inpaint.jpg"</span> | |
| ) | |
| init_image = init_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>)) | |
| mask_image = load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-inpaint-mask.jpg"</span> | |
| ) | |
| mask_image = mask_image.resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))`}}),He=new v({props:{code:"ZGVmJTIwbWFrZV9pbnBhaW50X2NvbmRpdGlvbihpbWFnZSUyQyUyMGltYWdlX21hc2spJTNBJTBBJTIwJTIwJTIwJTIwaW1hZ2UlMjAlM0QlMjBucC5hcnJheShpbWFnZS5jb252ZXJ0KCUyMlJHQiUyMikpLmFzdHlwZShucC5mbG9hdDMyKSUyMCUyRiUyMDI1NS4wJTBBJTIwJTIwJTIwJTIwaW1hZ2VfbWFzayUyMCUzRCUyMG5wLmFycmF5KGltYWdlX21hc2suY29udmVydCglMjJMJTIyKSkuYXN0eXBlKG5wLmZsb2F0MzIpJTIwJTJGJTIwMjU1LjAlMEElMEElMjAlMjAlMjAlMjBhc3NlcnQlMjBpbWFnZS5zaGFwZSU1QjAlM0ExJTVEJTIwJTNEJTNEJTIwaW1hZ2VfbWFzay5zaGFwZSU1QjAlM0ExJTVEJTBBJTIwJTIwJTIwJTIwaW1hZ2UlNUJpbWFnZV9tYXNrJTIwJTNFJTIwMC41JTVEJTIwJTNEJTIwMS4wJTIwJTIwJTIzJTIwc2V0JTIwYXMlMjBtYXNrZWQlMjBwaXhlbCUwQSUyMCUyMCUyMCUyMGltYWdlJTIwJTNEJTIwbnAuZXhwYW5kX2RpbXMoaW1hZ2UlMkMlMjAwKS50cmFuc3Bvc2UoMCUyQyUyMDMlMkMlMjAxJTJDJTIwMiklMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMHRvcmNoLmZyb21fbnVtcHkoaW1hZ2UpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwaW1hZ2UlMEElMEFjb250cm9sX2ltYWdlJTIwJTNEJTIwbWFrZV9pbnBhaW50X2NvbmRpdGlvbihpbml0X2ltYWdlJTJDJTIwbWFza19pbWFnZSk=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">make_inpaint_condition</span>(<span class="hljs-params">image, image_mask</span>): | |
| image = np.array(image.convert(<span class="hljs-string">"RGB"</span>)).astype(np.float32) / <span class="hljs-number">255.0</span> | |
| image_mask = np.array(image_mask.convert(<span class="hljs-string">"L"</span>)).astype(np.float32) / <span class="hljs-number">255.0</span> | |
| <span class="hljs-keyword">assert</span> image.shape[<span class="hljs-number">0</span>:<span class="hljs-number">1</span>] == image_mask.shape[<span class="hljs-number">0</span>:<span class="hljs-number">1</span>] | |
| image[image_mask > <span class="hljs-number">0.5</span>] = <span class="hljs-number">1.0</span> <span class="hljs-comment"># set as masked pixel</span> | |
| image = np.expand_dims(image, <span class="hljs-number">0</span>).transpose(<span class="hljs-number">0</span>, <span class="hljs-number">3</span>, <span class="hljs-number">1</span>, <span class="hljs-number">2</span>) | |
| image = torch.from_numpy(image) | |
| <span class="hljs-keyword">return</span> image | |
| control_image = make_inpaint_condition(init_image, mask_image)`}}),qe=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRJbnBhaW50UGlwZWxpbmUlMkMlMjBDb250cm9sTmV0TW9kZWwlMkMlMjBVbmlQQ011bHRpc3RlcFNjaGVkdWxlciUwQWltcG9ydCUyMHRvcmNoJTBBJTBBY29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIybGxseWFzdmllbCUyRmNvbnRyb2xfdjExcF9zZDE1X2lucGFpbnQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25Db250cm9sTmV0SW5wYWludFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0JTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlLnNjaGVkdWxlciUyMCUzRCUyMFVuaVBDTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyklMEFwaXBlLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetInpaintPipeline, ControlNetModel, UniPCMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| controlnet = ControlNetModel.from_pretrained(<span class="hljs-string">"lllyasviel/control_v11p_sd15_inpaint"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionControlNetInpaintPipeline.from_pretrained( | |
| <span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span>, controlnet=controlnet, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload()`}}),Ke=new v({props:{code:"b3V0cHV0JTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjJjb3JnaSUyMGZhY2UlMjB3aXRoJTIwbGFyZ2UlMjBlYXJzJTJDJTIwZGV0YWlsZWQlMkMlMjBwaXhhciUyQyUyMGFuaW1hdGVkJTJDJTIwZGlzbmV5JTIyJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwJTJDJTBBJTIwJTIwJTIwJTIwZXRhJTNEMS4wJTJDJTBBJTIwJTIwJTIwJTIwaW1hZ2UlM0Rpbml0X2ltYWdlJTJDJTBBJTIwJTIwJTIwJTIwbWFza19pbWFnZSUzRG1hc2tfaW1hZ2UlMkMlMEElMjAlMjAlMjAlMjBjb250cm9sX2ltYWdlJTNEY29udHJvbF9pbWFnZSUyQyUwQSkuaW1hZ2VzJTVCMCU1RA==",highlighted:`output = pipe( | |
| <span class="hljs-string">"corgi face with large ears, detailed, pixar, animated, disney"</span>, | |
| num_inference_steps=<span class="hljs-number">20</span>, | |
| eta=<span class="hljs-number">1.0</span>, | |
| image=init_image, | |
| mask_image=mask_image, | |
| control_image=control_image, | |
| ).images[<span class="hljs-number">0</span>]`}}),el=new Cl({}),be=new Tn({props:{$$slots:{default:[lm]},$$scope:{ctx:F}}}),sl=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkNvbnRyb2xOZXRQaXBlbGluZSUyQyUyMENvbnRyb2xOZXRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBY29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIybGxseWFzdmllbCUyRnNkLWNvbnRyb2xuZXQtY2FubnklMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25Db250cm9sTmV0UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTIwY29udHJvbG5ldCUzRGNvbnRyb2xuZXQlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKS50byglMEElMjAlMjAlMjAlMjAlMjJjdWRhJTIyJTBBKSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMjIlMjIlMkMlMjBpbWFnZSUzRGNhbm55X2ltYWdlJTJDJTIwZ3Vlc3NfbW9kZSUzRFRydWUlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDMuMCkuaW1hZ2VzJTVCMCU1RCUwQWltYWdl",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline, ControlNetModel | |
| <span class="hljs-keyword">import</span> torch | |
| controlnet = ControlNetModel.from_pretrained(<span class="hljs-string">"lllyasviel/sd-controlnet-canny"</span>, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionControlNetPipeline.from_pretrained(<span class="hljs-string">"runwayml/stable-diffusion-v1-5"</span>, controlnet=controlnet, use_safetensors=<span class="hljs-literal">True</span>).to( | |
| <span class="hljs-string">"cuda"</span> | |
| ) | |
| image = pipe(<span class="hljs-string">""</span>, image=canny_image, guess_mode=<span class="hljs-literal">True</span>, guidance_scale=<span class="hljs-number">3.0</span>).images[<span class="hljs-number">0</span>] | |
| image`}}),il=new Cl({}),pl=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMQ29udHJvbE5ldFBpcGVsaW5lJTJDJTIwQ29udHJvbE5ldE1vZGVsJTJDJTIwQXV0b2VuY29kZXJLTCUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBZnJvbSUyMFBJTCUyMGltcG9ydCUyMEltYWdlJTBBaW1wb3J0JTIwY3YyJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBJTBBaW1hZ2UlMjAlM0QlMjBsb2FkX2ltYWdlKCUwQSUyMCUyMCUyMCUyMCUyMmh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmhmLWludGVybmFsLXRlc3RpbmclMkZkaWZmdXNlcnMtaW1hZ2VzJTJGcmVzb2x2ZSUyRm1haW4lMkZzZF9jb250cm9sbmV0JTJGaGYtbG9nby5wbmclMjIlMEEpJTBBJTBBaW1hZ2UlMjAlM0QlMjBucC5hcnJheShpbWFnZSklMEElMEFsb3dfdGhyZXNob2xkJTIwJTNEJTIwMTAwJTBBaGlnaF90aHJlc2hvbGQlMjAlM0QlMjAyMDAlMEElMEFpbWFnZSUyMCUzRCUyMGN2Mi5DYW5ueShpbWFnZSUyQyUyMGxvd190aHJlc2hvbGQlMkMlMjBoaWdoX3RocmVzaG9sZCklMEFpbWFnZSUyMCUzRCUyMGltYWdlJTVCJTNBJTJDJTIwJTNBJTJDJTIwTm9uZSU1RCUwQWltYWdlJTIwJTNEJTIwbnAuY29uY2F0ZW5hdGUoJTVCaW1hZ2UlMkMlMjBpbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwYXhpcyUzRDIpJTBBY2FubnlfaW1hZ2UlMjAlM0QlMjBJbWFnZS5mcm9tYXJyYXkoaW1hZ2UpJTBBY2FubnlfaW1hZ2U=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLControlNetPipeline, ControlNetModel, AutoencoderKL | |
| <span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-keyword">import</span> cv2 | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| image = load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png"</span> | |
| ) | |
| image = np.array(image) | |
| low_threshold = <span class="hljs-number">100</span> | |
| high_threshold = <span class="hljs-number">200</span> | |
| image = cv2.Canny(image, low_threshold, high_threshold) | |
| image = image[:, :, <span class="hljs-literal">None</span>] | |
| image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>) | |
| canny_image = Image.fromarray(image) | |
| canny_image`}}),dl=new v({props:{code:"Y29udHJvbG5ldCUyMCUzRCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyZGlmZnVzZXJzJTJGY29udHJvbG5ldC1jYW5ueS1zZHhsLTEuMCUyMiUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUwQSUyMCUyMCUyMCUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTC5mcm9tX3ByZXRyYWluZWQoJTIybWFkZWJ5b2xsaW4lMkZzZHhsLXZhZS1mcDE2LWZpeCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblhMQ29udHJvbE5ldFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMEElMjAlMjAlMjAlMjBjb250cm9sbmV0JTNEY29udHJvbG5ldCUyQyUwQSUyMCUyMCUyMCUyMHZhZSUzRHZhZSUyQyUwQSUyMCUyMCUyMCUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUwQSUyMCUyMCUyMCUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpJTBBcGlwZS5lbmFibGVfbW9kZWxfY3B1X29mZmxvYWQoKQ==",highlighted:`controlnet = ControlNetModel.from_pretrained( | |
| <span class="hljs-string">"diffusers/controlnet-canny-sdxl-1.0"</span>, | |
| torch_dtype=torch.float16, | |
| use_safetensors=<span class="hljs-literal">True</span> | |
| ) | |
| vae = AutoencoderKL.from_pretrained(<span class="hljs-string">"madebyollin/sdxl-vae-fp16-fix"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionXLControlNetPipeline.from_pretrained( | |
| <span class="hljs-string">"stabilityai/stable-diffusion-xl-base-1.0"</span>, | |
| controlnet=controlnet, | |
| vae=vae, | |
| torch_dtype=torch.float16, | |
| use_safetensors=<span class="hljs-literal">True</span> | |
| ) | |
| pipe.enable_model_cpu_offload()`}}),Te=new Tn({props:{$$slots:{default:[tm]},$$scope:{ctx:F}}}),fl=new v({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyYWVyaWFsJTIwdmlldyUyQyUyMGElMjBmdXR1cmlzdGljJTIwcmVzZWFyY2glMjBjb21wbGV4JTIwaW4lMjBhJTIwYnJpZ2h0JTIwZm9nZ3klMjBqdW5nbGUlMkMlMjBoYXJkJTIwbGlnaHRpbmclMjIlMEFuZWdhdGl2ZV9wcm9tcHQlMjAlM0QlMjAnbG93JTIwcXVhbGl0eSUyQyUyMGJhZCUyMHF1YWxpdHklMkMlMjBza2V0Y2hlcyclMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUyMCUwQSUyMCUyMCUyMCUyMG5lZ2F0aXZlX3Byb21wdCUzRG5lZ2F0aXZlX3Byb21wdCUyQyUyMCUwQSUyMCUyMCUyMCUyMGltYWdlJTNEaW1hZ2UlMkMlMjAlMEElMjAlMjAlMjAlMjBjb250cm9sbmV0X2NvbmRpdGlvbmluZ19zY2FsZSUzRDAuNSUyQyUwQSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlcw==",highlighted:`prompt = <span class="hljs-string">"aerial view, a futuristic research complex in a bright foggy jungle, hard lighting"</span> | |
| negative_prompt = <span class="hljs-string">'low quality, bad quality, sketches'</span> | |
| images = pipe( | |
| prompt, | |
| negative_prompt=negative_prompt, | |
| image=image, | |
| controlnet_conditioning_scale=<span class="hljs-number">0.5</span>, | |
| ).images[<span class="hljs-number">0</span>] | |
| images`}}),hl=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMQ29udHJvbE5ldFBpcGVsaW5lJTJDJTIwQ29udHJvbE5ldE1vZGVsJTJDJTIwQXV0b2VuY29kZXJLTCUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBaW1wb3J0JTIwdG9yY2glMEElMEFpbXBvcnQlMjBjdjIlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJhZXJpYWwlMjB2aWV3JTJDJTIwYSUyMGZ1dHVyaXN0aWMlMjByZXNlYXJjaCUyMGNvbXBsZXglMjBpbiUyMGElMjBicmlnaHQlMjBmb2dneSUyMGp1bmdsZSUyQyUyMGhhcmQlMjBsaWdodGluZyUyMiUwQW5lZ2F0aXZlX3Byb21wdCUyMCUzRCUyMCUyMmxvdyUyMHF1YWxpdHklMkMlMjBiYWQlMjBxdWFsaXR5JTJDJTIwc2tldGNoZXMlMjIlMEElMEFpbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZoZi5jbyUyRmRhdGFzZXRzJTJGaGYtaW50ZXJuYWwtdGVzdGluZyUyRmRpZmZ1c2Vycy1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRnNkX2NvbnRyb2xuZXQlMkZoZi1sb2dvLnBuZyUyMiUwQSklMEElMEFjb250cm9sbmV0JTIwJTNEJTIwQ29udHJvbE5ldE1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJkaWZmdXNlcnMlMkZjb250cm9sbmV0LWNhbm55LXNkeGwtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSklMEF2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMLmZyb21fcHJldHJhaW5lZCglMjJtYWRlYnlvbGxpbiUyRnNkeGwtdmFlLWZwMTYtZml4JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSklMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uWExDb250cm9sTmV0UGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMGNvbnRyb2xuZXQlM0Rjb250cm9sbmV0JTJDJTIwdmFlJTNEdmFlJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSUwQSklMEFwaXBlLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTBBaW1hZ2UlMjAlM0QlMjBucC5hcnJheShpbWFnZSklMEFpbWFnZSUyMCUzRCUyMGN2Mi5DYW5ueShpbWFnZSUyQyUyMDEwMCUyQyUyMDIwMCklMEFpbWFnZSUyMCUzRCUyMGltYWdlJTVCJTNBJTJDJTIwJTNBJTJDJTIwTm9uZSU1RCUwQWltYWdlJTIwJTNEJTIwbnAuY29uY2F0ZW5hdGUoJTVCaW1hZ2UlMkMlMjBpbWFnZSUyQyUyMGltYWdlJTVEJTJDJTIwYXhpcyUzRDIpJTBBY2FubnlfaW1hZ2UlMjAlM0QlMjBJbWFnZS5mcm9tYXJyYXkoaW1hZ2UpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUyMGNvbnRyb2xuZXRfY29uZGl0aW9uaW5nX3NjYWxlJTNEMC41JTJDJTIwaW1hZ2UlM0RjYW5ueV9pbWFnZSUyQyUyMGd1ZXNzX21vZGUlM0RUcnVlJTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLControlNetPipeline, ControlNetModel, AutoencoderKL | |
| <span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| <span class="hljs-keyword">import</span> torch | |
| <span class="hljs-keyword">import</span> cv2 | |
| <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| prompt = <span class="hljs-string">"aerial view, a futuristic research complex in a bright foggy jungle, hard lighting"</span> | |
| negative_prompt = <span class="hljs-string">"low quality, bad quality, sketches"</span> | |
| image = load_image( | |
| <span class="hljs-string">"https://hf.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png"</span> | |
| ) | |
| controlnet = ControlNetModel.from_pretrained( | |
| <span class="hljs-string">"diffusers/controlnet-canny-sdxl-1.0"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ) | |
| vae = AutoencoderKL.from_pretrained(<span class="hljs-string">"madebyollin/sdxl-vae-fp16-fix"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionXLControlNetPipeline.from_pretrained( | |
| <span class="hljs-string">"stabilityai/stable-diffusion-xl-base-1.0"</span>, controlnet=controlnet, vae=vae, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ) | |
| pipe.enable_model_cpu_offload() | |
| image = np.array(image) | |
| image = cv2.Canny(image, <span class="hljs-number">100</span>, <span class="hljs-number">200</span>) | |
| image = image[:, :, <span class="hljs-literal">None</span>] | |
| image = np.concatenate([image, image, image], axis=<span class="hljs-number">2</span>) | |
| canny_image = Image.fromarray(image) | |
| image = pipe( | |
| prompt, controlnet_conditioning_scale=<span class="hljs-number">0.5</span>, image=canny_image, guess_mode=<span class="hljs-literal">True</span>, | |
| ).images[<span class="hljs-number">0</span>]`}}),yl=new Cl({}),ve=new Tn({props:{$$slots:{default:[am]},$$scope:{ctx:F}}}),bl=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFpbXBvcnQlMjBudW1weSUyMGFzJTIwbnAlMjAlMEFpbXBvcnQlMjBjdjIlMEElMEFjYW5ueV9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGbGFuZHNjYXBlLnBuZyUyMiUwQSklMEFjYW5ueV9pbWFnZSUyMCUzRCUyMG5wLmFycmF5KGNhbm55X2ltYWdlKSUwQSUwQWxvd190aHJlc2hvbGQlMjAlM0QlMjAxMDAlMEFoaWdoX3RocmVzaG9sZCUyMCUzRCUyMDIwMCUwQSUwQWNhbm55X2ltYWdlJTIwJTNEJTIwY3YyLkNhbm55KGNhbm55X2ltYWdlJTJDJTIwbG93X3RocmVzaG9sZCUyQyUyMGhpZ2hfdGhyZXNob2xkKSUwQSUwQSUyMyUyMHplcm8lMjBvdXQlMjBtaWRkbGUlMjBjb2x1bW5zJTIwb2YlMjBpbWFnZSUyMHdoZXJlJTIwcG9zZSUyMHdpbGwlMjBiZSUyMG92ZXJsYXllZCUwQXplcm9fc3RhcnQlMjAlM0QlMjBjYW5ueV9pbWFnZS5zaGFwZSU1QjElNUQlMjAlMkYlMkYlMjA0JTBBemVyb19lbmQlMjAlM0QlMjB6ZXJvX3N0YXJ0JTIwJTJCJTIwY2FubnlfaW1hZ2Uuc2hhcGUlNUIxJTVEJTIwJTJGJTJGJTIwMiUwQWNhbm55X2ltYWdlJTVCJTNBJTJDJTIwemVyb19zdGFydCUzQXplcm9fZW5kJTVEJTIwJTNEJTIwMCUwQSUwQWNhbm55X2ltYWdlJTIwJTNEJTIwY2FubnlfaW1hZ2UlNUIlM0ElMkMlMjAlM0ElMkMlMjBOb25lJTVEJTBBY2FubnlfaW1hZ2UlMjAlM0QlMjBucC5jb25jYXRlbmF0ZSglNUJjYW5ueV9pbWFnZSUyQyUyMGNhbm55X2ltYWdlJTJDJTIwY2FubnlfaW1hZ2UlNUQlMkMlMjBheGlzJTNEMiklMEFjYW5ueV9pbWFnZSUyMCUzRCUyMEltYWdlLmZyb21hcnJheShjYW5ueV9pbWFnZSkucmVzaXplKCgxMDI0JTJDJTIwMTAyNCkp",highlighted:`<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| <span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image | |
| <span class="hljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np | |
| <span class="hljs-keyword">import</span> cv2 | |
| canny_image = load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/landscape.png"</span> | |
| ) | |
| canny_image = np.array(canny_image) | |
| low_threshold = <span class="hljs-number">100</span> | |
| high_threshold = <span class="hljs-number">200</span> | |
| canny_image = cv2.Canny(canny_image, low_threshold, high_threshold) | |
| <span class="hljs-comment"># zero out middle columns of image where pose will be overlayed</span> | |
| zero_start = canny_image.shape[<span class="hljs-number">1</span>] // <span class="hljs-number">4</span> | |
| zero_end = zero_start + canny_image.shape[<span class="hljs-number">1</span>] // <span class="hljs-number">2</span> | |
| canny_image[:, zero_start:zero_end] = <span class="hljs-number">0</span> | |
| canny_image = canny_image[:, :, <span class="hljs-literal">None</span>] | |
| canny_image = np.concatenate([canny_image, canny_image, canny_image], axis=<span class="hljs-number">2</span>) | |
| canny_image = Image.fromarray(canny_image).resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))`}}),Ul=new v({props:{code:"ZnJvbSUyMGNvbnRyb2xuZXRfYXV4JTIwaW1wb3J0JTIwT3BlbnBvc2VEZXRlY3RvciUwQWZyb20lMjBkaWZmdXNlcnMudXRpbHMlMjBpbXBvcnQlMjBsb2FkX2ltYWdlJTBBJTBBb3BlbnBvc2UlMjAlM0QlMjBPcGVucG9zZURldGVjdG9yLmZyb21fcHJldHJhaW5lZCglMjJsbGx5YXN2aWVsJTJGQ29udHJvbE5ldCUyMiklMEElMEFvcGVucG9zZV9pbWFnZSUyMCUzRCUyMGxvYWRfaW1hZ2UoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGcGVyc29uLnBuZyUyMiUwQSklMEFvcGVucG9zZV9pbWFnZSUyMCUzRCUyMG9wZW5wb3NlKG9wZW5wb3NlX2ltYWdlKS5yZXNpemUoKDEwMjQlMkMlMjAxMDI0KSk=",highlighted:`<span class="hljs-keyword">from</span> controlnet_aux <span class="hljs-keyword">import</span> OpenposeDetector | |
| <span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image | |
| openpose = OpenposeDetector.from_pretrained(<span class="hljs-string">"lllyasviel/ControlNet"</span>) | |
| openpose_image = load_image( | |
| <span class="hljs-string">"https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/person.png"</span> | |
| ) | |
| openpose_image = openpose(openpose_image).resize((<span class="hljs-number">1024</span>, <span class="hljs-number">1024</span>))`}}),vl=new v({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMQ29udHJvbE5ldFBpcGVsaW5lJTJDJTIwQ29udHJvbE5ldE1vZGVsJTJDJTIwQXV0b2VuY29kZXJLTCUyQyUyMFVuaVBDTXVsdGlzdGVwU2NoZWR1bGVyJTBBaW1wb3J0JTIwdG9yY2glMEElMEFjb250cm9sbmV0cyUyMCUzRCUyMCU1QiUwQSUyMCUyMCUyMCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIydGhpYmF1ZCUyRmNvbnRyb2xuZXQtb3BlbnBvc2Utc2R4bC0xLjAlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBJTIwJTIwJTIwJTIwKSUyQyUwQSUyMCUyMCUyMCUyMENvbnRyb2xOZXRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIyZGlmZnVzZXJzJTJGY29udHJvbG5ldC1jYW5ueS1zZHhsLTEuMCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEElMjAlMjAlMjAlMjApJTJDJTBBJTVEJTBBJTBBdmFlJTIwJTNEJTIwQXV0b2VuY29kZXJLTC5mcm9tX3ByZXRyYWluZWQoJTIybWFkZWJ5b2xsaW4lMkZzZHhsLXZhZS1mcDE2LWZpeCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblhMQ29udHJvbE5ldFBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFiaWxpdHlhaSUyRnN0YWJsZS1kaWZmdXNpb24teGwtYmFzZS0xLjAlMjIlMkMlMjBjb250cm9sbmV0JTNEY29udHJvbG5ldHMlMkMlMjB2YWUlM0R2YWUlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlJTBBKSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwVW5pUENNdWx0aXN0ZXBTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZS5zY2hlZHVsZXIuY29uZmlnKSUwQXBpcGUuZW5hYmxlX21vZGVsX2NwdV9vZmZsb2FkKCk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLControlNetPipeline, ControlNetModel, AutoencoderKL, UniPCMultistepScheduler | |
| <span class="hljs-keyword">import</span> torch | |
| controlnets = [ | |
| ControlNetModel.from_pretrained( | |
| <span class="hljs-string">"thibaud/controlnet-openpose-sdxl-1.0"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ), | |
| ControlNetModel.from_pretrained( | |
| <span class="hljs-string">"diffusers/controlnet-canny-sdxl-1.0"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ), | |
| ] | |
| vae = AutoencoderKL.from_pretrained(<span class="hljs-string">"madebyollin/sdxl-vae-fp16-fix"</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>) | |
| pipe = StableDiffusionXLControlNetPipeline.from_pretrained( | |
| <span class="hljs-string">"stabilityai/stable-diffusion-xl-base-1.0"</span>, controlnet=controlnets, vae=vae, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span> | |
| ) | |
| pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config) | |
| pipe.enable_model_cpu_offload()`}}),jl=new v({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyYSUyMGdpYW50JTIwc3RhbmRpbmclMjBpbiUyMGElMjBmYW50YXN5JTIwbGFuZHNjYXBlJTJDJTIwYmVzdCUyMHF1YWxpdHklMjIlMEFuZWdhdGl2ZV9wcm9tcHQlMjAlM0QlMjAlMjJtb25vY2hyb21lJTJDJTIwbG93cmVzJTJDJTIwYmFkJTIwYW5hdG9teSUyQyUyMHdvcnN0JTIwcXVhbGl0eSUyQyUyMGxvdyUyMHF1YWxpdHklMjIlMEElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5tYW51YWxfc2VlZCgxKSUwQSUwQWltYWdlcyUyMCUzRCUyMCU1Qm9wZW5wb3NlX2ltYWdlJTJDJTIwY2FubnlfaW1hZ2UlNUQlMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMGltYWdlJTNEaW1hZ2VzJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDI1JTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwbnVtX2ltYWdlc19wZXJfcHJvbXB0JTNEMyUyQyUwQSUyMCUyMCUyMCUyMGNvbnRyb2xuZXRfY29uZGl0aW9uaW5nX3NjYWxlJTNEJTVCMS4wJTJDJTIwMC44JTVEJTJDJTBBKS5pbWFnZXMlNUIwJTVE",highlighted:`prompt = <span class="hljs-string">"a giant standing in a fantasy landscape, best quality"</span> | |
| negative_prompt = <span class="hljs-string">"monochrome, lowres, bad anatomy, worst quality, low quality"</span> | |
| generator = torch.manual_seed(<span class="hljs-number">1</span>) | |
| images = [openpose_image, canny_image] | |
| images = pipe( | |
| prompt, | |
| image=images, | |
| num_inference_steps=<span class="hljs-number">25</span>, | |
| generator=generator, | |
| negative_prompt=negative_prompt, | |
| num_images_per_prompt=<span class="hljs-number">3</span>, | |
| controlnet_conditioning_scale=[<span class="hljs-number">1.0</span>, <span class="hljs-number">0.8</span>], | |
| ).images[<span class="hljs-number">0</span>]`}}),{c(){f=a("meta"),T=c(),u=a("h1"),w=a("a"),C=a("span"),h(U.$$.fragment),Z=c(),j=a("span"),G=r("ControlNet"),V=c(),$=a("p"),de=r("ControlNet is a type of model for controlling image diffusion models by conditioning the model with an additional input image. There are many types of conditioning inputs (canny edge, user sketching, human pose, depth, and more) you can use to control a diffusion model. This is hugely useful because it affords you greater control over image generation, making it easier to generate specific images without experimenting with different text prompts or denoising values as much."),N=c(),h(k.$$.fragment),B=c(),x=a("p"),Ce=r("A ControlNet model has two sets of weights (or blocks) connected by a zero-convolution layer:"),X=c(),R=a("ul"),Y=a("li"),I=r("a "),W=a("em"),Nl=r("locked copy"),Il=r(" keeps everything a large pretrained diffusion model has learned"),Gl=c(),E=a("li"),El=r("a "),fe=a("em"),Zn=r("trainable copy"),vn=r(" is trained on the additional conditioning input"),wa=c(),kl=a("p"),jn=r("Since the locked copy preserves the pretrained model, training and implementing a ControlNet on a new conditioning input is as fast as finetuning any other model because you aren\u2019t training the model from scratch."),Ua=c(),Bl=a("p"),Wn=r("This guide will show you how to use ControlNet for text-to-image, image-to-image, inpainting, and more! There are many types of ControlNet conditioning inputs to choose from, but in this guide we\u2019ll only focus on several of them. Feel free to experiment with other conditioning inputs!"),Ta=c(),Xl=a("p"),_n=r("Before you begin, make sure you have the following libraries installed:"),Za=c(),h(Ne.$$.fragment),va=c(),O=a("h2"),ue=a("a"),Dt=a("span"),h(Ie.$$.fragment),Cn=c(),Ht=a("span"),Nn=r("Text-to-image"),ja=c(),Rl=a("p"),In=r("For text-to-image, you normally pass a text prompt to the model. But with ControlNet, you can specify an additional conditioning input. Let\u2019s condition the model with a canny image, a white outline of an image on a black background. This way, the ControlNet can use the canny image as a control to guide the model to generate an image with the same outline."),Wa=c(),he=a("p"),Gn=r("Load an image and use the "),Ge=a("a"),En=r("opencv-python"),kn=r(" library to extract the canny image:"),_a=c(),h(Ee.$$.fragment),Ca=c(),ee=a("div"),ke=a("div"),Sl=a("img"),Bn=c(),Vl=a("figcaption"),Xn=r("original image"),Rn=c(),Be=a("div"),Yl=a("img"),Sn=c(),Fl=a("figcaption"),Vn=r("canny image"),Na=c(),Q=a("p"),Yn=r("Next, load a ControlNet model conditioned on canny edge detection and pass it to the "),$l=a("a"),Fn=r("StableDiffusionControlNetPipeline"),$n=r(". Use the faster "),xl=a("a"),xn=r("UniPCMultistepScheduler"),Qn=r(" and enable model offloading to speed up inference and reduce memory usage."),Ia=c(),h(Xe.$$.fragment),Ga=c(),Ql=a("p"),zn=r("Now pass your prompt and canny image to the pipeline:"),Ea=c(),h(Re.$$.fragment),ka=c(),Se=a("div"),Lt=a("img"),Ba=c(),le=a("h2"),ye=a("a"),Pt=a("span"),h(Ve.$$.fragment),An=c(),qt=a("span"),Dn=r("Image-to-image"),Xa=c(),zl=a("p"),Hn=r("For image-to-image, you\u2019d typically pass an initial image and a prompt to the pipeline to generate a new image. With ControlNet, you can pass an additional conditioning input to guide the model. Let\u2019s condition the model with a depth map, an image which contains spatial information. This way, the ControlNet can use the depth map as a control to guide the model to generate an image that preserves spatial information."),Ra=c(),z=a("p"),Ln=r("You\u2019ll use the "),Al=a("a"),Pn=r("StableDiffusionControlNetImg2ImgPipeline"),qn=r(" for this task, which is different from the "),Dl=a("a"),Kn=r("StableDiffusionControlNetPipeline"),On=r(" because it allows you to pass an initial image as the starting point for the image generation process."),Sa=c(),A=a("p"),eo=r("Load an image and use the "),Kt=a("code"),lo=r("depth-estimation"),to=c(),Ye=a("a"),ao=r("Pipeline"),so=r(" from \u{1F917} Transformers to extract the depth map of an image:"),Va=c(),h(Fe.$$.fragment),Ya=c(),D=a("p"),no=r("Next, load a ControlNet model conditioned on depth maps and pass it to the "),Hl=a("a"),oo=r("StableDiffusionControlNetImg2ImgPipeline"),io=r(". Use the faster "),Ll=a("a"),ro=r("UniPCMultistepScheduler"),po=r(" and enable model offloading to speed up inference and reduce memory usage."),Fa=c(),h($e.$$.fragment),$a=c(),Pl=a("p"),mo=r("Now pass your prompt, initial image, and depth map to the pipeline:"),xa=c(),h(xe.$$.fragment),Qa=c(),te=a("div"),Qe=a("div"),ql=a("img"),co=c(),Kl=a("figcaption"),fo=r("original image"),uo=c(),ze=a("div"),Ol=a("img"),ho=c(),et=a("figcaption"),yo=r("generated image"),za=c(),ae=a("h2"),Me=a("a"),Ot=a("span"),h(Ae.$$.fragment),Mo=c(),ea=a("span"),go=r("Inpainting"),Aa=c(),lt=a("p"),bo=r("For inpainting, you need an initial image, a mask image, and a prompt describing what to replace the mask with. ControlNet models allow you to add another control image to condition a model with. Let\u2019s condition the model with a canny image, a white outline of an image on a black background. This way, the ControlNet can use the canny image as a control to guide the model to generate an image with the same outline."),Da=c(),tt=a("p"),Jo=r("Load an initial image and a mask image:"),Ha=c(),h(De.$$.fragment),La=c(),H=a("p"),wo=r("Create a function to prepare the control image from the initial and mask images. This\u2019ll create a tensor to mark the pixels in "),la=a("code"),Uo=r("init_image"),To=r(" as masked if the corresponding pixel in "),ta=a("code"),Zo=r("mask_image"),vo=r(" is over a certain threshold."),Pa=c(),h(He.$$.fragment),qa=c(),se=a("div"),Le=a("div"),at=a("img"),jo=c(),st=a("figcaption"),Wo=r("original image"),_o=c(),Pe=a("div"),nt=a("img"),Co=c(),ot=a("figcaption"),No=r("mask image"),Ka=c(),L=a("p"),Io=r("Load a ControlNet model conditioned on inpainting and pass it to the "),it=a("a"),Go=r("StableDiffusionControlNetInpaintPipeline"),Eo=r(". Use the faster "),rt=a("a"),ko=r("UniPCMultistepScheduler"),Bo=r(" and enable model offloading to speed up inference and reduce memory usage."),Oa=c(),h(qe.$$.fragment),es=c(),pt=a("p"),Xo=r("Now pass your prompt, initial image, mask image, and control image to the pipeline:"),ls=c(),h(Ke.$$.fragment),ts=c(),Oe=a("div"),aa=a("img"),as=c(),ne=a("h2"),ge=a("a"),sa=a("span"),h(el.$$.fragment),Ro=c(),na=a("span"),So=r("Guess mode"),ss=c(),ll=a("p"),tl=a("a"),Vo=r("Guess mode"),Yo=r(" does not require supplying a prompt to a ControlNet at all! This forces the ControlNet encoder to do it\u2019s best to \u201Cguess\u201D the contents of the input control map (depth map, pose estimation, canny edge, etc.)."),ns=c(),P=a("p"),Fo=r("Guess mode adjusts the scale of the output residuals from a ControlNet by a fixed ratio depending on the block depth. The shallowest "),oa=a("code"),$o=r("DownBlock"),xo=r(" corresponds to 0.1, and as the blocks get deeper, the scale increases exponentially such that the scale of the "),ia=a("code"),Qo=r("MidBlock"),zo=r(" output becomes 1.0."),os=c(),h(be.$$.fragment),is=c(),S=a("p"),Ao=r("Set "),ra=a("code"),Do=r("guess_mode=True"),Ho=r(" in the pipeline, and it is "),al=a("a"),Lo=r("recommended"),Po=r(" to set the "),pa=a("code"),qo=r("guidance_scale"),Ko=r(" value between 3.0 and 5.0."),rs=c(),h(sl.$$.fragment),ps=c(),oe=a("div"),nl=a("div"),mt=a("img"),Oo=c(),ct=a("figcaption"),ei=r("regular mode with prompt"),li=c(),ol=a("div"),dt=a("img"),ti=c(),ft=a("figcaption"),ai=r("guess mode without prompt"),ms=c(),ie=a("h2"),Je=a("a"),ma=a("span"),h(il.$$.fragment),si=c(),ca=a("span"),ni=r("ControlNet with Stable Diffusion XL"),cs=c(),we=a("p"),oi=r("There aren\u2019t too many ControlNet models compatible with Stable Diffusion XL (SDXL) at the moment, but we\u2019ve trained two full-sized ControlNet models for SDXL conditioned on canny edge detection and depth maps. We\u2019re also experimenting with creating smaller versions of these SDXL-compatible ControlNet models so it is easier to run on resource-constrained hardware. You can find these checkpoints on the \u{1F917} "),rl=a("a"),ii=r("Diffusers"),ri=r(" Hub organization!"),ds=c(),ut=a("p"),pi=r("Let\u2019s use a SDXL ControlNet conditioned on canny images to generate an image. Start by loading an image and prepare the canny image:"),fs=c(),h(pl.$$.fragment),us=c(),re=a("div"),ml=a("div"),ht=a("img"),mi=c(),yt=a("figcaption"),ci=r("original image"),di=c(),cl=a("div"),Mt=a("img"),fi=c(),gt=a("figcaption"),ui=r("canny image"),hs=c(),Ue=a("p"),hi=r("Load a SDXL ControlNet model conditioned on canny edge detection and pass it to the "),bt=a("a"),yi=r("StableDiffusionXLControlNetPipeline"),Mi=r(". You can also enable model offloading to reduce memory usage."),ys=c(),h(dl.$$.fragment),Ms=c(),Jt=a("p"),gi=r("Now pass your prompt (and optionally a negative prompt if you\u2019re using one) and canny image to the pipeline:"),gs=c(),h(Te.$$.fragment),bs=c(),h(fl.$$.fragment),Js=c(),ul=a("div"),wt=a("img"),ws=c(),q=a("p"),bi=r("You can use "),Ut=a("a"),Ji=r("StableDiffusionXLControlNetPipeline"),wi=r(" in guess mode as well by setting the parameter to "),da=a("code"),Ui=r("True"),Ti=r(":"),Us=c(),h(hl.$$.fragment),Ts=c(),pe=a("h3"),Ze=a("a"),fa=a("span"),h(yl.$$.fragment),Zi=c(),ua=a("span"),vi=r("MultiControlNet"),Zs=c(),h(ve.$$.fragment),vs=c(),je=a("p"),ji=r("You can compose multiple ControlNet conditionings from different image inputs to create a "),ha=a("em"),Wi=r("MultiControlNet"),_i=r(". To get better results, it is often helpful to:"),js=c(),We=a("ol"),ya=a("li"),Ci=r("mask conditionings such that they don\u2019t overlap (for example, mask the area of a canny image where the pose conditioning is located)"),Ni=c(),Ml=a("li"),Ii=r("experiment with the "),gl=a("a"),Ma=a("code"),Gi=r("controlnet_conditioning_scale"),Ei=r(" parameter to determine how much weight to assign to each conditioning input"),Ws=c(),Tt=a("p"),ki=r("In this example, you\u2019ll combine a canny image and a human pose estimation image to generate a new image."),_s=c(),Zt=a("p"),Bi=r("Prepare the canny image conditioning:"),Cs=c(),h(bl.$$.fragment),Ns=c(),me=a("div"),Jl=a("div"),vt=a("img"),Xi=c(),jt=a("figcaption"),Ri=r("original image"),Si=c(),wl=a("div"),Wt=a("img"),Vi=c(),_t=a("figcaption"),Yi=r("canny image"),Is=c(),Ct=a("p"),Fi=r("Prepare the human pose estimation conditioning:"),Gs=c(),h(Ul.$$.fragment),Es=c(),ce=a("div"),Tl=a("div"),Nt=a("img"),$i=c(),It=a("figcaption"),xi=r("original image"),Qi=c(),Zl=a("div"),Gt=a("img"),zi=c(),Et=a("figcaption"),Ai=r("human pose image"),ks=c(),K=a("p"),Di=r("Load a list of ControlNet models that correspond to each conditioning, and pass them to the "),kt=a("a"),Hi=r("StableDiffusionXLControlNetPipeline"),Li=r(". Use the faster "),Bt=a("a"),Pi=r("UniPCMultistepScheduler"),qi=r(" and enable model offloading to reduce memory usage."),Bs=c(),h(vl.$$.fragment),Xs=c(),Xt=a("p"),Ki=r("Now you can pass your prompt (an optional negative prompt if you\u2019re using one), canny image, and pose image to the pipeline:"),Rs=c(),h(jl.$$.fragment),Ss=c(),Wl=a("div"),Rt=a("img"),this.h()},l(e){const n=Kp('[data-svelte="svelte-1phssyn"]',document.head);f=s(n,"META",{name:!0,content:!0}),n.forEach(l),T=d(e),u=s(e,"H1",{class:!0});var _l=o(u);w=s(_l,"A",{id:!0,class:!0,href:!0});var ga=o(w);C=s(ga,"SPAN",{});var ba=o(C);y(U.$$.fragment,ba),ba.forEach(l),ga.forEach(l),Z=d(_l),j=s(_l,"SPAN",{});var Ja=o(j);G=p(Ja,"ControlNet"),Ja.forEach(l),_l.forEach(l),V=d(e),$=s(e,"P",{});var gr=o($);de=p(gr,"ControlNet is a type of model for controlling image diffusion models by conditioning the model with an additional input image. There are many types of conditioning inputs (canny edge, user sketching, human pose, depth, and more) you can use to control a diffusion model. This is hugely useful because it affords you greater control over image generation, making it easier to generate specific images without experimenting with different text prompts or denoising values as much."),gr.forEach(l),N=d(e),y(k.$$.fragment,e),B=d(e),x=s(e,"P",{});var br=o(x);Ce=p(br,"A ControlNet model has two sets of weights (or blocks) connected by a zero-convolution layer:"),br.forEach(l),X=d(e),R=s(e,"UL",{});var Ys=o(R);Y=s(Ys,"LI",{});var Fs=o(Y);I=p(Fs,"a "),W=s(Fs,"EM",{});var Jr=o(W);Nl=p(Jr,"locked copy"),Jr.forEach(l),Il=p(Fs," keeps everything a large pretrained diffusion model has learned"),Fs.forEach(l),Gl=d(Ys),E=s(Ys,"LI",{});var $s=o(E);El=p($s,"a "),fe=s($s,"EM",{});var wr=o(fe);Zn=p(wr,"trainable copy"),wr.forEach(l),vn=p($s," is trained on the additional conditioning input"),$s.forEach(l),Ys.forEach(l),wa=d(e),kl=s(e,"P",{});var Ur=o(kl);jn=p(Ur,"Since the locked copy preserves the pretrained model, training and implementing a ControlNet on a new conditioning input is as fast as finetuning any other model because you aren\u2019t training the model from scratch."),Ur.forEach(l),Ua=d(e),Bl=s(e,"P",{});var Tr=o(Bl);Wn=p(Tr,"This guide will show you how to use ControlNet for text-to-image, image-to-image, inpainting, and more! There are many types of ControlNet conditioning inputs to choose from, but in this guide we\u2019ll only focus on several of them. Feel free to experiment with other conditioning inputs!"),Tr.forEach(l),Ta=d(e),Xl=s(e,"P",{});var Zr=o(Xl);_n=p(Zr,"Before you begin, make sure you have the following libraries installed:"),Zr.forEach(l),Za=d(e),y(Ne.$$.fragment,e),va=d(e),O=s(e,"H2",{class:!0});var xs=o(O);ue=s(xs,"A",{id:!0,class:!0,href:!0});var vr=o(ue);Dt=s(vr,"SPAN",{});var jr=o(Dt);y(Ie.$$.fragment,jr),jr.forEach(l),vr.forEach(l),Cn=d(xs),Ht=s(xs,"SPAN",{});var Wr=o(Ht);Nn=p(Wr,"Text-to-image"),Wr.forEach(l),xs.forEach(l),ja=d(e),Rl=s(e,"P",{});var _r=o(Rl);In=p(_r,"For text-to-image, you normally pass a text prompt to the model. But with ControlNet, you can specify an additional conditioning input. Let\u2019s condition the model with a canny image, a white outline of an image on a black background. This way, the ControlNet can use the canny image as a control to guide the model to generate an image with the same outline."),_r.forEach(l),Wa=d(e),he=s(e,"P",{});var Qs=o(he);Gn=p(Qs,"Load an image and use the "),Ge=s(Qs,"A",{href:!0,rel:!0});var Cr=o(Ge);En=p(Cr,"opencv-python"),Cr.forEach(l),kn=p(Qs," library to extract the canny image:"),Qs.forEach(l),_a=d(e),y(Ee.$$.fragment,e),Ca=d(e),ee=s(e,"DIV",{class:!0});var zs=o(ee);ke=s(zs,"DIV",{});var As=o(ke);Sl=s(As,"IMG",{class:!0,src:!0}),Bn=d(As),Vl=s(As,"FIGCAPTION",{class:!0});var Nr=o(Vl);Xn=p(Nr,"original image"),Nr.forEach(l),As.forEach(l),Rn=d(zs),Be=s(zs,"DIV",{});var Ds=o(Be);Yl=s(Ds,"IMG",{class:!0,src:!0}),Sn=d(Ds),Fl=s(Ds,"FIGCAPTION",{class:!0});var Ir=o(Fl);Vn=p(Ir,"canny image"),Ir.forEach(l),Ds.forEach(l),zs.forEach(l),Na=d(e),Q=s(e,"P",{});var St=o(Q);Yn=p(St,"Next, load a ControlNet model conditioned on canny edge detection and pass it to the "),$l=s(St,"A",{href:!0});var Gr=o($l);Fn=p(Gr,"StableDiffusionControlNetPipeline"),Gr.forEach(l),$n=p(St,". Use the faster "),xl=s(St,"A",{href:!0});var Er=o(xl);xn=p(Er,"UniPCMultistepScheduler"),Er.forEach(l),Qn=p(St," and enable model offloading to speed up inference and reduce memory usage."),St.forEach(l),Ia=d(e),y(Xe.$$.fragment,e),Ga=d(e),Ql=s(e,"P",{});var kr=o(Ql);zn=p(kr,"Now pass your prompt and canny image to the pipeline:"),kr.forEach(l),Ea=d(e),y(Re.$$.fragment,e),ka=d(e),Se=s(e,"DIV",{class:!0});var Br=o(Se);Lt=s(Br,"IMG",{src:!0}),Br.forEach(l),Ba=d(e),le=s(e,"H2",{class:!0});var Hs=o(le);ye=s(Hs,"A",{id:!0,class:!0,href:!0});var Xr=o(ye);Pt=s(Xr,"SPAN",{});var Rr=o(Pt);y(Ve.$$.fragment,Rr),Rr.forEach(l),Xr.forEach(l),An=d(Hs),qt=s(Hs,"SPAN",{});var Sr=o(qt);Dn=p(Sr,"Image-to-image"),Sr.forEach(l),Hs.forEach(l),Xa=d(e),zl=s(e,"P",{});var Vr=o(zl);Hn=p(Vr,"For image-to-image, you\u2019d typically pass an initial image and a prompt to the pipeline to generate a new image. With ControlNet, you can pass an additional conditioning input to guide the model. Let\u2019s condition the model with a depth map, an image which contains spatial information. This way, the ControlNet can use the depth map as a control to guide the model to generate an image that preserves spatial information."),Vr.forEach(l),Ra=d(e),z=s(e,"P",{});var Vt=o(z);Ln=p(Vt,"You\u2019ll use the "),Al=s(Vt,"A",{href:!0});var Yr=o(Al);Pn=p(Yr,"StableDiffusionControlNetImg2ImgPipeline"),Yr.forEach(l),qn=p(Vt," for this task, which is different from the "),Dl=s(Vt,"A",{href:!0});var Fr=o(Dl);Kn=p(Fr,"StableDiffusionControlNetPipeline"),Fr.forEach(l),On=p(Vt," because it allows you to pass an initial image as the starting point for the image generation process."),Vt.forEach(l),Sa=d(e),A=s(e,"P",{});var Yt=o(A);eo=p(Yt,"Load an image and use the "),Kt=s(Yt,"CODE",{});var $r=o(Kt);lo=p($r,"depth-estimation"),$r.forEach(l),to=d(Yt),Ye=s(Yt,"A",{href:!0,rel:!0});var xr=o(Ye);ao=p(xr,"Pipeline"),xr.forEach(l),so=p(Yt," from \u{1F917} Transformers to extract the depth map of an image:"),Yt.forEach(l),Va=d(e),y(Fe.$$.fragment,e),Ya=d(e),D=s(e,"P",{});var Ft=o(D);no=p(Ft,"Next, load a ControlNet model conditioned on depth maps and pass it to the "),Hl=s(Ft,"A",{href:!0});var Qr=o(Hl);oo=p(Qr,"StableDiffusionControlNetImg2ImgPipeline"),Qr.forEach(l),io=p(Ft,". Use the faster "),Ll=s(Ft,"A",{href:!0});var zr=o(Ll);ro=p(zr,"UniPCMultistepScheduler"),zr.forEach(l),po=p(Ft," and enable model offloading to speed up inference and reduce memory usage."),Ft.forEach(l),Fa=d(e),y($e.$$.fragment,e),$a=d(e),Pl=s(e,"P",{});var Ar=o(Pl);mo=p(Ar,"Now pass your prompt, initial image, and depth map to the pipeline:"),Ar.forEach(l),xa=d(e),y(xe.$$.fragment,e),Qa=d(e),te=s(e,"DIV",{class:!0});var Ls=o(te);Qe=s(Ls,"DIV",{});var Ps=o(Qe);ql=s(Ps,"IMG",{class:!0,src:!0}),co=d(Ps),Kl=s(Ps,"FIGCAPTION",{class:!0});var Dr=o(Kl);fo=p(Dr,"original image"),Dr.forEach(l),Ps.forEach(l),uo=d(Ls),ze=s(Ls,"DIV",{});var qs=o(ze);Ol=s(qs,"IMG",{class:!0,src:!0}),ho=d(qs),et=s(qs,"FIGCAPTION",{class:!0});var Hr=o(et);yo=p(Hr,"generated image"),Hr.forEach(l),qs.forEach(l),Ls.forEach(l),za=d(e),ae=s(e,"H2",{class:!0});var Ks=o(ae);Me=s(Ks,"A",{id:!0,class:!0,href:!0});var Lr=o(Me);Ot=s(Lr,"SPAN",{});var Pr=o(Ot);y(Ae.$$.fragment,Pr),Pr.forEach(l),Lr.forEach(l),Mo=d(Ks),ea=s(Ks,"SPAN",{});var qr=o(ea);go=p(qr,"Inpainting"),qr.forEach(l),Ks.forEach(l),Aa=d(e),lt=s(e,"P",{});var Kr=o(lt);bo=p(Kr,"For inpainting, you need an initial image, a mask image, and a prompt describing what to replace the mask with. ControlNet models allow you to add another control image to condition a model with. Let\u2019s condition the model with a canny image, a white outline of an image on a black background. This way, the ControlNet can use the canny image as a control to guide the model to generate an image with the same outline."),Kr.forEach(l),Da=d(e),tt=s(e,"P",{});var Or=o(tt);Jo=p(Or,"Load an initial image and a mask image:"),Or.forEach(l),Ha=d(e),y(De.$$.fragment,e),La=d(e),H=s(e,"P",{});var $t=o(H);wo=p($t,"Create a function to prepare the control image from the initial and mask images. This\u2019ll create a tensor to mark the pixels in "),la=s($t,"CODE",{});var ep=o(la);Uo=p(ep,"init_image"),ep.forEach(l),To=p($t," as masked if the corresponding pixel in "),ta=s($t,"CODE",{});var lp=o(ta);Zo=p(lp,"mask_image"),lp.forEach(l),vo=p($t," is over a certain threshold."),$t.forEach(l),Pa=d(e),y(He.$$.fragment,e),qa=d(e),se=s(e,"DIV",{class:!0});var Os=o(se);Le=s(Os,"DIV",{});var en=o(Le);at=s(en,"IMG",{class:!0,src:!0}),jo=d(en),st=s(en,"FIGCAPTION",{class:!0});var tp=o(st);Wo=p(tp,"original image"),tp.forEach(l),en.forEach(l),_o=d(Os),Pe=s(Os,"DIV",{});var ln=o(Pe);nt=s(ln,"IMG",{class:!0,src:!0}),Co=d(ln),ot=s(ln,"FIGCAPTION",{class:!0});var ap=o(ot);No=p(ap,"mask image"),ap.forEach(l),ln.forEach(l),Os.forEach(l),Ka=d(e),L=s(e,"P",{});var xt=o(L);Io=p(xt,"Load a ControlNet model conditioned on inpainting and pass it to the "),it=s(xt,"A",{href:!0});var sp=o(it);Go=p(sp,"StableDiffusionControlNetInpaintPipeline"),sp.forEach(l),Eo=p(xt,". Use the faster "),rt=s(xt,"A",{href:!0});var np=o(rt);ko=p(np,"UniPCMultistepScheduler"),np.forEach(l),Bo=p(xt," and enable model offloading to speed up inference and reduce memory usage."),xt.forEach(l),Oa=d(e),y(qe.$$.fragment,e),es=d(e),pt=s(e,"P",{});var op=o(pt);Xo=p(op,"Now pass your prompt, initial image, mask image, and control image to the pipeline:"),op.forEach(l),ls=d(e),y(Ke.$$.fragment,e),ts=d(e),Oe=s(e,"DIV",{class:!0});var ip=o(Oe);aa=s(ip,"IMG",{src:!0}),ip.forEach(l),as=d(e),ne=s(e,"H2",{class:!0});var tn=o(ne);ge=s(tn,"A",{id:!0,class:!0,href:!0});var rp=o(ge);sa=s(rp,"SPAN",{});var pp=o(sa);y(el.$$.fragment,pp),pp.forEach(l),rp.forEach(l),Ro=d(tn),na=s(tn,"SPAN",{});var mp=o(na);So=p(mp,"Guess mode"),mp.forEach(l),tn.forEach(l),ss=d(e),ll=s(e,"P",{});var Oi=o(ll);tl=s(Oi,"A",{href:!0,rel:!0});var cp=o(tl);Vo=p(cp,"Guess mode"),cp.forEach(l),Yo=p(Oi," does not require supplying a prompt to a ControlNet at all! This forces the ControlNet encoder to do it\u2019s best to \u201Cguess\u201D the contents of the input control map (depth map, pose estimation, canny edge, etc.)."),Oi.forEach(l),ns=d(e),P=s(e,"P",{});var Qt=o(P);Fo=p(Qt,"Guess mode adjusts the scale of the output residuals from a ControlNet by a fixed ratio depending on the block depth. The shallowest "),oa=s(Qt,"CODE",{});var dp=o(oa);$o=p(dp,"DownBlock"),dp.forEach(l),xo=p(Qt," corresponds to 0.1, and as the blocks get deeper, the scale increases exponentially such that the scale of the "),ia=s(Qt,"CODE",{});var fp=o(ia);Qo=p(fp,"MidBlock"),fp.forEach(l),zo=p(Qt," output becomes 1.0."),Qt.forEach(l),os=d(e),y(be.$$.fragment,e),is=d(e),S=s(e,"P",{});var _e=o(S);Ao=p(_e,"Set "),ra=s(_e,"CODE",{});var up=o(ra);Do=p(up,"guess_mode=True"),up.forEach(l),Ho=p(_e," in the pipeline, and it is "),al=s(_e,"A",{href:!0,rel:!0});var hp=o(al);Lo=p(hp,"recommended"),hp.forEach(l),Po=p(_e," to set the "),pa=s(_e,"CODE",{});var yp=o(pa);qo=p(yp,"guidance_scale"),yp.forEach(l),Ko=p(_e," value between 3.0 and 5.0."),_e.forEach(l),rs=d(e),y(sl.$$.fragment,e),ps=d(e),oe=s(e,"DIV",{class:!0});var an=o(oe);nl=s(an,"DIV",{});var sn=o(nl);mt=s(sn,"IMG",{class:!0,src:!0}),Oo=d(sn),ct=s(sn,"FIGCAPTION",{class:!0});var Mp=o(ct);ei=p(Mp,"regular mode with prompt"),Mp.forEach(l),sn.forEach(l),li=d(an),ol=s(an,"DIV",{});var nn=o(ol);dt=s(nn,"IMG",{class:!0,src:!0}),ti=d(nn),ft=s(nn,"FIGCAPTION",{class:!0});var gp=o(ft);ai=p(gp,"guess mode without prompt"),gp.forEach(l),nn.forEach(l),an.forEach(l),ms=d(e),ie=s(e,"H2",{class:!0});var on=o(ie);Je=s(on,"A",{id:!0,class:!0,href:!0});var bp=o(Je);ma=s(bp,"SPAN",{});var Jp=o(ma);y(il.$$.fragment,Jp),Jp.forEach(l),bp.forEach(l),si=d(on),ca=s(on,"SPAN",{});var wp=o(ca);ni=p(wp,"ControlNet with Stable Diffusion XL"),wp.forEach(l),on.forEach(l),cs=d(e),we=s(e,"P",{});var rn=o(we);oi=p(rn,"There aren\u2019t too many ControlNet models compatible with Stable Diffusion XL (SDXL) at the moment, but we\u2019ve trained two full-sized ControlNet models for SDXL conditioned on canny edge detection and depth maps. We\u2019re also experimenting with creating smaller versions of these SDXL-compatible ControlNet models so it is easier to run on resource-constrained hardware. You can find these checkpoints on the \u{1F917} "),rl=s(rn,"A",{href:!0,rel:!0});var Up=o(rl);ii=p(Up,"Diffusers"),Up.forEach(l),ri=p(rn," Hub organization!"),rn.forEach(l),ds=d(e),ut=s(e,"P",{});var Tp=o(ut);pi=p(Tp,"Let\u2019s use a SDXL ControlNet conditioned on canny images to generate an image. Start by loading an image and prepare the canny image:"),Tp.forEach(l),fs=d(e),y(pl.$$.fragment,e),us=d(e),re=s(e,"DIV",{class:!0});var pn=o(re);ml=s(pn,"DIV",{});var mn=o(ml);ht=s(mn,"IMG",{class:!0,src:!0}),mi=d(mn),yt=s(mn,"FIGCAPTION",{class:!0});var Zp=o(yt);ci=p(Zp,"original image"),Zp.forEach(l),mn.forEach(l),di=d(pn),cl=s(pn,"DIV",{});var cn=o(cl);Mt=s(cn,"IMG",{class:!0,src:!0}),fi=d(cn),gt=s(cn,"FIGCAPTION",{class:!0});var vp=o(gt);ui=p(vp,"canny image"),vp.forEach(l),cn.forEach(l),pn.forEach(l),hs=d(e),Ue=s(e,"P",{});var dn=o(Ue);hi=p(dn,"Load a SDXL ControlNet model conditioned on canny edge detection and pass it to the "),bt=s(dn,"A",{href:!0});var jp=o(bt);yi=p(jp,"StableDiffusionXLControlNetPipeline"),jp.forEach(l),Mi=p(dn,". You can also enable model offloading to reduce memory usage."),dn.forEach(l),ys=d(e),y(dl.$$.fragment,e),Ms=d(e),Jt=s(e,"P",{});var Wp=o(Jt);gi=p(Wp,"Now pass your prompt (and optionally a negative prompt if you\u2019re using one) and canny image to the pipeline:"),Wp.forEach(l),gs=d(e),y(Te.$$.fragment,e),bs=d(e),y(fl.$$.fragment,e),Js=d(e),ul=s(e,"DIV",{class:!0});var _p=o(ul);wt=s(_p,"IMG",{class:!0,src:!0}),_p.forEach(l),ws=d(e),q=s(e,"P",{});var zt=o(q);bi=p(zt,"You can use "),Ut=s(zt,"A",{href:!0});var Cp=o(Ut);Ji=p(Cp,"StableDiffusionXLControlNetPipeline"),Cp.forEach(l),wi=p(zt," in guess mode as well by setting the parameter to "),da=s(zt,"CODE",{});var Np=o(da);Ui=p(Np,"True"),Np.forEach(l),Ti=p(zt,":"),zt.forEach(l),Us=d(e),y(hl.$$.fragment,e),Ts=d(e),pe=s(e,"H3",{class:!0});var fn=o(pe);Ze=s(fn,"A",{id:!0,class:!0,href:!0});var Ip=o(Ze);fa=s(Ip,"SPAN",{});var Gp=o(fa);y(yl.$$.fragment,Gp),Gp.forEach(l),Ip.forEach(l),Zi=d(fn),ua=s(fn,"SPAN",{});var Ep=o(ua);vi=p(Ep,"MultiControlNet"),Ep.forEach(l),fn.forEach(l),Zs=d(e),y(ve.$$.fragment,e),vs=d(e),je=s(e,"P",{});var un=o(je);ji=p(un,"You can compose multiple ControlNet conditionings from different image inputs to create a "),ha=s(un,"EM",{});var kp=o(ha);Wi=p(kp,"MultiControlNet"),kp.forEach(l),_i=p(un,". To get better results, it is often helpful to:"),un.forEach(l),js=d(e),We=s(e,"OL",{});var hn=o(We);ya=s(hn,"LI",{});var Bp=o(ya);Ci=p(Bp,"mask conditionings such that they don\u2019t overlap (for example, mask the area of a canny image where the pose conditioning is located)"),Bp.forEach(l),Ni=d(hn),Ml=s(hn,"LI",{});var yn=o(Ml);Ii=p(yn,"experiment with the "),gl=s(yn,"A",{href:!0,rel:!0});var Xp=o(gl);Ma=s(Xp,"CODE",{});var Rp=o(Ma);Gi=p(Rp,"controlnet_conditioning_scale"),Rp.forEach(l),Xp.forEach(l),Ei=p(yn," parameter to determine how much weight to assign to each conditioning input"),yn.forEach(l),hn.forEach(l),Ws=d(e),Tt=s(e,"P",{});var Sp=o(Tt);ki=p(Sp,"In this example, you\u2019ll combine a canny image and a human pose estimation image to generate a new image."),Sp.forEach(l),_s=d(e),Zt=s(e,"P",{});var Vp=o(Zt);Bi=p(Vp,"Prepare the canny image conditioning:"),Vp.forEach(l),Cs=d(e),y(bl.$$.fragment,e),Ns=d(e),me=s(e,"DIV",{class:!0});var Mn=o(me);Jl=s(Mn,"DIV",{});var gn=o(Jl);vt=s(gn,"IMG",{class:!0,src:!0}),Xi=d(gn),jt=s(gn,"FIGCAPTION",{class:!0});var Yp=o(jt);Ri=p(Yp,"original image"),Yp.forEach(l),gn.forEach(l),Si=d(Mn),wl=s(Mn,"DIV",{});var bn=o(wl);Wt=s(bn,"IMG",{class:!0,src:!0}),Vi=d(bn),_t=s(bn,"FIGCAPTION",{class:!0});var Fp=o(_t);Yi=p(Fp,"canny image"),Fp.forEach(l),bn.forEach(l),Mn.forEach(l),Is=d(e),Ct=s(e,"P",{});var $p=o(Ct);Fi=p($p,"Prepare the human pose estimation conditioning:"),$p.forEach(l),Gs=d(e),y(Ul.$$.fragment,e),Es=d(e),ce=s(e,"DIV",{class:!0});var Jn=o(ce);Tl=s(Jn,"DIV",{});var wn=o(Tl);Nt=s(wn,"IMG",{class:!0,src:!0}),$i=d(wn),It=s(wn,"FIGCAPTION",{class:!0});var xp=o(It);xi=p(xp,"original image"),xp.forEach(l),wn.forEach(l),Qi=d(Jn),Zl=s(Jn,"DIV",{});var Un=o(Zl);Gt=s(Un,"IMG",{class:!0,src:!0}),zi=d(Un),Et=s(Un,"FIGCAPTION",{class:!0});var Qp=o(Et);Ai=p(Qp,"human pose image"),Qp.forEach(l),Un.forEach(l),Jn.forEach(l),ks=d(e),K=s(e,"P",{});var At=o(K);Di=p(At,"Load a list of ControlNet models that correspond to each conditioning, and pass them to the "),kt=s(At,"A",{href:!0});var zp=o(kt);Hi=p(zp,"StableDiffusionXLControlNetPipeline"),zp.forEach(l),Li=p(At,". Use the faster "),Bt=s(At,"A",{href:!0});var Ap=o(Bt);Pi=p(Ap,"UniPCMultistepScheduler"),Ap.forEach(l),qi=p(At," and enable model offloading to reduce memory usage."),At.forEach(l),Bs=d(e),y(vl.$$.fragment,e),Xs=d(e),Xt=s(e,"P",{});var Dp=o(Xt);Ki=p(Dp,"Now you can pass your prompt (an optional negative prompt if you\u2019re using one), canny image, and pose image to the pipeline:"),Dp.forEach(l),Rs=d(e),y(jl.$$.fragment,e),Ss=d(e),Wl=s(e,"DIV",{class:!0});var Hp=o(Wl);Rt=s(Hp,"IMG",{class:!0,src:!0}),Hp.forEach(l),this.h()},h(){m(f,"name","hf:doc:metadata"),m(f,"content",JSON.stringify(nm)),m(w,"id","controlnet"),m(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(w,"href","#controlnet"),m(u,"class","relative group"),m(ue,"id","texttoimage"),m(ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ue,"href","#texttoimage"),m(O,"class","relative group"),m(Ge,"href","https://github.com/opencv/opencv-python"),m(Ge,"rel","nofollow"),m(Sl,"class","rounded-xl"),_(Sl.src,er="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/input_image_vermeer.png")||m(Sl,"src",er),m(Vl,"class","mt-2 text-center text-sm text-gray-500"),m(Yl,"class","rounded-xl"),_(Yl.src,lr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/vermeer_canny_edged.png")||m(Yl,"src",lr),m(Fl,"class","mt-2 text-center text-sm text-gray-500"),m(ee,"class","flex gap-4"),m($l,"href","/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetPipeline"),m(xl,"href","/docs/diffusers/main/en/api/schedulers/unipc#diffusers.UniPCMultistepScheduler"),_(Lt.src,tr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-text2img.png")||m(Lt,"src",tr),m(Se,"class","flex justify-center"),m(ye,"id","imagetoimage"),m(ye,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ye,"href","#imagetoimage"),m(le,"class","relative group"),m(Al,"href","/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetImg2ImgPipeline"),m(Dl,"href","/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetPipeline"),m(Ye,"href","https://huggingface.co/docs/transformers/main/en/main_classes/pipelines#transformers.Pipeline"),m(Ye,"rel","nofollow"),m(Hl,"href","/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetImg2ImgPipeline"),m(Ll,"href","/docs/diffusers/main/en/api/schedulers/unipc#diffusers.UniPCMultistepScheduler"),m(ql,"class","rounded-xl"),_(ql.src,ar="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-img2img.jpg")||m(ql,"src",ar),m(Kl,"class","mt-2 text-center text-sm text-gray-500"),m(Ol,"class","rounded-xl"),_(Ol.src,sr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-img2img-2.png")||m(Ol,"src",sr),m(et,"class","mt-2 text-center text-sm text-gray-500"),m(te,"class","flex gap-4"),m(Me,"id","inpainting"),m(Me,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Me,"href","#inpainting"),m(ae,"class","relative group"),m(at,"class","rounded-xl"),_(at.src,nr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-inpaint.jpg")||m(at,"src",nr),m(st,"class","mt-2 text-center text-sm text-gray-500"),m(nt,"class","rounded-xl"),_(nt.src,or="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-inpaint-mask.jpg")||m(nt,"src",or),m(ot,"class","mt-2 text-center text-sm text-gray-500"),m(se,"class","flex gap-4"),m(it,"href","/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetInpaintPipeline"),m(rt,"href","/docs/diffusers/main/en/api/schedulers/unipc#diffusers.UniPCMultistepScheduler"),_(aa.src,ir="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet-inpaint-result.png")||m(aa,"src",ir),m(Oe,"class","flex justify-center"),m(ge,"id","guess-mode"),m(ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(ge,"href","#guess-mode"),m(ne,"class","relative group"),m(tl,"href","https://github.com/lllyasviel/ControlNet/discussions/188"),m(tl,"rel","nofollow"),m(al,"href","https://github.com/lllyasviel/ControlNet#guess-mode--non-prompt-mode"),m(al,"rel","nofollow"),m(mt,"class","rounded-xl"),_(mt.src,rr="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare_guess_mode/output_images/diffusers/output_bird_canny_0.png")||m(mt,"src",rr),m(ct,"class","mt-2 text-center text-sm text-gray-500"),m(dt,"class","rounded-xl"),_(dt.src,pr="https://huggingface.co/takuma104/controlnet_dev/resolve/main/gen_compare_guess_mode/output_images/diffusers/output_bird_canny_0_gm.png")||m(dt,"src",pr),m(ft,"class","mt-2 text-center text-sm text-gray-500"),m(oe,"class","flex gap-4"),m(Je,"id","controlnet-with-stable-diffusion-xl"),m(Je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Je,"href","#controlnet-with-stable-diffusion-xl"),m(ie,"class","relative group"),m(rl,"href","https://huggingface.co/diffusers"),m(rl,"rel","nofollow"),m(ht,"class","rounded-xl"),_(ht.src,mr="https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd_controlnet/hf-logo.png")||m(ht,"src",mr),m(yt,"class","mt-2 text-center text-sm text-gray-500"),m(Mt,"class","rounded-xl"),_(Mt.src,cr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/hf-logo-canny.png")||m(Mt,"src",cr),m(gt,"class","mt-2 text-center text-sm text-gray-500"),m(re,"class","flex gap-4"),m(bt,"href","/docs/diffusers/main/en/api/pipelines/controlnet_sdxl#diffusers.StableDiffusionXLControlNetPipeline"),m(wt,"class","rounded-xl"),_(wt.src,dr="https://huggingface.co/diffusers/controlnet-canny-sdxl-1.0/resolve/main/out_hug_lab_7.png")||m(wt,"src",dr),m(ul,"class","flex justify-center"),m(Ut,"href","/docs/diffusers/main/en/api/pipelines/controlnet_sdxl#diffusers.StableDiffusionXLControlNetPipeline"),m(Ze,"id","multicontrolnet"),m(Ze,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Ze,"href","#multicontrolnet"),m(pe,"class","relative group"),m(gl,"href","https://huggingface.co/docs/diffusers/main/en/api/pipelines/controlnet#diffusers.StableDiffusionControlNetPipeline.__call__.controlnet_conditioning_scale"),m(gl,"rel","nofollow"),m(vt,"class","rounded-xl"),_(vt.src,fr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/landscape.png")||m(vt,"src",fr),m(jt,"class","mt-2 text-center text-sm text-gray-500"),m(Wt,"class","rounded-xl"),_(Wt.src,ur="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/controlnet/landscape_canny_masked.png")||m(Wt,"src",ur),m(_t,"class","mt-2 text-center text-sm text-gray-500"),m(me,"class","flex gap-4"),m(Nt,"class","rounded-xl"),_(Nt.src,hr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/person.png")||m(Nt,"src",hr),m(It,"class","mt-2 text-center text-sm text-gray-500"),m(Gt,"class","rounded-xl"),_(Gt.src,yr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/blog/controlnet/person_pose.png")||m(Gt,"src",yr),m(Et,"class","mt-2 text-center text-sm text-gray-500"),m(ce,"class","flex gap-4"),m(kt,"href","/docs/diffusers/main/en/api/pipelines/controlnet_sdxl#diffusers.StableDiffusionXLControlNetPipeline"),m(Bt,"href","/docs/diffusers/main/en/api/schedulers/unipc#diffusers.UniPCMultistepScheduler"),m(Rt,"class","rounded-xl"),_(Rt.src,Mr="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/multicontrolnet.png")||m(Rt,"src",Mr),m(Wl,"class","flex justify-center")},m(e,n){t(document.head,f),i(e,T,n),i(e,u,n),t(u,w),t(w,C),M(U,C,null),t(u,Z),t(u,j),t(j,G),i(e,V,n),i(e,$,n),t($,de),i(e,N,n),M(k,e,n),i(e,B,n),i(e,x,n),t(x,Ce),i(e,X,n),i(e,R,n),t(R,Y),t(Y,I),t(Y,W),t(W,Nl),t(Y,Il),t(R,Gl),t(R,E),t(E,El),t(E,fe),t(fe,Zn),t(E,vn),i(e,wa,n),i(e,kl,n),t(kl,jn),i(e,Ua,n),i(e,Bl,n),t(Bl,Wn),i(e,Ta,n),i(e,Xl,n),t(Xl,_n),i(e,Za,n),M(Ne,e,n),i(e,va,n),i(e,O,n),t(O,ue),t(ue,Dt),M(Ie,Dt,null),t(O,Cn),t(O,Ht),t(Ht,Nn),i(e,ja,n),i(e,Rl,n),t(Rl,In),i(e,Wa,n),i(e,he,n),t(he,Gn),t(he,Ge),t(Ge,En),t(he,kn),i(e,_a,n),M(Ee,e,n),i(e,Ca,n),i(e,ee,n),t(ee,ke),t(ke,Sl),t(ke,Bn),t(ke,Vl),t(Vl,Xn),t(ee,Rn),t(ee,Be),t(Be,Yl),t(Be,Sn),t(Be,Fl),t(Fl,Vn),i(e,Na,n),i(e,Q,n),t(Q,Yn),t(Q,$l),t($l,Fn),t(Q,$n),t(Q,xl),t(xl,xn),t(Q,Qn),i(e,Ia,n),M(Xe,e,n),i(e,Ga,n),i(e,Ql,n),t(Ql,zn),i(e,Ea,n),M(Re,e,n),i(e,ka,n),i(e,Se,n),t(Se,Lt),i(e,Ba,n),i(e,le,n),t(le,ye),t(ye,Pt),M(Ve,Pt,null),t(le,An),t(le,qt),t(qt,Dn),i(e,Xa,n),i(e,zl,n),t(zl,Hn),i(e,Ra,n),i(e,z,n),t(z,Ln),t(z,Al),t(Al,Pn),t(z,qn),t(z,Dl),t(Dl,Kn),t(z,On),i(e,Sa,n),i(e,A,n),t(A,eo),t(A,Kt),t(Kt,lo),t(A,to),t(A,Ye),t(Ye,ao),t(A,so),i(e,Va,n),M(Fe,e,n),i(e,Ya,n),i(e,D,n),t(D,no),t(D,Hl),t(Hl,oo),t(D,io),t(D,Ll),t(Ll,ro),t(D,po),i(e,Fa,n),M($e,e,n),i(e,$a,n),i(e,Pl,n),t(Pl,mo),i(e,xa,n),M(xe,e,n),i(e,Qa,n),i(e,te,n),t(te,Qe),t(Qe,ql),t(Qe,co),t(Qe,Kl),t(Kl,fo),t(te,uo),t(te,ze),t(ze,Ol),t(ze,ho),t(ze,et),t(et,yo),i(e,za,n),i(e,ae,n),t(ae,Me),t(Me,Ot),M(Ae,Ot,null),t(ae,Mo),t(ae,ea),t(ea,go),i(e,Aa,n),i(e,lt,n),t(lt,bo),i(e,Da,n),i(e,tt,n),t(tt,Jo),i(e,Ha,n),M(De,e,n),i(e,La,n),i(e,H,n),t(H,wo),t(H,la),t(la,Uo),t(H,To),t(H,ta),t(ta,Zo),t(H,vo),i(e,Pa,n),M(He,e,n),i(e,qa,n),i(e,se,n),t(se,Le),t(Le,at),t(Le,jo),t(Le,st),t(st,Wo),t(se,_o),t(se,Pe),t(Pe,nt),t(Pe,Co),t(Pe,ot),t(ot,No),i(e,Ka,n),i(e,L,n),t(L,Io),t(L,it),t(it,Go),t(L,Eo),t(L,rt),t(rt,ko),t(L,Bo),i(e,Oa,n),M(qe,e,n),i(e,es,n),i(e,pt,n),t(pt,Xo),i(e,ls,n),M(Ke,e,n),i(e,ts,n),i(e,Oe,n),t(Oe,aa),i(e,as,n),i(e,ne,n),t(ne,ge),t(ge,sa),M(el,sa,null),t(ne,Ro),t(ne,na),t(na,So),i(e,ss,n),i(e,ll,n),t(ll,tl),t(tl,Vo),t(ll,Yo),i(e,ns,n),i(e,P,n),t(P,Fo),t(P,oa),t(oa,$o),t(P,xo),t(P,ia),t(ia,Qo),t(P,zo),i(e,os,n),M(be,e,n),i(e,is,n),i(e,S,n),t(S,Ao),t(S,ra),t(ra,Do),t(S,Ho),t(S,al),t(al,Lo),t(S,Po),t(S,pa),t(pa,qo),t(S,Ko),i(e,rs,n),M(sl,e,n),i(e,ps,n),i(e,oe,n),t(oe,nl),t(nl,mt),t(nl,Oo),t(nl,ct),t(ct,ei),t(oe,li),t(oe,ol),t(ol,dt),t(ol,ti),t(ol,ft),t(ft,ai),i(e,ms,n),i(e,ie,n),t(ie,Je),t(Je,ma),M(il,ma,null),t(ie,si),t(ie,ca),t(ca,ni),i(e,cs,n),i(e,we,n),t(we,oi),t(we,rl),t(rl,ii),t(we,ri),i(e,ds,n),i(e,ut,n),t(ut,pi),i(e,fs,n),M(pl,e,n),i(e,us,n),i(e,re,n),t(re,ml),t(ml,ht),t(ml,mi),t(ml,yt),t(yt,ci),t(re,di),t(re,cl),t(cl,Mt),t(cl,fi),t(cl,gt),t(gt,ui),i(e,hs,n),i(e,Ue,n),t(Ue,hi),t(Ue,bt),t(bt,yi),t(Ue,Mi),i(e,ys,n),M(dl,e,n),i(e,Ms,n),i(e,Jt,n),t(Jt,gi),i(e,gs,n),M(Te,e,n),i(e,bs,n),M(fl,e,n),i(e,Js,n),i(e,ul,n),t(ul,wt),i(e,ws,n),i(e,q,n),t(q,bi),t(q,Ut),t(Ut,Ji),t(q,wi),t(q,da),t(da,Ui),t(q,Ti),i(e,Us,n),M(hl,e,n),i(e,Ts,n),i(e,pe,n),t(pe,Ze),t(Ze,fa),M(yl,fa,null),t(pe,Zi),t(pe,ua),t(ua,vi),i(e,Zs,n),M(ve,e,n),i(e,vs,n),i(e,je,n),t(je,ji),t(je,ha),t(ha,Wi),t(je,_i),i(e,js,n),i(e,We,n),t(We,ya),t(ya,Ci),t(We,Ni),t(We,Ml),t(Ml,Ii),t(Ml,gl),t(gl,Ma),t(Ma,Gi),t(Ml,Ei),i(e,Ws,n),i(e,Tt,n),t(Tt,ki),i(e,_s,n),i(e,Zt,n),t(Zt,Bi),i(e,Cs,n),M(bl,e,n),i(e,Ns,n),i(e,me,n),t(me,Jl),t(Jl,vt),t(Jl,Xi),t(Jl,jt),t(jt,Ri),t(me,Si),t(me,wl),t(wl,Wt),t(wl,Vi),t(wl,_t),t(_t,Yi),i(e,Is,n),i(e,Ct,n),t(Ct,Fi),i(e,Gs,n),M(Ul,e,n),i(e,Es,n),i(e,ce,n),t(ce,Tl),t(Tl,Nt),t(Tl,$i),t(Tl,It),t(It,xi),t(ce,Qi),t(ce,Zl),t(Zl,Gt),t(Zl,zi),t(Zl,Et),t(Et,Ai),i(e,ks,n),i(e,K,n),t(K,Di),t(K,kt),t(kt,Hi),t(K,Li),t(K,Bt),t(Bt,Pi),t(K,qi),i(e,Bs,n),M(vl,e,n),i(e,Xs,n),i(e,Xt,n),t(Xt,Ki),i(e,Rs,n),M(jl,e,n),i(e,Ss,n),i(e,Wl,n),t(Wl,Rt),Vs=!0},p(e,[n]){const _l={};n&2&&(_l.$$scope={dirty:n,ctx:e}),k.$set(_l);const ga={};n&2&&(ga.$$scope={dirty:n,ctx:e}),be.$set(ga);const ba={};n&2&&(ba.$$scope={dirty:n,ctx:e}),Te.$set(ba);const Ja={};n&2&&(Ja.$$scope={dirty:n,ctx:e}),ve.$set(Ja)},i(e){Vs||(g(U.$$.fragment,e),g(k.$$.fragment,e),g(Ne.$$.fragment,e),g(Ie.$$.fragment,e),g(Ee.$$.fragment,e),g(Xe.$$.fragment,e),g(Re.$$.fragment,e),g(Ve.$$.fragment,e),g(Fe.$$.fragment,e),g($e.$$.fragment,e),g(xe.$$.fragment,e),g(Ae.$$.fragment,e),g(De.$$.fragment,e),g(He.$$.fragment,e),g(qe.$$.fragment,e),g(Ke.$$.fragment,e),g(el.$$.fragment,e),g(be.$$.fragment,e),g(sl.$$.fragment,e),g(il.$$.fragment,e),g(pl.$$.fragment,e),g(dl.$$.fragment,e),g(Te.$$.fragment,e),g(fl.$$.fragment,e),g(hl.$$.fragment,e),g(yl.$$.fragment,e),g(ve.$$.fragment,e),g(bl.$$.fragment,e),g(Ul.$$.fragment,e),g(vl.$$.fragment,e),g(jl.$$.fragment,e),Vs=!0)},o(e){b(U.$$.fragment,e),b(k.$$.fragment,e),b(Ne.$$.fragment,e),b(Ie.$$.fragment,e),b(Ee.$$.fragment,e),b(Xe.$$.fragment,e),b(Re.$$.fragment,e),b(Ve.$$.fragment,e),b(Fe.$$.fragment,e),b($e.$$.fragment,e),b(xe.$$.fragment,e),b(Ae.$$.fragment,e),b(De.$$.fragment,e),b(He.$$.fragment,e),b(qe.$$.fragment,e),b(Ke.$$.fragment,e),b(el.$$.fragment,e),b(be.$$.fragment,e),b(sl.$$.fragment,e),b(il.$$.fragment,e),b(pl.$$.fragment,e),b(dl.$$.fragment,e),b(Te.$$.fragment,e),b(fl.$$.fragment,e),b(hl.$$.fragment,e),b(yl.$$.fragment,e),b(ve.$$.fragment,e),b(bl.$$.fragment,e),b(Ul.$$.fragment,e),b(vl.$$.fragment,e),b(jl.$$.fragment,e),Vs=!1},d(e){l(f),e&&l(T),e&&l(u),J(U),e&&l(V),e&&l($),e&&l(N),J(k,e),e&&l(B),e&&l(x),e&&l(X),e&&l(R),e&&l(wa),e&&l(kl),e&&l(Ua),e&&l(Bl),e&&l(Ta),e&&l(Xl),e&&l(Za),J(Ne,e),e&&l(va),e&&l(O),J(Ie),e&&l(ja),e&&l(Rl),e&&l(Wa),e&&l(he),e&&l(_a),J(Ee,e),e&&l(Ca),e&&l(ee),e&&l(Na),e&&l(Q),e&&l(Ia),J(Xe,e),e&&l(Ga),e&&l(Ql),e&&l(Ea),J(Re,e),e&&l(ka),e&&l(Se),e&&l(Ba),e&&l(le),J(Ve),e&&l(Xa),e&&l(zl),e&&l(Ra),e&&l(z),e&&l(Sa),e&&l(A),e&&l(Va),J(Fe,e),e&&l(Ya),e&&l(D),e&&l(Fa),J($e,e),e&&l($a),e&&l(Pl),e&&l(xa),J(xe,e),e&&l(Qa),e&&l(te),e&&l(za),e&&l(ae),J(Ae),e&&l(Aa),e&&l(lt),e&&l(Da),e&&l(tt),e&&l(Ha),J(De,e),e&&l(La),e&&l(H),e&&l(Pa),J(He,e),e&&l(qa),e&&l(se),e&&l(Ka),e&&l(L),e&&l(Oa),J(qe,e),e&&l(es),e&&l(pt),e&&l(ls),J(Ke,e),e&&l(ts),e&&l(Oe),e&&l(as),e&&l(ne),J(el),e&&l(ss),e&&l(ll),e&&l(ns),e&&l(P),e&&l(os),J(be,e),e&&l(is),e&&l(S),e&&l(rs),J(sl,e),e&&l(ps),e&&l(oe),e&&l(ms),e&&l(ie),J(il),e&&l(cs),e&&l(we),e&&l(ds),e&&l(ut),e&&l(fs),J(pl,e),e&&l(us),e&&l(re),e&&l(hs),e&&l(Ue),e&&l(ys),J(dl,e),e&&l(Ms),e&&l(Jt),e&&l(gs),J(Te,e),e&&l(bs),J(fl,e),e&&l(Js),e&&l(ul),e&&l(ws),e&&l(q),e&&l(Us),J(hl,e),e&&l(Ts),e&&l(pe),J(yl),e&&l(Zs),J(ve,e),e&&l(vs),e&&l(je),e&&l(js),e&&l(We),e&&l(Ws),e&&l(Tt),e&&l(_s),e&&l(Zt),e&&l(Cs),J(bl,e),e&&l(Ns),e&&l(me),e&&l(Is),e&&l(Ct),e&&l(Gs),J(Ul,e),e&&l(Es),e&&l(ce),e&&l(ks),e&&l(K),e&&l(Bs),J(vl,e),e&&l(Xs),e&&l(Xt),e&&l(Rs),J(jl,e),e&&l(Ss),e&&l(Wl)}}}const nm={local:"controlnet",sections:[{local:"texttoimage",title:"Text-to-image"},{local:"imagetoimage",title:"Image-to-image"},{local:"inpainting",title:"Inpainting"},{local:"guess-mode",title:"Guess mode"},{local:"controlnet-with-stable-diffusion-xl",sections:[{local:"multicontrolnet",title:"MultiControlNet"}],title:"ControlNet with Stable Diffusion XL"}],title:"ControlNet"};function om(F){return Op(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class cm extends Lp{constructor(f){super();Pp(this,f,om,sm,qp,{})}}export{cm as default,nm as metadata}; | |
Xet Storage Details
- Size:
- 85.6 kB
- Xet hash:
- a69a3ef40264afb5964d128727b676cbf909df61b4b1c243e0f1fb9233b774c3
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.