import{S as gi,i as _i,s as Mi,e as a,k as f,w as d,t as r,M as Ui,c as i,d as t,m as h,a as s,x as u,h as o,b as c,G as l,g as p,y as m,L as Ti,q as y,o as w,B as b,v as Ji}from"../../chunks/vendor-hf-doc-builder.js";import{I as D}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as P}from"../../chunks/CodeBlock-hf-doc-builder.js";function Zi(ga){let J,rt,Z,I,Re,q,tl,We,ll,ot,g,al,je,il,sl,O,nl,rl,K,ol,pl,pt,E,V,ke,ee,cl,Ie,fl,ct,$,B,Ve,te,hl,Be,dl,ft,_e,ul,ht,Me,Xe,ml,dt,X,yl,Ce,wl,bl,ut,le,mt,C,vl,Ae,gl,_l,yt,ae,wt,A,Ml,ie,Ul,Tl,bt,se,vt,Ue,Jl,gt,ne,_t,Te,Zl,Mt,re,Ut,N,El,Ne,$l,Gl,Tt,G,S,Se,oe,Rl,Ye,Wl,Jt,v,jl,pe,kl,Il,xe,Vl,Bl,ce,Xl,Cl,Fe,Al,Nl,Zt,R,Y,He,fe,Sl,ze,Yl,Et,Je,xl,$t,he,Gt,x,Fl,Le,Hl,zl,Rt,de,Wt,Ze,Ll,jt,F,_,Qe,Ql,Dl,De,Pl,ql,Pe,Ol,Kl,ea,M,qe,ta,la,Oe,aa,ia,Ke,sa,na,kt,Ee,ra,It,W,H,et,ue,oa,tt,pa,Vt,$e,ca,Bt,me,Xt,j,z,lt,ye,fa,at,ha,Ct,k,L,it,we,da,st,ua,At,U,ma,nt,ya,wa,be,ba,va,Nt;return q=new D({}),ee=new D({}),te=new D({}),le=new P({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC1lJTIwLg==",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 P({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzX3NkeGwudHh0",highlighted:"pip install -r requirements_sdxl.txt"}}),se=new P({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),ne=new P({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),re=new P({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config
write_basic_config()`}}),oe=new D({}),fe=new D({}),he=new P({props:{code:"d2dldCUyMGh0dHBzJTNBJTJGJTJGaHVnZ2luZ2ZhY2UuY28lMkZkYXRhc2V0cyUyRmh1Z2dpbmdmYWNlJTJGZG9jdW1lbnRhdGlvbi1pbWFnZXMlMkZyZXNvbHZlJTJGbWFpbiUyRmRpZmZ1c2VycyUyRmNvbnRyb2xuZXRfdHJhaW5pbmclMkZjb25kaXRpb25pbmdfaW1hZ2VfMS5wbmclMEElMEF3Z2V0JTIwaHR0cHMlM0ElMkYlMkZodWdnaW5nZmFjZS5jbyUyRmRhdGFzZXRzJTJGaHVnZ2luZ2ZhY2UlMkZkb2N1bWVudGF0aW9uLWltYWdlcyUyRnJlc29sdmUlMkZtYWluJTJGZGlmZnVzZXJzJTJGY29udHJvbG5ldF90cmFpbmluZyUyRmNvbmRpdGlvbmluZ19pbWFnZV8yLnBuZw==",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`}}),de=new P({props:{code:"ZXhwb3J0JTIwTU9ERUxfRElSJTNEJTIyc3R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wcyUzRDQlMjAlNUMlMEElMjAtLXJlcG9ydF90byUzRCUyMndhbmRiJTIyJTIwJTVDJTBBJTIwLS1zZWVkJTNENDIlMjAlNUMlMEElMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_DIR=<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&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_t2i_adapter_sdxl.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 \\
 --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span> \\
 --resolution=1024 \\
 --learning_rate=1e-5 \\
 --max_train_steps=15000 \\
 --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> \\
 --validation_steps=100 \\
 --train_batch_size=1 \\
 --gradient_accumulation_steps=4 \\
 --report_to=<span class="hljs-string">&quot;wandb&quot;</span> \\
 --seed=42 \\
 --push_to_hub`}}),ue=new D({}),me=new P({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblhMQWRhcHRlclBpcGVsaW5lJTJDJTIwVDJJQWRhcHRlciUyQyUyMEV1bGVyQW5jZXN0cmFsRGlzY3JldGVTY2hlZHVsZXJUZXN0JTBBZnJvbSUyMGRpZmZ1c2Vycy51dGlscyUyMGltcG9ydCUyMGxvYWRfaW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQWJhc2VfbW9kZWxfcGF0aCUyMCUzRCUyMCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2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RmNvbmRpdGlvbmluZ19pbWFnZV8xLnBuZyUyMiklMEFwcm9tcHQlMjAlM0QlMjAlMjJwYWxlJTIwZ29sZGVuJTIwcm9kJTIwY2lyY2xlJTIwd2l0aCUyMG9sZCUyMGxhY2UlMjBiYWNrZ3JvdW5kJTIyJTBBJTBBJTIzJTIwZ2VuZXJhdGUlMjBpbWFnZSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLm1hbnVhbF9zZWVkKDApJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyMCUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUyMGltYWdlJTNEY29udHJvbF9pbWFnZSUwQSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyLiUyRm91dHB1dC5wbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionXLAdapterPipeline, T2IAdapter, EulerAncestralDiscreteSchedulerTest
<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;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>
adapter_path = <span class="hljs-string">&quot;path to adapter&quot;</span>

adapter = T2IAdapter.from_pretrained(adapter_path, torch_dtype=torch.float16)
pipe = StableDiffusionXLAdapterPipeline.from_pretrained(
    base_model_path, adapter=adapter, torch_dtype=torch.float16
)

<span class="hljs-comment"># speed up diffusion process with faster scheduler and memory optimization</span>
pipe.scheduler = EulerAncestralDiscreteSchedulerTest.from_config(pipe.scheduler.config)
<span class="hljs-comment"># remove following line if xformers is not installed or when using Torch 2.0.</span>
pipe.enable_xformers_memory_efficient_attention()
<span class="hljs-comment"># memory optimization.</span>
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>)`}}),ye=new D({}),we=new D({}),{c(){J=a("meta"),rt=f(),Z=a("h1"),I=a("a"),Re=a("span"),d(q.$$.fragment),tl=f(),We=a("span"),ll=r("T2I-Adapters for Stable Diffusion XL (SDXL)"),ot=f(),g=a("p"),al=r("The "),je=a("code"),il=r("train_t2i_adapter_sdxl.py"),sl=r(" script (as shown below) shows how to implement the "),O=a("a"),nl=r("T2I-Adapter training procedure"),rl=r(" for "),K=a("a"),ol=r("Stable Diffusion XL"),pl=r("."),pt=f(),E=a("h2"),V=a("a"),ke=a("span"),d(ee.$$.fragment),cl=f(),Ie=a("span"),fl=r("Running locally with PyTorch"),ct=f(),$=a("h3"),B=a("a"),Ve=a("span"),d(te.$$.fragment),hl=f(),Be=a("span"),dl=r("Installing the dependencies"),ft=f(),_e=a("p"),ul=r("Before running the scripts, make sure to install the library\u2019s training dependencies:"),ht=f(),Me=a("p"),Xe=a("strong"),ml=r("Important"),dt=f(),X=a("p"),yl=r("To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),Ce=a("strong"),wl=r("installing from source"),bl=r(" and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:"),ut=f(),d(le.$$.fragment),mt=f(),C=a("p"),vl=r("Then cd in the "),Ae=a("code"),gl=r("examples/t2i_adapter"),_l=r(" folder and run"),yt=f(),d(ae.$$.fragment),wt=f(),A=a("p"),Ml=r("And initialize an "),ie=a("a"),Ul=r("\u{1F917}Accelerate"),Tl=r(" environment with:"),bt=f(),d(se.$$.fragment),vt=f(),Ue=a("p"),Jl=r("Or for a default accelerate configuration without answering questions about your environment"),gt=f(),d(ne.$$.fragment),_t=f(),Te=a("p"),Zl=r("Or if your environment doesn\u2019t support an interactive shell (e.g., a notebook)"),Mt=f(),d(re.$$.fragment),Ut=f(),N=a("p"),El=r("When running "),Ne=a("code"),$l=r("accelerate config"),Gl=r(", if we specify torch compile mode to True there can be dramatic speedups."),Tt=f(),G=a("h2"),S=a("a"),Se=a("span"),d(oe.$$.fragment),Rl=f(),Ye=a("span"),Wl=r("Circle filling dataset"),Jt=f(),v=a("p"),jl=r("The original dataset is hosted in the "),pe=a("a"),kl=r("ControlNet repo"),Il=r(". We re-uploaded it to be compatible with "),xe=a("code"),Vl=r("datasets"),Bl=f(),ce=a("a"),Xl=r("here"),Cl=r(". Note that "),Fe=a("code"),Al=r("datasets"),Nl=r(" handles dataloading within the training script."),Zt=f(),R=a("h2"),Y=a("a"),He=a("span"),d(fe.$$.fragment),Sl=f(),ze=a("span"),Yl=r("Training"),Et=f(),Je=a("p"),xl=r("Our training examples use two test conditioning images. They can be downloaded by running"),$t=f(),d(he.$$.fragment),Gt=f(),x=a("p"),Fl=r("Then run "),Le=a("code"),Hl=r("huggingface-cli login"),zl=r(" to log into your Hugging Face account. This is needed to be able to push the trained T2IAdapter parameters to Hugging Face Hub."),Rt=f(),d(de.$$.fragment),Wt=f(),Ze=a("p"),Ll=r("To better track our training experiments, we\u2019re using the following flags in the command above:"),jt=f(),F=a("ul"),_=a("li"),Qe=a("code"),Ql=r('report_to="wandb'),Dl=r(" will ensure the training runs are tracked on Weights and Biases. To use it, be sure to install "),De=a("code"),Pl=r("wandb"),ql=r(" with "),Pe=a("code"),Ol=r("pip install wandb"),Kl=r("."),ea=f(),M=a("li"),qe=a("code"),ta=r("validation_image"),la=r(", "),Oe=a("code"),aa=r("validation_prompt"),ia=r(", and "),Ke=a("code"),sa=r("validation_steps"),na=r(" to allow the script to do a few validation inference runs. This allows us to qualitatively check if the training is progressing as expected."),kt=f(),Ee=a("p"),ra=r("Our experiments were conducted on a single 40GB A100 GPU."),It=f(),W=a("h3"),H=a("a"),et=a("span"),d(ue.$$.fragment),oa=f(),tt=a("span"),pa=r("Inference"),Vt=f(),$e=a("p"),ca=r("Once training is done, we can perform inference like so:"),Bt=f(),d(me.$$.fragment),Xt=f(),j=a("h2"),z=a("a"),lt=a("span"),d(ye.$$.fragment),fa=f(),at=a("span"),ha=r("Notes"),Ct=f(),k=a("h3"),L=a("a"),it=a("span"),d(we.$$.fragment),da=f(),st=a("span"),ua=r("Specifying a better VAE"),At=f(),U=a("p"),ma=r("SDXL\u2019s VAE is known to suffer from numerical instability issues. This is why we also expose a CLI argument namely "),nt=a("code"),ya=r("--pretrained_vae_model_name_or_path"),wa=r(" that lets you specify the location of a better VAE (such as "),be=a("a"),ba=r("this one"),va=r(")."),this.h()},l(e){const n=Ui('[data-svelte="svelte-1phssyn"]',document.head);J=i(n,"META",{name:!0,content:!0}),n.forEach(t),rt=h(e),Z=i(e,"H1",{class:!0});var St=s(Z);I=i(St,"A",{id:!0,class:!0,href:!0});var _a=s(I);Re=i(_a,"SPAN",{});var Ma=s(Re);u(q.$$.fragment,Ma),Ma.forEach(t),_a.forEach(t),tl=h(St),We=i(St,"SPAN",{});var Ua=s(We);ll=o(Ua,"T2I-Adapters for Stable Diffusion XL (SDXL)"),Ua.forEach(t),St.forEach(t),ot=h(e),g=i(e,"P",{});var Q=s(g);al=o(Q,"The "),je=i(Q,"CODE",{});var Ta=s(je);il=o(Ta,"train_t2i_adapter_sdxl.py"),Ta.forEach(t),sl=o(Q," script (as shown below) shows how to implement the "),O=i(Q,"A",{href:!0,rel:!0});var Ja=s(O);nl=o(Ja,"T2I-Adapter training procedure"),Ja.forEach(t),rl=o(Q," for "),K=i(Q,"A",{href:!0,rel:!0});var Za=s(K);ol=o(Za,"Stable Diffusion XL"),Za.forEach(t),pl=o(Q,"."),Q.forEach(t),pt=h(e),E=i(e,"H2",{class:!0});var Yt=s(E);V=i(Yt,"A",{id:!0,class:!0,href:!0});var Ea=s(V);ke=i(Ea,"SPAN",{});var $a=s(ke);u(ee.$$.fragment,$a),$a.forEach(t),Ea.forEach(t),cl=h(Yt),Ie=i(Yt,"SPAN",{});var Ga=s(Ie);fl=o(Ga,"Running locally with PyTorch"),Ga.forEach(t),Yt.forEach(t),ct=h(e),$=i(e,"H3",{class:!0});var xt=s($);B=i(xt,"A",{id:!0,class:!0,href:!0});var Ra=s(B);Ve=i(Ra,"SPAN",{});var Wa=s(Ve);u(te.$$.fragment,Wa),Wa.forEach(t),Ra.forEach(t),hl=h(xt),Be=i(xt,"SPAN",{});var ja=s(Be);dl=o(ja,"Installing the dependencies"),ja.forEach(t),xt.forEach(t),ft=h(e),_e=i(e,"P",{});var ka=s(_e);ul=o(ka,"Before running the scripts, make sure to install the library\u2019s training dependencies:"),ka.forEach(t),ht=h(e),Me=i(e,"P",{});var Ia=s(Me);Xe=i(Ia,"STRONG",{});var Va=s(Xe);ml=o(Va,"Important"),Va.forEach(t),Ia.forEach(t),dt=h(e),X=i(e,"P",{});var Ft=s(X);yl=o(Ft,"To make sure you can successfully run the latest versions of the example scripts, we highly recommend "),Ce=i(Ft,"STRONG",{});var Ba=s(Ce);wl=o(Ba,"installing from source"),Ba.forEach(t),bl=o(Ft," and keeping the install up to date as we update the example scripts frequently and install some example-specific requirements. To do this, execute the following steps in a new virtual environment:"),Ft.forEach(t),ut=h(e),u(le.$$.fragment,e),mt=h(e),C=i(e,"P",{});var Ht=s(C);vl=o(Ht,"Then cd in the "),Ae=i(Ht,"CODE",{});var Xa=s(Ae);gl=o(Xa,"examples/t2i_adapter"),Xa.forEach(t),_l=o(Ht," folder and run"),Ht.forEach(t),yt=h(e),u(ae.$$.fragment,e),wt=h(e),A=i(e,"P",{});var zt=s(A);Ml=o(zt,"And initialize an "),ie=i(zt,"A",{href:!0,rel:!0});var Ca=s(ie);Ul=o(Ca,"\u{1F917}Accelerate"),Ca.forEach(t),Tl=o(zt," environment with:"),zt.forEach(t),bt=h(e),u(se.$$.fragment,e),vt=h(e),Ue=i(e,"P",{});var Aa=s(Ue);Jl=o(Aa,"Or for a default accelerate configuration without answering questions about your environment"),Aa.forEach(t),gt=h(e),u(ne.$$.fragment,e),_t=h(e),Te=i(e,"P",{});var Na=s(Te);Zl=o(Na,"Or if your environment doesn\u2019t support an interactive shell (e.g., a notebook)"),Na.forEach(t),Mt=h(e),u(re.$$.fragment,e),Ut=h(e),N=i(e,"P",{});var Lt=s(N);El=o(Lt,"When running "),Ne=i(Lt,"CODE",{});var Sa=s(Ne);$l=o(Sa,"accelerate config"),Sa.forEach(t),Gl=o(Lt,", if we specify torch compile mode to True there can be dramatic speedups."),Lt.forEach(t),Tt=h(e),G=i(e,"H2",{class:!0});var Qt=s(G);S=i(Qt,"A",{id:!0,class:!0,href:!0});var Ya=s(S);Se=i(Ya,"SPAN",{});var xa=s(Se);u(oe.$$.fragment,xa),xa.forEach(t),Ya.forEach(t),Rl=h(Qt),Ye=i(Qt,"SPAN",{});var Fa=s(Ye);Wl=o(Fa,"Circle filling dataset"),Fa.forEach(t),Qt.forEach(t),Jt=h(e),v=i(e,"P",{});var T=s(v);jl=o(T,"The original dataset is hosted in the "),pe=i(T,"A",{href:!0,rel:!0});var Ha=s(pe);kl=o(Ha,"ControlNet repo"),Ha.forEach(t),Il=o(T,". We re-uploaded it to be compatible with "),xe=i(T,"CODE",{});var za=s(xe);Vl=o(za,"datasets"),za.forEach(t),Bl=h(T),ce=i(T,"A",{href:!0,rel:!0});var La=s(ce);Xl=o(La,"here"),La.forEach(t),Cl=o(T,". Note that "),Fe=i(T,"CODE",{});var Qa=s(Fe);Al=o(Qa,"datasets"),Qa.forEach(t),Nl=o(T," handles dataloading within the training script."),T.forEach(t),Zt=h(e),R=i(e,"H2",{class:!0});var Dt=s(R);Y=i(Dt,"A",{id:!0,class:!0,href:!0});var Da=s(Y);He=i(Da,"SPAN",{});var Pa=s(He);u(fe.$$.fragment,Pa),Pa.forEach(t),Da.forEach(t),Sl=h(Dt),ze=i(Dt,"SPAN",{});var qa=s(ze);Yl=o(qa,"Training"),qa.forEach(t),Dt.forEach(t),Et=h(e),Je=i(e,"P",{});var Oa=s(Je);xl=o(Oa,"Our training examples use two test conditioning images. They can be downloaded by running"),Oa.forEach(t),$t=h(e),u(he.$$.fragment,e),Gt=h(e),x=i(e,"P",{});var Pt=s(x);Fl=o(Pt,"Then run "),Le=i(Pt,"CODE",{});var Ka=s(Le);Hl=o(Ka,"huggingface-cli login"),Ka.forEach(t),zl=o(Pt," to log into your Hugging Face account. This is needed to be able to push the trained T2IAdapter parameters to Hugging Face Hub."),Pt.forEach(t),Rt=h(e),u(de.$$.fragment,e),Wt=h(e),Ze=i(e,"P",{});var ei=s(Ze);Ll=o(ei,"To better track our training experiments, we\u2019re using the following flags in the command above:"),ei.forEach(t),jt=h(e),F=i(e,"UL",{});var qt=s(F);_=i(qt,"LI",{});var ve=s(_);Qe=i(ve,"CODE",{});var ti=s(Qe);Ql=o(ti,'report_to="wandb'),ti.forEach(t),Dl=o(ve," will ensure the training runs are tracked on Weights and Biases. To use it, be sure to install "),De=i(ve,"CODE",{});var li=s(De);Pl=o(li,"wandb"),li.forEach(t),ql=o(ve," with "),Pe=i(ve,"CODE",{});var ai=s(Pe);Ol=o(ai,"pip install wandb"),ai.forEach(t),Kl=o(ve,"."),ve.forEach(t),ea=h(qt),M=i(qt,"LI",{});var ge=s(M);qe=i(ge,"CODE",{});var ii=s(qe);ta=o(ii,"validation_image"),ii.forEach(t),la=o(ge,", "),Oe=i(ge,"CODE",{});var si=s(Oe);aa=o(si,"validation_prompt"),si.forEach(t),ia=o(ge,", and "),Ke=i(ge,"CODE",{});var ni=s(Ke);sa=o(ni,"validation_steps"),ni.forEach(t),na=o(ge," to allow the script to do a few validation inference runs. This allows us to qualitatively check if the training is progressing as expected."),ge.forEach(t),qt.forEach(t),kt=h(e),Ee=i(e,"P",{});var ri=s(Ee);ra=o(ri,"Our experiments were conducted on a single 40GB A100 GPU."),ri.forEach(t),It=h(e),W=i(e,"H3",{class:!0});var Ot=s(W);H=i(Ot,"A",{id:!0,class:!0,href:!0});var oi=s(H);et=i(oi,"SPAN",{});var pi=s(et);u(ue.$$.fragment,pi),pi.forEach(t),oi.forEach(t),oa=h(Ot),tt=i(Ot,"SPAN",{});var ci=s(tt);pa=o(ci,"Inference"),ci.forEach(t),Ot.forEach(t),Vt=h(e),$e=i(e,"P",{});var fi=s($e);ca=o(fi,"Once training is done, we can perform inference like so:"),fi.forEach(t),Bt=h(e),u(me.$$.fragment,e),Xt=h(e),j=i(e,"H2",{class:!0});var Kt=s(j);z=i(Kt,"A",{id:!0,class:!0,href:!0});var hi=s(z);lt=i(hi,"SPAN",{});var di=s(lt);u(ye.$$.fragment,di),di.forEach(t),hi.forEach(t),fa=h(Kt),at=i(Kt,"SPAN",{});var ui=s(at);ha=o(ui,"Notes"),ui.forEach(t),Kt.forEach(t),Ct=h(e),k=i(e,"H3",{class:!0});var el=s(k);L=i(el,"A",{id:!0,class:!0,href:!0});var mi=s(L);it=i(mi,"SPAN",{});var yi=s(it);u(we.$$.fragment,yi),yi.forEach(t),mi.forEach(t),da=h(el),st=i(el,"SPAN",{});var wi=s(st);ua=o(wi,"Specifying a better VAE"),wi.forEach(t),el.forEach(t),At=h(e),U=i(e,"P",{});var Ge=s(U);ma=o(Ge,"SDXL\u2019s VAE is known to suffer from numerical instability issues. This is why we also expose a CLI argument namely "),nt=i(Ge,"CODE",{});var bi=s(nt);ya=o(bi,"--pretrained_vae_model_name_or_path"),bi.forEach(t),wa=o(Ge," that lets you specify the location of a better VAE (such as "),be=i(Ge,"A",{href:!0,rel:!0});var vi=s(be);ba=o(vi,"this one"),vi.forEach(t),va=o(Ge,")."),Ge.forEach(t),this.h()},h(){c(J,"name","hf:doc:metadata"),c(J,"content",JSON.stringify(Ei)),c(I,"id","t2iadapters-for-stable-diffusion-xl-sdxl"),c(I,"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"),c(I,"href","#t2iadapters-for-stable-diffusion-xl-sdxl"),c(Z,"class","relative group"),c(O,"href","https://hf.co/papers/2302.08453"),c(O,"rel","nofollow"),c(K,"href","https://huggingface.co/papers/2307.01952"),c(K,"rel","nofollow"),c(V,"id","running-locally-with-pytorch"),c(V,"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"),c(V,"href","#running-locally-with-pytorch"),c(E,"class","relative group"),c(B,"id","installing-the-dependencies"),c(B,"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"),c(B,"href","#installing-the-dependencies"),c($,"class","relative group"),c(ie,"href","https://github.com/huggingface/accelerate/"),c(ie,"rel","nofollow"),c(S,"id","circle-filling-dataset"),c(S,"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"),c(S,"href","#circle-filling-dataset"),c(G,"class","relative group"),c(pe,"href","https://huggingface.co/lllyasviel/ControlNet/blob/main/training/fill50k.zip"),c(pe,"rel","nofollow"),c(ce,"href","https://huggingface.co/datasets/fusing/fill50k"),c(ce,"rel","nofollow"),c(Y,"id","training"),c(Y,"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"),c(Y,"href","#training"),c(R,"class","relative group"),c(H,"id","inference"),c(H,"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"),c(H,"href","#inference"),c(W,"class","relative group"),c(z,"id","notes"),c(z,"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"),c(z,"href","#notes"),c(j,"class","relative group"),c(L,"id","specifying-a-better-vae"),c(L,"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"),c(L,"href","#specifying-a-better-vae"),c(k,"class","relative group"),c(be,"href","https://huggingface.co/madebyollin/sdxl-vae-fp16-fix"),c(be,"rel","nofollow")},m(e,n){l(document.head,J),p(e,rt,n),p(e,Z,n),l(Z,I),l(I,Re),m(q,Re,null),l(Z,tl),l(Z,We),l(We,ll),p(e,ot,n),p(e,g,n),l(g,al),l(g,je),l(je,il),l(g,sl),l(g,O),l(O,nl),l(g,rl),l(g,K),l(K,ol),l(g,pl),p(e,pt,n),p(e,E,n),l(E,V),l(V,ke),m(ee,ke,null),l(E,cl),l(E,Ie),l(Ie,fl),p(e,ct,n),p(e,$,n),l($,B),l(B,Ve),m(te,Ve,null),l($,hl),l($,Be),l(Be,dl),p(e,ft,n),p(e,_e,n),l(_e,ul),p(e,ht,n),p(e,Me,n),l(Me,Xe),l(Xe,ml),p(e,dt,n),p(e,X,n),l(X,yl),l(X,Ce),l(Ce,wl),l(X,bl),p(e,ut,n),m(le,e,n),p(e,mt,n),p(e,C,n),l(C,vl),l(C,Ae),l(Ae,gl),l(C,_l),p(e,yt,n),m(ae,e,n),p(e,wt,n),p(e,A,n),l(A,Ml),l(A,ie),l(ie,Ul),l(A,Tl),p(e,bt,n),m(se,e,n),p(e,vt,n),p(e,Ue,n),l(Ue,Jl),p(e,gt,n),m(ne,e,n),p(e,_t,n),p(e,Te,n),l(Te,Zl),p(e,Mt,n),m(re,e,n),p(e,Ut,n),p(e,N,n),l(N,El),l(N,Ne),l(Ne,$l),l(N,Gl),p(e,Tt,n),p(e,G,n),l(G,S),l(S,Se),m(oe,Se,null),l(G,Rl),l(G,Ye),l(Ye,Wl),p(e,Jt,n),p(e,v,n),l(v,jl),l(v,pe),l(pe,kl),l(v,Il),l(v,xe),l(xe,Vl),l(v,Bl),l(v,ce),l(ce,Xl),l(v,Cl),l(v,Fe),l(Fe,Al),l(v,Nl),p(e,Zt,n),p(e,R,n),l(R,Y),l(Y,He),m(fe,He,null),l(R,Sl),l(R,ze),l(ze,Yl),p(e,Et,n),p(e,Je,n),l(Je,xl),p(e,$t,n),m(he,e,n),p(e,Gt,n),p(e,x,n),l(x,Fl),l(x,Le),l(Le,Hl),l(x,zl),p(e,Rt,n),m(de,e,n),p(e,Wt,n),p(e,Ze,n),l(Ze,Ll),p(e,jt,n),p(e,F,n),l(F,_),l(_,Qe),l(Qe,Ql),l(_,Dl),l(_,De),l(De,Pl),l(_,ql),l(_,Pe),l(Pe,Ol),l(_,Kl),l(F,ea),l(F,M),l(M,qe),l(qe,ta),l(M,la),l(M,Oe),l(Oe,aa),l(M,ia),l(M,Ke),l(Ke,sa),l(M,na),p(e,kt,n),p(e,Ee,n),l(Ee,ra),p(e,It,n),p(e,W,n),l(W,H),l(H,et),m(ue,et,null),l(W,oa),l(W,tt),l(tt,pa),p(e,Vt,n),p(e,$e,n),l($e,ca),p(e,Bt,n),m(me,e,n),p(e,Xt,n),p(e,j,n),l(j,z),l(z,lt),m(ye,lt,null),l(j,fa),l(j,at),l(at,ha),p(e,Ct,n),p(e,k,n),l(k,L),l(L,it),m(we,it,null),l(k,da),l(k,st),l(st,ua),p(e,At,n),p(e,U,n),l(U,ma),l(U,nt),l(nt,ya),l(U,wa),l(U,be),l(be,ba),l(U,va),Nt=!0},p:Ti,i(e){Nt||(y(q.$$.fragment,e),y(ee.$$.fragment,e),y(te.$$.fragment,e),y(le.$$.fragment,e),y(ae.$$.fragment,e),y(se.$$.fragment,e),y(ne.$$.fragment,e),y(re.$$.fragment,e),y(oe.$$.fragment,e),y(fe.$$.fragment,e),y(he.$$.fragment,e),y(de.$$.fragment,e),y(ue.$$.fragment,e),y(me.$$.fragment,e),y(ye.$$.fragment,e),y(we.$$.fragment,e),Nt=!0)},o(e){w(q.$$.fragment,e),w(ee.$$.fragment,e),w(te.$$.fragment,e),w(le.$$.fragment,e),w(ae.$$.fragment,e),w(se.$$.fragment,e),w(ne.$$.fragment,e),w(re.$$.fragment,e),w(oe.$$.fragment,e),w(fe.$$.fragment,e),w(he.$$.fragment,e),w(de.$$.fragment,e),w(ue.$$.fragment,e),w(me.$$.fragment,e),w(ye.$$.fragment,e),w(we.$$.fragment,e),Nt=!1},d(e){t(J),e&&t(rt),e&&t(Z),b(q),e&&t(ot),e&&t(g),e&&t(pt),e&&t(E),b(ee),e&&t(ct),e&&t($),b(te),e&&t(ft),e&&t(_e),e&&t(ht),e&&t(Me),e&&t(dt),e&&t(X),e&&t(ut),b(le,e),e&&t(mt),e&&t(C),e&&t(yt),b(ae,e),e&&t(wt),e&&t(A),e&&t(bt),b(se,e),e&&t(vt),e&&t(Ue),e&&t(gt),b(ne,e),e&&t(_t),e&&t(Te),e&&t(Mt),b(re,e),e&&t(Ut),e&&t(N),e&&t(Tt),e&&t(G),b(oe),e&&t(Jt),e&&t(v),e&&t(Zt),e&&t(R),b(fe),e&&t(Et),e&&t(Je),e&&t($t),b(he,e),e&&t(Gt),e&&t(x),e&&t(Rt),b(de,e),e&&t(Wt),e&&t(Ze),e&&t(jt),e&&t(F),e&&t(kt),e&&t(Ee),e&&t(It),e&&t(W),b(ue),e&&t(Vt),e&&t($e),e&&t(Bt),b(me,e),e&&t(Xt),e&&t(j),b(ye),e&&t(Ct),e&&t(k),b(we),e&&t(At),e&&t(U)}}}const Ei={local:"t2iadapters-for-stable-diffusion-xl-sdxl",sections:[{local:"running-locally-with-pytorch",sections:[{local:"installing-the-dependencies",title:"Installing the dependencies"}],title:"Running locally with PyTorch"},{local:"circle-filling-dataset",title:"Circle filling dataset"},{local:"training",sections:[{local:"inference",title:"Inference"}],title:"Training"},{local:"notes",sections:[{local:"specifying-a-better-vae",title:"Specifying a better VAE"}],title:"Notes"}],title:"T2I-Adapters for Stable Diffusion XL (SDXL)"};function $i(ga){return Ji(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ji extends gi{constructor(J){super();_i(this,J,$i,Zi,Mi,{})}}export{ji as default,Ei as metadata};
