import{s as Ca,o as Ia,n as v}from"../chunks/scheduler.8c3d61f6.js";import{S as va,i as Ga,g as u,s as p,r as y,A as Xa,h as M,f as a,c as m,j as Za,u as w,x as h,k as Ra,y as Va,a as s,v as b,d as J,t as U,w as T}from"../chunks/index.589a98e8.js";import{T as Gl}from"../chunks/Tip.42aa8582.js";import{C}from"../chunks/CodeBlock.36627b28.js";import{H as W,E as Ba}from"../chunks/EditOnGithub.e5a8d9cb.js";import{H as pt,a as X}from"../chunks/HfOption.9804ab8b.js";function Wa($){let t,f;return t=new C({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/dreambooth
pip install -r requirements.txt`,wrap:!1}}),{c(){y(t.$$.fragment)},l(n){w(t.$$.fragment,n)},m(n,r){b(t,n,r),f=!0},p:v,i(n){f||(J(t.$$.fragment,n),f=!0)},o(n){U(t.$$.fragment,n),f=!1},d(n){T(t,n)}}}function xa($){let t,f;return t=new C({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/dreambooth
pip install -r requirements_flax.txt`,wrap:!1}}),{c(){y(t.$$.fragment)},l(n){w(t.$$.fragment,n)},m(n,r){b(t,n,r),f=!0},p:v,i(n){f||(J(t.$$.fragment,n),f=!0)},o(n){U(t.$$.fragment,n),f=!1},d(n){T(t,n)}}}function Na($){let t,f,n,r;return t=new X({props:{id:"installation",option:"PyTorch",$$slots:{default:[Wa]},$$scope:{ctx:$}}}),n=new X({props:{id:"installation",option:"Flax",$$slots:{default:[xa]},$$scope:{ctx:$}}}),{c(){y(t.$$.fragment),f=p(),y(n.$$.fragment)},l(i){w(t.$$.fragment,i),f=m(i),w(n.$$.fragment,i)},m(i,o){b(t,i,o),s(i,f,o),b(n,i,o),r=!0},p(i,o){const c={};o&2&&(c.$$scope={dirty:o,ctx:i}),t.$set(c);const _={};o&2&&(_.$$scope={dirty:o,ctx:i}),n.$set(_)},i(i){r||(J(t.$$.fragment,i),J(n.$$.fragment,i),r=!0)},o(i){U(t.$$.fragment,i),U(n.$$.fragment,i),r=!1},d(i){i&&a(f),T(t,i),T(n,i)}}}function ka($){let t,f='🤗 Accelerate is a library for helping you train on multiple GPUs/TPUs or with mixed-precision. It’ll automatically configure your training setup based on your hardware and environment. Take a look at the 🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">Quick tour</a> to learn more.';return{c(){t=u("p"),t.innerHTML=f},l(n){t=M(n,"P",{"data-svelte-h":!0}),h(t)!=="svelte-1qbiqsn"&&(t.innerHTML=f)},m(n,r){s(n,t,r)},p:v,d(n){n&&a(t)}}}function Fa($){let t,f='The following sections highlight parts of the training script that are important for understanding how to modify it, but it doesn’t cover every aspect of the script in detail. If you’re interested in learning more, feel free to read through the <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">script</a> and let us know if you have any questions or concerns.';return{c(){t=u("p"),t.innerHTML=f},l(n){t=M(n,"P",{"data-svelte-h":!0}),h(t)!=="svelte-ag3huc"&&(t.innerHTML=f)},m(n,r){s(n,t,r)},p:v,d(n){n&&a(t)}}}function Ea($){let t,f='DreamBooth is very sensitive to training hyperparameters, and it is easy to overfit. Read the <a href="https://huggingface.co/blog/dreambooth" rel="nofollow">Training Stable Diffusion with Dreambooth using 🧨 Diffusers</a> blog post for recommended settings for different subjects to help you choose the appropriate hyperparameters.';return{c(){t=u("p"),t.innerHTML=f},l(n){t=M(n,"P",{"data-svelte-h":!0}),h(t)!=="svelte-1gadrly"&&(t.innerHTML=f)},m(n,r){s(n,t,r)},p:v,d(n){n&&a(t)}}}function Ya($){let t,f="On a 16GB GPU, you can use bitsandbytes 8-bit optimizer and gradient checkpointing to help you train a DreamBooth model. Install bitsandbytes:",n,r,i,o,c="Then, add the following parameter to your training command:",_,d,g;return r=new C({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcw==",highlighted:"pip install bitsandbytes",wrap:!1}}),d=new C({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUM=",highlighted:`accelerate launch train_dreambooth.py \\
  --gradient_checkpointing \\
  --use_8bit_adam \\`,wrap:!1}}),{c(){t=u("p"),t.textContent=f,n=p(),y(r.$$.fragment),i=p(),o=u("p"),o.textContent=c,_=p(),y(d.$$.fragment)},l(Z){t=M(Z,"P",{"data-svelte-h":!0}),h(t)!=="svelte-fd1675"&&(t.textContent=f),n=m(Z),w(r.$$.fragment,Z),i=m(Z),o=M(Z,"P",{"data-svelte-h":!0}),h(o)!=="svelte-1rkm1uq"&&(o.textContent=c),_=m(Z),w(d.$$.fragment,Z)},m(Z,j){s(Z,t,j),s(Z,n,j),b(r,Z,j),s(Z,i,j),s(Z,o,j),s(Z,_,j),b(d,Z,j),g=!0},p:v,i(Z){g||(J(r.$$.fragment,Z),J(d.$$.fragment,Z),g=!0)},o(Z){U(r.$$.fragment,Z),U(d.$$.fragment,Z),g=!1},d(Z){Z&&(a(t),a(n),a(i),a(o),a(_)),T(r,Z),T(d,Z)}}}function Aa($){let t,f="On a 12GB GPU, you’ll need bitsandbytes 8-bit optimizer, gradient checkpointing, xFormers, and set the gradients to <code>None</code> instead of zero to reduce your memory-usage.",n,r,i;return r=new C({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAtLWVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbiUyMCU1QyUwQSUyMCUyMC0tc2V0X2dyYWRzX3RvX25vbmUlMjAlNUM=",highlighted:`accelerate launch train_dreambooth.py \\
  --use_8bit_adam \\
  --gradient_checkpointing \\
  --enable_xformers_memory_efficient_attention \\
  --set_grads_to_none \\`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=f,n=p(),y(r.$$.fragment)},l(o){t=M(o,"P",{"data-svelte-h":!0}),h(t)!=="svelte-13zq302"&&(t.innerHTML=f),n=m(o),w(r.$$.fragment,o)},m(o,c){s(o,t,c),s(o,n,c),b(r,o,c),i=!0},p:v,i(o){i||(J(r.$$.fragment,o),i=!0)},o(o){U(r.$$.fragment,o),i=!1},d(o){o&&(a(t),a(n)),T(r,o)}}}function za($){let t,f='On a 8GB GPU, you’ll need <a href="https://www.deepspeed.ai/" rel="nofollow">DeepSpeed</a> to offload some of the tensors from the vRAM to either the CPU or NVME to allow training with less GPU memory.',n,r,i="Run the following command to configure your 🤗 Accelerate environment:",o,c,_,d,g='During configuration, confirm that you want to use DeepSpeed. Now it should be 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 (~25 GB). See the <a href="https://huggingface.co/docs/accelerate/usage_guides/deepspeed" rel="nofollow">DeepSpeed documentation</a> for more configuration options.',Z,j,I='You should also change the default Adam optimizer to DeepSpeed’s optimized version of Adam <a href="https://deepspeed.readthedocs.io/en/latest/optimizers.html#adam-cpu" rel="nofollow"><code>deepspeed.ops.adam.DeepSpeedCPUAdam</code></a> for a substantial speedup. Enabling <code>DeepSpeedCPUAdam</code> requires your system’s CUDA toolchain version to be the same as the one installed with PyTorch.',x,V,N="bitsandbytes 8-bit optimizers don’t seem to be compatible with DeepSpeed at the moment.",q,B,k="That’s it! You don’t need to add any additional parameters to your training command.",F;return c=new C({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),{c(){t=u("p"),t.innerHTML=f,n=p(),r=u("p"),r.textContent=i,o=p(),y(c.$$.fragment),_=p(),d=u("p"),d.innerHTML=g,Z=p(),j=u("p"),j.innerHTML=I,x=p(),V=u("p"),V.textContent=N,q=p(),B=u("p"),B.textContent=k},l(R){t=M(R,"P",{"data-svelte-h":!0}),h(t)!=="svelte-5k52bm"&&(t.innerHTML=f),n=m(R),r=M(R,"P",{"data-svelte-h":!0}),h(r)!=="svelte-1fx999v"&&(r.textContent=i),o=m(R),w(c.$$.fragment,R),_=m(R),d=M(R,"P",{"data-svelte-h":!0}),h(d)!=="svelte-wvaz2k"&&(d.innerHTML=g),Z=m(R),j=M(R,"P",{"data-svelte-h":!0}),h(j)!=="svelte-14m6rf5"&&(j.innerHTML=I),x=m(R),V=M(R,"P",{"data-svelte-h":!0}),h(V)!=="svelte-z8cdsf"&&(V.textContent=N),q=m(R),B=M(R,"P",{"data-svelte-h":!0}),h(B)!=="svelte-lwtx0u"&&(B.textContent=k)},m(R,G){s(R,t,G),s(R,n,G),s(R,r,G),s(R,o,G),b(c,R,G),s(R,_,G),s(R,d,G),s(R,Z,G),s(R,j,G),s(R,x,G),s(R,V,G),s(R,q,G),s(R,B,G),F=!0},p:v,i(R){F||(J(c.$$.fragment,R),F=!0)},o(R){U(c.$$.fragment,R),F=!1},d(R){R&&(a(t),a(n),a(r),a(o),a(_),a(d),a(Z),a(j),a(x),a(V),a(q),a(B)),T(c,R)}}}function Sa($){let t,f,n,r,i,o;return t=new X({props:{id:"gpu-select",option:"16GB",$$slots:{default:[Ya]},$$scope:{ctx:$}}}),n=new X({props:{id:"gpu-select",option:"12GB",$$slots:{default:[Aa]},$$scope:{ctx:$}}}),i=new X({props:{id:"gpu-select",option:"8GB",$$slots:{default:[za]},$$scope:{ctx:$}}}),{c(){y(t.$$.fragment),f=p(),y(n.$$.fragment),r=p(),y(i.$$.fragment)},l(c){w(t.$$.fragment,c),f=m(c),w(n.$$.fragment,c),r=m(c),w(i.$$.fragment,c)},m(c,_){b(t,c,_),s(c,f,_),b(n,c,_),s(c,r,_),b(i,c,_),o=!0},p(c,_){const d={};_&2&&(d.$$scope={dirty:_,ctx:c}),t.$set(d);const g={};_&2&&(g.$$scope={dirty:_,ctx:c}),n.$set(g);const Z={};_&2&&(Z.$$scope={dirty:_,ctx:c}),i.$set(Z)},i(c){o||(J(t.$$.fragment,c),J(n.$$.fragment,c),J(i.$$.fragment,c),o=!0)},o(c){U(t.$$.fragment,c),U(n.$$.fragment,c),U(i.$$.fragment,c),o=!1},d(c){c&&(a(f),a(r)),T(t,c),T(n,c),T(i,c)}}}function La($){let t,f;return t=new C({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwSU5TVEFOQ0VfRElSJTNEJTIyLiUyRmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJwYXRoX3RvX3NhdmVkX21vZGVsJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0Q1ZS02JTIwJTVDJTBBJTIwJTIwLS1scl9zY2hlZHVsZXIlM0QlMjJjb25zdGFudCUyMiUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNENDAwJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&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> \\
  --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`,wrap:!1}}),{c(){y(t.$$.fragment)},l(n){w(t.$$.fragment,n)},m(n,r){b(t,n,r),f=!0},p:v,i(n){f||(J(t.$$.fragment,n),f=!0)},o(n){U(t.$$.fragment,n),f=!1},d(n){T(t,n)}}}function Ha($){let t,f;return t=new C({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`,wrap:!1}}),{c(){y(t.$$.fragment)},l(n){w(t.$$.fragment,n)},m(n,r){b(t,n,r),f=!0},p:v,i(n){f||(J(t.$$.fragment,n),f=!0)},o(n){U(t.$$.fragment,n),f=!1},d(n){T(t,n)}}}function Qa($){let t,f,n,r;return t=new X({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[La]},$$scope:{ctx:$}}}),n=new X({props:{id:"training-inference",option:"Flax",$$slots:{default:[Ha]},$$scope:{ctx:$}}}),{c(){y(t.$$.fragment),f=p(),y(n.$$.fragment)},l(i){w(t.$$.fragment,i),f=m(i),w(n.$$.fragment,i)},m(i,o){b(t,i,o),s(i,f,o),b(n,i,o),r=!0},p(i,o){const c={};o&2&&(c.$$scope={dirty:o,ctx:i}),t.$set(c);const _={};o&2&&(_.$$scope={dirty:o,ctx:i}),n.$set(_)},i(i){r||(J(t.$$.fragment,i),J(n.$$.fragment,i),r=!0)},o(i){U(t.$$.fragment,i),U(n.$$.fragment,i),r=!1},d(i){i&&a(f),T(t,i),T(n,i)}}}function Da($){let t,f="Can’t wait to try your model for inference before training is complete? 🤭 Make sure you have the latest version of 🤗 Accelerate installed.",n,r,i;return r=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ0xJUFRleHRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZtb2RlbCUyRmNoZWNrcG9pbnQtMTAwJTJGdW5ldCUyMiklMEElMEElMjMlMjBpZiUyMHlvdSUyMGhhdmUlMjB0cmFpbmVkJTIwd2l0aCUyMCU2MC0tYXJncy50cmFpbl90ZXh0X2VuY29kZXIlNjAlMjBtYWtlJTIwc3VyZSUyMHRvJTIwYWxzbyUyMGxvYWQlMjB0aGUlMjB0ZXh0JTIwZW5jb2RlciUwQXRleHRfZW5jb2RlciUyMCUzRCUyMENMSVBUZXh0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdGglMkZ0byUyRm1vZGVsJTJGY2hlY2twb2ludC0xMDAlMkZjaGVja3BvaW50LTEwMCUyRnRleHRfZW5jb2RlciUyMiklMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJydW53YXltbCUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUyQyUyMHVuZXQlM0R1bmV0JTJDJTIwdGV4dF9lbmNvZGVyJTNEdGV4dF9lbmNvZGVyJTJDJTIwZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTBBKS50byglMjJjdWRhJTIyKSUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZWxpbmUoJTIyQSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjBpbiUyMGElMjBidWNrZXQlMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMjBndWlkYW5jZV9zY2FsZSUzRDcuNSkuaW1hZ2VzJTVCMCU1RCUwQWltYWdlLnNhdmUoJTIyZG9nLWJ1Y2tldC5wbmclMjIp",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

unet = UNet2DConditionModel.from_pretrained(<span class="hljs-string">&quot;path/to/model/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;path/to/model/checkpoint-100/checkpoint-100/text_encoder&quot;</span>)

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

image = pipeline(<span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>, 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>)`,wrap:!1}}),{c(){t=u("p"),t.textContent=f,n=p(),y(r.$$.fragment)},l(o){t=M(o,"P",{"data-svelte-h":!0}),h(t)!=="svelte-fduxd"&&(t.textContent=f),n=m(o),w(r.$$.fragment,o)},m(o,c){s(o,t,c),s(o,n,c),b(r,o,c),i=!0},p:v,i(o){i||(J(r.$$.fragment,o),i=!0)},o(o){U(r.$$.fragment,o),i=!1},d(o){o&&(a(t),a(n)),T(r,o)}}}function qa($){let t,f;return t=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwYXRoX3RvX3NhdmVkX21vZGVsJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTJDJTIwdXNlX3NhZmV0ZW5zb3JzJTNEVHJ1ZSkudG8oJTIyY3VkYSUyMiklMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKCUyMkElMjBwaG90byUyMG9mJTIwc2tzJTIwZG9nJTIwaW4lMjBhJTIwYnVja2V0JTIyJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmRvZy1idWNrZXQucG5nJTIyKQ==",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline
<span class="hljs-keyword">import</span> torch

pipeline = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;path_to_saved_model&quot;</span>, torch_dtype=torch.float16, use_safetensors=<span class="hljs-literal">True</span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)
image = pipeline(<span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>, 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>)`,wrap:!1}}),{c(){y(t.$$.fragment)},l(n){w(t.$$.fragment,n)},m(n,r){b(t,n,r),f=!0},p:v,i(n){f||(J(t.$$.fragment,n),f=!0)},o(n){U(t.$$.fragment,n),f=!1},d(n){T(t,n)}}}function Pa($){let t,f;return t=new C({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdGgtdG8teW91ci10cmFpbmVkLW1vZGVsJTIyJTJ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ljs-keyword">import</span> numpy <span class="hljs-keyword">as</span> np
<span class="hljs-keyword">from</span> flax.jax_utils <span class="hljs-keyword">import</span> replicate
<span class="hljs-keyword">from</span> flax.training.common_utils <span class="hljs-keyword">import</span> shard
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> FlaxStableDiffusionPipeline

pipeline, params = FlaxStableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;path-to-your-trained-model&quot;</span>, dtype=jax.numpy.bfloat16)

prompt = <span class="hljs-string">&quot;A photo of sks dog in a bucket&quot;</span>
prng_seed = jax.random.PRNGKey(<span class="hljs-number">0</span>)
num_inference_steps = <span class="hljs-number">50</span>

num_samples = jax.device_count()
prompt = num_samples * [prompt]
prompt_ids = pipeline.prepare_inputs(prompt)

<span class="hljs-comment"># shard inputs and rng</span>
params = replicate(params)
prng_seed = jax.random.split(prng_seed, jax.device_count())
prompt_ids = shard(prompt_ids)

images = pipeline(prompt_ids, params, prng_seed, num_inference_steps, jit=<span class="hljs-literal">True</span>).images
images = pipeline.numpy_to_pil(np.asarray(images.reshape((num_samples,) + images.shape[-<span class="hljs-number">3</span>:])))
image.save(<span class="hljs-string">&quot;dog-bucket.png&quot;</span>)`,wrap:!1}}),{c(){y(t.$$.fragment)},l(n){w(t.$$.fragment,n)},m(n,r){b(t,n,r),f=!0},p:v,i(n){f||(J(t.$$.fragment,n),f=!0)},o(n){U(t.$$.fragment,n),f=!1},d(n){T(t,n)}}}function Oa($){let t,f,n,r;return t=new X({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[qa]},$$scope:{ctx:$}}}),n=new X({props:{id:"training-inference",option:"Flax",$$slots:{default:[Pa]},$$scope:{ctx:$}}}),{c(){y(t.$$.fragment),f=p(),y(n.$$.fragment)},l(i){w(t.$$.fragment,i),f=m(i),w(n.$$.fragment,i)},m(i,o){b(t,i,o),s(i,f,o),b(n,i,o),r=!0},p(i,o){const c={};o&2&&(c.$$scope={dirty:o,ctx:i}),t.$set(c);const _={};o&2&&(_.$$scope={dirty:o,ctx:i}),n.$set(_)},i(i){r||(J(t.$$.fragment,i),J(n.$$.fragment,i),r=!0)},o(i){U(t.$$.fragment,i),U(n.$$.fragment,i),r=!1},d(i){i&&a(f),T(t,i),T(n,i)}}}function Ka($){let t,f="Training stage 1 of DeepFloyd IF with LoRA and DreamBooth requires ~28GB of memory.",n,r,i;return r=new C({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`,wrap:!1}}),{c(){t=u("p"),t.textContent=f,n=p(),y(r.$$.fragment)},l(o){t=M(o,"P",{"data-svelte-h":!0}),h(t)!=="svelte-1tn6pyi"&&(t.textContent=f),n=m(o),w(r.$$.fragment,o)},m(o,c){s(o,t,c),s(o,n,c),b(r,o,c),i=!0},p:v,i(o){i||(J(r.$$.fragment,o),i=!0)},o(o){U(r.$$.fragment,o),i=!1},d(o){o&&(a(t),a(n)),T(r,o)}}}function es($){let t,f="For stage 2 of DeepFloyd IF with LoRA and DreamBooth, pay attention to these parameters:",n,r,i="<li><code>--validation_images</code>, the images to upscale during validation</li> <li><code>--class_labels_conditioning=timesteps</code>, to additionally conditional the UNet as needed in stage 2</li> <li><code>--learning_rate=1e-6</code>, a lower learning rate is used compared to stage 1</li> <li><code>--resolution=256</code>, the expected resolution for the upscaler</li>",o,c,_;return c=new C({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFweXRob24lMjB0cmFpbl9kcmVhbWJvb3RoX2xvcmEucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXJlcG9ydF90byUyMHdhbmRiJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfR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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`,wrap:!1}}),{c(){t=u("p"),t.textContent=f,n=p(),r=u("ul"),r.innerHTML=i,o=p(),y(c.$$.fragment)},l(d){t=M(d,"P",{"data-svelte-h":!0}),h(t)!=="svelte-1x9610h"&&(t.textContent=f),n=m(d),r=M(d,"UL",{"data-svelte-h":!0}),h(r)!=="svelte-168lfnx"&&(r.innerHTML=i),o=m(d),w(c.$$.fragment,d)},m(d,g){s(d,t,g),s(d,n,g),s(d,r,g),s(d,o,g),b(c,d,g),_=!0},p:v,i(d){_||(J(c.$$.fragment,d),_=!0)},o(d){U(c.$$.fragment,d),_=!1},d(d){d&&(a(t),a(n),a(r),a(o)),T(c,d)}}}function ts($){let t,f="For stage 1 of DeepFloyd IF with DreamBooth, pay attention to these parameters:",n,r,i="<li><code>--skip_save_text_encoder</code>, to skip saving the full T5 text encoder with the finetuned model</li> <li><code>--use_8bit_adam</code>, to use 8-bit Adam optimizer to save memory due to the size of the optimizer state when training the full model</li> <li><code>--learning_rate=1e-7</code>, a really low learning rate should be used for full model training otherwise the model quality is degraded (you can use a higher learning rate with a larger batch size)</li>",o,c,_="Training with 8-bit Adam and a batch size of 4, the full model can be trained with ~48GB of memory.",d,g,Z;return g=new C({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUktWEwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2lmJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDY0JTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNENCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTclMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MCUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9wcm9tcHQlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9zdGVwcyUyMDI1JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUyMDc3JTIwJTVDJTBBJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUMlMEElMjAlMjAtLXNldF9ncmFkc190b19ub25lJTIwJTVDJTBBJTIwJTIwLS1za2lwX3NhdmVfdGV4dF9lbmNvZGVyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",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`,wrap:!1}}),{c(){t=u("p"),t.textContent=f,n=p(),r=u("ul"),r.innerHTML=i,o=p(),c=u("p"),c.textContent=_,d=p(),y(g.$$.fragment)},l(j){t=M(j,"P",{"data-svelte-h":!0}),h(t)!=="svelte-9e0na3"&&(t.textContent=f),n=m(j),r=M(j,"UL",{"data-svelte-h":!0}),h(r)!=="svelte-1s6g2k9"&&(r.innerHTML=i),o=m(j),c=M(j,"P",{"data-svelte-h":!0}),h(c)!=="svelte-124typ1"&&(c.textContent=_),d=m(j),w(g.$$.fragment,j)},m(j,I){s(j,t,I),s(j,n,I),s(j,r,I),s(j,o,I),s(j,c,I),s(j,d,I),b(g,j,I),Z=!0},p:v,i(j){Z||(J(g.$$.fragment,j),Z=!0)},o(j){U(g.$$.fragment,j),Z=!1},d(j){j&&(a(t),a(n),a(r),a(o),a(c),a(d)),T(g,j)}}}function ls($){let t,f="For stage 2 of DeepFloyd IF with DreamBooth, pay attention to these parameters:",n,r,i="<li><code>--learning_rate=5e-6</code>, use a lower learning rate with a smaller effective batch size</li> <li><code>--resolution=256</code>, the expected resolution for the upscaler</li> <li><code>--train_batch_size=2</code> and <code>--gradient_accumulation_steps=6</code>, to effectively train on images wiht faces requires larger batch sizes</li>",o,c,_;return c=new C({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJG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VDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX2ltYWdlcyUyMCUyNFZBTElEQVRJT05fSU1BR0VTJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19sYWJlbHNfY29uZGl0aW9uaW5nJTIwdGltZXN0ZXBzJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",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`,wrap:!1}}),{c(){t=u("p"),t.textContent=f,n=p(),r=u("ul"),r.innerHTML=i,o=p(),y(c.$$.fragment)},l(d){t=M(d,"P",{"data-svelte-h":!0}),h(t)!=="svelte-1i483k6"&&(t.textContent=f),n=m(d),r=M(d,"UL",{"data-svelte-h":!0}),h(r)!=="svelte-1a3h6r9"&&(r.innerHTML=i),o=m(d),w(c.$$.fragment,d)},m(d,g){s(d,t,g),s(d,n,g),s(d,r,g),s(d,o,g),b(c,d,g),_=!0},p:v,i(d){_||(J(c.$$.fragment,d),_=!0)},o(d){U(c.$$.fragment,d),_=!1},d(d){d&&(a(t),a(n),a(r),a(o)),T(c,d)}}}function as($){let t,f,n,r,i,o,c,_;return t=new X({props:{id:"IF-DreamBooth",option:"Stage 1 LoRA DreamBooth",$$slots:{default:[Ka]},$$scope:{ctx:$}}}),n=new X({props:{id:"IF-DreamBooth",option:"Stage 2 LoRA DreamBooth",$$slots:{default:[es]},$$scope:{ctx:$}}}),i=new X({props:{id:"IF-DreamBooth",option:"Stage 1 DreamBooth",$$slots:{default:[ts]},$$scope:{ctx:$}}}),c=new X({props:{id:"IF-DreamBooth",option:"Stage 2 DreamBooth",$$slots:{default:[ls]},$$scope:{ctx:$}}}),{c(){y(t.$$.fragment),f=p(),y(n.$$.fragment),r=p(),y(i.$$.fragment),o=p(),y(c.$$.fragment)},l(d){w(t.$$.fragment,d),f=m(d),w(n.$$.fragment,d),r=m(d),w(i.$$.fragment,d),o=m(d),w(c.$$.fragment,d)},m(d,g){b(t,d,g),s(d,f,g),b(n,d,g),s(d,r,g),b(i,d,g),s(d,o,g),b(c,d,g),_=!0},p(d,g){const Z={};g&2&&(Z.$$scope={dirty:g,ctx:d}),t.$set(Z);const j={};g&2&&(j.$$scope={dirty:g,ctx:d}),n.$set(j);const I={};g&2&&(I.$$scope={dirty:g,ctx:d}),i.$set(I);const x={};g&2&&(x.$$scope={dirty:g,ctx:d}),c.$set(x)},i(d){_||(J(t.$$.fragment,d),J(n.$$.fragment,d),J(i.$$.fragment,d),J(c.$$.fragment,d),_=!0)},o(d){U(t.$$.fragment,d),U(n.$$.fragment,d),U(i.$$.fragment,d),U(c.$$.fragment,d),_=!1},d(d){d&&(a(f),a(r),a(o)),T(t,d),T(n,d),T(i,d),T(c,d)}}}function ss($){let t,f,n,r,i,o,c,_='<a href="https://huggingface.co/papers/2208.12242" rel="nofollow">DreamBooth</a> is a training technique that updates the entire diffusion model by training on just a few images of a subject or style. It works by associating a special word in the prompt with the example images.',d,g,Z='If you’re training on a GPU with limited vRAM, you should try enabling the <code>gradient_checkpointing</code> and <code>mixed_precision</code> parameters in the training command. You can also reduce your memory footprint by using memory-efficient attention with <a href="../optimization/xformers">xFormers</a>. JAX/Flax training is also supported for efficient training on TPUs and GPUs, but it doesn’t support gradient checkpointing or xFormers. You should have a GPU with &gt;30GB of memory if you want to train faster with Flax.',j,I,x='This guide will explore the <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">train_dreambooth.py</a> script to help you become more familiar with it, and how you can adapt it for your own use-case.',V,N,q="Before running the script, make sure you install the library from source:",B,k,F,R,G="Navigate to the example folder with the training script and install the required dependencies for the script you’re using:",mt,E,dt,Y,ct,P,Xl="Initialize an 🤗 Accelerate environment:",ft,O,ut,K,Vl="To setup a default 🤗 Accelerate environment without choosing any configurations:",Mt,ee,ht,te,Bl="Or if your environment doesn’t support an interactive shell, like a notebook, you can use:",yt,le,wt,ae,Wl='Lastly, if you want to train a model on your own dataset, take a look at the <a href="create_dataset">Create a dataset for training</a> guide to learn how to create a dataset that works with the training script.',bt,A,Jt,se,Ut,z,Tt,ne,xl='The training script offers many parameters for customizing your training run. All of the parameters and their descriptions are found in the <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L228" rel="nofollow"><code>parse_args()</code></a> function. The parameters are set with default values that should work pretty well out-of-the-box, but you can also set your own values in the training command if you’d like.',gt,ie,Nl="For example, to train in the bf16 format:",_t,oe,$t,re,kl="Some basic and important parameters to know and specify are:",jt,pe,Fl="<li><code>--pretrained_model_name_or_path</code>: the name of the model on the Hub or a local path to the pretrained model</li> <li><code>--instance_data_dir</code>: path to a folder containing the training dataset (example images)</li> <li><code>--instance_prompt</code>: the text prompt that contains the special word for the example images</li> <li><code>--train_text_encoder</code>: whether to also train the text encoder</li> <li><code>--output_dir</code>: where to save the trained model</li> <li><code>--push_to_hub</code>: whether to push the trained model to the Hub</li> <li><code>--checkpointing_steps</code>: frequency of saving a checkpoint as the model trains; this is useful if for some reason training is interrupted, you can continue training from that checkpoint by adding <code>--resume_from_checkpoint</code> to your training command</li>",Zt,me,Rt,de,El='The <a href="https://huggingface.co/papers/2303.09556" rel="nofollow">Min-SNR</a> weighting strategy can help with training by rebalancing the loss to achieve faster convergence. The training script supports predicting <code>epsilon</code> (noise) or <code>v_prediction</code>, but Min-SNR is compatible with both prediction types. This weighting strategy is only supported by PyTorch and is unavailable in the Flax training script.',Ct,ce,Yl="Add the <code>--snr_gamma</code> parameter and set it to the recommended value of 5.0:",It,fe,vt,ue,Gt,Me,Al="Prior preservation loss is a method that uses a model’s own generated samples to help it learn how to generate more diverse images. Because these generated sample images belong to the same class as the images you provided, they help the model retain what it has learned about the class and how it can use what it already knows about the class to make new compositions.",Xt,he,zl="<li><code>--with_prior_preservation</code>: whether to use prior preservation loss</li> <li><code>--prior_loss_weight</code>: controls the influence of the prior preservation loss on the model</li> <li><code>--class_data_dir</code>: path to a folder containing the generated class sample images</li> <li><code>--class_prompt</code>: the text prompt describing the class of the generated sample images</li>",Vt,ye,Bt,we,Wt,be,Sl="To improve the quality of the generated outputs, you can also train the text encoder in addition to the UNet. This requires additional memory and you’ll need a GPU with at least 24GB of vRAM. If you have the necessary hardware, then training the text encoder produces better results, especially when generating images of faces. Enable this option by:",xt,Je,Nt,Ue,kt,Te,Ll="DreamBooth comes with its own dataset classes:",Ft,ge,Hl='<li><a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L604" rel="nofollow"><code>DreamBoothDataset</code></a>: preprocesses the images and class images, and tokenizes the prompts for training</li> <li><a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L738" rel="nofollow"><code>PromptDataset</code></a>: generates the prompt embeddings to generate the class images</li>',Et,_e,Ql='If you enabled <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L842" rel="nofollow">prior preservation loss</a>, the class images are generated here:',Yt,$e,At,je,Dl='Next is the <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L799" rel="nofollow"><code>main()</code></a> function which handles setting up the dataset for training and the training loop itself. The script loads the <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L898" rel="nofollow">tokenizer</a>, <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L912C1-L912C1" rel="nofollow">scheduler and models</a>:',zt,Ze,St,Re,ql='Then, it’s time to <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L1073" rel="nofollow">create the training dataset</a> and DataLoader from <code>DreamBoothDataset</code>:',Lt,Ce,Ht,Ie,Pl='Lastly, the <a href="https://github.com/huggingface/diffusers/blob/072e00897a7cf4302c347a63ec917b4b8add16d4/examples/dreambooth/train_dreambooth.py#L1151" rel="nofollow">training loop</a> takes care of the remaining steps such as converting images to latent space, adding noise to the input, predicting the noise residual, and calculating the loss.',Qt,ve,Ol='If you want to learn more about how the training loop works, check out the <a href="../using-diffusers/write_own_pipeline">Understanding pipelines, models and schedulers</a> tutorial which breaks down the basic pattern of the denoising process.',Dt,Ge,qt,Xe,Kl="You’re now ready to launch the training script! 🚀",Pt,Ve,ea='For this guide, you’ll download some images of a <a href="https://huggingface.co/datasets/diffusers/dog-example" rel="nofollow">dog</a> and store them in a directory. But remember, you can create and use your own dataset if you want (see the <a href="create_dataset">Create a dataset for training</a> guide).',Ot,Be,Kt,We,ta="Set the environment variable <code>MODEL_NAME</code> to a model id on the Hub or a path to a local model, <code>INSTANCE_DIR</code> to the path where you just downloaded the dog images to, and <code>OUTPUT_DIR</code> to where you want to save the model. You’ll use <code>sks</code> as the special word to tie the training to.",el,xe,la="If you’re interested in following along with the training process, you can periodically save generated images as training progresses. Add the following parameters to the training command:",tl,Ne,ll,ke,aa="One more thing before you launch the script! Depending on the GPU you have, you may need to enable certain optimizations to train DreamBooth.",al,S,sl,L,nl,Fe,sa="Once training is complete, you can use your newly trained model for inference!",il,H,ol,Q,rl,Ee,pl,Ye,na='LoRA is a training technique for significantly reducing the number of trainable parameters. As a result, training is faster and it is easier to store the resulting weights because they are a lot smaller (~100MBs). Use the <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py" rel="nofollow">train_dreambooth_lora.py</a> script to train with LoRA.',ml,Ae,ia='The LoRA training script is discussed in more detail in the <a href="lora">LoRA training</a> guide.',dl,ze,cl,Se,oa='Stable Diffusion XL (SDXL) is a powerful text-to-image model that generates high-resolution images, and it adds a second text-encoder to its architecture. Use the <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora_sdxl.py" rel="nofollow">train_dreambooth_lora_sdxl.py</a> script to train a SDXL model with LoRA.',fl,Le,ra='The SDXL training script is discussed in more detail in the <a href="sdxl">SDXL training</a> guide.',ul,He,Ml,Qe,pa='DeepFloyd IF is a cascading pixel diffusion model with three stages. The first stage generates a base image and the second and third stages progressively upscales the base image into a high-resolution 1024x1024 image. Use the <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_lora.py" rel="nofollow">train_dreambooth_lora.py</a> or <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">train_dreambooth.py</a> scripts to train a DeepFloyd IF model with LoRA or the full model.',hl,De,ma="DeepFloyd IF uses predicted variance, but the Diffusers training scripts uses predicted error so the trained DeepFloyd IF models are switched to a fixed variance schedule. The training scripts will update the scheduler config of the fully trained model for you. However, when you load the saved LoRA weights you must also update the pipeline’s scheduler config.",yl,qe,wl,Pe,da="The stage 2 model requires additional validation images to upscale. You can download and use a downsized version of the training images for this.",bl,Oe,Jl,Ke,ca="The code samples below provide a brief overview of how to train a DeepFloyd IF model with a combination of DreamBooth and LoRA. Some important parameters to note are:",Ul,et,fa='<li><code>--resolution=64</code>, a much smaller resolution is required because DeepFloyd IF is a pixel diffusion model and to work on uncompressed pixels, the input images must be smaller</li> <li><code>--pre_compute_text_embeddings</code>, compute the text embeddings ahead of time to save memory because the <a href="https://huggingface.co/docs/transformers/main/en/model_doc/t5#transformers.T5Model" rel="nofollow">T5Model</a> can take up a lot of memory</li> <li><code>--tokenizer_max_length=77</code>, you can use a longer default text length with T5 as the text encoder but the default model encoding procedure uses a shorter text length</li> <li><code>--text_encoder_use_attention_mask</code>, to pass the attention mask to the text encoder</li>',Tl,D,gl,tt,_l,lt,ua="Training the DeepFloyd IF model can be challenging, but here are some tips that we’ve found helpful:",$l,at,Ma='<li>LoRA is sufficient for training the stage 1 model because the model’s low resolution makes representing finer details difficult regardless.</li> <li>For common or simple objects, you don’t necessarily need to finetune the upscaler. Make sure the prompt passed to the upscaler is adjusted to remove the new token from the instance prompt. For example, if your stage 1 prompt is “a sks dog” then your stage 2 prompt should be “a dog”.</li> <li>For finer details like faces, fully training the stage 2 upscaler is better than training the stage 2 model with LoRA. It also helps to use lower learning rates with larger batch sizes.</li> <li>Lower learning rates should be used to train the stage 2 model.</li> <li>The <a href="/docs/diffusers/main/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a> works better than the DPMSolver used in the training scripts.</li>',jl,st,Zl,nt,ha="Congratulations on training your DreamBooth model! To learn more about how to use your new model, the following guide may be helpful:",Rl,it,ya='<li>Learn how to <a href="../using-diffusers/loading_adapters">load a DreamBooth</a> model for inference if you trained your model with LoRA.</li>',Cl,ot,Il,rt,vl;return i=new W({props:{title:"DreamBooth",local:"dreambooth",headingTag:"h1"}}),k=new C({props:{code:"Z2l0JTIwY2xvbmUlMjBodHRwcyUzQSUyRiUyRmdpdGh1Yi5jb20lMkZodWdnaW5nZmFjZSUyRmRpZmZ1c2VycyUwQWNkJTIwZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC4=",highlighted:`git <span class="hljs-built_in">clone</span> https://github.com/huggingface/diffusers
<span class="hljs-built_in">cd</span> diffusers
pip install .`,wrap:!1}}),E=new pt({props:{id:"installation",options:["PyTorch","Flax"],$$slots:{default:[Na]},$$scope:{ctx:$}}}),Y=new Gl({props:{$$slots:{default:[ka]},$$scope:{ctx:$}}}),O=new C({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),ee=new C({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),le=new C({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`<span class="hljs-keyword">from</span> accelerate.utils <span class="hljs-keyword">import</span> write_basic_config

write_basic_config()`,wrap:!1}}),A=new Gl({props:{$$slots:{default:[Fa]},$$scope:{ctx:$}}}),se=new W({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),z=new Gl({props:{warning:!0,$$slots:{default:[Ea]},$$scope:{ctx:$}}}),oe=new C({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmJmMTYlMjI=",highlighted:`accelerate launch train_dreambooth.py \\
    --mixed_precision=<span class="hljs-string">&quot;bf16&quot;</span>`,wrap:!1}}),me=new W({props:{title:"Min-SNR weighting",local:"min-snr-weighting",headingTag:"h3"}}),fe=new C({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXNucl9nYW1tYSUzRDUuMA==",highlighted:`accelerate launch train_dreambooth.py \\
  --snr_gamma=5.0`,wrap:!1}}),ue=new W({props:{title:"Prior preservation loss",local:"prior-preservation-loss",headingTag:"h3"}}),ye=new C({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwJTVDJTBBJTIwJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfZGF0YV9kaXIlM0QlMjJwYXRoJTJGdG8lMkZjbGFzcyUyRmltYWdlcyUyMiUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIydGV4dCUyMHByb21wdCUyMGRlc2NyaWJpbmclMjBjbGFzcyUyMg==",highlighted:`accelerate launch train_dreambooth.py \\
  --with_prior_preservation \\
  --prior_loss_weight=1.0 \\
  --class_data_dir=<span class="hljs-string">&quot;path/to/class/images&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;text prompt describing class&quot;</span>`,wrap:!1}}),we=new W({props:{title:"Train text encoder",local:"train-text-encoder",headingTag:"h3"}}),Je=new C({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXRyYWluX3RleHRfZW5jb2Rlcg==",highlighted:`accelerate launch train_dreambooth.py \\
  --train_text_encoder`,wrap:!1}}),Ue=new W({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),$e=new C({props:{code:"c2FtcGxlX2RhdGFzZXQlMjAlM0QlMjBQcm9tcHREYXRhc2V0KGFyZ3MuY2xhc3NfcHJvbXB0JTJDJTIwbnVtX25ld19pbWFnZXMpJTBBc2FtcGxlX2RhdGFsb2FkZXIlMjAlM0QlMjB0b3JjaC51dGlscy5kYXRhLkRhdGFMb2FkZXIoc2FtcGxlX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEYXJncy5zYW1wbGVfYmF0Y2hfc2l6ZSklMEElMEFzYW1wbGVfZGF0YWxvYWRlciUyMCUzRCUyMGFjY2VsZXJhdG9yLnByZXBhcmUoc2FtcGxlX2RhdGFsb2FkZXIpJTBBcGlwZWxpbmUudG8oYWNjZWxlcmF0b3IuZGV2aWNlKSUwQSUwQWZvciUyMGV4YW1wbGUlMjBpbiUyMHRxZG0oJTBBJTIwJTIwJTIwJTIwc2FtcGxlX2RhdGFsb2FkZXIlMkMlMjBkZXNjJTNEJTIyR2VuZXJhdGluZyUyMGNsYXNzJTIwaW1hZ2VzJTIyJTJDJTIwZGlzYWJsZSUzRG5vdCUyMGFjY2VsZXJhdG9yLmlzX2xvY2FsX21haW5fcHJvY2VzcyUwQSklM0ElMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjBwaXBlbGluZShleGFtcGxlJTVCJTIycHJvbXB0JTIyJTVEKS5pbWFnZXM=",highlighted:`sample_dataset = PromptDataset(args.class_prompt, num_new_images)
sample_dataloader = torch.utils.data.DataLoader(sample_dataset, batch_size=args.sample_batch_size)

sample_dataloader = accelerator.prepare(sample_dataloader)
pipeline.to(accelerator.device)

<span class="hljs-keyword">for</span> example <span class="hljs-keyword">in</span> tqdm(
    sample_dataloader, desc=<span class="hljs-string">&quot;Generating class images&quot;</span>, disable=<span class="hljs-keyword">not</span> accelerator.is_local_main_process
):
    images = pipeline(example[<span class="hljs-string">&quot;prompt&quot;</span>]).images`,wrap:!1}}),Ze=new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pbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSklMEElMEFpZiUyMG1vZGVsX2hhc192YWUoYXJncyklM0ElMEElMjAlMjAlMjAlMjB2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydmFlJTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBJTIwJTIwJTIwJTIwKSUwQWVsc2UlM0ElMEElMjAlMjAlMjAlMjB2YWUlMjAlM0QlMjBOb25lJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydW5ldCUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSk=",highlighted:`<span class="hljs-comment"># Load the tokenizer</span>
<span class="hljs-keyword">if</span> args.tokenizer_name:
    tokenizer = AutoTokenizer.from_pretrained(args.tokenizer_name, revision=args.revision, use_fast=<span class="hljs-literal">False</span>)
<span class="hljs-keyword">elif</span> args.pretrained_model_name_or_path:
    tokenizer = AutoTokenizer.from_pretrained(
        args.pretrained_model_name_or_path,
        subfolder=<span class="hljs-string">&quot;tokenizer&quot;</span>,
        revision=args.revision,
        use_fast=<span class="hljs-literal">False</span>,
    )

<span class="hljs-comment"># Load scheduler and models</span>
noise_scheduler = DDPMScheduler.from_pretrained(args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
text_encoder = text_encoder_cls.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, revision=args.revision
)

<span class="hljs-keyword">if</span> model_has_vae(args):
    vae = AutoencoderKL.from_pretrained(
        args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, revision=args.revision
    )
<span class="hljs-keyword">else</span>:
    vae = <span class="hljs-literal">None</span>

unet = UNet2DConditionModel.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, revision=args.revision
)`,wrap:!1}}),Ce=new C({props:{code:"dHJhaW5fZGF0YXNldCUyMCUzRCUyMERyZWFtQm9vdGhEYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGluc3RhbmNlX2RhdGFfcm9vdCUzRGFyZ3MuaW5zdGFuY2VfZGF0YV9kaXIlMkMlMEElMjAlMjAlMjAlMjBpbnN0YW5jZV9wcm9tcHQlM0RhcmdzLmluc3RhbmNlX3Byb21wdCUyQyUwQSUyMCUyMCUyMCUyMGNsYXNzX2RhdGFfcm9vdCUzRGFyZ3MuY2xhc3NfZGF0YV9kaXIlMjBpZiUyMGFyZ3Mud2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24lMjBlbHNlJTIwTm9uZSUyQyUwQSUyMCUyMCUyMCUyMGNsYXNzX3Byb21wdCUzRGFyZ3MuY2xhc3NfcHJvbXB0JTJDJTBBJTIwJTIwJTIwJTIwY2xhc3NfbnVtJTNEYXJncy5udW1fY2xhc3NfaW1hZ2VzJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTNEdG9rZW5pemVyJTJDJTBBJTIwJTIwJTIwJTIwc2l6ZSUzRGFyZ3MucmVzb2x1dGlvbiUyQyUwQSUyMCUyMCUyMCUyMGNlbnRlcl9jcm9wJTNEYXJncy5jZW50ZXJfY3JvcCUyQyUwQSUyMCUyMCUyMCUyMGVuY29kZXJfaGlkZGVuX3N0YXRlcyUzRHByZV9jb21wdXRlZF9lbmNvZGVyX2hpZGRlbl9zdGF0ZXMlMkMlMEElMjAlMjAlMjAlMjBjbGFzc19wcm9tcHRfZW5jb2Rlcl9oaWRkZW5fc3RhdGVzJTNEcHJlX2NvbXB1dGVkX2NsYXNzX3Byb21wdF9lbmNvZGVyX2hpZGRlbl9zdGF0ZXMlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXJfbWF4X2xlbmd0aCUzRGFyZ3MudG9rZW5pemVyX21heF9sZW5ndGglMkMlMEEpJTBBJTBBdHJhaW5fZGF0YWxvYWRlciUyMCUzRCUyMHRvcmNoLnV0aWxzLmRhdGEuRGF0YUxvYWRlciglMEElMjAlMjAlMjAlMjB0cmFpbl9kYXRhc2V0JTJDJTBBJTIwJTIwJTIwJTIwYmF0Y2hfc2l6ZSUzRGFyZ3MudHJhaW5fYmF0Y2hfc2l6ZSUyQyUwQSUyMCUyMCUyMCUyMHNodWZmbGUlM0RUcnVlJTJDJTBBJTIwJTIwJTIwJTIwY29sbGF0ZV9mbiUzRGxhbWJkYSUyMGV4YW1wbGVzJTNBJTIwY29sbGF0ZV9mbihleGFtcGxlcyUyQyUyMGFyZ3Mud2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24pJTJDJTBBJTIwJTIwJTIwJTIwbnVtX3dvcmtlcnMlM0RhcmdzLmRhdGFsb2FkZXJfbnVtX3dvcmtlcnMlMkMlMEEp",highlighted:`train_dataset = DreamBoothDataset(
    instance_data_root=args.instance_data_dir,
    instance_prompt=args.instance_prompt,
    class_data_root=args.class_data_dir <span class="hljs-keyword">if</span> args.with_prior_preservation <span class="hljs-keyword">else</span> <span class="hljs-literal">None</span>,
    class_prompt=args.class_prompt,
    class_num=args.num_class_images,
    tokenizer=tokenizer,
    size=args.resolution,
    center_crop=args.center_crop,
    encoder_hidden_states=pre_computed_encoder_hidden_states,
    class_prompt_encoder_hidden_states=pre_computed_class_prompt_encoder_hidden_states,
    tokenizer_max_length=args.tokenizer_max_length,
)

train_dataloader = torch.utils.data.DataLoader(
    train_dataset,
    batch_size=args.train_batch_size,
    shuffle=<span class="hljs-literal">True</span>,
    collate_fn=<span class="hljs-keyword">lambda</span> examples: collate_fn(examples, args.with_prior_preservation),
    num_workers=args.dataloader_num_workers,
)`,wrap:!1}}),Ge=new W({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),Be=new C({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>,
)`,wrap:!1}}),Ne=new C({props:{code:"LS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMmElMjBwaG90byUyMG9mJTIwYSUyMHNrcyUyMGRvZyUyMiUwQS0tbnVtX3ZhbGlkYXRpb25faW1hZ2VzJTNENCUwQS0tdmFsaWRhdGlvbl9zdGVwcyUzRDEwMA==",highlighted:`--validation_prompt=<span class="hljs-string">&quot;a photo of a sks dog&quot;</span>
--num_validation_images=4
--validation_steps=100`,wrap:!1}}),S=new pt({props:{id:"gpu-select",options:["16GB","12GB","8GB"],$$slots:{default:[Sa]},$$scope:{ctx:$}}}),L=new pt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Qa]},$$scope:{ctx:$}}}),H=new Gl({props:{$$slots:{default:[Da]},$$scope:{ctx:$}}}),Q=new pt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Oa]},$$scope:{ctx:$}}}),Ee=new W({props:{title:"LoRA",local:"lora",headingTag:"h2"}}),ze=new W({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),He=new W({props:{title:"DeepFloyd IF",local:"deepfloyd-if",headingTag:"h2"}}),qe=new C({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJEZWVwRmxveWQlMkZJRi1JLVhMLXYxLjAlMjIlMkMlMjB1c2Vfc2FmZXRlbnNvcnMlM0RUcnVlKSUwQSUwQXBpcGUubG9hZF9sb3JhX3dlaWdodHMoJTIyJTNDbG9yYSUyMHdlaWdodHMlMjBwYXRoJTNFJTIyKSUwQSUwQSUyMyUyMFVwZGF0ZSUyMHNjaGVkdWxlciUyMGNvbmZpZyUyMHRvJTIwZml4ZWQlMjB2YXJpYW5jZSUyMHNjaGVkdWxlJTBBcGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBwaXBlLnNjaGVkdWxlci5fX2NsYXNzX18uZnJvbV9jb25maWcocGlwZS5zY2hlZHVsZXIuY29uZmlnJTJDJTIwdmFyaWFuY2VfdHlwZSUzRCUyMmZpeGVkX3NtYWxsJTIyKQ==",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>, use_safetensors=<span class="hljs-literal">True</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>)`,wrap:!1}}),Oe=new C({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>,
)`,wrap:!1}}),D=new pt({props:{id:"IF-DreamBooth",options:["Stage 1 LoRA DreamBooth","Stage 2 LoRA DreamBooth","Stage 1 DreamBooth","Stage 2 DreamBooth"],$$slots:{default:[as]},$$scope:{ctx:$}}}),tt=new W({props:{title:"Training tips",local:"training-tips",headingTag:"h3"}}),st=new W({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),ot=new Ba({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/dreambooth.md"}}),{c(){t=u("meta"),f=p(),n=u("p"),r=p(),y(i.$$.fragment),o=p(),c=u("p"),c.innerHTML=_,d=p(),g=u("p"),g.innerHTML=Z,j=p(),I=u("p"),I.innerHTML=x,V=p(),N=u("p"),N.textContent=q,B=p(),y(k.$$.fragment),F=p(),R=u("p"),R.textContent=G,mt=p(),y(E.$$.fragment),dt=p(),y(Y.$$.fragment),ct=p(),P=u("p"),P.textContent=Xl,ft=p(),y(O.$$.fragment),ut=p(),K=u("p"),K.textContent=Vl,Mt=p(),y(ee.$$.fragment),ht=p(),te=u("p"),te.textContent=Bl,yt=p(),y(le.$$.fragment),wt=p(),ae=u("p"),ae.innerHTML=Wl,bt=p(),y(A.$$.fragment),Jt=p(),y(se.$$.fragment),Ut=p(),y(z.$$.fragment),Tt=p(),ne=u("p"),ne.innerHTML=xl,gt=p(),ie=u("p"),ie.textContent=Nl,_t=p(),y(oe.$$.fragment),$t=p(),re=u("p"),re.textContent=kl,jt=p(),pe=u("ul"),pe.innerHTML=Fl,Zt=p(),y(me.$$.fragment),Rt=p(),de=u("p"),de.innerHTML=El,Ct=p(),ce=u("p"),ce.innerHTML=Yl,It=p(),y(fe.$$.fragment),vt=p(),y(ue.$$.fragment),Gt=p(),Me=u("p"),Me.textContent=Al,Xt=p(),he=u("ul"),he.innerHTML=zl,Vt=p(),y(ye.$$.fragment),Bt=p(),y(we.$$.fragment),Wt=p(),be=u("p"),be.textContent=Sl,xt=p(),y(Je.$$.fragment),Nt=p(),y(Ue.$$.fragment),kt=p(),Te=u("p"),Te.textContent=Ll,Ft=p(),ge=u("ul"),ge.innerHTML=Hl,Et=p(),_e=u("p"),_e.innerHTML=Ql,Yt=p(),y($e.$$.fragment),At=p(),je=u("p"),je.innerHTML=Dl,zt=p(),y(Ze.$$.fragment),St=p(),Re=u("p"),Re.innerHTML=ql,Lt=p(),y(Ce.$$.fragment),Ht=p(),Ie=u("p"),Ie.innerHTML=Pl,Qt=p(),ve=u("p"),ve.innerHTML=Ol,Dt=p(),y(Ge.$$.fragment),qt=p(),Xe=u("p"),Xe.textContent=Kl,Pt=p(),Ve=u("p"),Ve.innerHTML=ea,Ot=p(),y(Be.$$.fragment),Kt=p(),We=u("p"),We.innerHTML=ta,el=p(),xe=u("p"),xe.textContent=la,tl=p(),y(Ne.$$.fragment),ll=p(),ke=u("p"),ke.textContent=aa,al=p(),y(S.$$.fragment),sl=p(),y(L.$$.fragment),nl=p(),Fe=u("p"),Fe.textContent=sa,il=p(),y(H.$$.fragment),ol=p(),y(Q.$$.fragment),rl=p(),y(Ee.$$.fragment),pl=p(),Ye=u("p"),Ye.innerHTML=na,ml=p(),Ae=u("p"),Ae.innerHTML=ia,dl=p(),y(ze.$$.fragment),cl=p(),Se=u("p"),Se.innerHTML=oa,fl=p(),Le=u("p"),Le.innerHTML=ra,ul=p(),y(He.$$.fragment),Ml=p(),Qe=u("p"),Qe.innerHTML=pa,hl=p(),De=u("p"),De.textContent=ma,yl=p(),y(qe.$$.fragment),wl=p(),Pe=u("p"),Pe.textContent=da,bl=p(),y(Oe.$$.fragment),Jl=p(),Ke=u("p"),Ke.textContent=ca,Ul=p(),et=u("ul"),et.innerHTML=fa,Tl=p(),y(D.$$.fragment),gl=p(),y(tt.$$.fragment),_l=p(),lt=u("p"),lt.textContent=ua,$l=p(),at=u("ul"),at.innerHTML=Ma,jl=p(),y(st.$$.fragment),Zl=p(),nt=u("p"),nt.textContent=ha,Rl=p(),it=u("ul"),it.innerHTML=ya,Cl=p(),y(ot.$$.fragment),Il=p(),rt=u("p"),this.h()},l(e){const l=Xa("svelte-u9bgzb",document.head);t=M(l,"META",{name:!0,content:!0}),l.forEach(a),f=m(e),n=M(e,"P",{}),Za(n).forEach(a),r=m(e),w(i.$$.fragment,e),o=m(e),c=M(e,"P",{"data-svelte-h":!0}),h(c)!=="svelte-yz6jri"&&(c.innerHTML=_),d=m(e),g=M(e,"P",{"data-svelte-h":!0}),h(g)!=="svelte-en2tmp"&&(g.innerHTML=Z),j=m(e),I=M(e,"P",{"data-svelte-h":!0}),h(I)!=="svelte-1ol1kd9"&&(I.innerHTML=x),V=m(e),N=M(e,"P",{"data-svelte-h":!0}),h(N)!=="svelte-l7dm2q"&&(N.textContent=q),B=m(e),w(k.$$.fragment,e),F=m(e),R=M(e,"P",{"data-svelte-h":!0}),h(R)!=="svelte-1nancx8"&&(R.textContent=G),mt=m(e),w(E.$$.fragment,e),dt=m(e),w(Y.$$.fragment,e),ct=m(e),P=M(e,"P",{"data-svelte-h":!0}),h(P)!=="svelte-60q53m"&&(P.textContent=Xl),ft=m(e),w(O.$$.fragment,e),ut=m(e),K=M(e,"P",{"data-svelte-h":!0}),h(K)!=="svelte-di6juu"&&(K.textContent=Vl),Mt=m(e),w(ee.$$.fragment,e),ht=m(e),te=M(e,"P",{"data-svelte-h":!0}),h(te)!=="svelte-tsz4qp"&&(te.textContent=Bl),yt=m(e),w(le.$$.fragment,e),wt=m(e),ae=M(e,"P",{"data-svelte-h":!0}),h(ae)!=="svelte-1fkfdql"&&(ae.innerHTML=Wl),bt=m(e),w(A.$$.fragment,e),Jt=m(e),w(se.$$.fragment,e),Ut=m(e),w(z.$$.fragment,e),Tt=m(e),ne=M(e,"P",{"data-svelte-h":!0}),h(ne)!=="svelte-gb0mrm"&&(ne.innerHTML=xl),gt=m(e),ie=M(e,"P",{"data-svelte-h":!0}),h(ie)!=="svelte-1aa3zni"&&(ie.textContent=Nl),_t=m(e),w(oe.$$.fragment,e),$t=m(e),re=M(e,"P",{"data-svelte-h":!0}),h(re)!=="svelte-1ug35mp"&&(re.textContent=kl),jt=m(e),pe=M(e,"UL",{"data-svelte-h":!0}),h(pe)!=="svelte-pohxvr"&&(pe.innerHTML=Fl),Zt=m(e),w(me.$$.fragment,e),Rt=m(e),de=M(e,"P",{"data-svelte-h":!0}),h(de)!=="svelte-isitbv"&&(de.innerHTML=El),Ct=m(e),ce=M(e,"P",{"data-svelte-h":!0}),h(ce)!=="svelte-tp3kp"&&(ce.innerHTML=Yl),It=m(e),w(fe.$$.fragment,e),vt=m(e),w(ue.$$.fragment,e),Gt=m(e),Me=M(e,"P",{"data-svelte-h":!0}),h(Me)!=="svelte-1oc83h6"&&(Me.textContent=Al),Xt=m(e),he=M(e,"UL",{"data-svelte-h":!0}),h(he)!=="svelte-1e6kqrs"&&(he.innerHTML=zl),Vt=m(e),w(ye.$$.fragment,e),Bt=m(e),w(we.$$.fragment,e),Wt=m(e),be=M(e,"P",{"data-svelte-h":!0}),h(be)!=="svelte-n5xd96"&&(be.textContent=Sl),xt=m(e),w(Je.$$.fragment,e),Nt=m(e),w(Ue.$$.fragment,e),kt=m(e),Te=M(e,"P",{"data-svelte-h":!0}),h(Te)!=="svelte-76mqwg"&&(Te.textContent=Ll),Ft=m(e),ge=M(e,"UL",{"data-svelte-h":!0}),h(ge)!=="svelte-1sge1kf"&&(ge.innerHTML=Hl),Et=m(e),_e=M(e,"P",{"data-svelte-h":!0}),h(_e)!=="svelte-c9697n"&&(_e.innerHTML=Ql),Yt=m(e),w($e.$$.fragment,e),At=m(e),je=M(e,"P",{"data-svelte-h":!0}),h(je)!=="svelte-e2s2vm"&&(je.innerHTML=Dl),zt=m(e),w(Ze.$$.fragment,e),St=m(e),Re=M(e,"P",{"data-svelte-h":!0}),h(Re)!=="svelte-s7uwdj"&&(Re.innerHTML=ql),Lt=m(e),w(Ce.$$.fragment,e),Ht=m(e),Ie=M(e,"P",{"data-svelte-h":!0}),h(Ie)!=="svelte-4ixpqk"&&(Ie.innerHTML=Pl),Qt=m(e),ve=M(e,"P",{"data-svelte-h":!0}),h(ve)!=="svelte-6gmbd2"&&(ve.innerHTML=Ol),Dt=m(e),w(Ge.$$.fragment,e),qt=m(e),Xe=M(e,"P",{"data-svelte-h":!0}),h(Xe)!=="svelte-1fq45yi"&&(Xe.textContent=Kl),Pt=m(e),Ve=M(e,"P",{"data-svelte-h":!0}),h(Ve)!=="svelte-191fegd"&&(Ve.innerHTML=ea),Ot=m(e),w(Be.$$.fragment,e),Kt=m(e),We=M(e,"P",{"data-svelte-h":!0}),h(We)!=="svelte-bekdku"&&(We.innerHTML=ta),el=m(e),xe=M(e,"P",{"data-svelte-h":!0}),h(xe)!=="svelte-196wtq5"&&(xe.textContent=la),tl=m(e),w(Ne.$$.fragment,e),ll=m(e),ke=M(e,"P",{"data-svelte-h":!0}),h(ke)!=="svelte-7wz93i"&&(ke.textContent=aa),al=m(e),w(S.$$.fragment,e),sl=m(e),w(L.$$.fragment,e),nl=m(e),Fe=M(e,"P",{"data-svelte-h":!0}),h(Fe)!=="svelte-1x6in5t"&&(Fe.textContent=sa),il=m(e),w(H.$$.fragment,e),ol=m(e),w(Q.$$.fragment,e),rl=m(e),w(Ee.$$.fragment,e),pl=m(e),Ye=M(e,"P",{"data-svelte-h":!0}),h(Ye)!=="svelte-1bstso5"&&(Ye.innerHTML=na),ml=m(e),Ae=M(e,"P",{"data-svelte-h":!0}),h(Ae)!=="svelte-1sxi0tl"&&(Ae.innerHTML=ia),dl=m(e),w(ze.$$.fragment,e),cl=m(e),Se=M(e,"P",{"data-svelte-h":!0}),h(Se)!=="svelte-1stipnz"&&(Se.innerHTML=oa),fl=m(e),Le=M(e,"P",{"data-svelte-h":!0}),h(Le)!=="svelte-6dxtva"&&(Le.innerHTML=ra),ul=m(e),w(He.$$.fragment,e),Ml=m(e),Qe=M(e,"P",{"data-svelte-h":!0}),h(Qe)!=="svelte-187eih0"&&(Qe.innerHTML=pa),hl=m(e),De=M(e,"P",{"data-svelte-h":!0}),h(De)!=="svelte-3y6ob9"&&(De.textContent=ma),yl=m(e),w(qe.$$.fragment,e),wl=m(e),Pe=M(e,"P",{"data-svelte-h":!0}),h(Pe)!=="svelte-19tur1m"&&(Pe.textContent=da),bl=m(e),w(Oe.$$.fragment,e),Jl=m(e),Ke=M(e,"P",{"data-svelte-h":!0}),h(Ke)!=="svelte-5uztdo"&&(Ke.textContent=ca),Ul=m(e),et=M(e,"UL",{"data-svelte-h":!0}),h(et)!=="svelte-vlxh2r"&&(et.innerHTML=fa),Tl=m(e),w(D.$$.fragment,e),gl=m(e),w(tt.$$.fragment,e),_l=m(e),lt=M(e,"P",{"data-svelte-h":!0}),h(lt)!=="svelte-1qpzgdo"&&(lt.textContent=ua),$l=m(e),at=M(e,"UL",{"data-svelte-h":!0}),h(at)!=="svelte-1f59k5d"&&(at.innerHTML=Ma),jl=m(e),w(st.$$.fragment,e),Zl=m(e),nt=M(e,"P",{"data-svelte-h":!0}),h(nt)!=="svelte-1lopwzr"&&(nt.textContent=ha),Rl=m(e),it=M(e,"UL",{"data-svelte-h":!0}),h(it)!=="svelte-nczfxk"&&(it.innerHTML=ya),Cl=m(e),w(ot.$$.fragment,e),Il=m(e),rt=M(e,"P",{}),Za(rt).forEach(a),this.h()},h(){Ra(t,"name","hf:doc:metadata"),Ra(t,"content",ns)},m(e,l){Va(document.head,t),s(e,f,l),s(e,n,l),s(e,r,l),b(i,e,l),s(e,o,l),s(e,c,l),s(e,d,l),s(e,g,l),s(e,j,l),s(e,I,l),s(e,V,l),s(e,N,l),s(e,B,l),b(k,e,l),s(e,F,l),s(e,R,l),s(e,mt,l),b(E,e,l),s(e,dt,l),b(Y,e,l),s(e,ct,l),s(e,P,l),s(e,ft,l),b(O,e,l),s(e,ut,l),s(e,K,l),s(e,Mt,l),b(ee,e,l),s(e,ht,l),s(e,te,l),s(e,yt,l),b(le,e,l),s(e,wt,l),s(e,ae,l),s(e,bt,l),b(A,e,l),s(e,Jt,l),b(se,e,l),s(e,Ut,l),b(z,e,l),s(e,Tt,l),s(e,ne,l),s(e,gt,l),s(e,ie,l),s(e,_t,l),b(oe,e,l),s(e,$t,l),s(e,re,l),s(e,jt,l),s(e,pe,l),s(e,Zt,l),b(me,e,l),s(e,Rt,l),s(e,de,l),s(e,Ct,l),s(e,ce,l),s(e,It,l),b(fe,e,l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irty:l,ctx:e}),E.$set(wa);const ba={};l&2&&(ba.$$scope={dirty:l,ctx:e}),Y.$set(ba);const Ja={};l&2&&(Ja.$$scope={dirty:l,ctx:e}),A.$set(Ja);const Ua={};l&2&&(Ua.$$scope={dirty:l,ctx:e}),z.$set(Ua);const Ta={};l&2&&(Ta.$$scope={dirty:l,ctx:e}),S.$set(Ta);const ga={};l&2&&(ga.$$scope={dirty:l,ctx:e}),L.$set(ga);const _a={};l&2&&(_a.$$scope={dirty:l,ctx:e}),H.$set(_a);const $a={};l&2&&($a.$$scope={dirty:l,ctx:e}),Q.$set($a);const ja={};l&2&&(ja.$$scope={dirty:l,ctx:e}),D.$set(ja)},i(e){vl||(J(i.$$.fragment,e),J(k.$$.fragment,e),J(E.$$.fragment,e),J(Y.$$.fragment,e),J(O.$$.fragment,e),J(ee.$$.fragment,e),J(le.$$.fragment,e),J(A.$$.fragment,e),J(se.$$.fragment,e),J(z.$$.fragment,e),J(oe.$$.fragment,e),J(me.$$.fragment,e),J(fe.$$.fragment,e),J(ue.$$.fragment,e),J(ye.$$.fragment,e),J(we.$$.fragment,e),J(Je.$$.fragment,e),J(Ue.$$.fragment,e),J($e.$$.fragment,e),J(Ze.$$.fragment,e),J(Ce.$$.fragment,e),J(Ge.$$.fragment,e),J(Be.$$.fragment,e),J(Ne.$$.fragment,e),J(S.$$.fragment,e),J(L.$$.fragment,e),J(H.$$.fragment,e),J(Q.$$.fragment,e),J(Ee.$$.fragment,e),J(ze.$$.fragment,e),J(He.$$.fragment,e),J(qe.$$.fragment,e),J(Oe.$$.fragment,e),J(D.$$.fragment,e),J(tt.$$.fragment,e),J(st.$$.fragment,e),J(ot.$$.fragment,e),vl=!0)},o(e){U(i.$$.fragment,e),U(k.$$.fragment,e),U(E.$$.fragment,e),U(Y.$$.fragment,e),U(O.$$.fragment,e),U(ee.$$.fragment,e),U(le.$$.fragment,e),U(A.$$.fragment,e),U(se.$$.fragment,e),U(z.$$.fragment,e),U(oe.$$.fragment,e),U(me.$$.fragment,e),U(fe.$$.fragment,e),U(ue.$$.fragment,e),U(ye.$$.fragment,e),U(we.$$.fragment,e),U(Je.$$.fragment,e),U(Ue.$$.fragment,e),U($e.$$.fragment,e),U(Ze.$$.fragment,e),U(Ce.$$.fragment,e),U(Ge.$$.fragment,e),U(Be.$$.fragment,e),U(Ne.$$.fragment,e),U(S.$$.fragment,e),U(L.$$.fragment,e),U(H.$$.fragment,e),U(Q.$$.fragment,e),U(Ee.$$.fragment,e),U(ze.$$.fragment,e),U(He.$$.fragment,e),U(qe.$$.fragment,e),U(Oe.$$.fragment,e),U(D.$$.fragment,e),U(tt.$$.fragment,e),U(st.$$.fragment,e),U(ot.$$.fragment,e),vl=!1},d(e){e&&(a(f),a(n),a(r),a(o),a(c),a(d),a(g),a(j),a(I),a(V),a(N),a(B),a(F),a(R),a(mt),a(dt),a(ct),a(P),a(ft),a(ut),a(K),a(Mt),a(ht),a(te),a(yt),a(wt),a(ae),a(bt),a(Jt),a(Ut),a(Tt),a(ne),a(gt),a(ie),a(_t),a($t),a(re),a(jt),a(pe),a(Zt),a(Rt),a(de),a(Ct),a(ce),a(It),a(vt),a(Gt),a(Me),a(Xt),a(he),a(Vt),a(Bt),a(Wt),a(be),a(xt),a(Nt),a(kt),a(Te),a(Ft),a(ge),a(Et),a(_e),a(Yt),a(At),a(je),a(zt),a(St),a(Re),a(Lt),a(Ht),a(Ie),a(Qt),a(ve),a(Dt),a(qt),a(Xe),a(Pt),a(Ve),a(Ot),a(Kt),a(We),a(el),a(xe),a(tl),a(ll),a(ke),a(al),a(sl),a(nl),a(Fe),a(il),a(ol),a(rl),a(pl),a(Ye),a(ml),a(Ae),a(dl),a(cl),a(Se),a(fl),a(Le),a(ul),a(Ml),a(Qe),a(hl),a(De),a(yl),a(wl),a(Pe),a(bl),a(Jl),a(Ke),a(Ul),a(et),a(Tl),a(gl),a(_l),a(lt),a($l),a(at),a(jl),a(Zl),a(nt),a(Rl),a(it),a(Cl),a(Il),a(rt)),a(t),T(i,e),T(k,e),T(E,e),T(Y,e),T(O,e),T(ee,e),T(le,e),T(A,e),T(se,e),T(z,e),T(oe,e),T(me,e),T(fe,e),T(ue,e),T(ye,e),T(we,e),T(Je,e),T(Ue,e),T($e,e),T(Ze,e),T(Ce,e),T(Ge,e),T(Be,e),T(Ne,e),T(S,e),T(L,e),T(H,e),T(Q,e),T(Ee,e),T(ze,e),T(He,e),T(qe,e),T(Oe,e),T(D,e),T(tt,e),T(st,e),T(ot,e)}}}const ns='{"title":"DreamBooth","local":"dreambooth","sections":[{"title":"Script parameters","local":"script-parameters","sections":[{"title":"Min-SNR weighting","local":"min-snr-weighting","sections":[],"depth":3},{"title":"Prior preservation loss","local":"prior-preservation-loss","sections":[],"depth":3},{"title":"Train text encoder","local":"train-text-encoder","sections":[],"depth":3}],"depth":2},{"title":"Training script","local":"training-script","sections":[],"depth":2},{"title":"Launch the script","local":"launch-the-script","sections":[],"depth":2},{"title":"LoRA","local":"lora","sections":[],"depth":2},{"title":"Stable Diffusion XL","local":"stable-diffusion-xl","sections":[],"depth":2},{"title":"DeepFloyd IF","local":"deepfloyd-if","sections":[{"title":"Training tips","local":"training-tips","sections":[],"depth":3}],"depth":2},{"title":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function is($){return Ia(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class fs extends va{constructor(t){super(),Ga(this,t,is,ss,Ca,{})}}export{fs as component};
