import{s as el,o as tl,n as g}from"../chunks/scheduler.5c93273d.js";import{S as ll,i as sl,g as m,s as r,r as M,A as nl,h as u,f as n,c as o,j as Kt,u as d,x as _,k as Ot,y as al,a,v as J,d as y,t as $,w as b}from"../chunks/index.e43dd92b.js";import{T as yt}from"../chunks/Tip.1cbfe904.js";import{C as U}from"../chunks/CodeBlock.6896320e.js";import{H as he,E as il}from"../chunks/getInferenceSnippets.d410b42d.js";import{H as $t,a as be}from"../chunks/HfOption.d50154c3.js";function pl(h){let l,p;return l=new U({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHR1YWxfaW52ZXJzaW9uJTBBcGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzLnR4dA==",highlighted:`<span class="hljs-built_in">cd</span> examples/textual_inversion
pip install -r requirements.txt`,wrap:!1}}),{c(){M(l.$$.fragment)},l(s){d(l.$$.fragment,s)},m(s,c){J(l,s,c),p=!0},p:g,i(s){p||(y(l.$$.fragment,s),p=!0)},o(s){$(l.$$.fragment,s),p=!1},d(s){b(l,s)}}}function rl(h){let l,p;return l=new U({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHR1YWxfaW52ZXJzaW9uJTBBcGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzX2ZsYXgudHh0",highlighted:`<span class="hljs-built_in">cd</span> examples/textual_inversion
pip install -r requirements_flax.txt`,wrap:!1}}),{c(){M(l.$$.fragment)},l(s){d(l.$$.fragment,s)},m(s,c){J(l,s,c),p=!0},p:g,i(s){p||(y(l.$$.fragment,s),p=!0)},o(s){$(l.$$.fragment,s),p=!1},d(s){b(l,s)}}}function ol(h){let l,p,s,c;return l=new be({props:{id:"installation",option:"PyTorch",$$slots:{default:[pl]},$$scope:{ctx:h}}}),s=new be({props:{id:"installation",option:"Flax",$$slots:{default:[rl]},$$scope:{ctx:h}}}),{c(){M(l.$$.fragment),p=r(),M(s.$$.fragment)},l(i){d(l.$$.fragment,i),p=o(i),d(s.$$.fragment,i)},m(i,f){J(l,i,f),a(i,p,f),J(s,i,f),c=!0},p(i,f){const T={};f&2&&(T.$$scope={dirty:f,ctx:i}),l.$set(T);const w={};f&2&&(w.$$scope={dirty:f,ctx:i}),s.$set(w)},i(i){c||(y(l.$$.fragment,i),y(s.$$.fragment,i),c=!0)},o(i){$(l.$$.fragment,i),$(s.$$.fragment,i),c=!1},d(i){i&&n(p),b(l,i),b(s,i)}}}function fl(h){let l,p='🤗 Accelerate 是一个帮助您在多GPU/TPU或混合精度环境下训练的工具库。它会根据硬件和环境自动配置训练设置。查看🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">快速入门</a>了解更多。';return{c(){l=m("p"),l.innerHTML=p},l(s){l=u(s,"P",{"data-svelte-h":!0}),_(l)!=="svelte-17yq3xy"&&(l.innerHTML=p)},m(s,c){a(s,l,c)},p:g,d(s){s&&n(l)}}}function cl(h){let l,p='以下部分重点介绍训练脚本中需要理解的关键修改点，但未涵盖脚本所有细节。如需深入了解，可随时查阅<a href="https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py" rel="nofollow">脚本源码</a>，如有疑问欢迎反馈。';return{c(){l=m("p"),l.innerHTML=p},l(s){l=u(s,"P",{"data-svelte-h":!0}),_(l)!=="svelte-1j29v6z"&&(l.innerHTML=p)},m(s,c){a(s,l,c)},p:g,d(s){s&&n(l)}}}function ml(h){let l,p="在单块V100 GPU上完整训练约需1小时。";return{c(){l=m("p"),l.textContent=p},l(s){l=u(s,"P",{"data-svelte-h":!0}),_(l)!=="svelte-19bhqr7"&&(l.textContent=p)},m(s,c){a(s,l,c)},p:g,d(s){s&&n(l)}}}function ul(h){let l,p;return l=new U({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQWV4cG9ydCUyMERBVEFfRElSJTNEJTIyLiUyRmNhdCUyMiUwQSUwQWFjY2VsZXJhdGUlMjBsYXVuY2glMjB0ZXh0dWFsX2ludmVyc2lvbi5weSUyMCU1QyUwQSUyMCUyMC0tcHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglM0QlMjRNT0RFTF9OQU1FJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9kYXRhX2RpciUzRCUyNERBVEFfRElSJTIwJTVDJTBBJTIwJTIwLS1sZWFybmFibGVfcHJvcGVydHklM0QlMjJvYmplY3QlMjIlMjAlNUMlMEElMjAlMjAtLXBsYWNlaG9sZGVyX3Rva2VuJTNEJTIyJTNDY2F0LXRveSUzRSUyMiUyMCU1QyUwQSUyMCUyMC0taW5pdGlhbGl6ZXJfdG9rZW4lM0QlMjJ0b3klMjIlMjAlNUMlMEElMjAlMjAtLXJlc29sdXRpb24lM0Q1MTIlMjAlNUMlMEElMjAlMjAtLXRyYWluX2JhdGNoX3NpemUlM0QxJTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q0JTIwJTVDJTBBJTIwJTIwLS1tYXhfdHJhaW5fc3RlcHMlM0QzMDAwJTIwJTVDJTBBJTIwJTIwLS1sZWFybmluZ19yYXRlJTNENS4wZS0wNCUyMCU1QyUwQSUyMCUyMC0tc2NhbGVfbHIlMjAlNUMlMEElMjAlMjAtLWxyX3NjaGVkdWxlciUzRCUyMmNvbnN0YW50JTIyJTIwJTVDJTBBJTIwJTIwLS1scl93YXJtdXBfc3RlcHMlM0QwJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTIydGV4dHVhbF9pbnZlcnNpb25fY2F0JTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",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> DATA_DIR=<span class="hljs-string">&quot;./cat&quot;</span>

accelerate launch textual_inversion.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --train_data_dir=<span class="hljs-variable">$DATA_DIR</span> \\
  --learnable_property=<span class="hljs-string">&quot;object&quot;</span> \\
  --placeholder_token=<span class="hljs-string">&quot;&lt;cat-toy&gt;&quot;</span> \\
  --initializer_token=<span class="hljs-string">&quot;toy&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --max_train_steps=3000 \\
  --learning_rate=5.0e-04 \\
  --scale_lr \\
  --lr_scheduler=<span class="hljs-string">&quot;constant&quot;</span> \\
  --lr_warmup_steps=0 \\
  --output_dir=<span class="hljs-string">&quot;textual_inversion_cat&quot;</span> \\
  --push_to_hub`,wrap:!1}}),{c(){M(l.$$.fragment)},l(s){d(l.$$.fragment,s)},m(s,c){J(l,s,c),p=!0},p:g,i(s){p||(y(l.$$.fragment,s),p=!0)},o(s){$(l.$$.fragment,s),p=!1},d(s){b(l,s)}}}function Ml(h){let l,p;return l=new U({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMERBVEFfRElSJTNEJTIyLiUyRmNhdCUyMiUwQSUwQXB5dGhvbiUyMHRleHR1YWxfaW52ZXJzaW9uX2ZsYXgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fZGF0YV9kaXIlM0QlMjREQVRBX0RJUiUyMCU1QyUwQSUyMCUyMC0tbGVhcm5hYmxlX3Byb3BlcnR5JTNEJTIyb2JqZWN0JTIyJTIwJTVDJTBBJTIwJTIwLS1wbGFjZWhvbGRlcl90b2tlbiUzRCUyMiUzQ2NhdC10b3klM0UlMjIlMjAlNUMlMEElMjAlMjAtLWluaXRpYWxpemVyX3Rva2VuJTNEJTIydG95JTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMzAwMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDUuMGUtMDQlMjAlNUMlMEElMjAlMjAtLXNjYWxlX2xyJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTIydGV4dHVhbF9pbnZlcnNpb25fY2F0JTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",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> DATA_DIR=<span class="hljs-string">&quot;./cat&quot;</span>

python textual_inversion_flax.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> \\
  --train_data_dir=<span class="hljs-variable">$DATA_DIR</span> \\
  --learnable_property=<span class="hljs-string">&quot;object&quot;</span> \\
  --placeholder_token=<span class="hljs-string">&quot;&lt;cat-toy&gt;&quot;</span> \\
  --initializer_token=<span class="hljs-string">&quot;toy&quot;</span> \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --max_train_steps=3000 \\
  --learning_rate=5.0e-04 \\
  --scale_lr \\
  --output_dir=<span class="hljs-string">&quot;textual_inversion_cat&quot;</span> \\
  --push_to_hub`,wrap:!1}}),{c(){M(l.$$.fragment)},l(s){d(l.$$.fragment,s)},m(s,c){J(l,s,c),p=!0},p:g,i(s){p||(y(l.$$.fragment,s),p=!0)},o(s){$(l.$$.fragment,s),p=!1},d(s){b(l,s)}}}function dl(h){let l,p,s,c;return l=new be({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[ul]},$$scope:{ctx:h}}}),s=new be({props:{id:"training-inference",option:"Flax",$$slots:{default:[Ml]},$$scope:{ctx:h}}}),{c(){M(l.$$.fragment),p=r(),M(s.$$.fragment)},l(i){d(l.$$.fragment,i),p=o(i),d(s.$$.fragment,i)},m(i,f){J(l,i,f),a(i,p,f),J(s,i,f),c=!0},p(i,f){const T={};f&2&&(T.$$scope={dirty:f,ctx:i}),l.$set(T);const w={};f&2&&(w.$$scope={dirty:f,ctx:i}),s.$set(w)},i(i){c||(y(l.$$.fragment,i),y(s.$$.fragment,i),c=!0)},o(i){$(l.$$.fragment,i),$(s.$$.fragment,i),c=!1},d(i){i&&n(p),b(l,i),b(s,i)}}}function Jl(h){let l,p;return l=new U({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJzdGFibGUtZGlmZnVzaW9uLXYxLTUlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTUlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBcGlwZWxpbmUubG9hZF90ZXh0dWFsX2ludmVyc2lvbiglMjJzZC1jb25jZXB0cy1saWJyYXJ5JTJGY2F0LXRveSUyMiklMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lKCUyMkElMjAlM0NjYXQtdG95JTNFJTIwdHJhaW4lMjIlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTApLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmNhdC10cmFpbi5wbmclMjIp",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;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/cat-toy&quot;</span>)
image = pipeline(<span class="hljs-string">&quot;A &lt;cat-toy&gt; train&quot;</span>, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;cat-train.png&quot;</span>)`,wrap:!1}}),{c(){M(l.$$.fragment)},l(s){d(l.$$.fragment,s)},m(s,c){J(l,s,c),p=!0},p:g,i(s){p||(y(l.$$.fragment,s),p=!0)},o(s){$(l.$$.fragment,s),p=!1},d(s){b(l,s)}}}function yl(h){let l,p='Flax不支持<code>load_textual_inversion()</code>方法，但textual_inversion_flax.py脚本会在训练后<a href="https://github.com/huggingface/diffusers/blob/c0f058265161178f2a88849e92b37ffdc81f1dcc/examples/textual_inversion/textual_inversion_flax.py#L636C2-L636C2" rel="nofollow">保存</a>学习到的嵌入作为模型的一部分。这意味着您可以像使用其他Flax模型一样进行推理：',s,c,i;return c=new U({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMnBhdGgtdG8teW91ci10cmFpbmVkLW1vZGVsJTIyJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX3BhdGglMkMlMjBkdHlwZSUzRGpheC5udW1weS5iZmxvYXQxNiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwJTNDY2F0LXRveSUzRSUyMHRyYWluJTIyJTBBcHJuZ19zZWVkJTIwJTNEJTIwamF4LnJhbmRvbS5QUk5HS2V5KDApJTBBbnVtX2luZmVyZW5jZV9zdGVwcyUyMCUzRCUyMDUwJTBBJTBBbnVtX3NhbXBsZXMlMjAlM0QlMjBqYXguZGV2aWNlX2NvdW50KCklMEFwcm9tcHQlMjAlM0QlMjBudW1fc2FtcGxlcyUyMColMjAlNUJwcm9tcHQlNUQlMEFwcm9tcHRfaWRzJTIwJTNEJTIwcGlwZWxpbmUucHJlcGFyZV9pbnB1dHMocHJvbXB0KSUwQSUwQSUyMyUyMCVFNSU4OCU4NiVFNyU4OSU4NyVFOCVCRSU5MyVFNSU4NSVBNSVFNSU5MiU4QyVFOSU5QSU4RiVFNiU5QyVCQSVFNiU5NSVCMCVFNyU5NCU5RiVFNiU4OCU5MCVFNSU5OSVBOCUwQXBhcmFtcyUyMCUzRCUyMHJlcGxpY2F0ZShwYXJhbXMpJTBBcHJuZ19zZWVkJTIwJTNEJTIwamF4LnJhbmRvbS5zcGxpdChwcm5nX3NlZWQlMkMlMjBqYXguZGV2aWNlX2NvdW50KCkpJTBBcHJvbXB0X2lkcyUyMCUzRCUyMHNoYXJkKHByb21wdF9pZHMpJTBBJTBBaW1hZ2VzJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0X2lkcyUyQyUyMHBhcmFtcyUyQyUyMHBybmdfc2VlZCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlMkMlMjBqaXQlM0RUcnVlKS5pbWFnZXMlMEFpbWFnZXMlMjAlM0QlMjBwaXBlbGluZS5udW1weV90b19waWwobnAuYXNhcnJheShpbWFnZXMucmVzaGFwZSgobnVtX3NhbXBsZXMlMkMpJTIwJTJCJTIwaW1hZ2VzLnNoYXBlJTVCLTMlM0ElNUQpKSklMEFpbWFnZS5zYXZlKCUyMmNhdC10cmFpbi5wbmclMjIp",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

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

prompt = <span class="hljs-string">&quot;A &lt;cat-toy&gt; train&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"># 分片输入和随机数生成器</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;cat-train.png&quot;</span>)`,wrap:!1}}),{c(){l=m("p"),l.innerHTML=p,s=r(),M(c.$$.fragment)},l(f){l=u(f,"P",{"data-svelte-h":!0}),_(l)!=="svelte-1272v9b"&&(l.innerHTML=p),s=o(f),d(c.$$.fragment,f)},m(f,T){a(f,l,T),a(f,s,T),J(c,f,T),i=!0},p:g,i(f){i||(y(c.$$.fragment,f),i=!0)},o(f){$(c.$$.fragment,f),i=!1},d(f){f&&(n(l),n(s)),b(c,f)}}}function $l(h){let l,p,s,c;return l=new be({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[Jl]},$$scope:{ctx:h}}}),s=new be({props:{id:"training-inference",option:"Flax",$$slots:{default:[yl]},$$scope:{ctx:h}}}),{c(){M(l.$$.fragment),p=r(),M(s.$$.fragment)},l(i){d(l.$$.fragment,i),p=o(i),d(s.$$.fragment,i)},m(i,f){J(l,i,f),a(i,p,f),J(s,i,f),c=!0},p(i,f){const T={};f&2&&(T.$$scope={dirty:f,ctx:i}),l.$set(T);const w={};f&2&&(w.$$scope={dirty:f,ctx:i}),s.$set(w)},i(i){c||(y(l.$$.fragment,i),y(s.$$.fragment,i),c=!0)},o(i){$(l.$$.fragment,i),$(s.$$.fragment,i),c=!1},d(i){i&&n(p),b(l,i),b(s,i)}}}function bl(h){let l,p,s,c,i,f,T,w='<a href="https://hf.co/papers/2208.01618" rel="nofollow">文本反转</a>是一种训练技术，仅需少量示例图像即可个性化图像生成模型。该技术通过学习和更新文本嵌入（新嵌入会绑定到提示中必须使用的特殊词汇）来匹配您提供的示例图像。',Te,W,bt='如果在显存有限的GPU上训练，建议在训练命令中启用<code>gradient_checkpointing</code>和<code>mixed_precision</code>参数。您还可以通过<a href="../optimization/xformers">xFormers</a>使用内存高效注意力机制来减少内存占用。JAX/Flax训练也支持在TPU和GPU上进行高效训练，但不支持梯度检查点或xFormers。在配置与PyTorch相同的情况下，Flax训练脚本的速度至少应快70%！',Ue,R,_t='本指南将探索<a href="https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py" rel="nofollow">textual_inversion.py</a>脚本，帮助您更熟悉其工作原理，并了解如何根据自身需求进行调整。',we,B,ht="运行脚本前，请确保从源码安装库：",ge,V,Ze,G,Tt="进入包含训练脚本的示例目录，并安装所需依赖：",je,Z,ve,j,xe,F,Ut="初始化🤗 Accelerate环境：",Xe,I,Ce,k,wt="要设置默认的🤗 Accelerate环境（不选择任何配置）：",We,N,Re,Y,gt="如果您的环境不支持交互式shell（如notebook），可以使用：",Be,E,Ve,H,Zt='最后，如果想在自定义数据集上训练模型，请参阅<a href="create_dataset">创建训练数据集</a>指南，了解如何创建适用于训练脚本的数据集。',Ge,v,Fe,L,Ie,z,jt='训练脚本包含众多参数，便于您定制训练过程。所有参数及其说明都列在<a href="https://github.com/huggingface/diffusers/blob/839c2a5ece0af4e75530cb520d77bc7ed8acf474/examples/textual_inversion/textual_inversion.py#L176" rel="nofollow"><code>parse_args()</code></a>函数中。Diffusers为每个参数提供了默认值（如训练批次大小和学习率），但您可以通过训练命令自由调整这些值。',ke,S,vt="例如，将梯度累积步数增加到默认值1以上：",Ne,Q,Ye,A,xt="其他需要指定的基础重要参数包括：",Ee,q,Xt="<li><code>--pretrained_model_name_or_path</code>：Hub上的模型名称或本地预训练模型路径</li> <li><code>--train_data_dir</code>：包含训练数据集（示例图像）的文件夹路径</li> <li><code>--output_dir</code>：训练模型保存位置</li> <li><code>--push_to_hub</code>：是否将训练好的模型推送至Hub</li> <li><code>--checkpointing_steps</code>：训练过程中保存检查点的频率；若训练意外中断，可通过在命令中添加<code>--resume_from_checkpoint</code>从该检查点恢复训练</li> <li><code>--num_vectors</code>：学习嵌入的向量数量；增加此参数可提升模型效果，但会提高训练成本</li> <li><code>--placeholder_token</code>：绑定学习嵌入的特殊词汇（推理时需在提示中使用该词）</li> <li><code>--initializer_token</code>：大致描述训练目标的单字词汇（如物体或风格）</li> <li><code>--learnable_property</code>：训练目标是学习新”风格”（如梵高画风）还是”物体”（如您的宠物狗）</li>",He,D,Le,P,Ct='与其他训练脚本不同，textual_inversion.py包含自定义数据集类<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L487" rel="nofollow"><code>TextualInversionDataset</code></a>，用于创建数据集。您可以自定义图像尺寸、占位符词汇、插值方法、是否裁剪图像等。如需修改数据集创建方式，可调整<code>TextualInversionDataset</code>类。',ze,K,Wt='接下来，在<a href="https://github.com/huggingface/diffusers/blob/839c2a5ece0af4e75530cb520d77bc7ed8acf474/examples/textual_inversion/textual_inversion.py#L573" rel="nofollow"><code>main()</code></a>函数中可找到数据集预处理代码和训练循环。',Se,O,Rt='脚本首先加载<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L616" rel="nofollow">tokenizer</a>、<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L622" rel="nofollow">scheduler和模型</a>：',Qe,ee,Ae,te,Bt='随后将特殊<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L632" rel="nofollow">占位符词汇</a>加入tokenizer，并调整嵌入层以适配新词汇。',qe,le,Vt='接着，脚本通过<code>TextualInversionDataset</code><a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L716" rel="nofollow">创建数据集</a>：',De,se,Pe,ne,Gt='最后，<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L784" rel="nofollow">训练循环</a>处理从预测噪声残差到更新特殊占位符词汇嵌入权重的所有流程。',Ke,ae,Ft='如需深入了解训练循环工作原理，请参阅<a href="../using-diffusers/write_own_pipeline">理解管道、模型与调度器</a>教程，该教程解析了去噪过程的基本模式。',Oe,ie,et,pe,It="完成所有修改或确认默认配置后，即可启动训练脚本！🚀",tt,re,kt='本指南将下载<a href="https://huggingface.co/datasets/diffusers/cat_toy_example" rel="nofollow">猫玩具</a>的示例图像并存储在目录中。当然，您也可以创建和使用自己的数据集（参见<a href="create_dataset">创建训练数据集</a>指南）。',lt,oe,st,fe,Nt="设置环境变量<code>MODEL_NAME</code>为Hub上的模型ID或本地模型路径，<code>DATA_DIR</code>为刚下载的猫图像路径。脚本会将以下文件保存至您的仓库：",nt,ce,Yt="<li><code>learned_embeds.bin</code>：与示例图像对应的学习嵌入向量</li> <li><code>token_identifier.txt</code>：特殊占位符词汇</li> <li><code>type_of_concept.txt</code>：训练概念类型（“object”或”style”）</li>",at,x,it,me,Et="启动脚本前还有最后一步。如果想实时观察训练过程，可以定期保存生成图像。在训练命令中添加以下参数：",pt,ue,rt,X,ot,Me,Ht="训练完成后，可以像这样使用新模型进行推理：",ft,C,ct,de,mt,Je,Lt="恭喜您成功训练了自己的文本反转模型！🎉 如需了解更多使用技巧，以下指南可能会有所帮助：",ut,ye,zt='<li>学习如何<a href="../using-diffusers/loading_adapters">加载文本反转嵌入</a>，并将其用作负面嵌入</li> <li>学习如何将<a href="textual_inversion_inference">文本反转</a>应用于Stable Diffusion 1/2和Stable Diffusion XL的推理</li>',Mt,$e,dt,_e,Jt;return i=new he({props:{title:"文本反转（Textual Inversion）",local:"文本反转textual-inversion",headingTag:"h1"}}),V=new U({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}}),Z=new $t({props:{id:"installation",options:["PyTorch","Flax"],$$slots:{default:[ol]},$$scope:{ctx:h}}}),j=new yt({props:{$$slots:{default:[fl]},$$scope:{ctx:h}}}),I=new U({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config",wrap:!1}}),N=new U({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default",wrap:!1}}),E=new U({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}}),v=new yt({props:{$$slots:{default:[cl]},$$scope:{ctx:h}}}),L=new he({props:{title:"脚本参数",local:"脚本参数",headingTag:"h2"}}),Q=new U({props:{code:"YWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRleHR1YWxfaW52ZXJzaW9uLnB5JTIwJTVDJTBBJTIwJTIwLS1ncmFkaWVudF9hY2N1bXVsYXRpb25fc3RlcHMlM0Q0",highlighted:`accelerate launch textual_inversion.py \\
  --gradient_accumulation_steps=4`,wrap:!1}}),D=new he({props:{title:"训练脚本",local:"训练脚本",headingTag:"h2"}}),ee=new U({props:{code:"JTIzJTIwJUU1JThBJUEwJUU4JUJEJUJEdG9rZW5pemVyJTBBaWYlMjBhcmdzLnRva2VuaXplcl9uYW1lJTNBJTBBJTIwJTIwJTIwJTIwdG9rZW5pemVyJTIwJTNEJTIwQ0xJUFRva2VuaXplci5mcm9tX3ByZXRyYWluZWQoYXJncy50b2tlbml6ZXJfbmFtZSklMEFlbGlmJTIwYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzQSUwQSUyMCUyMCUyMCUyMHRva2VuaXplciUyMCUzRCUyMENMSVBUb2tlbml6ZXIuZnJvbV9wcmV0cmFpbmVkKGFyZ3MucHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglMkMlMjBzdWJmb2xkZXIlM0QlMjJ0b2tlbml6ZXIlMjIpJTBBJTBBJTIzJTIwJUU1JThBJUEwJUU4JUJEJUJEc2NoZWR1bGVyJUU1JTkyJThDJUU2JUE4JUExJUU1JTlFJThCJTBBbm9pc2Vfc2NoZWR1bGVyJTIwJTNEJTIwRERQTVNjaGVkdWxlci5mcm9tX3ByZXRyYWluZWQoYXJncy5wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUyQyUyMHN1YmZvbGRlciUzRCUyMnNjaGVkdWxlciUyMiklMEF0ZXh0X2VuY29kZXIlMjAlM0QlMjBDTElQVGV4dE1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydGV4dF9lbmNvZGVyJTIyJTJDJTIwcmV2aXNpb24lM0RhcmdzLnJldmlzaW9uJTBBKSUwQXZhZSUyMCUzRCUyMEF1dG9lbmNvZGVyS0wuZnJvbV9wcmV0cmFpbmVkKGFyZ3MucHJldHJhaW5lZF9tb2RlbF9uYW1lX29yX3BhdGglMkMlMjBzdWJmb2xkZXIlM0QlMjJ2YWUlMjIlMkMlMjByZXZpc2lvbiUzRGFyZ3MucmV2aXNpb24pJTBBdW5ldCUyMCUzRCUyMFVOZXQyRENvbmRpdGlvbk1vZGVsLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjBhcmdzLnByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTJDJTIwc3ViZm9sZGVyJTNEJTIydW5ldCUyMiUyQyUyMHJldmlzaW9uJTNEYXJncy5yZXZpc2lvbiUwQSk=",highlighted:`<span class="hljs-comment"># 加载tokenizer</span>
<span class="hljs-keyword">if</span> args.tokenizer_name:
    tokenizer = CLIPTokenizer.from_pretrained(args.tokenizer_name)
<span class="hljs-keyword">elif</span> args.pretrained_model_name_or_path:
    tokenizer = CLIPTokenizer.from_pretrained(args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;tokenizer&quot;</span>)

<span class="hljs-comment"># 加载scheduler和模型</span>
noise_scheduler = DDPMScheduler.from_pretrained(args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;scheduler&quot;</span>)
text_encoder = CLIPTextModel.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;text_encoder&quot;</span>, revision=args.revision
)
vae = AutoencoderKL.from_pretrained(args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;vae&quot;</span>, revision=args.revision)
unet = UNet2DConditionModel.from_pretrained(
    args.pretrained_model_name_or_path, subfolder=<span class="hljs-string">&quot;unet&quot;</span>, revision=args.revision
)`,wrap:!1}}),se=new U({props:{code:"dHJhaW5fZGF0YXNldCUyMCUzRCUyMFRleHR1YWxJbnZlcnNpb25EYXRhc2V0KCUwQSUyMCUyMCUyMCUyMGRhdGFfcm9vdCUzRGFyZ3MudHJhaW5fZGF0YV9kaXIlMkMlMEElMjAlMjAlMjAlMjB0b2tlbml6ZXIlM0R0b2tlbml6ZXIlMkMlMEElMjAlMjAlMjAlMjBzaXplJTNEYXJncy5yZXNvbHV0aW9uJTJDJTBBJTIwJTIwJTIwJTIwcGxhY2Vob2xkZXJfdG9rZW4lM0QoJTIyJTIwJTIyLmpvaW4odG9rZW5pemVyLmNvbnZlcnRfaWRzX3RvX3Rva2VucyhwbGFjZWhvbGRlcl90b2tlbl9pZHMpKSklMkMlMEElMjAlMjAlMjAlMjByZXBlYXRzJTNEYXJncy5yZXBlYXRzJTJDJTBBJTIwJTIwJTIwJTIwbGVhcm5hYmxlX3Byb3BlcnR5JTNEYXJncy5sZWFybmFibGVfcHJvcGVydHklMkMlMEElMjAlMjAlMjAlMjBjZW50ZXJfY3JvcCUzRGFyZ3MuY2VudGVyX2Nyb3AlMkMlMEElMjAlMjAlMjAlMjBzZXQlM0QlMjJ0cmFpbiUyMiUyQyUwQSklMEF0cmFpbl9kYXRhbG9hZGVyJTIwJTNEJTIwdG9yY2gudXRpbHMuZGF0YS5EYXRhTG9hZGVyKCUwQSUyMCUyMCUyMCUyMHRyYWluX2RhdGFzZXQlMkMlMjBiYXRjaF9zaXplJTNEYXJncy50cmFpbl9iYXRjaF9zaXplJTJDJTIwc2h1ZmZsZSUzRFRydWUlMkMlMjBudW1fd29ya2VycyUzRGFyZ3MuZGF0YWxvYWRlcl9udW1fd29ya2VycyUwQSk=",highlighted:`train_dataset = TextualInversionDataset(
    data_root=args.train_data_dir,
    tokenizer=tokenizer,
    size=args.resolution,
    placeholder_token=(<span class="hljs-string">&quot; &quot;</span>.join(tokenizer.convert_ids_to_tokens(placeholder_token_ids))),
    repeats=args.repeats,
    learnable_property=args.learnable_property,
    center_crop=args.center_crop,
    <span class="hljs-built_in">set</span>=<span class="hljs-string">&quot;train&quot;</span>,
)
train_dataloader = torch.utils.data.DataLoader(
    train_dataset, batch_size=args.train_batch_size, shuffle=<span class="hljs-literal">True</span>, num_workers=args.dataloader_num_workers
)`,wrap:!1}}),ie=new he({props:{title:"启动脚本",local:"启动脚本",headingTag:"h2"}}),oe=new U({props:{code:"ZnJvbSUyMGh1Z2dpbmdmYWNlX2h1YiUyMGltcG9ydCUyMHNuYXBzaG90X2Rvd25sb2FkJTBBJTBBbG9jYWxfZGlyJTIwJTNEJTIwJTIyLiUyRmNhdCUyMiUwQXNuYXBzaG90X2Rvd25sb2FkKCUwQSUyMCUyMCUyMCUyMCUyMmRpZmZ1c2VycyUyRmNhdF90b3lfZXhhbXBsZSUyMiUyQyUyMGxvY2FsX2RpciUzRGxvY2FsX2RpciUyQyUyMHJlcG9fdHlwZSUzRCUyMmRhdGFzZXQlMjIlMkMlMjBpZ25vcmVfcGF0dGVybnMlM0QlMjIuZ2l0YXR0cmlidXRlcyUyMiUwQSk=",highlighted:`<span class="hljs-keyword">from</span> huggingface_hub <span class="hljs-keyword">import</span> snapshot_download

local_dir = <span class="hljs-string">&quot;./cat&quot;</span>
snapshot_download(
    <span class="hljs-string">&quot;diffusers/cat_toy_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}}),x=new yt({props:{warning:!0,$$slots:{default:[ml]},$$scope:{ctx:h}}}),ue=new U({props:{code:"LS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMkElMjAlM0NjYXQtdG95JTNFJTIwdHJhaW4lMjIlMEEtLW51bV92YWxpZGF0aW9uX2ltYWdlcyUzRDQlMEEtLXZhbGlkYXRpb25fc3RlcHMlM0QxMDA=",highlighted:`--validation_prompt=<span class="hljs-string">&quot;A &lt;cat-toy&gt; train&quot;</span>
--num_validation_images=4
--validation_steps=100`,wrap:!1}}),X=new $t({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[dl]},$$scope:{ctx:h}}}),C=new $t({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[$l]},$$scope:{ctx:h}}}),de=new he({props:{title:"后续步骤",local:"后续步骤",headingTag:"h2"}}),$e=new il({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/text_inversion.md"}}),{c(){l=m("meta"),p=r(),s=m("p"),c=r(),M(i.$$.fragment),f=r(),T=m("p"),T.innerHTML=w,Te=r(),W=m("p"),W.innerHTML=bt,Ue=r(),R=m("p"),R.innerHTML=_t,we=r(),B=m("p"),B.textContent=ht,ge=r(),M(V.$$.fragment),Ze=r(),G=m("p"),G.textContent=Tt,je=r(),M(Z.$$.fragment),ve=r(),M(j.$$.fragment),xe=r(),F=m("p"),F.textContent=Ut,Xe=r(),M(I.$$.fragment),Ce=r(),k=m("p"),k.textContent=wt,We=r(),M(N.$$.fragment),Re=r(),Y=m("p"),Y.textContent=gt,Be=r(),M(E.$$.fragment),Ve=r(),H=m("p"),H.innerHTML=Zt,Ge=r(),M(v.$$.fragment),Fe=r(),M(L.$$.fragment),Ie=r(),z=m("p"),z.innerHTML=jt,ke=r(),S=m("p"),S.textContent=vt,Ne=r(),M(Q.$$.fragment),Ye=r(),A=m("p"),A.textContent=xt,Ee=r(),q=m("ul"),q.innerHTML=Xt,He=r(),M(D.$$.fragment),Le=r(),P=m("p"),P.innerHTML=Ct,ze=r(),K=m("p"),K.innerHTML=Wt,Se=r(),O=m("p"),O.innerHTML=Rt,Qe=r(),M(ee.$$.fragment),Ae=r(),te=m("p"),te.innerHTML=Bt,qe=r(),le=m("p"),le.innerHTML=Vt,De=r(),M(se.$$.fragment),Pe=r(),ne=m("p"),ne.innerHTML=Gt,Ke=r(),ae=m("p"),ae.innerHTML=Ft,Oe=r(),M(ie.$$.fragment),et=r(),pe=m("p"),pe.textContent=It,tt=r(),re=m("p"),re.innerHTML=kt,lt=r(),M(oe.$$.fragment),st=r(),fe=m("p"),fe.innerHTML=Nt,nt=r(),ce=m("ul"),ce.innerHTML=Yt,at=r(),M(x.$$.fragment),it=r(),me=m("p"),me.textContent=Et,pt=r(),M(ue.$$.fragment),rt=r(),M(X.$$.fragment),ot=r(),Me=m("p"),Me.textContent=Ht,ft=r(),M(C.$$.fragment),ct=r(),M(de.$$.fragment),mt=r(),Je=m("p"),Je.textContent=Lt,ut=r(),ye=m("ul"),ye.innerHTML=zt,Mt=r(),M($e.$$.fragment),dt=r(),_e=m("p"),this.h()},l(e){const t=nl("svelte-u9bgzb",document.head);l=u(t,"META",{name:!0,content:!0}),t.forEach(n),p=o(e),s=u(e,"P",{}),Kt(s).forEach(n),c=o(e),d(i.$$.fragment,e),f=o(e),T=u(e,"P",{"data-svelte-h":!0}),_(T)!=="svelte-583d0v"&&(T.innerHTML=w),Te=o(e),W=u(e,"P",{"data-svelte-h":!0}),_(W)!=="svelte-11ie2pv"&&(W.innerHTML=bt),Ue=o(e),R=u(e,"P",{"data-svelte-h":!0}),_(R)!=="svelte-79domf"&&(R.innerHTML=_t),we=o(e),B=u(e,"P",{"data-svelte-h":!0}),_(B)!=="svelte-1l0wcm7"&&(B.textContent=ht),ge=o(e),d(V.$$.fragment,e),Ze=o(e),G=u(e,"P",{"data-svelte-h":!0}),_(G)!=="svelte-1por4m9"&&(G.textContent=Tt),je=o(e),d(Z.$$.fragment,e),ve=o(e),d(j.$$.fragment,e),xe=o(e),F=u(e,"P",{"data-svelte-h":!0}),_(F)!=="svelte-cfitki"&&(F.textContent=Ut),Xe=o(e),d(I.$$.fragment,e),Ce=o(e),k=u(e,"P",{"data-svelte-h":!0}),_(k)!=="svelte-b5atr0"&&(k.textContent=wt),We=o(e),d(N.$$.fragment,e),Re=o(e),Y=u(e,"P",{"data-svelte-h":!0}),_(Y)!=="svelte-h13mpn"&&(Y.textContent=gt),Be=o(e),d(E.$$.fragment,e),Ve=o(e),H=u(e,"P",{"data-svelte-h":!0}),_(H)!=="svelte-13r470a"&&(H.innerHTML=Zt),Ge=o(e),d(v.$$.fragment,e),Fe=o(e),d(L.$$.fragment,e),Ie=o(e),z=u(e,"P",{"data-svelte-h":!0}),_(z)!=="svelte-11ybobz"&&(z.innerHTML=jt),ke=o(e),S=u(e,"P",{"data-svelte-h":!0}),_(S)!=="svelte-yyke9b"&&(S.textContent=vt),Ne=o(e),d(Q.$$.fragment,e),Ye=o(e),A=u(e,"P",{"data-svelte-h":!0}),_(A)!=="svelte-1fmbksz"&&(A.textContent=xt),Ee=o(e),q=u(e,"UL",{"data-svelte-h":!0}),_(q)!=="svelte-1v241ru"&&(q.innerHTML=Xt),He=o(e),d(D.$$.fragment,e),Le=o(e),P=u(e,"P",{"data-svelte-h":!0}),_(P)!=="svelte-188nunv"&&(P.innerHTML=Ct),ze=o(e),K=u(e,"P",{"data-svelte-h":!0}),_(K)!=="svelte-1rv31ld"&&(K.innerHTML=Wt),Se=o(e),O=u(e,"P",{"data-svelte-h":!0}),_(O)!=="svelte-t2slq7"&&(O.innerHTML=Rt),Qe=o(e),d(ee.$$.fragment,e),Ae=o(e),te=u(e,"P",{"data-svelte-h":!0}),_(te)!=="svelte-162yif"&&(te.innerHTML=Bt),qe=o(e),le=u(e,"P",{"data-svelte-h":!0}),_(le)!=="svelte-1kypmdn"&&(le.innerHTML=Vt),De=o(e),d(se.$$.fragment,e),Pe=o(e),ne=u(e,"P",{"data-svelte-h":!0}),_(ne)!=="svelte-16ltvar"&&(ne.innerHTML=Gt),Ke=o(e),ae=u(e,"P",{"data-svelte-h":!0}),_(ae)!=="svelte-1m9gut4"&&(ae.innerHTML=Ft),Oe=o(e),d(ie.$$.fragment,e),et=o(e),pe=u(e,"P",{"data-svelte-h":!0}),_(pe)!=="svelte-1fd8wg2"&&(pe.textContent=It),tt=o(e),re=u(e,"P",{"data-svelte-h":!0}),_(re)!=="svelte-he73wu"&&(re.innerHTML=kt),lt=o(e),d(oe.$$.fragment,e),st=o(e),fe=u(e,"P",{"data-svelte-h":!0}),_(fe)!=="svelte-1b8hdsd"&&(fe.innerHTML=Nt),nt=o(e),ce=u(e,"UL",{"data-svelte-h":!0}),_(ce)!=="svelte-1ch14mg"&&(ce.innerHTML=Yt),at=o(e),d(x.$$.fragment,e),it=o(e),me=u(e,"P",{"data-svelte-h":!0}),_(me)!=="svelte-xksh79"&&(me.textContent=Et),pt=o(e),d(ue.$$.fragment,e),rt=o(e),d(X.$$.fragment,e),ot=o(e),Me=u(e,"P",{"data-svelte-h":!0}),_(Me)!=="svelte-eky57p"&&(Me.textContent=Ht),ft=o(e),d(C.$$.fragment,e),ct=o(e),d(de.$$.fragment,e),mt=o(e),Je=u(e,"P",{"data-svelte-h":!0}),_(Je)!=="svelte-1jignpy"&&(Je.textContent=Lt),ut=o(e),ye=u(e,"UL",{"data-svelte-h":!0}),_(ye)!=="svelte-g6dwxa"&&(ye.innerHTML=zt),Mt=o(e),d($e.$$.fragment,e),dt=o(e),_e=u(e,"P",{}),Kt(_e).forEach(n),this.h()},h(){Ot(l,"name","hf:doc:metadata"),Ot(l,"content",_l)},m(e,t){al(document.head,l),a(e,p,t),a(e,s,t),a(e,c,t),J(i,e,t),a(e,f,t),a(e,T,t),a(e,Te,t),a(e,W,t),a(e,Ue,t),a(e,R,t),a(e,we,t),a(e,B,t),a(e,ge,t),J(V,e,t),a(e,Ze,t),a(e,G,t),a(e,je,t),J(Z,e,t),a(e,ve,t),J(j,e,t),a(e,xe,t),a(e,F,t),a(e,Xe,t),J(I,e,t),a(e,Ce,t),a(e,k,t),a(e,We,t),J(N,e,t),a(e,Re,t),a(e,Y,t),a(e,Be,t),J(E,e,t),a(e,Ve,t),a(e,H,t),a(e,Ge,t),J(v,e,t),a(e,Fe,t),J(L,e,t),a(e,Ie,t),a(e,z,t),a(e,ke,t),a(e,S,t),a(e,Ne,t),J(Q,e,t),a(e,Ye,t),a(e,A,t),a(e,Ee,t),a(e,q,t),a(e,He,t),J(D,e,t),a(e,Le,t),a(e,P,t),a(e,ze,t),a(e,K,t),a(e,Se,t),a(e,O,t),a(e,Qe,t),J(ee,e,t),a(e,Ae,t),a(e,te,t),a(e,qe,t),a(e,le,t),a(e,De,t),J(se,e,t),a(e,Pe,t),a(e,ne,t),a(e,Ke,t),a(e,ae,t),a(e,Oe,t),J(ie,e,t),a(e,et,t),a(e,pe,t),a(e,tt,t),a(e,re,t),a(e,lt,t),J(oe,e,t),a(e,st,t),a(e,fe,t),a(e,nt,t),a(e,ce,t),a(e,at,t),J(x,e,t),a(e,it,t),a(e,me,t),a(e,pt,t),J(ue,e,t),a(e,rt,t),J(X,e,t),a(e,ot,t),a(e,Me,t),a(e,ft,t),J(C,e,t),a(e,ct,t),J(de,e,t),a(e,mt,t),a(e,Je,t),a(e,ut,t),a(e,ye,t),a(e,Mt,t),J($e,e,t),a(e,dt,t),a(e,_e,t),Jt=!0},p(e,[t]){const St={};t&2&&(St.$$scope={dirty:t,ctx:e}),Z.$set(St);const Qt={};t&2&&(Qt.$$scope={dirty:t,ctx:e}),j.$set(Qt);const At={};t&2&&(At.$$scope={dirty:t,ctx:e}),v.$set(At);const qt={};t&2&&(qt.$$scope={dirty:t,ctx:e}),x.$set(qt);const Dt={};t&2&&(Dt.$$scope={dirty:t,ctx:e}),X.$set(Dt);const Pt={};t&2&&(Pt.$$scope={dirty:t,ctx:e}),C.$set(Pt)},i(e){Jt||(y(i.$$.fragment,e),y(V.$$.fragment,e),y(Z.$$.fragment,e),y(j.$$.fragment,e),y(I.$$.fragment,e),y(N.$$.fragment,e),y(E.$$.fragment,e),y(v.$$.fragment,e),y(L.$$.fragment,e),y(Q.$$.fragment,e),y(D.$$.fragment,e),y(ee.$$.fragment,e),y(se.$$.fragment,e),y(ie.$$.fragment,e),y(oe.$$.fragment,e),y(x.$$.fragment,e),y(ue.$$.fragment,e),y(X.$$.fragment,e),y(C.$$.fragment,e),y(de.$$.fragment,e),y($e.$$.fragment,e),Jt=!0)},o(e){$(i.$$.fragment,e),$(V.$$.fragment,e),$(Z.$$.fragment,e),$(j.$$.fragment,e),$(I.$$.fragment,e),$(N.$$.fragment,e),$(E.$$.fragment,e),$(v.$$.fragment,e),$(L.$$.fragment,e),$(Q.$$.fragment,e),$(D.$$.fragment,e),$(ee.$$.fragment,e),$(se.$$.fragment,e),$(ie.$$.fragment,e),$(oe.$$.fragment,e),$(x.$$.fragment,e),$(ue.$$.fragment,e),$(X.$$.fragment,e),$(C.$$.fragment,e),$(de.$$.fragment,e),$($e.$$.fragment,e),Jt=!1},d(e){e&&(n(p),n(s),n(c),n(f),n(T),n(Te),n(W),n(Ue),n(R),n(we),n(B),n(ge),n(Ze),n(G),n(je),n(ve),n(xe),n(F),n(Xe),n(Ce),n(k),n(We),n(Re),n(Y),n(Be),n(Ve),n(H),n(Ge),n(Fe),n(Ie),n(z),n(ke),n(S),n(Ne),n(Ye),n(A),n(Ee),n(q),n(He),n(Le),n(P),n(ze),n(K),n(Se),n(O),n(Qe),n(Ae),n(te),n(qe),n(le),n(De),n(Pe),n(ne),n(Ke),n(ae),n(Oe),n(et),n(pe),n(tt),n(re),n(lt),n(st),n(fe),n(nt),n(ce),n(at),n(it),n(me),n(pt),n(rt),n(ot),n(Me),n(ft),n(ct),n(mt),n(Je),n(ut),n(ye),n(Mt),n(dt),n(_e)),n(l),b(i,e),b(V,e),b(Z,e),b(j,e),b(I,e),b(N,e),b(E,e),b(v,e),b(L,e),b(Q,e),b(D,e),b(ee,e),b(se,e),b(ie,e),b(oe,e),b(x,e),b(ue,e),b(X,e),b(C,e),b(de,e),b($e,e)}}}const _l='{"title":"文本反转（Textual Inversion）","local":"文本反转textual-inversion","sections":[{"title":"脚本参数","local":"脚本参数","sections":[],"depth":2},{"title":"训练脚本","local":"训练脚本","sections":[],"depth":2},{"title":"启动脚本","local":"启动脚本","sections":[],"depth":2},{"title":"后续步骤","local":"后续步骤","sections":[],"depth":2}],"depth":1}';function hl(h){return tl(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vl extends ll{constructor(l){super(),sl(this,l,hl,bl,el,{})}}export{vl as component};
