import{S as vd,i as gd,s as Id,e as a,k as c,w,t as r,M as Ed,c as s,d as t,m as f,a as n,x as y,h as i,b as u,N as jd,G as l,g as p,y as U,q as b,o as _,B as T,v as Rd,L as ja}from"../../chunks/vendor-hf-doc-builder.js";import{T as Jd}from"../../chunks/Tip-hf-doc-builder.js";import{I as V}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as E}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as Xc,M as Ra}from"../../chunks/Markdown-hf-doc-builder.js";function $d(R){let d,M,h,J,v;return{c(){d=a("p"),M=r("DreamBooth finetuning is very sensitive to hyperparameters and easy to overfit. We recommend you take a look at our "),h=a("a"),J=r("in-depth analysis"),v=r(" with recommended settings for different subjects to help you choose the appropriate hyperparameters."),this.h()},l($){d=s($,"P",{});var I=n(d);M=i(I,"DreamBooth finetuning is very sensitive to hyperparameters and easy to overfit. We recommend you take a look at our "),h=s(I,"A",{href:!0,rel:!0});var C=n(h);J=i(C,"in-depth analysis"),C.forEach(t),v=i(I," with recommended settings for different subjects to help you choose the appropriate hyperparameters."),I.forEach(t),this.h()},h(){u(h,"href","https://huggingface.co/blog/dreambooth"),u(h,"rel","nofollow")},m($,I){p($,d,I),l(d,M),l(d,h),l(h,J),l(d,v)},d($){$&&t(d)}}}function Nd(R){let d,M,h,J,v,$,I,C,x,A,S,j,ue,O,Q,Y,F,oe,ne,k,K,z,ee,te,N,L,B,le,W,q,D,ae,G,H;return N=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwT1VUUFVUX0RJUiUzRCUyMnBhdGhfdG9fc2F2ZWRfbW9kZWwlMjI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>`}}),G=new E({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0Q1ZS02JTIwJTVDJTBBJTIwJTIwLS1scl9zY2hlZHVsZXIlM0QlMjJjb25zdGFudCUyMiUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNENDAwJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`accelerate launch train_dreambooth.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 \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --max_train_steps=400 \\
  --push_to_hub`}}),{c(){d=a("p"),M=r("Set the "),h=a("code"),J=r("INSTANCE_DIR"),v=r(" environment variable to the path of the directory containing the dog images."),$=c(),I=a("p"),C=r("Specify the "),x=a("code"),A=r("MODEL_NAME"),S=r(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),j=a("code"),ue=r("pretrained_model_name_or_path"),O=r(" argument. The "),Q=a("code"),Y=r("instance_prompt"),F=r(" argument is a text prompt that contains a unique identifier, such as "),oe=a("code"),ne=r("sks"),k=r(", and the class the image belongs to, which in this example is "),K=a("code"),z=r("a photo of a sks dog"),ee=r("."),te=c(),w(N.$$.fragment),L=c(),B=a("p"),le=r("Then you can launch the training script (you can find the full training script "),W=a("a"),q=r("here"),D=r(") with the following command:"),ae=c(),w(G.$$.fragment),this.h()},l(m){d=s(m,"P",{});var g=n(d);M=i(g,"Set the "),h=s(g,"CODE",{});var de=n(h);J=i(de,"INSTANCE_DIR"),de.forEach(t),v=i(g," environment variable to the path of the directory containing the dog images."),g.forEach(t),$=f(m),I=s(m,"P",{});var X=n(I);C=i(X,"Specify the "),x=s(X,"CODE",{});var Z=n(x);A=i(Z,"MODEL_NAME"),Z.forEach(t),S=i(X," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),j=s(X,"CODE",{});var we=n(j);ue=i(we,"pretrained_model_name_or_path"),we.forEach(t),O=i(X," argument. The "),Q=s(X,"CODE",{});var se=n(Q);Y=i(se,"instance_prompt"),se.forEach(t),F=i(X," argument is a text prompt that contains a unique identifier, such as "),oe=s(X,"CODE",{});var ye=n(oe);ne=i(ye,"sks"),ye.forEach(t),k=i(X,", and the class the image belongs to, which in this example is "),K=s(X,"CODE",{});var P=n(K);z=i(P,"a photo of a sks dog"),P.forEach(t),ee=i(X,"."),X.forEach(t),te=f(m),y(N.$$.fragment,m),L=f(m),B=s(m,"P",{});var me=n(B);le=i(me,"Then you can launch the training script (you can find the full training script "),W=s(me,"A",{href:!0,rel:!0});var re=n(W);q=i(re,"here"),re.forEach(t),D=i(me,") with the following command:"),me.forEach(t),ae=f(m),y(G.$$.fragment,m),this.h()},h(){u(W,"href","https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py"),u(W,"rel","nofollow")},m(m,g){p(m,d,g),l(d,M),l(d,h),l(h,J),l(d,v),p(m,$,g),p(m,I,g),l(I,C),l(I,x),l(x,A),l(I,S),l(I,j),l(j,ue),l(I,O),l(I,Q),l(Q,Y),l(I,F),l(I,oe),l(oe,ne),l(I,k),l(I,K),l(K,z),l(I,ee),p(m,te,g),U(N,m,g),p(m,L,g),p(m,B,g),l(B,le),l(B,W),l(W,q),l(B,D),p(m,ae,g),U(G,m,g),H=!0},p:ja,i(m){H||(b(N.$$.fragment,m),b(G.$$.fragment,m),H=!0)},o(m){_(N.$$.fragment,m),_(G.$$.fragment,m),H=!1},d(m){m&&t(d),m&&t($),m&&t(I),m&&t(te),T(N,m),m&&t(L),m&&t(B),m&&t(ae),T(G,m)}}}function Vd(R){let d,M;return d=new Ra({props:{$$slots:{default:[Nd]},$$scope:{ctx:R}}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p(h,J){const v={};J&2&&(v.$$scope={dirty:J,ctx:h}),d.$set(v)},i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Bd(R){let d,M,h,J,v,$,I,C,x,A,S,j,ue,O,Q,Y,F,oe,ne,k,K,z,ee,te,N,L,B,le,W,q,D,ae,G,H;return A=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:"pip install -U -r requirements.txt"}}),G=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMi4lMkZkb2clMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTBBJTBBcHl0aG9uJTIwdHJhaW5fZHJlYW1ib290aF9mbGF4LnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNENDAwJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;duongna/stable-diffusion-v1-4-flax&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

python train_dreambooth_flax.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 \\
  --learning_rate=5e-6 \\
  --max_train_steps=400 \\
  --push_to_hub`}}),{c(){d=a("p"),M=r("If you have access to TPUs or want to train even faster, you can try out the "),h=a("a"),J=r("Flax training script"),v=r(". The Flax training script doesn\u2019t support gradient checkpointing or gradient accumulation, so you\u2019ll need a GPU with at least 30GB of memory."),$=c(),I=a("p"),C=r("Before running the script, make sure you have the requirements installed:"),x=c(),w(A.$$.fragment),S=c(),j=a("p"),ue=r("Specify the "),O=a("code"),Q=r("MODEL_NAME"),Y=r(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),F=a("code"),oe=r("pretrained_model_name_or_path"),ne=r(" argument. The "),k=a("code"),K=r("instance_prompt"),z=r(" argument is a text prompt that contains a unique identifier, such as "),ee=a("code"),te=r("sks"),N=r(", and the class the image belongs to, which in this example is "),L=a("code"),B=r("a photo of a sks dog"),le=r("."),W=c(),q=a("p"),D=r("Now you can launch the training script with the following command:"),ae=c(),w(G.$$.fragment),this.h()},l(m){d=s(m,"P",{});var g=n(d);M=i(g,"If you have access to TPUs or want to train even faster, you can try out the "),h=s(g,"A",{href:!0,rel:!0});var de=n(h);J=i(de,"Flax training script"),de.forEach(t),v=i(g,". The Flax training script doesn\u2019t support gradient checkpointing or gradient accumulation, so you\u2019ll need a GPU with at least 30GB of memory."),g.forEach(t),$=f(m),I=s(m,"P",{});var X=n(I);C=i(X,"Before running the script, make sure you have the requirements installed:"),X.forEach(t),x=f(m),y(A.$$.fragment,m),S=f(m),j=s(m,"P",{});var Z=n(j);ue=i(Z,"Specify the "),O=s(Z,"CODE",{});var we=n(O);Q=i(we,"MODEL_NAME"),we.forEach(t),Y=i(Z," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),F=s(Z,"CODE",{});var se=n(F);oe=i(se,"pretrained_model_name_or_path"),se.forEach(t),ne=i(Z," argument. The "),k=s(Z,"CODE",{});var ye=n(k);K=i(ye,"instance_prompt"),ye.forEach(t),z=i(Z," argument is a text prompt that contains a unique identifier, such as "),ee=s(Z,"CODE",{});var P=n(ee);te=i(P,"sks"),P.forEach(t),N=i(Z,", and the class the image belongs to, which in this example is "),L=s(Z,"CODE",{});var me=n(L);B=i(me,"a photo of a sks dog"),me.forEach(t),le=i(Z,"."),Z.forEach(t),W=f(m),q=s(m,"P",{});var re=n(q);D=i(re,"Now you can launch the training script with the following command:"),re.forEach(t),ae=f(m),y(G.$$.fragment,m),this.h()},h(){u(h,"href","https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_flax.py"),u(h,"rel","nofollow")},m(m,g){p(m,d,g),l(d,M),l(d,h),l(h,J),l(d,v),p(m,$,g),p(m,I,g),l(I,C),p(m,x,g),U(A,m,g),p(m,S,g),p(m,j,g),l(j,ue),l(j,O),l(O,Q),l(j,Y),l(j,F),l(F,oe),l(j,ne),l(j,k),l(k,K),l(j,z),l(j,ee),l(ee,te),l(j,N),l(j,L),l(L,B),l(j,le),p(m,W,g),p(m,q,g),l(q,D),p(m,ae,g),U(G,m,g),H=!0},p:ja,i(m){H||(b(A.$$.fragment,m),b(G.$$.fragment,m),H=!0)},o(m){_(A.$$.fragment,m),_(G.$$.fragment,m),H=!1},d(m){m&&t(d),m&&t($),m&&t(I),m&&t(x),T(A,m),m&&t(S),m&&t(j),m&&t(W),m&&t(q),m&&t(ae),T(G,m)}}}function Gd(R){let d,M;return d=new Ra({props:{$$slots:{default:[Bd]},$$scope:{ctx:R}}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p(h,J){const v={};J&2&&(v.$$scope={dirty:J,ctx:h}),d.$set(v)},i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$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zJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDVlLTYlMjAlNUMlMEElMjAlMjAtLWxyX3NjaGVkdWxlciUzRCUyMmNvbnN0YW50JTIyJTIwJTVDJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTNEMjAwJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0Q4MDAlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p:ja,i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Zd(R){let d,M;return d=new Ra({props:{$$slots:{default:[Xd]},$$scope:{ctx:R}}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p(h,J){const v={};J&2&&(v.$$scope={dirty:J,ctx:h}),d.$set(v)},i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function kd(R){let d,M;return d=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMi4lMkZkb2clMjIlMEFleHBvcnQlMjBDTEFTU19ESVIlM0QlMjJwYXRoLXRvLWNsYXNzLWltYWdlcyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJwYXRoLXRvLXNhdmUtbW9kZWwlMjIlMEElMEFweXRob24lMjB0cmFpbl9kcmVhbWJvb3RoX2ZsYXgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX2RhdGFfZGlyJTNEJTI0Q0xBU1NfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0td2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24lMjAtLXByaW9yX2xvc3Nfd2VpZ2h0JTNEMS4wJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tbnVtX2NsYXNzX2ltYWdlcyUzRDIwMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEODAwJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;duongna/stable-diffusion-v1-4-flax&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path-to-class-images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

python train_dreambooth_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --learning_rate=5e-6 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p:ja,i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Cd(R){let d,M;return d=new Ra({props:{$$slots:{default:[kd]},$$scope:{ctx:R}}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p(h,J){const v={};J&2&&(v.$$scope={dirty:J,ctx:h}),d.$set(v)},i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Ad(R){let d,M;return{c(){d=a("p"),M=r("Training the text encoder requires additional memory and it won\u2019t fit on a 16GB GPU. You\u2019ll need at least 24GB VRAM to use this option.")},l(h){d=s(h,"P",{});var J=n(d);M=i(J,"Training the text encoder requires additional memory and it won\u2019t fit on a 16GB GPU. You\u2019ll need at least 24GB VRAM to use this option."),J.forEach(t)},m(h,J){p(h,d,J),l(d,M)},d(h){h&&t(d)}}}function Sd(R){let d,M;return d=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aF90b19jbGFzc19pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b19zYXZlZF9tb2RlbCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0cmFpbl9kcmVhbWJvb3RoLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLXRyYWluX3RleHRfZW5jb2RlciUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX2RhdGFfZGlyJTNEJTI0Q0xBU1NfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0td2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24lMjAtLXByaW9yX2xvc3Nfd2VpZ2h0JTNEMS4wJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS11c2VfOGJpdF9hZGFtJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9jaGVja3BvaW50aW5nJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMmUtNiUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW51bV9jbGFzc19pbWFnZXMlM0QyMDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDgwMCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --train_text_encoder \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --use_8bit_adam \\
  --gradient_checkpointing \\
  --learning_rate=2e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p:ja,i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Fd(R){let d,M;return d=new Ra({props:{$$slots:{default:[Sd]},$$scope:{ctx:R}}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p(h,J){const v={};J&2&&(v.$$scope={dirty:J,ctx:h}),d.$set(v)},i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Wd(R){let d,M;return d=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMi4lMkZkb2clMjIlMEFleHBvcnQlMjBDTEFTU19ESVIlM0QlMjJwYXRoLXRvLWNsYXNzLWlt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-flax&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path-to-class-images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

python train_dreambooth_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --train_text_encoder \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --learning_rate=2e-6 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p:ja,i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function Dd(R){let d,M;return d=new Ra({props:{$$slots:{default:[Wd]},$$scope:{ctx:R}}}),{c(){w(d.$$.fragment)},l(h){y(d.$$.fragment,h)},m(h,J){U(d,h,J),M=!0},p(h,J){const v={};J&2&&(v.$$scope={dirty:J,ctx:h}),d.$set(v)},i(h){M||(b(d.$$.fragment,h),M=!0)},o(h){_(d.$$.fragment,h),M=!1},d(h){T(d,h)}}}function xd(R){let d,M,h,J,v,$,I,C,x,A,S,j,ue,O,Q,Y,F,oe,ne,k,K,z,ee,te,N,L,B,le,W,q,D,ae,G,H,m,g,de,X,Z,we,se,ye,P,me,re,Qr,Yr,io,Qe,zr,kt,Lr,qr,po,Ct,ho,Kl,Hr,co,At,fo,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MGNvbmZpZw==",highlighted:"accelerate config"}}),At=new E({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),St=new E({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`}}),Wt=new E({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHNuYXBzaG90X2Rvd25sb2FkJTBBJTBBbG9jYWxfZGlyJTIwJTNEJTIwJTIyLiUyRmRvZyUyMiUwQXNuYXBzaG90X2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMCUyMmRpZmZ1c2VycyUyRmRvZy1leGFtcGxlJTIyJTJDJTBBJTIwJTIwJTIwJTIwbG9jYWxfZGlyJTNEbG9jYWxfZGlyJTJDJTBBJTIwJTIwJTIwJTIwcmVwb190eXBlJTNEJTIyZGF0YXNldCUyMiUyQyUwQSUyMCUyMCUyMCUyMGlnbm9yZV9wYXR0ZXJucyUzRCUyMi5naXRhdHRyaWJ1dGVzJTIyJTJDJTBBKQ==",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download

local_dir = <span class="hljs-string">&quot;./dog&quot;</span>
snapshot_download(
    <span class="hljs-string">&quot;diffusers/dog-example&quot;</span>,
    local_dir=local_dir,
    repo_type=<span class="hljs-string">&quot;dataset&quot;</span>,
    ignore_patterns=<span class="hljs-string">&quot;.gitattributes&quot;</span>,
)`}}),Dt=new V({}),qe=new Jd({props:{warning:!0,$$slots:{default:[$d]},$$scope:{ctx:R}}}),He=new Xc({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[Gd],pytorch:[Vd]},$$scope:{ctx:R}}}),xt=new V({}),et=new Xc({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[Cd],pytorch:[Zd]},$$scope:{ctx:R}}}),Yt=new V({}),lt=new Jd({props:{warning:!0,$$slots:{default:[Ad]},$$scope:{ctx:R}}}),at=new Xc({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[Dd],pytorch:[Fd]},$$scope:{ctx:R}}}),Lt=new V({}),qt=new V({}),Ht=new E({props:{code:"JTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAw",highlighted:"  --checkpointing_steps=500"}}),Pt=new V({}),Ot=new E({props:{code:"JTIwJTIwLS1yZXN1bWVfZnJvbV9jaGVja3BvaW50JTNEJTIyY2hlY2twb2ludC0xNTAwJTIy",highlighted:'  --resume_from_checkpoint=<span class="hljs-string">&quot;checkpoint-1500&quot;</span>'}}),Kt=new V({}),el=new E({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ0xJUFRleHRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBJTIzJTIwTG9hZCUyMHRoZSUyMHBpcGVsaW5lJTIwd2l0aCUyMHRoZSUyMHNhbWUlMjBhcmd1bWVudHMlMjAobW9kZWwlMkMlMjByZXZpc2lvbiklMjB0aGF0JTIwd2VyZSUyMHVzZWQlMjBmb3IlMjB0cmFpbmluZyUwQW1vZGVsX2lkJTIwJTNEJTIwJTIyQ29tcFZpcyUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNCUyMiUwQSUwQXVuZXQlMjAlM0QlMjBVTmV0MkRDb25kaXRpb25Nb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyJTJGc2RkYXRhJTJGZHJlYW1ib290aCUyRmRhcnVtYS12Mi0xJTJGY2hlY2twb2ludC0xMDAlMkZ1bmV0JTIyKSUwQSUwQSUyMyUyMGlmJTIweW91JTIwaGF2ZSUyMHRyYWluZWQlMjB3aXRoJTIwJTYwLS1hcmdzLnRyYWluX3RleHRfZW5jb2RlciU2MCUyMG1ha2UlMjBzdXJlJTIwdG8lMjBhbHNvJTIwbG9hZCUyMHRoZSUyMHRleHQlMjBlbmNvZGVyJTBBdGV4dF9lbmNvZGVyJTIwJTNEJTIwQ0xJUFRleHRNb2RlbC5mcm9tX3ByZXRyYWluZWQoJTIyJTJGc2RkYXRhJTJGZHJlYW1ib290aCUyRmRhcnVtYS12Mi0xJTJGY2hlY2twb2ludC0xMDAlMkZ0ZXh0X2VuY29kZXIlMjIpJTBBJTBBcGlwZWxpbmUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB1bmV0JTNEdW5ldCUyQyUyMHRleHRfZW5jb2RlciUzRHRleHRfZW5jb2RlciUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlbGluZS50byglMjJjdWRhJTIyKSUwQSUwQSUyMyUyMFBlcmZvcm0lMjBpbmZlcmVuY2UlMkMlMjBvciUyMHNhdmUlMkMlMjBvciUyMHB1c2glMjB0byUyMHRoZSUyMGh1YiUwQXBpcGVsaW5lLnNhdmVfcHJldHJhaW5lZCglMjJkcmVhbWJvb3RoLXBpcGVsaW5lJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, UNet2DConditionModel
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPTextModel
<span class="hljs-keyword">import</span> torch

<span class="hljs-comment"># Load the pipeline with the same arguments (model, revision) that were used for training</span>
model_id = <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>

unet = UNet2DConditionModel.from_pretrained(<span class="hljs-string">&quot;/sddata/dreambooth/daruma-v2-1/checkpoint-100/unet&quot;</span>)

<span class="hljs-comment"># if you have trained with \`--args.train_text_encoder\` make sure to also load the text encoder</span>
text_encoder = CLIPTextModel.from_pretrained(<span class="hljs-string">&quot;/sddata/dreambooth/daruma-v2-1/checkpoint-100/text_encoder&quot;</span>)

pipeline = DiffusionPipeline.from_pretrained(model_id, unet=unet, text_encoder=text_encoder, dtype=torch.float16)
pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-comment"># Perform inference, or save, or push to the hub</span>
pipeline.save_pretrained(<span class="hljs-string">&quot;dreambooth-pipeline&quot;</span>)`}}),tl=new E({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEaWZmdXNpb25QaXBlbGluZSUwQSUwQSUyMyUyMExvYWQlMjB0aGUlMjBwaXBlbGluZSUyMHdpdGglMjB0aGUlMjBzYW1lJTIwYXJndW1lbnRzJTIwKG1vZGVsJTJDJTIwcmV2aXNpb24pJTIwdGhhdCUyMHdlcmUlMjB1c2VkJTIwZm9yJTIwdHJhaW5pbmclMEFtb2RlbF9pZCUyMCUzRCUyMCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCklMEElMEFhY2NlbGVyYXRvciUyMCUzRCUyMEFjY2VsZXJhdG9yKCklMEElMEElMjMlMjBVc2UlMjB0ZXh0X2VuY29kZXIlMjBpZiUyMCU2MC0tdHJhaW5fdGV4dF9lbmNvZGVyJTYwJTIwd2FzJTIwdXNlZCUyMGZvciUyMHRoZSUyMGluaXRpYWwlMjB0cmFpbmluZyUwQXVuZXQlMkMlMjB0ZXh0X2VuY29kZXIlMjAlM0QlMjBhY2NlbGVyYXRvci5wcmVwYXJlKHBpcGVsaW5lLnVuZXQlMkMlMjBwaXBlbGluZS50ZXh0X2VuY29kZXIpJTBBJTBBJTIzJTIwUmVzdG9yZSUyMHN0YXRlJTIwZnJvbSUyMGElMjBjaGVja3BvaW50JTIwcGF0aC4lMjBZb3UlMjBoYXZlJTIwdG8lMjB1c2UlMjB0aGUlMjBhYnNvbHV0ZSUyMHBhdGglMjBoZXJlLiUwQWFjY2VsZXJhdG9yLmxvYWRfc3RhdGUoJTIyJTJGc2RkYXRhJTJGZHJlYW1ib290aCUyRmRhcnVtYS12Mi0xJTJGY2hlY2twb2ludC0xMDAlMjIpJTBBJTBBJTIzJTIwUmVidWlsZCUyMHRoZSUyMHBpcGVsaW5lJTIwd2l0aCUyMHRoZSUyMHVud3JhcHBlZCUyMG1vZGVscyUyMChhc3NpZ25tZW50JTIwdG8lMjAudW5ldCUyMGFuZCUyMC50ZXh0X2VuY29kZXIlMjBzaG91bGQlMjB3b3JrJTIwdG9vKSUwQXBpcGVsaW5lJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMG1vZGVsX2lkJTJDJTBBJTIwJTIwJTIwJTIwdW5ldCUzRGFjY2VsZXJhdG9yLnVud3JhcF9tb2RlbCh1bmV0KSUyQyUwQSUyMCUyMCUyMCUyMHRleHRfZW5jb2RlciUzRGFjY2VsZXJhdG9yLnVud3JhcF9tb2RlbCh0ZXh0X2VuY29kZXIpJTJDJTBBKSUwQSUwQSUyMyUyMFBlcmZvcm0lMjBpbmZlcmVuY2UlMkMlMjBvciUyMHNhdmUlMkMlMjBvciUyMHB1c2glMjB0byUyMHRoZSUyMGh1YiUwQXBpcGVsaW5lLnNhdmVfcHJldHJhaW5lZCglMjJkcmVhbWJvb3RoLXBpcGVsaW5lJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

<span class="hljs-comment"># Load the pipeline with the same arguments (model, revision) that were used for training</span>
model_id = <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
pipeline = DiffusionPipeline.from_pretrained(model_id)

accelerator = Accelerator()

<span class="hljs-comment"># Use text_encoder if \`--train_text_encoder\` was used for the initial training</span>
unet, text_encoder = accelerator.prepare(pipeline.unet, pipeline.text_encoder)

<span class="hljs-comment"># Restore state from a checkpoint path. You have to use the absolute path here.</span>
accelerator.load_state(<span class="hljs-string">&quot;/sddata/dreambooth/daruma-v2-1/checkpoint-100&quot;</span>)

<span class="hljs-comment"># Rebuild the pipeline with the unwrapped models (assignment to .unet and .text_encoder should work too)</span>
pipeline = DiffusionPipeline.from_pretrained(
    model_id,
    unet=accelerator.unwrap_model(unet),
    text_encoder=accelerator.unwrap_model(text_encoder),
)

<span class="hljs-comment"># Perform inference, or save, or push to the hub</span>
pipeline.save_pretrained(<span class="hljs-string">&quot;dreambooth-pipeline&quot;</span>)`}}),ll=new V({}),al=new V({}),nl=new E({props:{code:"JTIwJTIwLS1lbmFibGVfeGZvcm1lcnNfbWVtb3J5X2VmZmljaWVudF9hdHRlbnRpb24=",highlighted:"  --enable_xformers_memory_efficient_attention"}}),rl=new V({}),pl=new E({props:{code:"JTIwJTIwLS1zZXRfZ3JhZHNfdG9fbm9uZQ==",highlighted:"  --set_grads_to_none"}}),hl=new V({}),fl=new E({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcw==",highlighted:"pip install bitsandbytes"}}),ul=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aF90b19jbGFzc19pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b19zY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IwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0Q4MDAlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=2 --gradient_checkpointing \\
  --use_8bit_adam \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`}}),dl=new V({}),ml=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aC10by1jbGFzcy1pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10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GVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW51bV9jbGFzc19pbWFnZXMlM0QyMDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDgwMCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path-to-class-images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=1 --gradient_checkpointing \\
  --use_8bit_adam \\
  --enable_xformers_memory_efficient_attention \\
  --set_grads_to_none \\
  --learning_rate=2e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`}}),Ml=new V({}),yl=new E({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),_l=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSU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W50aW5nJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW51bV9jbGFzc19pbWFnZXMlM0QyMDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDgwMCUyMCU1QyUwQSUyMCUyMC0tbWl4ZWRfcHJlY2lzaW9uJTNEZnAxNiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --sample_batch_size=1 \\
  --gradient_accumulation_steps=1 --gradient_checkpointing \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --mixed_precision=fp16 \\
  --push_to_hub`}}),Tl=new V({}),Jl=new E({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnBhdGhfdG9fc2F2ZWRfbW9kZWwlMjIlMEFwaXBlJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX2lkJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBwaG90byUyMG9mJTIwc2tzJTIwZG9nJTIwaW4lMjBhJTIwYnVja2V0JTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlKHByb21wdCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCUyQyUyMGd1aWRhbmNlX3NjYWxlJTNENy41KS5pbWFnZXMlNUIwJTVEJTBBJTBBaW1hZ2Uuc2F2ZSglMjJkb2ctYnVja2V0LnBuZyUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;path_to_saved_model&quot;</span>
pipe = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>
image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>, guidance_scale=<span class="hljs-number">7.5</span>).images[<span class="hljs-number">0</span>]

image.save(<span class="hljs-string">&quot;dog-bucket.png&quot;</span>)`}}),vl=new V({}),El=new E({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJEZWVwRmxveWQlMkZJRi1JLVhMLXYxLjAlMjIpJTBBJTBBcGlwZS5sb2FkX2xvcmFfd2VpZ2h0cyglMjIlM0Nsb3JhJTIwd2VpZ2h0cyUyMHBhdGglM0UlMjIpJTBBJTBBJTIzJTIwVXBkYXRlJTIwc2NoZWR1bGVyJTIwY29uZmlnJTIwdG8lMjBmaXhlZCUyMHZhcmlhbmNlJTIwc2NoZWR1bGUlMEFwaXBlLnNjaGVkdWxlciUyMCUzRCUyMHBpcGUuc2NoZWR1bGVyLl9fY2xhc3NfXy5mcm9tX2NvbmZpZyhwaXBlLnNjaGVkdWxlci5jb25maWclMkMlMjB2YXJpYW5jZV90eXBlJTNEJTIyZml4ZWRfc21hbGwlMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>)

pipe.load_lora_weights(<span class="hljs-string">&quot;&lt;lora weights path&gt;&quot;</span>)

<span class="hljs-comment"># Update scheduler config to fixed variance schedule</span>
pipe.scheduler = pipe.scheduler.__class__.from_config(pipe.scheduler.config, variance_type=<span class="hljs-string">&quot;fixed_small&quot;</span>)`}}),Vl=new V({}),Bl=new V({}),Gl=new E({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHNuYXBzaG90X2Rvd25sb2FkJTBBJTBBbG9jYWxfZGlyJTIwJTNEJTIwJTIyLiUyRmRvZ19kb3duc2l6ZWQlMjIlMEFzbmFwc2hvdF9kb3dubG9hZCglMEElMjAlMjAlMjAlMjAlMjJkaWZmdXNlcnMlMkZkb2ctZXhhbXBsZS1kb3duc2l6ZWQlMjIlMkMlMEElMjAlMjAlMjAlMjBsb2NhbF9kaXIlM0Rsb2NhbF9kaXIlMkMlMEElMjAlMjAlMjAlMjByZXBvX3R5cGUlM0QlMjJkYXRhc2V0JTIyJTJDJTBBJTIwJTIwJTIwJTIwaWdub3JlX3BhdHRlcm5zJTNEJTIyLmdpdGF0dHJpYnV0ZXMlMjIlMkMlMEEp",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download

local_dir = <span class="hljs-string">&quot;./dog_downsized&quot;</span>
snapshot_download(
    <span class="hljs-string">&quot;diffusers/dog-example-downsized&quot;</span>,
    local_dir=local_dir,
    repo_type=<span class="hljs-string">&quot;dataset&quot;</span>,
    ignore_patterns=<span class="hljs-string">&quot;.gitattributes&quot;</span>,
)`}}),Xl=new V({}),Zl=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUktWEwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ19sb3JhJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGhfbG9yYS5weSUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTIwd2FuZGIlMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwc2tzJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENjQlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0Q0JTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tc2NhbGVfbHIlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDEyMDAlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9lcG9jaHMlM0QyNSUyMCU1QyUwQSUyMCUyMC0tY2hlY2twb2ludGluZ19zdGVwcyUzRDEwMCUyMCU1QyUwQSUyMCUyMC0tcHJlX2NvbXB1dGVfdGV4dF9lbWJlZGRpbmdzJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUzRDc3JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNr",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_lora&quot;</span>

accelerate launch train_dreambooth_lora.py \\
  --report_to wandb \\
  --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 sks dog&quot;</span> \\
  --resolution=64 \\
  --train_batch_size=4 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=5e-6 \\
  --scale_lr \\
  --max_train_steps=1200 \\
  --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
  --validation_epochs=25 \\
  --checkpointing_steps=100 \\
  --pre_compute_text_embeddings \\
  --tokenizer_max_length=77 \\
  --text_encoder_use_attention_mask`}}),kl=new V({}),Wl=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFweXRob24lMjB0cmFpbl9kcmVhbWJvb3RoX2xvcmEucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXJlcG9ydF90byUyMHdhbmRiJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcmVzb2x1dGlvbiUzRDI1NiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAlMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS02JTIwJTVDJTIwJTBBJTIwJTIwJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QyMDAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMmElMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZhbGlkYXRpb25fZXBvY2hzJTNEMTAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRva2VuaXplcl9tYXhfbGVuZ3RoJTNENzclMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRleHRfZW5jb2Rlcl91c2VfYXR0ZW50aW9uX21hc2slMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZhbGlkYXRpb25faW1hZ2VzJTIwJTI0VkFMSURBVElPTl9JTUFHRVMlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWNsYXNzX2xhYmVsc19jb25kaXRpb25pbmclM0R0aW1lc3RlcHM=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-II-L-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_upscale&quot;</span>
<span class="hljs-built_in">export</span> VALIDATION_IMAGES=<span class="hljs-string">&quot;dog_downsized/image_1.png dog_downsized/image_2.png dog_downsized/image_3.png dog_downsized/image_4.png&quot;</span>

python train_dreambooth_lora.py \\
    --report_to wandb \\
    --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 sks dog&quot;</span> \\
    --resolution=256 \\
    --train_batch_size=4 \\
    --gradient_accumulation_steps=1 \\
    --learning_rate=1e-6 \\ 
    --max_train_steps=2000 \\
    --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
    --validation_epochs=100 \\
    --checkpointing_steps=500 \\
    --pre_compute_text_embeddings \\
    --tokenizer_max_length=77 \\
    --text_encoder_use_attention_mask \\
    --validation_images <span class="hljs-variable">$VALIDATION_IMAGES</span> \\
    --class_labels_conditioning=timesteps`}}),Dl=new V({}),Yl=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUktWEwtdjEuMCUyMiUwQSUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2lmJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDY0JTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNENCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTclMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MCUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9wcm9tcHQlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9zdGVwcyUyMDI1JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUyMDc3JTIwJTVDJTBBJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUMlMEElMjAlMjAtLXNldF9ncmFkc190b19ub25lJTIwJTVDJTBBJTIwJTIwLS1za2lwX3NhdmVfdGV4dF9lbmNvZGVyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>

<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_if&quot;</span>

accelerate launch train_dreambooth.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=64 \\
  --train_batch_size=4 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=1e-7 \\
  --max_train_steps=150 \\
  --validation_prompt <span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --validation_steps 25 \\
  --text_encoder_use_attention_mask \\
  --tokenizer_max_length 77 \\
  --pre_compute_text_embeddings \\
  --use_8bit_adam \\
  --set_grads_to_none \\
  --skip_save_text_encoder \\
  --push_to_hub`}}),zl=new V({}),Hl=new E({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwdHJhaW5fZHJlYW1ib290aC5weSUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTIwd2FuZGIlMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwc2tzJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNEMjU2JTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMiUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNENiUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDVlLTYlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDIwMDAlMjAlNUMlMEElMjAlMjAtLXZhbGlkYXRpb25fcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9zdGVwcyUzRDE1MCUyMCU1QyUwQSUyMCUyMC0tY2hlY2twb2ludGluZ19zdGVwcyUzRDUwMCUyMCU1QyUwQSUyMCUyMC0tcHJlX2NvbXB1dGVfdGV4dF9lbWJlZGRpbmdzJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUzRDc3JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX2ltYWdlcyUyMCUyNFZBTElEQVRJT05fSU1BR0VTJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19sYWJlbHNfY29uZGl0aW9uaW5nJTIwdGltZXN0ZXBzJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-II-L-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_upscale&quot;</span>
<span class="hljs-built_in">export</span> VALIDATION_IMAGES=<span class="hljs-string">&quot;dog_downsized/image_1.png dog_downsized/image_2.png dog_downsized/image_3.png dog_downsized/image_4.png&quot;</span>

accelerate launch train_dreambooth.py \\
  --report_to wandb \\
  --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 sks dog&quot;</span> \\
  --resolution=256 \\
  --train_batch_size=2 \\
  --gradient_accumulation_steps=6 \\
  --learning_rate=5e-6 \\
  --max_train_steps=2000 \\
  --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
  --validation_steps=150 \\
  --checkpointing_steps=500 \\
  --pre_compute_text_embeddings \\
  --tokenizer_max_length=77 \\
  --text_encoder_use_attention_mask \\
  --validation_images <span class="hljs-variable">$VALIDATION_IMAGES</span> \\
  --class_labels_conditioning timesteps \\
  --push_to_hub`}}),{c(){d=a("meta"),M=c(),h=a("h1"),J=a("a"),v=a("span"),w($.$$.fragment),I=c(),C=a("span"),x=r("DreamBooth"),A=c(),S=a("p"),j=a("a"),ue=r("DreamBooth"),O=r(" is a method to personalize text-to-image models like Stable Diffusion given just a few (3-5) images of a subject. It allows the model to generate contextualized images of the subject in different scenes, poses, and views."),Q=c(),Y=a("p"),F=a("img"),ne=c(),k=a("small"),K=r("Dreambooth examples from the "),z=a("a"),ee=r("project's blog."),te=c(),N=a("p"),L=r("This guide will show you how to finetune DreamBooth with the "),B=a("a"),le=a("code"),W=r("CompVis/stable-diffusion-v1-4"),q=r(" model for various GPU sizes, and with Flax. All the training scripts for DreamBooth used in this guide can be found "),D=a("a"),ae=r("here"),G=r(" if you\u2019re interested in digging deeper and seeing how things work."),H=c(),m=a("p"),g=r("Before running the scripts, make sure you install the library\u2019s training dependencies. We also recommend installing \u{1F9E8} Diffusers from the "),de=a("code"),X=r("main"),Z=r(" GitHub branch:"),we=c(),w(se.$$.fragment),ye=c(),P=a("p"),me=r("xFormers is not part of the training requirements, but we recommend you "),re=a("a"),Qr=r("install"),Yr=r(" it if you can because it could make your training faster and less memory intensive."),io=c(),Qe=a("p"),zr=r("After all the dependencies have been set up, initialize a "),kt=a("a"),Lr=r("\u{1F917} Accelerate"),qr=r(" environment with:"),po=c(),w(Ct.$$.fragment),ho=c(),Kl=a("p"),Hr=r("To setup a default \u{1F917} Accelerate environment without choosing any configurations:"),co=c(),w(At.$$.fragment),fo=c(),ea=a("p"),Pr=r("Or if your environment doesn\u2019t support an interactive shell like a notebook, you can use:"),uo=c(),w(St.$$.fragment),mo=c(),Ye=a("p"),Or=r("Finally, download a "),Ft=a("a"),Kr=r("few images of a dog"),ei=r(" to DreamBooth with:"),Mo=c(),w(Wt.$$.fragment),wo=c(),ze=a("p"),ti=r("To use your own dataset, take a look at the "),ta=a("a"),li=r("Create a dataset for training"),ai=r(" guide."),yo=c(),Te=a("h2"),Le=a("a"),$a=a("span"),w(Dt.$$.fragment),si=c(),Na=a("span"),oi=r("Finetuning"),Uo=c(),w(qe.$$.fragment),bo=c(),w(He.$$.fragment),_o=c(),Je=a("h2"),Pe=a("a"),Va=a("span"),w(xt.$$.fragment),ni=c(),Ba=a("span"),ri=r("Finetuning with prior-preserving loss"),To=c(),Oe=a("p"),ii=r("Prior preservation is used to avoid overfitting and language-drift (check out the "),Qt=a("a"),pi=r("paper"),hi=r(" to learn more if you\u2019re interested). For prior preservation, you use other images of the same class as part of the training process. The nice thing is that you can generate those images using the Stable Diffusion model itself! The training script will save the generated images to a local path you specify."),Jo=c(),Ke=a("p"),ci=r("The authors recommend generating "),Ga=a("code"),fi=r("num_epochs * num_samples"),ui=r(" images for prior preservation. In most cases, 200-300 images work well."),vo=c(),w(et.$$.fragment),go=c(),ve=a("h2"),tt=a("a"),Xa=a("span"),w(Yt.$$.fragment),di=c(),Za=a("span"),mi=r("Finetuning the text encoder and UNet"),Io=c(),ie=a("p"),Mi=r("The script also allows you to finetune the "),ka=a("code"),wi=r("text_encoder"),yi=r(" along with the "),Ca=a("code"),Ui=r("unet"),bi=r(". In our experiments (check out the "),zt=a("a"),_i=r("Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),Ti=r(" post for more details), this yields much better results, especially when generating images of faces."),Eo=c(),w(lt.$$.fragment),jo=c(),pe=a("p"),Ji=r("Pass the "),Aa=a("code"),vi=r("--train_text_encoder"),gi=r(" argument to the training script to enable finetuning the "),Sa=a("code"),Ii=r("text_encoder"),Ei=r(" and "),Fa=a("code"),ji=r("unet"),Ri=r(":"),Ro=c(),w(at.$$.fragment),$o=c(),ge=a("h2"),st=a("a"),Wa=a("span"),w(Lt.$$.fragment),$i=c(),Da=a("span"),Ni=r("Finetuning with LoRA"),No=c(),ot=a("p"),Vi=r("You can also use Low-Rank Adaptation of Large Language Models (LoRA), a fine-tuning technique for accelerating training large models, on DreamBooth. For more details, take a look at the "),la=a("a"),Bi=r("LoRA training"),Gi=r(" guide."),Vo=c(),Ie=a("h2"),nt=a("a"),xa=a("span"),w(qt.$$.fragment),Xi=c(),Qa=a("span"),Zi=r("Saving checkpoints while training"),Bo=c(),aa=a("p"),ki=r("It\u2019s easy to overfit while training with Dreambooth, so sometimes it\u2019s useful to save regular checkpoints during the training process. One of the intermediate checkpoints might actually work better than the final model! Pass the following argument to the training script to enable saving checkpoints:"),Go=c(),w(Ht.$$.fragment),Xo=c(),he=a("p"),Ci=r("This saves the full training state in subfolders of your "),Ya=a("code"),Ai=r("output_dir"),Si=r(". Subfolder names begin with the prefix "),za=a("code"),Fi=r("checkpoint-"),Wi=r(", followed by the number of steps performed so far; for example, "),La=a("code"),Di=r("checkpoint-1500"),xi=r(" would be a checkpoint saved after 1500 training steps."),Zo=c(),Ee=a("h3"),rt=a("a"),qa=a("span"),w(Pt.$$.fragment),Qi=c(),Ha=a("span"),Yi=r("Resume training from a saved checkpoint"),ko=c(),Ue=a("p"),zi=r("If you want to resume training from any of the saved checkpoints, you can pass the argument "),Pa=a("code"),Li=r("--resume_from_checkpoint"),qi=r(" to the script and specify the name of the checkpoint you want to use. You can also use the special string "),Oa=a("code"),Hi=r('"latest"'),Pi=r(" to resume from the last saved checkpoint (the one with the largest number of steps). For example, the following would resume training from the checkpoint saved after 1500 steps:"),Co=c(),w(Ot.$$.fragment),Ao=c(),sa=a("p"),Oi=r("This is a good opportunity to tweak some of your hyperparameters if you wish."),So=c(),je=a("h3"),it=a("a"),Ka=a("span"),w(Kt.$$.fragment),Ki=c(),es=a("span"),ep=r("Inference from a saved checkpoint"),Fo=c(),oa=a("p"),tp=r("Saved checkpoints are stored in a format suitable for resuming training. They not only include the model weights, but also the state of the optimizer, data loaders, and learning rate."),Wo=c(),pt=a("p"),lp=r("If you have "),ts=a("strong"),ls=a("code"),ap=r('"accelerate>=0.16.0"'),sp=r(` installed, use the following code to run
inference from an intermediate checkpoint.`),Do=c(),w(el.$$.fragment),xo=c(),ht=a("p"),op=r("If you have "),as=a("strong"),ss=a("code"),np=r('"accelerate<0.16.0"'),rp=r(" installed, you need to convert it to an inference pipeline first:"),Qo=c(),w(tl.$$.fragment),Yo=c(),Re=a("h2"),ct=a("a"),os=a("span"),w(ll.$$.fragment),ip=c(),ns=a("span"),pp=r("Optimizations for different GPU sizes"),zo=c(),na=a("p"),hp=r("Depending on your hardware, there are a few different ways to optimize DreamBooth on GPUs from 16GB to just 8GB!"),Lo=c(),$e=a("h3"),ft=a("a"),rs=a("span"),w(al.$$.fragment),cp=c(),is=a("span"),fp=r("xFormers"),qo=c(),Me=a("p"),sl=a("a"),up=r("xFormers"),dp=r(" is a toolbox for optimizing Transformers, and it includes a "),ol=a("a"),mp=r("memory-efficient attention"),Mp=r(" mechanism that is used in \u{1F9E8} Diffusers. You\u2019ll need to "),ra=a("a"),wp=r("install xFormers"),yp=r(" and then add the following argument to your training script:"),Ho=c(),w(nl.$$.fragment),Po=c(),ia=a("p"),Up=r("xFormers is not available in Flax."),Oo=c(),Ne=a("h3"),ut=a("a"),ps=a("span"),w(rl.$$.fragment),bp=c(),hs=a("span"),_p=r("Set gradients to none"),Ko=c(),ce=a("p"),Tp=r("Another way you can lower your memory footprint is to "),il=a("a"),Jp=r("set the gradients"),vp=r(" to "),cs=a("code"),gp=r("None"),Ip=r(" instead of zero. However, this may change certain behaviors, so if you run into any issues, try removing this argument. Add the following argument to your training script to set the gradients to "),fs=a("code"),Ep=r("None"),jp=r(":"),en=c(),w(pl.$$.fragment),tn=c(),Ve=a("h3"),dt=a("a"),us=a("span"),w(hl.$$.fragment),Rp=c(),ds=a("span"),$p=r("16GB GPU"),ln=c(),mt=a("p"),Np=r("With the help of gradient checkpointing and "),cl=a("a"),Vp=r("bitsandbytes"),Bp=r(" 8-bit optimizer, it\u2019s possible to train DreamBooth on a 16GB GPU. Make sure you have bitsandbytes installed:"),an=c(),w(fl.$$.fragment),sn=c(),Mt=a("p"),Gp=r("Then pass the "),ms=a("code"),Xp=r("--use_8bit_adam"),Zp=r(" option to the training script:"),on=c(),w(ul.$$.fragment),nn=c(),Be=a("h3"),wt=a("a"),Ms=a("span"),w(dl.$$.fragment),kp=c(),ws=a("span"),Cp=r("12GB GPU"),rn=c(),yt=a("p"),Ap=r("To run DreamBooth on a 12GB GPU, you\u2019ll need to enable gradient checkpointing, the 8-bit optimizer, xFormers, and set the gradients to "),ys=a("code"),Sp=r("None"),Fp=r(":"),pn=c(),w(ml.$$.fragment),hn=c(),Ge=a("h3"),Ut=a("a"),Us=a("span"),w(Ml.$$.fragment),Wp=c(),bs=a("span"),Dp=r("8 GB GPU"),cn=c(),bt=a("p"),xp=r("For 8GB GPUs, you\u2019ll need the help of "),wl=a("a"),Qp=r("DeepSpeed"),Yp=r(` to offload some
tensors from the VRAM to either the CPU or NVME, enabling training with less GPU memory.`),fn=c(),pa=a("p"),zp=r("Run the following command to configure your \u{1F917} Accelerate environment:"),un=c(),w(yl.$$.fragment),dn=c(),_t=a("p"),Lp=r("During configuration, confirm that you want to use DeepSpeed. Now it\u2019s possible to train on under 8GB VRAM by combining DeepSpeed stage 2, fp16 mixed precision, and offloading the model parameters and the optimizer state to the CPU. The drawback is that this requires more system RAM, about 25 GB. See "),Ul=a("a"),qp=r("the DeepSpeed documentation"),Hp=r(" for more configuration options."),mn=c(),be=a("p"),Pp=r(`You should also change the default Adam optimizer to DeepSpeed\u2019s optimized version of Adam
`),bl=a("a"),_s=a("code"),Op=r("deepspeed.ops.adam.DeepSpeedCPUAdam"),Kp=r(" for a substantial speedup. Enabling "),Ts=a("code"),eh=r("DeepSpeedCPUAdam"),th=r(" requires your system\u2019s CUDA toolchain version to be the same as the one installed with PyTorch."),Mn=c(),ha=a("p"),lh=r("8-bit optimizers don\u2019t seem to be compatible with DeepSpeed at the moment."),wn=c(),ca=a("p"),ah=r("Launch training with the following command:"),yn=c(),w(_l.$$.fragment),Un=c(),Xe=a("h2"),Tt=a("a"),Js=a("span"),w(Tl.$$.fragment),sh=c(),vs=a("span"),oh=r("Inference"),bn=c(),fe=a("p"),nh=r("Once you have trained a model, specify the path to where the model is saved, and use it for inference in the "),fa=a("a"),rh=r("StableDiffusionPipeline"),ih=r(". Make sure your prompts include the special "),gs=a("code"),ph=r("identifier"),hh=r(" used during training ("),Is=a("code"),ch=r("sks"),fh=r(" in the previous examples)."),_n=c(),Jt=a("p"),uh=r("If you have "),Es=a("strong"),js=a("code"),dh=r('"accelerate>=0.16.0"'),mh=r(` installed, you can use the following code to run
inference from an intermediate checkpoint:`),Tn=c(),w(Jl.$$.fragment),Jn=c(),vt=a("p"),Mh=r("You may also run inference from any of the "),ua=a("a"),wh=r("saved training checkpoints"),yh=r("."),vn=c(),Ze=a("h2"),gt=a("a"),Rs=a("span"),w(vl.$$.fragment),Uh=c(),$s=a("span"),bh=r("IF"),gn=c(),_e=a("p"),_h=r("You can use the lora and full dreambooth scripts to train the text to image "),gl=a("a"),Th=r("IF model"),Jh=r(` and the stage II upscaler
`),Il=a("a"),vh=r("IF model"),gh=r("."),In=c(),da=a("p"),Ih=r(`Note that IF has a predicted variance, and our finetuning scripts only train the models predicted error, so for finetuned IF models we switch to a fixed
variance schedule. The full finetuning scripts will update the scheduler config for the full saved model. However, when loading saved LoRA weights, you
must also update the pipeline\u2019s scheduler config.`),En=c(),w(El.$$.fragment),jn=c(),ma=a("p"),Eh=r("Additionally, a few alternative cli flags are needed for IF."),Rn=c(),jl=a("p"),Ns=a("code"),jh=r("--resolution=64"),Rh=r(": IF is a pixel space diffusion model. In order to operate on un-compressed pixels, the input images are of a much smaller resolution."),$n=c(),ke=a("p"),Vs=a("code"),$h=r("--pre_compute_text_embeddings"),Nh=r(": IF uses "),Rl=a("a"),Vh=r("T5"),Bh=r(` for its text encoder. In order to save GPU memory, we pre compute all text embeddings and then de-allocate
T5.`),Nn=c(),$l=a("p"),Bs=a("code"),Gh=r("--tokenizer_max_length=77"),Xh=r(": T5 has a longer default text length, but the default IF encoding procedure uses a smaller number."),Vn=c(),Nl=a("p"),Gs=a("code"),Zh=r("--text_encoder_use_attention_mask"),kh=r(": T5 passes the attention mask to the text encoder."),Bn=c(),Ce=a("h3"),It=a("a"),Xs=a("span"),w(Vl.$$.fragment),Ch=c(),Zs=a("span"),Ah=r("Tips and Tricks"),Gn=r(`

We find LoRA to be sufficient for finetuning the stage I model as the low resolution of the model makes representing finegrained detail hard regardless.
`),Ma=a("p"),Sh=r(`For common and/or not-visually complex object concepts, you can get away with not-finetuning the upscaler. Just be sure to adjust the prompt passed to the
upscaler to remove the new token from the instance prompt. I.e. if your stage I prompt is \u201Ca sks dog\u201D, use \u201Ca dog\u201D for your stage II prompt.`),Xn=c(),wa=a("p"),Fh=r(`For finegrained detail like faces that aren\u2019t present in the original training set, we find that full finetuning of the stage II upscaler is better than
LoRA finetuning stage II.`),Zn=c(),ya=a("p"),Wh=r("For finegrained detail like faces, we find that lower learning rates along with larger batch sizes work best."),kn=c(),Ua=a("p"),Dh=r("For stage II, we find that lower learning rates are also needed."),Cn=c(),ba=a("p"),xh=r(`We found experimentally that the DDPM scheduler with the default larger number of denoising steps to sometimes work better than the DPM Solver scheduler
used in the training scripts.`),An=c(),Ae=a("h3"),Et=a("a"),ks=a("span"),w(Bl.$$.fragment),Qh=c(),Cs=a("span"),Yh=r("Stage II additional validation images"),Sn=c(),_a=a("p"),zh=r("The stage II validation requires images to upscale, we can download a downsized version of the training set:"),Fn=c(),w(Gl.$$.fragment),Wn=c(),Se=a("h3"),jt=a("a"),As=a("span"),w(Xl.$$.fragment),Lh=c(),Ss=a("span"),qh=r("IF stage I LoRA Dreambooth"),Dn=r(`

This training configuration requires ~28 GB VRAM.

	`),w(Zl.$$.fragment),xn=c(),Fe=a("h3"),Rt=a("a"),Fs=a("span"),w(kl.$$.fragment),Hh=c(),Ws=a("span"),Ph=r("IF stage II LoRA Dreambooth"),Qn=c(),Cl=a("p"),Ds=a("code"),Oh=r("--validation_images"),Kh=r(": These images are upscaled during validation steps."),Yn=c(),Al=a("p"),xs=a("code"),ec=r("--class_labels_conditioning=timesteps"),tc=r(": Pass additional conditioning to the UNet needed for stage II."),zn=c(),Sl=a("p"),Qs=a("code"),lc=r("--learning_rate=1e-6"),ac=r(": Lower learning rate than stage I."),Ln=c(),Fl=a("p"),Ys=a("code"),sc=r("--resolution=256"),oc=r(": The upscaler expects higher resolution inputs"),qn=c(),w(Wl.$$.fragment),Hn=c(),We=a("h3"),$t=a("a"),zs=a("span"),w(Dl.$$.fragment),nc=c(),Ls=a("span"),rc=r("IF Stage I Full Dreambooth"),Pn=r(`

\`--skip_save_text_encoder\`: When training the full model, this will skip saving the entire T5 with the finetuned model. You can still load the pipeline
with a T5 loaded from the original model.
`),xl=a("p"),qs=a("code"),ic=r("use_8bit_adam"),pc=r(": Due to the size of the optimizer states, we recommend training the full XL IF model with 8bit adam."),On=c(),Ql=a("p"),Hs=a("code"),hc=r("--learning_rate=1e-7"),cc=r(`: For full dreambooth, IF requires very low learning rates. With higher learning rates model quality will degrade. Note that it is
likely the learning rate can be increased with larger batch sizes.`),Kn=c(),Ta=a("p"),fc=r("Using 8bit adam and a batch size of 4, the model can be trained in ~48 GB VRAM."),er=c(),w(Yl.$$.fragment),tr=c(),De=a("h3"),Nt=a("a"),Ps=a("span"),w(zl.$$.fragment),uc=c(),Os=a("span"),dc=r("IF Stage II Full Dreambooth"),lr=c(),Ll=a("p"),Ks=a("code"),mc=r("--learning_rate=5e-6"),Mc=r(`: With a smaller effective batch size of 4, we found that we required learning rates as low as
1e-8.`),ar=c(),ql=a("p"),eo=a("code"),wc=r("--resolution=256"),yc=r(": The upscaler expects higher resolution inputs"),sr=c(),xe=a("p"),to=a("code"),Uc=r("--train_batch_size=2"),bc=r(" and "),lo=a("code"),_c=r("--gradient_accumulation_steps=6"),Tc=r(`: We found that full training of stage II particularly with
faces required large effective batch sizes.`),or=c(),w(Hl.$$.fragment),this.h()},l(e){const o=Ed('[data-svelte="svelte-1phssyn"]',document.head);d=s(o,"META",{name:!0,content:!0}),o.forEach(t),M=f(e),h=s(e,"H1",{class:!0});var Pl=n(h);J=s(Pl,"A",{id:!0,class:!0,href:!0});var ao=n(J);v=s(ao,"SPAN",{});var so=n(v);y($.$$.fragment,so),so.forEach(t),ao.forEach(t),I=f(Pl),C=s(Pl,"SPAN",{});var oo=n(C);x=i(oo,"DreamBooth"),oo.forEach(t),Pl.forEach(t),A=f(e),S=s(e,"P",{});var Ja=n(S);j=s(Ja,"A",{href:!0,rel:!0});var Zc=n(j);ue=i(Zc,"DreamBooth"),Zc.forEach(t),O=i(Ja," is a method to personalize text-to-image models like Stable Diffusion given just a few (3-5) images of a subject. It allows the model to generate contextualized images of the subject in different scenes, poses, and views."),Ja.forEach(t),Q=f(e),Y=s(e,"P",{});var kc=n(Y);F=s(kc,"IMG",{src:!0,alt:!0}),kc.forEach(t),ne=f(e),k=s(e,"SMALL",{});var Jc=n(k);K=i(Jc,"Dreambooth examples from the "),z=s(Jc,"A",{href:!0});var Cc=n(z);ee=i(Cc,"project's blog."),Cc.forEach(t),Jc.forEach(t),te=f(e),N=s(e,"P",{});var va=n(N);L=i(va,"This guide will show you how to finetune DreamBooth with the "),B=s(va,"A",{href:!0,rel:!0});var Ac=n(B);le=s(Ac,"CODE",{});var Sc=n(le);W=i(Sc,"CompVis/stable-diffusion-v1-4"),Sc.forEach(t),Ac.forEach(t),q=i(va," model for various GPU sizes, and with Flax. All the training scripts for DreamBooth used in this guide can be found "),D=s(va,"A",{href:!0,rel:!0});var Fc=n(D);ae=i(Fc,"here"),Fc.forEach(t),G=i(va," if you\u2019re interested in digging deeper and seeing how things work."),va.forEach(t),H=f(e),m=s(e,"P",{});var rr=n(m);g=i(rr,"Before running the scripts, make sure you install the library\u2019s training dependencies. We also recommend installing \u{1F9E8} Diffusers from the "),de=s(rr,"CODE",{});var Wc=n(de);X=i(Wc,"main"),Wc.forEach(t),Z=i(rr," GitHub branch:"),rr.forEach(t),we=f(e),y(se.$$.fragment,e),ye=f(e),P=s(e,"P",{});var ir=n(P);me=i(ir,"xFormers is not part of the training requirements, but we recommend you "),re=s(ir,"A",{href:!0});var Dc=n(re);Qr=i(Dc,"install"),Dc.forEach(t),Yr=i(ir," it if you can because it could make your training faster and less memory intensive."),ir.forEach(t),io=f(e),Qe=s(e,"P",{});var pr=n(Qe);zr=i(pr,"After all the dependencies have been set up, initialize a "),kt=s(pr,"A",{href:!0,rel:!0});var xc=n(kt);Lr=i(xc,"\u{1F917} Accelerate"),xc.forEach(t),qr=i(pr," environment with:"),pr.forEach(t),po=f(e),y(Ct.$$.fragment,e),ho=f(e),Kl=s(e,"P",{});var Qc=n(Kl);Hr=i(Qc,"To setup a default \u{1F917} Accelerate environment without choosing any configurations:"),Qc.forEach(t),co=f(e),y(At.$$.fragment,e),fo=f(e),ea=s(e,"P",{});var Yc=n(ea);Pr=i(Yc,"Or if your environment doesn\u2019t support an interactive shell like a notebook, you can use:"),Yc.forEach(t),uo=f(e),y(St.$$.fragment,e),mo=f(e),Ye=s(e,"P",{});var hr=n(Ye);Or=i(hr,"Finally, download a "),Ft=s(hr,"A",{href:!0,rel:!0});var zc=n(Ft);Kr=i(zc,"few images of a dog"),zc.forEach(t),ei=i(hr," to DreamBooth with:"),hr.forEach(t),Mo=f(e),y(Wt.$$.fragment,e),wo=f(e),ze=s(e,"P",{});var cr=n(ze);ti=i(cr,"To use your own dataset, take a look at the "),ta=s(cr,"A",{href:!0});var Lc=n(ta);li=i(Lc,"Create a dataset for training"),Lc.forEach(t),ai=i(cr," guide."),cr.forEach(t),yo=f(e),Te=s(e,"H2",{class:!0});var fr=n(Te);Le=s(fr,"A",{id:!0,class:!0,href:!0});var qc=n(Le);$a=s(qc,"SPAN",{});var Hc=n($a);y(Dt.$$.fragment,Hc),Hc.forEach(t),qc.forEach(t),si=f(fr),Na=s(fr,"SPAN",{});var Pc=n(Na);oi=i(Pc,"Finetuning"),Pc.forEach(t),fr.forEach(t),Uo=f(e),y(qe.$$.fragment,e),bo=f(e),y(He.$$.fragment,e),_o=f(e),Je=s(e,"H2",{class:!0});var ur=n(Je);Pe=s(ur,"A",{id:!0,class:!0,href:!0});var Oc=n(Pe);Va=s(Oc,"SPAN",{});var Kc=n(Va);y(xt.$$.fragment,Kc),Kc.forEach(t),Oc.forEach(t),ni=f(ur),Ba=s(ur,"SPAN",{});var ef=n(Ba);ri=i(ef,"Finetuning with prior-preserving loss"),ef.forEach(t),ur.forEach(t),To=f(e),Oe=s(e,"P",{});var dr=n(Oe);ii=i(dr,"Prior preservation is used to avoid overfitting and language-drift (check out the "),Qt=s(dr,"A",{href:!0,rel:!0});var tf=n(Qt);pi=i(tf,"paper"),tf.forEach(t),hi=i(dr," to learn more if you\u2019re interested). For prior preservation, you use other images of the same class as part of the training process. The nice thing is that you can generate those images using the Stable Diffusion model itself! The training script will save the generated images to a local path you specify."),dr.forEach(t),Jo=f(e),Ke=s(e,"P",{});var mr=n(Ke);ci=i(mr,"The authors recommend generating "),Ga=s(mr,"CODE",{});var lf=n(Ga);fi=i(lf,"num_epochs * num_samples"),lf.forEach(t),ui=i(mr," images for prior preservation. In most cases, 200-300 images work well."),mr.forEach(t),vo=f(e),y(et.$$.fragment,e),go=f(e),ve=s(e,"H2",{class:!0});var Mr=n(ve);tt=s(Mr,"A",{id:!0,class:!0,href:!0});var af=n(tt);Xa=s(af,"SPAN",{});var sf=n(Xa);y(Yt.$$.fragment,sf),sf.forEach(t),af.forEach(t),di=f(Mr),Za=s(Mr,"SPAN",{});var of=n(Za);mi=i(of,"Finetuning the text encoder and UNet"),of.forEach(t),Mr.forEach(t),Io=f(e),ie=s(e,"P",{});var Vt=n(ie);Mi=i(Vt,"The script also allows you to finetune the "),ka=s(Vt,"CODE",{});var nf=n(ka);wi=i(nf,"text_encoder"),nf.forEach(t),yi=i(Vt," along with the "),Ca=s(Vt,"CODE",{});var rf=n(Ca);Ui=i(rf,"unet"),rf.forEach(t),bi=i(Vt,". In our experiments (check out the "),zt=s(Vt,"A",{href:!0,rel:!0});var pf=n(zt);_i=i(pf,"Training Stable Diffusion with DreamBooth using \u{1F9E8} Diffusers"),pf.forEach(t),Ti=i(Vt," post for more details), this yields much better results, especially when generating images of faces."),Vt.forEach(t),Eo=f(e),y(lt.$$.fragment,e),jo=f(e),pe=s(e,"P",{});var Bt=n(pe);Ji=i(Bt,"Pass the "),Aa=s(Bt,"CODE",{});var hf=n(Aa);vi=i(hf,"--train_text_encoder"),hf.forEach(t),gi=i(Bt," argument to the training script to enable finetuning the "),Sa=s(Bt,"CODE",{});var cf=n(Sa);Ii=i(cf,"text_encoder"),cf.forEach(t),Ei=i(Bt," and "),Fa=s(Bt,"CODE",{});var ff=n(Fa);ji=i(ff,"unet"),ff.forEach(t),Ri=i(Bt,":"),Bt.forEach(t),Ro=f(e),y(at.$$.fragment,e),$o=f(e),ge=s(e,"H2",{class:!0});var wr=n(ge);st=s(wr,"A",{id:!0,class:!0,href:!0});var uf=n(st);Wa=s(uf,"SPAN",{});var df=n(Wa);y(Lt.$$.fragment,df),df.forEach(t),uf.forEach(t),$i=f(wr),Da=s(wr,"SPAN",{});var mf=n(Da);Ni=i(mf,"Finetuning with LoRA"),mf.forEach(t),wr.forEach(t),No=f(e),ot=s(e,"P",{});var yr=n(ot);Vi=i(yr,"You can also use Low-Rank Adaptation of Large Language Models (LoRA), a fine-tuning technique for accelerating training large models, on DreamBooth. For more details, take a look at the "),la=s(yr,"A",{href:!0});var Mf=n(la);Bi=i(Mf,"LoRA training"),Mf.forEach(t),Gi=i(yr," guide."),yr.forEach(t),Vo=f(e),Ie=s(e,"H2",{class:!0});var Ur=n(Ie);nt=s(Ur,"A",{id:!0,class:!0,href:!0});var wf=n(nt);xa=s(wf,"SPAN",{});var yf=n(xa);y(qt.$$.fragment,yf),yf.forEach(t),wf.forEach(t),Xi=f(Ur),Qa=s(Ur,"SPAN",{});var Uf=n(Qa);Zi=i(Uf,"Saving checkpoints while training"),Uf.forEach(t),Ur.forEach(t),Bo=f(e),aa=s(e,"P",{});var bf=n(aa);ki=i(bf,"It\u2019s easy to overfit while training with Dreambooth, so sometimes it\u2019s useful to save regular checkpoints during the training process. One of the intermediate checkpoints might actually work better than the final model! Pass the following argument to the training script to enable saving checkpoints:"),bf.forEach(t),Go=f(e),y(Ht.$$.fragment,e),Xo=f(e),he=s(e,"P",{});var Gt=n(he);Ci=i(Gt,"This saves the full training state in subfolders of your "),Ya=s(Gt,"CODE",{});var _f=n(Ya);Ai=i(_f,"output_dir"),_f.forEach(t),Si=i(Gt,". Subfolder names begin with the prefix "),za=s(Gt,"CODE",{});var Tf=n(za);Fi=i(Tf,"checkpoint-"),Tf.forEach(t),Wi=i(Gt,", followed by the number of steps performed so far; for example, "),La=s(Gt,"CODE",{});var Jf=n(La);Di=i(Jf,"checkpoint-1500"),Jf.forEach(t),xi=i(Gt," would be a checkpoint saved after 1500 training steps."),Gt.forEach(t),Zo=f(e),Ee=s(e,"H3",{class:!0});var br=n(Ee);rt=s(br,"A",{id:!0,class:!0,href:!0});var vf=n(rt);qa=s(vf,"SPAN",{});var gf=n(qa);y(Pt.$$.fragment,gf),gf.forEach(t),vf.forEach(t),Qi=f(br),Ha=s(br,"SPAN",{});var If=n(Ha);Yi=i(If,"Resume training from a saved checkpoint"),If.forEach(t),br.forEach(t),ko=f(e),Ue=s(e,"P",{});var ga=n(Ue);zi=i(ga,"If you want to resume training from any of the saved checkpoints, you can pass the argument "),Pa=s(ga,"CODE",{});var Ef=n(Pa);Li=i(Ef,"--resume_from_checkpoint"),Ef.forEach(t),qi=i(ga," to the script and specify the name of the checkpoint you want to use. You can also use the special string "),Oa=s(ga,"CODE",{});var jf=n(Oa);Hi=i(jf,'"latest"'),jf.forEach(t),Pi=i(ga," to resume from the last saved checkpoint (the one with the largest number of steps). For example, the following would resume training from the checkpoint saved after 1500 steps:"),ga.forEach(t),Co=f(e),y(Ot.$$.fragment,e),Ao=f(e),sa=s(e,"P",{});var Rf=n(sa);Oi=i(Rf,"This is a good opportunity to tweak some of your hyperparameters if you wish."),Rf.forEach(t),So=f(e),je=s(e,"H3",{class:!0});var _r=n(je);it=s(_r,"A",{id:!0,class:!0,href:!0});var $f=n(it);Ka=s($f,"SPAN",{});var Nf=n(Ka);y(Kt.$$.fragment,Nf),Nf.forEach(t),$f.forEach(t),Ki=f(_r),es=s(_r,"SPAN",{});var Vf=n(es);ep=i(Vf,"Inference from a saved checkpoint"),Vf.forEach(t),_r.forEach(t),Fo=f(e),oa=s(e,"P",{});var Bf=n(oa);tp=i(Bf,"Saved checkpoints are stored in a format suitable for resuming training. They not only include the model weights, but also the state of the optimizer, data loaders, and learning rate."),Bf.forEach(t),Wo=f(e),pt=s(e,"P",{});var Tr=n(pt);lp=i(Tr,"If you have "),ts=s(Tr,"STRONG",{});var Gf=n(ts);ls=s(Gf,"CODE",{});var Xf=n(ls);ap=i(Xf,'"accelerate>=0.16.0"'),Xf.forEach(t),Gf.forEach(t),sp=i(Tr,` installed, use the following code to run
inference from an intermediate checkpoint.`),Tr.forEach(t),Do=f(e),y(el.$$.fragment,e),xo=f(e),ht=s(e,"P",{});var Jr=n(ht);op=i(Jr,"If you have "),as=s(Jr,"STRONG",{});var Zf=n(as);ss=s(Zf,"CODE",{});var kf=n(ss);np=i(kf,'"accelerate<0.16.0"'),kf.forEach(t),Zf.forEach(t),rp=i(Jr," installed, you need to convert it to an inference pipeline first:"),Jr.forEach(t),Qo=f(e),y(tl.$$.fragment,e),Yo=f(e),Re=s(e,"H2",{class:!0});var vr=n(Re);ct=s(vr,"A",{id:!0,class:!0,href:!0});var Cf=n(ct);os=s(Cf,"SPAN",{});var Af=n(os);y(ll.$$.fragment,Af),Af.forEach(t),Cf.forEach(t),ip=f(vr),ns=s(vr,"SPAN",{});var Sf=n(ns);pp=i(Sf,"Optimizations for different GPU sizes"),Sf.forEach(t),vr.forEach(t),zo=f(e),na=s(e,"P",{});var Ff=n(na);hp=i(Ff,"Depending on your hardware, there are a few different ways to optimize DreamBooth on GPUs from 16GB to just 8GB!"),Ff.forEach(t),Lo=f(e),$e=s(e,"H3",{class:!0});var gr=n($e);ft=s(gr,"A",{id:!0,class:!0,href:!0});var Wf=n(ft);rs=s(Wf,"SPAN",{});var Df=n(rs);y(al.$$.fragment,Df),Df.forEach(t),Wf.forEach(t),cp=f(gr),is=s(gr,"SPAN",{});var xf=n(is);fp=i(xf,"xFormers"),xf.forEach(t),gr.forEach(t),qo=f(e),Me=s(e,"P",{});var Ol=n(Me);sl=s(Ol,"A",{href:!0,rel:!0});var Qf=n(sl);up=i(Qf,"xFormers"),Qf.forEach(t),dp=i(Ol," is a toolbox for optimizing Transformers, and it includes a "),ol=s(Ol,"A",{href:!0,rel:!0});var Yf=n(ol);mp=i(Yf,"memory-efficient attention"),Yf.forEach(t),Mp=i(Ol," mechanism that is used in \u{1F9E8} Diffusers. You\u2019ll need to "),ra=s(Ol,"A",{href:!0});var zf=n(ra);wp=i(zf,"install xFormers"),zf.forEach(t),yp=i(Ol," and then add the following argument to your training script:"),Ol.forEach(t),Ho=f(e),y(nl.$$.fragment,e),Po=f(e),ia=s(e,"P",{});var Lf=n(ia);Up=i(Lf,"xFormers is not available in Flax."),Lf.forEach(t),Oo=f(e),Ne=s(e,"H3",{class:!0});var Ir=n(Ne);ut=s(Ir,"A",{id:!0,class:!0,href:!0});var qf=n(ut);ps=s(qf,"SPAN",{});var Hf=n(ps);y(rl.$$.fragment,Hf),Hf.forEach(t),qf.forEach(t),bp=f(Ir),hs=s(Ir,"SPAN",{});var Pf=n(hs);_p=i(Pf,"Set gradients to none"),Pf.forEach(t),Ir.forEach(t),Ko=f(e),ce=s(e,"P",{});var Xt=n(ce);Tp=i(Xt,"Another way you can lower your memory footprint is to "),il=s(Xt,"A",{href:!0,rel:!0});var Of=n(il);Jp=i(Of,"set the gradients"),Of.forEach(t),vp=i(Xt," to "),cs=s(Xt,"CODE",{});var Kf=n(cs);gp=i(Kf,"None"),Kf.forEach(t),Ip=i(Xt," instead of zero. However, this may change certain behaviors, so if you run into any issues, try removing this argument. Add the following argument to your training script to set the gradients to "),fs=s(Xt,"CODE",{});var eu=n(fs);Ep=i(eu,"None"),eu.forEach(t),jp=i(Xt,":"),Xt.forEach(t),en=f(e),y(pl.$$.fragment,e),tn=f(e),Ve=s(e,"H3",{class:!0});var Er=n(Ve);dt=s(Er,"A",{id:!0,class:!0,href:!0});var tu=n(dt);us=s(tu,"SPAN",{});var lu=n(us);y(hl.$$.fragment,lu),lu.forEach(t),tu.forEach(t),Rp=f(Er),ds=s(Er,"SPAN",{});var au=n(ds);$p=i(au,"16GB GPU"),au.forEach(t),Er.forEach(t),ln=f(e),mt=s(e,"P",{});var jr=n(mt);Np=i(jr,"With the help of gradient checkpointing and "),cl=s(jr,"A",{href:!0,rel:!0});var su=n(cl);Vp=i(su,"bitsandbytes"),su.forEach(t),Bp=i(jr," 8-bit optimizer, it\u2019s possible to train DreamBooth on a 16GB GPU. Make sure you have bitsandbytes installed:"),jr.forEach(t),an=f(e),y(fl.$$.fragment,e),sn=f(e),Mt=s(e,"P",{});var Rr=n(Mt);Gp=i(Rr,"Then pass the "),ms=s(Rr,"CODE",{});var ou=n(ms);Xp=i(ou,"--use_8bit_adam"),ou.forEach(t),Zp=i(Rr," option to the training script:"),Rr.forEach(t),on=f(e),y(ul.$$.fragment,e),nn=f(e),Be=s(e,"H3",{class:!0});var $r=n(Be);wt=s($r,"A",{id:!0,class:!0,href:!0});var nu=n(wt);Ms=s(nu,"SPAN",{});var ru=n(Ms);y(dl.$$.fragment,ru),ru.forEach(t),nu.forEach(t),kp=f($r),ws=s($r,"SPAN",{});var iu=n(ws);Cp=i(iu,"12GB GPU"),iu.forEach(t),$r.forEach(t),rn=f(e),yt=s(e,"P",{});var Nr=n(yt);Ap=i(Nr,"To run DreamBooth on a 12GB GPU, you\u2019ll need to enable gradient checkpointing, the 8-bit optimizer, xFormers, and set the gradients to "),ys=s(Nr,"CODE",{});var pu=n(ys);Sp=i(pu,"None"),pu.forEach(t),Fp=i(Nr,":"),Nr.forEach(t),pn=f(e),y(ml.$$.fragment,e),hn=f(e),Ge=s(e,"H3",{class:!0});var Vr=n(Ge);Ut=s(Vr,"A",{id:!0,class:!0,href:!0});var hu=n(Ut);Us=s(hu,"SPAN",{});var cu=n(Us);y(Ml.$$.fragment,cu),cu.forEach(t),hu.forEach(t),Wp=f(Vr),bs=s(Vr,"SPAN",{});var fu=n(bs);Dp=i(fu,"8 GB GPU"),fu.forEach(t),Vr.forEach(t),cn=f(e),bt=s(e,"P",{});var Br=n(bt);xp=i(Br,"For 8GB GPUs, you\u2019ll need the help of "),wl=s(Br,"A",{href:!0,rel:!0});var uu=n(wl);Qp=i(uu,"DeepSpeed"),uu.forEach(t),Yp=i(Br,` to offload some
tensors from the VRAM to either the CPU or NVME, enabling training with less GPU memory.`),Br.forEach(t),fn=f(e),pa=s(e,"P",{});var du=n(pa);zp=i(du,"Run the following command to configure your \u{1F917} Accelerate environment:"),du.forEach(t),un=f(e),y(yl.$$.fragment,e),dn=f(e),_t=s(e,"P",{});var Gr=n(_t);Lp=i(Gr,"During configuration, confirm that you want to use DeepSpeed. Now it\u2019s possible to train on under 8GB VRAM by combining DeepSpeed stage 2, fp16 mixed precision, and offloading the model parameters and the optimizer state to the CPU. The drawback is that this requires more system RAM, about 25 GB. See "),Ul=s(Gr,"A",{href:!0,rel:!0});var mu=n(Ul);qp=i(mu,"the DeepSpeed documentation"),mu.forEach(t),Hp=i(Gr," for more configuration options."),Gr.forEach(t),mn=f(e),be=s(e,"P",{});var Ia=n(be);Pp=i(Ia,`You should also change the default Adam optimizer to DeepSpeed\u2019s optimized version of Adam
`),bl=s(Ia,"A",{href:!0,rel:!0});var Mu=n(bl);_s=s(Mu,"CODE",{});var wu=n(_s);Op=i(wu,"deepspeed.ops.adam.DeepSpeedCPUAdam"),wu.forEach(t),Mu.forEach(t),Kp=i(Ia," for a substantial speedup. Enabling "),Ts=s(Ia,"CODE",{});var yu=n(Ts);eh=i(yu,"DeepSpeedCPUAdam"),yu.forEach(t),th=i(Ia," requires your system\u2019s CUDA toolchain version to be the same as the one installed with PyTorch."),Ia.forEach(t),Mn=f(e),ha=s(e,"P",{});var Uu=n(ha);lh=i(Uu,"8-bit optimizers don\u2019t seem to be compatible with DeepSpeed at the moment."),Uu.forEach(t),wn=f(e),ca=s(e,"P",{});var bu=n(ca);ah=i(bu,"Launch training with the following command:"),bu.forEach(t),yn=f(e),y(_l.$$.fragment,e),Un=f(e),Xe=s(e,"H2",{class:!0});var Xr=n(Xe);Tt=s(Xr,"A",{id:!0,class:!0,href:!0});var _u=n(Tt);Js=s(_u,"SPAN",{});var Tu=n(Js);y(Tl.$$.fragment,Tu),Tu.forEach(t),_u.forEach(t),sh=f(Xr),vs=s(Xr,"SPAN",{});var Ju=n(vs);oh=i(Ju,"Inference"),Ju.forEach(t),Xr.forEach(t),bn=f(e),fe=s(e,"P",{});var Zt=n(fe);nh=i(Zt,"Once you have trained a model, specify the path to where the model is saved, and use it for inference in the "),fa=s(Zt,"A",{href:!0});var vu=n(fa);rh=i(vu,"StableDiffusionPipeline"),vu.forEach(t),ih=i(Zt,". Make sure your prompts include the special "),gs=s(Zt,"CODE",{});var gu=n(gs);ph=i(gu,"identifier"),gu.forEach(t),hh=i(Zt," used during training ("),Is=s(Zt,"CODE",{});var Iu=n(Is);ch=i(Iu,"sks"),Iu.forEach(t),fh=i(Zt," in the previous examples)."),Zt.forEach(t),_n=f(e),Jt=s(e,"P",{});var Zr=n(Jt);uh=i(Zr,"If you have "),Es=s(Zr,"STRONG",{});var Eu=n(Es);js=s(Eu,"CODE",{});var ju=n(js);dh=i(ju,'"accelerate>=0.16.0"'),ju.forEach(t),Eu.forEach(t),mh=i(Zr,` installed, you can use the following code to run
inference from an intermediate checkpoint:`),Zr.forEach(t),Tn=f(e),y(Jl.$$.fragment,e),Jn=f(e),vt=s(e,"P",{});var kr=n(vt);Mh=i(kr,"You may also run inference from any of the "),ua=s(kr,"A",{href:!0});var Ru=n(ua);wh=i(Ru,"saved training checkpoints"),Ru.forEach(t),yh=i(kr,"."),kr.forEach(t),vn=f(e),Ze=s(e,"H2",{class:!0});var Cr=n(Ze);gt=s(Cr,"A",{id:!0,class:!0,href:!0});var $u=n(gt);Rs=s($u,"SPAN",{});var Nu=n(Rs);y(vl.$$.fragment,Nu),Nu.forEach(t),$u.forEach(t),Uh=f(Cr),$s=s(Cr,"SPAN",{});var Vu=n($s);bh=i(Vu,"IF"),Vu.forEach(t),Cr.forEach(t),gn=f(e),_e=s(e,"P",{});var Ea=n(_e);_h=i(Ea,"You can use the lora and full dreambooth scripts to train the text to image "),gl=s(Ea,"A",{href:!0,rel:!0});var Bu=n(gl);Th=i(Bu,"IF model"),Bu.forEach(t),Jh=i(Ea,` and the stage II upscaler
`),Il=s(Ea,"A",{href:!0,rel:!0});var Gu=n(Il);vh=i(Gu,"IF model"),Gu.forEach(t),gh=i(Ea,"."),Ea.forEach(t),In=f(e),da=s(e,"P",{});var Xu=n(da);Ih=i(Xu,`Note that IF has a predicted variance, and our finetuning scripts only train the models predicted error, so for finetuned IF models we switch to a fixed
variance schedule. The full finetuning scripts will update the scheduler config for the full saved model. However, when loading saved LoRA weights, you
must also update the pipeline\u2019s scheduler config.`),Xu.forEach(t),En=f(e),y(El.$$.fragment,e),jn=f(e),ma=s(e,"P",{});var Zu=n(ma);Eh=i(Zu,"Additionally, a few alternative cli flags are needed for IF."),Zu.forEach(t),Rn=f(e),jl=s(e,"P",{});var vc=n(jl);Ns=s(vc,"CODE",{});var ku=n(Ns);jh=i(ku,"--resolution=64"),ku.forEach(t),Rh=i(vc,": IF is a pixel space diffusion model. In order to operate on un-compressed pixels, the input images are of a much smaller resolution."),vc.forEach(t),$n=f(e),ke=s(e,"P",{});var no=n(ke);Vs=s(no,"CODE",{});var Cu=n(Vs);$h=i(Cu,"--pre_compute_text_embeddings"),Cu.forEach(t),Nh=i(no,": IF uses "),Rl=s(no,"A",{href:!0,rel:!0});var Au=n(Rl);Vh=i(Au,"T5"),Au.forEach(t),Bh=i(no,` for its text encoder. In order to save GPU memory, we pre compute all text embeddings and then de-allocate
T5.`),no.forEach(t),Nn=f(e),$l=s(e,"P",{});var gc=n($l);Bs=s(gc,"CODE",{});var Su=n(Bs);Gh=i(Su,"--tokenizer_max_length=77"),Su.forEach(t),Xh=i(gc,": T5 has a longer default text length, but the default IF encoding procedure uses a smaller number."),gc.forEach(t),Vn=f(e),Nl=s(e,"P",{});var Ic=n(Nl);Gs=s(Ic,"CODE",{});var Fu=n(Gs);Zh=i(Fu,"--text_encoder_use_attention_mask"),Fu.forEach(t),kh=i(Ic,": T5 passes the attention mask to the text encoder."),Ic.forEach(t),Bn=f(e),Ce=s(e,"H3",{class:!0});var Ar=n(Ce);It=s(Ar,"A",{id:!0,class:!0,href:!0});var Wu=n(It);Xs=s(Wu,"SPAN",{});var Du=n(Xs);y(Vl.$$.fragment,Du),Du.forEach(t),Wu.forEach(t),Ch=f(Ar),Zs=s(Ar,"SPAN",{});var xu=n(Zs);Ah=i(xu,"Tips and Tricks"),xu.forEach(t),Ar.forEach(t),Gn=i(e,`

We find LoRA to be sufficient for finetuning the stage I model as the low resolution of the model makes representing finegrained detail hard regardless.
`),Ma=s(e,"P",{});var Qu=n(Ma);Sh=i(Qu,`For common and/or not-visually complex object concepts, you can get away with not-finetuning the upscaler. Just be sure to adjust the prompt passed to the
upscaler to remove the new token from the instance prompt. I.e. if your stage I prompt is \u201Ca sks dog\u201D, use \u201Ca dog\u201D for your stage II prompt.`),Qu.forEach(t),Xn=f(e),wa=s(e,"P",{});var Yu=n(wa);Fh=i(Yu,`For finegrained detail like faces that aren\u2019t present in the original training set, we find that full finetuning of the stage II upscaler is better than
LoRA finetuning stage II.`),Yu.forEach(t),Zn=f(e),ya=s(e,"P",{});var zu=n(ya);Wh=i(zu,"For finegrained detail like faces, we find that lower learning rates along with larger batch sizes work best."),zu.forEach(t),kn=f(e),Ua=s(e,"P",{});var Lu=n(Ua);Dh=i(Lu,"For stage II, we find that lower learning rates are also needed."),Lu.forEach(t),Cn=f(e),ba=s(e,"P",{});var qu=n(ba);xh=i(qu,`We found experimentally that the DDPM scheduler with the default larger number of denoising steps to sometimes work better than the DPM Solver scheduler
used in the training scripts.`),qu.forEach(t),An=f(e),Ae=s(e,"H3",{class:!0});var Sr=n(Ae);Et=s(Sr,"A",{id:!0,class:!0,href:!0});var Hu=n(Et);ks=s(Hu,"SPAN",{});var Pu=n(ks);y(Bl.$$.fragment,Pu),Pu.forEach(t),Hu.forEach(t),Qh=f(Sr),Cs=s(Sr,"SPAN",{});var Ou=n(Cs);Yh=i(Ou,"Stage II additional validation images"),Ou.forEach(t),Sr.forEach(t),Sn=f(e),_a=s(e,"P",{});var Ku=n(_a);zh=i(Ku,"The stage II validation requires images to upscale, we can download a downsized version of the training set:"),Ku.forEach(t),Fn=f(e),y(Gl.$$.fragment,e),Wn=f(e),Se=s(e,"H3",{class:!0});var Fr=n(Se);jt=s(Fr,"A",{id:!0,class:!0,href:!0});var ed=n(jt);As=s(ed,"SPAN",{});var td=n(As);y(Xl.$$.fragment,td),td.forEach(t),ed.forEach(t),Lh=f(Fr),Ss=s(Fr,"SPAN",{});var ld=n(Ss);qh=i(ld,"IF stage I LoRA Dreambooth"),ld.forEach(t),Fr.forEach(t),Dn=i(e,`

This training configuration requires ~28 GB VRAM.

	`),y(Zl.$$.fragment,e),xn=f(e),Fe=s(e,"H3",{class:!0});var Wr=n(Fe);Rt=s(Wr,"A",{id:!0,class:!0,href:!0});var ad=n(Rt);Fs=s(ad,"SPAN",{});var sd=n(Fs);y(kl.$$.fragment,sd),sd.forEach(t),ad.forEach(t),Hh=f(Wr),Ws=s(Wr,"SPAN",{});var od=n(Ws);Ph=i(od,"IF stage II LoRA Dreambooth"),od.forEach(t),Wr.forEach(t),Qn=f(e),Cl=s(e,"P",{});var Ec=n(Cl);Ds=s(Ec,"CODE",{});var nd=n(Ds);Oh=i(nd,"--validation_images"),nd.forEach(t),Kh=i(Ec,": These images are upscaled during validation steps."),Ec.forEach(t),Yn=f(e),Al=s(e,"P",{});var jc=n(Al);xs=s(jc,"CODE",{});var rd=n(xs);ec=i(rd,"--class_labels_conditioning=timesteps"),rd.forEach(t),tc=i(jc,": Pass additional conditioning to the UNet needed for stage II."),jc.forEach(t),zn=f(e),Sl=s(e,"P",{});var Rc=n(Sl);Qs=s(Rc,"CODE",{});var id=n(Qs);lc=i(id,"--learning_rate=1e-6"),id.forEach(t),ac=i(Rc,": Lower learning rate than stage I."),Rc.forEach(t),Ln=f(e),Fl=s(e,"P",{});var $c=n(Fl);Ys=s($c,"CODE",{});var pd=n(Ys);sc=i(pd,"--resolution=256"),pd.forEach(t),oc=i($c,": The upscaler expects higher resolution inputs"),$c.forEach(t),qn=f(e),y(Wl.$$.fragment,e),Hn=f(e),We=s(e,"H3",{class:!0});var Dr=n(We);$t=s(Dr,"A",{id:!0,class:!0,href:!0});var hd=n($t);zs=s(hd,"SPAN",{});var cd=n(zs);y(Dl.$$.fragment,cd),cd.forEach(t),hd.forEach(t),nc=f(Dr),Ls=s(Dr,"SPAN",{});var fd=n(Ls);rc=i(fd,"IF Stage I Full Dreambooth"),fd.forEach(t),Dr.forEach(t),Pn=i(e,`

\`--skip_save_text_encoder\`: When training the full model, this will skip saving the entire T5 with the finetuned model. You can still load the pipeline
with a T5 loaded from the original model.
`),xl=s(e,"P",{});var Nc=n(xl);qs=s(Nc,"CODE",{});var ud=n(qs);ic=i(ud,"use_8bit_adam"),ud.forEach(t),pc=i(Nc,": Due to the size of the optimizer states, we recommend training the full XL IF model with 8bit adam."),Nc.forEach(t),On=f(e),Ql=s(e,"P",{});var Vc=n(Ql);Hs=s(Vc,"CODE",{});var dd=n(Hs);hc=i(dd,"--learning_rate=1e-7"),dd.forEach(t),cc=i(Vc,`: For full dreambooth, IF requires very low learning rates. With higher learning rates model quality will degrade. Note that it is
likely the learning rate can be increased with larger batch sizes.`),Vc.forEach(t),Kn=f(e),Ta=s(e,"P",{});var md=n(Ta);fc=i(md,"Using 8bit adam and a batch size of 4, the model can be trained in ~48 GB VRAM."),md.forEach(t),er=f(e),y(Yl.$$.fragment,e),tr=f(e),De=s(e,"H3",{class:!0});var xr=n(De);Nt=s(xr,"A",{id:!0,class:!0,href:!0});var Md=n(Nt);Ps=s(Md,"SPAN",{});var wd=n(Ps);y(zl.$$.fragment,wd),wd.forEach(t),Md.forEach(t),uc=f(xr),Os=s(xr,"SPAN",{});var yd=n(Os);dc=i(yd,"IF Stage II Full Dreambooth"),yd.forEach(t),xr.forEach(t),lr=f(e),Ll=s(e,"P",{});var Bc=n(Ll);Ks=s(Bc,"CODE",{});var Ud=n(Ks);mc=i(Ud,"--learning_rate=5e-6"),Ud.forEach(t),Mc=i(Bc,`: With a smaller effective batch size of 4, we found that we required learning rates as low as
1e-8.`),Bc.forEach(t),ar=f(e),ql=s(e,"P",{});var Gc=n(ql);eo=s(Gc,"CODE",{});var bd=n(eo);wc=i(bd,"--resolution=256"),bd.forEach(t),yc=i(Gc,": The upscaler expects higher resolution inputs"),Gc.forEach(t),sr=f(e),xe=s(e,"P",{});var ro=n(xe);to=s(ro,"CODE",{});var _d=n(to);Uc=i(_d,"--train_batch_size=2"),_d.forEach(t),bc=i(ro," and "),lo=s(ro,"CODE",{});var Td=n(lo);_c=i(Td,"--gradient_accumulation_steps=6"),Td.forEach(t),Tc=i(ro,`: We found that full training of stage II particularly with
faces required large effective batch sizes.`),ro.forEach(t),or=f(e),y(Hl.$$.fragment,e),this.h()},h(){u(d,"name","hf:doc:metadata"),u(d,"content",JSON.stringify(Qd)),u(J,"id","dreambooth"),u(J,"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"),u(J,"href","#dreambooth"),u(h,"class","relative group"),u(j,"href","https://arxiv.org/abs/2208.12242"),u(j,"rel","nofollow"),jd(F.src,oe="https://dreambooth.github.io/DreamBooth_files/teaser_static.jpg")||u(F,"src",oe),u(F,"alt","Dreambooth examples from the project's blog"),u(z,"href","https://dreambooth.github.io"),u(B,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),u(B,"rel","nofollow"),u(D,"href","https://github.com/huggingface/diffusers/tree/main/examples/dreambooth"),u(D,"rel","nofollow"),u(re,"href","../optimization/xformers"),u(kt,"href","https://github.com/huggingface/accelerate/"),u(kt,"rel","nofollow"),u(Ft,"href","https://huggingface.co/datasets/diffusers/dog-example"),u(Ft,"rel","nofollow"),u(ta,"href","create_dataset"),u(Le,"id","finetuning"),u(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"),u(Le,"href","#finetuning"),u(Te,"class","relative group"),u(Pe,"id","finetuning-with-priorpreserving-loss"),u(Pe,"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"),u(Pe,"href","#finetuning-with-priorpreserving-loss"),u(Je,"class","relative group"),u(Qt,"href","https://arxiv.org/abs/2208.12242"),u(Qt,"rel","nofollow"),u(tt,"id","finetuning-the-text-encoder-and-unet"),u(tt,"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"),u(tt,"href","#finetuning-the-text-encoder-and-unet"),u(ve,"class","relative group"),u(zt,"href","https://huggingface.co/blog/dreambooth"),u(zt,"rel","nofollow"),u(st,"id","finetuning-with-lora"),u(st,"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"),u(st,"href","#finetuning-with-lora"),u(ge,"class","relative group"),u(la,"href","./lora#dreambooth"),u(nt,"id","saving-checkpoints-while-training"),u(nt,"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"),u(nt,"href","#saving-checkpoints-while-training"),u(Ie,"class","relative group"),u(rt,"id","resume-training-from-a-saved-checkpoint"),u(rt,"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"),u(rt,"href","#resume-training-from-a-saved-checkpoint"),u(Ee,"class","relative group"),u(it,"id","inference-from-a-saved-checkpoint"),u(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"),u(it,"href","#inference-from-a-saved-checkpoint"),u(je,"class","relative group"),u(ct,"id","optimizations-for-different-gpu-sizes"),u(ct,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(ct,"href","#optimizations-for-different-gpu-sizes"),u(Re,"class","relative group"),u(ft,"id","xformers"),u(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"),u(ft,"href","#xformers"),u($e,"class","relative group"),u(sl,"href","https://github.com/facebookresearch/xformers"),u(sl,"rel","nofollow"),u(ol,"href","https://facebookresearch.github.io/xformers/components/ops.html#module-xformers.ops"),u(ol,"rel","nofollow"),u(ra,"href","./optimization/xformers"),u(ut,"id","set-gradients-to-none"),u(ut,"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"),u(ut,"href","#set-gradients-to-none"),u(Ne,"class","relative group"),u(il,"href","https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html"),u(il,"rel","nofollow"),u(dt,"id","16gb-gpu"),u(dt,"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"),u(dt,"href","#16gb-gpu"),u(Ve,"class","relative group"),u(cl,"href","https://github.com/TimDettmers/bitsandbytes"),u(cl,"rel","nofollow"),u(wt,"id","12gb-gpu"),u(wt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(wt,"href","#12gb-gpu"),u(Be,"class","relative group"),u(Ut,"id","8-gb-gpu"),u(Ut,"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"),u(Ut,"href","#8-gb-gpu"),u(Ge,"class","relative group"),u(wl,"href","https://www.deepspeed.ai/"),u(wl,"rel","nofollow"),u(Ul,"href","https://huggingface.co/docs/accelerate/usage_guides/deepspeed"),u(Ul,"rel","nofollow"),u(bl,"href","https://deepspeed.readthedocs.io/en/latest/optimizers.html#adam-cpu"),u(bl,"rel","nofollow"),u(Tt,"id","inference"),u(Tt,"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"),u(Tt,"href","#inference"),u(Xe,"class","relative group"),u(fa,"href","/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),u(ua,"href","#inference-from-a-saved-checkpoint"),u(gt,"id","if"),u(gt,"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"),u(gt,"href","#if"),u(Ze,"class","relative group"),u(gl,"href","https://huggingface.co/DeepFloyd/IF-I-XL-v1.0"),u(gl,"rel","nofollow"),u(Il,"href","https://huggingface.co/DeepFloyd/IF-II-L-v1.0"),u(Il,"rel","nofollow"),u(Rl,"href","https://huggingface.co/docs/transformers/model_doc/t5"),u(Rl,"rel","nofollow"),u(It,"id","tips-and-tricks"),u(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"),u(It,"href","#tips-and-tricks"),u(Ce,"class","relative group"),u(Et,"id","stage-ii-additional-validation-images"),u(Et,"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"),u(Et,"href","#stage-ii-additional-validation-images"),u(Ae,"class","relative group"),u(jt,"id","if-stage-i-lora-dreambooth"),u(jt,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u(jt,"href","#if-stage-i-lora-dreambooth"),u(Se,"class","relative group"),u(Rt,"id","if-stage-ii-lora-dreambooth"),u(Rt,"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"),u(Rt,"href","#if-stage-ii-lora-dreambooth"),u(Fe,"class","relative group"),u($t,"id","if-stage-i-full-dreambooth"),u($t,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),u($t,"href","#if-stage-i-full-dreambooth"),u(We,"class","relative group"),u(Nt,"id","if-stage-ii-full-dreambooth"),u(Nt,"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"),u(Nt,"href","#if-stage-ii-full-dreambooth"),u(De,"class","relative group")},m(e,o){l(document.head,d),p(e,M,o),p(e,h,o),l(h,J),l(J,v),U($,v,null),l(h,I),l(h,C),l(C,x),p(e,A,o),p(e,S,o),l(S,j),l(j,ue),l(S,O),p(e,Q,o),p(e,Y,o),l(Y,F),p(e,ne,o),p(e,k,o),l(k,K),l(k,z),l(z,ee),p(e,te,o),p(e,N,o),l(N,L),l(N,B),l(B,le),l(le,W),l(N,q),l(N,D),l(D,ae),l(N,G),p(e,H,o),p(e,m,o),l(m,g),l(m,de),l(de,X),l(m,Z),p(e,we,o),U(se,e,o),p(e,ye,o),p(e,P,o),l(P,me),l(P,re),l(re,Qr),l(P,Yr),p(e,io,o),p(e,Qe,o),l(Qe,zr),l(Qe,kt),l(kt,Lr),l(Qe,qr),p(e,po,o),U(Ct,e,o),p(e,ho,o),p(e,Kl,o),l(Kl,Hr),p(e,co,o),U(At,e,o),p(e,fo,o),p(e,ea,o),l(ea,Pr),p(e,uo,o),U(St,e,o),p(e,mo,o),p(e,Ye,o),l(Ye,Or),l(Ye,Ft),l(Ft,Kr),l(Ye,ei),p(e,Mo,o),U(Wt,e,o),p(e,wo,o),p(e,ze,o),l(ze,ti),l(ze,ta),l(ta,li),l(ze,ai),p(e,yo,o),p(e,Te,o),l(Te,Le),l(Le,$a),U(Dt,$a,null),l(Te,si),l(Te,Na),l(Na,oi),p(e,Uo,o),U(qe,e,o),p(e,bo,o),U(He,e,o),p(e,_o,o),p(e,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(e,Ao,o),p(e,sa,o),l(sa,Oi),p(e,So,o),p(e,je,o),l(je,it),l(it,Ka),U(Kt,Ka,null),l(je,Ki),l(je,es),l(es,ep),p(e,Fo,o),p(e,oa,o),l(oa,tp),p(e,Wo,o),p(e,pt,o),l(pt,lp),l(pt,ts),l(ts,ls),l(ls,ap),l(pt,sp),p(e,Do,o),U(el,e,o),p(e,xo,o),p(e,ht,o),l(ht,op),l(ht,as),l(as,ss),l(ss,np),l(ht,rp),p(e,Qo,o),U(tl,e,o),p(e,Yo,o),p(e,Re,o),l(Re,ct),l(ct,os),U(ll,os,null),l(Re,ip),l(Re,ns),l(ns,pp),p(e,zo,o),p(e,na,o),l(na,hp),p(e,Lo,o),p(e,$e,o),l($e,ft),l(ft,rs),U(al,rs,null),l($e,cp),l($e,is),l(is,fp),p(e,qo,o),p(e,Me,o),l(Me,sl),l(sl,up),l(Me,dp),l(Me,ol),l(ol,mp),l(Me,Mp),l(Me,ra),l(ra,wp),l(Me,yp),p(e,Ho,o),U(nl,e,o),p(e,Po,o),p(e,ia,o),l(ia,Up),p(e,Oo,o),p(e,Ne,o),l(Ne,ut),l(ut,ps),U(rl,ps,null),l(Ne,bp),l(Ne,hs),l(hs,_p),p(e,Ko,o),p(e,ce,o),l(ce,Tp),l(ce,il),l(il,Jp),l(ce,vp),l(ce,cs),l(cs,gp),l(ce,Ip),l(ce,fs),l(fs,Ep),l(ce,jp),p(e,en,o),U(pl,e,o),p(e,tn,o),p(e,Ve,o),l(Ve,dt),l(dt,us),U(hl,us,null),l(Ve,Rp),l(Ve,ds),l(ds,$p),p(e,ln,o),p(e,mt,o),l(mt,Np),l(mt,cl),l(cl,Vp),l(mt,Bp),p(e,an,o),U(fl,e,o),p(e,sn,o),p(e,Mt,o),l(Mt,Gp),l(Mt,ms),l(ms,Xp),l(Mt,Zp),p(e,on,o),U(ul,e,o),p(e,nn,o),p(e,Be,o),l(Be,wt),l(wt,Ms),U(dl,Ms,null),l(Be,kp),l(Be,ws),l(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(Hs,hc),l(Ql,cc),p(e,Kn,o),p(e,Ta,o),l(Ta,fc),p(e,er,o),U(Yl,e,o),p(e,tr,o),p(e,De,o),l(De,Nt),l(Nt,Ps),U(zl,Ps,null),l(De,uc),l(De,Os),l(Os,dc),p(e,lr,o),p(e,Ll,o),l(Ll,Ks),l(Ks,mc),l(Ll,Mc),p(e,ar,o),p(e,ql,o),l(ql,eo),l(eo,wc),l(ql,yc),p(e,sr,o),p(e,xe,o),l(xe,to),l(to,Uc),l(xe,bc),l(xe,lo),l(lo,_c),l(xe,Tc),p(e,or,o),U(Hl,e,o),nr=!0},p(e,[o]){const Pl={};o&2&&(Pl.$$scope={dirty:o,ctx:e}),qe.$set(Pl);const ao={};o&2&&(ao.$$scope={dirty:o,ctx:e}),He.$set(ao);const so={};o&2&&(so.$$scope={dirty:o,ctx:e}),et.$set(so);const oo={};o&2&&(oo.$$scope={dirty:o,ctx:e}),lt.$set(oo);const Ja={};o&2&&(Ja.$$scope={dirty:o,ctx:e}),at.$set(Ja)},i(e){nr||(b($.$$.fragment,e),b(se.$$.fragment,e),b(Ct.$$.fragment,e),b(At.$$.fragment,e),b(St.$$.fragment,e),b(Wt.$$.fragment,e),b(Dt.$$.fragment,e),b(qe.$$.fragment,e),b(He.$$.fragment,e),b(xt.$$.fragment,e),b(et.$$.fragment,e),b(Yt.$$.fragment,e),b(lt.$$.fragment,e),b(at.$$.fragment,e),b(Lt.$$.fragment,e),b(qt.$$.fragment,e),b(Ht.$$.fragment,e),b(Pt.$$.fragment,e),b(Ot.$$.fragment,e),b(Kt.$$.fragment,e),b(el.$$.fragment,e),b(tl.$$.fragment,e),b(ll.$$.fragment,e),b(al.$$.fragment,e),b(nl.$$.fragment,e),b(rl.$$.fragment,e),b(pl.$$.fragment,e),b(hl.$$.fragment,e),b(fl.$$.fragment,e),b(ul.$$.fragment,e),b(dl.$$.fragment,e),b(ml.$$.fragment,e),b(Ml.$$.fragment,e),b(yl.$$.fragment,e),b(_l.$$.fragment,e),b(Tl.$$.fragment,e),b(Jl.$$.fragment,e),b(vl.$$.fragment,e),b(El.$$.fragment,e),b(Vl.$$.fragment,e),b(Bl.$$.fragment,e),b(Gl.$$.fragment,e),b(Xl.$$.fragment,e),b(Zl.$$.fragment,e),b(kl.$$.fragment,e),b(Wl.$$.fragment,e),b(Dl.$$.fragment,e),b(Yl.$$.fragment,e),b(zl.$$.fragment,e),b(Hl.$$.fragment,e),nr=!0)},o(e){_($.$$.fragment,e),_(se.$$.fragment,e),_(Ct.$$.fragment,e),_(At.$$.fragment,e),_(St.$$.fragment,e),_(Wt.$$.fragment,e),_(Dt.$$.fragment,e),_(qe.$$.fragment,e),_(He.$$.fragment,e),_(xt.$$.fragment,e),_(et.$$.fragment,e),_(Yt.$$.fragment,e),_(lt.$$.fragment,e),_(at.$$.fragment,e),_(Lt.$$.fragment,e),_(qt.$$.fragment,e),_(Ht.$$.fragment,e),_(Pt.$$.fragment,e),_(Ot.$$.fragment,e),_(Kt.$$.fragment,e),_(el.$$.fragment,e),_(tl.$$.fragment,e),_(ll.$$.fragment,e),_(al.$$.fragment,e),_(nl.$$.fragment,e),_(rl.$$.fragment,e),_(pl.$$.fragment,e),_(hl.$$.fragment,e),_(fl.$$.fragment,e),_(ul.$$.fragment,e),_(dl.$$.fragment,e),_(ml.$$.fragment,e),_(Ml.$$.fragment,e),_(yl.$$.fragment,e),_(_l.$$.fragment,e),_(Tl.$$.fragment,e),_(Jl.$$.fragment,e),_(vl.$$.fragment,e),_(El.$$.fragment,e),_(Vl.$$.fragment,e),_(Bl.$$.fragment,e),_(Gl.$$.fragment,e),_(Xl.$$.fragment,e),_(Zl.$$.fragment,e),_(kl.$$.fragment,e),_(Wl.$$.fragment,e),_(Dl.$$.fragment,e),_(Yl.$$.fragment,e),_(zl.$$.fragment,e),_(Hl.$$.fragment,e),nr=!1},d(e){t(d),e&&t(M),e&&t(h),T($),e&&t(A),e&&t(S),e&&t(Q),e&&t(Y),e&&t(ne),e&&t(k),e&&t(te),e&&t(N),e&&t(H),e&&t(m),e&&t(we),T(se,e),e&&t(ye),e&&t(P),e&&t(io),e&&t(Qe),e&&t(po),T(Ct,e),e&&t(ho),e&&t(Kl),e&&t(co),T(At,e),e&&t(fo),e&&t(ea),e&&t(uo),T(St,e),e&&t(mo),e&&t(Ye),e&&t(Mo),T(Wt,e),e&&t(wo),e&&t(ze),e&&t(yo),e&&t(Te),T(Dt),e&&t(Uo),T(qe,e),e&&t(bo),T(He,e),e&&t(_o),e&&t(Je),T(xt),e&&t(To),e&&t(Oe),e&&t(Jo),e&&t(Ke),e&&t(vo),T(et,e),e&&t(go),e&&t(ve),T(Yt),e&&t(Io),e&&t(ie),e&&t(Eo),T(lt,e),e&&t(jo),e&&t(pe),e&&t(Ro),T(at,e),e&&t($o),e&&t(ge),T(Lt),e&&t(No),e&&t(ot),e&&t(Vo),e&&t(Ie),T(qt),e&&t(Bo),e&&t(aa),e&&t(Go),T(Ht,e),e&&t(Xo),e&&t(he),e&&t(Zo),e&&t(Ee),T(Pt),e&&t(ko),e&&t(Ue),e&&t(Co),T(Ot,e),e&&t(Ao),e&&t(sa),e&&t(So),e&&t(je),T(Kt),e&&t(Fo),e&&t(oa),e&&t(Wo),e&&t(pt),e&&t(Do),T(el,e),e&&t(xo),e&&t(ht),e&&t(Qo),T(tl,e),e&&t(Yo),e&&t(Re),T(ll),e&&t(zo),e&&t(na),e&&t(Lo),e&&t($e),T(al),e&&t(qo),e&&t(Me),e&&t(Ho),T(nl,e),e&&t(Po),e&&t(ia),e&&t(Oo),e&&t(Ne),T(rl),e&&t(Ko),e&&t(ce),e&&t(en),T(pl,e),e&&t(tn),e&&t(Ve),T(hl),e&&t(ln),e&&t(mt),e&&t(an),T(fl,e),e&&t(sn),e&&t(Mt),e&&t(on),T(ul,e),e&&t(nn),e&&t(Be),T(dl),e&&t(rn),e&&t(yt),e&&t(pn),T(ml,e),e&&t(hn),e&&t(Ge),T(Ml),e&&t(cn),e&&t(bt),e&&t(fn),e&&t(pa),e&&t(un),T(yl,e),e&&t(dn),e&&t(_t),e&&t(mn),e&&t(be),e&&t(Mn),e&&t(ha),e&&t(wn),e&&t(ca),e&&t(yn),T(_l,e),e&&t(Un),e&&t(Xe),T(Tl),e&&t(bn),e&&t(fe),e&&t(_n),e&&t(Jt),e&&t(Tn),T(Jl,e),e&&t(Jn),e&&t(vt),e&&t(vn),e&&t(Ze),T(vl),e&&t(gn),e&&t(_e),e&&t(In),e&&t(da),e&&t(En),T(El,e),e&&t(jn),e&&t(ma),e&&t(Rn),e&&t(jl),e&&t($n),e&&t(ke),e&&t(Nn),e&&t($l),e&&t(Vn),e&&t(Nl),e&&t(Bn),e&&t(Ce),T(Vl),e&&t(Gn),e&&t(Ma),e&&t(Xn),e&&t(wa),e&&t(Zn),e&&t(ya),e&&t(kn),e&&t(Ua),e&&t(Cn),e&&t(ba),e&&t(An),e&&t(Ae),T(Bl),e&&t(Sn),e&&t(_a),e&&t(Fn),T(Gl,e),e&&t(Wn),e&&t(Se),T(Xl),e&&t(Dn),T(Zl,e),e&&t(xn),e&&t(Fe),T(kl),e&&t(Qn),e&&t(Cl),e&&t(Yn),e&&t(Al),e&&t(zn),e&&t(Sl),e&&t(Ln),e&&t(Fl),e&&t(qn),T(Wl,e),e&&t(Hn),e&&t(We),T(Dl),e&&t(Pn),e&&t(xl),e&&t(On),e&&t(Ql),e&&t(Kn),e&&t(Ta),e&&t(er),T(Yl,e),e&&t(tr),e&&t(De),T(zl),e&&t(lr),e&&t(Ll),e&&t(ar),e&&t(ql),e&&t(sr),e&&t(xe),e&&t(or),T(Hl,e)}}}const Qd={local:"dreambooth",sections:[{local:"finetuning",title:"Finetuning"},{local:"finetuning-with-priorpreserving-loss",title:"Finetuning with prior-preserving loss"},{local:"finetuning-the-text-encoder-and-unet",title:"Finetuning the text encoder and UNet"},{local:"finetuning-with-lora",title:"Finetuning with LoRA"},{local:"saving-checkpoints-while-training",sections:[{local:"resume-training-from-a-saved-checkpoint",title:"Resume training from a saved checkpoint"},{local:"inference-from-a-saved-checkpoint",title:"Inference from a saved checkpoint"}],title:"Saving checkpoints while training"},{local:"optimizations-for-different-gpu-sizes",sections:[{local:"xformers",title:"xFormers"},{local:"set-gradients-to-none",title:"Set gradients to none"},{local:"16gb-gpu",title:"16GB GPU"},{local:"12gb-gpu",title:"12GB GPU"},{local:"8-gb-gpu",title:"8 GB GPU"}],title:"Optimizations for different GPU sizes"},{local:"inference",title:"Inference"},{local:"if",sections:[{local:"tips-and-tricks",title:"Tips and Tricks"},{local:"stage-ii-additional-validation-images",title:"Stage II additional validation images"},{local:"if-stage-i-lora-dreambooth",title:"IF stage I LoRA Dreambooth"},{local:"if-stage-ii-lora-dreambooth",title:"IF stage II LoRA Dreambooth"},{local:"if-stage-i-full-dreambooth",title:"IF Stage I Full Dreambooth"},{local:"if-stage-ii-full-dreambooth",title:"IF Stage II Full Dreambooth"}],title:"IF"}],title:"DreamBooth"};function Yd(R){return Rd(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Od extends vd{constructor(d){super();gd(this,d,Yd,xd,Id,{})}}export{Od as default,Qd as metadata};
