import{S as Km,i as ew,s as tw,e as s,k as h,w as M,t as a,M as lw,c as r,d as l,m as u,a as n,x as v,h as o,b as p,N as aw,G as t,g as f,y as J,q as T,o as E,B as U,v as ow,L as sw}from"../../chunks/vendor-hf-doc-builder.js";import{T as Te}from"../../chunks/Tip-hf-doc-builder.js";import{I as F}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as X}from"../../chunks/CodeBlock-hf-doc-builder.js";function rw(B){let c,b;return{c(){c=s("p"),b=a("This is an experimental feature. Its APIs can change in future.")},l(d){c=r(d,"P",{});var y=n(c);b=o(y,"This is an experimental feature. Its APIs can change in future."),y.forEach(l)},m(d,y){f(d,c,y),t(c,b)},d(d){d&&l(c)}}}function nw(B){let c,b,d,y,$;return{c(){c=s("p"),b=a(`\u{1F4A1} LoRA is not only limited to attention layers. The authors found that amending
the attention layers of a language model is sufficient to obtain good downstream performance with great efficiency. This is why it\u2019s common to just add the LoRA weights to the attention layers of a model. Check out the `),d=s("a"),y=a("Using LoRA for efficient Stable Diffusion fine-tuning"),$=a(" blog for more information about how LoRA works!"),this.h()},l(m){c=r(m,"P",{});var _=n(c);b=o(_,`\u{1F4A1} LoRA is not only limited to attention layers. The authors found that amending
the attention layers of a language model is sufficient to obtain good downstream performance with great efficiency. This is why it\u2019s common to just add the LoRA weights to the attention layers of a model. Check out the `),d=r(_,"A",{href:!0,rel:!0});var I=n(d);y=o(I,"Using LoRA for efficient Stable Diffusion fine-tuning"),I.forEach(l),$=o(_," blog for more information about how LoRA works!"),_.forEach(l),this.h()},h(){p(d,"href","https://huggingface.co/blog/lora"),p(d,"rel","nofollow")},m(m,_){f(m,c,_),t(c,b),t(c,d),t(d,y),t(c,$)},d(m){m&&l(c)}}}function iw(B){let c,b,d,y,$,m,_,I,g,w,k,j,R,V,W,Q,Y,N,z,D;return{c(){c=s("p"),b=a("\u{1F4A1} A "),d=s("code"),y=a("scale"),$=a(" value of "),m=s("code"),_=a("0"),I=a(" is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),g=s("code"),w=a("scale"),k=a(" value of "),j=s("code"),R=a("1"),V=a(" means you\u2019re only using the fully finetuned LoRA weights. Values between "),W=s("code"),Q=a("0"),Y=a(" and "),N=s("code"),z=a("1"),D=a(" interpolates between the two weights.")},l(A){c=r(A,"P",{});var Z=n(c);b=o(Z,"\u{1F4A1} A "),d=r(Z,"CODE",{});var q=n(d);y=o(q,"scale"),q.forEach(l),$=o(Z," value of "),m=r(Z,"CODE",{});var G=n(m);_=o(G,"0"),G.forEach(l),I=o(Z," is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),g=r(Z,"CODE",{});var C=n(g);w=o(C,"scale"),C.forEach(l),k=o(Z," value of "),j=r(Z,"CODE",{});var K=n(j);R=o(K,"1"),K.forEach(l),V=o(Z," means you\u2019re only using the fully finetuned LoRA weights. Values between "),W=r(Z,"CODE",{});var L=n(W);Q=o(L,"0"),L.forEach(l),Y=o(Z," and "),N=r(Z,"CODE",{});var ee=n(N);z=o(ee,"1"),ee.forEach(l),D=o(Z," interpolates between the two weights."),Z.forEach(l)},m(A,Z){f(A,c,Z),t(c,b),t(c,d),t(d,y),t(c,$),t(c,m),t(m,_),t(c,I),t(c,g),t(g,w),t(c,k),t(c,j),t(j,R),t(c,V),t(c,W),t(W,Q),t(c,Y),t(c,N),t(N,z),t(c,D)},d(A){A&&l(c)}}}function fw(B){let c,b,d,y,$,m,_,I,g,w,k;return w=new X({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1Yi5yZXBvY2FyZCUyMGltcG9ydCUyMFJlcG9DYXJkJTBBJTBBbG9yYV9tb2RlbF9pZCUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRnNkLW1vZGVsLWZpbmV0dW5lZC1sb3JhLXQ0JTIyJTBBY2FyZCUyMCUzRCUyMFJlcG9DYXJkLmxvYWQobG9yYV9tb2RlbF9pZCklMEFiYXNlX21vZGVsX2lkJTIwJTNEJTIwY2FyZC5kYXRhLnRvX2RpY3QoKSU1QiUyMmJhc2VfbW9kZWwlMjIlNUQlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQS4uLg==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub.repocard <span class="hljs-keyword">import</span> RepoCard

lora_model_id = <span class="hljs-string">&quot;sayakpaul/sd-model-finetuned-lora-t4&quot;</span>
card = RepoCard.load(lora_model_id)
base_model_id = card.data.to_dict()[<span class="hljs-string">&quot;base_model&quot;</span>]

pipe = StableDiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
...`}}),{c(){c=s("p"),b=a(`If you are loading the LoRA parameters from the Hub and if the Hub repository has
a `),d=s("code"),y=a("base_model"),$=a(" tag (such as "),m=s("a"),_=a("this"),I=a(`), then
you can do:`),g=h(),M(w.$$.fragment),this.h()},l(j){c=r(j,"P",{});var R=n(c);b=o(R,`If you are loading the LoRA parameters from the Hub and if the Hub repository has
a `),d=r(R,"CODE",{});var V=n(d);y=o(V,"base_model"),V.forEach(l),$=o(R," tag (such as "),m=r(R,"A",{href:!0,rel:!0});var W=n(m);_=o(W,"this"),W.forEach(l),I=o(R,`), then
you can do:`),R.forEach(l),g=u(j),v(w.$$.fragment,j),this.h()},h(){p(m,"href","https://huggingface.co/sayakpaul/sd-model-finetuned-lora-t4/blob/main/README.md?code=true#L4"),p(m,"rel","nofollow")},m(j,R){f(j,c,R),t(c,b),t(c,d),t(d,y),t(c,$),t(c,m),t(m,_),t(c,I),f(j,g,R),J(w,j,R),k=!0},p:sw,i(j){k||(T(w.$$.fragment,j),k=!0)},o(j){E(w.$$.fragment,j),k=!1},d(j){j&&l(c),j&&l(g),U(w,j)}}}function pw(B){let c,b,d,y,$;return{c(){c=s("p"),b=a("\u{1F4A1} Take a look at the "),d=s("a"),y=a("Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),$=a(" blog for an in-depth analysis of DreamBooth experiments and recommended settings."),this.h()},l(m){c=r(m,"P",{});var _=n(c);b=o(_,"\u{1F4A1} Take a look at the "),d=r(_,"A",{href:!0,rel:!0});var I=n(d);y=o(I,"Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),I.forEach(l),$=o(_," blog for an in-depth analysis of DreamBooth experiments and recommended settings."),_.forEach(l),this.h()},h(){p(d,"href","https://huggingface.co/blog/dreambooth"),p(d,"rel","nofollow")},m(m,_){f(m,c,_),t(c,b),t(c,d),t(d,y),t(c,$)},d(m){m&&l(c)}}}function hw(B){let c,b,d,y,$,m,_,I,g,w,k,j,R,V,W,Q,Y,N,z,D;return{c(){c=s("p"),b=a("\u{1F4A1} A "),d=s("code"),y=a("scale"),$=a(" value of "),m=s("code"),_=a("0"),I=a(" is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),g=s("code"),w=a("scale"),k=a(" value of "),j=s("code"),R=a("1"),V=a(" means you\u2019re only using the fully finetuned LoRA weights. Values between "),W=s("code"),Q=a("0"),Y=a(" and "),N=s("code"),z=a("1"),D=a(" interpolates between the two weights.")},l(A){c=r(A,"P",{});var Z=n(c);b=o(Z,"\u{1F4A1} A "),d=r(Z,"CODE",{});var q=n(d);y=o(q,"scale"),q.forEach(l),$=o(Z," value of "),m=r(Z,"CODE",{});var G=n(m);_=o(G,"0"),G.forEach(l),I=o(Z," is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),g=r(Z,"CODE",{});var C=n(g);w=o(C,"scale"),C.forEach(l),k=o(Z," value of "),j=r(Z,"CODE",{});var K=n(j);R=o(K,"1"),K.forEach(l),V=o(Z," means you\u2019re only using the fully finetuned LoRA weights. Values between "),W=r(Z,"CODE",{});var L=n(W);Q=o(L,"0"),L.forEach(l),Y=o(Z," and "),N=r(Z,"CODE",{});var ee=n(N);z=o(ee,"1"),ee.forEach(l),D=o(Z," interpolates between the two weights."),Z.forEach(l)},m(A,Z){f(A,c,Z),t(c,b),t(c,d),t(d,y),t(c,$),t(c,m),t(m,_),t(c,I),t(c,g),t(g,w),t(c,k),t(c,j),t(j,R),t(c,V),t(c,W),t(W,Q),t(c,Y),t(c,N),t(N,z),t(c,D)},d(A){A&&l(c)}}}function uw(B){let c,b,d,y,$,m,_,I;return{c(){c=s("p"),b=a(`If your LoRA parameters involve the UNet as well as the Text Encoder, then passing
`),d=s("code"),y=a('cross_attention_kwargs={"scale": 0.5}'),$=a(" will apply the "),m=s("code"),_=a("scale"),I=a(` value to both the UNet
and the Text Encoder.`)},l(g){c=r(g,"P",{});var w=n(c);b=o(w,`If your LoRA parameters involve the UNet as well as the Text Encoder, then passing
`),d=r(w,"CODE",{});var k=n(d);y=o(k,'cross_attention_kwargs={"scale": 0.5}'),k.forEach(l),$=o(w," will apply the "),m=r(w,"CODE",{});var j=n(m);_=o(j,"scale"),j.forEach(l),I=o(w,` value to both the UNet
and the Text Encoder.`),w.forEach(l)},m(g,w){f(g,c,w),t(c,b),t(c,d),t(d,y),t(c,$),t(c,m),t(m,_),t(c,I)},d(g){g&&l(c)}}}function cw(B){let c,b,d,y,$,m,_,I;return{c(){c=s("p"),b=a("You can also provide a local directory path to "),d=s("a"),y=a("load_lora_weights()"),$=a(" as well as "),m=s("a"),_=a("load_attn_procs()"),I=a("."),this.h()},l(g){c=r(g,"P",{});var w=n(c);b=o(w,"You can also provide a local directory path to "),d=r(w,"A",{href:!0});var k=n(d);y=o(k,"load_lora_weights()"),k.forEach(l),$=o(w," as well as "),m=r(w,"A",{href:!0});var j=n(m);_=o(j,"load_attn_procs()"),j.forEach(l),I=o(w,"."),w.forEach(l),this.h()},h(){p(d,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(m,"href","/docs/diffusers/v0.21.0/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs")},m(g,w){f(g,c,w),t(c,b),t(c,d),t(d,y),t(c,$),t(c,m),t(m,_),t(c,I)},d(g){g&&l(c)}}}function dw(B){let c,b,d,y,$,m,_,I;return{c(){c=s("p"),b=a("If you\u2019re loading a checkpoint in the "),d=s("code"),y=a("safetensors"),$=a(" format, please ensure you have "),m=s("code"),_=a("safetensors"),I=a(" installed.")},l(g){c=r(g,"P",{});var w=n(c);b=o(w,"If you\u2019re loading a checkpoint in the "),d=r(w,"CODE",{});var k=n(d);y=o(k,"safetensors"),k.forEach(l),$=o(w," format, please ensure you have "),m=r(w,"CODE",{});var j=n(m);_=o(j,"safetensors"),j.forEach(l),I=o(w," installed."),w.forEach(l)},m(g,w){f(g,c,w),t(c,b),t(c,d),t(d,y),t(c,$),t(c,m),t(m,_),t(c,I)},d(g){g&&l(c)}}}function mw(B){let c,b,d,y,$,m,_,I,g,w,k,j,R,V,W,Q,Y,N,z,D;return{c(){c=s("p"),b=s("strong"),d=a("Known limitations specific to the Kohya LoRAs"),y=a(":"),$=h(),m=s("ul"),_=s("li"),I=a("When images don\u2019t looks similar to other UIs, such as ComfyUI, it can be because of multiple reasons, as explained "),g=s("a"),w=a("here"),k=a("."),j=h(),R=s("li"),V=a("We don\u2019t fully support "),W=s("a"),Q=a("LyCORIS checkpoints"),Y=a(". To the best of our knowledge, our current "),N=s("code"),z=a("load_lora_weights()"),D=a(" should support LyCORIS checkpoints that have LoRA and LoCon modules but not the other ones, such as Hada, LoKR, etc."),this.h()},l(A){c=r(A,"P",{});var Z=n(c);b=r(Z,"STRONG",{});var q=n(b);d=o(q,"Known limitations specific to the Kohya LoRAs"),q.forEach(l),y=o(Z,":"),Z.forEach(l),$=u(A),m=r(A,"UL",{});var G=n(m);_=r(G,"LI",{});var C=n(_);I=o(C,"When images don\u2019t looks similar to other UIs, such as ComfyUI, it can be because of multiple reasons, as explained "),g=r(C,"A",{href:!0,rel:!0});var K=n(g);w=o(K,"here"),K.forEach(l),k=o(C,"."),C.forEach(l),j=u(G),R=r(G,"LI",{});var L=n(R);V=o(L,"We don\u2019t fully support "),W=r(L,"A",{href:!0,rel:!0});var ee=n(W);Q=o(ee,"LyCORIS checkpoints"),ee.forEach(l),Y=o(L,". To the best of our knowledge, our current "),N=r(L,"CODE",{});var ea=n(N);z=o(ea,"load_lora_weights()"),ea.forEach(l),D=o(L," should support LyCORIS checkpoints that have LoRA and LoCon modules but not the other ones, such as Hada, LoKR, etc."),L.forEach(l),G.forEach(l),this.h()},h(){p(g,"href","https://github.com/huggingface/diffusers/pull/4287/#issuecomment-1655110736"),p(g,"rel","nofollow"),p(W,"href","https://github.com/KohakuBlueleaf/LyCORIS"),p(W,"rel","nofollow")},m(A,Z){f(A,c,Z),t(c,b),t(b,d),t(c,y),f(A,$,Z),f(A,m,Z),t(m,_),t(_,I),t(_,g),t(g,w),t(_,k),t(m,j),t(m,R),t(R,V),t(R,W),t(W,Q),t(R,Y),t(R,N),t(N,z),t(R,D)},d(A){A&&l(c),A&&l($),A&&l(m)}}}function ww(B){let c,b,d,y,$,m,_,I,g,w,k,j,R,V,W,Q,Y,N,z,D,A,Z,q,G,C,K,L,ee,ea,ti,Pa,li,ai,Ee,oi,ta,si,ri,qa,ni,ii,fi,Oa,pi,Vs,Ye,Ns,O,Wt,hi,ui,Gt,ci,di,Bt,mi,wi,Vt,yi,_i,Ls,De,bi,la,gi,Mi,Xs,Nt,Cs,Ue,xe,Ka,Lt,vi,eo,Ji,Ss,aa,Ti,Ys,je,Fe,to,Xt,Ei,lo,Ui,Ds,ne,ji,Ct,ao,Zi,$i,St,Ri,Ii,xs,H,ki,oo,Ai,Wi,Yt,so,Gi,Bi,ro,Vi,Ni,oa,Li,Xi,Fs,ie,Ci,no,Si,Yi,io,Di,xi,Qs,Dt,zs,sa,Fi,Hs,fe,ra,fo,Qi,zi,Hi,Qe,po,Pi,qi,xt,Oi,Ki,ef,na,ho,tf,lf,Ps,pe,af,Ft,of,sf,uo,rf,nf,qs,Qt,Os,Ze,ze,co,zt,ff,mo,pf,Ks,he,hf,ia,uf,cf,fa,df,mf,er,Ht,tr,ue,wf,wo,yf,_f,yo,bf,gf,lr,He,ar,Pt,or,Pe,sr,$e,qe,_o,qt,Mf,bo,vf,rr,Ot,Kt,Jf,Tf,nr,Oe,ir,Re,Ke,go,el,Ef,Mo,Uf,fr,te,jf,tl,vo,Zf,$f,ll,Rf,If,pa,kf,Af,pr,le,Wf,Jo,Gf,Bf,al,To,Vf,Nf,Eo,Lf,Xf,hr,et,Cf,Uo,Sf,Yf,ur,ol,cr,ha,Df,dr,ce,ua,jo,xf,Ff,Qf,tt,Zo,zf,Hf,sl,Pf,qf,Of,ca,$o,Kf,ep,mr,de,tp,rl,lp,ap,Ro,op,sp,wr,me,rp,Io,np,ip,ko,fp,pp,yr,nl,_r,Ie,lt,Ao,il,hp,Wo,up,br,at,cp,da,dp,mp,gr,fl,Mr,we,wp,Go,yp,_p,Bo,bp,gp,vr,ot,Jr,pl,Tr,ye,Mp,Vo,vp,Jp,No,Tp,Ep,Er,hl,Ur,st,jr,ae,Up,ma,jp,Zp,wa,$p,Rp,ya,Ip,kp,Zr,rt,ul,cl,Ap,dl,Lo,Wp,Gp,Bp,ml,Vp,Xo,wl,Np,yl,Co,Lp,Xp,$r,nt,Rr,ke,it,So,_l,Cp,Yo,Sp,Ir,ft,Yp,bl,Dp,xp,kr,pt,Do,gl,Fp,Qp,xo,Ml,zp,Ar,Ae,ht,Fo,vl,Hp,Qo,Pp,Wr,ut,qp,_a,Op,Kp,Gr,We,ct,zo,Jl,eh,Ho,th,Br,dt,lh,ba,ah,oh,Vr,Ge,mt,Po,Tl,sh,qo,rh,Nr,_e,nh,Oo,ih,fh,ga,ph,hh,Lr,Be,wt,Ko,El,uh,es,ch,Xr,S,dh,ts,mh,wh,ls,yh,_h,as,bh,gh,os,Mh,vh,ss,Jh,Th,rs,Eh,Uh,Cr,x,jh,ns,Zh,$h,is,Rh,Ih,fs,kh,Ah,ps,Wh,Gh,hs,Bh,Vh,Sr,Ul,Yr,Ve,yt,us,jl,Nh,cs,Lh,Dr,be,Xh,Zl,Ch,Sh,$l,Yh,Dh,xr,Ne,_t,ds,Rl,xh,ms,Fh,Fr,ge,Qh,Il,zh,Hh,kl,Ph,qh,Qr,Me,Oh,Ma,Kh,eu,Al,tu,lu,zr,bt,au,Wl,ou,su,Hr,Gl,Pr,gt,ru,va,nu,iu,qr,Bl,Or,Ja,fu,Kr,Vl,en,Mt,tn,Ta,pu,ln,Nl,an,Ea,hu,on,Ua,ja,Ku,sn,vt,uu,Za,cu,du,rn,Ll,nn,Le,Jt,ws,Xl,mu,ys,wu,fn,Tt,yu,Cl,_u,bu,pn,$a,gu,hn,Et,Ra,Mu,se,_s,Sl,vu,Ju,bs,Yl,Tu,Eu,gs,Dl,Uu,ju,Ms,xl,Zu,$u,Ia,Ru,vs,Js,Fl,Iu,un,Ut,ku,Ts,Au,Wu,cn,Ql,dn,Xe,Es,Gu,Bu,zl,Vu,Nu,mn,ka,Lu,wn,jt,Xu,Hl,Cu,Su,yn,Zt,_n,Ce,$t,Us,Pl,Yu,js,Du,bn,Aa,xu,gn,ql,Mn;return m=new F({}),k=new Te({props:{warning:!0,$$slots:{default:[rw]},$$scope:{ctx:B}}}),Ye=new Te({props:{$$slots:{default:[nw]},$$scope:{ctx:B}}}),Nt=new X({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login"}}),Lt=new F({}),Xt=new F({}),Dt=new X({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwT1VUUFVUX0RJUiUzRCUyMiUyRnNkZGF0YSUyRmZpbmV0dW5lJTJGbG9yYSUyRnBva2Vtb24lMjIlMEFleHBvcnQlMjBIVUJfTU9ERUxfSUQlM0QlMjJwb2tlbW9uLWxvcmElMjIlMEFleHBvcnQlMjBEQVRBU0VUX05BTUUlM0QlMjJsYW1iZGFsYWJzJTJGcG9rZW1vbi1ibGlwLWNhcHRpb25zJTIy",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<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;/sddata/finetune/lora/pokemon&quot;</span>
<span class="hljs-built_in">export</span> HUB_MODEL_ID=<span class="hljs-string">&quot;pokemon-lora&quot;</span>
<span class="hljs-built_in">export</span> DATASET_NAME=<span class="hljs-string">&quot;lambdalabs/pokemon-blip-captions&quot;</span>`}}),Qt=new X({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEJTIyZnAxNiUyMiUyMCUyMHRyYWluX3RleHRfdG9faW1hZ2VfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTVDJTBBJTIwJTIwLS1kYXRhc2V0X25hbWUlM0QlMjREQVRBU0VUX05BTUUlMjAlNUMlMEElMjAlMjAtLWRhdGFsb2FkZXJfbnVtX3dvcmtlcnMlM0Q4JTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwLS1jZW50ZXJfY3JvcCUyMC0tcmFuZG9tX2ZsaXAlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q0JTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QxNTAwMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTA0JTIwJTVDJTBBJTIwJTIwLS1tYXhfZ3JhZF9ub3JtJTNEMSUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29zaW5lJTIyJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0JTdCT1VUUFVUX0RJUiU3RCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWIlMjAlNUMlMEElMjAlMjAtLWh1Yl9tb2RlbF9pZCUzRCUyNCU3QkhVQl9NT0RFTF9JRCU3RCUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTNEd2FuZGIlMjAlNUMlMEElMjAlMjAtLWNoZWNrcG9pbnRpbmdfc3RlcHMlM0Q1MDAlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyQSUyMHBva2Vtb24lMjB3aXRoJTIwYmx1ZSUyMGV5ZXMuJTIyJTIwJTVDJTBBJTIwJTIwLS1zZWVkJTNEMTMzNw==",highlighted:`accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>  train_text_to_image_lora.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$DATASET_NAME</span> \\
  --dataloader_num_workers=8 \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --max_train_steps=15000 \\
  --learning_rate=1e-04 \\
  --max_grad_norm=1 \\
  --lr_scheduler=<span class="hljs-string">&quot;cosine&quot;</span> --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-variable">\${OUTPUT_DIR}</span> \\
  --push_to_hub \\
  --hub_model_id=<span class="hljs-variable">\${HUB_MODEL_ID}</span> \\
  --report_to=wandb \\
  --checkpointing_steps=500 \\
  --validation_prompt=<span class="hljs-string">&quot;A pokemon with blue eyes.&quot;</span> \\
  --seed=1337`}}),zt=new F({}),Ht=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEElMEFtb2RlbF9iYXNlJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2Jhc2UlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, DPMSolverMultistepScheduler

<span class="hljs-meta">&gt;&gt;&gt; </span>model_base = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionPipeline.from_pretrained(model_base, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)`}}),He=new Te({props:{$$slots:{default:[iw]},$$scope:{ctx:B}}}),Pt=new X({props:{code:"cGlwZS51bmV0LmxvYWRfYXR0bl9wcm9jcyhsb3JhX21vZGVsX3BhdGgpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjJBJTIwcG9rZW1vbiUyMHdpdGglMjBibHVlJTIwZXllcy4lMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSUyQyUyMGNyb3NzX2F0dGVudGlvbl9rd2FyZ3MlM0QlN0IlMjJzY2FsZSUyMiUzQSUyMDAuNSU3RCUwQSkuaW1hZ2VzJTVCMCU1RCUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMjJBJTIwcG9rZW1vbiUyMHdpdGglMjBibHVlJTIwZXllcy4lMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyYmx1ZV9wb2tlbW9uLnBuZyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.unet.load_attn_procs(lora_model_path)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># use half the weights from the LoRA finetuned model and half the weights from the base model</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;A pokemon with blue eyes.&quot;</span>, num_inference_steps=<span class="hljs-number">25</span>, guidance_scale=<span class="hljs-number">7.5</span>, cross_attention_kwargs={<span class="hljs-string">&quot;scale&quot;</span>: <span class="hljs-number">0.5</span>}
<span class="hljs-meta">... </span>).images[<span class="hljs-number">0</span>]
<span class="hljs-comment"># use the weights from the fully finetuned LoRA model</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(<span class="hljs-string">&quot;A pokemon with blue eyes.&quot;</span>, num_inference_steps=<span class="hljs-number">25</span>, guidance_scale=<span class="hljs-number">7.5</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;blue_pokemon.png&quot;</span>)`}}),Pe=new Te({props:{$$slots:{default:[fw]},$$scope:{ctx:B}}}),qt=new F({}),Oe=new Te({props:{$$slots:{default:[pw]},$$scope:{ctx:B}}}),el=new F({}),ol=new X({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwSU5TVEFOQ0VfRElSJTNEJTIycGF0aC10by1pbnN0YW5jZS1pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIy",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;path-to-instance-images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>`}}),nl=new X({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGhfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9kYXRhX2RpciUzRCUyNElOU1RBTkNFX0RJUiUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNE9VVFBVVF9ESVIlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX3Byb21wdCUzRCUyMmElMjBwaG90byUyMG9mJTIwc2tzJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tY2hlY2twb2ludGluZ19zdGVwcyUzRDEwMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTQlMjAlNUMlMEElMjAlMjAtLXJlcG9ydF90byUzRCUyMndhbmRiJTIyJTIwJTVDJTBBJTIwJTIwLS1scl9zY2hlZHVsZXIlM0QlMjJjb25zdGFudCUyMiUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNENTAwJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMkElMjBwaG90byUyMG9mJTIwc2tzJTIwZG9nJTIwaW4lMjBhJTIwYnVja2V0JTIyJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX2Vwb2NocyUzRDUwJTIwJTVDJTBBJTIwJTIwLS1zZWVkJTNEJTIyMCUyMiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`accelerate launch train_dreambooth_lora.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=1 \\
  --checkpointing_steps=100 \\
  --learning_rate=1e-4 \\
  --report_to=<span class="hljs-string">&quot;wandb&quot;</span> \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --max_train_steps=500 \\
  --validation_prompt=<span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span> \\
  --validation_epochs=50 \\
  --seed=<span class="hljs-string">&quot;0&quot;</span> \\
  --push_to_hub`}}),il=new F({}),fl=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFtb2RlbF9iYXNlJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2Jhc2UlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>model_base = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionPipeline.from_pretrained(model_base, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)`}}),ot=new Te({props:{$$slots:{default:[hw]},$$scope:{ctx:B}}}),pl=new X({props:{code:"cGlwZS51bmV0LmxvYWRfYXR0bl9wcm9jcyhsb3JhX21vZGVsX3BhdGgpJTBBcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjJBJTIwcGljdHVyZSUyMG9mJTIwYSUyMHNrcyUyMGRvZyUyMGluJTIwYSUyMGJ1Y2tldC4lMjIlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUlMkMlMEElMjAlMjAlMjAlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSUyQyUwQSUyMCUyMCUyMCUyMGNyb3NzX2F0dGVudGlvbl9rd2FyZ3MlM0QlN0IlMjJzY2FsZSUyMiUzQSUyMDAuNSU3RCUyQyUwQSkuaW1hZ2VzJTVCMCU1RCUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMjJBJTIwcGljdHVyZSUyMG9mJTIwYSUyMHNrcyUyMGRvZyUyMGluJTIwYSUyMGJ1Y2tldC4lMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyYnVja2V0LWRvZy5wbmclMjIp",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.unet.load_attn_procs(lora_model_path)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-comment"># use half the weights from the LoRA finetuned model and half the weights from the base model</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;A picture of a sks dog in a bucket.&quot;</span>,
<span class="hljs-meta">... </span>    num_inference_steps=<span class="hljs-number">25</span>,
<span class="hljs-meta">... </span>    guidance_scale=<span class="hljs-number">7.5</span>,
<span class="hljs-meta">... </span>    cross_attention_kwargs={<span class="hljs-string">&quot;scale&quot;</span>: <span class="hljs-number">0.5</span>},
<span class="hljs-meta">... </span>).images[<span class="hljs-number">0</span>]
<span class="hljs-comment"># use the weights from the fully finetuned LoRA model</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(<span class="hljs-string">&quot;A picture of a sks dog in a bucket.&quot;</span>, num_inference_steps=<span class="hljs-number">25</span>, guidance_scale=<span class="hljs-number">7.5</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;bucket-dog.png&quot;</span>)`}}),hl=new X({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1Yi5yZXBvY2FyZCUyMGltcG9ydCUyMFJlcG9DYXJkJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFsb3JhX21vZGVsX2lkJTIwJTNEJTIwJTIyc2F5YWtwYXVsJTJGZHJlYW1ib290aC10ZXh0LWVuY29kZXItdGVzdCUyMiUwQWNhcmQlMjAlM0QlMjBSZXBvQ2FyZC5sb2FkKGxvcmFfbW9kZWxfaWQpJTBBYmFzZV9tb2RlbF9pZCUyMCUzRCUyMGNhcmQuZGF0YS50b19kaWN0KCklNUIlMjJiYXNlX21vZGVsJTIyJTVEJTBBJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsX2lkJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQXBpcGUubG9hZF9sb3JhX3dlaWdodHMobG9yYV9tb2RlbF9pZCklMEFpbWFnZSUyMCUzRCUyMHBpcGUoJTIyQSUyMHBpY3R1cmUlMjBvZiUyMGElMjBza3MlMjBkb2clMjBpbiUyMGElMjBidWNrZXQlMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub.repocard <span class="hljs-keyword">import</span> RepoCard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

lora_model_id = <span class="hljs-string">&quot;sayakpaul/dreambooth-text-encoder-test&quot;</span>
card = RepoCard.load(lora_model_id)
base_model_id = card.data.to_dict()[<span class="hljs-string">&quot;base_model&quot;</span>]

pipe = StableDiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.load_lora_weights(lora_model_id)
image = pipe(<span class="hljs-string">&quot;A picture of a sks dog in a bucket&quot;</span>, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>]`}}),st=new Te({props:{$$slots:{default:[uw]},$$scope:{ctx:B}}}),ml=new X({props:{code:"cGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyhsb3JhX21vZGVsX3BhdGgp",highlighted:"pipe.load_lora_weights(lora_model_path)"}}),nt=new Te({props:{$$slots:{default:[cw]},$$scope:{ctx:B}}}),_l=new F({}),vl=new F({}),Jl=new F({}),Tl=new F({}),El=new F({}),Ul=new X({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMjAlMEElMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnN0YWJpbGl0eWFpJTJGc3RhYmxlLWRpZmZ1c2lvbi14bC1iYXNlLTEuMCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEFsb3JhX21vZGVsX2lkJTIwJTNEJTIwJTIyaGYtaW50ZXJuYWwtdGVzdGluZyUyRnNkeGwtMS4wLWxvcmElMjIlMEFsb3JhX2ZpbGVuYW1lJTIwJTNEJTIwJTIyc2RfeGxfb2Zmc2V0X2V4YW1wbGUtbG9yYV8xLjAuc2FmZXRlbnNvcnMlMjIlMEFwaXBlLmxvYWRfbG9yYV93ZWlnaHRzKGxvcmFfbW9kZWxfaWQlMkMlMjB3ZWlnaHRfbmFtZSUzRGxvcmFfZmlsZW5hbWUpJTBBJTBBJTIzJTIwVGhpcyUyMHVzZXMlMjBhJTIwZGVmYXVsdCUyMCU2MGxvcmFfc2NhbGUlNjAlMjBvZiUyMDEuMC4lMEFwaXBlLmZ1c2VfbG9yYSgpJTBBJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2gubWFudWFsX3NlZWQoMCklMEFpbWFnZXNfZnVzaW9uJTIwJTNEJTIwcGlwZSglMEElMjAlMjAlMjAlMjAlMjJtYXN0ZXJwaWVjZSUyQyUyMGJlc3QlMjBxdWFsaXR5JTJDJTIwbW91bnRhaW4lMjIlMkMlMjBvdXRwdXRfdHlwZSUzRCUyMm5wJTIyJTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDIlMEEpLmltYWdlcyUwQSUwQSUyMyUyMFRvJTIwd29yayUyMHdpdGglMjBhJTIwZGlmZmVyZW50JTIwJTYwbG9yYV9zY2FsZSU2MCUyQyUyMGZpcnN0JTIwcmV2ZXJzZSUyMHRoZSUyMGVmZmVjdHMlMjBvZiUyMCU2MGZ1c2VfbG9yYSgpJTYwLiUwQXBpcGUudW5mdXNlX2xvcmEoKSUwQSUwQSUyMyUyMFRoZW4lMjBwcm9jZWVkJTIwYXMlMjBmb2xsb3dzLiUwQXBpcGUubG9hZF9sb3JhX3dlaWdodHMobG9yYV9tb2RlbF9pZCUyQyUyMHdlaWdodF9uYW1lJTNEbG9yYV9maWxlbmFtZSklMEFwaXBlLmZ1c2VfbG9yYShsb3JhX3NjYWxlJTNEMC41KSUwQSUwQWdlbmVyYXRvciUyMCUzRCUyMHRvcmNoLm1hbnVhbF9zZWVkKDApJTBBaW1hZ2VzX2Z1c2lvbiUyMCUzRCUyMHBpcGUoJTBBJTIwJTIwJTIwJTIwJTIybWFzdGVycGllY2UlMkMlMjBiZXN0JTIwcXVhbGl0eSUyQyUyMG1vdW50YWluJTIyJTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJucCUyMiUyQyUyMGdlbmVyYXRvciUzRGdlbmVyYXRvciUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyJTBBKS5pbWFnZXM=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch 

pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
lora_model_id = <span class="hljs-string">&quot;hf-internal-testing/sdxl-1.0-lora&quot;</span>
lora_filename = <span class="hljs-string">&quot;sd_xl_offset_example-lora_1.0.safetensors&quot;</span>
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)

<span class="hljs-comment"># This uses a default \`lora_scale\` of 1.0.</span>
pipe.fuse_lora()

generator = torch.manual_seed(<span class="hljs-number">0</span>)
images_fusion = pipe(
    <span class="hljs-string">&quot;masterpiece, best quality, mountain&quot;</span>, output_type=<span class="hljs-string">&quot;np&quot;</span>, generator=generator, num_inference_steps=<span class="hljs-number">2</span>
).images

<span class="hljs-comment"># To work with a different \`lora_scale\`, first reverse the effects of \`fuse_lora()\`.</span>
pipe.unfuse_lora()

<span class="hljs-comment"># Then proceed as follows.</span>
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)
pipe.fuse_lora(lora_scale=<span class="hljs-number">0.5</span>)

generator = torch.manual_seed(<span class="hljs-number">0</span>)
images_fusion = pipe(
    <span class="hljs-string">&quot;masterpiece, best quality, mountain&quot;</span>, output_type=<span class="hljs-string">&quot;np&quot;</span>, generator=generator, num_inference_steps=<span class="hljs-number">2</span>
).images`}}),jl=new F({}),Rl=new F({}),Gl=new X({props:{code:"d2dldCUyMGh0dHBzJTNBJTJGJTJGY2l2aXRhaS5jb20lMkZhcGklMkZkb3dubG9hZCUyRm1vZGVscyUyRjE1NjAzJTIwLU8lMjBsaWdodF9hbmRfc2hhZG93LnNhZmV0ZW5zb3Jz",highlighted:"wget https://civitai.com/api/download/models/15603 -O light_and_shadow.safetensors"}}),Bl=new X({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnc2RmJTJGQ291bnRlcmZlaXQtVjIuNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHNhZmV0eV9jaGVja2VyJTNETm9uZSUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKCUwQSUyMCUyMCUyMCUyMHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWclMkMlMjB1c2Vfa2FycmFzX3NpZ21hcyUzRFRydWUlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch

<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, DPMSolverMultistepScheduler

pipeline = StableDiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;gsdf/Counterfeit-V2.5&quot;</span>, torch_dtype=torch.float16, safety_checker=<span class="hljs-literal">None</span>, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(
    pipeline.scheduler.config, use_karras_sigmas=<span class="hljs-literal">True</span>
)`}}),Vl=new X({props:{code:"cGlwZWxpbmUubG9hZF9sb3JhX3dlaWdodHMoJTIyLiUyMiUyQyUyMHdlaWdodF9uYW1lJTNEJTIybGlnaHRfYW5kX3NoYWRvdy5zYWZldGVuc29ycyUyMik=",highlighted:'pipeline.load_lora_weights(<span class="hljs-string">&quot;.&quot;</span>, weight_name=<span class="hljs-string">&quot;light_and_shadow.safetensors&quot;</span>)'}}),Mt=new Te({props:{warning:!0,$$slots:{default:[dw]},$$scope:{ctx:B}}}),Nl=new X({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIybWFzdGVycGllY2UlMkMlMjBiZXN0JTIwcXVhbGl0eSUyQyUyMDFnaXJsJTJDJTIwYXQlMjBkdXNrJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwKCUyMihsb3clMjBxdWFsaXR5JTJDJTIwd29yc3QlMjBxdWFsaXR5JTNBMS40KSUyQyUyMChiYWQlMjBhbmF0b215KSUyQyUyMChpbmFjY3VyYXRlJTIwbGltYiUzQTEuMiklMkMlMjAlMjIlMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjJiYWQlMjBjb21wb3NpdGlvbiUyQyUyMGluYWNjdXJhdGUlMjBleWVzJTJDJTIwZXh0cmElMjBkaWdpdCUyQyUyMGZld2VyJTIwZGlnaXRzJTJDJTIwKGV4dHJhJTIwYXJtcyUzQTEuMiklMkMlMjBsYXJnZSUyMGJyZWFzdHMlMjIpJTBBJTBBaW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTNEcHJvbXB0JTJDJTIwJTBBJTIwJTIwJTIwJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwJTBBJTIwJTIwJTIwJTIwd2lkdGglM0Q1MTIlMkMlMjAlMEElMjAlMjAlMjAlMjBoZWlnaHQlM0Q3NjglMkMlMjAlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMTUlMkMlMjAlMEElMjAlMjAlMjAlMjBudW1faW1hZ2VzX3Blcl9wcm9tcHQlM0Q0JTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEdG9yY2gubWFudWFsX3NlZWQoMCklMEEpLmltYWdlcw==",highlighted:`prompt = <span class="hljs-string">&quot;masterpiece, best quality, 1girl, at dusk&quot;</span>
negative_prompt = (<span class="hljs-string">&quot;(low quality, worst quality:1.4), (bad anatomy), (inaccurate limb:1.2), &quot;</span>
                   <span class="hljs-string">&quot;bad composition, inaccurate eyes, extra digit, fewer digits, (extra arms:1.2), large breasts&quot;</span>)

images = pipeline(prompt=prompt, 
    negative_prompt=negative_prompt, 
    width=<span class="hljs-number">512</span>, 
    height=<span class="hljs-number">768</span>, 
    num_inference_steps=<span class="hljs-number">15</span>, 
    num_images_per_prompt=<span class="hljs-number">4</span>,
    generator=torch.manual_seed(<span class="hljs-number">0</span>)
).images`}}),Ll=new X({props:{code:"bG9yYV9tb2RlbF9pZCUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRmNpdml0YWktbGlnaHQtc2hhZG93LWxvcmElMjIlMEFsb3JhX2ZpbGVuYW1lJTIwJTNEJTIwJTIybGlnaHRfYW5kX3NoYWRvdy5zYWZldGVuc29ycyUyMiUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKGxvcmFfbW9kZWxfaWQlMkMlMjB3ZWlnaHRfbmFtZSUzRGxvcmFfZmlsZW5hbWUp",highlighted:`lora_model_id = <span class="hljs-string">&quot;sayakpaul/civitai-light-shadow-lora&quot;</span>
lora_filename = <span class="hljs-string">&quot;light_and_shadow.safetensors&quot;</span>
pipeline.load_lora_weights(lora_model_id, weight_name=lora_filename)`}}),Xl=new F({}),Ql=new X({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMjAlMEElMEFiYXNlX21vZGVsX2lkJTIwJTNEJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMC45JTIyJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoYmFzZV9tb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZS5sb2FkX2xvcmFfd2VpZ2h0cyglMjIuJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJLYW1lcGFuLnNhZmV0ZW5zb3JzJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMmFuaW1lJTIwc2NyZWVuY2FwJTJDJTIwZ2xpbnQlMkMlMjBkcmF3aW5nJTJDJTIwYmVzdCUyMHF1YWxpdHklMkMlMjBsaWdodCUyMHNtaWxlJTJDJTIwc2h5JTJDJTIwYSUyMGZ1bGwlMjBib2R5JTIwb2YlMjBhJTIwZ2lybCUyMHdlYXJpbmclMjB3ZWRkaW5nJTIwZHJlc3MlMjBpbiUyMHRoZSUyMG1pZGRsZSUyMG9mJTIwdGhlJTIwZm9yZXN0JTIwYmVuZWF0aCUyMHRoZSUyMHRyZWVzJTJDJTIwZmlyZWZsaWVzJTJDJTIwYmlnJTIwZXllcyUyQyUyMDJkJTJDJTIwY3V0ZSUyQyUyMGFuaW1lJTIwZ2lybCUyQyUyMHdhaWZ1JTJDJTIwY2VsJTIwc2hhZGluZyUyQyUyMG1hZ2ljYWwlMjBnaXJsJTJDJTIwdml2aWQlMjBjb2xvcnMlMkMlMjAob3V0bGluZSUzQTEuMSklMkMlMjBtYW5nYSUyMGFuaW1lJTIwYXJ0c3R5bGUlMkMlMjBtYXN0ZXJwaWVjZSUyQyUyMG9mZmljYWwlMjB3YWxscGFwZXIlMkMlMjBnbGludCUyMCUzQ2xvcmElM0FrYW1lX3NkeGxfdjIlM0ExJTNFJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIyKGRlZm9ybWVkJTJDJTIwYmFkJTIwcXVhbGl0eSUyQyUyMHNrZXRjaCUyQyUyMGRlcHRoJTIwb2YlMjBmaWVsZCUyQyUyMGJsdXJyeSUzQTEuMSklMkMlMjBncmFpbnklMkMlMjBiYWQlMjBhbmF0b215JTJDJTIwYmFkJTIwcGVyc3BlY3RpdmUlMkMlMjBvbGQlMkMlMjB1Z2x5JTJDJTIwcmVhbGlzdGljJTJDJTIwY2FydG9vbiUyQyUyMGRpc25leSUyQyUyMGJhZCUyMHByb3BvdGlvbnMlMjIlMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5tYW51YWxfc2VlZCgyOTQ3ODgzMDYwKSUwQW51bV9pbmZlcmVuY2Vfc3RlcHMlMjAlM0QlMjAzMCUwQWd1aWRhbmNlX3NjYWxlJTIwJTNEJTIwNyUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRG51bV9pbmZlcmVuY2Vfc3RlcHMlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMjBndWlkYW5jZV9zY2FsZSUzRGd1aWRhbmNlX3NjYWxlJTBBKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJLYW1lcGFuLnBuZyUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch 

base_model_id = <span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-0.9&quot;</span>
pipeline = DiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_lora_weights(<span class="hljs-string">&quot;.&quot;</span>, weight_name=<span class="hljs-string">&quot;Kamepan.safetensors&quot;</span>)

prompt = <span class="hljs-string">&quot;anime screencap, glint, drawing, best quality, light smile, shy, a full body of a girl wearing wedding dress in the middle of the forest beneath the trees, fireflies, big eyes, 2d, cute, anime girl, waifu, cel shading, magical girl, vivid colors, (outline:1.1), manga anime artstyle, masterpiece, offical wallpaper, glint &lt;lora:kame_sdxl_v2:1&gt;&quot;</span>
negative_prompt = <span class="hljs-string">&quot;(deformed, bad quality, sketch, depth of field, blurry:1.1), grainy, bad anatomy, bad perspective, old, ugly, realistic, cartoon, disney, bad propotions&quot;</span>
generator = torch.manual_seed(<span class="hljs-number">2947883060</span>)
num_inference_steps = <span class="hljs-number">30</span>
guidance_scale = <span class="hljs-number">7</span>

image = pipeline(
    prompt=prompt, negative_prompt=negative_prompt, num_inference_steps=num_inference_steps,
    generator=generator, guidance_scale=guidance_scale
).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;Kamepan.png&quot;</span>)`}}),Zt=new Te({props:{warning:!0,$$slots:{default:[mw]},$$scope:{ctx:B}}}),Pl=new F({}),ql=new X({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZV9pZCUyMCUzRCUyMCUyMkx5a29uJTJGZHJlYW1zaGFwZXIteGwtMS0wJTIyJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChwaXBlbGluZV9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlLmVuYWJsZV9tb2RlbF9jcHVfb2ZmbG9hZCgpJTBBJTBBbG9yYV9tb2RlbF9pZCUyMCUzRCUyMCUyMlRoZUxhc3RCZW4lMkZQYXBlcmN1dF9TRFhMJTIyJTBBbG9yYV9maWxlbmFtZSUyMCUzRCUyMCUyMnBhcGVyY3V0LnNhZmV0ZW5zb3JzJTIyJTBBcGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyhsb3JhX21vZGVsX2lkJTJDJTIwd2VpZ2h0X25hbWUlM0Rsb3JhX2ZpbGVuYW1lKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMnBhcGVyY3V0JTIwc29uaWMlMjIlMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTNEcHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwJTJDJTIwZ2VuZXJhdG9yJTNEdG9yY2gubWFudWFsX3NlZWQoMCkpLmltYWdlcyU1QjAlNUQlMEFpbWFnZQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch

pipeline_id = <span class="hljs-string">&quot;Lykon/dreamshaper-xl-1-0&quot;</span>

pipe = DiffusionPipeline.from_pretrained(pipeline_id, torch_dtype=torch.float16)
pipe.enable_model_cpu_offload()

lora_model_id = <span class="hljs-string">&quot;TheLastBen/Papercut_SDXL&quot;</span>
lora_filename = <span class="hljs-string">&quot;papercut.safetensors&quot;</span>
pipe.load_lora_weights(lora_model_id, weight_name=lora_filename)

prompt = <span class="hljs-string">&quot;papercut sonic&quot;</span>
image = pipe(prompt=prompt, num_inference_steps=<span class="hljs-number">20</span>, generator=torch.manual_seed(<span class="hljs-number">0</span>)).images[<span class="hljs-number">0</span>]
image`}}),{c(){c=s("meta"),b=h(),d=s("h1"),y=s("a"),$=s("span"),M(m.$$.fragment),_=h(),I=s("span"),g=a("Low-Rank Adaptation of Large Language Models (LoRA)"),w=h(),M(k.$$.fragment),j=h(),R=s("p"),V=s("a"),W=a("Low-Rank Adaptation of Large Language Models (LoRA)"),Q=a(" is a training method that accelerates the training of large models while consuming less memory. It adds pairs of rank-decomposition weight matrices (called "),Y=s("strong"),N=a("update matrices"),z=a(") to existing weights, and "),D=s("strong"),A=a("only"),Z=a(" trains those newly added weights. This has a couple of advantages:"),q=h(),G=s("ul"),C=s("li"),K=a("Previous pretrained weights are kept frozen so the model is not as prone to "),L=s("a"),ee=a("catastrophic forgetting"),ea=a("."),ti=h(),Pa=s("li"),li=a("Rank-decomposition matrices have significantly fewer parameters than the original model, which means that trained LoRA weights are easily portable."),ai=h(),Ee=s("li"),oi=a("LoRA matrices are generally added to the attention layers of the original model. \u{1F9E8} Diffusers provides the "),ta=s("a"),si=a("load_attn_procs()"),ri=a(" method to load the LoRA weights into a model\u2019s attention layers. You can control the extent to which the model is adapted toward new training images via a "),qa=s("code"),ni=a("scale"),ii=a(" parameter."),fi=h(),Oa=s("li"),pi=a("The greater memory-efficiency allows you to run fine-tuning on consumer GPUs like the Tesla T4, RTX 3080 or even the RTX 2080 Ti! GPUs like the T4 are free and readily accessible in Kaggle or Google Colab notebooks."),Vs=h(),M(Ye.$$.fragment),Ns=h(),O=s("p"),Wt=s("a"),hi=a("cloneofsimo"),ui=a(" was the first to try out LoRA training for Stable Diffusion in the popular "),Gt=s("a"),ci=a("lora"),di=a(" GitHub repository. \u{1F9E8} Diffusers now supports finetuning with LoRA for "),Bt=s("a"),mi=a("text-to-image generation"),wi=a(" and "),Vt=s("a"),yi=a("DreamBooth"),_i=a(". This guide will show you how to do both."),Ls=h(),De=s("p"),bi=a("If you\u2019d like to store or share your model with the community, login to your Hugging Face account (create "),la=s("a"),gi=a("one"),Mi=a(" if you don\u2019t have one already):"),Xs=h(),M(Nt.$$.fragment),Cs=h(),Ue=s("h2"),xe=s("a"),Ka=s("span"),M(Lt.$$.fragment),vi=h(),eo=s("span"),Ji=a("Text-to-image"),Ss=h(),aa=s("p"),Ti=a("Finetuning a model like Stable Diffusion, which has billions of parameters, can be slow and difficult. With LoRA, it is much easier and faster to finetune a diffusion model. It can run on hardware with as little as 11GB of GPU RAM without resorting to tricks such as 8-bit optimizers."),Ys=h(),je=s("h3"),Fe=s("a"),to=s("span"),M(Xt.$$.fragment),Ei=h(),lo=s("span"),Ui=a("Training"),Ds=h(),ne=s("p"),ji=a("Let\u2019s finetune "),Ct=s("a"),ao=s("code"),Zi=a("stable-diffusion-v1-5"),$i=a(" on the "),St=s("a"),Ri=a("Pok\xE9mon BLIP captions"),Ii=a(" dataset to generate your own Pok\xE9mon."),xs=h(),H=s("p"),ki=a("Specify the "),oo=s("code"),Ai=a("MODEL_NAME"),Wi=a(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Yt=s("a"),so=s("code"),Gi=a("pretrained_model_name_or_path"),Bi=a(" argument. You\u2019ll also need to set the "),ro=s("code"),Vi=a("DATASET_NAME"),Ni=a(" environment variable to the name of the dataset you want to train on. To use your own dataset, take a look at the "),oa=s("a"),Li=a("Create a dataset for training"),Xi=a(" guide."),Fs=h(),ie=s("p"),Ci=a("The "),no=s("code"),Si=a("OUTPUT_DIR"),Yi=a(" and "),io=s("code"),Di=a("HUB_MODEL_ID"),xi=a(" variables are optional and specify where to save the model to on the Hub:"),Qs=h(),M(Dt.$$.fragment),zs=h(),sa=s("p"),Fi=a("There are some flags to be aware of before you start training:"),Hs=h(),fe=s("ul"),ra=s("li"),fo=s("code"),Qi=a("--push_to_hub"),zi=a(" stores the trained LoRA embeddings on the Hub."),Hi=h(),Qe=s("li"),po=s("code"),Pi=a("--report_to=wandb"),qi=a(" reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),xt=s("a"),Oi=a("report"),Ki=a(")."),ef=h(),na=s("li"),ho=s("code"),tf=a("--learning_rate=1e-04"),lf=a(", you can afford to use a higher learning rate than you normally would with LoRA."),Ps=h(),pe=s("p"),af=a("Now you\u2019re ready to launch the training (you can find the full training script "),Ft=s("a"),of=a("here"),sf=a("). Training takes about 5 hours on a 2080 Ti GPU with 11GB of RAM, and it\u2019ll create and save model checkpoints and the "),uo=s("code"),rf=a("pytorch_lora_weights"),nf=a(" in your repository."),qs=h(),M(Qt.$$.fragment),Os=h(),Ze=s("h3"),ze=s("a"),co=s("span"),M(zt.$$.fragment),ff=h(),mo=s("span"),pf=a("Inference"),Ks=h(),he=s("p"),hf=a("Now you can use the model for inference by loading the base model in the "),ia=s("a"),uf=a("StableDiffusionPipeline"),cf=a(" and then the "),fa=s("a"),df=a("DPMSolverMultistepScheduler"),mf=a(":"),er=h(),M(Ht.$$.fragment),tr=h(),ue=s("p"),wf=a("Load the LoRA weights from your finetuned model "),wo=s("em"),yf=a("on top of the base model weights"),_f=a(", and then move the pipeline to a GPU for faster inference. When you merge the LoRA weights with the frozen pretrained model weights, you can optionally adjust how much of the weights to merge with the "),yo=s("code"),bf=a("scale"),gf=a(" parameter:"),lr=h(),M(He.$$.fragment),ar=h(),M(Pt.$$.fragment),or=h(),M(Pe.$$.fragment),sr=h(),$e=s("h2"),qe=s("a"),_o=s("span"),M(qt.$$.fragment),Mf=h(),bo=s("span"),vf=a("DreamBooth"),rr=h(),Ot=s("p"),Kt=s("a"),Jf=a("DreamBooth"),Tf=a(" is a finetuning technique for personalizing a text-to-image model like Stable Diffusion to generate photorealistic images of a subject in different contexts, given a few images of the subject. However, DreamBooth is very sensitive to hyperparameters and it is easy to overfit. Some important hyperparameters to consider include those that affect the training time (learning rate, number of training steps), and inference time (number of steps, scheduler type)."),nr=h(),M(Oe.$$.fragment),ir=h(),Re=s("h3"),Ke=s("a"),go=s("span"),M(el.$$.fragment),Ef=h(),Mo=s("span"),Uf=a("Training"),fr=h(),te=s("p"),jf=a("Let\u2019s finetune "),tl=s("a"),vo=s("code"),Zf=a("stable-diffusion-v1-5"),$f=a(" with DreamBooth and LoRA with some \u{1F436} "),ll=s("a"),Rf=a("dog images"),If=a(". Download and save these images to a directory. To use your own dataset, take a look at the "),pa=s("a"),kf=a("Create a dataset for training"),Af=a(" guide."),pr=h(),le=s("p"),Wf=a("To start, specify the "),Jo=s("code"),Gf=a("MODEL_NAME"),Bf=a(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),al=s("a"),To=s("code"),Vf=a("pretrained_model_name_or_path"),Nf=a(" argument. You\u2019ll also need to set "),Eo=s("code"),Lf=a("INSTANCE_DIR"),Xf=a(" to the path of the directory containing the images."),hr=h(),et=s("p"),Cf=a("The "),Uo=s("code"),Sf=a("OUTPUT_DIR"),Yf=a(" variables is optional and specifies where to save the model to on the Hub:"),ur=h(),M(ol.$$.fragment),cr=h(),ha=s("p"),Df=a("There are some flags to be aware of before you start training:"),dr=h(),ce=s("ul"),ua=s("li"),jo=s("code"),xf=a("--push_to_hub"),Ff=a(" stores the trained LoRA embeddings on the Hub."),Qf=h(),tt=s("li"),Zo=s("code"),zf=a("--report_to=wandb"),Hf=a(" reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),sl=s("a"),Pf=a("report"),qf=a(")."),Of=h(),ca=s("li"),$o=s("code"),Kf=a("--learning_rate=1e-04"),ep=a(", you can afford to use a higher learning rate than you normally would with LoRA."),mr=h(),de=s("p"),tp=a("Now you\u2019re ready to launch the training (you can find the full training script "),rl=s("a"),lp=a("here"),ap=a("). The script creates and saves model checkpoints and the "),Ro=s("code"),op=a("pytorch_lora_weights.bin"),sp=a(" file in your repository."),wr=h(),me=s("p"),rp=a(`It\u2019s also possible to additionally fine-tune the text encoder with LoRA. This, in most cases, leads
to better results with a slight increase in the compute. To allow fine-tuning the text encoder with LoRA,
specify the `),Io=s("code"),np=a("--train_text_encoder"),ip=a(" while launching the "),ko=s("code"),fp=a("train_dreambooth_lora.py"),pp=a(" script."),yr=h(),M(nl.$$.fragment),_r=h(),Ie=s("h3"),lt=s("a"),Ao=s("span"),M(il.$$.fragment),hp=h(),Wo=s("span"),up=a("Inference"),br=h(),at=s("p"),cp=a("Now you can use the model for inference by loading the base model in the "),da=s("a"),dp=a("StableDiffusionPipeline"),mp=a(":"),gr=h(),M(fl.$$.fragment),Mr=h(),we=s("p"),wp=a("Load the LoRA weights from your finetuned DreamBooth model "),Go=s("em"),yp=a("on top of the base model weights"),_p=a(", and then move the pipeline to a GPU for faster inference. When you merge the LoRA weights with the frozen pretrained model weights, you can optionally adjust how much of the weights to merge with the "),Bo=s("code"),bp=a("scale"),gp=a(" parameter:"),vr=h(),M(ot.$$.fragment),Jr=h(),M(pl.$$.fragment),Tr=h(),ye=s("p"),Mp=a("If you used "),Vo=s("code"),vp=a("--train_text_encoder"),Jp=a(" during training, then use "),No=s("code"),Tp=a("pipe.load_lora_weights()"),Ep=a(` to load the LoRA
weights. For example:`),Er=h(),M(hl.$$.fragment),Ur=h(),M(st.$$.fragment),jr=h(),ae=s("p"),Up=a("Note that the use of "),ma=s("a"),jp=a("load_lora_weights()"),Zp=a(" is preferred to "),wa=s("a"),$p=a("load_attn_procs()"),Rp=a(` for loading LoRA parameters. This is because
`),ya=s("a"),Ip=a("load_lora_weights()"),kp=a(" can handle the following situations:"),Zr=h(),rt=s("ul"),ul=s("li"),cl=s("p"),Ap=a("LoRA parameters that don\u2019t have separate identifiers for the UNet and the text encoder (such as "),dl=s("a"),Lo=s("code"),Wp=a('"patrickvonplaten/lora_dreambooth_dog_example"'),Gp=a("). So, you can just do:"),Bp=h(),M(ml.$$.fragment),Vp=h(),Xo=s("li"),wl=s("p"),Np=a("LoRA parameters that have separate identifiers for the UNet and the text encoder such as: "),yl=s("a"),Co=s("code"),Lp=a('"sayakpaul/dreambooth"'),Xp=a("."),$r=h(),M(nt.$$.fragment),Rr=h(),ke=s("h2"),it=s("a"),So=s("span"),M(_l.$$.fragment),Cp=h(),Yo=s("span"),Sp=a("Stable Diffusion XL"),Ir=h(),ft=s("p"),Yp=a("We support fine-tuning with "),bl=s("a"),Dp=a("Stable Diffusion XL"),xp=a(". Please refer to the following docs:"),kr=h(),pt=s("ul"),Do=s("li"),gl=s("a"),Fp=a("text_to_image/README_sdxl.md"),Qp=h(),xo=s("li"),Ml=s("a"),zp=a("dreambooth/README_sdxl.md"),Ar=h(),Ae=s("h2"),ht=s("a"),Fo=s("span"),M(vl.$$.fragment),Hp=h(),Qo=s("span"),Pp=a("Unloading LoRA parameters"),Wr=h(),ut=s("p"),qp=a("You can call "),_a=s("a"),Op=a("unload_lora_weights()"),Kp=a(" on a pipeline to unload the LoRA parameters."),Gr=h(),We=s("h2"),ct=s("a"),zo=s("span"),M(Jl.$$.fragment),eh=h(),Ho=s("span"),th=a("Fusing LoRA parameters"),Br=h(),dt=s("p"),lh=a("You can call "),ba=s("a"),ah=a("fuse_lora()"),oh=a(" on a pipeline to merge the LoRA parameters with the original parameters of the underlying model(s). This can lead to a potential speedup in the inference latency."),Vr=h(),Ge=s("h2"),mt=s("a"),Po=s("span"),M(Tl.$$.fragment),sh=h(),qo=s("span"),rh=a("Unfusing LoRA parameters"),Nr=h(),_e=s("p"),nh=a("To undo "),Oo=s("code"),ih=a("fuse_lora"),fh=a(", call "),ga=s("a"),ph=a("unfuse_lora()"),hh=a(" on a pipeline."),Lr=h(),Be=s("h2"),wt=s("a"),Ko=s("span"),M(El.$$.fragment),uh=h(),es=s("span"),ch=a("Working with different LoRA scales when using LoRA fusion"),Xr=h(),S=s("p"),dh=a("If you need to use "),ts=s("code"),mh=a("scale"),wh=a(" when working with "),ls=s("code"),yh=a("fuse_lora()"),_h=a(" to control the influence of the LoRA parameters on the outputs, you should specify "),as=s("code"),bh=a("lora_scale"),gh=a(" within "),os=s("code"),Mh=a("fuse_lora()"),vh=a(". Passing the "),ss=s("code"),Jh=a("scale"),Th=a(" parameter to "),rs=s("code"),Eh=a("cross_attention_kwargs"),Uh=a(" when you call the pipeline won\u2019t work."),Cr=h(),x=s("p"),jh=a("To use a different "),ns=s("code"),Zh=a("lora_scale"),$h=a(" with "),is=s("code"),Rh=a("fuse_lora()"),Ih=a(", you should first call "),fs=s("code"),kh=a("unfuse_lora()"),Ah=a(" on the corresponding pipeline and call "),ps=s("code"),Wh=a("fuse_lora()"),Gh=a(" again with the expected "),hs=s("code"),Bh=a("lora_scale"),Vh=a("."),Sr=h(),M(Ul.$$.fragment),Yr=h(),Ve=s("h2"),yt=s("a"),us=s("span"),M(jl.$$.fragment),Nh=h(),cs=s("span"),Lh=a("Supporting different LoRA checkpoints from Diffusers"),Dr=h(),be=s("p"),Xh=a("\u{1F917} Diffusers supports loading checkpoints from popular LoRA trainers such as "),Zl=s("a"),Ch=a("Kohya"),Sh=a(" and "),$l=s("a"),Yh=a("TheLastBen"),Dh=a(". In this section, we outline the current API\u2019s details and limitations."),xr=h(),Ne=s("h3"),_t=s("a"),ds=s("span"),M(Rl.$$.fragment),xh=h(),ms=s("span"),Fh=a("Kohya"),Fr=h(),ge=s("p"),Qh=a("This support was made possible because of the amazing contributors: "),Il=s("a"),zh=a("@takuma104"),Hh=a(" and "),kl=s("a"),Ph=a("@isidentical"),qh=a("."),Qr=h(),Me=s("p"),Oh=a("We support loading Kohya LoRA checkpoints using "),Ma=s("a"),Kh=a("load_lora_weights()"),eu=a(". In this section, we explain how to load such a checkpoint from "),Al=s("a"),tu=a("CivitAI"),lu=a(`
in Diffusers and perform inference with it.`),zr=h(),bt=s("p"),au=a(`First, download a checkpoint. We\u2019ll use
`),Wl=s("a"),ou=a("this one"),su=a(" for demonstration purposes."),Hr=h(),M(Gl.$$.fragment),Pr=h(),gt=s("p"),ru=a("Next, we initialize a "),va=s("a"),nu=a("~DiffusionPipeline"),iu=a(":"),qr=h(),M(Bl.$$.fragment),Or=h(),Ja=s("p"),fu=a("We then load the checkpoint downloaded from CivitAI:"),Kr=h(),M(Vl.$$.fragment),en=h(),M(Mt.$$.fragment),tn=h(),Ta=s("p"),pu=a("And then it\u2019s time for running inference:"),ln=h(),M(Nl.$$.fragment),an=h(),Ea=s("p"),hu=a("Below is a comparison between the LoRA and the non-LoRA results:"),on=h(),Ua=s("p"),ja=s("img"),sn=h(),vt=s("p"),uu=a(`You have a similar checkpoint stored on the Hugging Face Hub, you can load it
directly with `),Za=s("a"),cu=a("load_lora_weights()"),du=a(" like so:"),rn=h(),M(Ll.$$.fragment),nn=h(),Le=s("h3"),Jt=s("a"),ws=s("span"),M(Xl.$$.fragment),mu=h(),ys=s("span"),wu=a("Kohya + Stable Diffusion XL"),fn=h(),Tt=s("p"),yu=a("After the release of "),Cl=s("a"),_u=a("Stable Diffusion XL"),bu=a(", the community contributed some amazing LoRA checkpoints trained on top of it with the Kohya trainer."),pn=h(),$a=s("p"),gu=a("Here are some example checkpoints we tried out:"),hn=h(),Et=s("ul"),Ra=s("li"),Mu=a("SDXL 0.9:"),se=s("ul"),_s=s("li"),Sl=s("a"),vu=a("https://civitai.com/models/22279?modelVersionId=118556"),Ju=h(),bs=s("li"),Yl=s("a"),Tu=a("https://civitai.com/models/104515/sdxlor30costumesrevue-starlight-saijoclaudine-lora"),Eu=h(),gs=s("li"),Dl=s("a"),Uu=a("https://civitai.com/models/108448/daiton-sdxl-test"),ju=h(),Ms=s("li"),xl=s("a"),Zu=a("https://filebin.net/2ntfqqnapiu9q3zx/pixelbuildings128-v1.safetensors"),$u=h(),Ia=s("li"),Ru=a("SDXL 1.0:"),vs=s("ul"),Js=s("li"),Fl=s("a"),Iu=a("https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_offset_example-lora_1.0.safetensors"),un=h(),Ut=s("p"),ku=a("Here is an example of how to perform inference with these checkpoints in "),Ts=s("code"),Au=a("diffusers"),Wu=a(":"),cn=h(),M(Ql.$$.fragment),dn=h(),Xe=s("p"),Es=s("code"),Gu=a("Kamepan.safetensors"),Bu=a(" comes from "),zl=s("a"),Vu=a("https://civitai.com/models/22279?modelVersionId=118556"),Nu=a(" ."),mn=h(),ka=s("p"),Lu=a("If you notice carefully, the inference UX is exactly identical to what we presented in the sections above."),wn=h(),jt=s("p"),Xu=a("Thanks to "),Hl=s("a"),Cu=a("@isidentical"),Su=a(" for helping us on integrating this feature."),yn=h(),M(Zt.$$.fragment),_n=h(),Ce=s("h3"),$t=s("a"),Us=s("span"),M(Pl.$$.fragment),Yu=h(),js=s("span"),Du=a("TheLastBen"),bn=h(),Aa=s("p"),xu=a("Here is an example:"),gn=h(),M(ql.$$.fragment),this.h()},l(e){const i=lw('[data-svelte="svelte-1phssyn"]',document.head);c=r(i,"META",{name:!0,content:!0}),i.forEach(l),b=u(e),d=r(e,"H1",{class:!0});var Ol=n(d);y=r(Ol,"A",{id:!0,class:!0,href:!0});var Zs=n(y);$=r(Zs,"SPAN",{});var $s=n($);v(m.$$.fragment,$s),$s.forEach(l),Zs.forEach(l),_=u(Ol),I=r(Ol,"SPAN",{});var Rs=n(I);g=o(Rs,"Low-Rank Adaptation of Large Language Models (LoRA)"),Rs.forEach(l),Ol.forEach(l),w=u(e),v(k.$$.fragment,e),j=u(e),R=r(e,"P",{});var ve=n(R);V=r(ve,"A",{href:!0,rel:!0});var Is=n(V);W=o(Is,"Low-Rank Adaptation of Large Language Models (LoRA)"),Is.forEach(l),Q=o(ve," is a training method that accelerates the training of large models while consuming less memory. It adds pairs of rank-decomposition weight matrices (called "),Y=r(ve,"STRONG",{});var ks=n(Y);N=o(ks,"update matrices"),ks.forEach(l),z=o(ve,") to existing weights, and "),D=r(ve,"STRONG",{});var As=n(D);A=o(As,"only"),As.forEach(l),Z=o(ve," trains those newly added weights. This has a couple of advantages:"),ve.forEach(l),q=u(e),G=r(e,"UL",{});var re=n(G);C=r(re,"LI",{});var Kl=n(C);K=o(Kl,"Previous pretrained weights are kept frozen so the model is not as prone to "),L=r(Kl,"A",{href:!0,rel:!0});var ec=n(L);ee=o(ec,"catastrophic forgetting"),ec.forEach(l),ea=o(Kl,"."),Kl.forEach(l),ti=u(re),Pa=r(re,"LI",{});var tc=n(Pa);li=o(tc,"Rank-decomposition matrices have significantly fewer parameters than the original model, which means that trained LoRA weights are easily portable."),tc.forEach(l),ai=u(re),Ee=r(re,"LI",{});var Wa=n(Ee);oi=o(Wa,"LoRA matrices are generally added to the attention layers of the original model. \u{1F9E8} Diffusers provides the "),ta=r(Wa,"A",{href:!0});var lc=n(ta);si=o(lc,"load_attn_procs()"),lc.forEach(l),ri=o(Wa," method to load the LoRA weights into a model\u2019s attention layers. You can control the extent to which the model is adapted toward new training images via a "),qa=r(Wa,"CODE",{});var ac=n(qa);ni=o(ac,"scale"),ac.forEach(l),ii=o(Wa," parameter."),Wa.forEach(l),fi=u(re),Oa=r(re,"LI",{});var oc=n(Oa);pi=o(oc,"The greater memory-efficiency allows you to run fine-tuning on consumer GPUs like the Tesla T4, RTX 3080 or even the RTX 2080 Ti! GPUs like the T4 are free and readily accessible in Kaggle or Google Colab notebooks."),oc.forEach(l),re.forEach(l),Vs=u(e),v(Ye.$$.fragment,e),Ns=u(e),O=r(e,"P",{});var Se=n(O);Wt=r(Se,"A",{href:!0,rel:!0});var sc=n(Wt);hi=o(sc,"cloneofsimo"),sc.forEach(l),ui=o(Se," was the first to try out LoRA training for Stable Diffusion in the popular "),Gt=r(Se,"A",{href:!0,rel:!0});var rc=n(Gt);ci=o(rc,"lora"),rc.forEach(l),di=o(Se," GitHub repository. \u{1F9E8} Diffusers now supports finetuning with LoRA for "),Bt=r(Se,"A",{href:!0,rel:!0});var nc=n(Bt);mi=o(nc,"text-to-image generation"),nc.forEach(l),wi=o(Se," and "),Vt=r(Se,"A",{href:!0,rel:!0});var ic=n(Vt);yi=o(ic,"DreamBooth"),ic.forEach(l),_i=o(Se,". This guide will show you how to do both."),Se.forEach(l),Ls=u(e),De=r(e,"P",{});var vn=n(De);bi=o(vn,"If you\u2019d like to store or share your model with the community, login to your Hugging Face account (create "),la=r(vn,"A",{href:!0});var fc=n(la);gi=o(fc,"one"),fc.forEach(l),Mi=o(vn," if you don\u2019t have one already):"),vn.forEach(l),Xs=u(e),v(Nt.$$.fragment,e),Cs=u(e),Ue=r(e,"H2",{class:!0});var Jn=n(Ue);xe=r(Jn,"A",{id:!0,class:!0,href:!0});var pc=n(xe);Ka=r(pc,"SPAN",{});var hc=n(Ka);v(Lt.$$.fragment,hc),hc.forEach(l),pc.forEach(l),vi=u(Jn),eo=r(Jn,"SPAN",{});var uc=n(eo);Ji=o(uc,"Text-to-image"),uc.forEach(l),Jn.forEach(l),Ss=u(e),aa=r(e,"P",{});var cc=n(aa);Ti=o(cc,"Finetuning a model like Stable Diffusion, which has billions of parameters, can be slow and difficult. With LoRA, it is much easier and faster to finetune a diffusion model. It can run on hardware with as little as 11GB of GPU RAM without resorting to tricks such as 8-bit optimizers."),cc.forEach(l),Ys=u(e),je=r(e,"H3",{class:!0});var Tn=n(je);Fe=r(Tn,"A",{id:!0,class:!0,href:!0});var dc=n(Fe);to=r(dc,"SPAN",{});var mc=n(to);v(Xt.$$.fragment,mc),mc.forEach(l),dc.forEach(l),Ei=u(Tn),lo=r(Tn,"SPAN",{});var wc=n(lo);Ui=o(wc,"Training"),wc.forEach(l),Tn.forEach(l),Ds=u(e),ne=r(e,"P",{});var Ga=n(ne);ji=o(Ga,"Let\u2019s finetune "),Ct=r(Ga,"A",{href:!0,rel:!0});var yc=n(Ct);ao=r(yc,"CODE",{});var _c=n(ao);Zi=o(_c,"stable-diffusion-v1-5"),_c.forEach(l),yc.forEach(l),$i=o(Ga," on the "),St=r(Ga,"A",{href:!0,rel:!0});var bc=n(St);Ri=o(bc,"Pok\xE9mon BLIP captions"),bc.forEach(l),Ii=o(Ga," dataset to generate your own Pok\xE9mon."),Ga.forEach(l),xs=u(e),H=r(e,"P",{});var Je=n(H);ki=o(Je,"Specify the "),oo=r(Je,"CODE",{});var gc=n(oo);Ai=o(gc,"MODEL_NAME"),gc.forEach(l),Wi=o(Je," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Yt=r(Je,"A",{href:!0,rel:!0});var Mc=n(Yt);so=r(Mc,"CODE",{});var vc=n(so);Gi=o(vc,"pretrained_model_name_or_path"),vc.forEach(l),Mc.forEach(l),Bi=o(Je," argument. You\u2019ll also need to set the "),ro=r(Je,"CODE",{});var Jc=n(ro);Vi=o(Jc,"DATASET_NAME"),Jc.forEach(l),Ni=o(Je," environment variable to the name of the dataset you want to train on. To use your own dataset, take a look at the "),oa=r(Je,"A",{href:!0});var Tc=n(oa);Li=o(Tc,"Create a dataset for training"),Tc.forEach(l),Xi=o(Je," guide."),Je.forEach(l),Fs=u(e),ie=r(e,"P",{});var Ba=n(ie);Ci=o(Ba,"The "),no=r(Ba,"CODE",{});var Ec=n(no);Si=o(Ec,"OUTPUT_DIR"),Ec.forEach(l),Yi=o(Ba," and "),io=r(Ba,"CODE",{});var Uc=n(io);Di=o(Uc,"HUB_MODEL_ID"),Uc.forEach(l),xi=o(Ba," variables are optional and specify where to save the model to on the Hub:"),Ba.forEach(l),Qs=u(e),v(Dt.$$.fragment,e),zs=u(e),sa=r(e,"P",{});var jc=n(sa);Fi=o(jc,"There are some flags to be aware of before you start training:"),jc.forEach(l),Hs=u(e),fe=r(e,"UL",{});var Va=n(fe);ra=r(Va,"LI",{});var Fu=n(ra);fo=r(Fu,"CODE",{});var Zc=n(fo);Qi=o(Zc,"--push_to_hub"),Zc.forEach(l),zi=o(Fu," stores the trained LoRA embeddings on the Hub."),Fu.forEach(l),Hi=u(Va),Qe=r(Va,"LI",{});var Ws=n(Qe);po=r(Ws,"CODE",{});var $c=n(po);Pi=o($c,"--report_to=wandb"),$c.forEach(l),qi=o(Ws," reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),xt=r(Ws,"A",{href:!0,rel:!0});var Rc=n(xt);Oi=o(Rc,"report"),Rc.forEach(l),Ki=o(Ws,")."),Ws.forEach(l),ef=u(Va),na=r(Va,"LI",{});var Qu=n(na);ho=r(Qu,"CODE",{});var Ic=n(ho);tf=o(Ic,"--learning_rate=1e-04"),Ic.forEach(l),lf=o(Qu,", you can afford to use a higher learning rate than you normally would with LoRA."),Qu.forEach(l),Va.forEach(l),Ps=u(e),pe=r(e,"P",{});var Na=n(pe);af=o(Na,"Now you\u2019re ready to launch the training (you can find the full training script "),Ft=r(Na,"A",{href:!0,rel:!0});var kc=n(Ft);of=o(kc,"here"),kc.forEach(l),sf=o(Na,"). Training takes about 5 hours on a 2080 Ti GPU with 11GB of RAM, and it\u2019ll create and save model checkpoints and the "),uo=r(Na,"CODE",{});var Ac=n(uo);rf=o(Ac,"pytorch_lora_weights"),Ac.forEach(l),nf=o(Na," in your repository."),Na.forEach(l),qs=u(e),v(Qt.$$.fragment,e),Os=u(e),Ze=r(e,"H3",{class:!0});var En=n(Ze);ze=r(En,"A",{id:!0,class:!0,href:!0});var Wc=n(ze);co=r(Wc,"SPAN",{});var Gc=n(co);v(zt.$$.fragment,Gc),Gc.forEach(l),Wc.forEach(l),ff=u(En),mo=r(En,"SPAN",{});var Bc=n(mo);pf=o(Bc,"Inference"),Bc.forEach(l),En.forEach(l),Ks=u(e),he=r(e,"P",{});var La=n(he);hf=o(La,"Now you can use the model for inference by loading the base model in the "),ia=r(La,"A",{href:!0});var Vc=n(ia);uf=o(Vc,"StableDiffusionPipeline"),Vc.forEach(l),cf=o(La," and then the "),fa=r(La,"A",{href:!0});var Nc=n(fa);df=o(Nc,"DPMSolverMultistepScheduler"),Nc.forEach(l),mf=o(La,":"),La.forEach(l),er=u(e),v(Ht.$$.fragment,e),tr=u(e),ue=r(e,"P",{});var Xa=n(ue);wf=o(Xa,"Load the LoRA weights from your finetuned model "),wo=r(Xa,"EM",{});var Lc=n(wo);yf=o(Lc,"on top of the base model weights"),Lc.forEach(l),_f=o(Xa,", and then move the pipeline to a GPU for faster inference. When you merge the LoRA weights with the frozen pretrained model weights, you can optionally adjust how much of the weights to merge with the "),yo=r(Xa,"CODE",{});var Xc=n(yo);bf=o(Xc,"scale"),Xc.forEach(l),gf=o(Xa," parameter:"),Xa.forEach(l),lr=u(e),v(He.$$.fragment,e),ar=u(e),v(Pt.$$.fragment,e),or=u(e),v(Pe.$$.fragment,e),sr=u(e),$e=r(e,"H2",{class:!0});var Un=n($e);qe=r(Un,"A",{id:!0,class:!0,href:!0});var Cc=n(qe);_o=r(Cc,"SPAN",{});var Sc=n(_o);v(qt.$$.fragment,Sc),Sc.forEach(l),Cc.forEach(l),Mf=u(Un),bo=r(Un,"SPAN",{});var Yc=n(bo);vf=o(Yc,"DreamBooth"),Yc.forEach(l),Un.forEach(l),rr=u(e),Ot=r(e,"P",{});var zu=n(Ot);Kt=r(zu,"A",{href:!0,rel:!0});var Dc=n(Kt);Jf=o(Dc,"DreamBooth"),Dc.forEach(l),Tf=o(zu," is a finetuning technique for personalizing a text-to-image model like Stable Diffusion to generate photorealistic images of a subject in different contexts, given a few images of the subject. However, DreamBooth is very sensitive to hyperparameters and it is easy to overfit. Some important hyperparameters to consider include those that affect the training time (learning rate, number of training steps), and inference time (number of steps, scheduler type)."),zu.forEach(l),nr=u(e),v(Oe.$$.fragment,e),ir=u(e),Re=r(e,"H3",{class:!0});var jn=n(Re);Ke=r(jn,"A",{id:!0,class:!0,href:!0});var xc=n(Ke);go=r(xc,"SPAN",{});var Fc=n(go);v(el.$$.fragment,Fc),Fc.forEach(l),xc.forEach(l),Ef=u(jn),Mo=r(jn,"SPAN",{});var Qc=n(Mo);Uf=o(Qc,"Training"),Qc.forEach(l),jn.forEach(l),fr=u(e),te=r(e,"P",{});var Rt=n(te);jf=o(Rt,"Let\u2019s finetune "),tl=r(Rt,"A",{href:!0,rel:!0});var zc=n(tl);vo=r(zc,"CODE",{});var Hc=n(vo);Zf=o(Hc,"stable-diffusion-v1-5"),Hc.forEach(l),zc.forEach(l),$f=o(Rt," with DreamBooth and LoRA with some \u{1F436} "),ll=r(Rt,"A",{href:!0,rel:!0});var Pc=n(ll);Rf=o(Pc,"dog images"),Pc.forEach(l),If=o(Rt,". Download and save these images to a directory. To use your own dataset, take a look at the "),pa=r(Rt,"A",{href:!0});var qc=n(pa);kf=o(qc,"Create a dataset for training"),qc.forEach(l),Af=o(Rt," guide."),Rt.forEach(l),pr=u(e),le=r(e,"P",{});var It=n(le);Wf=o(It,"To start, specify the "),Jo=r(It,"CODE",{});var Oc=n(Jo);Gf=o(Oc,"MODEL_NAME"),Oc.forEach(l),Bf=o(It," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),al=r(It,"A",{href:!0,rel:!0});var Kc=n(al);To=r(Kc,"CODE",{});var ed=n(To);Vf=o(ed,"pretrained_model_name_or_path"),ed.forEach(l),Kc.forEach(l),Nf=o(It," argument. You\u2019ll also need to set "),Eo=r(It,"CODE",{});var td=n(Eo);Lf=o(td,"INSTANCE_DIR"),td.forEach(l),Xf=o(It," to the path of the directory containing the images."),It.forEach(l),hr=u(e),et=r(e,"P",{});var Zn=n(et);Cf=o(Zn,"The "),Uo=r(Zn,"CODE",{});var ld=n(Uo);Sf=o(ld,"OUTPUT_DIR"),ld.forEach(l),Yf=o(Zn," variables is optional and specifies where to save the model to on the Hub:"),Zn.forEach(l),ur=u(e),v(ol.$$.fragment,e),cr=u(e),ha=r(e,"P",{});var ad=n(ha);Df=o(ad,"There are some flags to be aware of before you start training:"),ad.forEach(l),dr=u(e),ce=r(e,"UL",{});var Ca=n(ce);ua=r(Ca,"LI",{});var Hu=n(ua);jo=r(Hu,"CODE",{});var od=n(jo);xf=o(od,"--push_to_hub"),od.forEach(l),Ff=o(Hu," stores the trained LoRA embeddings on the Hub."),Hu.forEach(l),Qf=u(Ca),tt=r(Ca,"LI",{});var Gs=n(tt);Zo=r(Gs,"CODE",{});var sd=n(Zo);zf=o(sd,"--report_to=wandb"),sd.forEach(l),Hf=o(Gs," reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),sl=r(Gs,"A",{href:!0,rel:!0});var rd=n(sl);Pf=o(rd,"report"),rd.forEach(l),qf=o(Gs,")."),Gs.forEach(l),Of=u(Ca),ca=r(Ca,"LI",{});var Pu=n(ca);$o=r(Pu,"CODE",{});var nd=n($o);Kf=o(nd,"--learning_rate=1e-04"),nd.forEach(l),ep=o(Pu,", you can afford to use a higher learning rate than you normally would with LoRA."),Pu.forEach(l),Ca.forEach(l),mr=u(e),de=r(e,"P",{});var Sa=n(de);tp=o(Sa,"Now you\u2019re ready to launch the training (you can find the full training script "),rl=r(Sa,"A",{href:!0,rel:!0});var id=n(rl);lp=o(id,"here"),id.forEach(l),ap=o(Sa,"). The script creates and saves model checkpoints and the "),Ro=r(Sa,"CODE",{});var fd=n(Ro);op=o(fd,"pytorch_lora_weights.bin"),fd.forEach(l),sp=o(Sa," file in your repository."),Sa.forEach(l),wr=u(e),me=r(e,"P",{});var Ya=n(me);rp=o(Ya,`It\u2019s also possible to additionally fine-tune the text encoder with LoRA. This, in most cases, leads
to better results with a slight increase in the compute. To allow fine-tuning the text encoder with LoRA,
specify the `),Io=r(Ya,"CODE",{});var pd=n(Io);np=o(pd,"--train_text_encoder"),pd.forEach(l),ip=o(Ya," while launching the "),ko=r(Ya,"CODE",{});var hd=n(ko);fp=o(hd,"train_dreambooth_lora.py"),hd.forEach(l),pp=o(Ya," script."),Ya.forEach(l),yr=u(e),v(nl.$$.fragment,e),_r=u(e),Ie=r(e,"H3",{class:!0});var $n=n(Ie);lt=r($n,"A",{id:!0,class:!0,href:!0});var ud=n(lt);Ao=r(ud,"SPAN",{});var cd=n(Ao);v(il.$$.fragment,cd),cd.forEach(l),ud.forEach(l),hp=u($n),Wo=r($n,"SPAN",{});var dd=n(Wo);up=o(dd,"Inference"),dd.forEach(l),$n.forEach(l),br=u(e),at=r(e,"P",{});var Rn=n(at);cp=o(Rn,"Now you can use the model for inference by loading the base model in the "),da=r(Rn,"A",{href:!0});var md=n(da);dp=o(md,"StableDiffusionPipeline"),md.forEach(l),mp=o(Rn,":"),Rn.forEach(l),gr=u(e),v(fl.$$.fragment,e),Mr=u(e),we=r(e,"P",{});var Da=n(we);wp=o(Da,"Load the LoRA weights from your finetuned DreamBooth model "),Go=r(Da,"EM",{});var wd=n(Go);yp=o(wd,"on top of the base model weights"),wd.forEach(l),_p=o(Da,", and then move the pipeline to a GPU for faster inference. When you merge the LoRA weights with the frozen pretrained model weights, you can optionally adjust how much of the weights to merge with the "),Bo=r(Da,"CODE",{});var yd=n(Bo);bp=o(yd,"scale"),yd.forEach(l),gp=o(Da," parameter:"),Da.forEach(l),vr=u(e),v(ot.$$.fragment,e),Jr=u(e),v(pl.$$.fragment,e),Tr=u(e),ye=r(e,"P",{});var xa=n(ye);Mp=o(xa,"If you used "),Vo=r(xa,"CODE",{});var _d=n(Vo);vp=o(_d,"--train_text_encoder"),_d.forEach(l),Jp=o(xa," during training, then use "),No=r(xa,"CODE",{});var bd=n(No);Tp=o(bd,"pipe.load_lora_weights()"),bd.forEach(l),Ep=o(xa,` to load the LoRA
weights. For example:`),xa.forEach(l),Er=u(e),v(hl.$$.fragment,e),Ur=u(e),v(st.$$.fragment,e),jr=u(e),ae=r(e,"P",{});var kt=n(ae);Up=o(kt,"Note that the use of "),ma=r(kt,"A",{href:!0});var gd=n(ma);jp=o(gd,"load_lora_weights()"),gd.forEach(l),Zp=o(kt," is preferred to "),wa=r(kt,"A",{href:!0});var Md=n(wa);$p=o(Md,"load_attn_procs()"),Md.forEach(l),Rp=o(kt,` for loading LoRA parameters. This is because
`),ya=r(kt,"A",{href:!0});var vd=n(ya);Ip=o(vd,"load_lora_weights()"),vd.forEach(l),kp=o(kt," can handle the following situations:"),kt.forEach(l),Zr=u(e),rt=r(e,"UL",{});var In=n(rt);ul=r(In,"LI",{});var kn=n(ul);cl=r(kn,"P",{});var An=n(cl);Ap=o(An,"LoRA parameters that don\u2019t have separate identifiers for the UNet and the text encoder (such as "),dl=r(An,"A",{href:!0,rel:!0});var Jd=n(dl);Lo=r(Jd,"CODE",{});var Td=n(Lo);Wp=o(Td,'"patrickvonplaten/lora_dreambooth_dog_example"'),Td.forEach(l),Jd.forEach(l),Gp=o(An,"). So, you can just do:"),An.forEach(l),Bp=u(kn),v(ml.$$.fragment,kn),kn.forEach(l),Vp=u(In),Xo=r(In,"LI",{});var Ed=n(Xo);wl=r(Ed,"P",{});var Wn=n(wl);Np=o(Wn,"LoRA parameters that have separate identifiers for the UNet and the text encoder such as: "),yl=r(Wn,"A",{href:!0,rel:!0});var Ud=n(yl);Co=r(Ud,"CODE",{});var jd=n(Co);Lp=o(jd,'"sayakpaul/dreambooth"'),jd.forEach(l),Ud.forEach(l),Xp=o(Wn,"."),Wn.forEach(l),Ed.forEach(l),In.forEach(l),$r=u(e),v(nt.$$.fragment,e),Rr=u(e),ke=r(e,"H2",{class:!0});var Gn=n(ke);it=r(Gn,"A",{id:!0,class:!0,href:!0});var Zd=n(it);So=r(Zd,"SPAN",{});var $d=n(So);v(_l.$$.fragment,$d),$d.forEach(l),Zd.forEach(l),Cp=u(Gn),Yo=r(Gn,"SPAN",{});var Rd=n(Yo);Sp=o(Rd,"Stable Diffusion XL"),Rd.forEach(l),Gn.forEach(l),Ir=u(e),ft=r(e,"P",{});var Bn=n(ft);Yp=o(Bn,"We support fine-tuning with "),bl=r(Bn,"A",{href:!0,rel:!0});var Id=n(bl);Dp=o(Id,"Stable Diffusion XL"),Id.forEach(l),xp=o(Bn,". Please refer to the following docs:"),Bn.forEach(l),kr=u(e),pt=r(e,"UL",{});var Vn=n(pt);Do=r(Vn,"LI",{});var kd=n(Do);gl=r(kd,"A",{href:!0,rel:!0});var Ad=n(gl);Fp=o(Ad,"text_to_image/README_sdxl.md"),Ad.forEach(l),kd.forEach(l),Qp=u(Vn),xo=r(Vn,"LI",{});var Wd=n(xo);Ml=r(Wd,"A",{href:!0,rel:!0});var Gd=n(Ml);zp=o(Gd,"dreambooth/README_sdxl.md"),Gd.forEach(l),Wd.forEach(l),Vn.forEach(l),Ar=u(e),Ae=r(e,"H2",{class:!0});var Nn=n(Ae);ht=r(Nn,"A",{id:!0,class:!0,href:!0});var Bd=n(ht);Fo=r(Bd,"SPAN",{});var Vd=n(Fo);v(vl.$$.fragment,Vd),Vd.forEach(l),Bd.forEach(l),Hp=u(Nn),Qo=r(Nn,"SPAN",{});var Nd=n(Qo);Pp=o(Nd,"Unloading LoRA parameters"),Nd.forEach(l),Nn.forEach(l),Wr=u(e),ut=r(e,"P",{});var Ln=n(ut);qp=o(Ln,"You can call "),_a=r(Ln,"A",{href:!0});var Ld=n(_a);Op=o(Ld,"unload_lora_weights()"),Ld.forEach(l),Kp=o(Ln," on a pipeline to unload the LoRA parameters."),Ln.forEach(l),Gr=u(e),We=r(e,"H2",{class:!0});var Xn=n(We);ct=r(Xn,"A",{id:!0,class:!0,href:!0});var Xd=n(ct);zo=r(Xd,"SPAN",{});var Cd=n(zo);v(Jl.$$.fragment,Cd),Cd.forEach(l),Xd.forEach(l),eh=u(Xn),Ho=r(Xn,"SPAN",{});var Sd=n(Ho);th=o(Sd,"Fusing LoRA parameters"),Sd.forEach(l),Xn.forEach(l),Br=u(e),dt=r(e,"P",{});var Cn=n(dt);lh=o(Cn,"You can call "),ba=r(Cn,"A",{href:!0});var Yd=n(ba);ah=o(Yd,"fuse_lora()"),Yd.forEach(l),oh=o(Cn," on a pipeline to merge the LoRA parameters with the original parameters of the underlying model(s). This can lead to a potential speedup in the inference latency."),Cn.forEach(l),Vr=u(e),Ge=r(e,"H2",{class:!0});var Sn=n(Ge);mt=r(Sn,"A",{id:!0,class:!0,href:!0});var Dd=n(mt);Po=r(Dd,"SPAN",{});var xd=n(Po);v(Tl.$$.fragment,xd),xd.forEach(l),Dd.forEach(l),sh=u(Sn),qo=r(Sn,"SPAN",{});var Fd=n(qo);rh=o(Fd,"Unfusing LoRA parameters"),Fd.forEach(l),Sn.forEach(l),Nr=u(e),_e=r(e,"P",{});var Fa=n(_e);nh=o(Fa,"To undo "),Oo=r(Fa,"CODE",{});var Qd=n(Oo);ih=o(Qd,"fuse_lora"),Qd.forEach(l),fh=o(Fa,", call "),ga=r(Fa,"A",{href:!0});var zd=n(ga);ph=o(zd,"unfuse_lora()"),zd.forEach(l),hh=o(Fa," on a pipeline."),Fa.forEach(l),Lr=u(e),Be=r(e,"H2",{class:!0});var Yn=n(Be);wt=r(Yn,"A",{id:!0,class:!0,href:!0});var Hd=n(wt);Ko=r(Hd,"SPAN",{});var Pd=n(Ko);v(El.$$.fragment,Pd),Pd.forEach(l),Hd.forEach(l),uh=u(Yn),es=r(Yn,"SPAN",{});var qd=n(es);ch=o(qd,"Working with different LoRA scales when using LoRA fusion"),qd.forEach(l),Yn.forEach(l),Xr=u(e),S=r(e,"P",{});var P=n(S);dh=o(P,"If you need to use "),ts=r(P,"CODE",{});var Od=n(ts);mh=o(Od,"scale"),Od.forEach(l),wh=o(P," when working with "),ls=r(P,"CODE",{});var Kd=n(ls);yh=o(Kd,"fuse_lora()"),Kd.forEach(l),_h=o(P," to control the influence of the LoRA parameters on the outputs, you should specify "),as=r(P,"CODE",{});var em=n(as);bh=o(em,"lora_scale"),em.forEach(l),gh=o(P," within "),os=r(P,"CODE",{});var tm=n(os);Mh=o(tm,"fuse_lora()"),tm.forEach(l),vh=o(P,". Passing the "),ss=r(P,"CODE",{});var lm=n(ss);Jh=o(lm,"scale"),lm.forEach(l),Th=o(P," parameter to "),rs=r(P,"CODE",{});var am=n(rs);Eh=o(am,"cross_attention_kwargs"),am.forEach(l),Uh=o(P," when you call the pipeline won\u2019t work."),P.forEach(l),Cr=u(e),x=r(e,"P",{});var oe=n(x);jh=o(oe,"To use a different "),ns=r(oe,"CODE",{});var om=n(ns);Zh=o(om,"lora_scale"),om.forEach(l),$h=o(oe," with "),is=r(oe,"CODE",{});var sm=n(is);Rh=o(sm,"fuse_lora()"),sm.forEach(l),Ih=o(oe,", you should first call "),fs=r(oe,"CODE",{});var rm=n(fs);kh=o(rm,"unfuse_lora()"),rm.forEach(l),Ah=o(oe," on the corresponding pipeline and call "),ps=r(oe,"CODE",{});var nm=n(ps);Wh=o(nm,"fuse_lora()"),nm.forEach(l),Gh=o(oe," again with the expected "),hs=r(oe,"CODE",{});var im=n(hs);Bh=o(im,"lora_scale"),im.forEach(l),Vh=o(oe,"."),oe.forEach(l),Sr=u(e),v(Ul.$$.fragment,e),Yr=u(e),Ve=r(e,"H2",{class:!0});var Dn=n(Ve);yt=r(Dn,"A",{id:!0,class:!0,href:!0});var fm=n(yt);us=r(fm,"SPAN",{});var pm=n(us);v(jl.$$.fragment,pm),pm.forEach(l),fm.forEach(l),Nh=u(Dn),cs=r(Dn,"SPAN",{});var hm=n(cs);Lh=o(hm,"Supporting different LoRA checkpoints from Diffusers"),hm.forEach(l),Dn.forEach(l),Dr=u(e),be=r(e,"P",{});var Qa=n(be);Xh=o(Qa,"\u{1F917} Diffusers supports loading checkpoints from popular LoRA trainers such as "),Zl=r(Qa,"A",{href:!0,rel:!0});var um=n(Zl);Ch=o(um,"Kohya"),um.forEach(l),Sh=o(Qa," and "),$l=r(Qa,"A",{href:!0,rel:!0});var cm=n($l);Yh=o(cm,"TheLastBen"),cm.forEach(l),Dh=o(Qa,". In this section, we outline the current API\u2019s details and limitations."),Qa.forEach(l),xr=u(e),Ne=r(e,"H3",{class:!0});var xn=n(Ne);_t=r(xn,"A",{id:!0,class:!0,href:!0});var dm=n(_t);ds=r(dm,"SPAN",{});var mm=n(ds);v(Rl.$$.fragment,mm),mm.forEach(l),dm.forEach(l),xh=u(xn),ms=r(xn,"SPAN",{});var wm=n(ms);Fh=o(wm,"Kohya"),wm.forEach(l),xn.forEach(l),Fr=u(e),ge=r(e,"P",{});var za=n(ge);Qh=o(za,"This support was made possible because of the amazing contributors: "),Il=r(za,"A",{href:!0,rel:!0});var ym=n(Il);zh=o(ym,"@takuma104"),ym.forEach(l),Hh=o(za," and "),kl=r(za,"A",{href:!0,rel:!0});var _m=n(kl);Ph=o(_m,"@isidentical"),_m.forEach(l),qh=o(za,"."),za.forEach(l),Qr=u(e),Me=r(e,"P",{});var Ha=n(Me);Oh=o(Ha,"We support loading Kohya LoRA checkpoints using "),Ma=r(Ha,"A",{href:!0});var bm=n(Ma);Kh=o(bm,"load_lora_weights()"),bm.forEach(l),eu=o(Ha,". In this section, we explain how to load such a checkpoint from "),Al=r(Ha,"A",{href:!0,rel:!0});var gm=n(Al);tu=o(gm,"CivitAI"),gm.forEach(l),lu=o(Ha,`
in Diffusers and perform inference with it.`),Ha.forEach(l),zr=u(e),bt=r(e,"P",{});var Fn=n(bt);au=o(Fn,`First, download a checkpoint. We\u2019ll use
`),Wl=r(Fn,"A",{href:!0,rel:!0});var Mm=n(Wl);ou=o(Mm,"this one"),Mm.forEach(l),su=o(Fn," for demonstration purposes."),Fn.forEach(l),Hr=u(e),v(Gl.$$.fragment,e),Pr=u(e),gt=r(e,"P",{});var Qn=n(gt);ru=o(Qn,"Next, we initialize a "),va=r(Qn,"A",{href:!0});var vm=n(va);nu=o(vm,"~DiffusionPipeline"),vm.forEach(l),iu=o(Qn,":"),Qn.forEach(l),qr=u(e),v(Bl.$$.fragment,e),Or=u(e),Ja=r(e,"P",{});var Jm=n(Ja);fu=o(Jm,"We then load the checkpoint downloaded from CivitAI:"),Jm.forEach(l),Kr=u(e),v(Vl.$$.fragment,e),en=u(e),v(Mt.$$.fragment,e),tn=u(e),Ta=r(e,"P",{});var Tm=n(Ta);pu=o(Tm,"And then it\u2019s time for running inference:"),Tm.forEach(l),ln=u(e),v(Nl.$$.fragment,e),an=u(e),Ea=r(e,"P",{});var Em=n(Ea);hu=o(Em,"Below is a comparison between the LoRA and the non-LoRA results:"),Em.forEach(l),on=u(e),Ua=r(e,"P",{});var Um=n(Ua);ja=r(Um,"IMG",{src:!0,alt:!0}),Um.forEach(l),sn=u(e),vt=r(e,"P",{});var zn=n(vt);uu=o(zn,`You have a similar checkpoint stored on the Hugging Face Hub, you can load it
directly with `),Za=r(zn,"A",{href:!0});var jm=n(Za);cu=o(jm,"load_lora_weights()"),jm.forEach(l),du=o(zn," like so:"),zn.forEach(l),rn=u(e),v(Ll.$$.fragment,e),nn=u(e),Le=r(e,"H3",{class:!0});var Hn=n(Le);Jt=r(Hn,"A",{id:!0,class:!0,href:!0});var Zm=n(Jt);ws=r(Zm,"SPAN",{});var $m=n(ws);v(Xl.$$.fragment,$m),$m.forEach(l),Zm.forEach(l),mu=u(Hn),ys=r(Hn,"SPAN",{});var Rm=n(ys);wu=o(Rm,"Kohya + Stable Diffusion XL"),Rm.forEach(l),Hn.forEach(l),fn=u(e),Tt=r(e,"P",{});var Pn=n(Tt);yu=o(Pn,"After the release of "),Cl=r(Pn,"A",{href:!0,rel:!0});var Im=n(Cl);_u=o(Im,"Stable Diffusion XL"),Im.forEach(l),bu=o(Pn,", the community contributed some amazing LoRA checkpoints trained on top of it with the Kohya trainer."),Pn.forEach(l),pn=u(e),$a=r(e,"P",{});var km=n($a);gu=o(km,"Here are some example checkpoints we tried out:"),km.forEach(l),hn=u(e),Et=r(e,"UL",{});var qn=n(Et);Ra=r(qn,"LI",{});var qu=n(Ra);Mu=o(qu,"SDXL 0.9:"),se=r(qu,"UL",{});var At=n(se);_s=r(At,"LI",{});var Am=n(_s);Sl=r(Am,"A",{href:!0,rel:!0});var Wm=n(Sl);vu=o(Wm,"https://civitai.com/models/22279?modelVersionId=118556"),Wm.forEach(l),Am.forEach(l),Ju=u(At),bs=r(At,"LI",{});var Gm=n(bs);Yl=r(Gm,"A",{href:!0,rel:!0});var Bm=n(Yl);Tu=o(Bm,"https://civitai.com/models/104515/sdxlor30costumesrevue-starlight-saijoclaudine-lora"),Bm.forEach(l),Gm.forEach(l),Eu=u(At),gs=r(At,"LI",{});var Vm=n(gs);Dl=r(Vm,"A",{href:!0,rel:!0});var Nm=n(Dl);Uu=o(Nm,"https://civitai.com/models/108448/daiton-sdxl-test"),Nm.forEach(l),Vm.forEach(l),ju=u(At),Ms=r(At,"LI",{});var Lm=n(Ms);xl=r(Lm,"A",{href:!0,rel:!0});var Xm=n(xl);Zu=o(Xm,"https://filebin.net/2ntfqqnapiu9q3zx/pixelbuildings128-v1.safetensors"),Xm.forEach(l),Lm.forEach(l),At.forEach(l),qu.forEach(l),$u=u(qn),Ia=r(qn,"LI",{});var Ou=n(Ia);Ru=o(Ou,"SDXL 1.0:"),vs=r(Ou,"UL",{});var Cm=n(vs);Js=r(Cm,"LI",{});var Sm=n(Js);Fl=r(Sm,"A",{href:!0,rel:!0});var Ym=n(Fl);Iu=o(Ym,"https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_offset_example-lora_1.0.safetensors"),Ym.forEach(l),Sm.forEach(l),Cm.forEach(l),Ou.forEach(l),qn.forEach(l),un=u(e),Ut=r(e,"P",{});var On=n(Ut);ku=o(On,"Here is an example of how to perform inference with these checkpoints in "),Ts=r(On,"CODE",{});var Dm=n(Ts);Au=o(Dm,"diffusers"),Dm.forEach(l),Wu=o(On,":"),On.forEach(l),cn=u(e),v(Ql.$$.fragment,e),dn=u(e),Xe=r(e,"P",{});var Bs=n(Xe);Es=r(Bs,"CODE",{});var xm=n(Es);Gu=o(xm,"Kamepan.safetensors"),xm.forEach(l),Bu=o(Bs," comes from "),zl=r(Bs,"A",{href:!0,rel:!0});var Fm=n(zl);Vu=o(Fm,"https://civitai.com/models/22279?modelVersionId=118556"),Fm.forEach(l),Nu=o(Bs," ."),Bs.forEach(l),mn=u(e),ka=r(e,"P",{});var Qm=n(ka);Lu=o(Qm,"If you notice carefully, the inference UX is exactly identical to what we presented in the sections above."),Qm.forEach(l),wn=u(e),jt=r(e,"P",{});var Kn=n(jt);Xu=o(Kn,"Thanks to "),Hl=r(Kn,"A",{href:!0,rel:!0});var zm=n(Hl);Cu=o(zm,"@isidentical"),zm.forEach(l),Su=o(Kn," for helping us on integrating this feature."),Kn.forEach(l),yn=u(e),v(Zt.$$.fragment,e),_n=u(e),Ce=r(e,"H3",{class:!0});var ei=n(Ce);$t=r(ei,"A",{id:!0,class:!0,href:!0});var Hm=n($t);Us=r(Hm,"SPAN",{});var Pm=n(Us);v(Pl.$$.fragment,Pm),Pm.forEach(l),Hm.forEach(l),Yu=u(ei),js=r(ei,"SPAN",{});var qm=n(js);Du=o(qm,"TheLastBen"),qm.forEach(l),ei.forEach(l),bn=u(e),Aa=r(e,"P",{});var Om=n(Aa);xu=o(Om,"Here is an example:"),Om.forEach(l),gn=u(e),v(ql.$$.fragment,e),this.h()},h(){p(c,"name","hf:doc:metadata"),p(c,"content",JSON.stringify(yw)),p(y,"id","lowrank-adaptation-of-large-language-models-lora"),p(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"),p(y,"href","#lowrank-adaptation-of-large-language-models-lora"),p(d,"class","relative group"),p(V,"href","https://arxiv.org/abs/2106.09685"),p(V,"rel","nofollow"),p(L,"href","https://www.pnas.org/doi/10.1073/pnas.1611835114"),p(L,"rel","nofollow"),p(ta,"href","/docs/diffusers/v0.21.0/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs"),p(Wt,"href","https://github.com/cloneofsimo"),p(Wt,"rel","nofollow"),p(Gt,"href","https://github.com/cloneofsimo/lora"),p(Gt,"rel","nofollow"),p(Bt,"href","https://github.com/huggingface/diffusers/tree/main/examples/text_to_image#training-with-lora"),p(Bt,"rel","nofollow"),p(Vt,"href","https://github.com/huggingface/diffusers/tree/main/examples/dreambooth#training-with-low-rank-adaptation-of-large-language-models-lora"),p(Vt,"rel","nofollow"),p(la,"href","hf.co/join"),p(xe,"id","texttoimage"),p(xe,"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(xe,"href","#texttoimage"),p(Ue,"class","relative group"),p(Fe,"id","text-to-image-training"),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","#text-to-image-training"),p(je,"class","relative group"),p(Ct,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),p(Ct,"rel","nofollow"),p(St,"href","https://huggingface.co/datasets/lambdalabs/pokemon-blip-captions"),p(St,"rel","nofollow"),p(Yt,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),p(Yt,"rel","nofollow"),p(oa,"href","create_dataset"),p(xt,"href","https://wandb.ai/pcuenq/text2image-fine-tune/runs/b4k1w0tn?workspace=user-pcuenq"),p(xt,"rel","nofollow"),p(Ft,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py"),p(Ft,"rel","nofollow"),p(ze,"id","text-to-image-inference"),p(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"),p(ze,"href","#text-to-image-inference"),p(Ze,"class","relative group"),p(ia,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(fa,"href","/docs/diffusers/v0.21.0/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler"),p(qe,"id","dreambooth"),p(qe,"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(qe,"href","#dreambooth"),p($e,"class","relative group"),p(Kt,"href","https://arxiv.org/abs/2208.12242"),p(Kt,"rel","nofollow"),p(Ke,"id","dreambooth-training"),p(Ke,"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(Ke,"href","#dreambooth-training"),p(Re,"class","relative group"),p(tl,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),p(tl,"rel","nofollow"),p(ll,"href","https://drive.google.com/drive/folders/1BO_dyz-p65qhBRRMRA4TbZ8qW4rB99JZ"),p(ll,"rel","nofollow"),p(pa,"href","create_dataset"),p(al,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),p(al,"rel","nofollow"),p(sl,"href","https://wandb.ai/pcuenq/text2image-fine-tune/runs/b4k1w0tn?workspace=user-pcuenq"),p(sl,"rel","nofollow"),p(rl,"href","https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py"),p(rl,"rel","nofollow"),p(lt,"id","dreambooth-inference"),p(lt,"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(lt,"href","#dreambooth-inference"),p(Ie,"class","relative group"),p(da,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(ma,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(wa,"href","/docs/diffusers/v0.21.0/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs"),p(ya,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(dl,"href","https://huggingface.co/patrickvonplaten/lora_dreambooth_dog_example"),p(dl,"rel","nofollow"),p(yl,"href","https://huggingface.co/sayakpaul/dreambooth"),p(yl,"rel","nofollow"),p(it,"id","stable-diffusion-xl"),p(it,"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(it,"href","#stable-diffusion-xl"),p(ke,"class","relative group"),p(bl,"href","https://huggingface.co/papers/2307.01952"),p(bl,"rel","nofollow"),p(gl,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/README_sdxl.md"),p(gl,"rel","nofollow"),p(Ml,"href","https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_sdxl.md"),p(Ml,"rel","nofollow"),p(ht,"id","unloading-lora-parameters"),p(ht,"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(ht,"href","#unloading-lora-parameters"),p(Ae,"class","relative group"),p(_a,"href","/docs/diffusers/v0.21.0/en/api/loaders#diffusers.loaders.LoraLoaderMixin.unload_lora_weights"),p(ct,"id","fusing-lora-parameters"),p(ct,"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(ct,"href","#fusing-lora-parameters"),p(We,"class","relative group"),p(ba,"href","/docs/diffusers/v0.21.0/en/api/loaders#diffusers.loaders.LoraLoaderMixin.fuse_lora"),p(mt,"id","unfusing-lora-parameters"),p(mt,"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(mt,"href","#unfusing-lora-parameters"),p(Ge,"class","relative group"),p(ga,"href","/docs/diffusers/v0.21.0/en/api/loaders#diffusers.loaders.LoraLoaderMixin.unfuse_lora"),p(wt,"id","working-with-different-lora-scales-when-using-lora-fusion"),p(wt,"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(wt,"href","#working-with-different-lora-scales-when-using-lora-fusion"),p(Be,"class","relative group"),p(yt,"id","supporting-different-lora-checkpoints-from-diffusers"),p(yt,"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(yt,"href","#supporting-different-lora-checkpoints-from-diffusers"),p(Ve,"class","relative group"),p(Zl,"href","https://github.com/kohya-ss/sd-scripts/"),p(Zl,"rel","nofollow"),p($l,"href","https://github.com/TheLastBen/fast-stable-diffusion"),p($l,"rel","nofollow"),p(_t,"id","kohya"),p(_t,"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(_t,"href","#kohya"),p(Ne,"class","relative group"),p(Il,"href","https://github.com/takuma104"),p(Il,"rel","nofollow"),p(kl,"href","https://github.com/isidentical"),p(kl,"rel","nofollow"),p(Ma,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(Al,"href","https://civitai.com/"),p(Al,"rel","nofollow"),p(Wl,"href","https://civitai.com/models/13239/light-and-shadow"),p(Wl,"rel","nofollow"),p(va,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),aw(ja.src,Ku="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/lora_non_lora_comparison.png")||p(ja,"src",Ku),p(ja,"alt","lora_non_lora"),p(Za,"href","/docs/diffusers/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(Jt,"id","kohya-stable-diffusion-xl"),p(Jt,"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(Jt,"href","#kohya-stable-diffusion-xl"),p(Le,"class","relative group"),p(Cl,"href","https://huggingface.co/papers/2307.01952"),p(Cl,"rel","nofollow"),p(Sl,"href","https://civitai.com/models/22279?modelVersionId=118556"),p(Sl,"rel","nofollow"),p(Yl,"href","https://civitai.com/models/104515/sdxlor30costumesrevue-starlight-saijoclaudine-lora"),p(Yl,"rel","nofollow"),p(Dl,"href","https://civitai.com/models/108448/daiton-sdxl-test"),p(Dl,"rel","nofollow"),p(xl,"href","https://filebin.net/2ntfqqnapiu9q3zx/pixelbuildings128-v1.safetensors"),p(xl,"rel","nofollow"),p(Fl,"href","https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/sd_xl_offset_example-lora_1.0.safetensors"),p(Fl,"rel","nofollow"),p(zl,"href","https://civitai.com/models/22279?modelVersionId=118556"),p(zl,"rel","nofollow"),p(Hl,"href","https://github.com/isidentical"),p(Hl,"rel","nofollow"),p($t,"id","thelastben"),p($t,"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($t,"href","#thelastben"),p(Ce,"class","relative group")},m(e,i){t(document.head,c),f(e,b,i),f(e,d,i),t(d,y),t(y,$),J(m,$,null),t(d,_),t(d,I),t(I,g),f(e,w,i),J(k,e,i),f(e,j,i),f(e,R,i),t(R,V),t(V,W),t(R,Q),t(R,Y),t(Y,N),t(R,z),t(R,D),t(D,A),t(R,Z),f(e,q,i),f(e,G,i),t(G,C),t(C,K),t(C,L),t(L,ee),t(C,ea),t(G,ti),t(G,Pa),t(Pa,li),t(G,ai),t(G,Ee),t(Ee,oi),t(Ee,ta),t(ta,si),t(Ee,ri),t(Ee,qa),t(qa,ni),t(Ee,ii),t(G,fi),t(G,Oa),t(Oa,pi),f(e,Vs,i),J(Ye,e,i),f(e,Ns,i),f(e,O,i),t(O,Wt),t(Wt,hi),t(O,ui),t(O,Gt),t(Gt,ci),t(O,di),t(O,Bt),t(Bt,mi),t(O,wi),t(O,Vt),t(Vt,yi),t(O,_i),f(e,Ls,i),f(e,De,i),t(De,bi),t(De,la),t(la,gi),t(De,Mi),f(e,Xs,i),J(Nt,e,i),f(e,Cs,i),f(e,Ue,i),t(Ue,xe),t(xe,Ka),J(Lt,Ka,null),t(Ue,vi),t(Ue,eo),t(eo,Ji),f(e,Ss,i),f(e,aa,i),t(aa,Ti),f(e,Ys,i),f(e,je,i),t(je,Fe),t(Fe,to),J(Xt,to,null),t(je,Ei),t(je,lo),t(lo,Ui),f(e,Ds,i),f(e,ne,i),t(ne,ji),t(ne,Ct),t(Ct,ao),t(ao,Zi),t(ne,$i),t(ne,St),t(St,Ri),t(ne,Ii),f(e,xs,i),f(e,H,i),t(H,ki),t(H,oo),t(oo,Ai),t(H,Wi),t(H,Yt),t(Yt,so),t(so,Gi),t(H,Bi),t(H,ro),t(ro,Vi),t(H,Ni),t(H,oa),t(oa,Li),t(H,Xi),f(e,Fs,i),f(e,ie,i),t(ie,Ci),t(ie,no),t(no,Si),t(ie,Yi),t(ie,io),t(io,Di),t(ie,xi),f(e,Qs,i),J(Dt,e,i),f(e,zs,i),f(e,sa,i),t(sa,Fi),f(e,Hs,i),f(e,fe,i),t(fe,ra),t(ra,fo),t(fo,Qi),t(ra,zi),t(fe,Hi),t(fe,Qe),t(Qe,po),t(po,Pi),t(Qe,qi),t(Qe,xt),t(xt,Oi),t(Qe,Ki),t(fe,ef),t(fe,na),t(na,ho),t(ho,tf),t(na,lf),f(e,Ps,i),f(e,pe,i),t(pe,af),t(pe,Ft),t(Ft,of),t(pe,sf),t(pe,uo),t(uo,rf),t(pe,nf),f(e,qs,i),J(Qt,e,i),f(e,Os,i),f(e,Ze,i),t(Ze,ze),t(ze,co),J(zt,co,null),t(Ze,ff),t(Ze,mo),t(mo,pf),f(e,Ks,i),f(e,he,i),t(he,hf),t(he,ia),t(ia,uf),t(he,cf),t(he,fa),t(fa,df),t(he,mf),f(e,er,i),J(Ht,e,i),f(e,tr,i),f(e,ue,i),t(ue,wf),t(ue,wo),t(wo,yf),t(ue,_f),t(ue,yo),t(yo,bf),t(ue,gf),f(e,lr,i),J(He,e,i),f(e,ar,i),J(Pt,e,i),f(e,or,i),J(Pe,e,i),f(e,sr,i),f(e,$e,i),t($e,qe),t(qe,_o),J(qt,_o,null),t($e,Mf),t($e,bo),t(bo,vf),f(e,rr,i),f(e,Ot,i),t(Ot,Kt),t(Kt,Jf),t(Ot,Tf),f(e,nr,i),J(Oe,e,i),f(e,ir,i),f(e,Re,i),t(Re,Ke),t(Ke,go),J(el,go,null),t(Re,Ef),t(Re,Mo),t(Mo,Uf),f(e,fr,i),f(e,te,i),t(te,jf),t(te,tl),t(tl,vo),t(vo,Zf),t(te,$f),t(te,ll),t(ll,Rf),t(te,If),t(te,pa),t(pa,kf),t(te,Af),f(e,pr,i),f(e,le,i),t(le,Wf),t(le,Jo),t(Jo,Gf),t(le,Bf),t(le,al),t(al,To),t(To,Vf),t(le,Nf),t(le,Eo),t(Eo,Lf),t(le,Xf),f(e,hr,i),f(e,et,i),t(et,Cf),t(et,Uo),t(Uo,Sf),t(et,Yf),f(e,ur,i),J(ol,e,i),f(e,cr,i),f(e,ha,i),t(ha,Df),f(e,dr,i),f(e,ce,i),t(ce,ua),t(ua,jo),t(jo,xf),t(ua,Ff),t(ce,Qf),t(ce,tt),t(tt,Zo),t(Zo,zf),t(tt,Hf),t(tt,sl),t(sl,Pf),t(tt,qf),t(ce,Of),t(ce,ca),t(ca,$o),t($o,Kf),t(ca,ep),f(e,mr,i),f(e,de,i),t(de,tp),t(de,rl),t(rl,lp),t(de,ap),t(de,Ro),t(Ro,op),t(de,sp),f(e,wr,i),f(e,me,i),t(me,rp),t(me,Io),t(Io,np),t(me,ip),t(me,ko),t(ko,fp),t(me,pp),f(e,yr,i),J(nl,e,i),f(e,_r,i),f(e,Ie,i),t(Ie,lt),t(lt,Ao),J(il,Ao,null),t(Ie,hp),t(Ie,Wo),t(Wo,up),f(e,br,i),f(e,at,i),t(at,cp),t(at,da),t(da,dp),t(at,mp),f(e,gr,i),J(fl,e,i),f(e,Mr,i),f(e,we,i),t(we,wp),t(we,Go),t(Go,yp),t(we,_p),t(we,Bo),t(Bo,bp),t(we,gp),f(e,vr,i),J(ot,e,i),f(e,Jr,i),J(pl,e,i),f(e,Tr,i),f(e,ye,i),t(ye,Mp),t(ye,Vo),t(Vo,vp),t(ye,Jp),t(ye,No),t(No,Tp),t(ye,Ep),f(e,Er,i),J(hl,e,i),f(e,Ur,i),J(st,e,i),f(e,jr,i),f(e,ae,i),t(ae,Up),t(ae,ma),t(ma,jp),t(ae,Zp),t(ae,wa),t(wa,$p),t(ae,Rp),t(ae,ya),t(ya,Ip),t(ae,kp),f(e,Zr,i),f(e,rt,i),t(rt,ul),t(ul,cl),t(cl,Ap),t(cl,dl),t(dl,Lo),t(Lo,Wp),t(cl,Gp),t(ul,Bp),J(ml,ul,null),t(rt,Vp),t(rt,Xo),t(Xo,wl),t(wl,Np),t(wl,yl),t(yl,Co),t(Co,Lp),t(wl,Xp),f(e,$r,i),J(nt,e,i),f(e,Rr,i),f(e,ke,i),t(ke,it),t(it,So),J(_l,So,null),t(ke,Cp),t(ke,Yo),t(Yo,Sp),f(e,Ir,i),f(e,ft,i),t(ft,Yp),t(ft,bl),t(bl,Dp),t(ft,xp),f(e,kr,i),f(e,pt,i),t(pt,Do),t(Do,gl),t(gl,Fp),t(pt,Qp),t(pt,xo),t(xo,Ml),t(Ml,zp),f(e,Ar,i),f(e,Ae,i),t(Ae,ht),t(ht,Fo),J(vl,Fo,null),t(Ae,Hp),t(Ae,Qo),t(Qo,Pp),f(e,Wr,i),f(e,ut,i),t(ut,qp),t(ut,_a),t(_a,Op),t(ut,Kp),f(e,Gr,i),f(e,We,i),t(We,ct),t(ct,zo),J(Jl,zo,null),t(We,eh),t(We,Ho),t(Ho,th),f(e,Br,i),f(e,dt,i),t(dt,lh),t(dt,ba),t(ba,ah),t(dt,oh),f(e,Vr,i),f(e,Ge,i),t(Ge,mt),t(mt,Po),J(Tl,Po,null),t(Ge,sh),t(Ge,qo),t(qo,rh),f(e,Nr,i),f(e,_e,i),t(_e,nh),t(_e,Oo),t(Oo,ih),t(_e,fh),t(_e,ga),t(ga,ph),t(_e,hh),f(e,Lr,i),f(e,Be,i),t(Be,wt),t(wt,Ko),J(El,Ko,null),t(Be,uh),t(Be,es),t(es,ch),f(e,Xr,i),f(e,S,i),t(S,dh),t(S,ts),t(ts,mh),t(S,wh),t(S,ls),t(ls,yh),t(S,_h),t(S,as),t(as,bh),t(S,gh),t(S,os),t(os,Mh),t(S,vh),t(S,ss),t(ss,Jh),t(S,Th),t(S,rs),t(rs,Eh),t(S,Uh),f(e,Cr,i),f(e,x,i),t(x,jh),t(x,ns),t(ns,Zh),t(x,$h),t(x,is),t(is,Rh),t(x,Ih),t(x,fs),t(fs,kh),t(x,Ah),t(x,ps),t(ps,Wh),t(x,Gh),t(x,hs),t(hs,Bh),t(x,Vh),f(e,Sr,i),J(Ul,e,i),f(e,Yr,i),f(e,Ve,i),t(Ve,yt),t(yt,us),J(jl,us,null),t(Ve,Nh),t(Ve,cs),t(cs,Lh),f(e,Dr,i),f(e,be,i),t(be,Xh),t(be,Zl),t(Zl,Ch),t(be,Sh),t(be,$l),t($l,Yh),t(be,Dh),f(e,xr,i),f(e,Ne,i),t(Ne,_t),t(_t,ds),J(Rl,ds,null),t(Ne,xh),t(Ne,ms),t(ms,Fh),f(e,Fr,i),f(e,ge,i),t(ge,Qh),t(ge,Il),t(Il,zh),t(ge,Hh),t(ge,kl),t(kl,Ph),t(ge,qh),f(e,Qr,i),f(e,Me,i),t(Me,Oh),t(Me,Ma),t(Ma,Kh),t(Me,eu),t(Me,Al),t(Al,tu),t(Me,lu),f(e,zr,i),f(e,bt,i),t(bt,au),t(bt,Wl),t(Wl,ou),t(bt,su),f(e,Hr,i),J(Gl,e,i),f(e,Pr,i),f(e,gt,i),t(gt,ru),t(gt,va),t(va,nu),t(gt,iu),f(e,qr,i),J(Bl,e,i),f(e,Or,i),f(e,Ja,i),t(Ja,fu),f(e,Kr,i),J(Vl,e,i),f(e,en,i),J(Mt,e,i),f(e,tn,i),f(e,Ta,i),t(Ta,pu),f(e,ln,i),J(Nl,e,i),f(e,an,i),f(e,Ea,i),t(Ea,hu),f(e,on,i),f(e,Ua,i),t(Ua,ja),f(e,sn,i),f(e,vt,i),t(vt,uu),t(vt,Za),t(Za,cu),t(vt,du),f(e,rn,i),J(Ll,e,i),f(e,nn,i),f(e,Le,i),t(Le,Jt),t(Jt,ws),J(Xl,ws,null),t(Le,mu),t(Le,ys),t(ys,wu),f(e,fn,i),f(e,Tt,i),t(Tt,yu),t(Tt,Cl),t(Cl,_u),t(Tt,bu),f(e,pn,i),f(e,$a,i),t($a,gu),f(e,hn,i),f(e,Et,i),t(Et,Ra),t(Ra,Mu),t(Ra,se),t(se,_s),t(_s,Sl),t(Sl,vu),t(se,Ju),t(se,bs),t(bs,Yl),t(Yl,Tu),t(se,Eu),t(se,gs),t(gs,Dl),t(Dl,Uu),t(se,ju),t(se,Ms),t(Ms,xl),t(xl,Zu),t(Et,$u),t(Et,Ia),t(Ia,Ru),t(Ia,vs),t(vs,Js),t(Js,Fl),t(Fl,Iu),f(e,un,i),f(e,Ut,i),t(Ut,ku),t(Ut,Ts),t(Ts,Au),t(Ut,Wu),f(e,cn,i),J(Ql,e,i),f(e,dn,i),f(e,Xe,i),t(Xe,Es),t(Es,Gu),t(Xe,Bu),t(Xe,zl),t(zl,Vu),t(Xe,Nu),f(e,mn,i),f(e,ka,i),t(ka,Lu),f(e,wn,i),f(e,jt,i),t(jt,Xu),t(jt,Hl),t(Hl,Cu),t(jt,Su),f(e,yn,i),J(Zt,e,i),f(e,_n,i),f(e,Ce,i),t(Ce,$t),t($t,Us),J(Pl,Us,null),t(Ce,Yu),t(Ce,js),t(js,Du),f(e,bn,i),f(e,Aa,i),t(Aa,xu),f(e,gn,i),J(ql,e,i),Mn=!0},p(e,[i]){const Ol={};i&2&&(Ol.$$scope={dirty:i,ctx:e}),k.$set(Ol);const Zs={};i&2&&(Zs.$$scope={dirty:i,ctx:e}),Ye.$set(Zs);const $s={};i&2&&($s.$$scope={dirty:i,ctx:e}),He.$set($s);const Rs={};i&2&&(Rs.$$scope={dirty:i,ctx:e}),Pe.$set(Rs);const ve={};i&2&&(ve.$$scope={dirty:i,ctx:e}),Oe.$set(ve);const Is={};i&2&&(Is.$$scope={dirty:i,ctx:e}),ot.$set(Is);const ks={};i&2&&(ks.$$scope={dirty:i,ctx:e}),st.$set(ks);const As={};i&2&&(As.$$scope={dirty:i,ctx:e}),nt.$set(As);const re={};i&2&&(re.$$scope={dirty:i,ctx:e}),Mt.$set(re);const Kl={};i&2&&(Kl.$$scope={dirty:i,ctx:e}),Zt.$set(Kl)},i(e){Mn||(T(m.$$.fragment,e),T(k.$$.fragment,e),T(Ye.$$.fragment,e),T(Nt.$$.fragment,e),T(Lt.$$.fragment,e),T(Xt.$$.fragment,e),T(Dt.$$.fragment,e),T(Qt.$$.fragment,e),T(zt.$$.fragment,e),T(Ht.$$.fragment,e),T(He.$$.fragment,e),T(Pt.$$.fragment,e),T(Pe.$$.fragment,e),T(qt.$$.fragment,e),T(Oe.$$.fragment,e),T(el.$$.fragment,e),T(ol.$$.fragment,e),T(nl.$$.fragment,e),T(il.$$.fragment,e),T(fl.$$.fragment,e),T(ot.$$.fragment,e),T(pl.$$.fragment,e),T(hl.$$.fragment,e),T(st.$$.fragment,e),T(ml.$$.fragment,e),T(nt.$$.fragment,e),T(_l.$$.fragment,e),T(vl.$$.fragment,e),T(Jl.$$.fragment,e),T(Tl.$$.fragment,e),T(El.$$.fragment,e),T(Ul.$$.fragment,e),T(jl.$$.fragment,e),T(Rl.$$.fragment,e),T(Gl.$$.fragment,e),T(Bl.$$.fragment,e),T(Vl.$$.fragment,e),T(Mt.$$.fragment,e),T(Nl.$$.fragment,e),T(Ll.$$.fragment,e),T(Xl.$$.fragment,e),T(Ql.$$.fragment,e),T(Zt.$$.fragment,e),T(Pl.$$.fragment,e),T(ql.$$.fragment,e),Mn=!0)},o(e){E(m.$$.fragment,e),E(k.$$.fragment,e),E(Ye.$$.fragment,e),E(Nt.$$.fragment,e),E(Lt.$$.fragment,e),E(Xt.$$.fragment,e),E(Dt.$$.fragment,e),E(Qt.$$.fragment,e),E(zt.$$.fragment,e),E(Ht.$$.fragment,e),E(He.$$.fragment,e),E(Pt.$$.fragment,e),E(Pe.$$.fragment,e),E(qt.$$.fragment,e),E(Oe.$$.fragment,e),E(el.$$.fragment,e),E(ol.$$.fragment,e),E(nl.$$.fragment,e),E(il.$$.fragment,e),E(fl.$$.fragment,e),E(ot.$$.fragment,e),E(pl.$$.fragment,e),E(hl.$$.fragment,e),E(st.$$.fragment,e),E(ml.$$.fragment,e),E(nt.$$.fragment,e),E(_l.$$.fragment,e),E(vl.$$.fragment,e),E(Jl.$$.fragment,e),E(Tl.$$.fragment,e),E(El.$$.fragment,e),E(Ul.$$.fragment,e),E(jl.$$.fragment,e),E(Rl.$$.fragment,e),E(Gl.$$.fragment,e),E(Bl.$$.fragment,e),E(Vl.$$.fragment,e),E(Mt.$$.fragment,e),E(Nl.$$.fragment,e),E(Ll.$$.fragment,e),E(Xl.$$.fragment,e),E(Ql.$$.fragment,e),E(Zt.$$.fragment,e),E(Pl.$$.fragment,e),E(ql.$$.fragment,e),Mn=!1},d(e){l(c),e&&l(b),e&&l(d),U(m),e&&l(w),U(k,e),e&&l(j),e&&l(R),e&&l(q),e&&l(G),e&&l(Vs),U(Ye,e),e&&l(Ns),e&&l(O),e&&l(Ls),e&&l(De),e&&l(Xs),U(Nt,e),e&&l(Cs),e&&l(Ue),U(Lt),e&&l(Ss),e&&l(aa),e&&l(Ys),e&&l(je),U(Xt),e&&l(Ds),e&&l(ne),e&&l(xs),e&&l(H),e&&l(Fs),e&&l(ie),e&&l(Qs),U(Dt,e),e&&l(zs),e&&l(sa),e&&l(Hs),e&&l(fe),e&&l(Ps),e&&l(pe),e&&l(qs),U(Qt,e),e&&l(Os),e&&l(Ze),U(zt),e&&l(Ks),e&&l(he),e&&l(er),U(Ht,e),e&&l(tr),e&&l(ue),e&&l(lr),U(He,e),e&&l(ar),U(Pt,e),e&&l(or),U(Pe,e),e&&l(sr),e&&l($e),U(qt),e&&l(rr),e&&l(Ot),e&&l(nr),U(Oe,e),e&&l(ir),e&&l(Re),U(el),e&&l(fr),e&&l(te),e&&l(pr),e&&l(le),e&&l(hr),e&&l(et),e&&l(ur),U(ol,e),e&&l(cr),e&&l(ha),e&&l(dr),e&&l(ce),e&&l(mr),e&&l(de),e&&l(wr),e&&l(me),e&&l(yr),U(nl,e),e&&l(_r),e&&l(Ie),U(il),e&&l(br),e&&l(at),e&&l(gr),U(fl,e),e&&l(Mr),e&&l(we),e&&l(vr),U(ot,e),e&&l(Jr),U(pl,e),e&&l(Tr),e&&l(ye),e&&l(Er),U(hl,e),e&&l(Ur),U(st,e),e&&l(jr),e&&l(ae),e&&l(Zr),e&&l(rt),U(ml),e&&l($r),U(nt,e),e&&l(Rr),e&&l(ke),U(_l),e&&l(Ir),e&&l(ft),e&&l(kr),e&&l(pt),e&&l(Ar),e&&l(Ae),U(vl),e&&l(Wr),e&&l(ut),e&&l(Gr),e&&l(We),U(Jl),e&&l(Br),e&&l(dt),e&&l(Vr),e&&l(Ge),U(Tl),e&&l(Nr),e&&l(_e),e&&l(Lr),e&&l(Be),U(El),e&&l(Xr),e&&l(S),e&&l(Cr),e&&l(x),e&&l(Sr),U(Ul,e),e&&l(Yr),e&&l(Ve),U(jl),e&&l(Dr),e&&l(be),e&&l(xr),e&&l(Ne),U(Rl),e&&l(Fr),e&&l(ge),e&&l(Qr),e&&l(Me),e&&l(zr),e&&l(bt),e&&l(Hr),U(Gl,e),e&&l(Pr),e&&l(gt),e&&l(qr),U(Bl,e),e&&l(Or),e&&l(Ja),e&&l(Kr),U(Vl,e),e&&l(en),U(Mt,e),e&&l(tn),e&&l(Ta),e&&l(ln),U(Nl,e),e&&l(an),e&&l(Ea),e&&l(on),e&&l(Ua),e&&l(sn),e&&l(vt),e&&l(rn),U(Ll,e),e&&l(nn),e&&l(Le),U(Xl),e&&l(fn),e&&l(Tt),e&&l(pn),e&&l($a),e&&l(hn),e&&l(Et),e&&l(un),e&&l(Ut),e&&l(cn),U(Ql,e),e&&l(dn),e&&l(Xe),e&&l(mn),e&&l(ka),e&&l(wn),e&&l(jt),e&&l(yn),U(Zt,e),e&&l(_n),e&&l(Ce),U(Pl),e&&l(bn),e&&l(Aa),e&&l(gn),U(ql,e)}}}const yw={local:"lowrank-adaptation-of-large-language-models-lora",sections:[{local:"texttoimage",sections:[{local:"text-to-image-training",title:"Training"},{local:"text-to-image-inference",title:"Inference"}],title:"Text-to-image"},{local:"dreambooth",sections:[{local:"dreambooth-training",title:"Training"},{local:"dreambooth-inference",title:"Inference"}],title:"DreamBooth"},{local:"stable-diffusion-xl",title:"Stable Diffusion XL"},{local:"unloading-lora-parameters",title:"Unloading LoRA parameters"},{local:"fusing-lora-parameters",title:"Fusing LoRA parameters"},{local:"unfusing-lora-parameters",title:"Unfusing LoRA parameters"},{local:"working-with-different-lora-scales-when-using-lora-fusion",title:"Working with different LoRA scales when using LoRA fusion"},{local:"supporting-different-lora-checkpoints-from-diffusers",sections:[{local:"kohya",title:"Kohya"},{local:"kohya-stable-diffusion-xl",title:"Kohya + Stable Diffusion XL"},{local:"thelastben",title:"TheLastBen"}],title:"Supporting different LoRA checkpoints from Diffusers"}],title:"Low-Rank Adaptation of Large Language Models (LoRA)"};function _w(B){return ow(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Jw extends Km{constructor(c){super();ew(this,c,_w,ww,tw,{})}}export{Jw as default,yw as metadata};
