import{s as Ga,o as Ia,n as C}from"../chunks/scheduler.8c3d61f6.js";import{S as Ca,i as va,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 b,x as h,k as Ra,y as Va,a as s,v as w,d as U,t as T,w as J}from"../chunks/index.da70eac4.js";import{T as vl}from"../chunks/Tip.1d9b8c37.js";import{C as G}from"../chunks/CodeBlock.00a903b3.js";import{H as W,E as Ba}from"../chunks/EditOnGithub.1e64e623.js";import{H as pt,a as X}from"../chunks/HfOption.6ab18950.js";function Wa($){let t,f;return t=new G({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){b(t.$$.fragment,n)},m(n,r){w(t,n,r),f=!0},p:C,i(n){f||(U(t.$$.fragment,n),f=!0)},o(n){T(t.$$.fragment,n),f=!1},d(n){J(t,n)}}}function xa($){let t,f;return t=new G({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){b(t.$$.fragment,n)},m(n,r){w(t,n,r),f=!0},p:C,i(n){f||(U(t.$$.fragment,n),f=!0)},o(n){T(t.$$.fragment,n),f=!1},d(n){J(t,n)}}}function ka($){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){b(t.$$.fragment,i),f=m(i),b(n.$$.fragment,i)},m(i,o){w(t,i,o),s(i,f,o),w(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||(U(t.$$.fragment,i),U(n.$$.fragment,i),r=!0)},o(i){T(t.$$.fragment,i),T(n.$$.fragment,i),r=!1},d(i){i&&a(f),J(t,i),J(n,i)}}}function Na($){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:C,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:C,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:C,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 G({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcw==",highlighted:"pip install bitsandbytes",wrap:!1}}),d=new G({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),b(r.$$.fragment,Z),i=m(Z),o=M(Z,"P",{"data-svelte-h":!0}),h(o)!=="svelte-1rkm1uq"&&(o.textContent=c),_=m(Z),b(d.$$.fragment,Z)},m(Z,j){s(Z,t,j),s(Z,n,j),w(r,Z,j),s(Z,i,j),s(Z,o,j),s(Z,_,j),w(d,Z,j),g=!0},p:C,i(Z){g||(U(r.$$.fragment,Z),U(d.$$.fragment,Z),g=!0)},o(Z){T(r.$$.fragment,Z),T(d.$$.fragment,Z),g=!1},d(Z){Z&&(a(t),a(n),a(i),a(o),a(_)),J(r,Z),J(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 G({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),b(r.$$.fragment,o)},m(o,c){s(o,t,c),s(o,n,c),w(r,o,c),i=!0},p:C,i(o){i||(U(r.$$.fragment,o),i=!0)},o(o){T(r.$$.fragment,o),i=!1},d(o){o&&(a(t),a(n)),J(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,k="bitsandbytes 8-bit optimizers don’t seem to be compatible with DeepSpeed at the moment.",q,B,N="That’s it! You don’t need to add any additional parameters to your training command.",F;return c=new G({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=k,q=p(),B=u("p"),B.textContent=N},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),b(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=k),q=m(R),B=M(R,"P",{"data-svelte-h":!0}),h(B)!=="svelte-lwtx0u"&&(B.textContent=N)},m(R,v){s(R,t,v),s(R,n,v),s(R,r,v),s(R,o,v),w(c,R,v),s(R,_,v),s(R,d,v),s(R,Z,v),s(R,j,v),s(R,x,v),s(R,V,v),s(R,q,v),s(R,B,v),F=!0},p:C,i(R){F||(U(c.$$.fragment,R),F=!0)},o(R){T(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)),J(c,R)}}}function La($){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){b(t.$$.fragment,c),f=m(c),b(n.$$.fragment,c),r=m(c),b(i.$$.fragment,c)},m(c,_){w(t,c,_),s(c,f,_),w(n,c,_),s(c,r,_),w(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||(U(t.$$.fragment,c),U(n.$$.fragment,c),U(i.$$.fragment,c),o=!0)},o(c){T(t.$$.fragment,c),T(n.$$.fragment,c),T(i.$$.fragment,c),o=!1},d(c){c&&(a(f),a(r)),J(t,c),J(n,c),J(i,c)}}}function Sa($){let t,f;return t=new G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMi4lMkZkb2clMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b19zYXZlZF9tb2RlbCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0cmFpbl9kcmVhbWJvb3RoLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0QxJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENWUtNiUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDQwMCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;stable-diffusion-v1-5/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){b(t.$$.fragment,n)},m(n,r){w(t,n,r),f=!0},p:C,i(n){f||(U(t.$$.fragment,n),f=!0)},o(n){T(t.$$.fragment,n),f=!1},d(n){J(t,n)}}}function Ha($){let t,f;return t=new G({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){b(t.$$.fragment,n)},m(n,r){w(t,n,r),f=!0},p:C,i(n){f||(U(t.$$.fragment,n),f=!0)},o(n){T(t.$$.fragment,n),f=!1},d(n){J(t,n)}}}function Qa($){let t,f,n,r;return t=new X({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[Sa]},$$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){b(t.$$.fragment,i),f=m(i),b(n.$$.fragment,i)},m(i,o){w(t,i,o),s(i,f,o),w(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||(U(t.$$.fragment,i),U(n.$$.fragment,i),r=!0)},o(i){T(t.$$.fragment,i),T(n.$$.fragment,i),r=!1},d(i){i&&a(f),J(t,i),J(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 G({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ0xJUFRleHRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZtb2RlbCUyRmNoZWNrcG9pbnQtMTAwJTJGdW5ldCUyMiklMEElMEElMjMlMjBpZiUyMHlvdSUyMGhhdmUlMjB0cmFpbmVkJTIwd2l0aCUyMCU2MC0tYXJncy50cmFpbl90ZXh0X2VuY29kZXIlNjAlMjBtYWtlJTIwc3VyZSUyMHRvJTIwYWxzbyUyMGxvYWQlMjB0aGUlMjB0ZXh0JTIwZW5jb2RlciUwQXRleHRfZW5jb2RlciUyMCUzRCUyMENMSVBUZXh0TW9kZWwuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdGglMkZ0byUyRm1vZGVsJTJGY2hlY2twb2ludC0xMDAlMkZjaGVja3BvaW50LTEwMCUyRnRleHRfZW5jb2RlciUyMiklMEElMEFwaXBlbGluZSUyMCUzRCUyMERpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB1bmV0JTNEdW5ldCUyQyUyMHRleHRfZW5jb2RlciUzRHRleHRfZW5jb2RlciUyQyUyMGR0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUwQSkudG8oJTIyY3VkYSUyMiklMEElMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKCUyMkElMjBwaG90byUyMG9mJTIwc2tzJTIwZG9nJTIwaW4lMjBhJTIwYnVja2V0JTIyJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwJTJDJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUpLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmRvZy1idWNrZXQucG5nJTIyKQ==",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;stable-diffusion-v1-5/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),b(r.$$.fragment,o)},m(o,c){s(o,t,c),s(o,n,c),w(r,o,c),i=!0},p:C,i(o){i||(U(r.$$.fragment,o),i=!0)},o(o){T(r.$$.fragment,o),i=!1},d(o){o&&(a(t),a(n)),J(r,o)}}}function qa($){let t,f;return t=new G({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){b(t.$$.fragment,n)},m(n,r){w(t,n,r),f=!0},p:C,i(n){f||(U(t.$$.fragment,n),f=!0)},o(n){T(t.$$.fragment,n),f=!1},d(n){J(t,n)}}}function Pa($){let t,f;return t=new G({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnBhd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yMik=",highlighted:`<span class="hljs-keyword">import</span> jax
<span class="hljs-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){b(t.$$.fragment,n)},m(n,r){w(t,n,r),f=!0},p:C,i(n){f||(U(t.$$.fragment,n),f=!0)},o(n){T(t.$$.fragment,n),f=!1},d(n){J(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){b(t.$$.fragment,i),f=m(i),b(n.$$.fragment,i)},m(i,o){w(t,i,o),s(i,f,o),w(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||(U(t.$$.fragment,i),U(n.$$.fragment,i),r=!0)},o(i){T(t.$$.fragment,i),T(n.$$.fragment,i),r=!1},d(i){i&&a(f),J(t,i),J(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 G({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),b(r.$$.fragment,o)},m(o,c){s(o,t,c),s(o,n,c),w(r,o,c),i=!0},p:C,i(o){i||(U(r.$$.fragment,o),i=!0)},o(o){T(r.$$.fragment,o),i=!1},d(o){o&&(a(t),a(n)),J(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 G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFweXRob24lMjB0cmFpbl9kcmVhbWJvb3RoX2xvcmEucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXJlcG9ydF90byUyMHdhbmRiJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWluc3RhbmN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HM=",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`,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),b(c.$$.fragment,d)},m(d,g){s(d,t,g),s(d,n,g),s(d,r,g),s(d,o,g),w(c,d,g),_=!0},p:C,i(d){_||(U(c.$$.fragment,d),_=!0)},o(d){T(c.$$.fragment,d),_=!1},d(d){d&&(a(t),a(n),a(r),a(o)),J(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 G({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),b(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),w(g,j,I),Z=!0},p:C,i(j){Z||(U(g.$$.fragment,j),Z=!0)},o(j){T(g.$$.fragment,j),Z=!1},d(j){j&&(a(t),a(n),a(r),a(o),a(c),a(d)),J(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 G({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2Vf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XJfbWF4X2xlbmd0aCUzRDc3JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS12YWxpZGF0aW9uX2ltYWdlcyUyMCUyNFZBTElEQVRJT05fSU1BR0VTJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19sYWJlbHNfY29uZGl0aW9uaW5nJTIwdGltZXN0ZXBzJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",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),b(c.$$.fragment,d)},m(d,g){s(d,t,g),s(d,n,g),s(d,r,g),s(d,o,g),w(c,d,g),_=!0},p:C,i(d){_||(U(c.$$.fragment,d),_=!0)},o(d){T(c.$$.fragment,d),_=!1},d(d){d&&(a(t),a(n),a(r),a(o)),J(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){b(t.$$.fragment,d),f=m(d),b(n.$$.fragment,d),r=m(d),b(i.$$.fragment,d),o=m(d),b(c.$$.fragment,d)},m(d,g){w(t,d,g),s(d,f,g),w(n,d,g),s(d,r,g),w(i,d,g),s(d,o,g),w(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){_||(U(t.$$.fragment,d),U(n.$$.fragment,d),U(i.$$.fragment,d),U(c.$$.fragment,d),_=!0)},o(d){T(t.$$.fragment,d),T(n.$$.fragment,d),T(i.$$.fragment,d),T(c.$$.fragment,d),_=!1},d(d){d&&(a(f),a(r),a(o)),J(t,d),J(n,d),J(i,d),J(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,k,q="Before running the script, make sure you install the library from source:",B,N,F,R,v="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,bt,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.',wt,A,Ut,se,Tt,z,Jt,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,kl="For example, to train in the bf16 format:",_t,oe,$t,re,Nl="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.',Gt,ce,Yl="Add the <code>--snr_gamma</code> parameter and set it to the recommended value of 5.0:",It,fe,Ct,ue,vt,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,be,Wt,we,Ll="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,Ue,kt,Te,Nt,Je,Sl="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,Lt,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>:',St,Ge,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,Ce,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,ve,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,ke,ll,Ne,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,L,sl,S,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,Le,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,Se,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,bl,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.",wl,Oe,Ul,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:",Tl,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>',Jl,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>',Gl,ot,Il,rt,Cl;return i=new W({props:{title:"DreamBooth",local:"dreambooth",headingTag:"h1"}}),N=new G({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:[ka]},$$scope:{ctx:$}}}),Y=new vl({props:{$$slots:{default:[Na]},$$scope:{ctx:$}}}),O=new G({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),ee=new G({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),le=new G({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 vl({props:{$$slots:{default:[Fa]},$$scope:{ctx:$}}}),se=new W({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),z=new vl({props:{warning:!0,$$slots:{default:[Ea]},$$scope:{ctx:$}}}),oe=new G({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 G({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 G({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}}),be=new W({props:{title:"Train text encoder",local:"train-text-encoder",headingTag:"h3"}}),Ue=new G({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXRyYWluX3RleHRfZW5jb2Rlcg==",highlighted:`accelerate launch train_dreambooth.py \\
  --train_text_encoder`,wrap:!1}}),Te=new W({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),$e=new G({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;promp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wJTIwJTIwJTIwYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSklMEElMEFpZiUyMG1vZGVsX2hhc192YWUoYXJncyklM0ElMEElMjAlMjAlMjAlMjB2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydmFlJTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBJTIwJTIwJTIwJTIwKSUwQWVsc2UlM0ElMEElMjAlMjAlMjAlMjB2YWUlMjAlM0QlMjBOb25lJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydW5ldCUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSk=",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}}),Ge=new G({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}}),ve=new W({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),Be=new G({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}}),ke=new G({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}}),L=new pt({props:{id:"gpu-select",options:["16GB","12GB","8GB"],$$slots:{default:[La]},$$scope:{ctx:$}}}),S=new pt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Qa]},$$scope:{ctx:$}}}),H=new vl({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 G({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 G({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(),k=u("p"),k.textContent=q,B=p(),y(N.$$.fragment),F=p(),R=u("p"),R.textContent=v,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),bt=p(),ae=u("p"),ae.innerHTML=Wl,wt=p(),y(A.$$.fragment),Ut=p(),y(se.$$.fragment),Tt=p(),y(z.$$.fragment),Jt=p(),ne=u("p"),ne.innerHTML=xl,gt=p(),ie=u("p"),ie.textContent=kl,_t=p(),y(oe.$$.fragment),$t=p(),re=u("p"),re.textContent=Nl,jt=p(),pe=u("ul"),pe.innerHTML=Fl,Zt=p(),y(me.$$.fragment),Rt=p(),de=u("p"),de.innerHTML=El,Gt=p(),ce=u("p"),ce.innerHTML=Yl,It=p(),y(fe.$$.fragment),Ct=p(),y(ue.$$.fragment),vt=p(),Me=u("p"),Me.textContent=Al,Xt=p(),he=u("ul"),he.innerHTML=zl,Vt=p(),y(ye.$$.fragment),Bt=p(),y(be.$$.fragment),Wt=p(),we=u("p"),we.textContent=Ll,xt=p(),y(Ue.$$.fragment),kt=p(),y(Te.$$.fragment),Nt=p(),Je=u("p"),Je.textContent=Sl,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),Lt=p(),Re=u("p"),Re.innerHTML=ql,St=p(),y(Ge.$$.fragment),Ht=p(),Ie=u("p"),Ie.innerHTML=Pl,Qt=p(),Ce=u("p"),Ce.innerHTML=Ol,Dt=p(),y(ve.$$.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(ke.$$.fragment),ll=p(),Ne=u("p"),Ne.textContent=aa,al=p(),y(L.$$.fragment),sl=p(),y(S.$$.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(),Le=u("p"),Le.innerHTML=oa,fl=p(),Se=u("p"),Se.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),bl=p(),Pe=u("p"),Pe.textContent=da,wl=p(),y(Oe.$$.fragment),Ul=p(),Ke=u("p"),Ke.textContent=ca,Tl=p(),et=u("ul"),et.innerHTML=fa,Jl=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,Gl=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),b(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),k=M(e,"P",{"data-svelte-h":!0}),h(k)!=="svelte-l7dm2q"&&(k.textContent=q),B=m(e),b(N.$$.fragment,e),F=m(e),R=M(e,"P",{"data-svelte-h":!0}),h(R)!=="svelte-1nancx8"&&(R.textContent=v),mt=m(e),b(E.$$.fragment,e),dt=m(e),b(Y.$$.fragment,e),ct=m(e),P=M(e,"P",{"data-svelte-h":!0}),h(P)!=="svelte-60q53m"&&(P.textContent=Xl),ft=m(e),b(O.$$.fragment,e),ut=m(e),K=M(e,"P",{"data-svelte-h":!0}),h(K)!=="svelte-di6juu"&&(K.textContent=Vl),Mt=m(e),b(ee.$$.fragment,e),ht=m(e),te=M(e,"P",{"data-svelte-h":!0}),h(te)!=="svelte-tsz4qp"&&(te.textContent=Bl),yt=m(e),b(le.$$.fragment,e),bt=m(e),ae=M(e,"P",{"data-svelte-h":!0}),h(ae)!=="svelte-1fkfdql"&&(ae.innerHTML=Wl),wt=m(e),b(A.$$.fragment,e),Ut=m(e),b(se.$$.fragment,e),Tt=m(e),b(z.$$.fragment,e),Jt=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=kl),_t=m(e),b(oe.$$.fragment,e),$t=m(e),re=M(e,"P",{"data-svelte-h":!0}),h(re)!=="svelte-1ug35mp"&&(re.textContent=Nl),jt=m(e),pe=M(e,"UL",{"data-svelte-h":!0}),h(pe)!=="svelte-pohxvr"&&(pe.innerHTML=Fl),Zt=m(e),b(me.$$.fragment,e),Rt=m(e),de=M(e,"P",{"data-svelte-h":!0}),h(de)!=="svelte-isitbv"&&(de.innerHTML=El),Gt=m(e),ce=M(e,"P",{"data-svelte-h":!0}),h(ce)!=="svelte-tp3kp"&&(ce.innerHTML=Yl),It=m(e),b(fe.$$.fragment,e),Ct=m(e),b(ue.$$.fragment,e),vt=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),b(ye.$$.fragment,e),Bt=m(e),b(be.$$.fragment,e),Wt=m(e),we=M(e,"P",{"data-svelte-h":!0}),h(we)!=="svelte-n5xd96"&&(we.textContent=Ll),xt=m(e),b(Ue.$$.fragment,e),kt=m(e),b(Te.$$.fragment,e),Nt=m(e),Je=M(e,"P",{"data-svelte-h":!0}),h(Je)!=="svelte-76mqwg"&&(Je.textContent=Sl),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),b($e.$$.fragment,e),At=m(e),je=M(e,"P",{"data-svelte-h":!0}),h(je)!=="svelte-e2s2vm"&&(je.innerHTML=Dl),zt=m(e),b(Ze.$$.fragment,e),Lt=m(e),Re=M(e,"P",{"data-svelte-h":!0}),h(Re)!=="svelte-s7uwdj"&&(Re.innerHTML=ql),St=m(e),b(Ge.$$.fragment,e),Ht=m(e),Ie=M(e,"P",{"data-svelte-h":!0}),h(Ie)!=="svelte-4ixpqk"&&(Ie.innerHTML=Pl),Qt=m(e),Ce=M(e,"P",{"data-svelte-h":!0}),h(Ce)!=="svelte-6gmbd2"&&(Ce.innerHTML=Ol),Dt=m(e),b(ve.$$.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),b(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),b(ke.$$.fragment,e),ll=m(e),Ne=M(e,"P",{"data-svelte-h":!0}),h(Ne)!=="svelte-7wz93i"&&(Ne.textContent=aa),al=m(e),b(L.$$.fragment,e),sl=m(e),b(S.$$.fragment,e),nl=m(e),Fe=M(e,"P",{"data-svelte-h":!0}),h(Fe)!=="svelte-1x6in5t"&&(Fe.textContent=sa),il=m(e),b(H.$$.fragment,e),ol=m(e),b(Q.$$.fragment,e),rl=m(e),b(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),b(ze.$$.fragment,e),cl=m(e),Le=M(e,"P",{"data-svelte-h":!0}),h(Le)!=="svelte-1stipnz"&&(Le.innerHTML=oa),fl=m(e),Se=M(e,"P",{"data-svelte-h":!0}),h(Se)!=="svelte-6dxtva"&&(Se.innerHTML=ra),ul=m(e),b(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),b(qe.$$.fragment,e),bl=m(e),Pe=M(e,"P",{"data-svelte-h":!0}),h(Pe)!=="svelte-19tur1m"&&(Pe.textContent=da),wl=m(e),b(Oe.$$.fragment,e),Ul=m(e),Ke=M(e,"P",{"data-svelte-h":!0}),h(Ke)!=="svelte-5uztdo"&&(Ke.textContent=ca),Tl=m(e),et=M(e,"UL",{"data-svelte-h":!0}),h(et)!=="svelte-vlxh2r"&&(et.innerHTML=fa),Jl=m(e),b(D.$$.fragment,e),gl=m(e),b(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),b(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),Gl=m(e),b(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),w(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,k,l),s(e,B,l),w(N,e,l),s(e,F,l),s(e,R,l),s(e,mt,l),w(E,e,l),s(e,dt,l),w(Y,e,l),s(e,ct,l),s(e,P,l),s(e,ft,l),w(O,e,l),s(e,ut,l),s(e,K,l),s(e,Mt,l),w(ee,e,l),s(e,ht,l),s(e,te,l),s(e,yt,l),w(le,e,l),s(e,bt,l),s(e,ae,l),s(e,wt,l),w(A,e,l),s(e,Ut,l),w(se,e,l),s(e,Tt,l),w(z,e,l),s(e,Jt,l),s(e,ne,l),s(e,gt,l),s(e,ie,l),s(e,_t,l),w(oe,e,l),s(e,$t,l),s(e,re,l),s(e,jt,l),s(e,pe,l),s(e,Zt,l),w(me,e,l),s(e,Rt,l),s(e,de,l),s(e,Gt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},p(e,[l]){const ba={};l&2&&(ba.$$scope={dirty:l,ctx:e}),E.$set(ba);const wa={};l&2&&(wa.$$scope={dirty:l,ctx:e}),Y.$set(wa);const Ua={};l&2&&(Ua.$$scope={dirty:l,ctx:e}),A.$set(Ua);const Ta={};l&2&&(Ta.$$scope={dirty:l,ctx:e}),z.$set(Ta);const Ja={};l&2&&(Ja.$$scope={dirty:l,ctx:e}),L.$set(Ja);const ga={};l&2&&(ga.$$scope={dirty:l,ctx:e}),S.$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){Cl||(U(i.$$.fragment,e),U(N.$$.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(be.$$.fragment,e),U(Ue.$$.fragment,e),U(Te.$$.fragment,e),U($e.$$.fragment,e),U(Ze.$$.fragment,e),U(Ge.$$.fragment,e),U(ve.$$.fragment,e),U(Be.$$.fragment,e),U(ke.$$.fragment,e),U(L.$$.fragment,e),U(S.$$.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),Cl=!0)},o(e){T(i.$$.fragment,e),T(N.$$.fragment,e),T(E.$$.fragment,e),T(Y.$$.fragment,e),T(O.$$.fragment,e),T(ee.$$.fragment,e),T(le.$$.fragment,e),T(A.$$.fragment,e),T(se.$$.fragment,e),T(z.$$.fragment,e),T(oe.$$.fragment,e),T(me.$$.fragment,e),T(fe.$$.fragment,e),T(ue.$$.fragment,e),T(ye.$$.fragment,e),T(be.$$.fragment,e),T(Ue.$$.fragment,e),T(Te.$$.fragment,e),T($e.$$.fragment,e),T(Ze.$$.fragment,e),T(Ge.$$.fragment,e),T(ve.$$.fragment,e),T(Be.$$.fragment,e),T(ke.$$.fragment,e),T(L.$$.fragment,e),T(S.$$.fragment,e),T(H.$$.fragment,e),T(Q.$$.fragment,e),T(Ee.$$.fragment,e),T(ze.$$.fragment,e),T(He.$$.fragment,e),T(qe.$$.fragment,e),T(Oe.$$.fragment,e),T(D.$$.fragment,e),T(tt.$$.fragment,e),T(st.$$.fragment,e),T(ot.$$.fragment,e),Cl=!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(k),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(bt),a(ae),a(wt),a(Ut),a(Tt),a(Jt),a(ne),a(gt),a(ie),a(_t),a($t),a(re),a(jt),a(pe),a(Zt),a(Rt),a(de),a(Gt),a(ce),a(It),a(Ct),a(vt),a(Me),a(Xt),a(he),a(Vt),a(Bt),a(Wt),a(we),a(xt),a(kt),a(Nt),a(Je),a(Ft),a(ge),a(Et),a(_e),a(Yt),a(At),a(je),a(zt),a(Lt),a(Re),a(St),a(Ht),a(Ie),a(Qt),a(Ce),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(Ne),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(Le),a(fl),a(Se),a(ul),a(Ml),a(Qe),a(hl),a(De),a(yl),a(bl),a(Pe),a(wl),a(Ul),a(Ke),a(Tl),a(et),a(Jl),a(gl),a(_l),a(lt),a($l),a(at),a(jl),a(Zl),a(nt),a(Rl),a(it),a(Gl),a(Il),a(rt)),a(t),J(i,e),J(N,e),J(E,e),J(Y,e),J(O,e),J(ee,e),J(le,e),J(A,e),J(se,e),J(z,e),J(oe,e),J(me,e),J(fe,e),J(ue,e),J(ye,e),J(be,e),J(Ue,e),J(Te,e),J($e,e),J(Ze,e),J(Ge,e),J(ve,e),J(Be,e),J(ke,e),J(L,e),J(S,e),J(H,e),J(Q,e),J(Ee,e),J(ze,e),J(He,e),J(qe,e),J(Oe,e),J(D,e),J(tt,e),J(st,e),J(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 Ca{constructor(t){super(),va(this,t,is,ss,Ga,{})}}export{fs as component};
