import{S as ec,i as tc,s as ac,e as s,k as p,w as g,t as l,M as lc,c as r,d as a,m as d,a as i,x as _,h as o,b as h,N as oc,G as t,g as f,y as M,q as v,o as J,B as T,v as sc,L as rc}from"../../chunks/vendor-hf-doc-builder.js";import{T as gt}from"../../chunks/Tip-hf-doc-builder.js";import{I as P}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as L}from"../../chunks/CodeBlock-hf-doc-builder.js";function ic(Z){let u,j;return{c(){u=s("p"),j=l("This is an experimental feature. Its APIs can change in future.")},l(c){u=r(c,"P",{});var w=i(u);j=o(w,"This is an experimental feature. Its APIs can change in future."),w.forEach(a)},m(c,w){f(c,u,w),t(u,j)},d(c){c&&a(u)}}}function nc(Z){let u,j,c,w,$;return{c(){u=s("p"),j=l(`\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"),w=l("Using LoRA for efficient Stable Diffusion fine-tuning"),$=l(" blog for more information about how LoRA works!"),this.h()},l(m){u=r(m,"P",{});var E=i(u);j=o(E,`\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(E,"A",{href:!0,rel:!0});var I=i(c);w=o(I,"Using LoRA for efficient Stable Diffusion fine-tuning"),I.forEach(a),$=o(E," blog for more information about how LoRA works!"),E.forEach(a),this.h()},h(){h(c,"href","https://huggingface.co/blog/lora"),h(c,"rel","nofollow")},m(m,E){f(m,u,E),t(u,j),t(u,c),t(c,w),t(u,$)},d(m){m&&a(u)}}}function fc(Z){let u,j,c,w,$,m,E,I,R,y,A,b,k,W,G,H,V,B,q,C;return{c(){u=s("p"),j=l("\u{1F4A1} A "),c=s("code"),w=l("scale"),$=l(" value of "),m=s("code"),E=l("0"),I=l(" is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=s("code"),y=l("scale"),A=l(" value of "),b=s("code"),k=l("1"),W=l(" means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=s("code"),H=l("0"),V=l(" and "),B=s("code"),q=l("1"),C=l(" interpolates between the two weights.")},l(S){u=r(S,"P",{});var U=i(u);j=o(U,"\u{1F4A1} A "),c=r(U,"CODE",{});var ee=i(c);w=o(ee,"scale"),ee.forEach(a),$=o(U," value of "),m=r(U,"CODE",{});var N=i(m);E=o(N,"0"),N.forEach(a),I=o(U," is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=r(U,"CODE",{});var D=i(R);y=o(D,"scale"),D.forEach(a),A=o(U," value of "),b=r(U,"CODE",{});var we=i(b);k=o(we,"1"),we.forEach(a),W=o(U," means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=r(U,"CODE",{});var x=i(G);H=o(x,"0"),x.forEach(a),V=o(U," and "),B=r(U,"CODE",{});var ye=i(B);q=o(ye,"1"),ye.forEach(a),C=o(U," interpolates between the two weights."),U.forEach(a)},m(S,U){f(S,u,U),t(u,j),t(u,c),t(c,w),t(u,$),t(u,m),t(m,E),t(u,I),t(u,R),t(R,y),t(u,A),t(u,b),t(b,k),t(u,W),t(u,G),t(G,H),t(u,V),t(u,B),t(B,q),t(u,C)},d(S){S&&a(u)}}}function hc(Z){let u,j,c,w,$,m,E,I,R,y,A;return y=new L({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1Yi5yZXBvY2FyZCUyMGltcG9ydCUyMFJlcG9DYXJkJTBBJTBBbG9yYV9tb2RlbF9pZCUyMCUzRCUyMCUyMnNheWFrcGF1bCUyRnNkLW1vZGVsLWZpbmV0dW5lZC1sb3JhLXQ0JTIyJTBBY2FyZCUyMCUzRCUyMFJlcG9DYXJkLmxvYWQobG9yYV9tb2RlbF9pZCklMEFiYXNlX21vZGVsX2lkJTIwJTNEJTIwY2FyZC5kYXRhLnRvX2RpY3QoKSU1QiUyMmJhc2VfbW9kZWwlMjIlNUQlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKGJhc2VfbW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQS4uLg==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub.repocard <span class="hljs-keyword">import</span> RepoCard

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

pipe = StableDiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
...`}}),{c(){u=s("p"),j=l(`If you are loading the LoRA parameters from the Hub and if the Hub repository has
a `),c=s("code"),w=l("base_model"),$=l(" tag (such as "),m=s("a"),E=l("this"),I=l(`), then
you can do:`),R=p(),g(y.$$.fragment),this.h()},l(b){u=r(b,"P",{});var k=i(u);j=o(k,`If you are loading the LoRA parameters from the Hub and if the Hub repository has
a `),c=r(k,"CODE",{});var W=i(c);w=o(W,"base_model"),W.forEach(a),$=o(k," tag (such as "),m=r(k,"A",{href:!0,rel:!0});var G=i(m);E=o(G,"this"),G.forEach(a),I=o(k,`), then
you can do:`),k.forEach(a),R=d(b),_(y.$$.fragment,b),this.h()},h(){h(m,"href","https://huggingface.co/sayakpaul/sd-model-finetuned-lora-t4/blob/main/README.md?code=true#L4"),h(m,"rel","nofollow")},m(b,k){f(b,u,k),t(u,j),t(u,c),t(c,w),t(u,$),t(u,m),t(m,E),t(u,I),f(b,R,k),M(y,b,k),A=!0},p:rc,i(b){A||(v(y.$$.fragment,b),A=!0)},o(b){J(y.$$.fragment,b),A=!1},d(b){b&&a(u),b&&a(R),T(y,b)}}}function pc(Z){let u,j,c,w,$;return{c(){u=s("p"),j=l("\u{1F4A1} Take a look at the "),c=s("a"),w=l("Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),$=l(" blog for an in-depth analysis of DreamBooth experiments and recommended settings."),this.h()},l(m){u=r(m,"P",{});var E=i(u);j=o(E,"\u{1F4A1} Take a look at the "),c=r(E,"A",{href:!0,rel:!0});var I=i(c);w=o(I,"Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),I.forEach(a),$=o(E," blog for an in-depth analysis of DreamBooth experiments and recommended settings."),E.forEach(a),this.h()},h(){h(c,"href","https://huggingface.co/blog/dreambooth"),h(c,"rel","nofollow")},m(m,E){f(m,u,E),t(u,j),t(u,c),t(c,w),t(u,$)},d(m){m&&a(u)}}}function dc(Z){let u,j,c,w,$,m,E,I,R,y,A,b,k,W,G,H,V,B,q,C;return{c(){u=s("p"),j=l("\u{1F4A1} A "),c=s("code"),w=l("scale"),$=l(" value of "),m=s("code"),E=l("0"),I=l(" is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=s("code"),y=l("scale"),A=l(" value of "),b=s("code"),k=l("1"),W=l(" means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=s("code"),H=l("0"),V=l(" and "),B=s("code"),q=l("1"),C=l(" interpolates between the two weights.")},l(S){u=r(S,"P",{});var U=i(u);j=o(U,"\u{1F4A1} A "),c=r(U,"CODE",{});var ee=i(c);w=o(ee,"scale"),ee.forEach(a),$=o(U," value of "),m=r(U,"CODE",{});var N=i(m);E=o(N,"0"),N.forEach(a),I=o(U," is the same as not using your LoRA weights and you\u2019re only using the base model weights, and a "),R=r(U,"CODE",{});var D=i(R);y=o(D,"scale"),D.forEach(a),A=o(U," value of "),b=r(U,"CODE",{});var we=i(b);k=o(we,"1"),we.forEach(a),W=o(U," means you\u2019re only using the fully finetuned LoRA weights. Values between "),G=r(U,"CODE",{});var x=i(G);H=o(x,"0"),x.forEach(a),V=o(U," and "),B=r(U,"CODE",{});var ye=i(B);q=o(ye,"1"),ye.forEach(a),C=o(U," interpolates between the two weights."),U.forEach(a)},m(S,U){f(S,u,U),t(u,j),t(u,c),t(c,w),t(u,$),t(u,m),t(m,E),t(u,I),t(u,R),t(R,y),t(u,A),t(u,b),t(b,k),t(u,W),t(u,G),t(G,H),t(u,V),t(u,B),t(B,q),t(u,C)},d(S){S&&a(u)}}}function uc(Z){let u,j,c,w,$,m,E,I;return{c(){u=s("p"),j=l(`If your LoRA parameters involve the UNet as well as the Text Encoder, then passing
`),c=s("code"),w=l('cross_attention_kwargs={"scale": 0.5}'),$=l(" will apply the "),m=s("code"),E=l("scale"),I=l(` value to both the UNet
and the Text Encoder.`)},l(R){u=r(R,"P",{});var y=i(u);j=o(y,`If your LoRA parameters involve the UNet as well as the Text Encoder, then passing
`),c=r(y,"CODE",{});var A=i(c);w=o(A,'cross_attention_kwargs={"scale": 0.5}'),A.forEach(a),$=o(y," will apply the "),m=r(y,"CODE",{});var b=i(m);E=o(b,"scale"),b.forEach(a),I=o(y,` value to both the UNet
and the Text Encoder.`),y.forEach(a)},m(R,y){f(R,u,y),t(u,j),t(u,c),t(c,w),t(u,$),t(u,m),t(m,E),t(u,I)},d(R){R&&a(u)}}}function cc(Z){let u,j,c,w,$,m,E,I;return{c(){u=s("p"),j=l("If you\u2019re loading a checkpoint in the "),c=s("code"),w=l("safetensors"),$=l(" format, please ensure you have "),m=s("code"),E=l("safetensors"),I=l(" installed.")},l(R){u=r(R,"P",{});var y=i(u);j=o(y,"If you\u2019re loading a checkpoint in the "),c=r(y,"CODE",{});var A=i(c);w=o(A,"safetensors"),A.forEach(a),$=o(y," format, please ensure you have "),m=r(y,"CODE",{});var b=i(m);E=o(b,"safetensors"),b.forEach(a),I=o(y," installed."),y.forEach(a)},m(R,y){f(R,u,y),t(u,j),t(u,c),t(c,w),t(u,$),t(u,m),t(m,E),t(u,I)},d(R){R&&a(u)}}}function mc(Z){let u,j,c,w,$,m,E,I,R,y,A,b,k,W,G,H,V,B,q,C,S,U,ee,N,D,we,x,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JTIwT1VUUFVUX0RJUiUzRCUyMiUyRnNkZGF0YSUyRmZpbmV0dW5lJTJGbG9yYSUyRnBva2Vtb24lMjIlMEFleHBvcnQlMjBIVUJfTU9ERUxfSUQlM0QlMjJwb2tlbW9uLWxvcmElMjIlMEFleHBvcnQlMjBEQVRBU0VUX05BTUUlM0QlMjJsYW1iZGFsYWJzJTJGcG9rZW1vbi1ibGlwLWNhcHRpb25zJTIy",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>`}}),Zt=new L({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`}}),Wt=new P({}),Gt=new L({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEElMEFtb2RlbF9iYXNlJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2Jhc2UlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyk=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline, DPMSolverMultistepScheduler

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

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionPipeline.from_pretrained(model_base, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)`}}),Se=new gt({props:{$$slots:{default:[fc]},$$scope:{ctx:Z}}}),Nt=new L({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>)`}}),Xe=new gt({props:{$$slots:{default:[hc]},$$scope:{ctx:Z}}}),Lt=new P({}),Ce=new gt({props:{$$slots:{default:[pc]},$$scope:{ctx:Z}}}),Xt=new P({}),xt=new L({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>`}}),Qt=new L({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`}}),zt=new P({}),Pt=new L({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMEElMEFtb2RlbF9iYXNlJTIwJTNEJTIwJTIycnVud2F5bWwlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2Jhc2UlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKQ==",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

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

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionPipeline.from_pretrained(model_base, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)`}}),ze=new gt({props:{$$slots:{default:[dc]},$$scope:{ctx:Z}}}),Ht=new L({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>)`}}),qt=new L({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1Yi5yZXBvY2FyZCUyMGltcG9ydCUyMFJlcG9DYXJkJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFsb3JhX21vZGVsX2lkJTIwJTNEJTIwJTIyc2F5YWtwYXVsJTJGZHJlYW1ib290aC10ZXh0LWVuY29kZXItdGVzdCUyMiUwQWNhcmQlMjAlM0QlMjBSZXBvQ2FyZC5sb2FkKGxvcmFfbW9kZWxfaWQpJTBBYmFzZV9tb2RlbF9pZCUyMCUzRCUyMGNhcmQuZGF0YS50b19kaWN0KCklNUIlMjJiYXNlX21vZGVsJTIyJTVEJTBBJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChiYXNlX21vZGVsX2lkJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQXBpcGUubG9hZF9sb3JhX3dlaWdodHMobG9yYV9tb2RlbF9pZCklMEFpbWFnZSUyMCUzRCUyMHBpcGUoJTIyQSUyMHBpY3R1cmUlMjBvZiUyMGElMjBza3MlMjBkb2clMjBpbiUyMGElMjBidWNrZXQlMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNEMjUpLmltYWdlcyU1QjAlNUQ=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub.repocard <span class="hljs-keyword">import</span> RepoCard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

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

pipe = StableDiffusionPipeline.from_pretrained(base_model_id, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipe.load_lora_weights(lora_model_id)
image = pipe(<span class="hljs-string">&quot;A picture of a sks dog in a bucket&quot;</span>, num_inference_steps=<span class="hljs-number">25</span>).images[<span class="hljs-number">0</span>]`}}),Pe=new gt({props:{$$slots:{default:[uc]},$$scope:{ctx:Z}}}),ta=new L({props:{code:"cGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyhsb3JhX21vZGVsX3BhdGgp",highlighted:"pipe.load_lora_weights(lora_model_path)"}}),oa=new P({}),sa=new P({}),ha=new L({props:{code:"d2dldCUyMGh0dHBzJTNBJTJGJTJGY2l2aXRhaS5jb20lMkZhcGklMkZkb3dubG9hZCUyRm1vZGVscyUyRjE1NjAzJTIwLU8lMjBsaWdodF9hbmRfc2hhZG93LnNhZmV0ZW5zb3Jz",highlighted:"wget https://civitai.com/api/download/models/15603 -O light_and_shadow.safetensors"}}),pa=new L({props:{code:"aW1wb3J0JTIwdG9yY2glMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUlMkMlMjBEUE1Tb2x2ZXJNdWx0aXN0ZXBTY2hlZHVsZXIlMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJnc2RmJTJGQ291bnRlcmZlaXQtVjIuNSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHNhZmV0eV9jaGVja2VyJTNETm9uZSUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMEEpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUuc2NoZWR1bGVyJTIwJTNEJTIwRFBNU29sdmVyTXVsdGlzdGVwU2NoZWR1bGVyLmZyb21fY29uZmlnKCUwQSUyMCUyMCUyMCUyMHBpcGVsaW5lLnNjaGVkdWxlci5jb25maWclMkMlMjB1c2Vfa2FycmFzX3NpZ21hcyUzRFRydWUlMEEp",highlighted:`<span class="hljs-keyword">import</span> torch

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

pipeline = StableDiffusionPipeline.from_pretrained(
    <span class="hljs-string">&quot;gsdf/Counterfeit-V2.5&quot;</span>, torch_dtype=torch.float16, safety_checker=<span class="hljs-literal">None</span>, use_safetensors=<span class="hljs-literal">True</span>
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.scheduler = DPMSolverMultistepScheduler.from_config(
    pipeline.scheduler.config, use_karras_sigmas=<span class="hljs-literal">True</span>
)`}}),da=new L({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>)'}}),at=new gt({props:{warning:!0,$$slots:{default:[cc]},$$scope:{ctx:Z}}}),ua=new L({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`}}),ca=new L({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)`}}),ma=new P({}),va=new L({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMjAlMEElMEFiYXNlX21vZGVsX2lkJTIwJTNEJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMC45JTIyJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoYmFzZV9tb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEFwaXBlbGluZS5sb2FkX2xvcmFfd2VpZ2h0cyglMjIuJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJLYW1lcGFuLnNhZmV0ZW5zb3JzJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMmFuaW1lJTIwc2Ny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zMDYwKSUwQW51bV9pbmZlcmVuY2Vfc3RlcHMlMjAlM0QlMjAzMCUwQWd1aWRhbmNlX3NjYWxlJTIwJTNEJTIwNyUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTBBJTIwJTIwJTIwJTIwcHJvbXB0JTNEcHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0JTNEbmVnYXRpdmVfcHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRG51bV9pbmZlcmVuY2Vfc3RlcHMlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMjBndWlkYW5jZV9zY2FsZSUzRGd1aWRhbmNlX3NjYWxlJTBBKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJLYW1lcGFuLnBuZyUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch 

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

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

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