import{S as gf,i as yf,s as _f,e as s,k as d,w as J,t as o,M as bf,c as r,d as a,m as u,a as n,x as E,h as l,b as p,N as Mf,G as t,g as h,y as U,q as j,o as $,B as A,v as vf,L as Tf}from"../../chunks/vendor-hf-doc-builder.js";import{T as qe}from"../../chunks/Tip-hf-doc-builder.js";import{I as Oe}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as B}from"../../chunks/CodeBlock-hf-doc-builder.js";function Jf(k){let f,v,c,g,b;return{c(){f=s("p"),v=o("Currently, LoRA is only supported for the attention layers of the "),c=s("code"),g=o("UNet2DConditionalModel"),b=o(`. We also
support fine-tuning the text encoder for DreamBooth with LoRA in a limited capacity. Fine-tuning the text encoder for DreamBooth generally yields better results, but it can increase compute usage.`)},l(m){f=r(m,"P",{});var w=n(f);v=l(w,"Currently, LoRA is only supported for the attention layers of the "),c=r(w,"CODE",{});var T=n(c);g=l(T,"UNet2DConditionalModel"),T.forEach(a),b=l(w,`. We also
support fine-tuning the text encoder for DreamBooth with LoRA in a limited capacity. Fine-tuning the text encoder for DreamBooth generally yields better results, but it can increase compute usage.`),w.forEach(a)},m(m,w){h(m,f,w),t(f,v),t(f,c),t(c,g),t(f,b)},d(m){m&&a(f)}}}function Ef(k){let f,v,c,g,b;return{c(){f=s("p"),v=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 `),c=s("a"),g=o("Using LoRA for efficient Stable Diffusion fine-tuning"),b=o(" blog for more information about how LoRA works!"),this.h()},l(m){f=r(m,"P",{});var w=n(f);v=l(w,`\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 `),c=r(w,"A",{href:!0,rel:!0});var T=n(c);g=l(T,"Using LoRA for efficient Stable Diffusion fine-tuning"),T.forEach(a),b=l(w," blog for more information about how LoRA works!"),w.forEach(a),this.h()},h(){p(c,"href","https://huggingface.co/blog/lora"),p(c,"rel","nofollow")},m(m,w){h(m,f,w),t(f,v),t(f,c),t(c,g),t(f,b)},d(m){m&&a(f)}}}function Uf(k){let f,v,c,g,b,m,w,T,R,y,I,_,Z,N,G,z,D,C,H,X;return{c(){f=s("p"),v=o("\u{1F4A1} A "),c=s("code"),g=o("scale"),b=o(" value of "),m=s("code"),w=o("0"),T=o(" is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=s("code"),y=o("scale"),I=o(" value of "),_=s("code"),Z=o("1"),N=o(" means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=s("code"),z=o("0"),D=o(" and "),C=s("code"),H=o("1"),X=o(" interpolates between the two weights.")},l(S){f=r(S,"P",{});var M=n(f);v=l(M,"\u{1F4A1} A "),c=r(M,"CODE",{});var O=n(c);g=l(O,"scale"),O.forEach(a),b=l(M," value of "),m=r(M,"CODE",{});var W=n(m);w=l(W,"0"),W.forEach(a),T=l(M," is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=r(M,"CODE",{});var V=n(R);y=l(V,"scale"),V.forEach(a),I=l(M," value of "),_=r(M,"CODE",{});var ue=n(_);Z=l(ue,"1"),ue.forEach(a),N=l(M," means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=r(M,"CODE",{});var Y=n(G);z=l(Y,"0"),Y.forEach(a),D=l(M," and "),C=r(M,"CODE",{});var ce=n(C);H=l(ce,"1"),ce.forEach(a),X=l(M," interpolates between the two weights."),M.forEach(a)},m(S,M){h(S,f,M),t(f,v),t(f,c),t(c,g),t(f,b),t(f,m),t(m,w),t(f,T),t(f,R),t(R,y),t(f,I),t(f,_),t(_,Z),t(f,N),t(f,G),t(G,z),t(f,D),t(f,C),t(C,H),t(f,X)},d(S){S&&a(f)}}}function jf(k){let f,v,c,g,b,m,w,T,R,y,I;return y=new B({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1Yi5yZXBvY2FyZCUyMGltcG9ydCUyMFJlcG9DYXJkJTBBJTBBbG9yYV9tb2RlbF9pZCUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRnNkLW1vZGVsLWZpbmV0dW5lZC1sb3JhLXQ0JTIyJTBBY2FyZCUyMCUzRCUyMFJlcG9DYXJkLmxvYWQobG9yYV9tb2RlbF9pZCklMEFiYXNlX21vZGVsX2lkJTIwJTNEJTIwY2FyZC5kYXRhLnRvX2RpY3QoKSU1QiUyMmJhc2VfbW9kZWwlMjIlNUQlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBLi4u",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)
...`}}),{c(){f=s("p"),v=o(`If you are loading the LoRA parameters from the Hub and if the Hub repository has
a `),c=s("code"),g=o("base_model"),b=o(" tag (such as "),m=s("a"),w=o("this"),T=o(`), then
you can do:`),R=d(),J(y.$$.fragment),this.h()},l(_){f=r(_,"P",{});var Z=n(f);v=l(Z,`If you are loading the LoRA parameters from the Hub and if the Hub repository has
a `),c=r(Z,"CODE",{});var N=n(c);g=l(N,"base_model"),N.forEach(a),b=l(Z," tag (such as "),m=r(Z,"A",{href:!0,rel:!0});var G=n(m);w=l(G,"this"),G.forEach(a),T=l(Z,`), then
you can do:`),Z.forEach(a),R=u(_),E(y.$$.fragment,_),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(_,Z){h(_,f,Z),t(f,v),t(f,c),t(c,g),t(f,b),t(f,m),t(m,w),t(f,T),h(_,R,Z),U(y,_,Z),I=!0},p:Tf,i(_){I||(j(y.$$.fragment,_),I=!0)},o(_){$(y.$$.fragment,_),I=!1},d(_){_&&a(f),_&&a(R),A(y,_)}}}function $f(k){let f,v,c,g,b;return{c(){f=s("p"),v=o("\u{1F4A1} Take a look at the "),c=s("a"),g=o("Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),b=o(" blog for an in-depth analysis of DreamBooth experiments and recommended settings."),this.h()},l(m){f=r(m,"P",{});var w=n(f);v=l(w,"\u{1F4A1} Take a look at the "),c=r(w,"A",{href:!0,rel:!0});var T=n(c);g=l(T,"Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),T.forEach(a),b=l(w," blog for an in-depth analysis of DreamBooth experiments and recommended settings."),w.forEach(a),this.h()},h(){p(c,"href","https://huggingface.co/blog/dreambooth"),p(c,"rel","nofollow")},m(m,w){h(m,f,w),t(f,v),t(f,c),t(c,g),t(f,b)},d(m){m&&a(f)}}}function Af(k){let f,v,c,g,b,m,w,T,R,y,I,_,Z,N,G,z,D,C,H,X;return{c(){f=s("p"),v=o("\u{1F4A1} A "),c=s("code"),g=o("scale"),b=o(" value of "),m=s("code"),w=o("0"),T=o(" is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=s("code"),y=o("scale"),I=o(" value of "),_=s("code"),Z=o("1"),N=o(" means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=s("code"),z=o("0"),D=o(" and "),C=s("code"),H=o("1"),X=o(" interpolates between the two weights.")},l(S){f=r(S,"P",{});var M=n(f);v=l(M,"\u{1F4A1} A "),c=r(M,"CODE",{});var O=n(c);g=l(O,"scale"),O.forEach(a),b=l(M," value of "),m=r(M,"CODE",{});var W=n(m);w=l(W,"0"),W.forEach(a),T=l(M," is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=r(M,"CODE",{});var V=n(R);y=l(V,"scale"),V.forEach(a),I=l(M," value of "),_=r(M,"CODE",{});var ue=n(_);Z=l(ue,"1"),ue.forEach(a),N=l(M," means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=r(M,"CODE",{});var Y=n(G);z=l(Y,"0"),Y.forEach(a),D=l(M," and "),C=r(M,"CODE",{});var ce=n(C);H=l(ce,"1"),ce.forEach(a),X=l(M," interpolates between the two weights."),M.forEach(a)},m(S,M){h(S,f,M),t(f,v),t(f,c),t(c,g),t(f,b),t(f,m),t(m,w),t(f,T),t(f,R),t(R,y),t(f,I),t(f,_),t(_,Z),t(f,N),t(f,G),t(G,z),t(f,D),t(f,C),t(C,H),t(f,X)},d(S){S&&a(f)}}}function Rf(k){let f,v,c,g,b,m,w,T;return{c(){f=s("p"),v=o(`If your LoRA parameters involve the UNet as well as the Text Encoder, then passing
`),c=s("code"),g=o('cross_attention_kwargs={"scale": 0.5}'),b=o(" will apply the "),m=s("code"),w=o("scale"),T=o(` value to both the UNet
and the Text Encoder.`)},l(R){f=r(R,"P",{});var y=n(f);v=l(y,`If your LoRA parameters involve the UNet as well as the Text Encoder, then passing
`),c=r(y,"CODE",{});var I=n(c);g=l(I,'cross_attention_kwargs={"scale": 0.5}'),I.forEach(a),b=l(y," will apply the "),m=r(y,"CODE",{});var _=n(m);w=l(_,"scale"),_.forEach(a),T=l(y,` value to both the UNet
and the Text Encoder.`),y.forEach(a)},m(R,y){h(R,f,y),t(f,v),t(f,c),t(c,g),t(f,b),t(f,m),t(m,w),t(f,T)},d(R){R&&a(f)}}}function Zf(k){let f,v,c,g,b,m,w,T;return{c(){f=s("p"),v=o("If you\u2019re loading a checkpoint in the "),c=s("code"),g=o("safetensors"),b=o(" format, please ensure you have "),m=s("code"),w=o("safetensors"),T=o(" installed.")},l(R){f=r(R,"P",{});var y=n(f);v=l(y,"If you\u2019re loading a checkpoint in the "),c=r(y,"CODE",{});var I=n(c);g=l(I,"safetensors"),I.forEach(a),b=l(y," format, please ensure you have "),m=r(y,"CODE",{});var _=n(m);w=l(_,"safetensors"),_.forEach(a),T=l(y," installed."),y.forEach(a)},m(R,y){h(R,f,y),t(f,v),t(f,c),t(c,g),t(f,b),t(f,m),t(m,w),t(f,T)},d(R){R&&a(f)}}}function If(k){let f,v,c,g,b,m,w,T,R,y,I,_,Z,N,G,z,D,C,H,X,S,M,O,W,V,ue,Y,ce,hs,fs,ka,ps,ds,me,us,Pt,cs,ms,Na,ws,gs,ys,Ga,_s,Wo,Je,Bo,x,Ke,bs,Ms,et,vs,Ts,tt,Js,Es,at,Us,js,Co,Ee,$s,Qt,As,Rs,So,ot,Lo,we,Ue,Wa,lt,Zs,Ba,Is,Do,zt,ks,Xo,ge,je,Ca,st,Ns,Sa,Gs,Vo,K,Ws,rt,La,Bs,Cs,nt,Ss,Ls,Yo,L,Ds,Da,Xs,Vs,it,Xa,Ys,xs,Va,Fs,Ps,Ht,Qs,zs,xo,ee,Hs,Ya,qs,Os,xa,Ks,er,Fo,ht,Po,qt,tr,Qo,te,Ot,Fa,ar,or,lr,$e,Pa,sr,rr,ft,nr,ir,hr,Kt,Qa,fr,pr,zo,ae,dr,pt,ur,cr,za,mr,wr,Ho,dt,qo,ye,Ae,Ha,ut,gr,qa,yr,Oo,oe,_r,ea,br,Mr,ta,vr,Tr,Ko,ct,el,le,Jr,Oa,Er,Ur,Ka,jr,$r,tl,Re,al,mt,ol,Ze,ll,_e,Ie,eo,wt,Ar,to,Rr,sl,gt,yt,Zr,Ir,rl,ke,nl,be,Ne,ao,_t,kr,oo,Nr,il,F,Gr,bt,lo,Wr,Br,Mt,Cr,Sr,aa,Lr,Dr,hl,P,Xr,so,Vr,Yr,vt,ro,xr,Fr,no,Pr,Qr,fl,Ge,zr,io,Hr,qr,pl,Tt,dl,oa,Or,ul,se,la,ho,Kr,en,tn,We,fo,an,on,Jt,ln,sn,rn,sa,po,nn,hn,cl,re,fn,Et,pn,dn,uo,un,cn,ml,ne,mn,co,wn,gn,mo,yn,_n,wl,Ut,gl,Me,Be,wo,jt,bn,go,Mn,yl,Ce,vn,ra,Tn,Jn,_l,$t,bl,ie,En,yo,Un,jn,_o,$n,An,Ml,Se,vl,At,Tl,he,Rn,bo,Zn,In,Mo,kn,Nn,Jl,Rt,El,Le,Ul,Q,Gn,na,Wn,Bn,ia,Cn,Sn,ha,Ln,Dn,jl,De,Zt,It,Xn,kt,vo,Vn,Yn,xn,Nt,Fn,To,Gt,Pn,Wt,Jo,Qn,zn,$l,q,Eo,Hn,qn,fa,On,Kn,pa,ei,ti,Al,ve,Xe,Uo,Bt,ai,jo,oi,Rl,fe,li,da,si,ri,Ct,ni,ii,Zl,Ve,hi,St,fi,pi,Il,Lt,kl,Ye,di,ua,ui,ci,Nl,Dt,Gl,ca,mi,Wl,Xt,Bl,xe,Cl,ma,wi,Sl,Vt,Ll,wa,gi,Dl,ga,ya,Ui,Xl,Fe,yi,_a,_i,bi,Vl,Yt,Yl;return m=new Oe({}),I=new qe({props:{warning:!0,$$slots:{default:[Jf]},$$scope:{ctx:k}}}),Je=new qe({props:{$$slots:{default:[Ef]},$$scope:{ctx:k}}}),ot=new B({props:{code:"aHVnZ2luZ2ZhY2UtY2xpJTIwbG9naW4=",highlighted:"huggingface-cli login"}}),lt=new Oe({}),st=new Oe({}),ht=new B({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>`}}),dt=new B({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`}}),ut=new Oe({}),ct=new B({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEElMEFtb2RlbF9iYXNlJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2Jhc2UlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpJTBBcGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIuZnJvbV9jb25maWcocGlwZS5zY2hlZHVsZXIuY29uZmlnKQ==",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)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)`}}),Re=new qe({props:{$$slots:{default:[Uf]},$$scope:{ctx:k}}}),mt=new B({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>)`}}),Ze=new qe({props:{$$slots:{default:[jf]},$$scope:{ctx:k}}}),wt=new Oe({}),ke=new qe({props:{$$slots:{default:[$f]},$$scope:{ctx:k}}}),_t=new Oe({}),Tt=new B({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>`}}),Ut=new B({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`}}),jt=new Oe({}),$t=new B({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFtb2RlbF9iYXNlJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2Jhc2UlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYp",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)`}}),Se=new qe({props:{$$slots:{default:[Af]},$$scope:{ctx:k}}}),At=new B({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>)`}}),Rt=new B({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1Yi5yZXBvY2FyZCUyMGltcG9ydCUyMFJlcG9DYXJkJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFsb3JhX21vZGVsX2lkJTIwJTNEJTIwJTIyc2F5YWtwYXVsJTJGZHJlYW1ib290aC10ZXh0LWVuY29kZXItdGVzdCUyMiUwQWNhcmQlMjAlM0QlMjBSZXBvQ2FyZC5sb2FkKGxvcmFfbW9kZWxfaWQpJTBBYmFzZV9tb2RlbF9pZCUyMCUzRCUyMGNhcmQuZGF0YS50b19kaWN0KCklNUIlMjJiYXNlX21vZGVsJTIyJTVEJTBBJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsX2lkJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUlMjAlM0QlMjBwaXBlLnRvKCUyMmN1ZGElMjIpJTBBcGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyhsb3JhX21vZGVsX2lkKSUwQWltYWdlJTIwJTNEJTIwcGlwZSglMjJBJTIwcGljdHVyZSUyMG9mJTIwYSUyMHNrcyUyMGRvZyUyMGluJTIwYSUyMGJ1Y2tldCUyMiUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QyNSkuaW1hZ2VzJTVCMCU1RA==",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)
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>]`}}),Le=new qe({props:{$$slots:{default:[Rf]},$$scope:{ctx:k}}}),Nt=new B({props:{code:"cGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyhsb3JhX21vZGVsX3BhdGgp",highlighted:"pipe.load_lora_weights(lora_model_path)"}}),Bt=new Oe({}),Lt=new B({props:{code:"d2dldCUyMGh0dHBzJTNBJTJGJTJGY2l2aXRhaS5jb20lMkZhcGklMkZkb3dubG9hZCUyRm1vZGVscyUyRjE1NjAzJTIwLU8lMjBsaWdodF9hbmRfc2hhZG93LnNhZmV0ZW5zb3Jz",highlighted:"wget https://civitai.com/api/download/models/15603 -O light_and_shadow.safetensors"}}),Dt=new B({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnc2RmJTJGQ291bnRlcmZlaXQtVjIuNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHNhZmV0eV9jaGVja2VyJTNETm9uZSUwQSkudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZS5zY2hlZHVsZXIlMjAlM0QlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIuZnJvbV9jb25maWcoJTBBJTIwJTIwJTIwJTIwcGlwZWxpbmUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHVzZV9rYXJyYXNfc2lnbWFzJTNEVHJ1ZSUwQSk=",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>
).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>
)`}}),Xt=new B({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>)'}}),xe=new qe({props:{warning:!0,$$slots:{default:[Zf]},$$scope:{ctx:k}}}),Vt=new B({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`}}),Yt=new B({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)`}}),{c(){f=s("meta"),v=d(),c=s("h1"),g=s("a"),b=s("span"),J(m.$$.fragment),w=d(),T=s("span"),R=o("Low-Rank Adaptation of Large Language Models (LoRA)"),y=d(),J(I.$$.fragment),_=d(),Z=s("p"),N=s("a"),G=o("Low-Rank Adaptation of Large Language Models (LoRA)"),z=o(" is a training method that accelerates the training of large models while consuming less memory. It adds pairs of rank-decomposition weight matrices (called "),D=s("strong"),C=o("update matrices"),H=o(") to existing weights, and "),X=s("strong"),S=o("only"),M=o(" trains those newly added weights. This has a couple of advantages:"),O=d(),W=s("ul"),V=s("li"),ue=o("Previous pretrained weights are kept frozen so the model is not as prone to "),Y=s("a"),ce=o("catastrophic forgetting"),hs=o("."),fs=d(),ka=s("li"),ps=o("Rank-decomposition matrices have significantly fewer parameters than the original model, which means that trained LoRA weights are easily portable."),ds=d(),me=s("li"),us=o("LoRA matrices are generally added to the attention layers of the original model. \u{1F9E8} Diffusers provides the "),Pt=s("a"),cs=o("load_attn_procs()"),ms=o(" 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 "),Na=s("code"),ws=o("scale"),gs=o(" parameter."),ys=d(),Ga=s("li"),_s=o("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."),Wo=d(),J(Je.$$.fragment),Bo=d(),x=s("p"),Ke=s("a"),bs=o("cloneofsimo"),Ms=o(" was the first to try out LoRA training for Stable Diffusion in the popular "),et=s("a"),vs=o("lora"),Ts=o(" GitHub repository. \u{1F9E8} Diffusers now supports finetuning with LoRA for "),tt=s("a"),Js=o("text-to-image generation"),Es=o(" and "),at=s("a"),Us=o("DreamBooth"),js=o(". This guide will show you how to do both."),Co=d(),Ee=s("p"),$s=o("If you\u2019d like to store or share your model with the community, login to your Hugging Face account (create "),Qt=s("a"),As=o("one"),Rs=o(" if you don\u2019t have one already):"),So=d(),J(ot.$$.fragment),Lo=d(),we=s("h2"),Ue=s("a"),Wa=s("span"),J(lt.$$.fragment),Zs=d(),Ba=s("span"),Is=o("Text-to-image"),Do=d(),zt=s("p"),ks=o("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."),Xo=d(),ge=s("h3"),je=s("a"),Ca=s("span"),J(st.$$.fragment),Ns=d(),Sa=s("span"),Gs=o("Training"),Vo=d(),K=s("p"),Ws=o("Let\u2019s finetune "),rt=s("a"),La=s("code"),Bs=o("stable-diffusion-v1-5"),Cs=o(" on the "),nt=s("a"),Ss=o("Pok\xE9mon BLIP captions"),Ls=o(" dataset to generate your own Pok\xE9mon."),Yo=d(),L=s("p"),Ds=o("Specify the "),Da=s("code"),Xs=o("MODEL_NAME"),Vs=o(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),it=s("a"),Xa=s("code"),Ys=o("pretrained_model_name_or_path"),xs=o(" argument. You\u2019ll also need to set the "),Va=s("code"),Fs=o("DATASET_NAME"),Ps=o(" environment variable to the name of the dataset you want to train on. To use your own dataset, take a look at the "),Ht=s("a"),Qs=o("Create a dataset for training"),zs=o(" guide."),xo=d(),ee=s("p"),Hs=o("The "),Ya=s("code"),qs=o("OUTPUT_DIR"),Os=o(" and "),xa=s("code"),Ks=o("HUB_MODEL_ID"),er=o(" variables are optional and specify where to save the model to on the Hub:"),Fo=d(),J(ht.$$.fragment),Po=d(),qt=s("p"),tr=o("There are some flags to be aware of before you start training:"),Qo=d(),te=s("ul"),Ot=s("li"),Fa=s("code"),ar=o("--push_to_hub"),or=o(" stores the trained LoRA embeddings on the Hub."),lr=d(),$e=s("li"),Pa=s("code"),sr=o("--report_to=wandb"),rr=o(" reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),ft=s("a"),nr=o("report"),ir=o(")."),hr=d(),Kt=s("li"),Qa=s("code"),fr=o("--learning_rate=1e-04"),pr=o(", you can afford to use a higher learning rate than you normally would with LoRA."),zo=d(),ae=s("p"),dr=o("Now you\u2019re ready to launch the training (you can find the full training script "),pt=s("a"),ur=o("here"),cr=o("). Training takes about 5 hours on a 2080 Ti GPU with 11GB of RAM, and it\u2019ll create and save model checkpoints and the "),za=s("code"),mr=o("pytorch_lora_weights"),wr=o(" in your repository."),Ho=d(),J(dt.$$.fragment),qo=d(),ye=s("h3"),Ae=s("a"),Ha=s("span"),J(ut.$$.fragment),gr=d(),qa=s("span"),yr=o("Inference"),Oo=d(),oe=s("p"),_r=o("Now you can use the model for inference by loading the base model in the "),ea=s("a"),br=o("StableDiffusionPipeline"),Mr=o(" and then the "),ta=s("a"),vr=o("DPMSolverMultistepScheduler"),Tr=o(":"),Ko=d(),J(ct.$$.fragment),el=d(),le=s("p"),Jr=o("Load the LoRA weights from your finetuned model "),Oa=s("em"),Er=o("on top of the base model weights"),Ur=o(", 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 "),Ka=s("code"),jr=o("scale"),$r=o(" parameter:"),tl=d(),J(Re.$$.fragment),al=d(),J(mt.$$.fragment),ol=d(),J(Ze.$$.fragment),ll=d(),_e=s("h2"),Ie=s("a"),eo=s("span"),J(wt.$$.fragment),Ar=d(),to=s("span"),Rr=o("DreamBooth"),sl=d(),gt=s("p"),yt=s("a"),Zr=o("DreamBooth"),Ir=o(" 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)."),rl=d(),J(ke.$$.fragment),nl=d(),be=s("h3"),Ne=s("a"),ao=s("span"),J(_t.$$.fragment),kr=d(),oo=s("span"),Nr=o("Training"),il=d(),F=s("p"),Gr=o("Let\u2019s finetune "),bt=s("a"),lo=s("code"),Wr=o("stable-diffusion-v1-5"),Br=o(" with DreamBooth and LoRA with some \u{1F436} "),Mt=s("a"),Cr=o("dog images"),Sr=o(". Download and save these images to a directory. To use your own dataset, take a look at the "),aa=s("a"),Lr=o("Create a dataset for training"),Dr=o(" guide."),hl=d(),P=s("p"),Xr=o("To start, specify the "),so=s("code"),Vr=o("MODEL_NAME"),Yr=o(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),vt=s("a"),ro=s("code"),xr=o("pretrained_model_name_or_path"),Fr=o(" argument. You\u2019ll also need to set "),no=s("code"),Pr=o("INSTANCE_DIR"),Qr=o(" to the path of the directory containing the images."),fl=d(),Ge=s("p"),zr=o("The "),io=s("code"),Hr=o("OUTPUT_DIR"),qr=o(" variables is optional and specifies where to save the model to on the Hub:"),pl=d(),J(Tt.$$.fragment),dl=d(),oa=s("p"),Or=o("There are some flags to be aware of before you start training:"),ul=d(),se=s("ul"),la=s("li"),ho=s("code"),Kr=o("--push_to_hub"),en=o(" stores the trained LoRA embeddings on the Hub."),tn=d(),We=s("li"),fo=s("code"),an=o("--report_to=wandb"),on=o(" reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),Jt=s("a"),ln=o("report"),sn=o(")."),rn=d(),sa=s("li"),po=s("code"),nn=o("--learning_rate=1e-04"),hn=o(", you can afford to use a higher learning rate than you normally would with LoRA."),cl=d(),re=s("p"),fn=o("Now you\u2019re ready to launch the training (you can find the full training script "),Et=s("a"),pn=o("here"),dn=o("). The script creates and saves model checkpoints and the "),uo=s("code"),un=o("pytorch_lora_weights.bin"),cn=o(" file in your repository."),ml=d(),ne=s("p"),mn=o(`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 `),co=s("code"),wn=o("--train_text_encoder"),gn=o(" while launching the "),mo=s("code"),yn=o("train_dreambooth_lora.py"),_n=o(" script."),wl=d(),J(Ut.$$.fragment),gl=d(),Me=s("h3"),Be=s("a"),wo=s("span"),J(jt.$$.fragment),bn=d(),go=s("span"),Mn=o("Inference"),yl=d(),Ce=s("p"),vn=o("Now you can use the model for inference by loading the base model in the "),ra=s("a"),Tn=o("StableDiffusionPipeline"),Jn=o(":"),_l=d(),J($t.$$.fragment),bl=d(),ie=s("p"),En=o("Load the LoRA weights from your finetuned DreamBooth model "),yo=s("em"),Un=o("on top of the base model weights"),jn=o(", 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 "),_o=s("code"),$n=o("scale"),An=o(" parameter:"),Ml=d(),J(Se.$$.fragment),vl=d(),J(At.$$.fragment),Tl=d(),he=s("p"),Rn=o("If you used "),bo=s("code"),Zn=o("--train_text_encoder"),In=o(" during training, then use "),Mo=s("code"),kn=o("pipe.load_lora_weights()"),Nn=o(` to load the LoRA
weights. For example:`),Jl=d(),J(Rt.$$.fragment),El=d(),J(Le.$$.fragment),Ul=d(),Q=s("p"),Gn=o("Note that the use of "),na=s("a"),Wn=o("load_lora_weights()"),Bn=o(" is preferred to "),ia=s("a"),Cn=o("load_attn_procs()"),Sn=o(` for loading LoRA parameters. This is because
`),ha=s("a"),Ln=o("load_lora_weights()"),Dn=o(" can handle the following situations:"),jl=d(),De=s("ul"),Zt=s("li"),It=s("p"),Xn=o("LoRA parameters that don\u2019t have separate identifiers for the UNet and the text encoder (such as "),kt=s("a"),vo=s("code"),Vn=o('"patrickvonplaten/lora_dreambooth_dog_example"'),Yn=o("). So, you can just do:"),xn=d(),J(Nt.$$.fragment),Fn=d(),To=s("li"),Gt=s("p"),Pn=o("LoRA parameters that have separate identifiers for the UNet and the text encoder such as: "),Wt=s("a"),Jo=s("code"),Qn=o('"sayakpaul/dreambooth"'),zn=o("."),$l=d(),q=s("p"),Eo=s("strong"),Hn=o("Note"),qn=o(" that it is possible to provide a local directory path to "),fa=s("a"),On=o("load_lora_weights()"),Kn=o(" as well as "),pa=s("a"),ei=o("load_attn_procs()"),ti=o(`. To know about the supported inputs,
refer to the respective docstrings.`),Al=d(),ve=s("h2"),Xe=s("a"),Uo=s("span"),J(Bt.$$.fragment),ai=d(),jo=s("span"),oi=o("Supporting A1111 themed LoRA checkpoints from Diffusers"),Rl=d(),fe=s("p"),li=o(`To provide seamless interoperability with A1111 to our users, we support loading A1111 formatted
LoRA checkpoints using `),da=s("a"),si=o("load_lora_weights()"),ri=o(` in a limited capacity.
In this section, we explain how to load an A1111 formatted LoRA checkpoint from `),Ct=s("a"),ni=o("CivitAI"),ii=o(`
in Diffusers and perform inference with it.`),Zl=d(),Ve=s("p"),hi=o(`First, download a checkpoint. We\u2019ll use
`),St=s("a"),fi=o("this one"),pi=o(" for demonstration purposes."),Il=d(),J(Lt.$$.fragment),kl=d(),Ye=s("p"),di=o("Next, we initialize a "),ua=s("a"),ui=o("~DiffusionPipeline"),ci=o(":"),Nl=d(),J(Dt.$$.fragment),Gl=d(),ca=s("p"),mi=o("We then load the checkpoint downloaded from CivitAI:"),Wl=d(),J(Xt.$$.fragment),Bl=d(),J(xe.$$.fragment),Cl=d(),ma=s("p"),wi=o("And then it\u2019s time for running inference:"),Sl=d(),J(Vt.$$.fragment),Ll=d(),wa=s("p"),gi=o("Below is a comparison between the LoRA and the non-LoRA results:"),Dl=d(),ga=s("p"),ya=s("img"),Xl=d(),Fe=s("p"),yi=o(`You have a similar checkpoint stored on the Hugging Face Hub, you can load it
directly with `),_a=s("a"),_i=o("load_lora_weights()"),bi=o(" like so:"),Vl=d(),J(Yt.$$.fragment),this.h()},l(e){const i=bf('[data-svelte="svelte-1phssyn"]',document.head);f=r(i,"META",{name:!0,content:!0}),i.forEach(a),v=u(e),c=r(e,"H1",{class:!0});var xt=n(c);g=r(xt,"A",{id:!0,class:!0,href:!0});var $o=n(g);b=r($o,"SPAN",{});var Ao=n(b);E(m.$$.fragment,Ao),Ao.forEach(a),$o.forEach(a),w=u(xt),T=r(xt,"SPAN",{});var Ro=n(T);R=l(Ro,"Low-Rank Adaptation of Large Language Models (LoRA)"),Ro.forEach(a),xt.forEach(a),y=u(e),E(I.$$.fragment,e),_=u(e),Z=r(e,"P",{});var pe=n(Z);N=r(pe,"A",{href:!0,rel:!0});var Zo=n(N);G=l(Zo,"Low-Rank Adaptation of Large Language Models (LoRA)"),Zo.forEach(a),z=l(pe," is a training method that accelerates the training of large models while consuming less memory. It adds pairs of rank-decomposition weight matrices (called "),D=r(pe,"STRONG",{});var Io=n(D);C=l(Io,"update matrices"),Io.forEach(a),H=l(pe,") to existing weights, and "),X=r(pe,"STRONG",{});var ko=n(X);S=l(ko,"only"),ko.forEach(a),M=l(pe," trains those newly added weights. This has a couple of advantages:"),pe.forEach(a),O=u(e),W=r(e,"UL",{});var Pe=n(W);V=r(Pe,"LI",{});var xl=n(V);ue=l(xl,"Previous pretrained weights are kept frozen so the model is not as prone to "),Y=r(xl,"A",{href:!0,rel:!0});var ji=n(Y);ce=l(ji,"catastrophic forgetting"),ji.forEach(a),hs=l(xl,"."),xl.forEach(a),fs=u(Pe),ka=r(Pe,"LI",{});var $i=n(ka);ps=l($i,"Rank-decomposition matrices have significantly fewer parameters than the original model, which means that trained LoRA weights are easily portable."),$i.forEach(a),ds=u(Pe),me=r(Pe,"LI",{});var ba=n(me);us=l(ba,"LoRA matrices are generally added to the attention layers of the original model. \u{1F9E8} Diffusers provides the "),Pt=r(ba,"A",{href:!0});var Ai=n(Pt);cs=l(Ai,"load_attn_procs()"),Ai.forEach(a),ms=l(ba," 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 "),Na=r(ba,"CODE",{});var Ri=n(Na);ws=l(Ri,"scale"),Ri.forEach(a),gs=l(ba," parameter."),ba.forEach(a),ys=u(Pe),Ga=r(Pe,"LI",{});var Zi=n(Ga);_s=l(Zi,"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."),Zi.forEach(a),Pe.forEach(a),Wo=u(e),E(Je.$$.fragment,e),Bo=u(e),x=r(e,"P",{});var Te=n(x);Ke=r(Te,"A",{href:!0,rel:!0});var Ii=n(Ke);bs=l(Ii,"cloneofsimo"),Ii.forEach(a),Ms=l(Te," was the first to try out LoRA training for Stable Diffusion in the popular "),et=r(Te,"A",{href:!0,rel:!0});var ki=n(et);vs=l(ki,"lora"),ki.forEach(a),Ts=l(Te," GitHub repository. \u{1F9E8} Diffusers now supports finetuning with LoRA for "),tt=r(Te,"A",{href:!0,rel:!0});var Ni=n(tt);Js=l(Ni,"text-to-image generation"),Ni.forEach(a),Es=l(Te," and "),at=r(Te,"A",{href:!0,rel:!0});var Gi=n(at);Us=l(Gi,"DreamBooth"),Gi.forEach(a),js=l(Te,". This guide will show you how to do both."),Te.forEach(a),Co=u(e),Ee=r(e,"P",{});var Fl=n(Ee);$s=l(Fl,"If you\u2019d like to store or share your model with the community, login to your Hugging Face account (create "),Qt=r(Fl,"A",{href:!0});var Wi=n(Qt);As=l(Wi,"one"),Wi.forEach(a),Rs=l(Fl," if you don\u2019t have one already):"),Fl.forEach(a),So=u(e),E(ot.$$.fragment,e),Lo=u(e),we=r(e,"H2",{class:!0});var Pl=n(we);Ue=r(Pl,"A",{id:!0,class:!0,href:!0});var Bi=n(Ue);Wa=r(Bi,"SPAN",{});var Ci=n(Wa);E(lt.$$.fragment,Ci),Ci.forEach(a),Bi.forEach(a),Zs=u(Pl),Ba=r(Pl,"SPAN",{});var Si=n(Ba);Is=l(Si,"Text-to-image"),Si.forEach(a),Pl.forEach(a),Do=u(e),zt=r(e,"P",{});var Li=n(zt);ks=l(Li,"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."),Li.forEach(a),Xo=u(e),ge=r(e,"H3",{class:!0});var Ql=n(ge);je=r(Ql,"A",{id:!0,class:!0,href:!0});var Di=n(je);Ca=r(Di,"SPAN",{});var Xi=n(Ca);E(st.$$.fragment,Xi),Xi.forEach(a),Di.forEach(a),Ns=u(Ql),Sa=r(Ql,"SPAN",{});var Vi=n(Sa);Gs=l(Vi,"Training"),Vi.forEach(a),Ql.forEach(a),Vo=u(e),K=r(e,"P",{});var Ma=n(K);Ws=l(Ma,"Let\u2019s finetune "),rt=r(Ma,"A",{href:!0,rel:!0});var Yi=n(rt);La=r(Yi,"CODE",{});var xi=n(La);Bs=l(xi,"stable-diffusion-v1-5"),xi.forEach(a),Yi.forEach(a),Cs=l(Ma," on the "),nt=r(Ma,"A",{href:!0,rel:!0});var Fi=n(nt);Ss=l(Fi,"Pok\xE9mon BLIP captions"),Fi.forEach(a),Ls=l(Ma," dataset to generate your own Pok\xE9mon."),Ma.forEach(a),Yo=u(e),L=r(e,"P",{});var de=n(L);Ds=l(de,"Specify the "),Da=r(de,"CODE",{});var Pi=n(Da);Xs=l(Pi,"MODEL_NAME"),Pi.forEach(a),Vs=l(de," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),it=r(de,"A",{href:!0,rel:!0});var Qi=n(it);Xa=r(Qi,"CODE",{});var zi=n(Xa);Ys=l(zi,"pretrained_model_name_or_path"),zi.forEach(a),Qi.forEach(a),xs=l(de," argument. You\u2019ll also need to set the "),Va=r(de,"CODE",{});var Hi=n(Va);Fs=l(Hi,"DATASET_NAME"),Hi.forEach(a),Ps=l(de," environment variable to the name of the dataset you want to train on. To use your own dataset, take a look at the "),Ht=r(de,"A",{href:!0});var qi=n(Ht);Qs=l(qi,"Create a dataset for training"),qi.forEach(a),zs=l(de," guide."),de.forEach(a),xo=u(e),ee=r(e,"P",{});var va=n(ee);Hs=l(va,"The "),Ya=r(va,"CODE",{});var Oi=n(Ya);qs=l(Oi,"OUTPUT_DIR"),Oi.forEach(a),Os=l(va," and "),xa=r(va,"CODE",{});var Ki=n(xa);Ks=l(Ki,"HUB_MODEL_ID"),Ki.forEach(a),er=l(va," variables are optional and specify where to save the model to on the Hub:"),va.forEach(a),Fo=u(e),E(ht.$$.fragment,e),Po=u(e),qt=r(e,"P",{});var eh=n(qt);tr=l(eh,"There are some flags to be aware of before you start training:"),eh.forEach(a),Qo=u(e),te=r(e,"UL",{});var Ta=n(te);Ot=r(Ta,"LI",{});var Mi=n(Ot);Fa=r(Mi,"CODE",{});var th=n(Fa);ar=l(th,"--push_to_hub"),th.forEach(a),or=l(Mi," stores the trained LoRA embeddings on the Hub."),Mi.forEach(a),lr=u(Ta),$e=r(Ta,"LI",{});var No=n($e);Pa=r(No,"CODE",{});var ah=n(Pa);sr=l(ah,"--report_to=wandb"),ah.forEach(a),rr=l(No," reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),ft=r(No,"A",{href:!0,rel:!0});var oh=n(ft);nr=l(oh,"report"),oh.forEach(a),ir=l(No,")."),No.forEach(a),hr=u(Ta),Kt=r(Ta,"LI",{});var vi=n(Kt);Qa=r(vi,"CODE",{});var lh=n(Qa);fr=l(lh,"--learning_rate=1e-04"),lh.forEach(a),pr=l(vi,", you can afford to use a higher learning rate than you normally would with LoRA."),vi.forEach(a),Ta.forEach(a),zo=u(e),ae=r(e,"P",{});var Ja=n(ae);dr=l(Ja,"Now you\u2019re ready to launch the training (you can find the full training script "),pt=r(Ja,"A",{href:!0,rel:!0});var sh=n(pt);ur=l(sh,"here"),sh.forEach(a),cr=l(Ja,"). Training takes about 5 hours on a 2080 Ti GPU with 11GB of RAM, and it\u2019ll create and save model checkpoints and the "),za=r(Ja,"CODE",{});var rh=n(za);mr=l(rh,"pytorch_lora_weights"),rh.forEach(a),wr=l(Ja," in your repository."),Ja.forEach(a),Ho=u(e),E(dt.$$.fragment,e),qo=u(e),ye=r(e,"H3",{class:!0});var zl=n(ye);Ae=r(zl,"A",{id:!0,class:!0,href:!0});var nh=n(Ae);Ha=r(nh,"SPAN",{});var ih=n(Ha);E(ut.$$.fragment,ih),ih.forEach(a),nh.forEach(a),gr=u(zl),qa=r(zl,"SPAN",{});var hh=n(qa);yr=l(hh,"Inference"),hh.forEach(a),zl.forEach(a),Oo=u(e),oe=r(e,"P",{});var Ea=n(oe);_r=l(Ea,"Now you can use the model for inference by loading the base model in the "),ea=r(Ea,"A",{href:!0});var fh=n(ea);br=l(fh,"StableDiffusionPipeline"),fh.forEach(a),Mr=l(Ea," and then the "),ta=r(Ea,"A",{href:!0});var ph=n(ta);vr=l(ph,"DPMSolverMultistepScheduler"),ph.forEach(a),Tr=l(Ea,":"),Ea.forEach(a),Ko=u(e),E(ct.$$.fragment,e),el=u(e),le=r(e,"P",{});var Ua=n(le);Jr=l(Ua,"Load the LoRA weights from your finetuned model "),Oa=r(Ua,"EM",{});var dh=n(Oa);Er=l(dh,"on top of the base model weights"),dh.forEach(a),Ur=l(Ua,", 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 "),Ka=r(Ua,"CODE",{});var uh=n(Ka);jr=l(uh,"scale"),uh.forEach(a),$r=l(Ua," parameter:"),Ua.forEach(a),tl=u(e),E(Re.$$.fragment,e),al=u(e),E(mt.$$.fragment,e),ol=u(e),E(Ze.$$.fragment,e),ll=u(e),_e=r(e,"H2",{class:!0});var Hl=n(_e);Ie=r(Hl,"A",{id:!0,class:!0,href:!0});var ch=n(Ie);eo=r(ch,"SPAN",{});var mh=n(eo);E(wt.$$.fragment,mh),mh.forEach(a),ch.forEach(a),Ar=u(Hl),to=r(Hl,"SPAN",{});var wh=n(to);Rr=l(wh,"DreamBooth"),wh.forEach(a),Hl.forEach(a),sl=u(e),gt=r(e,"P",{});var Ti=n(gt);yt=r(Ti,"A",{href:!0,rel:!0});var gh=n(yt);Zr=l(gh,"DreamBooth"),gh.forEach(a),Ir=l(Ti," 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)."),Ti.forEach(a),rl=u(e),E(ke.$$.fragment,e),nl=u(e),be=r(e,"H3",{class:!0});var ql=n(be);Ne=r(ql,"A",{id:!0,class:!0,href:!0});var yh=n(Ne);ao=r(yh,"SPAN",{});var _h=n(ao);E(_t.$$.fragment,_h),_h.forEach(a),yh.forEach(a),kr=u(ql),oo=r(ql,"SPAN",{});var bh=n(oo);Nr=l(bh,"Training"),bh.forEach(a),ql.forEach(a),il=u(e),F=r(e,"P",{});var Qe=n(F);Gr=l(Qe,"Let\u2019s finetune "),bt=r(Qe,"A",{href:!0,rel:!0});var Mh=n(bt);lo=r(Mh,"CODE",{});var vh=n(lo);Wr=l(vh,"stable-diffusion-v1-5"),vh.forEach(a),Mh.forEach(a),Br=l(Qe," with DreamBooth and LoRA with some \u{1F436} "),Mt=r(Qe,"A",{href:!0,rel:!0});var Th=n(Mt);Cr=l(Th,"dog images"),Th.forEach(a),Sr=l(Qe,". Download and save these images to a directory. To use your own dataset, take a look at the "),aa=r(Qe,"A",{href:!0});var Jh=n(aa);Lr=l(Jh,"Create a dataset for training"),Jh.forEach(a),Dr=l(Qe," guide."),Qe.forEach(a),hl=u(e),P=r(e,"P",{});var ze=n(P);Xr=l(ze,"To start, specify the "),so=r(ze,"CODE",{});var Eh=n(so);Vr=l(Eh,"MODEL_NAME"),Eh.forEach(a),Yr=l(ze," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),vt=r(ze,"A",{href:!0,rel:!0});var Uh=n(vt);ro=r(Uh,"CODE",{});var jh=n(ro);xr=l(jh,"pretrained_model_name_or_path"),jh.forEach(a),Uh.forEach(a),Fr=l(ze," argument. You\u2019ll also need to set "),no=r(ze,"CODE",{});var $h=n(no);Pr=l($h,"INSTANCE_DIR"),$h.forEach(a),Qr=l(ze," to the path of the directory containing the images."),ze.forEach(a),fl=u(e),Ge=r(e,"P",{});var Ol=n(Ge);zr=l(Ol,"The "),io=r(Ol,"CODE",{});var Ah=n(io);Hr=l(Ah,"OUTPUT_DIR"),Ah.forEach(a),qr=l(Ol," variables is optional and specifies where to save the model to on the Hub:"),Ol.forEach(a),pl=u(e),E(Tt.$$.fragment,e),dl=u(e),oa=r(e,"P",{});var Rh=n(oa);Or=l(Rh,"There are some flags to be aware of before you start training:"),Rh.forEach(a),ul=u(e),se=r(e,"UL",{});var ja=n(se);la=r(ja,"LI",{});var Ji=n(la);ho=r(Ji,"CODE",{});var Zh=n(ho);Kr=l(Zh,"--push_to_hub"),Zh.forEach(a),en=l(Ji," stores the trained LoRA embeddings on the Hub."),Ji.forEach(a),tn=u(ja),We=r(ja,"LI",{});var Go=n(We);fo=r(Go,"CODE",{});var Ih=n(fo);an=l(Ih,"--report_to=wandb"),Ih.forEach(a),on=l(Go," reports and logs the training results to your Weights & Biases dashboard (as an example, take a look at this "),Jt=r(Go,"A",{href:!0,rel:!0});var kh=n(Jt);ln=l(kh,"report"),kh.forEach(a),sn=l(Go,")."),Go.forEach(a),rn=u(ja),sa=r(ja,"LI",{});var Ei=n(sa);po=r(Ei,"CODE",{});var Nh=n(po);nn=l(Nh,"--learning_rate=1e-04"),Nh.forEach(a),hn=l(Ei,", you can afford to use a higher learning rate than you normally would with LoRA."),Ei.forEach(a),ja.forEach(a),cl=u(e),re=r(e,"P",{});var $a=n(re);fn=l($a,"Now you\u2019re ready to launch the training (you can find the full training script "),Et=r($a,"A",{href:!0,rel:!0});var Gh=n(Et);pn=l(Gh,"here"),Gh.forEach(a),dn=l($a,"). The script creates and saves model checkpoints and the "),uo=r($a,"CODE",{});var Wh=n(uo);un=l(Wh,"pytorch_lora_weights.bin"),Wh.forEach(a),cn=l($a," file in your repository."),$a.forEach(a),ml=u(e),ne=r(e,"P",{});var Aa=n(ne);mn=l(Aa,`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 `),co=r(Aa,"CODE",{});var Bh=n(co);wn=l(Bh,"--train_text_encoder"),Bh.forEach(a),gn=l(Aa," while launching the "),mo=r(Aa,"CODE",{});var Ch=n(mo);yn=l(Ch,"train_dreambooth_lora.py"),Ch.forEach(a),_n=l(Aa," script."),Aa.forEach(a),wl=u(e),E(Ut.$$.fragment,e),gl=u(e),Me=r(e,"H3",{class:!0});var Kl=n(Me);Be=r(Kl,"A",{id:!0,class:!0,href:!0});var Sh=n(Be);wo=r(Sh,"SPAN",{});var Lh=n(wo);E(jt.$$.fragment,Lh),Lh.forEach(a),Sh.forEach(a),bn=u(Kl),go=r(Kl,"SPAN",{});var Dh=n(go);Mn=l(Dh,"Inference"),Dh.forEach(a),Kl.forEach(a),yl=u(e),Ce=r(e,"P",{});var es=n(Ce);vn=l(es,"Now you can use the model for inference by loading the base model in the "),ra=r(es,"A",{href:!0});var Xh=n(ra);Tn=l(Xh,"StableDiffusionPipeline"),Xh.forEach(a),Jn=l(es,":"),es.forEach(a),_l=u(e),E($t.$$.fragment,e),bl=u(e),ie=r(e,"P",{});var Ra=n(ie);En=l(Ra,"Load the LoRA weights from your finetuned DreamBooth model "),yo=r(Ra,"EM",{});var Vh=n(yo);Un=l(Vh,"on top of the base model weights"),Vh.forEach(a),jn=l(Ra,", 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 "),_o=r(Ra,"CODE",{});var Yh=n(_o);$n=l(Yh,"scale"),Yh.forEach(a),An=l(Ra," parameter:"),Ra.forEach(a),Ml=u(e),E(Se.$$.fragment,e),vl=u(e),E(At.$$.fragment,e),Tl=u(e),he=r(e,"P",{});var Za=n(he);Rn=l(Za,"If you used "),bo=r(Za,"CODE",{});var xh=n(bo);Zn=l(xh,"--train_text_encoder"),xh.forEach(a),In=l(Za," during training, then use "),Mo=r(Za,"CODE",{});var Fh=n(Mo);kn=l(Fh,"pipe.load_lora_weights()"),Fh.forEach(a),Nn=l(Za,` to load the LoRA
weights. For example:`),Za.forEach(a),Jl=u(e),E(Rt.$$.fragment,e),El=u(e),E(Le.$$.fragment,e),Ul=u(e),Q=r(e,"P",{});var He=n(Q);Gn=l(He,"Note that the use of "),na=r(He,"A",{href:!0});var Ph=n(na);Wn=l(Ph,"load_lora_weights()"),Ph.forEach(a),Bn=l(He," is preferred to "),ia=r(He,"A",{href:!0});var Qh=n(ia);Cn=l(Qh,"load_attn_procs()"),Qh.forEach(a),Sn=l(He,` for loading LoRA parameters. This is because
`),ha=r(He,"A",{href:!0});var zh=n(ha);Ln=l(zh,"load_lora_weights()"),zh.forEach(a),Dn=l(He," can handle the following situations:"),He.forEach(a),jl=u(e),De=r(e,"UL",{});var ts=n(De);Zt=r(ts,"LI",{});var as=n(Zt);It=r(as,"P",{});var os=n(It);Xn=l(os,"LoRA parameters that don\u2019t have separate identifiers for the UNet and the text encoder (such as "),kt=r(os,"A",{href:!0,rel:!0});var Hh=n(kt);vo=r(Hh,"CODE",{});var qh=n(vo);Vn=l(qh,'"patrickvonplaten/lora_dreambooth_dog_example"'),qh.forEach(a),Hh.forEach(a),Yn=l(os,"). So, you can just do:"),os.forEach(a),xn=u(as),E(Nt.$$.fragment,as),as.forEach(a),Fn=u(ts),To=r(ts,"LI",{});var Oh=n(To);Gt=r(Oh,"P",{});var ls=n(Gt);Pn=l(ls,"LoRA parameters that have separate identifiers for the UNet and the text encoder such as: "),Wt=r(ls,"A",{href:!0,rel:!0});var Kh=n(Wt);Jo=r(Kh,"CODE",{});var ef=n(Jo);Qn=l(ef,'"sayakpaul/dreambooth"'),ef.forEach(a),Kh.forEach(a),zn=l(ls,"."),ls.forEach(a),Oh.forEach(a),ts.forEach(a),$l=u(e),q=r(e,"P",{});var Ft=n(q);Eo=r(Ft,"STRONG",{});var tf=n(Eo);Hn=l(tf,"Note"),tf.forEach(a),qn=l(Ft," that it is possible to provide a local directory path to "),fa=r(Ft,"A",{href:!0});var af=n(fa);On=l(af,"load_lora_weights()"),af.forEach(a),Kn=l(Ft," as well as "),pa=r(Ft,"A",{href:!0});var of=n(pa);ei=l(of,"load_attn_procs()"),of.forEach(a),ti=l(Ft,`. To know about the supported inputs,
refer to the respective docstrings.`),Ft.forEach(a),Al=u(e),ve=r(e,"H2",{class:!0});var ss=n(ve);Xe=r(ss,"A",{id:!0,class:!0,href:!0});var lf=n(Xe);Uo=r(lf,"SPAN",{});var sf=n(Uo);E(Bt.$$.fragment,sf),sf.forEach(a),lf.forEach(a),ai=u(ss),jo=r(ss,"SPAN",{});var rf=n(jo);oi=l(rf,"Supporting A1111 themed LoRA checkpoints from Diffusers"),rf.forEach(a),ss.forEach(a),Rl=u(e),fe=r(e,"P",{});var Ia=n(fe);li=l(Ia,`To provide seamless interoperability with A1111 to our users, we support loading A1111 formatted
LoRA checkpoints using `),da=r(Ia,"A",{href:!0});var nf=n(da);si=l(nf,"load_lora_weights()"),nf.forEach(a),ri=l(Ia,` in a limited capacity.
In this section, we explain how to load an A1111 formatted LoRA checkpoint from `),Ct=r(Ia,"A",{href:!0,rel:!0});var hf=n(Ct);ni=l(hf,"CivitAI"),hf.forEach(a),ii=l(Ia,`
in Diffusers and perform inference with it.`),Ia.forEach(a),Zl=u(e),Ve=r(e,"P",{});var rs=n(Ve);hi=l(rs,`First, download a checkpoint. We\u2019ll use
`),St=r(rs,"A",{href:!0,rel:!0});var ff=n(St);fi=l(ff,"this one"),ff.forEach(a),pi=l(rs," for demonstration purposes."),rs.forEach(a),Il=u(e),E(Lt.$$.fragment,e),kl=u(e),Ye=r(e,"P",{});var ns=n(Ye);di=l(ns,"Next, we initialize a "),ua=r(ns,"A",{href:!0});var pf=n(ua);ui=l(pf,"~DiffusionPipeline"),pf.forEach(a),ci=l(ns,":"),ns.forEach(a),Nl=u(e),E(Dt.$$.fragment,e),Gl=u(e),ca=r(e,"P",{});var df=n(ca);mi=l(df,"We then load the checkpoint downloaded from CivitAI:"),df.forEach(a),Wl=u(e),E(Xt.$$.fragment,e),Bl=u(e),E(xe.$$.fragment,e),Cl=u(e),ma=r(e,"P",{});var uf=n(ma);wi=l(uf,"And then it\u2019s time for running inference:"),uf.forEach(a),Sl=u(e),E(Vt.$$.fragment,e),Ll=u(e),wa=r(e,"P",{});var cf=n(wa);gi=l(cf,"Below is a comparison between the LoRA and the non-LoRA results:"),cf.forEach(a),Dl=u(e),ga=r(e,"P",{});var mf=n(ga);ya=r(mf,"IMG",{src:!0,alt:!0}),mf.forEach(a),Xl=u(e),Fe=r(e,"P",{});var is=n(Fe);yi=l(is,`You have a similar checkpoint stored on the Hugging Face Hub, you can load it
directly with `),_a=r(is,"A",{href:!0});var wf=n(_a);_i=l(wf,"load_lora_weights()"),wf.forEach(a),bi=l(is," like so:"),is.forEach(a),Vl=u(e),E(Yt.$$.fragment,e),this.h()},h(){p(f,"name","hf:doc:metadata"),p(f,"content",JSON.stringify(kf)),p(g,"id","lowrank-adaptation-of-large-language-models-lora"),p(g,"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(g,"href","#lowrank-adaptation-of-large-language-models-lora"),p(c,"class","relative group"),p(N,"href","https://arxiv.org/abs/2106.09685"),p(N,"rel","nofollow"),p(Y,"href","https://www.pnas.org/doi/10.1073/pnas.1611835114"),p(Y,"rel","nofollow"),p(Pt,"href","/docs/diffusers/v0.18.2/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs"),p(Ke,"href","https://github.com/cloneofsimo"),p(Ke,"rel","nofollow"),p(et,"href","https://github.com/cloneofsimo/lora"),p(et,"rel","nofollow"),p(tt,"href","https://github.com/huggingface/diffusers/tree/main/examples/text_to_image#training-with-lora"),p(tt,"rel","nofollow"),p(at,"href","https://github.com/huggingface/diffusers/tree/main/examples/dreambooth#training-with-low-rank-adaptation-of-large-language-models-lora"),p(at,"rel","nofollow"),p(Qt,"href","hf.co/join"),p(Ue,"id","texttoimage"),p(Ue,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(Ue,"href","#texttoimage"),p(we,"class","relative group"),p(je,"id","text-to-image-training"),p(je,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(je,"href","#text-to-image-training"),p(ge,"class","relative group"),p(rt,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),p(rt,"rel","nofollow"),p(nt,"href","https://huggingface.co/datasets/lambdalabs/pokemon-blip-captions"),p(nt,"rel","nofollow"),p(it,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),p(it,"rel","nofollow"),p(Ht,"href","create_dataset"),p(ft,"href","https://wandb.ai/pcuenq/text2image-fine-tune/runs/b4k1w0tn?workspace=user-pcuenq"),p(ft,"rel","nofollow"),p(pt,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py"),p(pt,"rel","nofollow"),p(Ae,"id","text-to-image-inference"),p(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(Ae,"href","#text-to-image-inference"),p(ye,"class","relative group"),p(ea,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(ta,"href","/docs/diffusers/v0.18.2/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler"),p(Ie,"id","dreambooth"),p(Ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(Ie,"href","#dreambooth"),p(_e,"class","relative group"),p(yt,"href","https://arxiv.org/abs/2208.12242"),p(yt,"rel","nofollow"),p(Ne,"id","dreambooth-training"),p(Ne,"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(Ne,"href","#dreambooth-training"),p(be,"class","relative group"),p(bt,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),p(bt,"rel","nofollow"),p(Mt,"href","https://drive.google.com/drive/folders/1BO_dyz-p65qhBRRMRA4TbZ8qW4rB99JZ"),p(Mt,"rel","nofollow"),p(aa,"href","create_dataset"),p(vt,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),p(vt,"rel","nofollow"),p(Jt,"href","https://wandb.ai/pcuenq/text2image-fine-tune/runs/b4k1w0tn?workspace=user-pcuenq"),p(Jt,"rel","nofollow"),p(Et,"href","https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py"),p(Et,"rel","nofollow"),p(Be,"id","dreambooth-inference"),p(Be,"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(Be,"href","#dreambooth-inference"),p(Me,"class","relative group"),p(ra,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(na,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),p(ia,"href","/docs/diffusers/v0.18.2/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs"),p(ha,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),p(kt,"href","https://huggingface.co/patrickvonplaten/lora_dreambooth_dog_example"),p(kt,"rel","nofollow"),p(Wt,"href","https://huggingface.co/sayakpaul/dreambooth"),p(Wt,"rel","nofollow"),p(fa,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),p(pa,"href","/docs/diffusers/v0.18.2/en/api/loaders#diffusers.loaders.UNet2DConditionLoadersMixin.load_attn_procs"),p(Xe,"id","supporting-a1111-themed-lora-checkpoints-from-diffusers"),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","#supporting-a1111-themed-lora-checkpoints-from-diffusers"),p(ve,"class","relative group"),p(da,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),p(Ct,"href","https://civitai.com/"),p(Ct,"rel","nofollow"),p(St,"href","https://civitai.com/models/13239/light-and-shadow"),p(St,"rel","nofollow"),p(ua,"href","/docs/diffusers/v0.18.2/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),Mf(ya.src,Ui="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/lora_non_lora_comparison.png")||p(ya,"src",Ui),p(ya,"alt","lora_non_lora"),p(_a,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights")},m(e,i){t(document.head,f),h(e,v,i),h(e,c,i),t(c,g),t(g,b),U(m,b,null),t(c,w),t(c,T),t(T,R),h(e,y,i),U(I,e,i),h(e,_,i),h(e,Z,i),t(Z,N),t(N,G),t(Z,z),t(Z,D),t(D,C),t(Z,H),t(Z,X),t(X,S),t(Z,M),h(e,O,i),h(e,W,i),t(W,V),t(V,ue),t(V,Y),t(Y,ce),t(V,hs),t(W,fs),t(W,ka),t(ka,ps),t(W,ds),t(W,me),t(me,us),t(me,Pt),t(Pt,cs),t(me,ms),t(me,Na),t(Na,ws),t(me,gs),t(W,ys),t(W,Ga),t(Ga,_s),h(e,Wo,i),U(Je,e,i),h(e,Bo,i),h(e,x,i),t(x,Ke),t(Ke,bs),t(x,Ms),t(x,et),t(et,vs),t(x,Ts),t(x,tt),t(tt,Js),t(x,Es),t(x,at),t(at,Us),t(x,js),h(e,Co,i),h(e,Ee,i),t(Ee,$s),t(Ee,Qt),t(Qt,As),t(Ee,Rs),h(e,So,i),U(ot,e,i),h(e,Lo,i),h(e,we,i),t(we,Ue),t(Ue,Wa),U(lt,Wa,null),t(we,Zs),t(we,Ba),t(Ba,Is),h(e,Do,i),h(e,zt,i),t(zt,ks),h(e,Xo,i),h(e,ge,i),t(ge,je),t(je,Ca),U(st,Ca,null),t(ge,Ns),t(ge,Sa),t(Sa,Gs),h(e,Vo,i),h(e,K,i),t(K,Ws),t(K,rt),t(rt,La),t(La,Bs),t(K,Cs),t(K,nt),t(nt,Ss),t(K,Ls),h(e,Yo,i),h(e,L,i),t(L,Ds),t(L,Da),t(Da,Xs),t(L,Vs),t(L,it),t(it,Xa),t(Xa,Ys),t(L,xs),t(L,Va),t(Va,Fs),t(L,Ps),t(L,Ht),t(Ht,Qs),t(L,zs),h(e,xo,i),h(e,ee,i),t(ee,Hs),t(ee,Ya),t(Ya,qs),t(ee,Os),t(ee,xa),t(xa,Ks),t(ee,er),h(e,Fo,i),U(ht,e,i),h(e,Po,i),h(e,qt,i),t(qt,tr),h(e,Qo,i),h(e,te,i),t(te,Ot),t(Ot,Fa),t(Fa,ar),t(Ot,or),t(te,lr),t(te,$e),t($e,Pa),t(Pa,sr),t($e,rr),t($e,ft),t(ft,nr),t($e,ir),t(te,hr),t(te,Kt),t(Kt,Qa),t(Qa,fr),t(Kt,pr),h(e,zo,i),h(e,ae,i),t(ae,dr),t(ae,pt),t(pt,ur),t(ae,cr),t(ae,za),t(za,mr),t(ae,wr),h(e,Ho,i),U(dt,e,i),h(e,qo,i),h(e,ye,i),t(ye,Ae),t(Ae,Ha),U(ut,Ha,null),t(ye,gr),t(ye,qa),t(qa,yr),h(e,Oo,i),h(e,oe,i),t(oe,_r),t(oe,ea),t(ea,br),t(oe,Mr),t(oe,ta),t(ta,vr),t(oe,Tr),h(e,Ko,i),U(ct,e,i),h(e,el,i),h(e,le,i),t(le,Jr),t(le,Oa),t(Oa,Er),t(le,Ur),t(le,Ka),t(Ka,jr),t(le,$r),h(e,tl,i),U(Re,e,i),h(e,al,i),U(mt,e,i),h(e,ol,i),U(Ze,e,i),h(e,ll,i),h(e,_e,i),t(_e,Ie),t(Ie,eo),U(wt,eo,null),t(_e,Ar),t(_e,to),t(to,Rr),h(e,sl,i),h(e,gt,i),t(gt,yt),t(yt,Zr),t(gt,Ir),h(e,rl,i),U(ke,e,i),h(e,nl,i),h(e,be,i),t(be,Ne),t(Ne,ao),U(_t,ao,null),t(be,kr),t(be,oo),t(oo,Nr),h(e,il,i),h(e,F,i),t(F,Gr),t(F,bt),t(bt,lo),t(lo,Wr),t(F,Br),t(F,Mt),t(Mt,Cr),t(F,Sr),t(F,aa),t(aa,Lr),t(F,Dr),h(e,hl,i),h(e,P,i),t(P,Xr),t(P,so),t(so,Vr),t(P,Yr),t(P,vt),t(vt,ro),t(ro,xr),t(P,Fr),t(P,no),t(no,Pr),t(P,Qr),h(e,fl,i),h(e,Ge,i),t(Ge,zr),t(Ge,io),t(io,Hr),t(Ge,qr),h(e,pl,i),U(Tt,e,i),h(e,dl,i),h(e,oa,i),t(oa,Or),h(e,ul,i),h(e,se,i),t(se,la),t(la,ho),t(ho,Kr),t(la,en),t(se,tn),t(se,We),t(We,fo),t(fo,an),t(We,on),t(We,Jt),t(Jt,ln),t(We,sn),t(se,rn),t(se,sa),t(sa,po),t(po,nn),t(sa,hn),h(e,cl,i),h(e,re,i),t(re,fn),t(re,Et),t(Et,pn),t(re,dn),t(re,uo),t(uo,un),t(re,cn),h(e,ml,i),h(e,ne,i),t(ne,mn),t(ne,co),t(co,wn),t(ne,gn),t(ne,mo),t(mo,yn),t(ne,_n),h(e,wl,i),U(Ut,e,i),h(e,gl,i),h(e,Me,i),t(Me,Be),t(Be,wo),U(jt,wo,null),t(Me,bn),t(Me,go),t(go,Mn),h(e,yl,i),h(e,Ce,i),t(Ce,vn),t(Ce,ra),t(ra,Tn),t(Ce,Jn),h(e,_l,i),U($t,e,i),h(e,bl,i),h(e,ie,i),t(ie,En),t(ie,yo),t(yo,Un),t(ie,jn),t(ie,_o),t(_o,$n),t(ie,An),h(e,Ml,i),U(Se,e,i),h(e,vl,i),U(At,e,i),h(e,Tl,i),h(e,he,i),t(he,Rn),t(he,bo),t(bo,Zn),t(he,In),t(he,Mo),t(Mo,kn),t(he,Nn),h(e,Jl,i),U(Rt,e,i),h(e,El,i),U(Le,e,i),h(e,Ul,i),h(e,Q,i),t(Q,Gn),t(Q,na),t(na,Wn),t(Q,Bn),t(Q,ia),t(ia,Cn),t(Q,Sn),t(Q,ha),t(ha,Ln),t(Q,Dn),h(e,jl,i),h(e,De,i),t(De,Zt),t(Zt,It),t(It,Xn),t(It,kt),t(kt,vo),t(vo,Vn),t(It,Yn),t(Zt,xn),U(Nt,Zt,null),t(De,Fn),t(De,To),t(To,Gt),t(Gt,Pn),t(Gt,Wt),t(Wt,Jo),t(Jo,Qn),t(Gt,zn),h(e,$l,i),h(e,q,i),t(q,Eo),t(Eo,Hn),t(q,qn),t(q,fa),t(fa,On),t(q,Kn),t(q,pa),t(pa,ei),t(q,ti),h(e,Al,i),h(e,ve,i),t(ve,Xe),t(Xe,Uo),U(Bt,Uo,null),t(ve,ai),t(ve,jo),t(jo,oi),h(e,Rl,i),h(e,fe,i),t(fe,li),t(fe,da),t(da,si),t(fe,ri),t(fe,Ct),t(Ct,ni),t(fe,ii),h(e,Zl,i),h(e,Ve,i),t(Ve,hi),t(Ve,St),t(St,fi),t(Ve,pi),h(e,Il,i),U(Lt,e,i),h(e,kl,i),h(e,Ye,i),t(Ye,di),t(Ye,ua),t(ua,ui),t(Ye,ci),h(e,Nl,i),U(Dt,e,i),h(e,Gl,i),h(e,ca,i),t(ca,mi),h(e,Wl,i),U(Xt,e,i),h(e,Bl,i),U(xe,e,i),h(e,Cl,i),h(e,ma,i),t(ma,wi),h(e,Sl,i),U(Vt,e,i),h(e,Ll,i),h(e,wa,i),t(wa,gi),h(e,Dl,i),h(e,ga,i),t(ga,ya),h(e,Xl,i),h(e,Fe,i),t(Fe,yi),t(Fe,_a),t(_a,_i),t(Fe,bi),h(e,Vl,i),U(Yt,e,i),Yl=!0},p(e,[i]){const xt={};i&2&&(xt.$$scope={dirty:i,ctx:e}),I.$set(xt);const $o={};i&2&&($o.$$scope={dirty:i,ctx:e}),Je.$set($o);const Ao={};i&2&&(Ao.$$scope={dirty:i,ctx:e}),Re.$set(Ao);const Ro={};i&2&&(Ro.$$scope={dirty:i,ctx:e}),Ze.$set(Ro);const pe={};i&2&&(pe.$$scope={dirty:i,ctx:e}),ke.$set(pe);const Zo={};i&2&&(Zo.$$scope={dirty:i,ctx:e}),Se.$set(Zo);const Io={};i&2&&(Io.$$scope={dirty:i,ctx:e}),Le.$set(Io);const ko={};i&2&&(ko.$$scope={dirty:i,ctx:e}),xe.$set(ko)},i(e){Yl||(j(m.$$.fragment,e),j(I.$$.fragment,e),j(Je.$$.fragment,e),j(ot.$$.fragment,e),j(lt.$$.fragment,e),j(st.$$.fragment,e),j(ht.$$.fragment,e),j(dt.$$.fragment,e),j(ut.$$.fragment,e),j(ct.$$.fragment,e),j(Re.$$.fragment,e),j(mt.$$.fragment,e),j(Ze.$$.fragment,e),j(wt.$$.fragment,e),j(ke.$$.fragment,e),j(_t.$$.fragment,e),j(Tt.$$.fragment,e),j(Ut.$$.fragment,e),j(jt.$$.fragment,e),j($t.$$.fragment,e),j(Se.$$.fragment,e),j(At.$$.fragment,e),j(Rt.$$.fragment,e),j(Le.$$.fragment,e),j(Nt.$$.fragment,e),j(Bt.$$.fragment,e),j(Lt.$$.fragment,e),j(Dt.$$.fragment,e),j(Xt.$$.fragment,e),j(xe.$$.fragment,e),j(Vt.$$.fragment,e),j(Yt.$$.fragment,e),Yl=!0)},o(e){$(m.$$.fragment,e),$(I.$$.fragment,e),$(Je.$$.fragment,e),$(ot.$$.fragment,e),$(lt.$$.fragment,e),$(st.$$.fragment,e),$(ht.$$.fragment,e),$(dt.$$.fragment,e),$(ut.$$.fragment,e),$(ct.$$.fragment,e),$(Re.$$.fragment,e),$(mt.$$.fragment,e),$(Ze.$$.fragment,e),$(wt.$$.fragment,e),$(ke.$$.fragment,e),$(_t.$$.fragment,e),$(Tt.$$.fragment,e),$(Ut.$$.fragment,e),$(jt.$$.fragment,e),$($t.$$.fragment,e),$(Se.$$.fragment,e),$(At.$$.fragment,e),$(Rt.$$.fragment,e),$(Le.$$.fragment,e),$(Nt.$$.fragment,e),$(Bt.$$.fragment,e),$(Lt.$$.fragment,e),$(Dt.$$.fragment,e),$(Xt.$$.fragment,e),$(xe.$$.fragment,e),$(Vt.$$.fragment,e),$(Yt.$$.fragment,e),Yl=!1},d(e){a(f),e&&a(v),e&&a(c),A(m),e&&a(y),A(I,e),e&&a(_),e&&a(Z),e&&a(O),e&&a(W),e&&a(Wo),A(Je,e),e&&a(Bo),e&&a(x),e&&a(Co),e&&a(Ee),e&&a(So),A(ot,e),e&&a(Lo),e&&a(we),A(lt),e&&a(Do),e&&a(zt),e&&a(Xo),e&&a(ge),A(st),e&&a(Vo),e&&a(K),e&&a(Yo),e&&a(L),e&&a(xo),e&&a(ee),e&&a(Fo),A(ht,e),e&&a(Po),e&&a(qt),e&&a(Qo),e&&a(te),e&&a(zo),e&&a(ae),e&&a(Ho),A(dt,e),e&&a(qo),e&&a(ye),A(ut),e&&a(Oo),e&&a(oe),e&&a(Ko),A(ct,e),e&&a(el),e&&a(le),e&&a(tl),A(Re,e),e&&a(al),A(mt,e),e&&a(ol),A(Ze,e),e&&a(ll),e&&a(_e),A(wt),e&&a(sl),e&&a(gt),e&&a(rl),A(ke,e),e&&a(nl),e&&a(be),A(_t),e&&a(il),e&&a(F),e&&a(hl),e&&a(P),e&&a(fl),e&&a(Ge),e&&a(pl),A(Tt,e),e&&a(dl),e&&a(oa),e&&a(ul),e&&a(se),e&&a(cl),e&&a(re),e&&a(ml),e&&a(ne),e&&a(wl),A(Ut,e),e&&a(gl),e&&a(Me),A(jt),e&&a(yl),e&&a(Ce),e&&a(_l),A($t,e),e&&a(bl),e&&a(ie),e&&a(Ml),A(Se,e),e&&a(vl),A(At,e),e&&a(Tl),e&&a(he),e&&a(Jl),A(Rt,e),e&&a(El),A(Le,e),e&&a(Ul),e&&a(Q),e&&a(jl),e&&a(De),A(Nt),e&&a($l),e&&a(q),e&&a(Al),e&&a(ve),A(Bt),e&&a(Rl),e&&a(fe),e&&a(Zl),e&&a(Ve),e&&a(Il),A(Lt,e),e&&a(kl),e&&a(Ye),e&&a(Nl),A(Dt,e),e&&a(Gl),e&&a(ca),e&&a(Wl),A(Xt,e),e&&a(Bl),A(xe,e),e&&a(Cl),e&&a(ma),e&&a(Sl),A(Vt,e),e&&a(Ll),e&&a(wa),e&&a(Dl),e&&a(ga),e&&a(Xl),e&&a(Fe),e&&a(Vl),A(Yt,e)}}}const kf={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:"supporting-a1111-themed-lora-checkpoints-from-diffusers",title:"Supporting A1111 themed LoRA checkpoints from Diffusers"}],title:"Low-Rank Adaptation of Large Language Models (LoRA)"};function Nf(k){return vf(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Sf extends gf{constructor(f){super();yf(this,f,Nf,If,_f,{})}}export{Sf as default,kf as metadata};
