import{s as Pl,o as Kl,n as W}from"../chunks/scheduler.182ea377.js";import{S as Ol,i as ea,g as f,s as o,r as h,A as ta,h as u,f as a,c as r,j as Dl,u as M,x as $,k as ql,y as la,a as n,v as y,d as b,t as w,w as g}from"../chunks/index.abf12888.js";import{T as ol}from"../chunks/Tip.230e2334.js";import{C as Z}from"../chunks/CodeBlock.57fe6e13.js";import{H as I,E as aa}from"../chunks/EditOnGithub.9b8e78e4.js";import{H as rl,a as N}from"../chunks/HfOption.fc88c804.js";function sa(U){let l,m;return l=new Z({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/dreambooth
pip install -r requirements.txt`,wrap:!1}}),{c(){h(l.$$.fragment)},l(s){M(l.$$.fragment,s)},m(s,c){y(l,s,c),m=!0},p:W,i(s){m||(b(l.$$.fragment,s),m=!0)},o(s){w(l.$$.fragment,s),m=!1},d(s){g(l,s)}}}function na(U){let l,m;return l=new Z({props:{code:"Y2QlMjBleGFtcGxlcyUyRmRyZWFtYm9vdGglMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/dreambooth
pip install -r requirements_flax.txt`,wrap:!1}}),{c(){h(l.$$.fragment)},l(s){M(l.$$.fragment,s)},m(s,c){y(l,s,c),m=!0},p:W,i(s){m||(b(l.$$.fragment,s),m=!0)},o(s){w(l.$$.fragment,s),m=!1},d(s){g(l,s)}}}function ia(U){let l,m,s,c;return l=new N({props:{id:"installation",option:"PyTorch",$$slots:{default:[sa]},$$scope:{ctx:U}}}),s=new N({props:{id:"installation",option:"Flax",$$slots:{default:[na]},$$scope:{ctx:U}}}),{c(){h(l.$$.fragment),m=o(),h(s.$$.fragment)},l(i){M(l.$$.fragment,i),m=r(i),M(s.$$.fragment,i)},m(i,p){y(l,i,p),n(i,m,p),y(s,i,p),c=!0},p(i,p){const d={};p&2&&(d.$$scope={dirty:p,ctx:i}),l.$set(d);const _={};p&2&&(_.$$scope={dirty:p,ctx:i}),s.$set(_)},i(i){c||(b(l.$$.fragment,i),b(s.$$.fragment,i),c=!0)},o(i){w(l.$$.fragment,i),w(s.$$.fragment,i),c=!1},d(i){i&&a(m),g(l,i),g(s,i)}}}function oa(U){let l,m='🤗 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(){l=f("p"),l.innerHTML=m},l(s){l=u(s,"P",{"data-svelte-h":!0}),$(l)!=="svelte-1qbiqsn"&&(l.innerHTML=m)},m(s,c){n(s,l,c)},p:W,d(s){s&&a(l)}}}function ra(U){let l,m='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(){l=f("p"),l.innerHTML=m},l(s){l=u(s,"P",{"data-svelte-h":!0}),$(l)!=="svelte-ag3huc"&&(l.innerHTML=m)},m(s,c){n(s,l,c)},p:W,d(s){s&&a(l)}}}function pa(U){let l,m='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(){l=f("p"),l.innerHTML=m},l(s){l=u(s,"P",{"data-svelte-h":!0}),$(l)!=="svelte-1gadrly"&&(l.innerHTML=m)},m(s,c){n(s,l,c)},p:W,d(s){s&&a(l)}}}function ma(U){let l,m="On a 16GB GPU, you can use bitsandbytes 8-bit optimizer and gradient checkpointing to help you train a DreamBooth model. Install bitsandbytes:",s,c,i,p,d="Then, add the following parameter to your training command:",_,j,C;return c=new Z({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcw==",highlighted:"pip install bitsandbytes",wrap:!1}}),j=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2NoZWNrcG9pbnRpbmclMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUM=",highlighted:`accelerate launch train_dreambooth.py \\
  --gradient_checkpointing \\
  --use_8bit_adam \\`,wrap:!1}}),{c(){l=f("p"),l.textContent=m,s=o(),h(c.$$.fragment),i=o(),p=f("p"),p.textContent=d,_=o(),h(j.$$.fragment)},l(T){l=u(T,"P",{"data-svelte-h":!0}),$(l)!=="svelte-fd1675"&&(l.textContent=m),s=r(T),M(c.$$.fragment,T),i=r(T),p=u(T,"P",{"data-svelte-h":!0}),$(p)!=="svelte-1rkm1uq"&&(p.textContent=d),_=r(T),M(j.$$.fragment,T)},m(T,v){n(T,l,v),n(T,s,v),y(c,T,v),n(T,i,v),n(T,p,v),n(T,_,v),y(j,T,v),C=!0},p:W,i(T){C||(b(c.$$.fragment,T),b(j.$$.fragment,T),C=!0)},o(T){w(c.$$.fragment,T),w(j.$$.fragment,T),C=!1},d(T){T&&(a(l),a(s),a(i),a(p),a(_)),g(c,T),g(j,T)}}}function ca(U){let l,m="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.",s,c,i;return c=new Z({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(){l=f("p"),l.innerHTML=m,s=o(),h(c.$$.fragment)},l(p){l=u(p,"P",{"data-svelte-h":!0}),$(l)!=="svelte-13zq302"&&(l.innerHTML=m),s=r(p),M(c.$$.fragment,p)},m(p,d){n(p,l,d),n(p,s,d),y(c,p,d),i=!0},p:W,i(p){i||(b(c.$$.fragment,p),i=!0)},o(p){w(c.$$.fragment,p),i=!1},d(p){p&&(a(l),a(s)),g(c,p)}}}function da(U){let l,m='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.',s,c,i="Run the following command to configure your 🤗 Accelerate environment:",p,d,_,j,C='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.',T,v,x='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.',Q,X,B="bitsandbytes 8-bit optimizers don’t seem to be compatible with DeepSpeed at the moment.",D,R,k="That’s it! You don’t need to add any additional parameters to your training command.",V;return d=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),{c(){l=f("p"),l.innerHTML=m,s=o(),c=f("p"),c.textContent=i,p=o(),h(d.$$.fragment),_=o(),j=f("p"),j.innerHTML=C,T=o(),v=f("p"),v.innerHTML=x,Q=o(),X=f("p"),X.textContent=B,D=o(),R=f("p"),R.textContent=k},l(J){l=u(J,"P",{"data-svelte-h":!0}),$(l)!=="svelte-5k52bm"&&(l.innerHTML=m),s=r(J),c=u(J,"P",{"data-svelte-h":!0}),$(c)!=="svelte-1fx999v"&&(c.textContent=i),p=r(J),M(d.$$.fragment,J),_=r(J),j=u(J,"P",{"data-svelte-h":!0}),$(j)!=="svelte-wvaz2k"&&(j.innerHTML=C),T=r(J),v=u(J,"P",{"data-svelte-h":!0}),$(v)!=="svelte-14m6rf5"&&(v.innerHTML=x),Q=r(J),X=u(J,"P",{"data-svelte-h":!0}),$(X)!=="svelte-z8cdsf"&&(X.textContent=B),D=r(J),R=u(J,"P",{"data-svelte-h":!0}),$(R)!=="svelte-lwtx0u"&&(R.textContent=k)},m(J,G){n(J,l,G),n(J,s,G),n(J,c,G),n(J,p,G),y(d,J,G),n(J,_,G),n(J,j,G),n(J,T,G),n(J,v,G),n(J,Q,G),n(J,X,G),n(J,D,G),n(J,R,G),V=!0},p:W,i(J){V||(b(d.$$.fragment,J),V=!0)},o(J){w(d.$$.fragment,J),V=!1},d(J){J&&(a(l),a(s),a(c),a(p),a(_),a(j),a(T),a(v),a(Q),a(X),a(D),a(R)),g(d,J)}}}function fa(U){let l,m,s,c,i,p;return l=new N({props:{id:"gpu-select",option:"16GB",$$slots:{default:[ma]},$$scope:{ctx:U}}}),s=new N({props:{id:"gpu-select",option:"12GB",$$slots:{default:[ca]},$$scope:{ctx:U}}}),i=new N({props:{id:"gpu-select",option:"8GB",$$slots:{default:[da]},$$scope:{ctx:U}}}),{c(){h(l.$$.fragment),m=o(),h(s.$$.fragment),c=o(),h(i.$$.fragment)},l(d){M(l.$$.fragment,d),m=r(d),M(s.$$.fragment,d),c=r(d),M(i.$$.fragment,d)},m(d,_){y(l,d,_),n(d,m,_),y(s,d,_),n(d,c,_),y(i,d,_),p=!0},p(d,_){const j={};_&2&&(j.$$scope={dirty:_,ctx:d}),l.$set(j);const C={};_&2&&(C.$$scope={dirty:_,ctx:d}),s.$set(C);const T={};_&2&&(T.$$scope={dirty:_,ctx:d}),i.$set(T)},i(d){p||(b(l.$$.fragment,d),b(s.$$.fragment,d),b(i.$$.fragment,d),p=!0)},o(d){w(l.$$.fragment,d),w(s.$$.fragment,d),w(i.$$.fragment,d),p=!1},d(d){d&&(a(m),a(c)),g(l,d),g(s,d),g(i,d)}}}function ua(U){let l,m;return l=new Z({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(){h(l.$$.fragment)},l(s){M(l.$$.fragment,s)},m(s,c){y(l,s,c),m=!0},p:W,i(s){m||(b(l.$$.fragment,s),m=!0)},o(s){w(l.$$.fragment,s),m=!1},d(s){g(l,s)}}}function ha(U){let l,m;return l=new Z({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(){h(l.$$.fragment)},l(s){M(l.$$.fragment,s)},m(s,c){y(l,s,c),m=!0},p:W,i(s){m||(b(l.$$.fragment,s),m=!0)},o(s){w(l.$$.fragment,s),m=!1},d(s){g(l,s)}}}function Ma(U){let l,m,s,c;return l=new N({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[ua]},$$scope:{ctx:U}}}),s=new N({props:{id:"training-inference",option:"Flax",$$slots:{default:[ha]},$$scope:{ctx:U}}}),{c(){h(l.$$.fragment),m=o(),h(s.$$.fragment)},l(i){M(l.$$.fragment,i),m=r(i),M(s.$$.fragment,i)},m(i,p){y(l,i,p),n(i,m,p),y(s,i,p),c=!0},p(i,p){const d={};p&2&&(d.$$scope={dirty:p,ctx:i}),l.$set(d);const _={};p&2&&(_.$$scope={dirty:p,ctx:i}),s.$set(_)},i(i){c||(b(l.$$.fragment,i),b(s.$$.fragment,i),c=!0)},o(i){w(l.$$.fragment,i),w(s.$$.fragment,i),c=!1},d(i){i&&a(m),g(l,i),g(s,i)}}}function ya(U){let l,m="Can’t wait to try your model for inference before training is complete? 🤭 Make sure you have the latest version of 🤗 Accelerate installed.",s,c,i;return c=new Z({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(){l=f("p"),l.textContent=m,s=o(),h(c.$$.fragment)},l(p){l=u(p,"P",{"data-svelte-h":!0}),$(l)!=="svelte-fduxd"&&(l.textContent=m),s=r(p),M(c.$$.fragment,p)},m(p,d){n(p,l,d),n(p,s,d),y(c,p,d),i=!0},p:W,i(p){i||(b(c.$$.fragment,p),i=!0)},o(p){w(c.$$.fragment,p),i=!1},d(p){p&&(a(l),a(s)),g(c,p)}}}function ba(U){let l,m;return l=new Z({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(){h(l.$$.fragment)},l(s){M(l.$$.fragment,s)},m(s,c){y(l,s,c),m=!0},p:W,i(s){m||(b(l.$$.fragment,s),m=!0)},o(s){w(l.$$.fragment,s),m=!1},d(s){g(l,s)}}}function wa(U){let l,m;return l=new Z({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdGgtdG8teW91ci10cmFpbmVkLW1vZGVsJTIyJTJDJTIwZHR5cGUlM0RqYXgubnVtcHkuYmZsb2F0MTYpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjBpbiUyMGElMjBidWNrZXQlMjIlMEFwcm5nX3NlZWQlMjAlM0QlMjBqYXgucmFuZG9tLlBSTkdLZXkoMCklMEFudW1faW5mZXJlbmNlX3N0ZXBzJTIwJTNEJTIwNTAlMEElMEFudW1fc2FtcGxlcyUyMCUzRCUyMGpheC5kZXZpY2VfY291bnQoKSUwQXByb21wdCUyMCUzRCUyMG51bV9zYW1wbGVzJTIwKiUyMCU1QnByb21wdCU1RCUwQXByb21wdF9pZHMlMjAlM0QlMjBwaXBlbGluZS5wcmVwYXJlX2lucHV0cyhwcm9tcHQpJTBBJTBBJTIzJTIwc2hhcmQlMjBpbnB1dHMlMjBhbmQlMjBybmclMEFwYXJhbXMlMjAlM0QlMjByZXBsaWNhdGUocGFyYW1zKSUwQXBybmdfc2VlZCUyMCUzRCUyMGpheC5yYW5kb20uc3BsaXQocHJuZ19zZWVkJTJDJTIwamF4LmRldmljZV9jb3VudCgpKSUwQXByb21wdF9pZHMlMjAlM0QlMjBzaGFyZChwcm9tcHRfaWRzKSUwQSUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lKHByb21wdF9pZHMlMkMlMjBwYXJhbXMlMkMlMjBwcm5nX3NlZWQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTJDJTIwaml0JTNEVHJ1ZSkuaW1hZ2VzJTBBaW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUubnVtcHlfdG9fcGlsKG5wLmFzYXJyYXkoaW1hZ2VzLnJlc2hhcGUoKG51bV9zYW1wbGVzJTJDKSUyMCUyQiUyMGltYWdlcy5zaGFwZSU1Qi0zJTNBJTVEKSkpJTBBaW1hZ2Uuc2F2ZSglMjJkb2ctYnVja2V0LnBuZyUyMik=",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(){h(l.$$.fragment)},l(s){M(l.$$.fragment,s)},m(s,c){y(l,s,c),m=!0},p:W,i(s){m||(b(l.$$.fragment,s),m=!0)},o(s){w(l.$$.fragment,s),m=!1},d(s){g(l,s)}}}function ga(U){let l,m,s,c;return l=new N({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[ba]},$$scope:{ctx:U}}}),s=new N({props:{id:"training-inference",option:"Flax",$$slots:{default:[wa]},$$scope:{ctx:U}}}),{c(){h(l.$$.fragment),m=o(),h(s.$$.fragment)},l(i){M(l.$$.fragment,i),m=r(i),M(s.$$.fragment,i)},m(i,p){y(l,i,p),n(i,m,p),y(s,i,p),c=!0},p(i,p){const d={};p&2&&(d.$$scope={dirty:p,ctx:i}),l.$set(d);const _={};p&2&&(_.$$scope={dirty:p,ctx:i}),s.$set(_)},i(i){c||(b(l.$$.fragment,i),b(s.$$.fragment,i),c=!0)},o(i){w(l.$$.fragment,i),w(s.$$.fragment,i),c=!1},d(i){i&&a(m),g(l,i),g(s,i)}}}function $a(U){let l,m,s,c,i,p,d,_='<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.',j,C,T='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.',v,x,Q='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.',X,B,D="Before running the script, make sure you install the library from source:",R,k,V,J,G="Navigate to the example folder with the training script and install the required dependencies for the script you’re using:",Pe,Y,Ke,F,Oe,q,pl="Initialize an 🤗 Accelerate environment:",et,P,tt,K,ml="To setup a default 🤗 Accelerate environment without choosing any configurations:",lt,O,at,ee,cl="Or if your environment doesn’t support an interactive shell, like a notebook, you can use:",st,te,nt,le,dl='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.',it,E,ot,ae,rt,z,pt,se,fl='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.',mt,ne,ul="For example, to train in the bf16 format:",ct,ie,dt,oe,hl="Some basic and important parameters to know and specify are:",ft,re,Ml="<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>",ut,pe,ht,me,yl='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.',Mt,ce,bl="Add the <code>--snr_gamma</code> parameter and set it to the recommended value of 5.0:",yt,de,bt,fe,wt,ue,wl="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.",gt,he,gl="<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>",$t,Me,Jt,ye,Ut,be,$l="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:",Tt,we,_t,ge,Zt,$e,Jl="DreamBooth comes with its own dataset classes:",jt,Je,Ul='<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>',vt,Ue,Tl='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:',Ct,Te,Gt,_e,_l='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>:',Wt,Ze,Xt,je,Zl='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>:',Rt,ve,xt,Ce,jl='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.',Bt,Ge,vl='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.',kt,We,It,Xe,Cl="You’re now ready to launch the training script! 🚀",Vt,Re,Gl='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).',Nt,xe,Yt,Be,Wl="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.",Ft,ke,Xl="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:",Et,Ie,zt,Ve,Rl="One more thing before you launch the script! Depending on the GPU you have, you may need to enable certain optimizations to train DreamBooth.",Ht,H,Lt,L,At,Ne,xl="Once training is complete, you can use your newly trained model for inference!",St,A,Qt,S,Dt,Ye,qt,Fe,Bl='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.',Pt,Ee,kl='The LoRA training script is discussed in more detail in the <a href="lora">LoRA training</a> guide.',Kt,ze,Ot,He,Il='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.',el,Le,Vl='The SDXL training script is discussed in more detail in the <a href="sdxl">SDXL training</a> guide.',tl,Ae,ll,Se,Nl="Congratulations on training your DreamBooth model! To learn more about how to use your new model, the following guide may be helpful:",al,Qe,Yl='<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>',sl,De,nl,qe,il;return i=new I({props:{title:"DreamBooth",local:"dreambooth",headingTag:"h1"}}),k=new Z({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}}),Y=new rl({props:{id:"installation",options:["PyTorch","Flax"],$$slots:{default:[ia]},$$scope:{ctx:U}}}),F=new ol({props:{$$slots:{default:[oa]},$$scope:{ctx:U}}}),P=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),O=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),te=new Z({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}}),E=new ol({props:{$$slots:{default:[ra]},$$scope:{ctx:U}}}),ae=new I({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),z=new ol({props:{warning:!0,$$slots:{default:[pa]},$$scope:{ctx:U}}}),ie=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmJmMTYlMjI=",highlighted:`accelerate launch train_dreambooth.py \\
    --mixed_precision=<span class="hljs-string">&quot;bf16&quot;</span>`,wrap:!1}}),pe=new I({props:{title:"Min-SNR weighting",local:"min-snr-weighting",headingTag:"h3"}}),de=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXNucl9nYW1tYSUzRDUuMA==",highlighted:`accelerate launch train_dreambooth.py \\
  --snr_gamma=5.0`,wrap:!1}}),fe=new I({props:{title:"Prior preservation loss",local:"prior-preservation-loss",headingTag:"h3"}}),Me=new Z({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}}),ye=new I({props:{title:"Train text encoder",local:"train-text-encoder",headingTag:"h3"}}),we=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXRyYWluX3RleHRfZW5jb2Rlcg==",highlighted:`accelerate launch train_dreambooth.py \\
  --train_text_encoder`,wrap:!1}}),ge=new I({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),Te=new Z({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 Z({props:{code:"JTIzJTIwTG9hZCUyMHRoZSUyMHRva2VuaXplciUwQWlmJTIwYXJncy50b2tlbml6ZXJfbmFtZSUzQSUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUyMCUzRCUyMEF1dG9Ub2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGFyZ3MudG9rZW5pemVyX25hbWUlMkMlMjByZXZpc2lvbiUzRGFyZ3MucmV2aXNpb24lMkMlMjB1c2VfZmFzdCUzREZhbHNlKSUwQWVsaWYlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNBJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTIwJTNEJTIwQXV0b1Rva2VuaXplci5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIwJTIwJTIwJTIwYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHN1YmZvbGRlciUzRCUyMnRva2VuaXplciUyMiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUyQyUwQSUyMCUyMCUyMCUyMCUyMCUyMCUyMCUyMHVzZV9mYXN0JTNERmFsc2UlMkMlMEElMjAlMjAlMjAlMjApJTBBJTBBJTIzJTIwTG9hZCUyMHNjaGVkdWxlciUyMGFuZCUyMG1vZGVscyUwQW5vaXNlX3NjaGVkdWxlciUyMCUzRCUyMEREUE1TY2hlZHVsZXIuZnJvbV9wcmV0cmFpbmVkKGFyZ3MucHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglMkMlMjBzdWJmb2xkZXIlM0QlMjJzY2hlZHVsZXIlMjIpJTBBdGV4dF9lbmNvZGVyJTIwJTNEJTIwdGV4dF9lbmNvZGVyX2Nscy5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUyMHN1YmZvbGRlciUzRCUyMnRleHRfZW5jb2RlciUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSklMEElMEFpZiUyMG1vZGVsX2hhc192YWUoYXJncyklM0ElMEElMjAlMjAlMjAlMjB2YWUlMjAlM0QlMjBBdXRvZW5jb2RlcktMLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydmFlJTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBJTIwJTIwJTIwJTIwKSUwQWVsc2UlM0ElMEElMjAlMjAlMjAlMjB2YWUlMjAlM0QlMjBOb25lJTBBJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydW5ldCUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSk=",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}}),ve=new Z({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}}),We=new I({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),xe=new Z({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}}),Ie=new Z({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}}),H=new rl({props:{id:"gpu-select",options:["16GB","12GB","8GB"],$$slots:{default:[fa]},$$scope:{ctx:U}}}),L=new rl({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Ma]},$$scope:{ctx:U}}}),A=new ol({props:{$$slots:{default:[ya]},$$scope:{ctx:U}}}),S=new rl({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[ga]},$$scope:{ctx:U}}}),Ye=new I({props:{title:"LoRA",local:"lora",headingTag:"h2"}}),ze=new I({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),Ae=new I({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),De=new aa({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/dreambooth.md"}}),{c(){l=f("meta"),m=o(),s=f("p"),c=o(),h(i.$$.fragment),p=o(),d=f("p"),d.innerHTML=_,j=o(),C=f("p"),C.innerHTML=T,v=o(),x=f("p"),x.innerHTML=Q,X=o(),B=f("p"),B.textContent=D,R=o(),h(k.$$.fragment),V=o(),J=f("p"),J.textContent=G,Pe=o(),h(Y.$$.fragment),Ke=o(),h(F.$$.fragment),Oe=o(),q=f("p"),q.textContent=pl,et=o(),h(P.$$.fragment),tt=o(),K=f("p"),K.textContent=ml,lt=o(),h(O.$$.fragment),at=o(),ee=f("p"),ee.textContent=cl,st=o(),h(te.$$.fragment),nt=o(),le=f("p"),le.innerHTML=dl,it=o(),h(E.$$.fragment),ot=o(),h(ae.$$.fragment),rt=o(),h(z.$$.fragment),pt=o(),se=f("p"),se.innerHTML=fl,mt=o(),ne=f("p"),ne.textContent=ul,ct=o(),h(ie.$$.fragment),dt=o(),oe=f("p"),oe.textContent=hl,ft=o(),re=f("ul"),re.innerHTML=Ml,ut=o(),h(pe.$$.fragment),ht=o(),me=f("p"),me.innerHTML=yl,Mt=o(),ce=f("p"),ce.innerHTML=bl,yt=o(),h(de.$$.fragment),bt=o(),h(fe.$$.fragment),wt=o(),ue=f("p"),ue.textContent=wl,gt=o(),he=f("ul"),he.innerHTML=gl,$t=o(),h(Me.$$.fragment),Jt=o(),h(ye.$$.fragment),Ut=o(),be=f("p"),be.textContent=$l,Tt=o(),h(we.$$.fragment),_t=o(),h(ge.$$.fragment),Zt=o(),$e=f("p"),$e.textContent=Jl,jt=o(),Je=f("ul"),Je.innerHTML=Ul,vt=o(),Ue=f("p"),Ue.innerHTML=Tl,Ct=o(),h(Te.$$.fragment),Gt=o(),_e=f("p"),_e.innerHTML=_l,Wt=o(),h(Ze.$$.fragment),Xt=o(),je=f("p"),je.innerHTML=Zl,Rt=o(),h(ve.$$.fragment),xt=o(),Ce=f("p"),Ce.innerHTML=jl,Bt=o(),Ge=f("p"),Ge.innerHTML=vl,kt=o(),h(We.$$.fragment),It=o(),Xe=f("p"),Xe.textContent=Cl,Vt=o(),Re=f("p"),Re.innerHTML=Gl,Nt=o(),h(xe.$$.fragment),Yt=o(),Be=f("p"),Be.innerHTML=Wl,Ft=o(),ke=f("p"),ke.textContent=Xl,Et=o(),h(Ie.$$.fragment),zt=o(),Ve=f("p"),Ve.textContent=Rl,Ht=o(),h(H.$$.fragment),Lt=o(),h(L.$$.fragment),At=o(),Ne=f("p"),Ne.textContent=xl,St=o(),h(A.$$.fragment),Qt=o(),h(S.$$.fragment),Dt=o(),h(Ye.$$.fragment),qt=o(),Fe=f("p"),Fe.innerHTML=Bl,Pt=o(),Ee=f("p"),Ee.innerHTML=kl,Kt=o(),h(ze.$$.fragment),Ot=o(),He=f("p"),He.innerHTML=Il,el=o(),Le=f("p"),Le.innerHTML=Vl,tl=o(),h(Ae.$$.fragment),ll=o(),Se=f("p"),Se.textContent=Nl,al=o(),Qe=f("ul"),Qe.innerHTML=Yl,sl=o(),h(De.$$.fragment),nl=o(),qe=f("p"),this.h()},l(e){const t=ta("svelte-u9bgzb",document.head);l=u(t,"META",{name:!0,content:!0}),t.forEach(a),m=r(e),s=u(e,"P",{}),Dl(s).forEach(a),c=r(e),M(i.$$.fragment,e),p=r(e),d=u(e,"P",{"data-svelte-h":!0}),$(d)!=="svelte-yz6jri"&&(d.innerHTML=_),j=r(e),C=u(e,"P",{"data-svelte-h":!0}),$(C)!=="svelte-en2tmp"&&(C.innerHTML=T),v=r(e),x=u(e,"P",{"data-svelte-h":!0}),$(x)!=="svelte-1ol1kd9"&&(x.innerHTML=Q),X=r(e),B=u(e,"P",{"data-svelte-h":!0}),$(B)!=="svelte-l7dm2q"&&(B.textContent=D),R=r(e),M(k.$$.fragment,e),V=r(e),J=u(e,"P",{"data-svelte-h":!0}),$(J)!=="svelte-1nancx8"&&(J.textContent=G),Pe=r(e),M(Y.$$.fragment,e),Ke=r(e),M(F.$$.fragment,e),Oe=r(e),q=u(e,"P",{"data-svelte-h":!0}),$(q)!=="svelte-60q53m"&&(q.textContent=pl),et=r(e),M(P.$$.fragment,e),tt=r(e),K=u(e,"P",{"data-svelte-h":!0}),$(K)!=="svelte-di6juu"&&(K.textContent=ml),lt=r(e),M(O.$$.fragment,e),at=r(e),ee=u(e,"P",{"data-svelte-h":!0}),$(ee)!=="svelte-tsz4qp"&&(ee.textContent=cl),st=r(e),M(te.$$.fragment,e),nt=r(e),le=u(e,"P",{"data-svelte-h":!0}),$(le)!=="svelte-1fkfdql"&&(le.innerHTML=dl),it=r(e),M(E.$$.fragment,e),ot=r(e),M(ae.$$.fragment,e),rt=r(e),M(z.$$.fragment,e),pt=r(e),se=u(e,"P",{"data-svelte-h":!0}),$(se)!=="svelte-gb0mrm"&&(se.innerHTML=fl),mt=r(e),ne=u(e,"P",{"data-svelte-h":!0}),$(ne)!=="svelte-1aa3zni"&&(ne.textContent=ul),ct=r(e),M(ie.$$.fragment,e),dt=r(e),oe=u(e,"P",{"data-svelte-h":!0}),$(oe)!=="svelte-1ug35mp"&&(oe.textContent=hl),ft=r(e),re=u(e,"UL",{"data-svelte-h":!0}),$(re)!=="svelte-pohxvr"&&(re.innerHTML=Ml),ut=r(e),M(pe.$$.fragment,e),ht=r(e),me=u(e,"P",{"data-svelte-h":!0}),$(me)!=="svelte-isitbv"&&(me.innerHTML=yl),Mt=r(e),ce=u(e,"P",{"data-svelte-h":!0}),$(ce)!=="svelte-tp3kp"&&(ce.innerHTML=bl),yt=r(e),M(de.$$.fragment,e),bt=r(e),M(fe.$$.fragment,e),wt=r(e),ue=u(e,"P",{"data-svelte-h":!0}),$(ue)!=="svelte-1oc83h6"&&(ue.textContent=wl),gt=r(e),he=u(e,"UL",{"data-svelte-h":!0}),$(he)!=="svelte-1e6kqrs"&&(he.innerHTML=gl),$t=r(e),M(Me.$$.fragment,e),Jt=r(e),M(ye.$$.fragment,e),Ut=r(e),be=u(e,"P",{"data-svelte-h":!0}),$(be)!=="svelte-n5xd96"&&(be.textContent=$l),Tt=r(e),M(we.$$.fragment,e),_t=r(e),M(ge.$$.fragment,e),Zt=r(e),$e=u(e,"P",{"data-svelte-h":!0}),$($e)!=="svelte-76mqwg"&&($e.textContent=Jl),jt=r(e),Je=u(e,"UL",{"data-svelte-h":!0}),$(Je)!=="svelte-1sge1kf"&&(Je.innerHTML=Ul),vt=r(e),Ue=u(e,"P",{"data-svelte-h":!0}),$(Ue)!=="svelte-c9697n"&&(Ue.innerHTML=Tl),Ct=r(e),M(Te.$$.fragment,e),Gt=r(e),_e=u(e,"P",{"data-svelte-h":!0}),$(_e)!=="svelte-e2s2vm"&&(_e.innerHTML=_l),Wt=r(e),M(Ze.$$.fragment,e),Xt=r(e),je=u(e,"P",{"data-svelte-h":!0}),$(je)!=="svelte-s7uwdj"&&(je.innerHTML=Zl),Rt=r(e),M(ve.$$.fragment,e),xt=r(e),Ce=u(e,"P",{"data-svelte-h":!0}),$(Ce)!=="svelte-4ixpqk"&&(Ce.innerHTML=jl),Bt=r(e),Ge=u(e,"P",{"data-svelte-h":!0}),$(Ge)!=="svelte-6gmbd2"&&(Ge.innerHTML=vl),kt=r(e),M(We.$$.fragment,e),It=r(e),Xe=u(e,"P",{"data-svelte-h":!0}),$(Xe)!=="svelte-1fq45yi"&&(Xe.textContent=Cl),Vt=r(e),Re=u(e,"P",{"data-svelte-h":!0}),$(Re)!=="svelte-191fegd"&&(Re.innerHTML=Gl),Nt=r(e),M(xe.$$.fragment,e),Yt=r(e),Be=u(e,"P",{"data-svelte-h":!0}),$(Be)!=="svelte-bekdku"&&(Be.innerHTML=Wl),Ft=r(e),ke=u(e,"P",{"data-svelte-h":!0}),$(ke)!=="svelte-196wtq5"&&(ke.textContent=Xl),Et=r(e),M(Ie.$$.fragment,e),zt=r(e),Ve=u(e,"P",{"data-svelte-h":!0}),$(Ve)!=="svelte-7wz93i"&&(Ve.textContent=Rl),Ht=r(e),M(H.$$.fragment,e),Lt=r(e),M(L.$$.fragment,e),At=r(e),Ne=u(e,"P",{"data-svelte-h":!0}),$(Ne)!=="svelte-1x6in5t"&&(Ne.textContent=xl),St=r(e),M(A.$$.fragment,e),Qt=r(e),M(S.$$.fragment,e),Dt=r(e),M(Ye.$$.fragment,e),qt=r(e),Fe=u(e,"P",{"data-svelte-h":!0}),$(Fe)!=="svelte-1bstso5"&&(Fe.innerHTML=Bl),Pt=r(e),Ee=u(e,"P",{"data-svelte-h":!0}),$(Ee)!=="svelte-1sxi0tl"&&(Ee.innerHTML=kl),Kt=r(e),M(ze.$$.fragment,e),Ot=r(e),He=u(e,"P",{"data-svelte-h":!0}),$(He)!=="svelte-1stipnz"&&(He.innerHTML=Il),el=r(e),Le=u(e,"P",{"data-svelte-h":!0}),$(Le)!=="svelte-6dxtva"&&(Le.innerHTML=Vl),tl=r(e),M(Ae.$$.fragment,e),ll=r(e),Se=u(e,"P",{"data-svelte-h":!0}),$(Se)!=="svelte-1lopwzr"&&(Se.textContent=Nl),al=r(e),Qe=u(e,"UL",{"data-svelte-h":!0}),$(Qe)!=="svelte-nczfxk"&&(Qe.innerHTML=Yl),sl=r(e),M(De.$$.fragment,e),nl=r(e),qe=u(e,"P",{}),Dl(qe).forEach(a),this.h()},h(){ql(l,"name","hf:doc:metadata"),ql(l,"content",Ja)},m(e,t){la(document.head,l),n(e,m,t),n(e,s,t),n(e,c,t),y(i,e,t),n(e,p,t),n(e,d,t),n(e,j,t),n(e,C,t),n(e,v,t),n(e,x,t),n(e,X,t),n(e,B,t),n(e,R,t),y(k,e,t),n(e,V,t),n(e,J,t),n(e,Pe,t),y(Y,e,t),n(e,Ke,t),y(F,e,t),n(e,Oe,t),n(e,q,t),n(e,et,t),y(P,e,t),n(e,tt,t),n(e,K,t),n(e,lt,t),y(O,e,t),n(e,at,t),n(e,ee,t),n(e,st,t),y(te,e,t),n(e,nt,t),n(e,le,t),n(e,it,t),y(E,e,t),n(e,ot,t),y(ae,e,t),n(e,rt,t),y(z,e,t),n(e,pt,t),n(e,se,t),n(e,mt,t),n(e,ne,t),n(e,ct,t),y(ie,e,t),n(e,dt,t),n(e,oe,t),n(e,ft,t),n(e,re,t),n(e,ut,t),y(pe,e,t),n(e,ht,t),n(e,me,t),n(e,Mt,t),n(e,ce,t),n(e,yt,t),y(de,e,t),n(e,bt,t),y(fe,e,t),n(e,wt,t),n(e,ue,t),n(e,gt,t),n(e,he,t),n(e,$t,t),y(Me,e,t),n(e,Jt,t),y(ye,e,t),n(e,Ut,t),n(e,be,t),n(e,Tt,t),y(we,e,t),n(e,_t,t),y(ge,e,t),n(e,Zt,t),n(e,$e,t),n(e,jt,t),n(e,Je,t),n(e,vt,t),n(e,Ue,t),n(e,Ct,t),y(Te,e,t),n(e,Gt,t),n(e,_e,t),n(e,Wt,t),y(Ze,e,t),n(e,Xt,t),n(e,je,t),n(e,Rt,t),y(ve,e,t),n(e,xt,t),n(e,Ce,t),n(e,Bt,t),n(e,Ge,t),n(e,kt,t),y(We,e,t),n(e,It,t),n(e,Xe,t),n(e,Vt,t),n(e,Re,t),n(e,Nt,t),y(xe,e,t),n(e,Yt,t),n(e,Be,t),n(e,Ft,t),n(e,ke,t),n(e,Et,t),y(Ie,e,t),n(e,zt,t),n(e,Ve,t),n(e,Ht,t),y(H,e,t),n(e,Lt,t),y(L,e,t),n(e,At,t),n(e,Ne,t),n(e,St,t),y(A,e,t),n(e,Qt,t),y(S,e,t),n(e,Dt,t),y(Ye,e,t),n(e,qt,t),n(e,Fe,t),n(e,Pt,t),n(e,Ee,t),n(e,Kt,t),y(ze,e,t),n(e,Ot,t),n(e,He,t),n(e,el,t),n(e,Le,t),n(e,tl,t),y(Ae,e,t),n(e,ll,t),n(e,Se,t),n(e,al,t),n(e,Qe,t),n(e,sl,t),y(De,e,t),n(e,nl,t),n(e,qe,t),il=!0},p(e,[t]){const Fl={};t&2&&(Fl.$$scope={dirty:t,ctx:e}),Y.$set(Fl);const El={};t&2&&(El.$$scope={dirty:t,ctx:e}),F.$set(El);const zl={};t&2&&(zl.$$scope={dirty:t,ctx:e}),E.$set(zl);const Hl={};t&2&&(Hl.$$scope={dirty:t,ctx:e}),z.$set(Hl);const Ll={};t&2&&(Ll.$$scope={dirty:t,ctx:e}),H.$set(Ll);const Al={};t&2&&(Al.$$scope={dirty:t,ctx:e}),L.$set(Al);const Sl={};t&2&&(Sl.$$scope={dirty:t,ctx:e}),A.$set(Sl);const Ql={};t&2&&(Ql.$$scope={dirty:t,ctx:e}),S.$set(Ql)},i(e){il||(b(i.$$.fragment,e),b(k.$$.fragment,e),b(Y.$$.fragment,e),b(F.$$.fragment,e),b(P.$$.fragment,e),b(O.$$.fragment,e),b(te.$$.fragment,e),b(E.$$.fragment,e),b(ae.$$.fragment,e),b(z.$$.fragment,e),b(ie.$$.fragment,e),b(pe.$$.fragment,e),b(de.$$.fragment,e),b(fe.$$.fragment,e),b(Me.$$.fragment,e),b(ye.$$.fragment,e),b(we.$$.fragment,e),b(ge.$$.fragment,e),b(Te.$$.fragment,e),b(Ze.$$.fragment,e),b(ve.$$.fragment,e),b(We.$$.fragment,e),b(xe.$$.fragment,e),b(Ie.$$.fragment,e),b(H.$$.fragment,e),b(L.$$.fragment,e),b(A.$$.fragment,e),b(S.$$.fragment,e),b(Ye.$$.fragment,e),b(ze.$$.fragment,e),b(Ae.$$.fragment,e),b(De.$$.fragment,e),il=!0)},o(e){w(i.$$.fragment,e),w(k.$$.fragment,e),w(Y.$$.fragment,e),w(F.$$.fragment,e),w(P.$$.fragment,e),w(O.$$.fragment,e),w(te.$$.fragment,e),w(E.$$.fragment,e),w(ae.$$.fragment,e),w(z.$$.fragment,e),w(ie.$$.fragment,e),w(pe.$$.fragment,e),w(de.$$.fragment,e),w(fe.$$.fragment,e),w(Me.$$.fragment,e),w(ye.$$.fragment,e),w(we.$$.fragment,e),w(ge.$$.fragment,e),w(Te.$$.fragment,e),w(Ze.$$.fragment,e),w(ve.$$.fragment,e),w(We.$$.fragment,e),w(xe.$$.fragment,e),w(Ie.$$.fragment,e),w(H.$$.fragment,e),w(L.$$.fragment,e),w(A.$$.fragment,e),w(S.$$.fragment,e),w(Ye.$$.fragment,e),w(ze.$$.fragment,e),w(Ae.$$.fragment,e),w(De.$$.fragment,e),il=!1},d(e){e&&(a(m),a(s),a(c),a(p),a(d),a(j),a(C),a(v),a(x),a(X),a(B),a(R),a(V),a(J),a(Pe),a(Ke),a(Oe),a(q),a(et),a(tt),a(K),a(lt),a(at),a(ee),a(st),a(nt),a(le),a(it),a(ot),a(rt),a(pt),a(se),a(mt),a(ne),a(ct),a(dt),a(oe),a(ft),a(re),a(ut),a(ht),a(me),a(Mt),a(ce),a(yt),a(bt),a(wt),a(ue),a(gt),a(he),a($t),a(Jt),a(Ut),a(be),a(Tt),a(_t),a(Zt),a($e),a(jt),a(Je),a(vt),a(Ue),a(Ct),a(Gt),a(_e),a(Wt),a(Xt),a(je),a(Rt),a(xt),a(Ce),a(Bt),a(Ge),a(kt),a(It),a(Xe),a(Vt),a(Re),a(Nt),a(Yt),a(Be),a(Ft),a(ke),a(Et),a(zt),a(Ve),a(Ht),a(Lt),a(At),a(Ne),a(St),a(Qt),a(Dt),a(qt),a(Fe),a(Pt),a(Ee),a(Kt),a(Ot),a(He),a(el),a(Le),a(tl),a(ll),a(Se),a(al),a(Qe),a(sl),a(nl),a(qe)),a(l),g(i,e),g(k,e),g(Y,e),g(F,e),g(P,e),g(O,e),g(te,e),g(E,e),g(ae,e),g(z,e),g(ie,e),g(pe,e),g(de,e),g(fe,e),g(Me,e),g(ye,e),g(we,e),g(ge,e),g(Te,e),g(Ze,e),g(ve,e),g(We,e),g(xe,e),g(Ie,e),g(H,e),g(L,e),g(A,e),g(S,e),g(Ye,e),g(ze,e),g(Ae,e),g(De,e)}}}const Ja='{"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":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function Ua(U){return Kl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ga extends Ol{constructor(l){super(),ea(this,l,Ua,$a,Pl,{})}}export{Ga as component};
