import{s as mn,o as dn,n as S}from"../chunks/scheduler.182ea377.js";import{S as un,i as hn,g as p,s as n,r as m,A as fn,h as r,f as l,c as i,j as rn,u as d,x as M,k as Mn,y as Tn,a as s,v as u,d as h,t as f,w as T}from"../chunks/index.abf12888.js";import{T as cn}from"../chunks/Tip.230e2334.js";import{C as b}from"../chunks/CodeBlock.57fe6e13.js";import{F as Ds,M as St}from"../chunks/Markdown.7a59e0fd.js";import{H as g}from"../chunks/Heading.16916d63.js";function Un(_){let o,c='DreamBooth finetuning is very sensitive to hyperparameters and easy to overfit. We recommend you take a look at our <a href="https://huggingface.co/blog/dreambooth" rel="nofollow">in-depth analysis</a> with recommended settings for different subjects to help you choose the appropriate hyperparameters.';return{c(){o=p("p"),o.innerHTML=c},l(a){o=r(a,"P",{"data-svelte-h":!0}),M(o)!=="svelte-1ije7yy"&&(o.innerHTML=c)},m(a,U){s(a,o,U)},p:S,d(a){a&&l(o)}}}function Jn(_){let o,c="Set the <code>INSTANCE_DIR</code> environment variable to the path of the directory containing the dog images.",a,U,w="Specify the <code>MODEL_NAME</code> environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the <code>pretrained_model_name_or_path</code> argument. The <code>instance_prompt</code> argument is a text prompt that contains a unique identifier, such as <code>sks</code>, and the class the image belongs to, which in this example is <code>a photo of a sks dog</code>.",N,j,Z,R,C='Then you can launch the training script (you can find the full training script <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth.py" rel="nofollow">here</a>) with the following command:',X,$,v;return j=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwT1VUUFVUX0RJUiUzRCUyMnBhdGhfdG9fc2F2ZWRfbW9kZWwlMjI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>`,wrap:!1}}),$=new b({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0Q1ZS02JTIwJTVDJTBBJTIwJTIwLS1scl9zY2hlZHVsZXIlM0QlMjJjb25zdGFudCUyMiUyMCU1QyUwQSUyMCUyMC0tbHJfd2FybXVwX3N0ZXBzJTNEMCUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNENDAwJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --max_train_steps=400 \\
  --push_to_hub`,wrap:!1}}),{c(){o=p("p"),o.innerHTML=c,a=n(),U=p("p"),U.innerHTML=w,N=n(),m(j.$$.fragment),Z=n(),R=p("p"),R.innerHTML=C,X=n(),m($.$$.fragment)},l(J){o=r(J,"P",{"data-svelte-h":!0}),M(o)!=="svelte-87vqu3"&&(o.innerHTML=c),a=i(J),U=r(J,"P",{"data-svelte-h":!0}),M(U)!=="svelte-3hq69k"&&(U.innerHTML=w),N=i(J),d(j.$$.fragment,J),Z=i(J),R=r(J,"P",{"data-svelte-h":!0}),M(R)!=="svelte-gl6rb5"&&(R.innerHTML=C),X=i(J),d($.$$.fragment,J)},m(J,I){s(J,o,I),s(J,a,I),s(J,U,I),s(J,N,I),u(j,J,I),s(J,Z,I),s(J,R,I),s(J,X,I),u($,J,I),v=!0},p:S,i(J){v||(h(j.$$.fragment,J),h($.$$.fragment,J),v=!0)},o(J){f(j.$$.fragment,J),f($.$$.fragment,J),v=!1},d(J){J&&(l(o),l(a),l(U),l(N),l(Z),l(R),l(X)),T(j,J),T($,J)}}}function yn(_){let o,c;return o=new St({props:{$$slots:{default:[Jn]},$$scope:{ctx:_}}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p(a,U){const w={};U&2&&(w.$$scope={dirty:U,ctx:a}),o.$set(w)},i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function wn(_){let o,c='If you have access to TPUs or want to train even faster, you can try out the <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/train_dreambooth_flax.py" rel="nofollow">Flax training script</a>. The Flax training script doesn’t support gradient checkpointing or gradient accumulation, so you’ll need a GPU with at least 30GB of memory.',a,U,w="Before running the script, make sure you have the requirements installed:",N,j,Z,R,C="Specify the <code>MODEL_NAME</code> environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the <code>pretrained_model_name_or_path</code> argument. The <code>instance_prompt</code> argument is a text prompt that contains a unique identifier, such as <code>sks</code>, and the class the image belongs to, which in this example is <code>a photo of a sks dog</code>.",X,$,v="Now you can launch the training script with the following command:",J,I,B;return j=new b({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:"pip install -U -r requirements.txt",wrap:!1}}),I=new b({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(){o=p("p"),o.innerHTML=c,a=n(),U=p("p"),U.textContent=w,N=n(),m(j.$$.fragment),Z=n(),R=p("p"),R.innerHTML=C,X=n(),$=p("p"),$.textContent=v,J=n(),m(I.$$.fragment)},l(y){o=r(y,"P",{"data-svelte-h":!0}),M(o)!=="svelte-5xo10d"&&(o.innerHTML=c),a=i(y),U=r(y,"P",{"data-svelte-h":!0}),M(U)!=="svelte-4s2veb"&&(U.textContent=w),N=i(y),d(j.$$.fragment,y),Z=i(y),R=r(y,"P",{"data-svelte-h":!0}),M(R)!=="svelte-3hq69k"&&(R.innerHTML=C),X=i(y),$=r(y,"P",{"data-svelte-h":!0}),M($)!=="svelte-fw1ia1"&&($.textContent=v),J=i(y),d(I.$$.fragment,y)},m(y,V){s(y,o,V),s(y,a,V),s(y,U,V),s(y,N,V),u(j,y,V),s(y,Z,V),s(y,R,V),s(y,X,V),s(y,$,V),s(y,J,V),u(I,y,V),B=!0},p:S,i(y){B||(h(j.$$.fragment,y),h(I.$$.fragment,y),B=!0)},o(y){f(j.$$.fragment,y),f(I.$$.fragment,y),B=!1},d(y){y&&(l(o),l(a),l(U),l(N),l(Z),l(R),l(X),l($),l(J)),T(j,y),T(I,y)}}}function bn(_){let o,c;return o=new St({props:{$$slots:{default:[wn]},$$scope:{ctx:_}}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p(a,U){const w={};U&2&&(w.$$scope={dirty:U,ctx:a}),o.$set(w)},i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function _n(_){let o,c;return o=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aF90b19jbGFzc19pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b19zYXZlZF9tb2RlbCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0cmFpbl9kcmVhbWJvb3RoLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19kYXRhX2RpciUzRCUyNENMQVNTX0RJUiUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNE9VVFBVVF9ESVIlMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX3Byb21wdCUzRCUyMmElMjBwaG90byUyMG9mJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDVlLTYlMjAlNUMlMEElMjAlMjAtLWxyX3NjaGVkdWxlciUzRCUyMmNvbnN0YW50JTIyJTIwJTVDJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTNEMjAwJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0Q4MDAlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

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

python train_dreambooth_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --learning_rate=5e-6 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`,wrap:!1}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p:S,i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function In(_){let o,c;return o=new St({props:{$$slots:{default:[gn]},$$scope:{ctx:_}}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p(a,U){const w={};U&2&&(w.$$scope={dirty:U,ctx:a}),o.$set(w)},i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function Rn(_){let o,c="Training the text encoder requires additional memory and it won’t fit on a 16GB GPU. You’ll need at least 24GB VRAM to use this option.";return{c(){o=p("p"),o.textContent=c},l(a){o=r(a,"P",{"data-svelte-h":!0}),M(o)!=="svelte-1uh02te"&&(o.textContent=c)},m(a,U){s(a,o,U)},p:S,d(a){a&&l(o)}}}function $n(_){let o,c;return o=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aF90b19jbGFzc19pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElS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c19pbWFnZXMlM0QyMDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDgwMCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --train_text_encoder \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --use_8bit_adam \\
  --gradient_checkpointing \\
  --learning_rate=2e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`,wrap:!1}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p:S,i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function Vn(_){let o,c;return o=new St({props:{$$slots:{default:[$n]},$$scope:{ctx:_}}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p(a,U){const w={};U&2&&(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MiUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QyZS02JTIwJTVDJTBBJTIwJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTNEMjAwJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0Q4MDAlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;duongna/stable-diffusion-v1-4-flax&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path-to-class-images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

python train_dreambooth_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --train_text_encoder \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --learning_rate=2e-6 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`,wrap:!1}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p:S,i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function Nn(_){let o,c;return o=new St({props:{$$slots:{default:[vn]},$$scope:{ctx:_}}}),{c(){m(o.$$.fragment)},l(a){d(o.$$.fragment,a)},m(a,U){u(o,a,U),c=!0},p(a,U){const w={};U&2&&(w.$$scope={dirty:U,ctx:a}),o.$set(w)},i(a){c||(h(o.$$.fragment,a),c=!0)},o(a){f(o.$$.fragment,a),c=!1},d(a){T(o,a)}}}function Cn(_){let o,c,a,U,w,N,j,Z='<a href="https://arxiv.org/abs/2208.12242" rel="nofollow">DreamBooth</a> is a method to personalize text-to-image models like Stable Diffusion given just a few (3-5) images of a subject. It allows the model to generate contextualized images of the subject in different scenes, poses, and views.',R,C,X='<img src="https://dreambooth.github.io/DreamBooth_files/teaser_static.jpg" alt="Dreambooth examples from the project&#39;s blog"/>',$,v,J='Dreambooth examples from the <a href="https://dreambooth.github.io">project&#39;s blog.</a>',I,B,y='This guide will show you how to finetune DreamBooth with the <a href="https://huggingface.co/CompVis/stable-diffusion-v1-4" rel="nofollow"><code>CompVis/stable-diffusion-v1-4</code></a> model for various GPU sizes, and with Flax. All the training scripts for DreamBooth used in this guide can be found <a href="https://github.com/huggingface/diffusers/tree/main/examples/dreambooth" rel="nofollow">here</a> if you’re interested in digging deeper and seeing how things work.',V,k,Hs="Before running the scripts, make sure you install the library’s training dependencies. We also recommend installing 🧨 Diffusers from the <code>main</code> GitHub branch:",At,A,Lt,L,qs='xFormers is not part of the training requirements, but we recommend you <a href="../optimization/xformers">install</a> it if you can because it could make your training faster and less memory intensive.',Qt,Q,Ps='After all the dependencies have been set up, initialize a <a href="https://github.com/huggingface/accelerate/" rel="nofollow">🤗 Accelerate</a> environment with:',Yt,Y,zt,z,Os="To setup a default 🤗 Accelerate environment without choosing any configurations:",Dt,D,Ht,H,Ks="Or if your environment doesn’t support an interactive shell like a notebook, you can use:",qt,q,Pt,P,ea='Finally, download a <a href="https://huggingface.co/datasets/diffusers/dog-example" rel="nofollow">few images of a dog</a> to DreamBooth with:',Ot,O,Kt,K,ta='To use your own dataset, take a look at the <a href="create_dataset">Create a dataset for training</a> guide.',el,ee,tl,G,ll,E,sl,te,al,le,la='Prior preservation is used to avoid overfitting and language-drift (check out the <a href="https://arxiv.org/abs/2208.12242" rel="nofollow">paper</a> to learn more if you’re interested). For prior preservation, you use other images of the same class as part of the training process. The nice thing is that you can generate those images using the Stable Diffusion model itself! The training script will save the generated images to a local path you specify.',nl,se,sa="The authors recommend generating <code>num_epochs * num_samples</code> images for prior preservation. In most cases, 200-300 images work well.",il,W,ol,ae,pl,ne,aa='The script also allows you to finetune the <code>text_encoder</code> along with the <code>unet</code>. In our experiments (check out the <a href="https://huggingface.co/blog/dreambooth" rel="nofollow">Training Stable Diffusion with DreamBooth using 🧨 Diffusers</a> post for more details), this yields much better results, especially when generating images of faces.',rl,x,Ml,ie,na="Pass the <code>--train_text_encoder</code> argument to the training script to enable finetuning the <code>text_encoder</code> and <code>unet</code>:",cl,F,ml,oe,dl,pe,ia='You can also use Low-Rank Adaptation of Large Language Models (LoRA), a fine-tuning technique for accelerating training large models, on DreamBooth. For more details, take a look at the <a href="./lora#dreambooth">LoRA training</a> guide.',ul,re,hl,Me,oa="It’s easy to overfit while training with Dreambooth, so sometimes it’s useful to save regular checkpoints during the training process. One of the intermediate checkpoints might actually work better than the final model! Pass the following argument to the training script to enable saving checkpoints:",fl,ce,Tl,me,pa="This saves the full training state in subfolders of your <code>output_dir</code>. Subfolder names begin with the prefix <code>checkpoint-</code>, followed by the number of steps performed so far; for example, <code>checkpoint-1500</code> would be a checkpoint saved after 1500 training steps.",Ul,de,Jl,ue,ra="If you want to resume training from any of the saved checkpoints, you can pass the argument <code>--resume_from_checkpoint</code> to the script and specify the name of the checkpoint you want to use. You can also use the special string <code>&quot;latest&quot;</code> to resume from the last saved checkpoint (the one with the largest number of steps). For example, the following would resume training from the checkpoint saved after 1500 steps:",yl,he,wl,fe,Ma="This is a good opportunity to tweak some of your hyperparameters if you wish.",bl,Te,_l,Ue,ca="Saved checkpoints are stored in a format suitable for resuming training. They not only include the model weights, but also the state of the optimizer, data loaders, and learning rate.",jl,Je,ma=`If you have <strong><code>&quot;accelerate&gt;=0.16.0&quot;</code></strong> installed, use the following code to run
inference from an intermediate checkpoint.`,gl,ye,Il,we,da="If you have <strong><code>&quot;accelerate&lt;0.16.0&quot;</code></strong> installed, you need to convert it to an inference pipeline first:",Rl,be,$l,_e,Vl,je,ua="Depending on your hardware, there are a few different ways to optimize DreamBooth on GPUs from 16GB to just 8GB!",vl,ge,Nl,Ie,ha='<a href="https://github.com/facebookresearch/xformers" rel="nofollow">xFormers</a> is a toolbox for optimizing Transformers, and it includes a <a href="https://facebookresearch.github.io/xformers/components/ops.html#module-xformers.ops" rel="nofollow">memory-efficient attention</a> mechanism that is used in 🧨 Diffusers. You’ll need to <a href="./optimization/xformers">install xFormers</a> and then add the following argument to your training script:',Cl,Re,Zl,$e,fa="xFormers is not available in Flax.",Xl,Ve,Bl,ve,Ta='Another way you can lower your memory footprint is to <a href="https://pytorch.org/docs/stable/generated/torch.optim.Optimizer.zero_grad.html" rel="nofollow">set the gradients</a> to <code>None</code> instead of zero. However, this may change certain behaviors, so if you run into any issues, try removing this argument. Add the following argument to your training script to set the gradients to <code>None</code>:',Gl,Ne,El,Ce,Wl,Ze,Ua='With the help of gradient checkpointing and <a href="https://github.com/TimDettmers/bitsandbytes" rel="nofollow">bitsandbytes</a> 8-bit optimizer, it’s possible to train DreamBooth on a 16GB GPU. Make sure you have bitsandbytes installed:',xl,Xe,Fl,Be,Ja="Then pass the <code>--use_8bit_adam</code> option to the training script:",Sl,Ge,kl,Ee,Al,We,ya="To run DreamBooth on a 12GB GPU, you’ll need to enable gradient checkpointing, the 8-bit optimizer, xFormers, and set the gradients to <code>None</code>:",Ll,xe,Ql,Fe,Yl,Se,wa=`For 8GB GPUs, you’ll need the help of <a href="https://www.deepspeed.ai/" rel="nofollow">DeepSpeed</a> to offload some
tensors from the VRAM to either the CPU or NVME, enabling training with less GPU memory.`,zl,ke,ba="Run the following command to configure your 🤗 Accelerate environment:",Dl,Ae,Hl,Le,_a='During configuration, confirm that you want to use DeepSpeed. Now it’s possible to train on under 8GB VRAM by combining DeepSpeed stage 2, fp16 mixed precision, and offloading the model parameters and the optimizer state to the CPU. The drawback is that this requires more system RAM, about 25 GB. See <a href="https://huggingface.co/docs/accelerate/usage_guides/deepspeed" rel="nofollow">the DeepSpeed documentation</a> for more configuration options.',ql,Qe,ja=`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.`,Pl,Ye,ga="8-bit optimizers don’t seem to be compatible with DeepSpeed at the moment.",Ol,ze,Ia="Launch training with the following command:",Kl,De,es,He,ts,qe,Ra='Once you have trained a model, specify the path to where the model is saved, and use it for inference in the <a href="/docs/diffusers/v0.22.1/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a>. Make sure your prompts include the special <code>identifier</code> used during training (<code>sks</code> in the previous examples).',ls,Pe,$a=`If you have <strong><code>&quot;accelerate&gt;=0.16.0&quot;</code></strong> installed, you can use the following code to run
inference from an intermediate checkpoint:`,ss,Oe,as,Ke,Va='You may also run inference from any of the <a href="#inference-from-a-saved-checkpoint">saved training checkpoints</a>.',ns,et,is,tt,va=`You can use the lora and full dreambooth scripts to train the text to image <a href="https://huggingface.co/DeepFloyd/IF-I-XL-v1.0" rel="nofollow">IF model</a> and the stage II upscaler
<a href="https://huggingface.co/DeepFloyd/IF-II-L-v1.0" rel="nofollow">IF model</a>.`,os,lt,Na=`Note that IF has a predicted variance, and our finetuning scripts only train the models predicted error, so for finetuned IF models we switch to a fixed
variance schedule. The full finetuning scripts will update the scheduler config for the full saved model. However, when loading saved LoRA weights, you
must also update the pipeline’s scheduler config.`,ps,st,rs,at,Ca="Additionally, a few alternative cli flags are needed for IF.",Ms,nt,Za="<code>--resolution=64</code>: IF is a pixel space diffusion model. In order to operate on un-compressed pixels, the input images are of a much smaller resolution.",cs,it,Xa=`<code>--pre_compute_text_embeddings</code>: IF uses <a href="https://huggingface.co/docs/transformers/model_doc/t5" rel="nofollow">T5</a> for its text encoder. In order to save GPU memory, we pre compute all text embeddings and then de-allocate
T5.`,ms,ot,Ba="<code>--tokenizer_max_length=77</code>: T5 has a longer default text length, but the default IF encoding procedure uses a smaller number.",ds,pt,Ga="<code>--text_encoder_use_attention_mask</code>: T5 passes the attention mask to the text encoder.",us,rt,hs,Mt,Ea="We find LoRA to be sufficient for finetuning the stage I model as the low resolution of the model makes representing finegrained detail hard regardless.",fs,ct,Wa=`For common and/or not-visually complex object concepts, you can get away with not-finetuning the upscaler. Just be sure to adjust the prompt passed to the
upscaler to remove the new token from the instance prompt. I.e. if your stage I prompt is “a sks dog”, use “a dog” for your stage II prompt.`,Ts,mt,xa=`For finegrained detail like faces that aren’t present in the original training set, we find that full finetuning of the stage II upscaler is better than
LoRA finetuning stage II.`,Us,dt,Fa="For finegrained detail like faces, we find that lower learning rates along with larger batch sizes work best.",Js,ut,Sa="For stage II, we find that lower learning rates are also needed.",ys,ht,ka=`We found experimentally that the DDPM scheduler with the default larger number of denoising steps to sometimes work better than the DPM Solver scheduler
used in the training scripts.`,ws,ft,bs,Tt,Aa="The stage II validation requires images to upscale, we can download a downsized version of the training set:",_s,Ut,js,Jt,gs,yt,La="This training configuration requires ~28 GB VRAM.",Is,wt,Rs,bt,$s,_t,Qa="<code>--validation_images</code>: These images are upscaled during validation steps.",Vs,jt,Ya="<code>--class_labels_conditioning=timesteps</code>: Pass additional conditioning to the UNet needed for stage II.",vs,gt,za="<code>--learning_rate=1e-6</code>: Lower learning rate than stage I.",Ns,It,Da="<code>--resolution=256</code>: The upscaler expects higher resolution inputs",Cs,Rt,Zs,$t,Xs,Vt,Ha=`<code>--skip_save_text_encoder</code>: When training the full model, this will skip saving the entire T5 with the finetuned model. You can still load the pipeline
with a T5 loaded from the original model.`,Bs,vt,qa="<code>use_8bit_adam</code>: Due to the size of the optimizer states, we recommend training the full XL IF model with 8bit adam.",Gs,Nt,Pa=`<code>--learning_rate=1e-7</code>: For full dreambooth, IF requires very low learning rates. With higher learning rates model quality will degrade. Note that it is
likely the learning rate can be increased with larger batch sizes.`,Es,Ct,Oa="Using 8bit adam and a batch size of 4, the model can be trained in ~48 GB VRAM.",Ws,Zt,xs,Xt,Fs,Bt,Ka=`<code>--learning_rate=5e-6</code>: With a smaller effective batch size of 4, we found that we required learning rates as low as
1e-8.`,Ss,Gt,en="<code>--resolution=256</code>: The upscaler expects higher resolution inputs",ks,Et,tn=`<code>--train_batch_size=2</code> and <code>--gradient_accumulation_steps=6</code>: We found that full training of stage II particularly with
faces required large effective batch sizes.`,As,Wt,Ls,xt,Qs,Ft,ln='We support fine-tuning of the UNet and text encoders shipped in <a href="https://huggingface.co/papers/2307.01952" rel="nofollow">Stable Diffusion XL</a> with DreamBooth and LoRA via the <code>train_dreambooth_lora_sdxl.py</code> script. Please refer to the docs <a href="https://github.com/huggingface/diffusers/blob/main/examples/dreambooth/README_sdxl.md" rel="nofollow">here</a>.',Ys,kt,zs;return w=new g({props:{title:"DreamBooth",local:"dreambooth",headingTag:"h1"}}),A=new b({props:{code:"cGlwJTIwaW5zdGFsbCUyMGdpdCUyQmh0dHBzJTNBJTJGJTJGZ2l0aHViLmNvbSUyRmh1Z2dpbmdmYWNlJTJGZGlmZnVzZXJzJTBBcGlwJTIwaW5zdGFsbCUyMC1VJTIwLXIlMjBkaWZmdXNlcnMlMkZleGFtcGxlcyUyRmRyZWFtYm9vdGglMkZyZXF1aXJlbWVudHMudHh0",highlighted:`pip install git+https://github.com/huggingface/diffusers
pip install -U -r diffusers/examples/dreambooth/requirements.txt`,wrap:!1}}),Y=new b({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),D=new b({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),q=new b({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}}),O=new b({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}}),ee=new g({props:{title:"Finetuning",local:"finetuning",headingTag:"h2"}}),G=new cn({props:{warning:!0,$$slots:{default:[Un]},$$scope:{ctx:_}}}),E=new Ds({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[bn],pytorch:[yn]},$$scope:{ctx:_}}}),te=new g({props:{title:"Finetuning with prior-preserving loss",local:"finetuning-with-prior-preserving-loss",headingTag:"h2"}}),W=new Ds({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[In],pytorch:[jn]},$$scope:{ctx:_}}}),ae=new g({props:{title:"Finetuning the text encoder and UNet",local:"finetuning-the-text-encoder-and-unet",headingTag:"h2"}}),x=new cn({props:{warning:!0,$$slots:{default:[Rn]},$$scope:{ctx:_}}}),F=new Ds({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[Nn],pytorch:[Vn]},$$scope:{ctx:_}}}),oe=new g({props:{title:"Finetuning with LoRA",local:"finetuning-with-lora",headingTag:"h2"}}),re=new g({props:{title:"Saving checkpoints while training",local:"saving-checkpoints-while-training",headingTag:"h2"}}),ce=new b({props:{code:"JTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAw",highlighted:"  --checkpointing_steps=500",wrap:!1}}),de=new g({props:{title:"Resume training from a saved checkpoint",local:"resume-training-from-a-saved-checkpoint",headingTag:"h3"}}),he=new b({props:{code:"JTIwJTIwLS1yZXN1bWVfZnJvbV9jaGVja3BvaW50JTNEJTIyY2hlY2twb2ludC0xNTAwJTIy",highlighted:'  --resume_from_checkpoint=<span class="hljs-string">&quot;checkpoint-1500&quot;</span>',wrap:!1}}),Te=new g({props:{title:"Inference from a saved checkpoint",local:"inference-from-a-saved-checkpoint",headingTag:"h3"}}),ye=new b({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwVU5ldDJEQ29uZGl0aW9uTW9kZWwlMEFmcm9tJTIwdHJhbnNmb3JtZXJzJTIwaW1wb3J0JTIwQ0xJUFRleHRNb2RlbCUwQWltcG9ydCUyMHRvcmNoJTBBJTBBJTIzJTIwTG9hZCUyMHRoZSUyMHBpcGVsaW5lJTIwd2l0aCUyMHRoZSUyMHNhbWUlMjBhcmd1bWVudHMlMjAobW9kZWwlMkMlMjByZXZpc2lvbiklMjB0aGF0JTIwd2Vy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lYW1ib290aC1waXBlbGluZSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, UNet2DConditionModel
<span class="hljs-keyword">from</span> transformers <span class="hljs-keyword">import</span> CLIPTextModel
<span class="hljs-keyword">import</span> torch

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

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

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

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

<span class="hljs-comment"># Perform inference, or save, or push to the hub</span>
pipeline.save_pretrained(<span class="hljs-string">&quot;dreambooth-pipeline&quot;</span>)`,wrap:!1}}),be=new b({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUlMjBpbXBvcnQlMjBBY2NlbGVyYXRvciUwQWZyb20lMjBkaWZmdXNlcnMlMjBpbXBvcnQlMjBEaWZmdXNpb25QaXBlbGluZSUwQSUwQSUyMyUyMExvYWQlMjB0aGUlMjBwaXBlbGluZSUyMHdpdGglMjB0aGUlMjBzYW1lJTIwYXJndW1lbnRzJTIwKG1vZGVsJTJDJTIwcmV2aXNpb24pJTIwdGhhdCUyMHdlcmUlMjB1c2VkJTIwZm9yJTIwdHJhaW5pbmclMEFtb2RlbF9pZCUyMCUzRCUyMCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFwaXBlbGluZSUyMCUzRCUyMERp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lMjAlMjB0ZXh0X2VuY29kZXIlM0RhY2NlbGVyYXRvci51bndyYXBfbW9kZWwodGV4dF9lbmNvZGVyKSUyQyUwQSUyMCUyMCUyMCUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUlMkMlMEEpJTBBJTBBJTIzJTIwUGVyZm9ybSUyMGluZmVyZW5jZSUyQyUyMG9yJTIwc2F2ZSUyQyUyMG9yJTIwcHVzaCUyMHRvJTIwdGhlJTIwaHViJTBBcGlwZWxpbmUuc2F2ZV9wcmV0cmFpbmVkKCUyMmRyZWFtYm9vdGgtcGlwZWxpbmUlMjIp",highlighted:`<span class="hljs-keyword">from</span> accelerate <span class="hljs-keyword">import</span> Accelerator
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline

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

accelerator = Accelerator()

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

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

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

<span class="hljs-comment"># Perform inference, or save, or push to the hub</span>
pipeline.save_pretrained(<span class="hljs-string">&quot;dreambooth-pipeline&quot;</span>)`,wrap:!1}}),_e=new g({props:{title:"Optimizations for different GPU sizes",local:"optimizations-for-different-gpu-sizes",headingTag:"h2"}}),ge=new g({props:{title:"xFormers",local:"xformers",headingTag:"h3"}}),Re=new b({props:{code:"JTIwJTIwLS1lbmFibGVfeGZvcm1lcnNfbWVtb3J5X2VmZmljaWVudF9hdHRlbnRpb24=",highlighted:"  --enable_xformers_memory_efficient_attention",wrap:!1}}),Ve=new g({props:{title:"Set gradients to none",local:"set-gradients-to-none",headingTag:"h3"}}),Ne=new b({props:{code:"JTIwJTIwLS1zZXRfZ3JhZHNfdG9fbm9uZQ==",highlighted:"  --set_grads_to_none",wrap:!1}}),Ce=new g({props:{title:"16GB GPU",local:"16gb-gpu",headingTag:"h3"}}),Xe=new b({props:{code:"cGlwJTIwaW5zdGFsbCUyMGJpdHNhbmRieXRlcw==",highlighted:"pip install bitsandbytes",wrap:!1}}),Ge=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aF90b19jbGFzc19pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b19zYXZlZF9tb2RlbCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0cmFpbl9kcmVhbWJvb3RoLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlMjAlNUMlMEElMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwLS1jbGFzc19kYXRhX2RpciUzRCUyNENMQVNTX0RJUiUyMCU1QyUwQSUyMCUyMC0tb3V0cHV0X2RpciUzRCUyNE9VVFBVVF9ESVIlMjAlNUMlMEElMjAlMjAtLXdpdGhfcHJpb3JfcHJlc2VydmF0aW9uJTIwLS1wcmlvcl9sb3NzX3dlaWdodCUzRDEuMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX3Byb21wdCUzRCUyMmElMjBwaG90byUyMG9mJTIwZG9nJTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMiUyMC0tZ3JhZGllbnRfY2hlY2twb2ludGluZyUyMCU1QyUwQSUyMCUyMC0tdXNlXzhiaXRfYWRhbSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDVlLTYlMjAlNUMlMEElMjAlMjAtLWxyX3NjaGVkdWxlciUzRCUyMmNvbnN0YW50JTIyJTIwJTVDJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1udW1fY2xhc3NfaW1hZ2VzJTNEMjAwJTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0Q4MDAlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=2 --gradient_checkpointing \\
  --use_8bit_adam \\
  --learning_rate=5e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`,wrap:!1}}),Ee=new g({props:{title:"12GB GPU",local:"12gb-gpu",headingTag:"h3"}}),xe=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aC10by1jbGFzcy1pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aC10by1zYXZlLW1vZGVsJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLWNsYXNzX2RhdGFfZGlyJTNEJTI0Q0xBU1NfRElSJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMC0td2l0aF9wcmlvcl9wcmVzZXJ2YXRpb24lMjAtLXByaW9yX2xvc3Nfd2VpZ2h0JTNEMS4wJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tY2xhc3NfcHJvbXB0JTNEJTIyYSUyMHBob3RvJTIwb2YlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0QxJTIwLS1ncmFkaWVudF9jaGVja3BvaW50aW5nJTIwJTVDJTBBJTIwJTIwLS11c2VfOGJpdF9hZGFtJTIwJTVDJTBBJTIwJTIwLS1lbmFibGVfeGZvcm1lcnNfbWVtb3J5X2VmZmljaWVudF9hdHRlbnRpb24lMjAlNUMlMEElMjAlMjAtLXNldF9ncmFkc190b19ub25lJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMmUtNiUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW51bV9jbGFzc19pbWFnZXMlM0QyMDAlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDgwMCUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path-to-class-images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path-to-save-model&quot;</span>

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --class_data_dir=<span class="hljs-variable">$CLASS_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --with_prior_preservation --prior_loss_weight=1.0 \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --class_prompt=<span class="hljs-string">&quot;a photo of dog&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=1 --gradient_checkpointing \\
  --use_8bit_adam \\
  --enable_xformers_memory_efficient_attention \\
  --set_grads_to_none \\
  --learning_rate=2e-6 \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --num_class_images=200 \\
  --max_train_steps=800 \\
  --push_to_hub`,wrap:!1}}),Fe=new g({props:{title:"8 GB GPU",local:"8-gb-gpu",headingTag:"h3"}}),Ae=new b({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),De=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMEFleHBvcnQlMjBJTlNUQU5DRV9ESVIlM0QlMjIuJTJGZG9nJTIyJTBBZXhwb3J0JTIwQ0xBU1NfRElSJTNEJTIycGF0aF90b19jbGFzc19pbWFnZXMlMjIlMEFleHBvcnQlMjBPVVRQVVRfRElSJTNEJTIycGF0aF90b19zYXZlZF9tb2RlbCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0cmFpbl9kcmVhbWJvb3Ro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RfcHJlY2lzaW9uJTNEZnAxNiUyMCU1QyUwQSUyMCUyMC0tcHVzaF90b19odWI=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;./dog&quot;</span>
<span class="hljs-built_in">export</span> CLASS_DIR=<span class="hljs-string">&quot;path_to_class_images&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;path_to_saved_model&quot;</span>

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

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

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

image.save(<span class="hljs-string">&quot;dog-bucket.png&quot;</span>)`,wrap:!1}}),et=new g({props:{title:"IF",local:"if",headingTag:"h2"}}),st=new b({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}}),rt=new g({props:{title:"Tips and Tricks",local:"tips-and-tricks",headingTag:"h3"}}),ft=new g({props:{title:"Stage II additional validation images",local:"stage-ii-additional-validation-images",headingTag:"h3"}}),Ut=new b({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}}),Jt=new g({props:{title:"IF stage I LoRA Dreambooth",local:"if-stage-i-lora-dreambooth",headingTag:"h3"}}),wt=new b({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}}),bt=new g({props:{title:"IF stage II LoRA Dreambooth",local:"if-stage-ii-lora-dreambooth",headingTag:"h3"}}),Rt=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFweXRob24lMjB0cmFpbl9kcmVhbWJvb3RoX2xvcmEucHklMjAlNUMlMEElMjAlMjAlMjAlMjAtLXJlcG9ydF90byUyMHdhbmRiJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWluc3RhbmNlX2RhdGFfZGlyJTNEJTI0SU5TVEFOQ0VfRElSJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTI0T1VUUFVUX0RJUiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0taW5zdGFuY2VfcHJvbXB0JTNEJTIyYSUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tcmVzb2x1dGlvbiUzRDI1NiUyMCU1QyUwQSUyMCUyMCUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDQlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDElMjAlNUMlMEElMjAlMjAlMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS02JTIwJTVDJTIwJTBBJTIwJTIwJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QyMDAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMmElMjBza3MlMjBkb2clMjIlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZhbGlkYXRpb25fZXBvY2hzJTNEMTAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAwJTIwJTVDJTBBJTIwJTIwJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRva2VuaXplcl9tYXhfbGVuZ3RoJTNENzclMjAlNUMlMEElMjAlMjAlMjAlMjAtLXRleHRfZW5jb2Rlcl91c2VfYXR0ZW50aW9uX21hc2slMjAlNUMlMEElMjAlMjAlMjAlMjAtLXZhbGlkYXRpb25faW1hZ2VzJTIwJTI0VkFMSURBVElPTl9JTUFHRVMlMjAlNUMlMEElMjAlMjAlMjAlMjAtLWNsYXNzX2xhYmVsc19jb25kaXRpb25pbmclM0R0aW1lc3RlcHM=",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-II-L-v1.0&quot;</span>
<span class="hljs-built_in">export</span> INSTANCE_DIR=<span class="hljs-string">&quot;dog&quot;</span>
<span class="hljs-built_in">export</span> OUTPUT_DIR=<span class="hljs-string">&quot;dreambooth_dog_upscale&quot;</span>
<span class="hljs-built_in">export</span> VALIDATION_IMAGES=<span class="hljs-string">&quot;dog_downsized/image_1.png dog_downsized/image_2.png dog_downsized/image_3.png dog_downsized/image_4.png&quot;</span>

python train_dreambooth_lora.py \\
    --report_to wandb \\
    --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
    --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
    --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
    --instance_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
    --resolution=256 \\
    --train_batch_size=4 \\
    --gradient_accumulation_steps=1 \\
    --learning_rate=1e-6 \\ 
    --max_train_steps=2000 \\
    --validation_prompt=<span class="hljs-string">&quot;a sks dog&quot;</span> \\
    --validation_epochs=100 \\
    --checkpointing_steps=500 \\
    --pre_compute_text_embeddings \\
    --tokenizer_max_length=77 \\
    --text_encoder_use_attention_mask \\
    --validation_images <span class="hljs-variable">$VALIDATION_IMAGES</span> \\
    --class_labels_conditioning=timesteps`,wrap:!1}}),$t=new g({props:{title:"IF Stage I Full Dreambooth",local:"if-stage-i-full-dreambooth",headingTag:"h3"}}),Zt=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUktWEwtdjEuMCUyMiUwQSUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2lmJTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX2RyZWFtYm9vdGgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCUyMCU1QyUwQSUyMCUyMC0taW5zdGFuY2VfZGF0YV9kaXIlM0QlMjRJTlNUQU5DRV9ESVIlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjRPVVRQVVRfRElSJTIwJTVDJTBBJTIwJTIwLS1pbnN0YW5jZV9wcm9tcHQlM0QlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDY0JTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNENCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNEMSUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDFlLTclMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MCUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9wcm9tcHQlMjAlMjJhJTIwcGhvdG8lMjBvZiUyMHNrcyUyMGRvZyUyMiUyMCU1QyUwQSUyMCUyMC0tdmFsaWRhdGlvbl9zdGVwcyUyMDI1JTIwJTVDJTBBJTIwJTIwLS10ZXh0X2VuY29kZXJfdXNlX2F0dGVudGlvbl9tYXNrJTIwJTVDJTBBJTIwJTIwLS10b2tlbml6ZXJfbWF4X2xlbmd0aCUyMDc3JTIwJTVDJTBBJTIwJTIwLS1wcmVfY29tcHV0ZV90ZXh0X2VtYmVkZGluZ3MlMjAlNUMlMEElMjAlMjAtLXVzZV84Yml0X2FkYW0lMjAlNUMlMEElMjAlMjAtLXNldF9ncmFkc190b19ub25lJTIwJTVDJTBBJTIwJTIwLS1za2lwX3NhdmVfdGV4dF9lbmNvZGVyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;DeepFloyd/IF-I-XL-v1.0&quot;</span>

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

accelerate launch train_dreambooth.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span>  \\
  --instance_data_dir=<span class="hljs-variable">$INSTANCE_DIR</span> \\
  --output_dir=<span class="hljs-variable">$OUTPUT_DIR</span> \\
  --instance_prompt=<span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --resolution=64 \\
  --train_batch_size=4 \\
  --gradient_accumulation_steps=1 \\
  --learning_rate=1e-7 \\
  --max_train_steps=150 \\
  --validation_prompt <span class="hljs-string">&quot;a photo of sks dog&quot;</span> \\
  --validation_steps 25 \\
  --text_encoder_use_attention_mask \\
  --tokenizer_max_length 77 \\
  --pre_compute_text_embeddings \\
  --use_8bit_adam \\
  --set_grads_to_none \\
  --skip_save_text_encoder \\
  --push_to_hub`,wrap:!1}}),Xt=new g({props:{title:"IF Stage II Full Dreambooth",local:"if-stage-ii-full-dreambooth",headingTag:"h3"}}),Wt=new b({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMkRlZXBGbG95ZCUyRklGLUlJLUwtdjEuMCUyMiUwQWV4cG9ydCUyMElOU1RBTkNFX0RJUiUzRCUyMmRvZyUyMiUwQWV4cG9ydCUyME9VVFBVVF9ESVIlM0QlMjJkcmVhbWJvb3RoX2RvZ191cHNjYWxlJTIyJTBBZXhwb3J0JTIwVkFMSURBVElPTl9JTUFHRVMlM0QlMjJkb2dfZG93bnNpemVkJTJGaW1hZ2VfMS5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMi5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfMy5wbmclMjBkb2dfZG93bnNpemVkJTJGaW1hZ2VfNC5wbmclMjIlMEElMEFhY2NlbGVyYXRlJTIwbGF1bmNoJTIwdHJhaW5fZHJlYW1ib290aC5weSUyMCU1QyUwQSUyMCUyMC0tcmVwb3J0X3RvJTIwd2FuZGIlMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl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ljs-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}}),xt=new g({props:{title:"Stable Diffusion XL",local:"stable-diffusion-xl",headingTag:"h2"}}),{c(){o=p("meta"),c=n(),a=p("p"),U=n(),m(w.$$.fragment),N=n(),j=p("p"),j.innerHTML=Z,R=n(),C=p("p"),C.innerHTML=X,$=n(),v=p("small"),v.innerHTML=J,I=n(),B=p("p"),B.innerHTML=y,V=n(),k=p("p"),k.innerHTML=Hs,At=n(),m(A.$$.fragment),Lt=n(),L=p("p"),L.innerHTML=qs,Qt=n(),Q=p("p"),Q.innerHTML=Ps,Yt=n(),m(Y.$$.fragment),zt=n(),z=p("p"),z.textContent=Os,Dt=n(),m(D.$$.fragment),Ht=n(),H=p("p"),H.textContent=Ks,qt=n(),m(q.$$.fragment),Pt=n(),P=p("p"),P.innerHTML=ea,Ot=n(),m(O.$$.fragment),Kt=n(),K=p("p"),K.innerHTML=ta,el=n(),m(ee.$$.fragment),tl=n(),m(G.$$.fragment),ll=n(),m(E.$$.fragment),sl=n(),m(te.$$.fragment),al=n(),le=p("p"),le.innerHTML=la,nl=n(),se=p("p"),se.innerHTML=sa,il=n(),m(W.$$.fragment),ol=n(),m(ae.$$.fragment),pl=n(),ne=p("p"),ne.innerHTML=aa,rl=n(),m(x.$$.fragment),Ml=n(),ie=p("p"),ie.innerHTML=na,cl=n(),m(F.$$.fragment),ml=n(),m(oe.$$.fragment),dl=n(),pe=p("p"),pe.innerHTML=ia,ul=n(),m(re.$$.fragment),hl=n(),Me=p("p"),Me.textContent=oa,fl=n(),m(ce.$$.fragment),Tl=n(),me=p("p"),me.innerHTML=pa,Ul=n(),m(de.$$.fragment),Jl=n(),ue=p("p"),ue.innerHTML=ra,yl=n(),m(he.$$.fragment),wl=n(),fe=p("p"),fe.textContent=Ma,bl=n(),m(Te.$$.fragment),_l=n(),Ue=p("p"),Ue.textContent=ca,jl=n(),Je=p("p"),Je.innerHTML=ma,gl=n(),m(ye.$$.fragment),Il=n(),we=p("p"),we.innerHTML=da,Rl=n(),m(be.$$.fragment),$l=n(),m(_e.$$.fragment),Vl=n(),je=p("p"),je.textContent=ua,vl=n(),m(ge.$$.fragment),Nl=n(),Ie=p("p"),Ie.innerHTML=ha,Cl=n(),m(Re.$$.fragment),Zl=n(),$e=p("p"),$e.textContent=fa,Xl=n(),m(Ve.$$.fragment),Bl=n(),ve=p("p"),ve.innerHTML=Ta,Gl=n(),m(Ne.$$.fragment),El=n(),m(Ce.$$.fragment),Wl=n(),Ze=p("p"),Ze.innerHTML=Ua,xl=n(),m(Xe.$$.fragment),Fl=n(),Be=p("p"),Be.innerHTML=Ja,Sl=n(),m(Ge.$$.fragment),kl=n(),m(Ee.$$.fragment),Al=n(),We=p("p"),We.innerHTML=ya,Ll=n(),m(xe.$$.fragment),Ql=n(),m(Fe.$$.fragment),Yl=n(),Se=p("p"),Se.innerHTML=wa,zl=n(),ke=p("p"),ke.textContent=ba,Dl=n(),m(Ae.$$.fragment),Hl=n(),Le=p("p"),Le.innerHTML=_a,ql=n(),Qe=p("p"),Qe.innerHTML=ja,Pl=n(),Ye=p("p"),Ye.textContent=ga,Ol=n(),ze=p("p"),ze.textContent=Ia,Kl=n(),m(De.$$.fragment),es=n(),m(He.$$.fragment),ts=n(),qe=p("p"),qe.innerHTML=Ra,ls=n(),Pe=p("p"),Pe.innerHTML=$a,ss=n(),m(Oe.$$.fragment),as=n(),Ke=p("p"),Ke.innerHTML=Va,ns=n(),m(et.$$.fragment),is=n(),tt=p("p"),tt.innerHTML=va,os=n(),lt=p("p"),lt.textContent=Na,ps=n(),m(st.$$.fragment),rs=n(),at=p("p"),at.textContent=Ca,Ms=n(),nt=p("p"),nt.innerHTML=Za,cs=n(),it=p("p"),it.innerHTML=Xa,ms=n(),ot=p("p"),ot.innerHTML=Ba,ds=n(),pt=p("p"),pt.innerHTML=Ga,us=n(),m(rt.$$.fragment),hs=n(),Mt=p("p"),Mt.textContent=Ea,fs=n(),ct=p("p"),ct.textContent=Wa,Ts=n(),mt=p("p"),mt.textContent=xa,Us=n(),dt=p("p"),dt.textContent=Fa,Js=n(),ut=p("p"),ut.textContent=Sa,ys=n(),ht=p("p"),ht.textContent=ka,ws=n(),m(ft.$$.fragment),bs=n(),Tt=p("p"),Tt.textContent=Aa,_s=n(),m(Ut.$$.fragment),js=n(),m(Jt.$$.fragment),gs=n(),yt=p("p"),yt.textContent=La,Is=n(),m(wt.$$.fragment),Rs=n(),m(bt.$$.fragment),$s=n(),_t=p("p"),_t.innerHTML=Qa,Vs=n(),jt=p("p"),jt.innerHTML=Ya,vs=n(),gt=p("p"),gt.innerHTML=za,Ns=n(),It=p("p"),It.innerHTML=Da,Cs=n(),m(Rt.$$.fragment),Zs=n(),m($t.$$.fragment),Xs=n(),Vt=p("p"),Vt.innerHTML=Ha,Bs=n(),vt=p("p"),vt.innerHTML=qa,Gs=n(),Nt=p("p"),Nt.innerHTML=Pa,Es=n(),Ct=p("p"),Ct.textContent=Oa,Ws=n(),m(Zt.$$.fragment),xs=n(),m(Xt.$$.fragment),Fs=n(),Bt=p("p"),Bt.innerHTML=Ka,Ss=n(),Gt=p("p"),Gt.innerHTML=en,ks=n(),Et=p("p"),Et.innerHTML=tn,As=n(),m(Wt.$$.fragment),Ls=n(),m(xt.$$.fragment),Qs=n(),Ft=p("p"),Ft.innerHTML=ln,Ys=n(),kt=p("p"),this.h()},l(e){const t=fn("svelte-u9bgzb",document.head);o=r(t,"META",{name:!0,content:!0}),t.forEach(l),c=i(e),a=r(e,"P",{}),rn(a).forEach(l),U=i(e),d(w.$$.fragment,e),N=i(e),j=r(e,"P",{"data-svelte-h":!0}),M(j)!=="svelte-1e4e3cx"&&(j.innerHTML=Z),R=i(e),C=r(e,"P",{"data-svelte-h":!0}),M(C)!=="svelte-ytrbfy"&&(C.innerHTML=X),$=i(e),v=r(e,"SMALL",{"data-svelte-h":!0}),M(v)!=="svelte-wmsu58"&&(v.innerHTML=J),I=i(e),B=r(e,"P",{"data-svelte-h":!0}),M(B)!=="svelte-1766onr"&&(B.innerHTML=y),V=i(e),k=r(e,"P",{"data-svelte-h":!0}),M(k)!=="svelte-1hqez46"&&(k.innerHTML=Hs),At=i(e),d(A.$$.fragment,e),Lt=i(e),L=r(e,"P",{"data-svelte-h":!0}),M(L)!=="svelte-1udyijm"&&(L.innerHTML=qs),Qt=i(e),Q=r(e,"P",{"data-svelte-h":!0}),M(Q)!=="svelte-ygb1fc"&&(Q.innerHTML=Ps),Yt=i(e),d(Y.$$.fragment,e),zt=i(e),z=r(e,"P",{"data-svelte-h":!0}),M(z)!=="svelte-di6juu"&&(z.textContent=Os),Dt=i(e),d(D.$$.fragment,e),Ht=i(e),H=r(e,"P",{"data-svelte-h":!0}),M(H)!=="svelte-130n95n"&&(H.textContent=Ks),qt=i(e),d(q.$$.fragment,e),Pt=i(e),P=r(e,"P",{"data-svelte-h":!0}),M(P)!=="svelte-1kk0dkm"&&(P.innerHTML=ea),Ot=i(e),d(O.$$.fragment,e),Kt=i(e),K=r(e,"P",{"data-svelte-h":!0}),M(K)!=="svelte-19a7h78"&&(K.innerHTML=ta),el=i(e),d(ee.$$.fragment,e),tl=i(e),d(G.$$.fragment,e),ll=i(e),d(E.$$.fragment,e),sl=i(e),d(te.$$.fragment,e),al=i(e),le=r(e,"P",{"data-svelte-h":!0}),M(le)!=="svelte-1vu0p8v"&&(le.innerHTML=la),nl=i(e),se=r(e,"P",{"data-svelte-h":!0}),M(se)!=="svelte-vlraqg"&&(se.innerHTML=sa),il=i(e),d(W.$$.fragment,e),ol=i(e),d(ae.$$.fragment,e),pl=i(e),ne=r(e,"P",{"data-svelte-h":!0}),M(ne)!=="svelte-grybit"&&(ne.innerHTML=aa),rl=i(e),d(x.$$.fragment,e),Ml=i(e),ie=r(e,"P",{"data-svelte-h":!0}),M(ie)!=="svelte-1k2uzj9"&&(ie.innerHTML=na),cl=i(e),d(F.$$.fragment,e),ml=i(e),d(oe.$$.fragment,e),dl=i(e),pe=r(e,"P",{"data-svelte-h":!0}),M(pe)!=="svelte-1au4x04"&&(pe.innerHTML=ia),ul=i(e),d(re.$$.fragment,e),hl=i(e),Me=r(e,"P",{"data-svelte-h":!0}),M(Me)!=="svelte-1p0pcfx"&&(Me.textContent=oa),fl=i(e),d(ce.$$.fragment,e),Tl=i(e),me=r(e,"P",{"data-svelte-h":!0}),M(me)!=="svelte-8xsnea"&&(me.innerHTML=pa),Ul=i(e),d(de.$$.fragment,e),Jl=i(e),ue=r(e,"P",{"data-svelte-h":!0}),M(ue)!=="svelte-1alj2e8"&&(ue.innerHTML=ra),yl=i(e),d(he.$$.fragment,e),wl=i(e),fe=r(e,"P",{"data-svelte-h":!0}),M(fe)!=="svelte-1m22ucf"&&(fe.textContent=Ma),bl=i(e),d(Te.$$.fragment,e),_l=i(e),Ue=r(e,"P",{"data-svelte-h":!0}),M(Ue)!=="svelte-klvvh8"&&(Ue.textContent=ca),jl=i(e),Je=r(e,"P",{"data-svelte-h":!0}),M(Je)!=="svelte-1tyy594"&&(Je.innerHTML=ma),gl=i(e),d(ye.$$.fragment,e),Il=i(e),we=r(e,"P",{"data-svelte-h":!0}),M(we)!=="svelte-10s7sps"&&(we.innerHTML=da),Rl=i(e),d(be.$$.fragment,e),$l=i(e),d(_e.$$.fragment,e),Vl=i(e),je=r(e,"P",{"data-svelte-h":!0}),M(je)!=="svelte-wcr4p4"&&(je.textContent=ua),vl=i(e),d(ge.$$.fragment,e),Nl=i(e),Ie=r(e,"P",{"data-svelte-h":!0}),M(Ie)!=="svelte-1tmlmwd"&&(Ie.innerHTML=ha),Cl=i(e),d(Re.$$.fragment,e),Zl=i(e),$e=r(e,"P",{"data-svelte-h":!0}),M($e)!=="svelte-ze7fj8"&&($e.textContent=fa),Xl=i(e),d(Ve.$$.fragment,e),Bl=i(e),ve=r(e,"P",{"data-svelte-h":!0}),M(ve)!=="svelte-1adkuc5"&&(ve.innerHTML=Ta),Gl=i(e),d(Ne.$$.fragment,e),El=i(e),d(Ce.$$.fragment,e),Wl=i(e),Ze=r(e,"P",{"data-svelte-h":!0}),M(Ze)!=="svelte-e7gg43"&&(Ze.innerHTML=Ua),xl=i(e),d(Xe.$$.fragment,e),Fl=i(e),Be=r(e,"P",{"data-svelte-h":!0}),M(Be)!=="svelte-1od8ya5"&&(Be.innerHTML=Ja),Sl=i(e),d(Ge.$$.fragment,e),kl=i(e),d(Ee.$$.fragment,e),Al=i(e),We=r(e,"P",{"data-svelte-h":!0}),M(We)!=="svelte-1g7pdkw"&&(We.innerHTML=ya),Ll=i(e),d(xe.$$.fragment,e),Ql=i(e),d(Fe.$$.fragment,e),Yl=i(e),Se=r(e,"P",{"data-svelte-h":!0}),M(Se)!=="svelte-4mpnbj"&&(Se.innerHTML=wa),zl=i(e),ke=r(e,"P",{"data-svelte-h":!0}),M(ke)!=="svelte-1fx999v"&&(ke.textContent=ba),Dl=i(e),d(Ae.$$.fragment,e),Hl=i(e),Le=r(e,"P",{"data-svelte-h":!0}),M(Le)!=="svelte-unul6w"&&(Le.innerHTML=_a),ql=i(e),Qe=r(e,"P",{"data-svelte-h":!0}),M(Qe)!=="svelte-pbdeen"&&(Qe.innerHTML=ja),Pl=i(e),Ye=r(e,"P",{"data-svelte-h":!0}),M(Ye)!=="svelte-uvirud"&&(Ye.textContent=ga),Ol=i(e),ze=r(e,"P",{"data-svelte-h":!0}),M(ze)!=="svelte-erekru"&&(ze.textContent=Ia),Kl=i(e),d(De.$$.fragment,e),es=i(e),d(He.$$.fragment,e),ts=i(e),qe=r(e,"P",{"data-svelte-h":!0}),M(qe)!=="svelte-1o79ayt"&&(qe.innerHTML=Ra),ls=i(e),Pe=r(e,"P",{"data-svelte-h":!0}),M(Pe)!=="svelte-14k0zzn"&&(Pe.innerHTML=$a),ss=i(e),d(Oe.$$.fragment,e),as=i(e),Ke=r(e,"P",{"data-svelte-h":!0}),M(Ke)!=="svelte-rw69oc"&&(Ke.innerHTML=Va),ns=i(e),d(et.$$.fragment,e),is=i(e),tt=r(e,"P",{"data-svelte-h":!0}),M(tt)!=="svelte-vx8447"&&(tt.innerHTML=va),os=i(e),lt=r(e,"P",{"data-svelte-h":!0}),M(lt)!=="svelte-1gxlb2o"&&(lt.textContent=Na),ps=i(e),d(st.$$.fragment,e),rs=i(e),at=r(e,"P",{"data-svelte-h":!0}),M(at)!=="svelte-j509hk"&&(at.textContent=Ca),Ms=i(e),nt=r(e,"P",{"data-svelte-h":!0}),M(nt)!=="svelte-7zyzyx"&&(nt.innerHTML=Za),cs=i(e),it=r(e,"P",{"data-svelte-h":!0}),M(it)!=="svelte-hvq437"&&(it.innerHTML=Xa),ms=i(e),ot=r(e,"P",{"data-svelte-h":!0}),M(ot)!=="svelte-1d1zpcw"&&(ot.innerHTML=Ba),ds=i(e),pt=r(e,"P",{"data-svelte-h":!0}),M(pt)!=="svelte-y6ibo7"&&(pt.innerHTML=Ga),us=i(e),d(rt.$$.fragment,e),hs=i(e),Mt=r(e,"P",{"data-svelte-h":!0}),M(Mt)!=="svelte-14brpob"&&(Mt.textContent=Ea),fs=i(e),ct=r(e,"P",{"data-svelte-h":!0}),M(ct)!=="svelte-vbhic8"&&(ct.textContent=Wa),Ts=i(e),mt=r(e,"P",{"data-svelte-h":!0}),M(mt)!=="svelte-9xbc5m"&&(mt.textContent=xa),Us=i(e),dt=r(e,"P",{"data-svelte-h":!0}),M(dt)!=="svelte-bx1cek"&&(dt.textContent=Fa),Js=i(e),ut=r(e,"P",{"data-svelte-h":!0}),M(ut)!=="svelte-19pvvud"&&(ut.textContent=Sa),ys=i(e),ht=r(e,"P",{"data-svelte-h":!0}),M(ht)!=="svelte-1qkh0q9"&&(ht.textContent=ka),ws=i(e),d(ft.$$.fragment,e),bs=i(e),Tt=r(e,"P",{"data-svelte-h":!0}),M(Tt)!=="svelte-jdi7gu"&&(Tt.textContent=Aa),_s=i(e),d(Ut.$$.fragment,e),js=i(e),d(Jt.$$.fragment,e),gs=i(e),yt=r(e,"P",{"data-svelte-h":!0}),M(yt)!=="svelte-1kpgnux"&&(yt.textContent=La),Is=i(e),d(wt.$$.fragment,e),Rs=i(e),d(bt.$$.fragment,e),$s=i(e),_t=r(e,"P",{"data-svelte-h":!0}),M(_t)!=="svelte-cqxip6"&&(_t.innerHTML=Qa),Vs=i(e),jt=r(e,"P",{"data-svelte-h":!0}),M(jt)!=="svelte-a9m9uf"&&(jt.innerHTML=Ya),vs=i(e),gt=r(e,"P",{"data-svelte-h":!0}),M(gt)!=="svelte-ilyx19"&&(gt.innerHTML=za),Ns=i(e),It=r(e,"P",{"data-svelte-h":!0}),M(It)!=="svelte-rh5mqd"&&(It.innerHTML=Da),Cs=i(e),d(Rt.$$.fragment,e),Zs=i(e),d($t.$$.fragment,e),Xs=i(e),Vt=r(e,"P",{"data-svelte-h":!0}),M(Vt)!=="svelte-1jd8uaa"&&(Vt.innerHTML=Ha),Bs=i(e),vt=r(e,"P",{"data-svelte-h":!0}),M(vt)!=="svelte-hly0r2"&&(vt.innerHTML=qa),Gs=i(e),Nt=r(e,"P",{"data-svelte-h":!0}),M(Nt)!=="svelte-b8gry9"&&(Nt.innerHTML=Pa),Es=i(e),Ct=r(e,"P",{"data-svelte-h":!0}),M(Ct)!=="svelte-jrp3vq"&&(Ct.textContent=Oa),Ws=i(e),d(Zt.$$.fragment,e),xs=i(e),d(Xt.$$.fragment,e),Fs=i(e),Bt=r(e,"P",{"data-svelte-h":!0}),M(Bt)!=="svelte-1qe7hwo"&&(Bt.innerHTML=Ka),Ss=i(e),Gt=r(e,"P",{"data-svelte-h":!0}),M(Gt)!=="svelte-rh5mqd"&&(Gt.innerHTML=en),ks=i(e),Et=r(e,"P",{"data-svelte-h":!0}),M(Et)!=="svelte-1acbypw"&&(Et.innerHTML=tn),As=i(e),d(Wt.$$.fragment,e),Ls=i(e),d(xt.$$.fragment,e),Qs=i(e),Ft=r(e,"P",{"data-svelte-h":!0}),M(Ft)!=="svelte-xyk1up"&&(Ft.innerHTML=ln),Ys=i(e),kt=r(e,"P",{}),rn(kt).forEach(l),this.h()},h(){Mn(o,"name","hf:doc:metadata"),Mn(o,"content",Zn)},m(e,t){Tn(document.head,o),s(e,c,t),s(e,a,t),s(e,U,t),u(w,e,t),s(e,N,t),s(e,j,t),s(e,R,t),s(e,C,t),s(e,$,t),s(e,v,t),s(e,I,t),s(e,B,t),s(e,V,t),s(e,k,t),s(e,At,t),u(A,e,t),s(e,Lt,t),s(e,L,t),s(e,Qt,t),s(e,Q,t),s(e,Yt,t),u(Y,e,t),s(e,zt,t),s(e,z,t),s(e,Dt,t),u(D,e,t),s(e,Ht,t),s(e,H,t),s(e,qt,t),u(q,e,t),s(e,Pt,t),s(e,P,t),s(e,Ot,t),u(O,e,t),s(e,Kt,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e,qe,t),s(e,ls,t),s(e,Pe,t),s(e,ss,t),u(Oe,e,t),s(e,as,t),s(e,Ke,t),s(e,ns,t),u(et,e,t),s(e,is,t),s(e,tt,t),s(e,os,t),s(e,lt,t),s(e,ps,t),u(st,e,t),s(e,rs,t),s(e,at,t),s(e,Ms,t),s(e,nt,t),s(e,cs,t),s(e,it,t),s(e,ms,t),s(e,ot,t),s(e,ds,t),s(e,pt,t),s(e,us,t),u(rt,e,t),s(e,hs,t),s(e,Mt,t),s(e,fs,t),s(e,ct,t),s(e,Ts,t),s(e,mt,t),s(e,Us,t),s(e,dt,t),s(e,Js,t),s(e,ut,t),s(e,ys,t),s(e,ht,t),s(e,ws,t),u(ft,e,t),s(e,bs,t),s(e,Tt,t),s(e,_s,t),u(Ut,e,t),s(e,js,t),u(Jt,e,t),s(e,gs,t),s(e,yt,t),s(e,Is,t),u(wt,e,t),s(e,Rs,t),u(bt,e,t),s(e,$s,t),s(e,_t,t),s(e,Vs,t),s(e,jt,t),s(e,vs,t),s(e,gt,t),s(e,Ns,t),s(e,It,t),s(e,Cs,t),u(Rt,e,t),s(e,Zs,t),u($t,e,t),s(e,Xs,t),s(e,Vt,t),s(e,Bs,t),s(e,vt,t),s(e,Gs,t),s(e,Nt,t),s(e,Es,t),s(e,Ct,t),s(e,Ws,t),u(Zt,e,t),s(e,xs,t),u(Xt,e,t),s(e,Fs,t),s(e,Bt,t),s(e,Ss,t),s(e,Gt,t),s(e,ks,t),s(e,Et,t),s(e,As,t),u(Wt,e,t),s(e,Ls,t),u(xt,e,t),s(e,Qs,t),s(e,Ft,t),s(e,Ys,t),s(e,kt,t),zs=!0},p(e,[t]){const sn={};t&2&&(sn.$$scope={dirty:t,ctx:e}),G.$set(sn);const an={};t&2&&(an.$$scope={dirty:t,ctx:e}),E.$set(an);const nn={};t&2&&(nn.$$scope={dirty:t,ctx:e}),W.$set(nn);const on={};t&2&&(on.$$scope={dirty:t,ctx:e}),x.$set(on);const pn={};t&2&&(pn.$$scope={dirty:t,ctx:e}),F.$set(pn)},i(e){zs||(h(w.$$.fragment,e),h(A.$$.fragment,e),h(Y.$$.fragment,e),h(D.$$.fragment,e),h(q.$$.fragment,e),h(O.$$.fragment,e),h(ee.$$.fragment,e),h(G.$$.fragment,e),h(E.$$.fragment,e),h(te.$$.fragment,e),h(W.$$.fragment,e),h(ae.$$.fragment,e),h(x.$$.fragment,e),h(F.$$.fragment,e),h(oe.$$.fragment,e),h(re.$$.fragment,e),h(ce.$$.fragment,e),h(de.$$.fragment,e),h(he.$$.fragment,e),h(Te.$$.fragment,e),h(ye.$$.fragment,e),h(be.$$.fragment,e),h(_e.$$.fragment,e),h(ge.$$.fragment,e),h(Re.$$.fragment,e),h(Ve.$$.fragment,e),h(Ne.$$.fragment,e),h(Ce.$$.fragment,e),h(Xe.$$.fragment,e),h(Ge.$$.fragment,e),h(Ee.$$.fragment,e),h(xe.$$.fragment,e),h(Fe.$$.fragment,e),h(Ae.$$.fragment,e),h(De.$$.fragment,e),h(He.$$.fragment,e),h(Oe.$$.fragment,e),h(et.$$.fragment,e),h(st.$$.fragment,e),h(rt.$$.fragment,e),h(ft.$$.fragment,e),h(Ut.$$.fragment,e),h(Jt.$$.fragment,e),h(wt.$$.fragment,e),h(bt.$$.fragment,e),h(Rt.$$.fragment,e),h($t.$$.fragment,e),h(Zt.$$.fragment,e),h(Xt.$$.fragment,e),h(Wt.$$.fragment,e),h(xt.$$.fragment,e),zs=!0)},o(e){f(w.$$.fragment,e),f(A.$$.fragment,e),f(Y.$$.fragment,e),f(D.$$.fragment,e),f(q.$$.fragment,e),f(O.$$.fragment,e),f(ee.$$.fragment,e),f(G.$$.fragment,e),f(E.$$.fragment,e),f(te.$$.fragment,e),f(W.$$.fragment,e),f(ae.$$.fragment,e),f(x.$$.fragment,e),f(F.$$.fragment,e),f(oe.$$.fragment,e),f(re.$$.fragment,e),f(ce.$$.fragment,e),f(de.$$.fragment,e),f(he.$$.fragment,e),f(Te.$$.fragment,e),f(ye.$$.fragment,e),f(be.$$.fragment,e),f(_e.$$.fragment,e),f(ge.$$.fragment,e),f(Re.$$.fragment,e),f(Ve.$$.fragment,e),f(Ne.$$.fragment,e),f(Ce.$$.fragment,e),f(Xe.$$.fragment,e),f(Ge.$$.fragment,e),f(Ee.$$.fragment,e),f(xe.$$.fragment,e),f(Fe.$$.fragment,e),f(Ae.$$.fragment,e),f(De.$$.fragment,e),f(He.$$.fragment,e),f(Oe.$$.fragment,e),f(et.$$.fragment,e),f(st.$$.fragment,e),f(rt.$$.fragment,e),f(ft.$$.fragment,e),f(Ut.$$.fragment,e),f(Jt.$$.fragment,e),f(wt.$$.fragment,e),f(bt.$$.fragment,e),f(Rt.$$.fragment,e),f($t.$$.fragment,e),f(Zt.$$.fragment,e),f(Xt.$$.fragment,e),f(Wt.$$.fragment,e),f(xt.$$.fragment,e),zs=!1},d(e){e&&(l(c),l(a),l(U),l(N),l(j),l(R),l(C),l($),l(v),l(I),l(B),l(V),l(k),l(At),l(Lt),l(L),l(Qt),l(Q),l(Yt),l(zt),l(z),l(Dt),l(Ht),l(H),l(qt),l(Pt),l(P),l(Ot),l(Kt),l(K),l(el),l(tl),l(ll),l(sl),l(al),l(le),l(nl),l(se),l(il),l(ol),l(pl),l(ne),l(rl),l(Ml),l(ie),l(cl),l(ml),l(dl),l(pe),l(ul),l(hl),l(Me),l(fl),l(Tl),l(me),l(Ul),l(Jl),l(ue),l(yl),l(wl),l(fe),l(bl),l(_l),l(Ue),l(jl),l(Je),l(gl),l(Il),l(we),l(Rl),l($l),l(Vl),l(je),l(vl),l(Nl),l(Ie),l(Cl),l(Zl),l($e),l(Xl),l(Bl),l(ve),l(Gl),l(El),l(Wl),l(Ze),l(xl),l(Fl),l(Be),l(Sl),l(kl),l(Al),l(We),l(Ll),l(Ql),l(Yl),l(Se),l(zl),l(ke),l(Dl),l(Hl),l(Le),l(ql),l(Qe),l(Pl),l(Ye),l(Ol),l(ze),l(Kl),l(es),l(ts),l(qe),l(ls),l(Pe),l(ss),l(as),l(Ke),l(ns),l(is),l(tt),l(os),l(lt),l(ps),l(rs),l(at),l(Ms),l(nt),l(cs),l(it),l(ms),l(ot),l(ds),l(pt),l(us),l(hs),l(Mt),l(fs),l(ct),l(Ts),l(mt),l(Us),l(dt),l(Js),l(ut),l(ys),l(ht),l(ws),l(bs),l(Tt),l(_s),l(js),l(gs),l(yt),l(Is),l(Rs),l($s),l(_t),l(Vs),l(jt),l(vs),l(gt),l(Ns),l(It),l(Cs),l(Zs),l(Xs),l(Vt),l(Bs),l(vt),l(Gs),l(Nt),l(Es),l(Ct),l(Ws),l(xs),l(Fs),l(Bt),l(Ss),l(Gt),l(ks),l(Et),l(As),l(Ls),l(Qs),l(Ft),l(Ys),l(kt)),l(o),T(w,e),T(A,e),T(Y,e),T(D,e),T(q,e),T(O,e),T(ee,e),T(G,e),T(E,e),T(te,e),T(W,e),T(ae,e),T(x,e),T(F,e),T(oe,e),T(re,e),T(ce,e),T(de,e),T(he,e),T(Te,e),T(ye,e),T(be,e),T(_e,e),T(ge,e),T(Re,e),T(Ve,e),T(Ne,e),T(Ce,e),T(Xe,e),T(Ge,e),T(Ee,e),T(xe,e),T(Fe,e),T(Ae,e),T(De,e),T(He,e),T(Oe,e),T(et,e),T(st,e),T(rt,e),T(ft,e),T(Ut,e),T(Jt,e),T(wt,e),T(bt,e),T(Rt,e),T($t,e),T(Zt,e),T(Xt,e),T(Wt,e),T(xt,e)}}}const Zn='{"title":"DreamBooth","local":"dreambooth","sections":[{"title":"Finetuning","local":"finetuning","sections":[],"depth":2},{"title":"Finetuning with prior-preserving loss","local":"finetuning-with-prior-preserving-loss","sections":[],"depth":2},{"title":"Finetuning the text encoder and UNet","local":"finetuning-the-text-encoder-and-unet","sections":[],"depth":2},{"title":"Finetuning with LoRA","local":"finetuning-with-lora","sections":[],"depth":2},{"title":"Saving checkpoints while training","local":"saving-checkpoints-while-training","sections":[{"title":"Resume training from a saved checkpoint","local":"resume-training-from-a-saved-checkpoint","sections":[],"depth":3},{"title":"Inference from a saved checkpoint","local":"inference-from-a-saved-checkpoint","sections":[],"depth":3}],"depth":2},{"title":"Optimizations for different GPU sizes","local":"optimizations-for-different-gpu-sizes","sections":[{"title":"xFormers","local":"xformers","sections":[],"depth":3},{"title":"Set gradients to none","local":"set-gradients-to-none","sections":[],"depth":3},{"title":"16GB GPU","local":"16gb-gpu","sections":[],"depth":3},{"title":"12GB GPU","local":"12gb-gpu","sections":[],"depth":3},{"title":"8 GB GPU","local":"8-gb-gpu","sections":[],"depth":3}],"depth":2},{"title":"Inference","local":"inference","sections":[],"depth":2},{"title":"IF","local":"if","sections":[{"title":"Tips and Tricks","local":"tips-and-tricks","sections":[],"depth":3},{"title":"Stage II additional validation images","local":"stage-ii-additional-validation-images","sections":[],"depth":3},{"title":"IF stage I LoRA Dreambooth","local":"if-stage-i-lora-dreambooth","sections":[],"depth":3},{"title":"IF stage II LoRA Dreambooth","local":"if-stage-ii-lora-dreambooth","sections":[],"depth":3},{"title":"IF Stage I Full Dreambooth","local":"if-stage-i-full-dreambooth","sections":[],"depth":3},{"title":"IF Stage II Full Dreambooth","local":"if-stage-ii-full-dreambooth","sections":[],"depth":3}],"depth":2},{"title":"Stable Diffusion XL","local":"stable-diffusion-xl","sections":[],"depth":2}],"depth":1}';function Xn(_){return dn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Sn extends un{constructor(o){super(),hn(this,o,Xn,Cn,mn,{})}}export{Sn as component};
