import{S as Ec,i as yc,s as kc,e as i,k as f,w as h,t as r,M as Dc,c as n,d as a,m as u,a as l,x as d,h as s,b as p,N as ke,G as t,g as c,y as _,q as m,o as g,B as v,v as Tc}from"../../chunks/vendor-hf-doc-builder.js";import{T as Pc}from"../../chunks/Tip-hf-doc-builder.js";import{I as A}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as y}from"../../chunks/CodeBlock-hf-doc-builder.js";function qc(mi){let b,K,E,D,M;return{c(){b=i("p"),K=r("To successfully run the latest versions of the example scripts, we highly recommend "),E=i("strong"),D=r("installing from source"),M=r(" and keeping the installation up to date. We update the example scripts frequently and install example-specific requirements.")},l(k){b=n(k,"P",{});var C=l(b);K=s(C,"To successfully run the latest versions of the example scripts, we highly recommend "),E=n(C,"STRONG",{});var Q=l(E);D=s(Q,"installing from source"),Q.forEach(a),M=s(C," and keeping the installation up to date. We update the example scripts frequently and install example-specific requirements."),C.forEach(a)},m(k,C){c(k,b,C),t(b,K),t(b,E),t(E,D),t(b,M)},d(k){k&&a(b)}}}function xc(mi){let b,K,E,D,M,k,C,Q,ul,gi,De,Te,hl,dl,vi,N,_l,Pe,ml,gl,qe,vl,bl,bi,G,X,ma,xe,wl,ga,$l,wi,It,El,$i,ee,Ei,Ut,yl,yi,je,ki,Ot,kl,Di,Ae,Ti,te,Dl,Ie,Tl,Pl,Pi,Ue,qi,Ct,ql,xi,Oe,ji,Nt,xl,Ai,Ce,Ii,z,ae,va,Ne,jl,ba,Al,Ui,R,Il,Re,Ul,Ol,Se,Cl,Nl,Oi,T,Rl,Me,wa,Sl,Ml,Ge,$a,Gl,zl,ze,Ea,Ll,Bl,Ci,L,ie,ya,Le,Hl,ka,Vl,Ni,Rt,Wl,Ri,Be,Si,S,Fl,Da,Yl,Zl,Ta,Jl,Kl,Mi,He,Gi,St,Ql,zi,ne,Xl,Pa,eo,to,Li,Mt,ao,Bi,Ve,Hi,B,le,qa,We,io,xa,no,Vi,I,ja,lo,oo,Fe,ro,so,Aa,po,co,Wi,Ye,Fi,H,oe,Ia,Ze,fo,Ua,uo,Yi,V,re,Oa,Je,ho,Ca,_o,Zi,se,Na,Ke,Ji,mo,Ra,go,U,Qe,Ki,vo,Gt,bo,wo,Xe,Sa,zt,ds,$o,Lt,Bt,_s,Eo,et,Qi,yo,Ht,ko,Do,tt,Ma,Vt,ms,To,Wt,Ft,gs,Xi,W,pe,Ga,at,Po,za,qo,en,ce,La,it,tn,xo,Ba,jo,O,nt,an,Ao,Yt,Io,Uo,lt,Ha,Zt,vs,Oo,Jt,Kt,bs,Co,ot,nn,No,Qt,Ro,So,rt,Va,Xt,ws,Mo,ea,ta,$s,ln,F,fe,Wa,st,Go,Fa,zo,on,aa,Lo,rn,ue,Ya,Bo,Ho,pt,Vo,ct,Wo,Fo,sn,ia,Yo,pn,ft,cn,Y,he,Za,ut,Zo,Ja,Jo,fn,na,Ko,un,P,Ka,Qo,Xo,ht,er,dt,tr,ar,ir,_t,nr,mt,lr,or,rr,la,sr,Qa,pr,hn,gt,dn,q,cr,Xa,fr,ur,ei,hr,dr,ti,_r,mr,_n,Z,de,ai,vt,gr,ii,vr,mn,oa,br,gn,ra,wr,vn,w,ni,$r,Er,bt,yr,wt,kr,Dr,Tr,$t,Pr,Et,qr,xr,jr,sa,Ar,li,Ir,Ur,oi,Or,Cr,ri,Nr,bn,yt,kt,Rr,Sr,wn,_e,Mr,si,Gr,zr,$n,pa,Lr,En,Dt,yn,ca,Br,kn,me,Hr,Tt,Vr,Wr,Dn,fa,Fr,Tn,ge,Yr,pi,Zr,Jr,Pn,Pt,qn,J,ve,ci,qt,Kr,fi,Qr,xn,$,Xr,ua,es,ts,ui,as,is,hi,ns,ls,di,os,rs,_i,ss,ps,jn,xt,An;return k=new A({}),xe=new A({}),ee=new Pc({props:{warning:!0,$$slots:{default:[qc]},$$scope:{ctx:mi}}}),je=new y({props:{code:`git clone https://github.com/huggingface/diffusers
cd diffusers
pip install -e .`,highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install -e .`}}),Ae=new y({props:{code:"pip install -r requirements.txt",highlighted:"pip install -r requirements.txt"}}),Ue=new y({props:{code:"accelerate config",highlighted:"accelerate config"}}),Oe=new y({props:{code:"accelerate config default",highlighted:"accelerate config default"}}),Ce=new y({props:{code:`from accelerate.utils import write_basic_config

write_basic_config()`,highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`}}),Ne=new A({}),Le=new A({}),Be=new y({props:{code:`wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png

wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_2.png`,highlighted:`wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png

wget https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_2.png`}}),He=new y({props:{code:`export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="path to save model"

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=$MODEL_DIR \\
 --output_dir=$OUTPUT_DIR \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image "./conditioning_image_1.png" "./conditioning_image_2.png" \\
 --validation_prompt "red circle with blue background" "cyan circle with brown floral background" \\
 --train_batch_size=4`,highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path to save model&quot;</span>

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_DIR</span> \\
 --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image <span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span> <span class="hljs-string">&quot;./conditioning_image_2.png&quot;</span> \\
 --validation_prompt <span class="hljs-string">&quot;red circle with blue background&quot;</span> <span class="hljs-string">&quot;cyan circle with brown floral background&quot;</span> \\
 --train_batch_size=4`}}),Ve=new y({props:{code:`export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="path to save model"

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=$MODEL_DIR \\
 --output_dir=$OUTPUT_DIR \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image "./conditioning_image_1.png" "./conditioning_image_2.png" \\
 --validation_prompt "red circle with blue background" "cyan circle with brown floral background" \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4`,highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path to save model&quot;</span>

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_DIR</span> \\
 --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image <span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span> <span class="hljs-string">&quot;./conditioning_image_2.png&quot;</span> \\
 --validation_prompt <span class="hljs-string">&quot;red circle with blue background&quot;</span> <span class="hljs-string">&quot;cyan circle with brown floral background&quot;</span> \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4`}}),We=new A({}),Ye=new y({props:{code:`export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="path to save model"

accelerate launch --mixed_precision="fp16" --multi_gpu train_controlnet.py \\
 --pretrained_model_name_or_path=$MODEL_DIR \\
 --output_dir=$OUTPUT_DIR \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image "./conditioning_image_1.png" "./conditioning_image_2.png" \\
 --validation_prompt "red circle with blue background" "cyan circle with brown floral background" \\
 --train_batch_size=4 \\
 --mixed_precision="fp16" \\
 --tracker_project_name="controlnet-demo" \\
 --report_to=wandb`,highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path to save model&quot;</span>

accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> --multi_gpu train_controlnet.py \\
 --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_DIR</span> \\
 --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image <span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span> <span class="hljs-string">&quot;./conditioning_image_2.png&quot;</span> \\
 --validation_prompt <span class="hljs-string">&quot;red circle with blue background&quot;</span> <span class="hljs-string">&quot;cyan circle with brown floral background&quot;</span> \\
 --train_batch_size=4 \\
 --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> \\
 --tracker_project_name=<span class="hljs-string">&quot;controlnet-demo&quot;</span> \\
 --report_to=wandb`}}),Ze=new A({}),Je=new A({}),at=new A({}),st=new A({}),ft=new y({props:{code:`export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="path to save model"

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=$MODEL_DIR \\
 --output_dir=$OUTPUT_DIR \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image "./conditioning_image_1.png" "./conditioning_image_2.png" \\
 --validation_prompt "red circle with blue background" "cyan circle with brown floral background" \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --gradient_checkpointing \\
 --use_8bit_adam`,highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path to save model&quot;</span>

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_DIR</span> \\
 --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image <span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span> <span class="hljs-string">&quot;./conditioning_image_2.png&quot;</span> \\
 --validation_prompt <span class="hljs-string">&quot;red circle with blue background&quot;</span> <span class="hljs-string">&quot;cyan circle with brown floral background&quot;</span> \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --gradient_checkpointing \\
 --use_8bit_adam`}}),ut=new A({}),gt=new y({props:{code:`export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="path to save model"

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=$MODEL_DIR \\
 --output_dir=$OUTPUT_DIR \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image "./conditioning_image_1.png" "./conditioning_image_2.png" \\
 --validation_prompt "red circle with blue background" "cyan circle with brown floral background" \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --gradient_checkpointing \\
 --use_8bit_adam \\
 --enable_xformers_memory_efficient_attention \\
 --set_grads_to_none`,highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path to save model&quot;</span>

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_DIR</span> \\
 --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --learning_rate=1e-5 \\
 --validation_image <span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span> <span class="hljs-string">&quot;./conditioning_image_2.png&quot;</span> \\
 --validation_prompt <span class="hljs-string">&quot;red circle with blue background&quot;</span> <span class="hljs-string">&quot;cyan circle with brown floral background&quot;</span> \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --gradient_checkpointing \\
 --use_8bit_adam \\
 --enable_xformers_memory_efficient_attention \\
 --set_grads_to_none`}}),vt=new A({}),Dt=new y({props:{code:`compute_environment: LOCAL_MACHINE
deepspeed_config:
  gradient_accumulation_steps: 4
  offload_optimizer_device: cpu
  offload_param_device: cpu
  zero3_init_flag: false
  zero_stage: 2
distributed_type: DEEPSPEED`,highlighted:`<span class="hljs-attr">compute_environment:</span> <span class="hljs-string">LOCAL_MACHINE</span>
<span class="hljs-attr">deepspeed_config:</span>
  <span class="hljs-attr">gradient_accumulation_steps:</span> <span class="hljs-number">4</span>
  <span class="hljs-attr">offload_optimizer_device:</span> <span class="hljs-string">cpu</span>
  <span class="hljs-attr">offload_param_device:</span> <span class="hljs-string">cpu</span>
  <span class="hljs-attr">zero3_init_flag:</span> <span class="hljs-literal">false</span>
  <span class="hljs-attr">zero_stage:</span> <span class="hljs-number">2</span>
<span class="hljs-attr">distributed_type:</span> <span class="hljs-string">DEEPSPEED</span>`}}),Pt=new y({props:{code:`export MODEL_DIR="runwayml/stable-diffusion-v1-5"
export OUTPUT_DIR="path to save model"

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=$MODEL_DIR \\
 --output_dir=$OUTPUT_DIR \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --validation_image "./conditioning_image_1.png" "./conditioning_image_2.png" \\
 --validation_prompt "red circle with blue background" "cyan circle with brown floral background" \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --gradient_checkpointing \\
 --enable_xformers_memory_efficient_attention \\
 --set_grads_to_none \\
 --mixed_precision fp16`,highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path to save model&quot;</span>

accelerate launch train_controlnet.py \\
 --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_DIR</span> \\
 --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
 --dataset_name=fusing/fill50k \\
 --resolution=512 \\
 --validation_image <span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span> <span class="hljs-string">&quot;./conditioning_image_2.png&quot;</span> \\
 --validation_prompt <span class="hljs-string">&quot;red circle with blue background&quot;</span> <span class="hljs-string">&quot;cyan circle with brown floral background&quot;</span> \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --gradient_checkpointing \\
 --enable_xformers_memory_efficient_attention \\
 --set_grads_to_none \\
 --mixed_precision fp16`}}),qt=new A({}),xt=new y({props:{code:`from diffusers import StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
from diffusers.utils import load_image
import torch

base_model_path = "path to model"
controlnet_path = "path to controlnet"

controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
    base_model_path, controlnet=controlnet, torch_dtype=torch.float16
)

# speed up diffusion process with faster scheduler and memory optimization
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
# remove following line if xformers is not installed
pipe.enable_xformers_memory_efficient_attention()

pipe.enable_model_cpu_offload()

control_image = load_image("./conditioning_image_1.png")
prompt = "pale golden rod circle with old lace background"

# generate image
generator = torch.manual_seed(0)
image = pipe(prompt, num_inference_steps=20, generator=generator, image=control_image).images[0]

image.save("./output.png")`,highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionControlNetPipeline, ControlNetModel, UniPCMultistepScheduler
<span class="hljs-keyword">from</span> diffusers.utils <span class="hljs-keyword">import</span> load_image
<span class="hljs-keyword">import</span> torch

base_model_path = <span class="hljs-string">&quot;path to model&quot;</span>
controlnet_path = <span class="hljs-string">&quot;path to controlnet&quot;</span>

controlnet = ControlNetModel.from_pretrained(controlnet_path, torch_dtype=torch.float16)
pipe = StableDiffusionControlNetPipeline.from_pretrained(
    base_model_path, controlnet=controlnet, torch_dtype=torch.float16
)

<span class="hljs-comment"># speed up diffusion process with faster scheduler and memory optimization</span>
pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config)
<span class="hljs-comment"># remove following line if xformers is not installed</span>
pipe.enable_xformers_memory_efficient_attention()

pipe.enable_model_cpu_offload()

control_image = load_image(<span class="hljs-string">&quot;./conditioning_image_1.png&quot;</span>)
prompt = <span class="hljs-string">&quot;pale golden rod circle with old lace background&quot;</span>

<span class="hljs-comment"># generate image</span>
generator = torch.manual_seed(<span class="hljs-number">0</span>)
image = pipe(prompt, num_inference_steps=<span class="hljs-number">20</span>, generator=generator, image=control_image).images[<span class="hljs-number">0</span>]

image.save(<span class="hljs-string">&quot;./output.png&quot;</span>)`}}),{c(){b=i("meta"),K=f(),E=i("h1"),D=i("a"),M=i("span"),h(k.$$.fragment),C=f(),Q=i("span"),ul=r("ControlNet"),gi=f(),De=i("p"),Te=i("a"),hl=r("Adding Conditional Control to Text-to-Image Diffusion Models"),dl=r(" (ControlNet) by Lvmin Zhang and Maneesh Agrawala."),vi=f(),N=i("p"),_l=r("This example is based on the "),Pe=i("a"),ml=r("training example in the original ControlNet repository"),gl=r(". It trains a ControlNet to fill circles using a "),qe=i("a"),vl=r("small synthetic dataset"),bl=r("."),bi=f(),G=i("h2"),X=i("a"),ma=i("span"),h(xe.$$.fragment),wl=f(),ga=i("span"),$l=r("Installing the dependencies"),wi=f(),It=i("p"),El=r("Before running the scripts, make sure to install the library\u2019s training dependencies."),$i=f(),h(ee.$$.fragment),Ei=f(),Ut=i("p"),yl=r("To do this, execute the following steps in a new virtual environment:"),yi=f(),h(je.$$.fragment),ki=f(),Ot=i("p"),kl=r("Then navigate into the example folder and run:"),Di=f(),h(Ae.$$.fragment),Ti=f(),te=i("p"),Dl=r("And initialize an "),Ie=i("a"),Tl=r("\u{1F917}Accelerate"),Pl=r(" environment with:"),Pi=f(),h(Ue.$$.fragment),qi=f(),Ct=i("p"),ql=r("Or for a default \u{1F917}Accelerate configuration without answering questions about your environment:"),xi=f(),h(Oe.$$.fragment),ji=f(),Nt=i("p"),xl=r("Or if your environment doesn\u2019t support an interactive shell like a notebook:"),Ai=f(),h(Ce.$$.fragment),Ii=f(),z=i("h2"),ae=i("a"),va=i("span"),h(Ne.$$.fragment),jl=f(),ba=i("span"),Al=r("Circle filling dataset"),Ui=f(),R=i("p"),Il=r("The original dataset is hosted in the ControlNet "),Re=i("a"),Ul=r("repo"),Ol=r(", but we re-uploaded it "),Se=i("a"),Cl=r("here"),Nl=r(" to be compatible with \u{1F917} Datasets so that it can handle the data loading within the training script."),Oi=f(),T=i("p"),Rl=r("Our training examples use "),Me=i("a"),wa=i("code"),Sl=r("runwayml/stable-diffusion-v1-5"),Ml=r(" because that is what the original set of ControlNet models was trained on. However, ControlNet can be trained to augment any compatible Stable Diffusion model (such as "),Ge=i("a"),$a=i("code"),Gl=r("CompVis/stable-diffusion-v1-4"),zl=r(") or "),ze=i("a"),Ea=i("code"),Ll=r("stabilityai/stable-diffusion-2-1"),Bl=r("."),Ci=f(),L=i("h2"),ie=i("a"),ya=i("span"),h(Le.$$.fragment),Hl=f(),ka=i("span"),Vl=r("Training"),Ni=f(),Rt=i("p"),Wl=r("Download the following images to condition our training with:"),Ri=f(),h(Be.$$.fragment),Si=f(),S=i("p"),Fl=r("Specify the "),Da=i("code"),Yl=r("MODEL_NAME"),Zl=r(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Ta=i("code"),Jl=r("~diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),Kl=r(" argument."),Mi=f(),h(He.$$.fragment),Gi=f(),St=i("p"),Ql=r("This default configuration requires ~38GB VRAM."),zi=f(),ne=i("p"),Xl=r("By default, the training script logs outputs to tensorboard. Pass "),Pa=i("code"),eo=r("--report_to wandb"),to=r(` to use Weights &
Biases.`),Li=f(),Mt=i("p"),ao=r("Gradient accumulation with a smaller batch size can be used to reduce training requirements to ~20 GB VRAM."),Bi=f(),h(Ve.$$.fragment),Hi=f(),B=i("h2"),le=i("a"),qa=i("span"),h(We.$$.fragment),io=f(),xa=i("span"),no=r("Training with multiple GPUs"),Vi=f(),I=i("p"),ja=i("code"),lo=r("accelerate"),oo=r(" allows for seamless multi-GPU training. Follow the instructions "),Fe=i("a"),ro=r("here"),so=r(`
for running distributed training with `),Aa=i("code"),po=r("accelerate"),co=r(". Here is an example command:"),Wi=f(),h(Ye.$$.fragment),Fi=f(),H=i("h2"),oe=i("a"),Ia=i("span"),h(Ze.$$.fragment),fo=f(),Ua=i("span"),uo=r("Example results"),Yi=f(),V=i("h4"),re=i("a"),Oa=i("span"),h(Je.$$.fragment),ho=f(),Ca=i("span"),_o=r("After 300 steps with batch size 8"),Zi=f(),se=i("table"),Na=i("thead"),Ke=i("tr"),Ji=i("th"),mo=f(),Ra=i("th"),go=f(),U=i("tbody"),Qe=i("tr"),Ki=i("td"),vo=f(),Gt=i("td"),bo=r("red circle with blue background"),wo=f(),Xe=i("tr"),Sa=i("td"),zt=i("img"),$o=f(),Lt=i("td"),Bt=i("img"),Eo=f(),et=i("tr"),Qi=i("td"),yo=f(),Ht=i("td"),ko=r("cyan circle with brown floral background"),Do=f(),tt=i("tr"),Ma=i("td"),Vt=i("img"),To=f(),Wt=i("td"),Ft=i("img"),Xi=f(),W=i("h4"),pe=i("a"),Ga=i("span"),h(at.$$.fragment),Po=f(),za=i("span"),qo=r("After 6000 steps with batch size 8:"),en=f(),ce=i("table"),La=i("thead"),it=i("tr"),tn=i("th"),xo=f(),Ba=i("th"),jo=f(),O=i("tbody"),nt=i("tr"),an=i("td"),Ao=f(),Yt=i("td"),Io=r("red circle with blue background"),Uo=f(),lt=i("tr"),Ha=i("td"),Zt=i("img"),Oo=f(),Jt=i("td"),Kt=i("img"),Co=f(),ot=i("tr"),nn=i("td"),No=f(),Qt=i("td"),Ro=r("cyan circle with brown floral background"),So=f(),rt=i("tr"),Va=i("td"),Xt=i("img"),Mo=f(),ea=i("td"),ta=i("img"),ln=f(),F=i("h2"),fe=i("a"),Wa=i("span"),h(st.$$.fragment),Go=f(),Fa=i("span"),zo=r("Training on a 16 GB GPU"),on=f(),aa=i("p"),Lo=r("Enable the following optimizations to train on a 16GB GPU:"),rn=f(),ue=i("ul"),Ya=i("li"),Bo=r("Gradient checkpointing"),Ho=f(),pt=i("li"),Vo=r("bitsandbyte\u2019s 8-bit optimizer (take a look at the [installation](("),ct=i("a"),Wo=r("https://github.com/TimDettmers/bitsandbytes#requirements\u2014installation"),Fo=r(") instructions if you don\u2019t already have it installed)"),sn=f(),ia=i("p"),Yo=r("Now you can launch the training script:"),pn=f(),h(ft.$$.fragment),cn=f(),Y=i("h2"),he=i("a"),Za=i("span"),h(ut.$$.fragment),Zo=f(),Ja=i("span"),Jo=r("Training on a 12 GB GPU"),fn=f(),na=i("p"),Ko=r("Enable the following optimizations to train on a 12GB GPU:"),un=f(),P=i("ul"),Ka=i("li"),Qo=r("Gradient checkpointing"),Xo=f(),ht=i("li"),er=r("bitsandbyte\u2019s 8-bit optimizer (take a look at the [installation](("),dt=i("a"),tr=r("https://github.com/TimDettmers/bitsandbytes#requirements\u2014installation"),ar=r(") instructions if you don\u2019t already have it installed)"),ir=f(),_t=i("li"),nr=r("xFormers (take a look at the "),mt=i("a"),lr=r("installation"),or=r(" instructions if you don\u2019t already have it installed)"),rr=f(),la=i("li"),sr=r("set gradients to "),Qa=i("code"),pr=r("None"),hn=f(),h(gt.$$.fragment),dn=f(),q=i("p"),cr=r("When using "),Xa=i("code"),fr=r("enable_xformers_memory_efficient_attention"),ur=r(", please make sure to install "),ei=i("code"),hr=r("xformers"),dr=r(" by "),ti=i("code"),_r=r("pip install xformers"),mr=r("."),_n=f(),Z=i("h2"),de=i("a"),ai=i("span"),h(vt.$$.fragment),gr=f(),ii=i("span"),vr=r("Training on an 8 GB GPU"),mn=f(),oa=i("p"),br=r(`We have not exhaustively tested DeepSpeed support for ControlNet. While the configuration does
save memory, we have not confirmed whether the configuration trains successfully. You will very likely
have to make changes to the config to have a successful training run.`),gn=f(),ra=i("p"),wr=r("Enable the following optimizations to train on a 8GB GPU:"),vn=f(),w=i("ul"),ni=i("li"),$r=r("Gradient checkpointing"),Er=f(),bt=i("li"),yr=r("bitsandbyte\u2019s 8-bit optimizer (take a look at the [installation](("),wt=i("a"),kr=r("https://github.com/TimDettmers/bitsandbytes#requirements\u2014installation"),Dr=r(") instructions if you don\u2019t already have it installed)"),Tr=f(),$t=i("li"),Pr=r("xFormers (take a look at the "),Et=i("a"),qr=r("installation"),xr=r(" instructions if you don\u2019t already have it installed)"),jr=f(),sa=i("li"),Ar=r("set gradients to "),li=i("code"),Ir=r("None"),Ur=f(),oi=i("li"),Or=r("DeepSpeed stage 2 with parameter and optimizer offloading"),Cr=f(),ri=i("li"),Nr=r("fp16 mixed precision"),bn=f(),yt=i("p"),kt=i("a"),Rr=r("DeepSpeed"),Sr=r(` can offload tensors from VRAM to either
CPU or NVME. This requires significantly more RAM (about 25 GB).`),wn=f(),_e=i("p"),Mr=r("You\u2019ll have to configure your environment with "),si=i("code"),Gr=r("accelerate config"),zr=r(" to enable DeepSpeed stage 2."),$n=f(),pa=i("p"),Lr=r("The configuration file should look like this:"),En=f(),h(Dt.$$.fragment),yn=f(),ca=i("p"),Br=r("<Tip>"),kn=f(),me=i("p"),Hr=r("See "),Tt=i("a"),Vr=r("documentation"),Wr=r(" for more DeepSpeed configuration options."),Dn=f(),fa=i("p"),Fr=r("<Tip>"),Tn=f(),ge=i("p"),Yr=r(`Changing the default Adam optimizer to DeepSpeed\u2019s Adam
`),pi=i("code"),Zr=r("deepspeed.ops.adam.DeepSpeedCPUAdam"),Jr=r(` gives a substantial speedup but
it requires a CUDA toolchain with the same version as PyTorch. 8-bit optimizer
does not seem to be compatible with DeepSpeed at the moment.`),Pn=f(),h(Pt.$$.fragment),qn=f(),J=i("h2"),ve=i("a"),ci=i("span"),h(qt.$$.fragment),Kr=f(),fi=i("span"),Qr=r("Inference"),xn=f(),$=i("p"),Xr=r("The trained model can be run with the "),ua=i("a"),es=r("StableDiffusionControlNetPipeline"),ts=r(`.
Set `),ui=i("code"),as=r("base_model_path"),is=r(" and "),hi=i("code"),ns=r("controlnet_path"),ls=r(" to the values "),di=i("code"),os=r("--pretrained_model_name_or_path"),rs=r(` and
`),_i=i("code"),ss=r("--output_dir"),ps=r(" were respectively set to in the training script."),jn=f(),h(xt.$$.fragment),this.h()},l(e){const o=Dc('[data-svelte="svelte-1phssyn"]',document.head);b=n(o,"META",{name:!0,content:!0}),o.forEach(a),K=u(e),E=n(e,"H1",{class:!0});var jt=l(E);D=n(jt,"A",{id:!0,class:!0,href:!0});var Es=l(D);M=n(Es,"SPAN",{});var ys=l(M);d(k.$$.fragment,ys),ys.forEach(a),Es.forEach(a),C=u(jt),Q=n(jt,"SPAN",{});var ks=l(Q);ul=s(ks,"ControlNet"),ks.forEach(a),jt.forEach(a),gi=u(e),De=n(e,"P",{});var cs=l(De);Te=n(cs,"A",{href:!0,rel:!0});var Ds=l(Te);hl=s(Ds,"Adding Conditional Control to Text-to-Image Diffusion Models"),Ds.forEach(a),dl=s(cs," (ControlNet) by Lvmin Zhang and Maneesh Agrawala."),cs.forEach(a),vi=u(e),N=n(e,"P",{});var ha=l(N);_l=s(ha,"This example is based on the "),Pe=n(ha,"A",{href:!0,rel:!0});var Ts=l(Pe);ml=s(Ts,"training example in the original ControlNet repository"),Ts.forEach(a),gl=s(ha,". It trains a ControlNet to fill circles using a "),qe=n(ha,"A",{href:!0,rel:!0});var Ps=l(qe);vl=s(Ps,"small synthetic dataset"),Ps.forEach(a),bl=s(ha,"."),ha.forEach(a),bi=u(e),G=n(e,"H2",{class:!0});var In=l(G);X=n(In,"A",{id:!0,class:!0,href:!0});var qs=l(X);ma=n(qs,"SPAN",{});var xs=l(ma);d(xe.$$.fragment,xs),xs.forEach(a),qs.forEach(a),wl=u(In),ga=n(In,"SPAN",{});var js=l(ga);$l=s(js,"Installing the dependencies"),js.forEach(a),In.forEach(a),wi=u(e),It=n(e,"P",{});var As=l(It);El=s(As,"Before running the scripts, make sure to install the library\u2019s training dependencies."),As.forEach(a),$i=u(e),d(ee.$$.fragment,e),Ei=u(e),Ut=n(e,"P",{});var Is=l(Ut);yl=s(Is,"To do this, execute the following steps in a new virtual environment:"),Is.forEach(a),yi=u(e),d(je.$$.fragment,e),ki=u(e),Ot=n(e,"P",{});var Us=l(Ot);kl=s(Us,"Then navigate into the example folder and run:"),Us.forEach(a),Di=u(e),d(Ae.$$.fragment,e),Ti=u(e),te=n(e,"P",{});var Un=l(te);Dl=s(Un,"And initialize an "),Ie=n(Un,"A",{href:!0,rel:!0});var Os=l(Ie);Tl=s(Os,"\u{1F917}Accelerate"),Os.forEach(a),Pl=s(Un," environment with:"),Un.forEach(a),Pi=u(e),d(Ue.$$.fragment,e),qi=u(e),Ct=n(e,"P",{});var Cs=l(Ct);ql=s(Cs,"Or for a default \u{1F917}Accelerate configuration without answering questions about your environment:"),Cs.forEach(a),xi=u(e),d(Oe.$$.fragment,e),ji=u(e),Nt=n(e,"P",{});var Ns=l(Nt);xl=s(Ns,"Or if your environment doesn\u2019t support an interactive shell like a notebook:"),Ns.forEach(a),Ai=u(e),d(Ce.$$.fragment,e),Ii=u(e),z=n(e,"H2",{class:!0});var On=l(z);ae=n(On,"A",{id:!0,class:!0,href:!0});var Rs=l(ae);va=n(Rs,"SPAN",{});var Ss=l(va);d(Ne.$$.fragment,Ss),Ss.forEach(a),Rs.forEach(a),jl=u(On),ba=n(On,"SPAN",{});var Ms=l(ba);Al=s(Ms,"Circle filling dataset"),Ms.forEach(a),On.forEach(a),Ui=u(e),R=n(e,"P",{});var da=l(R);Il=s(da,"The original dataset is hosted in the ControlNet "),Re=n(da,"A",{href:!0,rel:!0});var Gs=l(Re);Ul=s(Gs,"repo"),Gs.forEach(a),Ol=s(da,", but we re-uploaded it "),Se=n(da,"A",{href:!0,rel:!0});var zs=l(Se);Cl=s(zs,"here"),zs.forEach(a),Nl=s(da," to be compatible with \u{1F917} Datasets so that it can handle the data loading within the training script."),da.forEach(a),Oi=u(e),T=n(e,"P",{});var be=l(T);Rl=s(be,"Our training examples use "),Me=n(be,"A",{href:!0,rel:!0});var Ls=l(Me);wa=n(Ls,"CODE",{});var Bs=l(wa);Sl=s(Bs,"runwayml/stable-diffusion-v1-5"),Bs.forEach(a),Ls.forEach(a),Ml=s(be," because that is what the original set of ControlNet models was trained on. However, ControlNet can be trained to augment any compatible Stable Diffusion model (such as "),Ge=n(be,"A",{href:!0,rel:!0});var Hs=l(Ge);$a=n(Hs,"CODE",{});var Vs=l($a);Gl=s(Vs,"CompVis/stable-diffusion-v1-4"),Vs.forEach(a),Hs.forEach(a),zl=s(be,") or "),ze=n(be,"A",{href:!0,rel:!0});var Ws=l(ze);Ea=n(Ws,"CODE",{});var Fs=l(Ea);Ll=s(Fs,"stabilityai/stable-diffusion-2-1"),Fs.forEach(a),Ws.forEach(a),Bl=s(be,"."),be.forEach(a),Ci=u(e),L=n(e,"H2",{class:!0});var Cn=l(L);ie=n(Cn,"A",{id:!0,class:!0,href:!0});var Ys=l(ie);ya=n(Ys,"SPAN",{});var Zs=l(ya);d(Le.$$.fragment,Zs),Zs.forEach(a),Ys.forEach(a),Hl=u(Cn),ka=n(Cn,"SPAN",{});var Js=l(ka);Vl=s(Js,"Training"),Js.forEach(a),Cn.forEach(a),Ni=u(e),Rt=n(e,"P",{});var Ks=l(Rt);Wl=s(Ks,"Download the following images to condition our training with:"),Ks.forEach(a),Ri=u(e),d(Be.$$.fragment,e),Si=u(e),S=n(e,"P",{});var _a=l(S);Fl=s(_a,"Specify the "),Da=n(_a,"CODE",{});var Qs=l(Da);Yl=s(Qs,"MODEL_NAME"),Qs.forEach(a),Zl=s(_a," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Ta=n(_a,"CODE",{});var Xs=l(Ta);Jl=s(Xs,"~diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),Xs.forEach(a),Kl=s(_a," argument."),_a.forEach(a),Mi=u(e),d(He.$$.fragment,e),Gi=u(e),St=n(e,"P",{});var ep=l(St);Ql=s(ep,"This default configuration requires ~38GB VRAM."),ep.forEach(a),zi=u(e),ne=n(e,"P",{});var Nn=l(ne);Xl=s(Nn,"By default, the training script logs outputs to tensorboard. Pass "),Pa=n(Nn,"CODE",{});var tp=l(Pa);eo=s(tp,"--report_to wandb"),tp.forEach(a),to=s(Nn,` to use Weights &
Biases.`),Nn.forEach(a),Li=u(e),Mt=n(e,"P",{});var ap=l(Mt);ao=s(ap,"Gradient accumulation with a smaller batch size can be used to reduce training requirements to ~20 GB VRAM."),ap.forEach(a),Bi=u(e),d(Ve.$$.fragment,e),Hi=u(e),B=n(e,"H2",{class:!0});var Rn=l(B);le=n(Rn,"A",{id:!0,class:!0,href:!0});var ip=l(le);qa=n(ip,"SPAN",{});var np=l(qa);d(We.$$.fragment,np),np.forEach(a),ip.forEach(a),io=u(Rn),xa=n(Rn,"SPAN",{});var lp=l(xa);no=s(lp,"Training with multiple GPUs"),lp.forEach(a),Rn.forEach(a),Vi=u(e),I=n(e,"P",{});var At=l(I);ja=n(At,"CODE",{});var op=l(ja);lo=s(op,"accelerate"),op.forEach(a),oo=s(At," allows for seamless multi-GPU training. Follow the instructions "),Fe=n(At,"A",{href:!0,rel:!0});var rp=l(Fe);ro=s(rp,"here"),rp.forEach(a),so=s(At,`
for running distributed training with `),Aa=n(At,"CODE",{});var sp=l(Aa);po=s(sp,"accelerate"),sp.forEach(a),co=s(At,". Here is an example command:"),At.forEach(a),Wi=u(e),d(Ye.$$.fragment,e),Fi=u(e),H=n(e,"H2",{class:!0});var Sn=l(H);oe=n(Sn,"A",{id:!0,class:!0,href:!0});var pp=l(oe);Ia=n(pp,"SPAN",{});var cp=l(Ia);d(Ze.$$.fragment,cp),cp.forEach(a),pp.forEach(a),fo=u(Sn),Ua=n(Sn,"SPAN",{});var fp=l(Ua);uo=s(fp,"Example results"),fp.forEach(a),Sn.forEach(a),Yi=u(e),V=n(e,"H4",{class:!0});var Mn=l(V);re=n(Mn,"A",{id:!0,class:!0,href:!0});var up=l(re);Oa=n(up,"SPAN",{});var hp=l(Oa);d(Je.$$.fragment,hp),hp.forEach(a),up.forEach(a),ho=u(Mn),Ca=n(Mn,"SPAN",{});var dp=l(Ca);_o=s(dp,"After 300 steps with batch size 8"),dp.forEach(a),Mn.forEach(a),Zi=u(e),se=n(e,"TABLE",{});var Gn=l(se);Na=n(Gn,"THEAD",{});var _p=l(Na);Ke=n(_p,"TR",{});var zn=l(Ke);Ji=n(zn,"TH",{}),l(Ji).forEach(a),mo=u(zn),Ra=n(zn,"TH",{align:!0}),l(Ra).forEach(a),zn.forEach(a),_p.forEach(a),go=u(Gn),U=n(Gn,"TBODY",{});var we=l(U);Qe=n(we,"TR",{});var Ln=l(Qe);Ki=n(Ln,"TD",{}),l(Ki).forEach(a),vo=u(Ln),Gt=n(Ln,"TD",{align:!0});var mp=l(Gt);bo=s(mp,"red circle with blue background"),mp.forEach(a),Ln.forEach(a),wo=u(we),Xe=n(we,"TR",{});var Bn=l(Xe);Sa=n(Bn,"TD",{});var gp=l(Sa);zt=n(gp,"IMG",{src:!0,alt:!0}),gp.forEach(a),$o=u(Bn),Lt=n(Bn,"TD",{align:!0});var vp=l(Lt);Bt=n(vp,"IMG",{src:!0,alt:!0}),vp.forEach(a),Bn.forEach(a),Eo=u(we),et=n(we,"TR",{});var Hn=l(et);Qi=n(Hn,"TD",{}),l(Qi).forEach(a),yo=u(Hn),Ht=n(Hn,"TD",{align:!0});var bp=l(Ht);ko=s(bp,"cyan circle with brown floral background"),bp.forEach(a),Hn.forEach(a),Do=u(we),tt=n(we,"TR",{});var Vn=l(tt);Ma=n(Vn,"TD",{});var wp=l(Ma);Vt=n(wp,"IMG",{src:!0,alt:!0}),wp.forEach(a),To=u(Vn),Wt=n(Vn,"TD",{align:!0});var $p=l(Wt);Ft=n($p,"IMG",{src:!0,alt:!0}),$p.forEach(a),Vn.forEach(a),we.forEach(a),Gn.forEach(a),Xi=u(e),W=n(e,"H4",{class:!0});var Wn=l(W);pe=n(Wn,"A",{id:!0,class:!0,href:!0});var Ep=l(pe);Ga=n(Ep,"SPAN",{});var yp=l(Ga);d(at.$$.fragment,yp),yp.forEach(a),Ep.forEach(a),Po=u(Wn),za=n(Wn,"SPAN",{});var kp=l(za);qo=s(kp,"After 6000 steps with batch size 8:"),kp.forEach(a),Wn.forEach(a),en=u(e),ce=n(e,"TABLE",{});var Fn=l(ce);La=n(Fn,"THEAD",{});var Dp=l(La);it=n(Dp,"TR",{});var Yn=l(it);tn=n(Yn,"TH",{}),l(tn).forEach(a),xo=u(Yn),Ba=n(Yn,"TH",{align:!0}),l(Ba).forEach(a),Yn.forEach(a),Dp.forEach(a),jo=u(Fn),O=n(Fn,"TBODY",{});var $e=l(O);nt=n($e,"TR",{});var Zn=l(nt);an=n(Zn,"TD",{}),l(an).forEach(a),Ao=u(Zn),Yt=n(Zn,"TD",{align:!0});var Tp=l(Yt);Io=s(Tp,"red circle with blue background"),Tp.forEach(a),Zn.forEach(a),Uo=u($e),lt=n($e,"TR",{});var Jn=l(lt);Ha=n(Jn,"TD",{});var Pp=l(Ha);Zt=n(Pp,"IMG",{src:!0,alt:!0}),Pp.forEach(a),Oo=u(Jn),Jt=n(Jn,"TD",{align:!0});var qp=l(Jt);Kt=n(qp,"IMG",{src:!0,alt:!0}),qp.forEach(a),Jn.forEach(a),Co=u($e),ot=n($e,"TR",{});var Kn=l(ot);nn=n(Kn,"TD",{}),l(nn).forEach(a),No=u(Kn),Qt=n(Kn,"TD",{align:!0});var xp=l(Qt);Ro=s(xp,"cyan circle with brown floral background"),xp.forEach(a),Kn.forEach(a),So=u($e),rt=n($e,"TR",{});var Qn=l(rt);Va=n(Qn,"TD",{});var jp=l(Va);Xt=n(jp,"IMG",{src:!0,alt:!0}),jp.forEach(a),Mo=u(Qn),ea=n(Qn,"TD",{align:!0});var Ap=l(ea);ta=n(Ap,"IMG",{src:!0,alt:!0}),Ap.forEach(a),Qn.forEach(a),$e.forEach(a),Fn.forEach(a),ln=u(e),F=n(e,"H2",{class:!0});var Xn=l(F);fe=n(Xn,"A",{id:!0,class:!0,href:!0});var Ip=l(fe);Wa=n(Ip,"SPAN",{});var Up=l(Wa);d(st.$$.fragment,Up),Up.forEach(a),Ip.forEach(a),Go=u(Xn),Fa=n(Xn,"SPAN",{});var Op=l(Fa);zo=s(Op,"Training on a 16 GB GPU"),Op.forEach(a),Xn.forEach(a),on=u(e),aa=n(e,"P",{});var Cp=l(aa);Lo=s(Cp,"Enable the following optimizations to train on a 16GB GPU:"),Cp.forEach(a),rn=u(e),ue=n(e,"UL",{});var el=l(ue);Ya=n(el,"LI",{});var Np=l(Ya);Bo=s(Np,"Gradient checkpointing"),Np.forEach(a),Ho=u(el),pt=n(el,"LI",{});var tl=l(pt);Vo=s(tl,"bitsandbyte\u2019s 8-bit optimizer (take a look at the [installation](("),ct=n(tl,"A",{href:!0,rel:!0});var Rp=l(ct);Wo=s(Rp,"https://github.com/TimDettmers/bitsandbytes#requirements\u2014installation"),Rp.forEach(a),Fo=s(tl,") instructions if you don\u2019t already have it installed)"),tl.forEach(a),el.forEach(a),sn=u(e),ia=n(e,"P",{});var Sp=l(ia);Yo=s(Sp,"Now you can launch the training script:"),Sp.forEach(a),pn=u(e),d(ft.$$.fragment,e),cn=u(e),Y=n(e,"H2",{class:!0});var al=l(Y);he=n(al,"A",{id:!0,class:!0,href:!0});var Mp=l(he);Za=n(Mp,"SPAN",{});var Gp=l(Za);d(ut.$$.fragment,Gp),Gp.forEach(a),Mp.forEach(a),Zo=u(al),Ja=n(al,"SPAN",{});var zp=l(Ja);Jo=s(zp,"Training on a 12 GB GPU"),zp.forEach(a),al.forEach(a),fn=u(e),na=n(e,"P",{});var Lp=l(na);Ko=s(Lp,"Enable the following optimizations to train on a 12GB GPU:"),Lp.forEach(a),un=u(e),P=n(e,"UL",{});var Ee=l(P);Ka=n(Ee,"LI",{});var Bp=l(Ka);Qo=s(Bp,"Gradient checkpointing"),Bp.forEach(a),Xo=u(Ee),ht=n(Ee,"LI",{});var il=l(ht);er=s(il,"bitsandbyte\u2019s 8-bit optimizer (take a look at the [installation](("),dt=n(il,"A",{href:!0,rel:!0});var Hp=l(dt);tr=s(Hp,"https://github.com/TimDettmers/bitsandbytes#requirements\u2014installation"),Hp.forEach(a),ar=s(il,") instructions if you don\u2019t already have it installed)"),il.forEach(a),ir=u(Ee),_t=n(Ee,"LI",{});var nl=l(_t);nr=s(nl,"xFormers (take a look at the "),mt=n(nl,"A",{href:!0,rel:!0});var Vp=l(mt);lr=s(Vp,"installation"),Vp.forEach(a),or=s(nl," instructions if you don\u2019t already have it installed)"),nl.forEach(a),rr=u(Ee),la=n(Ee,"LI",{});var fs=l(la);sr=s(fs,"set gradients to "),Qa=n(fs,"CODE",{});var Wp=l(Qa);pr=s(Wp,"None"),Wp.forEach(a),fs.forEach(a),Ee.forEach(a),hn=u(e),d(gt.$$.fragment,e),dn=u(e),q=n(e,"P",{});var ye=l(q);cr=s(ye,"When using "),Xa=n(ye,"CODE",{});var Fp=l(Xa);fr=s(Fp,"enable_xformers_memory_efficient_attention"),Fp.forEach(a),ur=s(ye,", please make sure to install "),ei=n(ye,"CODE",{});var Yp=l(ei);hr=s(Yp,"xformers"),Yp.forEach(a),dr=s(ye," by "),ti=n(ye,"CODE",{});var Zp=l(ti);_r=s(Zp,"pip install xformers"),Zp.forEach(a),mr=s(ye,"."),ye.forEach(a),_n=u(e),Z=n(e,"H2",{class:!0});var ll=l(Z);de=n(ll,"A",{id:!0,class:!0,href:!0});var Jp=l(de);ai=n(Jp,"SPAN",{});var Kp=l(ai);d(vt.$$.fragment,Kp),Kp.forEach(a),Jp.forEach(a),gr=u(ll),ii=n(ll,"SPAN",{});var Qp=l(ii);vr=s(Qp,"Training on an 8 GB GPU"),Qp.forEach(a),ll.forEach(a),mn=u(e),oa=n(e,"P",{});var Xp=l(oa);br=s(Xp,`We have not exhaustively tested DeepSpeed support for ControlNet. While the configuration does
save memory, we have not confirmed whether the configuration trains successfully. You will very likely
have to make changes to the config to have a successful training run.`),Xp.forEach(a),gn=u(e),ra=n(e,"P",{});var ec=l(ra);wr=s(ec,"Enable the following optimizations to train on a 8GB GPU:"),ec.forEach(a),vn=u(e),w=n(e,"UL",{});var x=l(w);ni=n(x,"LI",{});var tc=l(ni);$r=s(tc,"Gradient checkpointing"),tc.forEach(a),Er=u(x),bt=n(x,"LI",{});var ol=l(bt);yr=s(ol,"bitsandbyte\u2019s 8-bit optimizer (take a look at the [installation](("),wt=n(ol,"A",{href:!0,rel:!0});var ac=l(wt);kr=s(ac,"https://github.com/TimDettmers/bitsandbytes#requirements\u2014installation"),ac.forEach(a),Dr=s(ol,") instructions if you don\u2019t already have it installed)"),ol.forEach(a),Tr=u(x),$t=n(x,"LI",{});var rl=l($t);Pr=s(rl,"xFormers (take a look at the "),Et=n(rl,"A",{href:!0,rel:!0});var ic=l(Et);qr=s(ic,"installation"),ic.forEach(a),xr=s(rl," instructions if you don\u2019t already have it installed)"),rl.forEach(a),jr=u(x),sa=n(x,"LI",{});var us=l(sa);Ar=s(us,"set gradients to "),li=n(us,"CODE",{});var nc=l(li);Ir=s(nc,"None"),nc.forEach(a),us.forEach(a),Ur=u(x),oi=n(x,"LI",{});var lc=l(oi);Or=s(lc,"DeepSpeed stage 2 with parameter and optimizer offloading"),lc.forEach(a),Cr=u(x),ri=n(x,"LI",{});var oc=l(ri);Nr=s(oc,"fp16 mixed precision"),oc.forEach(a),x.forEach(a),bn=u(e),yt=n(e,"P",{});var hs=l(yt);kt=n(hs,"A",{href:!0,rel:!0});var rc=l(kt);Rr=s(rc,"DeepSpeed"),rc.forEach(a),Sr=s(hs,` can offload tensors from VRAM to either
CPU or NVME. This requires significantly more RAM (about 25 GB).`),hs.forEach(a),wn=u(e),_e=n(e,"P",{});var sl=l(_e);Mr=s(sl,"You\u2019ll have to configure your environment with "),si=n(sl,"CODE",{});var sc=l(si);Gr=s(sc,"accelerate config"),sc.forEach(a),zr=s(sl," to enable DeepSpeed stage 2."),sl.forEach(a),$n=u(e),pa=n(e,"P",{});var pc=l(pa);Lr=s(pc,"The configuration file should look like this:"),pc.forEach(a),En=u(e),d(Dt.$$.fragment,e),yn=u(e),ca=n(e,"P",{});var cc=l(ca);Br=s(cc,"<Tip>"),cc.forEach(a),kn=u(e),me=n(e,"P",{});var pl=l(me);Hr=s(pl,"See "),Tt=n(pl,"A",{href:!0,rel:!0});var fc=l(Tt);Vr=s(fc,"documentation"),fc.forEach(a),Wr=s(pl," for more DeepSpeed configuration options."),pl.forEach(a),Dn=u(e),fa=n(e,"P",{});var uc=l(fa);Fr=s(uc,"<Tip>"),uc.forEach(a),Tn=u(e),ge=n(e,"P",{});var cl=l(ge);Yr=s(cl,`Changing the default Adam optimizer to DeepSpeed\u2019s Adam
`),pi=n(cl,"CODE",{});var hc=l(pi);Zr=s(hc,"deepspeed.ops.adam.DeepSpeedCPUAdam"),hc.forEach(a),Jr=s(cl,` gives a substantial speedup but
it requires a CUDA toolchain with the same version as PyTorch. 8-bit optimizer
does not seem to be compatible with DeepSpeed at the moment.`),cl.forEach(a),Pn=u(e),d(Pt.$$.fragment,e),qn=u(e),J=n(e,"H2",{class:!0});var fl=l(J);ve=n(fl,"A",{id:!0,class:!0,href:!0});var dc=l(ve);ci=n(dc,"SPAN",{});var _c=l(ci);d(qt.$$.fragment,_c),_c.forEach(a),dc.forEach(a),Kr=u(fl),fi=n(fl,"SPAN",{});var mc=l(fi);Qr=s(mc,"Inference"),mc.forEach(a),fl.forEach(a),xn=u(e),$=n(e,"P",{});var j=l($);Xr=s(j,"The trained model can be run with the "),ua=n(j,"A",{href:!0});var gc=l(ua);es=s(gc,"StableDiffusionControlNetPipeline"),gc.forEach(a),ts=s(j,`.
Set `),ui=n(j,"CODE",{});var vc=l(ui);as=s(vc,"base_model_path"),vc.forEach(a),is=s(j," and "),hi=n(j,"CODE",{});var bc=l(hi);ns=s(bc,"controlnet_path"),bc.forEach(a),ls=s(j," to the values "),di=n(j,"CODE",{});var wc=l(di);os=s(wc,"--pretrained_model_name_or_path"),wc.forEach(a),rs=s(j,` and
`),_i=n(j,"CODE",{});var $c=l(_i);ss=s($c,"--output_dir"),$c.forEach(a),ps=s(j," were respectively set to in the training script."),j.forEach(a),jn=u(e),d(xt.$$.fragment,e),this.h()},h(){p(b,"name","hf:doc:metadata"),p(b,"content",JSON.stringify(jc)),p(D,"id","controlnet"),p(D,"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"),p(D,"href","#controlnet"),p(E,"class","relative group"),p(Te,"href","https://arxiv.org/abs/2302.05543"),p(Te,"rel","nofollow"),p(Pe,"href","https://github.com/lllyasviel/ControlNet/blob/main/docs/train.md"),p(Pe,"rel","nofollow"),p(qe,"href","https://huggingface.co/datasets/fusing/fill50k"),p(qe,"rel","nofollow"),p(X,"id","installing-the-dependencies"),p(X,"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"),p(X,"href","#installing-the-dependencies"),p(G,"class","relative group"),p(Ie,"href","https://github.com/huggingface/accelerate/"),p(Ie,"rel","nofollow"),p(ae,"id","circle-filling-dataset"),p(ae,"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"),p(ae,"href","#circle-filling-dataset"),p(z,"class","relative group"),p(Re,"href","https://huggingface.co/lllyasviel/ControlNet/blob/main/training/fill50k.zip"),p(Re,"rel","nofollow"),p(Se,"href","https://huggingface.co/datasets/fusing/fill50k"),p(Se,"rel","nofollow"),p(Me,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),p(Me,"rel","nofollow"),p(Ge,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),p(Ge,"rel","nofollow"),p(ze,"href","https://huggingface.co/stabilityai/stable-diffusion-2-1"),p(ze,"rel","nofollow"),p(ie,"id","training"),p(ie,"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"),p(ie,"href","#training"),p(L,"class","relative group"),p(le,"id","training-with-multiple-gpus"),p(le,"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"),p(le,"href","#training-with-multiple-gpus"),p(B,"class","relative group"),p(Fe,"href","https://huggingface.co/docs/accelerate/basic_tutorials/launch"),p(Fe,"rel","nofollow"),p(oe,"id","example-results"),p(oe,"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"),p(oe,"href","#example-results"),p(H,"class","relative group"),p(re,"id","after-300-steps-with-batch-size-8"),p(re,"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"),p(re,"href","#after-300-steps-with-batch-size-8"),p(V,"class","relative group"),p(Ra,"align","center"),p(Gt,"align","center"),ke(zt.src,ds="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png")||p(zt,"src",ds),p(zt,"alt","conditioning image"),ke(Bt.src,_s="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/red_circle_with_blue_background_300_steps.png")||p(Bt,"src",_s),p(Bt,"alt","red circle with blue background"),p(Lt,"align","center"),p(Ht,"align","center"),ke(Vt.src,ms="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_2.png")||p(Vt,"src",ms),p(Vt,"alt","conditioning image"),ke(Ft.src,gs="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/cyan_circle_with_brown_floral_background_300_steps.png")||p(Ft,"src",gs),p(Ft,"alt","cyan circle with brown floral background"),p(Wt,"align","center"),p(pe,"id","after-6000-steps-with-batch-size-8"),p(pe,"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"),p(pe,"href","#after-6000-steps-with-batch-size-8"),p(W,"class","relative group"),p(Ba,"align","center"),p(Yt,"align","center"),ke(Zt.src,vs="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_1.png")||p(Zt,"src",vs),p(Zt,"alt","conditioning image"),ke(Kt.src,bs="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/red_circle_with_blue_background_6000_steps.png")||p(Kt,"src",bs),p(Kt,"alt","red circle with blue background"),p(Jt,"align","center"),p(Qt,"align","center"),ke(Xt.src,ws="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/conditioning_image_2.png")||p(Xt,"src",ws),p(Xt,"alt","conditioning image"),ke(ta.src,$s="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/controlnet_training/cyan_circle_with_brown_floral_background_6000_steps.png")||p(ta,"src",$s),p(ta,"alt","cyan circle with brown floral background"),p(ea,"align","center"),p(fe,"id","training-on-a-16-gb-gpu"),p(fe,"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"),p(fe,"href","#training-on-a-16-gb-gpu"),p(F,"class","relative group"),p(ct,"href","https://github.com/TimDettmers/bitsandbytes#requirements--installation"),p(ct,"rel","nofollow"),p(he,"id","training-on-a-12-gb-gpu"),p(he,"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"),p(he,"href","#training-on-a-12-gb-gpu"),p(Y,"class","relative group"),p(dt,"href","https://github.com/TimDettmers/bitsandbytes#requirements--installation"),p(dt,"rel","nofollow"),p(mt,"href","https://huggingface.co/docs/diffusers/training/optimization/xformers"),p(mt,"rel","nofollow"),p(de,"id","training-on-an-8-gb-gpu"),p(de,"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"),p(de,"href","#training-on-an-8-gb-gpu"),p(Z,"class","relative group"),p(wt,"href","https://github.com/TimDettmers/bitsandbytes#requirements--installation"),p(wt,"rel","nofollow"),p(Et,"href","https://huggingface.co/docs/diffusers/training/optimization/xformers"),p(Et,"rel","nofollow"),p(kt,"href","https://www.deepspeed.ai/"),p(kt,"rel","nofollow"),p(Tt,"href","https://huggingface.co/docs/accelerate/usage_guides/deepspeed"),p(Tt,"rel","nofollow"),p(ve,"id","inference"),p(ve,"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"),p(ve,"href","#inference"),p(J,"class","relative group"),p(ua,"href","/docs/diffusers/v0.16.0/en/api/pipelines/stable_diffusion/controlnet#diffusers.StableDiffusionControlNetPipeline")},m(e,o){t(document.head,b),c(e,K,o),c(e,E,o),t(E,D),t(D,M),_(k,M,null),t(E,C),t(E,Q),t(Q,ul),c(e,gi,o),c(e,De,o),t(De,Te),t(Te,hl),t(De,dl),c(e,vi,o),c(e,N,o),t(N,_l),t(N,Pe),t(Pe,ml),t(N,gl),t(N,qe),t(qe,vl),t(N,bl),c(e,bi,o),c(e,G,o),t(G,X),t(X,ma),_(xe,ma,null),t(G,wl),t(G,ga),t(ga,$l),c(e,wi,o),c(e,It,o),t(It,El),c(e,$i,o),_(ee,e,o),c(e,Ei,o),c(e,Ut,o),t(Ut,yl),c(e,yi,o),_(je,e,o),c(e,ki,o),c(e,Ot,o),t(Ot,kl),c(e,Di,o),_(Ae,e,o),c(e,Ti,o),c(e,te,o),t(te,Dl),t(te,Ie),t(Ie,Tl),t(te,Pl),c(e,Pi,o),_(Ue,e,o),c(e,qi,o),c(e,Ct,o),t(Ct,ql),c(e,xi,o),_(Oe,e,o),c(e,ji,o),c(e,Nt,o),t(Nt,xl),c(e,Ai,o),_(Ce,e,o),c(e,Ii,o),c(e,z,o),t(z,ae),t(ae,va),_(Ne,va,null),t(z,jl),t(z,ba),t(ba,Al),c(e,Ui,o),c(e,R,o),t(R,Il),t(R,Re),t(Re,Ul),t(R,Ol),t(R,Se),t(Se,Cl),t(R,Nl),c(e,Oi,o),c(e,T,o),t(T,Rl),t(T,Me),t(Me,wa),t(wa,Sl),t(T,Ml),t(T,Ge),t(Ge,$a),t($a,Gl),t(T,zl),t(T,ze),t(ze,Ea),t(Ea,Ll),t(T,Bl),c(e,Ci,o),c(e,L,o),t(L,ie),t(ie,ya),_(Le,ya,null),t(L,Hl),t(L,ka),t(ka,Vl),c(e,Ni,o),c(e,Rt,o),t(Rt,Wl),c(e,Ri,o),_(Be,e,o),c(e,Si,o),c(e,S,o),t(S,Fl),t(S,Da),t(Da,Yl),t(S,Zl),t(S,Ta),t(Ta,Jl),t(S,Kl),c(e,Mi,o),_(He,e,o),c(e,Gi,o),c(e,St,o),t(St,Ql),c(e,zi,o),c(e,ne,o),t(ne,Xl),t(ne,Pa),t(Pa,eo),t(ne,to),c(e,Li,o),c(e,Mt,o),t(Mt,ao),c(e,Bi,o),_(Ve,e,o),c(e,Hi,o),c(e,B,o),t(B,le),t(le,qa),_(We,qa,null),t(B,io),t(B,xa),t(xa,no),c(e,Vi,o),c(e,I,o),t(I,ja),t(ja,lo),t(I,oo),t(I,Fe),t(Fe,ro),t(I,so),t(I,Aa),t(Aa,po),t(I,co),c(e,Wi,o),_(Ye,e,o),c(e,Fi,o),c(e,H,o),t(H,oe),t(oe,Ia),_(Ze,Ia,null),t(H,fo),t(H,Ua),t(Ua,uo),c(e,Yi,o),c(e,V,o),t(V,re),t(re,Oa),_(Je,Oa,null),t(V,ho),t(V,Ca),t(Ca,_o),c(e,Zi,o),c(e,se,o),t(se,Na),t(Na,Ke),t(Ke,Ji),t(Ke,mo),t(Ke,Ra),t(se,go),t(se,U),t(U,Qe),t(Qe,Ki),t(Qe,vo),t(Qe,Gt),t(Gt,bo),t(U,wo),t(U,Xe),t(Xe,Sa),t(Sa,zt),t(Xe,$o),t(Xe,Lt),t(Lt,Bt),t(U,Eo),t(U,et),t(et,Qi),t(et,yo),t(et,Ht),t(Ht,ko),t(U,Do),t(U,tt),t(tt,Ma),t(Ma,Vt),t(tt,To),t(tt,Wt),t(Wt,Ft),c(e,Xi,o),c(e,W,o),t(W,pe),t(pe,Ga),_(at,Ga,null),t(W,Po),t(W,za),t(za,qo),c(e,en,o),c(e,ce,o),t(ce,La),t(La,it),t(it,tn),t(it,xo),t(it,Ba),t(ce,jo),t(ce,O),t(O,nt),t(nt,an),t(nt,Ao),t(nt,Yt),t(Yt,Io),t(O,Uo),t(O,lt),t(lt,Ha),t(Ha,Zt),t(lt,Oo),t(lt,Jt),t(Jt,Kt),t(O,Co),t(O,ot),t(ot,nn),t(ot,No),t(ot,Qt),t(Qt,Ro),t(O,So),t(O,rt),t(rt,Va),t(Va,Xt),t(rt,Mo),t(rt,ea),t(ea,ta),c(e,ln,o),c(e,F,o),t(F,fe),t(fe,Wa),_(st,Wa,null),t(F,Go),t(F,Fa),t(Fa,zo),c(e,on,o),c(e,aa,o),t(aa,Lo),c(e,rn,o),c(e,ue,o),t(ue,Ya),t(Ya,Bo),t(ue,Ho),t(ue,pt),t(pt,Vo),t(pt,ct),t(ct,Wo),t(pt,Fo),c(e,sn,o),c(e,ia,o),t(ia,Yo),c(e,pn,o),_(ft,e,o),c(e,cn,o),c(e,Y,o),t(Y,he),t(he,Za),_(ut,Za,null),t(Y,Zo),t(Y,Ja),t(Ja,Jo),c(e,fn,o),c(e,na,o),t(na,Ko),c(e,un,o),c(e,P,o),t(P,Ka),t(Ka,Qo),t(P,Xo),t(P,ht),t(ht,er),t(ht,dt),t(dt,tr),t(ht,ar),t(P,ir),t(P,_t),t(_t,nr),t(_t,mt),t(mt,lr),t(_t,or),t(P,rr),t(P,la),t(la,sr),t(la,Qa),t(Qa,pr),c(e,hn,o),_(gt,e,o),c(e,dn,o),c(e,q,o),t(q,cr),t(q,Xa),t(Xa,fr),t(q,ur),t(q,ei),t(ei,hr),t(q,dr),t(q,ti),t(ti,_r),t(q,mr),c(e,_n,o),c(e,Z,o),t(Z,de),t(de,ai),_(vt,ai,null),t(Z,gr),t(Z,ii),t(ii,vr),c(e,mn,o),c(e,oa,o),t(oa,br),c(e,gn,o),c(e,ra,o),t(ra,wr),c(e,vn,o),c(e,w,o),t(w,ni),t(ni,$r),t(w,Er),t(w,bt),t(bt,yr),t(bt,wt),t(wt,kr),t(bt,Dr),t(w,Tr),t(w,$t),t($t,Pr),t($t,Et),t(Et,qr),t($t,xr),t(w,jr),t(w,sa),t(sa,Ar),t(sa,li),t(li,Ir),t(w,Ur),t(w,oi),t(oi,Or),t(w,Cr),t(w,ri),t(ri,Nr),c(e,bn,o),c(e,yt,o),t(yt,kt),t(kt,Rr),t(yt,Sr),c(e,wn,o),c(e,_e,o),t(_e,Mr),t(_e,si),t(si,Gr),t(_e,zr),c(e,$n,o),c(e,pa,o),t(pa,Lr),c(e,En,o),_(Dt,e,o),c(e,yn,o),c(e,ca,o),t(ca,Br),c(e,kn,o),c(e,me,o),t(me,Hr),t(me,Tt),t(Tt,Vr),t(me,Wr),c(e,Dn,o),c(e,fa,o),t(fa,Fr),c(e,Tn,o),c(e,ge,o),t(ge,Yr),t(ge,pi),t(pi,Zr),t(ge,Jr),c(e,Pn,o),_(Pt,e,o),c(e,qn,o),c(e,J,o),t(J,ve),t(ve,ci),_(qt,ci,null),t(J,Kr),t(J,fi),t(fi,Qr),c(e,xn,o),c(e,$,o),t($,Xr),t($,ua),t(ua,es),t($,ts),t($,ui),t(ui,as),t($,is),t($,hi),t(hi,ns),t($,ls),t($,di),t(di,os),t($,rs),t($,_i),t(_i,ss),t($,ps),c(e,jn,o),_(xt,e,o),An=!0},p(e,[o]){const jt={};o&2&&(jt.$$scope={dirty:o,ctx:e}),ee.$set(jt)},i(e){An||(m(k.$$.fragment,e),m(xe.$$.fragment,e),m(ee.$$.fragment,e),m(je.$$.fragment,e),m(Ae.$$.fragment,e),m(Ue.$$.fragment,e),m(Oe.$$.fragment,e),m(Ce.$$.fragment,e),m(Ne.$$.fragment,e),m(Le.$$.fragment,e),m(Be.$$.fragment,e),m(He.$$.fragment,e),m(Ve.$$.fragment,e),m(We.$$.fragment,e),m(Ye.$$.fragment,e),m(Ze.$$.fragment,e),m(Je.$$.fragment,e),m(at.$$.fragment,e),m(st.$$.fragment,e),m(ft.$$.fragment,e),m(ut.$$.fragment,e),m(gt.$$.fragment,e),m(vt.$$.fragment,e),m(Dt.$$.fragment,e),m(Pt.$$.fragment,e),m(qt.$$.fragment,e),m(xt.$$.fragment,e),An=!0)},o(e){g(k.$$.fragment,e),g(xe.$$.fragment,e),g(ee.$$.fragment,e),g(je.$$.fragment,e),g(Ae.$$.fragment,e),g(Ue.$$.fragment,e),g(Oe.$$.fragment,e),g(Ce.$$.fragment,e),g(Ne.$$.fragment,e),g(Le.$$.fragment,e),g(Be.$$.fragment,e),g(He.$$.fragment,e),g(Ve.$$.fragment,e),g(We.$$.fragment,e),g(Ye.$$.fragment,e),g(Ze.$$.fragment,e),g(Je.$$.fragment,e),g(at.$$.fragment,e),g(st.$$.fragment,e),g(ft.$$.fragment,e),g(ut.$$.fragment,e),g(gt.$$.fragment,e),g(vt.$$.fragment,e),g(Dt.$$.fragment,e),g(Pt.$$.fragment,e),g(qt.$$.fragment,e),g(xt.$$.fragment,e),An=!1},d(e){a(b),e&&a(K),e&&a(E),v(k),e&&a(gi),e&&a(De),e&&a(vi),e&&a(N),e&&a(bi),e&&a(G),v(xe),e&&a(wi),e&&a(It),e&&a($i),v(ee,e),e&&a(Ei),e&&a(Ut),e&&a(yi),v(je,e),e&&a(ki),e&&a(Ot),e&&a(Di),v(Ae,e),e&&a(Ti),e&&a(te),e&&a(Pi),v(Ue,e),e&&a(qi),e&&a(Ct),e&&a(xi),v(Oe,e),e&&a(ji),e&&a(Nt),e&&a(Ai),v(Ce,e),e&&a(Ii),e&&a(z),v(Ne),e&&a(Ui),e&&a(R),e&&a(Oi),e&&a(T),e&&a(Ci),e&&a(L),v(Le),e&&a(Ni),e&&a(Rt),e&&a(Ri),v(Be,e),e&&a(Si),e&&a(S),e&&a(Mi),v(He,e),e&&a(Gi),e&&a(St),e&&a(zi),e&&a(ne),e&&a(Li),e&&a(Mt),e&&a(Bi),v(Ve,e),e&&a(Hi),e&&a(B),v(We),e&&a(Vi),e&&a(I),e&&a(Wi),v(Ye,e),e&&a(Fi),e&&a(H),v(Ze),e&&a(Yi),e&&a(V),v(Je),e&&a(Zi),e&&a(se),e&&a(Xi),e&&a(W),v(at),e&&a(en),e&&a(ce),e&&a(ln),e&&a(F),v(st),e&&a(on),e&&a(aa),e&&a(rn),e&&a(ue),e&&a(sn),e&&a(ia),e&&a(pn),v(ft,e),e&&a(cn),e&&a(Y),v(ut),e&&a(fn),e&&a(na),e&&a(un),e&&a(P),e&&a(hn),v(gt,e),e&&a(dn),e&&a(q),e&&a(_n),e&&a(Z),v(vt),e&&a(mn),e&&a(oa),e&&a(gn),e&&a(ra),e&&a(vn),e&&a(w),e&&a(bn),e&&a(yt),e&&a(wn),e&&a(_e),e&&a($n),e&&a(pa),e&&a(En),v(Dt,e),e&&a(yn),e&&a(ca),e&&a(kn),e&&a(me),e&&a(Dn),e&&a(fa),e&&a(Tn),e&&a(ge),e&&a(Pn),v(Pt,e),e&&a(qn),e&&a(J),v(qt),e&&a(xn),e&&a($),e&&a(jn),v(xt,e)}}}const jc={local:"controlnet",sections:[{local:"installing-the-dependencies",title:"Installing the dependencies"},{local:"circle-filling-dataset",title:"Circle filling dataset"},{local:"training",title:"Training"},{local:"training-with-multiple-gpus",title:"Training with multiple GPUs"},{local:"example-results",sections:[{local:"after-300-steps-with-batch-size-8",title:"After 300 steps with batch size 8"},{local:"after-6000-steps-with-batch-size-8",title:"After 6000 steps with batch size 8:"}],title:"Example results"},{local:"training-on-a-16-gb-gpu",title:"Training on a 16 GB GPU"},{local:"training-on-a-12-gb-gpu",title:"Training on a 12 GB GPU"},{local:"training-on-an-8-gb-gpu",title:"Training on an 8 GB GPU"},{local:"inference",title:"Inference"}],title:"ControlNet"};function Ac(mi){return Tc(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Nc extends Ec{constructor(b){super();yc(this,b,Ac,xc,kc,{})}}export{Nc as default,jc as metadata};
