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