import{s as At,o as Qt,n as v}from"../chunks/scheduler.8c3d61f6.js";import{S as Pt,i as qt,g as u,s as r,r as h,A as Dt,h as d,f as l,c as p,j as St,u as $,x as _,k as zt,y as Kt,a as s,v as g,d as M,t as b,w as y}from"../chunks/index.da70eac4.js";import{T as Ue}from"../chunks/Tip.1d9b8c37.js";import{C as Z}from"../chunks/CodeBlock.00a903b3.js";import{H as be,E as Ot}from"../chunks/EditOnGithub.1e64e623.js";import{H as ht,a as ye}from"../chunks/HfOption.c1483eb1.js";function en(T){let t,o="The text-to-image script is experimental, and it’s easy to overfit and run into issues like catastrophic forgetting. Try exploring different hyperparameters to get the best results on your dataset.";return{c(){t=u("p"),t.textContent=o},l(a){t=d(a,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1we1bp2"&&(t.textContent=o)},m(a,m){s(a,t,m)},p:v,d(a){a&&l(t)}}}function tn(T){let t,o;return t=new Z({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHMudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image
pip install -r requirements.txt`,wrap:!1}}),{c(){h(t.$$.fragment)},l(a){$(t.$$.fragment,a)},m(a,m){g(t,a,m),o=!0},p:v,i(a){o||(M(t.$$.fragment,a),o=!0)},o(a){b(t.$$.fragment,a),o=!1},d(a){y(t,a)}}}function nn(T){let t,o;return t=new Z({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHRfdG9faW1hZ2UlMEFwaXAlMjBpbnN0YWxsJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:`<span class="hljs-built_in">cd</span> examples/text_to_image
pip install -r requirements_flax.txt`,wrap:!1}}),{c(){h(t.$$.fragment)},l(a){$(t.$$.fragment,a)},m(a,m){g(t,a,m),o=!0},p:v,i(a){o||(M(t.$$.fragment,a),o=!0)},o(a){b(t.$$.fragment,a),o=!1},d(a){y(t,a)}}}function an(T){let t,o,a,m;return t=new ye({props:{id:"installation",option:"PyTorch",$$slots:{default:[tn]},$$scope:{ctx:T}}}),a=new ye({props:{id:"installation",option:"Flax",$$slots:{default:[nn]},$$scope:{ctx:T}}}),{c(){h(t.$$.fragment),o=r(),h(a.$$.fragment)},l(i){$(t.$$.fragment,i),o=p(i),$(a.$$.fragment,i)},m(i,f){g(t,i,f),s(i,o,f),g(a,i,f),m=!0},p(i,f){const U={};f&2&&(U.$$scope={dirty:f,ctx:i}),t.$set(U);const c={};f&2&&(c.$$scope={dirty:f,ctx:i}),a.$set(c)},i(i){m||(M(t.$$.fragment,i),M(a.$$.fragment,i),m=!0)},o(i){b(t.$$.fragment,i),b(a.$$.fragment,i),m=!1},d(i){i&&l(o),y(t,i),y(a,i)}}}function ln(T){let t,o='🤗 Accelerate is a library for helping you train on multiple GPUs/TPUs or with mixed-precision. It’ll automatically configure your training setup based on your hardware and environment. Take a look at the 🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">Quick tour</a> to learn more.';return{c(){t=u("p"),t.innerHTML=o},l(a){t=d(a,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1qbiqsn"&&(t.innerHTML=o)},m(a,m){s(a,t,m)},p:v,d(a){a&&l(t)}}}function sn(T){let t,o='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/text_to_image/train_text_to_image.py" rel="nofollow">script</a> and let us know if you have any questions or concerns.';return{c(){t=u("p"),t.innerHTML=o},l(a){t=d(a,"P",{"data-svelte-h":!0}),_(t)!=="svelte-5wvv6y"&&(t.innerHTML=o)},m(a,m){s(a,t,m)},p:v,d(a){a&&l(t)}}}function on(T){let t,o="To train on a local dataset, set the <code>TRAIN_DIR</code> and <code>OUTPUT_DIR</code> environment variables to the path of the dataset and where to save the model to.";return{c(){t=u("p"),t.innerHTML=o},l(a){t=d(a,"P",{"data-svelte-h":!0}),_(t)!=="svelte-21tcs5"&&(t.innerHTML=o)},m(a,m){s(a,t,m)},p:v,d(a){a&&l(t)}}}function rn(T){let t,o='Let’s train on the <a href="https://huggingface.co/datasets/lambdalabs/naruto-blip-captions" rel="nofollow">Naruto BLIP captions</a> dataset to generate your own Naruto characters. Set the environment variables <code>MODEL_NAME</code> and <code>dataset_name</code> to the model and the dataset (either from the Hub or a local path). If you’re training on more than one GPU, add the <code>--multi_gpu</code> parameter to the <code>accelerate launch</code> command.',a,m,i,f,U;return m=new Ue({props:{$$slots:{default:[on]},$$scope:{ctx:T}}}),f=new Z({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQWV4cG9ydCUyMGRhdGFzZXRfbmFtZSUzRCUyMmxhbWJkYWxhYnMlMkZuYXJ1dG8tYmxpcC1jYXB0aW9ucyUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmZwMTYlMjIlMjAlMjB0cmFpbl90ZXh0X3RvX2ltYWdlLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAtLWRhdGFzZXRfbmFtZSUzRCUyNGRhdGFzZXRfbmFtZSUyMCU1QyUwQSUyMCUyMC0tdXNlX2VtYSUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMC0tY2VudGVyX2Nyb3AlMjAtLXJhbmRvbV9mbGlwJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfYWNjdW11bGF0aW9uX3N0ZXBzJTNENCUyMCU1QyUwQSUyMCUyMC0tZ3JhZGllbnRfY2hlY2twb2ludGluZyUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMTUwMDAlMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0QxZS0wNSUyMCU1QyUwQSUyMCUyMC0tbWF4X2dyYWRfbm9ybSUzRDElMjAlNUMlMEElMjAlMjAtLWVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbiUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjJzZC1uYXJ1dG8tbW9kZWwlMjIlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> dataset_name=<span class="hljs-string">&quot;lambdalabs/naruto-blip-captions&quot;</span>

accelerate launch --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>  train_text_to_image.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$dataset_name</span> \\
  --use_ema \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --gradient_checkpointing \\
  --max_train_steps=15000 \\
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --enable_xformers_memory_efficient_attention \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-string">&quot;sd-naruto-model&quot;</span> \\
  --push_to_hub`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=o,a=r(),h(m.$$.fragment),i=r(),h(f.$$.fragment)},l(c){t=d(c,"P",{"data-svelte-h":!0}),_(t)!=="svelte-9diks3"&&(t.innerHTML=o),a=p(c),$(m.$$.fragment,c),i=p(c),$(f.$$.fragment,c)},m(c,J){s(c,t,J),s(c,a,J),g(m,c,J),s(c,i,J),g(f,c,J),U=!0},p(c,J){const j={};J&2&&(j.$$scope={dirty:J,ctx:c}),m.$set(j)},i(c){U||(M(m.$$.fragment,c),M(f.$$.fragment,c),U=!0)},o(c){b(m.$$.fragment,c),b(f.$$.fragment,c),U=!1},d(c){c&&(l(t),l(a),l(i)),y(m,c),y(f,c)}}}function pn(T){let t,o="To train on a local dataset, set the <code>TRAIN_DIR</code> and <code>OUTPUT_DIR</code> environment variables to the path of the dataset and where to save the model to.";return{c(){t=u("p"),t.innerHTML=o},l(a){t=d(a,"P",{"data-svelte-h":!0}),_(t)!=="svelte-21tcs5"&&(t.innerHTML=o)},m(a,m){s(a,t,m)},p:v,d(a){a&&l(t)}}}function mn(T){let t,o='Training with Flax can be faster on TPUs and GPUs thanks to <a href="https://github.com/duongna21" rel="nofollow">@duongna211</a>. Flax is more efficient on a TPU, but GPU performance is also great.',a,m,i="Set the environment variables <code>MODEL_NAME</code> and <code>dataset_name</code> to the model and the dataset (either from the Hub or a local path).",f,U,c,J,j;return U=new Ue({props:{$$slots:{default:[pn]},$$scope:{ctx:T}}}),J=new Z({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQWV4cG9ydCUyMGRhdGFzZXRfbmFtZSUzRCUyMmxhbWJkYWxhYnMlMkZuYXJ1dG8tYmxpcC1jYXB0aW9ucyUyMiUwQSUwQXB5dGhvbiUyMHRyYWluX3RleHRfdG9faW1hZ2VfZmxheC5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTVDJTBBJTIwJTIwLS1kYXRhc2V0X25hbWUlM0QlMjRkYXRhc2V0X25hbWUlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAtLWNlbnRlcl9jcm9wJTIwLS1yYW5kb21fZmxpcCUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDE1MDAwJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNEMWUtMDUlMjAlNUMlMEElMjAlMjAtLW1heF9ncmFkX25vcm0lM0QxJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTIyc2QtbmFydXRvLW1vZGVsJTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> dataset_name=<span class="hljs-string">&quot;lambdalabs/naruto-blip-captions&quot;</span>

python train_text_to_image_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --dataset_name=<span class="hljs-variable">$dataset_name</span> \\
  --resolution=512 --center_crop --random_flip \\
  --train_batch_size=1 \\
  --max_train_steps=15000 \\
  --learning_rate=1e-05 \\
  --max_grad_norm=1 \\
  --output_dir=<span class="hljs-string">&quot;sd-naruto-model&quot;</span> \\
  --push_to_hub`,wrap:!1}}),{c(){t=u("p"),t.innerHTML=o,a=r(),m=u("p"),m.innerHTML=i,f=r(),h(U.$$.fragment),c=r(),h(J.$$.fragment)},l(w){t=d(w,"P",{"data-svelte-h":!0}),_(t)!=="svelte-1sxlda3"&&(t.innerHTML=o),a=p(w),m=d(w,"P",{"data-svelte-h":!0}),_(m)!=="svelte-1shpxr8"&&(m.innerHTML=i),f=p(w),$(U.$$.fragment,w),c=p(w),$(J.$$.fragment,w)},m(w,x){s(w,t,x),s(w,a,x),s(w,m,x),s(w,f,x),g(U,w,x),s(w,c,x),g(J,w,x),j=!0},p(w,x){const _e={};x&2&&(_e.$$scope={dirty:x,ctx:w}),U.$set(_e)},i(w){j||(M(U.$$.fragment,w),M(J.$$.fragment,w),j=!0)},o(w){b(U.$$.fragment,w),b(J.$$.fragment,w),j=!1},d(w){w&&(l(t),l(a),l(m),l(f),l(c)),y(U,w),y(J,w)}}}function fn(T){let t,o,a,m;return t=new ye({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[rn]},$$scope:{ctx:T}}}),a=new ye({props:{id:"training-inference",option:"Flax",$$slots:{default:[mn]},$$scope:{ctx:T}}}),{c(){h(t.$$.fragment),o=r(),h(a.$$.fragment)},l(i){$(t.$$.fragment,i),o=p(i),$(a.$$.fragment,i)},m(i,f){g(t,i,f),s(i,o,f),g(a,i,f),m=!0},p(i,f){const U={};f&2&&(U.$$scope={dirty:f,ctx:i}),t.$set(U);const c={};f&2&&(c.$$scope={dirty:f,ctx:i}),a.$set(c)},i(i){m||(M(t.$$.fragment,i),M(a.$$.fragment,i),m=!0)},o(i){b(t.$$.fragment,i),b(a.$$.fragment,i),m=!1},d(i){i&&l(o),y(t,i),y(a,i)}}}function cn(T){let t,o;return t=new Z({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJwYXRoJTJGdG8lMkZzYXZlZF9tb2RlbCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUyQyUyMHVzZV9zYWZldGVuc29ycyUzRFRydWUpLnRvKCUyMmN1ZGElMjIpJTBBJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlM0QlMjJ5b2RhJTIyKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJ5b2RhLW5hcnV0by5wbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

pipeline = StableDiffusionPipeline.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(prompt=<span class="hljs-string">&quot;yoda&quot;</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;yoda-naruto.png&quot;</span>)`,wrap:!1}}),{c(){h(t.$$.fragment)},l(a){$(t.$$.fragment,a)},m(a,m){g(t,a,m),o=!0},p:v,i(a){o||(M(t.$$.fragment,a),o=!0)},o(a){b(t.$$.fragment,a),o=!1},d(a){y(t,a)}}}function un(T){let t,o;return t=new Z({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMnBhdGglMkZ0byUyRnNhdmVkX21vZGVsJTIyJTJDJTIwZHR5cGUlM0RqYXgubnVtcHkuYmZsb2F0MTYpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyeW9kYSUyMG5hcnV0byUyMiUwQXBybmdfc2VlZCUyMCUzRCUyMGpheC5yYW5kb20uUFJOR0tleSgwKSUwQW51bV9pbmZlcmVuY2Vfc3RlcHMlMjAlM0QlMjA1MCUwQSUwQW51bV9zYW1wbGVzJTIwJTNEJTIwamF4LmRldmljZV9jb3VudCgpJTBBcHJvbXB0JTIwJTNEJTIwbnVtX3NhbXBsZXMlMjAqJTIwJTVCcHJvbXB0JTVEJTBBcHJvbXB0X2lkcyUyMCUzRCUyMHBpcGVsaW5lLnByZXBhcmVfaW5wdXRzKHByb21wdCklMEElMEElMjMlMjBzaGFyZCUyMGlucHV0cyUyMGFuZCUyMHJuZyUwQXBhcmFtcyUyMCUzRCUyMHJlcGxpY2F0ZShwYXJhbXMpJTBBcHJuZ19zZWVkJTIwJTNEJTIwamF4LnJhbmRvbS5zcGxpdChwcm5nX3NlZWQlMkMlMjBqYXguZGV2aWNlX2NvdW50KCkpJTBBcHJvbXB0X2lkcyUyMCUzRCUyMHNoYXJkKHByb21wdF9pZHMpJTBBJTBBaW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0X2lkcyUyQyUyMHBhcmFtcyUyQyUyMHBybmdfc2VlZCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlMkMlMjBqaXQlM0RUcnVlKS5pbWFnZXMlMEFpbWFnZXMlMjAlM0QlMjBwaXBlbGluZS5udW1weV90b19waWwobnAuYXNhcnJheShpbWFnZXMucmVzaGFwZSgobnVtX3NhbXBsZXMlMkMpJTIwJTJCJTIwaW1hZ2VzLnNoYXBlJTVCLTMlM0ElNUQpKSklMEFpbWFnZS5zYXZlKCUyMnlvZGEtbmFydXRvLnBuZyUyMik=",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/saved_model&quot;</span>, dtype=jax.numpy.bfloat16)

prompt = <span class="hljs-string">&quot;yoda naruto&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;yoda-naruto.png&quot;</span>)`,wrap:!1}}),{c(){h(t.$$.fragment)},l(a){$(t.$$.fragment,a)},m(a,m){g(t,a,m),o=!0},p:v,i(a){o||(M(t.$$.fragment,a),o=!0)},o(a){b(t.$$.fragment,a),o=!1},d(a){y(t,a)}}}function dn(T){let t,o,a,m;return t=new ye({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[cn]},$$scope:{ctx:T}}}),a=new ye({props:{id:"training-inference",option:"Flax",$$slots:{default:[un]},$$scope:{ctx:T}}}),{c(){h(t.$$.fragment),o=r(),h(a.$$.fragment)},l(i){$(t.$$.fragment,i),o=p(i),$(a.$$.fragment,i)},m(i,f){g(t,i,f),s(i,o,f),g(a,i,f),m=!0},p(i,f){const U={};f&2&&(U.$$scope={dirty:f,ctx:i}),t.$set(U);const c={};f&2&&(c.$$scope={dirty:f,ctx:i}),a.$set(c)},i(i){m||(M(t.$$.fragment,i),M(a.$$.fragment,i),m=!0)},o(i){b(t.$$.fragment,i),b(a.$$.fragment,i),m=!1},d(i){i&&l(o),y(t,i),y(a,i)}}}function hn(T){let t,o,a,m,i,f,U,c,J,j="Text-to-image models like Stable Diffusion are conditioned to generate images given a text prompt.",w,x,_e='Training a model can be taxing on your hardware, but if you enable <code>gradient_checkpointing</code> and <code>mixed_precision</code>, it is possible to train a model on a single 24GB GPU. If you’re training with larger batch sizes or want to train faster, it’s better to use GPUs with more than 30GB of memory. You can reduce your memory footprint by enabling 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, gradient accumulation or xFormers. A GPU with at least 30GB of memory or a TPU v3 is recommended for training with Flax.',Te,k,$t='This guide will explore the <a href="https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py" rel="nofollow">train_text_to_image.py</a> training script to help you become familiar with it, and how you can adapt it for your own use-case.',Je,B,gt="Before running the script, make sure you install the library from source:",xe,V,Ze,N,Mt="Then navigate to the example folder containing the training script and install the required dependencies for the script you’re using:",je,W,ve,X,We,H,bt="Initialize an 🤗 Accelerate environment:",Xe,F,Ce,L,yt="To setup a default 🤗 Accelerate environment without choosing any configurations:",Re,Y,Ge,I,_t="Or if your environment doesn’t support an interactive shell, like a notebook, you can use:",ke,E,Be,S,wt='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.',Ve,z,Ne,C,He,A,Ut='The training script provides many parameters to help you customize your training run. All of the parameters and their descriptions are found in the <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L193" rel="nofollow"><code>parse_args()</code></a> function. This function provides default values for each parameter, such as the training batch size and learning rate, but you can also set your own values in the training command if you’d like.',Fe,Q,Tt="For example, to speedup training with mixed precision using the fp16 format, add the <code>--mixed_precision</code> parameter to the training command:",Le,P,Ye,q,Jt="Some basic and important parameters include:",Ie,D,xt="<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>--dataset_name</code>: the name of the dataset on the Hub or a local path to the dataset to train on</li> <li><code>--image_column</code>: the name of the image column in the dataset to train on</li> <li><code>--caption_column</code>: the name of the text column in the dataset to train on</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>",Ee,K,Se,O,Zt='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.',ze,ee,jt="Add the <code>--snr_gamma</code> parameter and set it to the recommended value of 5.0:",Ae,te,Qe,ne,vt='You can compare the loss surfaces for different <code>snr_gamma</code> values in this <a href="https://wandb.ai/sayakpaul/text2image-finetune-minsnr" rel="nofollow">Weights and Biases</a> report. For smaller datasets, the effects of Min-SNR may not be as obvious compared to larger datasets.',Pe,ae,qe,le,Wt='The dataset preprocessing code and training loop are found in the <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L490" rel="nofollow"><code>main()</code></a> function. If you need to adapt the training script, this is where you’ll need to make your changes.',De,se,Xt='The <code>train_text_to_image</code> script starts by <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L543" rel="nofollow">loading a scheduler</a> and tokenizer. You can choose to use a different scheduler here if you want:',Ke,ie,Oe,oe,Ct='Then the script <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L619" rel="nofollow">loads the UNet</a> model:',et,re,tt,pe,Rt='Next, the text and image columns of the dataset need to be preprocessed. The <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L724" rel="nofollow"><code>tokenize_captions</code></a> function handles tokenizing the inputs, and the <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L742" rel="nofollow"><code>train_transforms</code></a> function specifies the type of transforms to apply to the image. Both of these functions are bundled into <code>preprocess_train</code>:',nt,me,at,fe,Gt='Lastly, the <a href="https://github.com/huggingface/diffusers/blob/8959c5b9dec1c94d6ba482c94a58d2215c5fd026/examples/text_to_image/train_text_to_image.py#L878" rel="nofollow">training loop</a> handles everything else. It encodes images into latent space, adds noise to the latents, computes the text embeddings to condition on, updates the model parameters, and saves and pushes the model to the Hub. 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.',lt,ce,st,ue,kt="Once you’ve made all your changes or you’re okay with the default configuration, you’re ready to launch the training script! 🚀",it,R,ot,de,Bt="Once training is complete, you can use your newly trained model for inference:",rt,G,pt,he,mt,$e,Vt="Congratulations on training your own text-to-image model! To learn more about how to use your new model, the following guides may be helpful:",ft,ge,Nt='<li>Learn how to <a href="../using-diffusers/loading_adapters#LoRA">load LoRA weights</a> for inference if you trained your model with LoRA.</li> <li>Learn more about how certain parameters like guidance scale or techniques such as prompt weighting can help you control inference in the <a href="../using-diffusers/conditional_image_generation">Text-to-image</a> task guide.</li>',ct,Me,ut,we,dt;return i=new be({props:{title:"Text-to-image",local:"text-to-image",headingTag:"h1"}}),U=new Ue({props:{warning:!0,$$slots:{default:[en]},$$scope:{ctx:T}}}),V=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}}),W=new ht({props:{id:"installation",options:["PyTorch","Flax"],$$slots:{default:[an]},$$scope:{ctx:T}}}),X=new Ue({props:{$$slots:{default:[ln]},$$scope:{ctx:T}}}),F=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),Y=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),E=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}}),z=new be({props:{title:"Script parameters",local:"script-parameters",headingTag:"h2"}}),C=new Ue({props:{$$slots:{default:[sn]},$$scope:{ctx:T}}}),P=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3RleHRfdG9faW1hZ2UucHklMjAlNUMlMEElMjAlMjAtLW1peGVkX3ByZWNpc2lvbiUzRCUyMmZwMTYlMjI=",highlighted:`accelerate launch train_text_to_image.py \\
  --mixed_precision=<span class="hljs-string">&quot;fp16&quot;</span>`,wrap:!1}}),K=new be({props:{title:"Min-SNR weighting",local:"min-snr-weighting",headingTag:"h3"}}),te=new Z({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRyYWluX3RleHRfdG9faW1hZ2UucHklMjAlNUMlMEElMjAlMjAtLXNucl9nYW1tYSUzRDUuMA==",highlighted:`accelerate launch train_text_to_image.py \\
  --snr_gamma=5.0`,wrap:!1}}),ae=new be({props:{title:"Training script",local:"training-script",headingTag:"h2"}}),ie=new Z({props:{code:"bm9pc2Vfc2NoZWR1bGVyJTIwJTNEJTIwRERQTVNjaGVkdWxlci5mcm9tX3ByZXRyYWluZWQoYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiklMEF0b2tlbml6ZXIlMjAlM0QlMjBDTElQVG9rZW5pemVyLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydG9rZW5pemVyJTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBKQ==",highlighted:`noise_scheduler = DDPMScheduler.from_pretrained(args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
tokenizer = CLIPTokenizer.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;tokenizer&quot;</span>, revision=args.revision
)`,wrap:!1}}),re=new Z({props:{code:"bG9hZF9tb2RlbCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZChpbnB1dF9kaXIlMkMlMjBzdWJmb2xkZXIlM0QlMjJ1bmV0JTIyKSUwQW1vZGVsLnJlZ2lzdGVyX3RvX2NvbmZpZygqKmxvYWRfbW9kZWwuY29uZmlnKSUwQSUwQW1vZGVsLmxvYWRfc3RhdGVfZGljdChsb2FkX21vZGVsLnN0YXRlX2RpY3QoKSk=",highlighted:`load_model = UNet2DConditionModel.from_pretrained(input_dir, subfolder=<span class="hljs-string">&quot;unet&quot;</span>)
model.register_to_config(**load_model.config)

model.load_state_dict(load_model.state_dict())`,wrap:!1}}),me=new Z({props:{code:"ZGVmJTIwcHJlcHJvY2Vzc190cmFpbihleGFtcGxlcyklM0ElMEElMjAlMjAlMjAlMjBpbWFnZXMlMjAlM0QlMjAlNUJpbWFnZS5jb252ZXJ0KCUyMlJHQiUyMiklMjBmb3IlMjBpbWFnZSUyMGluJTIwZXhhbXBsZXMlNUJpbWFnZV9jb2x1bW4lNUQlNUQlMEElMjAlMjAlMjAlMjBleGFtcGxlcyU1QiUyMnBpeGVsX3ZhbHVlcyUyMiU1RCUyMCUzRCUyMCU1QnRyYWluX3RyYW5zZm9ybXMoaW1hZ2UpJTIwZm9yJTIwaW1hZ2UlMjBpbiUyMGltYWdlcyU1RCUwQSUyMCUyMCUyMCUyMGV4YW1wbGVzJTVCJTIyaW5wdXRfaWRzJTIyJTVEJTIwJTNEJTIwdG9rZW5pemVfY2FwdGlvbnMoZXhhbXBsZXMpJTBBJTIwJTIwJTIwJTIwcmV0dXJuJTIwZXhhbXBsZXM=",highlighted:`<span class="hljs-keyword">def</span> <span class="hljs-title function_">preprocess_train</span>(<span class="hljs-params">examples</span>):
    images = [image.convert(<span class="hljs-string">&quot;RGB&quot;</span>) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> examples[image_column]]
    examples[<span class="hljs-string">&quot;pixel_values&quot;</span>] = [train_transforms(image) <span class="hljs-keyword">for</span> image <span class="hljs-keyword">in</span> images]
    examples[<span class="hljs-string">&quot;input_ids&quot;</span>] = tokenize_captions(examples)
    <span class="hljs-keyword">return</span> examples`,wrap:!1}}),ce=new be({props:{title:"Launch the script",local:"launch-the-script",headingTag:"h2"}}),R=new ht({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[fn]},$$scope:{ctx:T}}}),G=new ht({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[dn]},$$scope:{ctx:T}}}),he=new be({props:{title:"Next steps",local:"next-steps",headingTag:"h2"}}),Me=new Ot({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/training/text2image.md"}}),{c(){t=u("meta"),o=r(),a=u("p"),m=r(),h(i.$$.fragment),f=r(),h(U.$$.fragment),c=r(),J=u("p"),J.textContent=j,w=r(),x=u("p"),x.innerHTML=_e,Te=r(),k=u("p"),k.innerHTML=$t,Je=r(),B=u("p"),B.textContent=gt,xe=r(),h(V.$$.fragment),Ze=r(),N=u("p"),N.textContent=Mt,je=r(),h(W.$$.fragment),ve=r(),h(X.$$.fragment),We=r(),H=u("p"),H.textContent=bt,Xe=r(),h(F.$$.fragment),Ce=r(),L=u("p"),L.textContent=yt,Re=r(),h(Y.$$.fragment),Ge=r(),I=u("p"),I.textContent=_t,ke=r(),h(E.$$.fragment),Be=r(),S=u("p"),S.innerHTML=wt,Ve=r(),h(z.$$.fragment),Ne=r(),h(C.$$.fragment),He=r(),A=u("p"),A.innerHTML=Ut,Fe=r(),Q=u("p"),Q.innerHTML=Tt,Le=r(),h(P.$$.fragment),Ye=r(),q=u("p"),q.textContent=Jt,Ie=r(),D=u("ul"),D.innerHTML=xt,Ee=r(),h(K.$$.fragment),Se=r(),O=u("p"),O.innerHTML=Zt,ze=r(),ee=u("p"),ee.innerHTML=jt,Ae=r(),h(te.$$.fragment),Qe=r(),ne=u("p"),ne.innerHTML=vt,Pe=r(),h(ae.$$.fragment),qe=r(),le=u("p"),le.innerHTML=Wt,De=r(),se=u("p"),se.innerHTML=Xt,Ke=r(),h(ie.$$.fragment),Oe=r(),oe=u("p"),oe.innerHTML=Ct,et=r(),h(re.$$.fragment),tt=r(),pe=u("p"),pe.innerHTML=Rt,nt=r(),h(me.$$.fragment),at=r(),fe=u("p"),fe.innerHTML=Gt,lt=r(),h(ce.$$.fragment),st=r(),ue=u("p"),ue.textContent=kt,it=r(),h(R.$$.fragment),ot=r(),de=u("p"),de.textContent=Bt,rt=r(),h(G.$$.fragment),pt=r(),h(he.$$.fragment),mt=r(),$e=u("p"),$e.textContent=Vt,ft=r(),ge=u("ul"),ge.innerHTML=Nt,ct=r(),h(Me.$$.fragment),ut=r(),we=u("p"),this.h()},l(e){const n=Dt("svelte-u9bgzb",document.head);t=d(n,"META",{name:!0,content:!0}),n.forEach(l),o=p(e),a=d(e,"P",{}),St(a).forEach(l),m=p(e),$(i.$$.fragment,e),f=p(e),$(U.$$.fragment,e),c=p(e),J=d(e,"P",{"data-svelte-h":!0}),_(J)!=="svelte-1y4tuwx"&&(J.textContent=j),w=p(e),x=d(e,"P",{"data-svelte-h":!0}),_(x)!=="svelte-1aeplm2"&&(x.innerHTML=_e),Te=p(e),k=d(e,"P",{"data-svelte-h":!0}),_(k)!=="svelte-1n3skb8"&&(k.innerHTML=$t),Je=p(e),B=d(e,"P",{"data-svelte-h":!0}),_(B)!=="svelte-l7dm2q"&&(B.textContent=gt),xe=p(e),$(V.$$.fragment,e),Ze=p(e),N=d(e,"P",{"data-svelte-h":!0}),_(N)!=="svelte-z4z0b9"&&(N.textContent=Mt),je=p(e),$(W.$$.fragment,e),ve=p(e),$(X.$$.fragment,e),We=p(e),H=d(e,"P",{"data-svelte-h":!0}),_(H)!=="svelte-60q53m"&&(H.textContent=bt),Xe=p(e),$(F.$$.fragment,e),Ce=p(e),L=d(e,"P",{"data-svelte-h":!0}),_(L)!=="svelte-di6juu"&&(L.textContent=yt),Re=p(e),$(Y.$$.fragment,e),Ge=p(e),I=d(e,"P",{"data-svelte-h":!0}),_(I)!=="svelte-tsz4qp"&&(I.textContent=_t),ke=p(e),$(E.$$.fragment,e),Be=p(e),S=d(e,"P",{"data-svelte-h":!0}),_(S)!=="svelte-1fkfdql"&&(S.innerHTML=wt),Ve=p(e),$(z.$$.fragment,e),Ne=p(e),$(C.$$.fragment,e),He=p(e),A=d(e,"P",{"data-svelte-h":!0}),_(A)!=="svelte-1rkoo94"&&(A.innerHTML=Ut),Fe=p(e),Q=d(e,"P",{"data-svelte-h":!0}),_(Q)!=="svelte-1r0bv1x"&&(Q.innerHTML=Tt),Le=p(e),$(P.$$.fragment,e),Ye=p(e),q=d(e,"P",{"data-svelte-h":!0}),_(q)!=="svelte-1mzaa4h"&&(q.textContent=Jt),Ie=p(e),D=d(e,"UL",{"data-svelte-h":!0}),_(D)!=="svelte-l4ycdy"&&(D.innerHTML=xt),Ee=p(e),$(K.$$.fragment,e),Se=p(e),O=d(e,"P",{"data-svelte-h":!0}),_(O)!=="svelte-isitbv"&&(O.innerHTML=Zt),ze=p(e),ee=d(e,"P",{"data-svelte-h":!0}),_(ee)!=="svelte-tp3kp"&&(ee.innerHTML=jt),Ae=p(e),$(te.$$.fragment,e),Qe=p(e),ne=d(e,"P",{"data-svelte-h":!0}),_(ne)!=="svelte-1kq6d2e"&&(ne.innerHTML=vt),Pe=p(e),$(ae.$$.fragment,e),qe=p(e),le=d(e,"P",{"data-svelte-h":!0}),_(le)!=="svelte-1ibfk21"&&(le.innerHTML=Wt),De=p(e),se=d(e,"P",{"data-svelte-h":!0}),_(se)!=="svelte-1yog97t"&&(se.innerHTML=Xt),Ke=p(e),$(ie.$$.fragment,e),Oe=p(e),oe=d(e,"P",{"data-svelte-h":!0}),_(oe)!=="svelte-1au88ib"&&(oe.innerHTML=Ct),et=p(e),$(re.$$.fragment,e),tt=p(e),pe=d(e,"P",{"data-svelte-h":!0}),_(pe)!=="svelte-1e0707i"&&(pe.innerHTML=Rt),nt=p(e),$(me.$$.fragment,e),at=p(e),fe=d(e,"P",{"data-svelte-h":!0}),_(fe)!=="svelte-13vuqhc"&&(fe.innerHTML=Gt),lt=p(e),$(ce.$$.fragment,e),st=p(e),ue=d(e,"P",{"data-svelte-h":!0}),_(ue)!=="svelte-9dei1q"&&(ue.textContent=kt),it=p(e),$(R.$$.fragment,e),ot=p(e),de=d(e,"P",{"data-svelte-h":!0}),_(de)!=="svelte-1jtuc6"&&(de.textContent=Bt),rt=p(e),$(G.$$.fragment,e),pt=p(e),$(he.$$.fragment,e),mt=p(e),$e=d(e,"P",{"data-svelte-h":!0}),_($e)!=="svelte-127gxsw"&&($e.textContent=Vt),ft=p(e),ge=d(e,"UL",{"data-svelte-h":!0}),_(ge)!=="svelte-10nfhag"&&(ge.innerHTML=Nt),ct=p(e),$(Me.$$.fragment,e),ut=p(e),we=d(e,"P",{}),St(we).forEach(l),this.h()},h(){zt(t,"name","hf:doc:metadata"),zt(t,"content",$n)},m(e,n){Kt(document.head,t),s(e,o,n),s(e,a,n),s(e,m,n),g(i,e,n),s(e,f,n),g(U,e,n),s(e,c,n),s(e,J,n),s(e,w,n),s(e,x,n),s(e,Te,n),s(e,k,n),s(e,Je,n),s(e,B,n),s(e,xe,n),g(V,e,n),s(e,Ze,n),s(e,N,n),s(e,je,n),g(W,e,n),s(e,ve,n),g(X,e,n),s(e,We,n),s(e,H,n),s(e,Xe,n),g(F,e,n),s(e,Ce,n),s(e,L,n),s(e,Re,n),g(Y,e,n),s(e,Ge,n),s(e,I,n),s(e,ke,n),g(E,e,n),s(e,Be,n),s(e,S,n),s(e,Ve,n),g(z,e,n),s(e,Ne,n),g(C,e,n),s(e,He,n),s(e,A,n),s(e,Fe,n),s(e,Q,n),s(e,Le,n),g(P,e,n),s(e,Ye,n),s(e,q,n),s(e,Ie,n),s(e,D,n),s(e,Ee,n),g(K,e,n),s(e,Se,n),s(e,O,n),s(e,ze,n),s(e,ee,n),s(e,Ae,n),g(te,e,n),s(e,Qe,n),s(e,ne,n),s(e,Pe,n),g(ae,e,n),s(e,qe,n),s(e,le,n),s(e,De,n),s(e,se,n),s(e,Ke,n),g(ie,e,n),s(e,Oe,n),s(e,oe,n),s(e,et,n),g(re,e,n),s(e,tt,n),s(e,pe,n),s(e,nt,n),g(me,e,n),s(e,at,n),s(e,fe,n),s(e,lt,n),g(ce,e,n),s(e,st,n),s(e,ue,n),s(e,it,n),g(R,e,n),s(e,ot,n),s(e,de,n),s(e,rt,n),g(G,e,n),s(e,pt,n),g(he,e,n),s(e,mt,n),s(e,$e,n),s(e,ft,n),s(e,ge,n),s(e,ct,n),g(Me,e,n),s(e,ut,n),s(e,we,n),dt=!0},p(e,[n]){const Ht={};n&2&&(Ht.$$scope={dirty:n,ctx:e}),U.$set(Ht);const Ft={};n&2&&(Ft.$$scope={dirty:n,ctx:e}),W.$set(Ft);const Lt={};n&2&&(Lt.$$scope={dirty:n,ctx:e}),X.$set(Lt);const Yt={};n&2&&(Yt.$$scope={dirty:n,ctx:e}),C.$set(Yt);const It={};n&2&&(It.$$scope={dirty:n,ctx:e}),R.$set(It);const Et={};n&2&&(Et.$$scope={dirty:n,ctx:e}),G.$set(Et)},i(e){dt||(M(i.$$.fragment,e),M(U.$$.fragment,e),M(V.$$.fragment,e),M(W.$$.fragment,e),M(X.$$.fragment,e),M(F.$$.fragment,e),M(Y.$$.fragment,e),M(E.$$.fragment,e),M(z.$$.fragment,e),M(C.$$.fragment,e),M(P.$$.fragment,e),M(K.$$.fragment,e),M(te.$$.fragment,e),M(ae.$$.fragment,e),M(ie.$$.fragment,e),M(re.$$.fragment,e),M(me.$$.fragment,e),M(ce.$$.fragment,e),M(R.$$.fragment,e),M(G.$$.fragment,e),M(he.$$.fragment,e),M(Me.$$.fragment,e),dt=!0)},o(e){b(i.$$.fragment,e),b(U.$$.fragment,e),b(V.$$.fragment,e),b(W.$$.fragment,e),b(X.$$.fragment,e),b(F.$$.fragment,e),b(Y.$$.fragment,e),b(E.$$.fragment,e),b(z.$$.fragment,e),b(C.$$.fragment,e),b(P.$$.fragment,e),b(K.$$.fragment,e),b(te.$$.fragment,e),b(ae.$$.fragment,e),b(ie.$$.fragment,e),b(re.$$.fragment,e),b(me.$$.fragment,e),b(ce.$$.fragment,e),b(R.$$.fragment,e),b(G.$$.fragment,e),b(he.$$.fragment,e),b(Me.$$.fragment,e),dt=!1},d(e){e&&(l(o),l(a),l(m),l(f),l(c),l(J),l(w),l(x),l(Te),l(k),l(Je),l(B),l(xe),l(Ze),l(N),l(je),l(ve),l(We),l(H),l(Xe),l(Ce),l(L),l(Re),l(Ge),l(I),l(ke),l(Be),l(S),l(Ve),l(Ne),l(He),l(A),l(Fe),l(Q),l(Le),l(Ye),l(q),l(Ie),l(D),l(Ee),l(Se),l(O),l(ze),l(ee),l(Ae),l(Qe),l(ne),l(Pe),l(qe),l(le),l(De),l(se),l(Ke),l(Oe),l(oe),l(et),l(tt),l(pe),l(nt),l(at),l(fe),l(lt),l(st),l(ue),l(it),l(ot),l(de),l(rt),l(pt),l(mt),l($e),l(ft),l(ge),l(ct),l(ut),l(we)),l(t),y(i,e),y(U,e),y(V,e),y(W,e),y(X,e),y(F,e),y(Y,e),y(E,e),y(z,e),y(C,e),y(P,e),y(K,e),y(te,e),y(ae,e),y(ie,e),y(re,e),y(me,e),y(ce,e),y(R,e),y(G,e),y(he,e),y(Me,e)}}}const $n='{"title":"Text-to-image","local":"text-to-image","sections":[{"title":"Script parameters","local":"script-parameters","sections":[{"title":"Min-SNR weighting","local":"min-snr-weighting","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":"Next steps","local":"next-steps","sections":[],"depth":2}],"depth":1}';function gn(T){return Qt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Tn extends Pt{constructor(t){super(),qt(this,t,gn,hn,At,{})}}export{Tn as component};
