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