import{s as tl,o as ll,n as _e}from"../chunks/scheduler.e4ff9b64.js";import{S as sl,i as nl,e as m,s as p,c as d,h as al,a as u,d as l,b as r,f as el,g as y,j as M,k as $e,l as il,m as s,n as J,t as b,o as T,p as _}from"../chunks/index.09f1bca0.js";import{C as pl,H as Ue,E as rl}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.dde31fc2.js";import{C as U}from"../chunks/CodeBlock.54e44b16.js";import{H as Tt,a as Te}from"../chunks/HfOption.44827c7f.js";function ol(h){let a,o;return a=new U({props:{code:"Y2QlMjBleGFtcGxlcyUyRnRleHR1YWxfaW52ZXJzaW9uJTBBcGlwJTIwaW5zdGFsbCUyMC1yJTIwcmVxdWlyZW1lbnRzLnR4dA==",highlighted:`<span class="hljs-built_in">cd</span> examples/textual_inversion
pip install -r requirements.txt`,wrap:!1}}),{c(){d(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,f){J(a,n,f),o=!0},p:_e,i(n){o||(b(a.$$.fragment,n),o=!0)},o(n){T(a.$$.fragment,n),o=!1},d(n){_(a,n)}}}function cl(h){let a,o;return a=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(){d(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,f){J(a,n,f),o=!0},p:_e,i(n){o||(b(a.$$.fragment,n),o=!0)},o(n){T(a.$$.fragment,n),o=!1},d(n){_(a,n)}}}function fl(h){let a,o,n,f;return a=new Te({props:{id:"installation",option:"PyTorch",$$slots:{default:[ol]},$$scope:{ctx:h}}}),n=new Te({props:{id:"installation",option:"Flax",$$slots:{default:[cl]},$$scope:{ctx:h}}}),{c(){d(a.$$.fragment),o=p(),d(n.$$.fragment)},l(i){y(a.$$.fragment,i),o=r(i),y(n.$$.fragment,i)},m(i,c){J(a,i,c),s(i,o,c),J(n,i,c),f=!0},p(i,c){const $={};c&2&&($.$$scope={dirty:c,ctx:i}),a.$set($);const w={};c&2&&(w.$$scope={dirty:c,ctx:i}),n.$set(w)},i(i){f||(b(a.$$.fragment,i),b(n.$$.fragment,i),f=!0)},o(i){T(a.$$.fragment,i),T(n.$$.fragment,i),f=!1},d(i){i&&l(o),_(a,i),_(n,i)}}}function ml(h){let a,o;return a=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(){d(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,f){J(a,n,f),o=!0},p:_e,i(n){o||(b(a.$$.fragment,n),o=!0)},o(n){T(a.$$.fragment,n),o=!1},d(n){_(a,n)}}}function ul(h){let a,o;return a=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(){d(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,f){J(a,n,f),o=!0},p:_e,i(n){o||(b(a.$$.fragment,n),o=!0)},o(n){T(a.$$.fragment,n),o=!1},d(n){_(a,n)}}}function Ml(h){let a,o,n,f;return a=new Te({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[ml]},$$scope:{ctx:h}}}),n=new Te({props:{id:"training-inference",option:"Flax",$$slots:{default:[ul]},$$scope:{ctx:h}}}),{c(){d(a.$$.fragment),o=p(),d(n.$$.fragment)},l(i){y(a.$$.fragment,i),o=r(i),y(n.$$.fragment,i)},m(i,c){J(a,i,c),s(i,o,c),J(n,i,c),f=!0},p(i,c){const $={};c&2&&($.$$scope={dirty:c,ctx:i}),a.$set($);const w={};c&2&&(w.$$scope={dirty:c,ctx:i}),n.$set(w)},i(i){f||(b(a.$$.fragment,i),b(n.$$.fragment,i),f=!0)},o(i){T(a.$$.fragment,i),T(n.$$.fragment,i),f=!1},d(i){i&&l(o),_(a,i),_(n,i)}}}function dl(h){let a,o;return a=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(){d(a.$$.fragment)},l(n){y(a.$$.fragment,n)},m(n,f){J(a,n,f),o=!0},p:_e,i(n){o||(b(a.$$.fragment,n),o=!0)},o(n){T(a.$$.fragment,n),o=!1},d(n){_(a,n)}}}function yl(h){let a,o='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模型一样进行推理：',n,f,i;return f=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(){a=m("p"),a.innerHTML=o,n=p(),d(f.$$.fragment)},l(c){a=u(c,"P",{"data-svelte-h":!0}),M(a)!=="svelte-1272v9b"&&(a.innerHTML=o),n=r(c),y(f.$$.fragment,c)},m(c,$){s(c,a,$),s(c,n,$),J(f,c,$),i=!0},p:_e,i(c){i||(b(f.$$.fragment,c),i=!0)},o(c){T(f.$$.fragment,c),i=!1},d(c){c&&(l(a),l(n)),_(f,c)}}}function Jl(h){let a,o,n,f;return a=new Te({props:{id:"training-inference",option:"PyTorch",$$slots:{default:[dl]},$$scope:{ctx:h}}}),n=new Te({props:{id:"training-inference",option:"Flax",$$slots:{default:[yl]},$$scope:{ctx:h}}}),{c(){d(a.$$.fragment),o=p(),d(n.$$.fragment)},l(i){y(a.$$.fragment,i),o=r(i),y(n.$$.fragment,i)},m(i,c){J(a,i,c),s(i,o,c),J(n,i,c),f=!0},p(i,c){const $={};c&2&&($.$$scope={dirty:c,ctx:i}),a.$set($);const w={};c&2&&(w.$$scope={dirty:c,ctx:i}),n.$set(w)},i(i){f||(b(a.$$.fragment,i),b(n.$$.fragment,i),f=!0)},o(i){T(a.$$.fragment,i),T(n.$$.fragment,i),f=!1},d(i){i&&l(o),_(a,i),_(n,i)}}}function bl(h){let a,o,n,f,i,c,$,w,C,_t='<a href="https://hf.co/papers/2208.01618" rel="nofollow">文本反转</a>是一种训练技术，仅需少量示例图像即可个性化图像生成模型。该技术通过学习和更新文本嵌入（新嵌入会绑定到提示中必须使用的特殊词汇）来匹配您提供的示例图像。',we,W,ht='如果在显存有限的GPU上训练，建议在训练命令中启用<code>gradient_checkpointing</code>和<code>mixed_precision</code>参数。您还可以通过<a href="../optimization/xformers">xFormers</a>使用内存高效注意力机制来减少内存占用。JAX/Flax训练也支持在TPU和GPU上进行高效训练，但不支持梯度检查点或xFormers。在配置与PyTorch相同的情况下，Flax训练脚本的速度至少应快70%！',ge,R,$t='本指南将探索<a href="https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py" rel="nofollow">textual_inversion.py</a>脚本，帮助您更熟悉其工作原理，并了解如何根据自身需求进行调整。',Ze,B,Ut="运行脚本前，请确保从源码安装库：",je,V,xe,G,wt="进入包含训练脚本的示例目录，并安装所需依赖：",ve,g,Xe,Z,gt='<p>🤗 Accelerate 是一个帮助您在多GPU/TPU或混合精度环境下训练的工具库。它会根据硬件和环境自动配置训练设置。查看🤗 Accelerate <a href="https://huggingface.co/docs/accelerate/quicktour" rel="nofollow">快速入门</a>了解更多。</p>',Ce,F,Zt="初始化🤗 Accelerate环境：",We,I,Re,k,jt="要设置默认的🤗 Accelerate环境（不选择任何配置）：",Be,N,Ve,E,xt="如果您的环境不支持交互式shell（如notebook），可以使用：",Ge,Y,Fe,H,vt='最后，如果想在自定义数据集上训练模型，请参阅<a href="create_dataset">创建训练数据集</a>指南，了解如何创建适用于训练脚本的数据集。',Ie,j,Xt='<p>以下部分重点介绍训练脚本中需要理解的关键修改点，但未涵盖脚本所有细节。如需深入了解，可随时查阅<a href="https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py" rel="nofollow">脚本源码</a>，如有疑问欢迎反馈。</p>',ke,L,Ne,z,Ct='训练脚本包含众多参数，便于您定制训练过程。所有参数及其说明都列在<a href="https://github.com/huggingface/diffusers/blob/839c2a5ece0af4e75530cb520d77bc7ed8acf474/examples/textual_inversion/textual_inversion.py#L176" rel="nofollow"><code>parse_args()</code></a>函数中。Diffusers为每个参数提供了默认值（如训练批次大小和学习率），但您可以通过训练命令自由调整这些值。',Ee,S,Wt="例如，将梯度累积步数增加到默认值1以上：",Ye,Q,He,A,Rt="其他需要指定的基础重要参数包括：",Le,q,Bt="<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>",ze,D,Se,P,Vt='与其他训练脚本不同，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>类。',Qe,K,Gt='接下来，在<a href="https://github.com/huggingface/diffusers/blob/839c2a5ece0af4e75530cb520d77bc7ed8acf474/examples/textual_inversion/textual_inversion.py#L573" rel="nofollow"><code>main()</code></a>函数中可找到数据集预处理代码和训练循环。',Ae,O,Ft='脚本首先加载<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,De,te,It='随后将特殊<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L632" rel="nofollow">占位符词汇</a>加入tokenizer，并调整嵌入层以适配新词汇。',Pe,le,kt='接着，脚本通过<code>TextualInversionDataset</code><a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L716" rel="nofollow">创建数据集</a>：',Ke,se,Oe,ne,Nt='最后，<a href="https://github.com/huggingface/diffusers/blob/b81c69e489aad3a0ba73798c459a33990dc4379c/examples/textual_inversion/textual_inversion.py#L784" rel="nofollow">训练循环</a>处理从预测噪声残差到更新特殊占位符词汇嵌入权重的所有流程。',et,ae,Et='如需深入了解训练循环工作原理，请参阅<a href="../using-diffusers/write_own_pipeline">理解管道、模型与调度器</a>教程，该教程解析了去噪过程的基本模式。',tt,ie,lt,pe,Yt="完成所有修改或确认默认配置后，即可启动训练脚本！🚀",st,re,Ht='本指南将下载<a href="https://huggingface.co/datasets/diffusers/cat_toy_example" rel="nofollow">猫玩具</a>的示例图像并存储在目录中。当然，您也可以创建和使用自己的数据集（参见<a href="create_dataset">创建训练数据集</a>指南）。',nt,oe,at,ce,Lt="设置环境变量<code>MODEL_NAME</code>为Hub上的模型ID或本地模型路径，<code>DATA_DIR</code>为刚下载的猫图像路径。脚本会将以下文件保存至您的仓库：",it,fe,zt="<li><code>learned_embeds.bin</code>：与示例图像对应的学习嵌入向量</li> <li><code>token_identifier.txt</code>：特殊占位符词汇</li> <li><code>type_of_concept.txt</code>：训练概念类型（“object”或”style”）</li>",pt,x,St="<p>在单块V100 GPU上完整训练约需1小时。</p>",rt,me,Qt="启动脚本前还有最后一步。如果想实时观察训练过程，可以定期保存生成图像。在训练命令中添加以下参数：",ot,ue,ct,v,ft,Me,At="训练完成后，可以像这样使用新模型进行推理：",mt,X,ut,de,Mt,ye,qt="恭喜您成功训练了自己的文本反转模型！🎉 如需了解更多使用技巧，以下指南可能会有所帮助：",dt,Je,Dt='<li>学习如何<a href="../using-diffusers/loading_adapters">加载文本反转嵌入</a>，并将其用作负面嵌入</li> <li>学习如何将<a href="textual_inversion_inference">文本反转</a>应用于Stable Diffusion 1/2和Stable Diffusion XL的推理</li>',yt,be,Jt,he,bt;return i=new pl({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new Ue({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}}),g=new Tt({props:{id:"installation",options:["PyTorch","Flax"],$$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}}),Y=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}}),L=new Ue({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 Ue({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 Ue({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}}),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}}),v=new Tt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Ml]},$$scope:{ctx:h}}}),X=new Tt({props:{id:"training-inference",options:["PyTorch","Flax"],$$slots:{default:[Jl]},$$scope:{ctx:h}}}),de=new Ue({props:{title:"后续步骤",local:"后续步骤",headingTag:"h2"}}),be=new rl({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/zh/training/text_inversion.md"}}),{c(){a=m("meta"),o=p(),n=m("p"),f=p(),d(i.$$.fragment),c=p(),d($.$$.fragment),w=p(),C=m("p"),C.innerHTML=_t,we=p(),W=m("p"),W.innerHTML=ht,ge=p(),R=m("p"),R.innerHTML=$t,Ze=p(),B=m("p"),B.textContent=Ut,je=p(),d(V.$$.fragment),xe=p(),G=m("p"),G.textContent=wt,ve=p(),d(g.$$.fragment),Xe=p(),Z=m("blockquote"),Z.innerHTML=gt,Ce=p(),F=m("p"),F.textContent=Zt,We=p(),d(I.$$.fragment),Re=p(),k=m("p"),k.textContent=jt,Be=p(),d(N.$$.fragment),Ve=p(),E=m("p"),E.textContent=xt,Ge=p(),d(Y.$$.fragment),Fe=p(),H=m("p"),H.innerHTML=vt,Ie=p(),j=m("blockquote"),j.innerHTML=Xt,ke=p(),d(L.$$.fragment),Ne=p(),z=m("p"),z.innerHTML=Ct,Ee=p(),S=m("p"),S.textContent=Wt,Ye=p(),d(Q.$$.fragment),He=p(),A=m("p"),A.textContent=Rt,Le=p(),q=m("ul"),q.innerHTML=Bt,ze=p(),d(D.$$.fragment),Se=p(),P=m("p"),P.innerHTML=Vt,Qe=p(),K=m("p"),K.innerHTML=Gt,Ae=p(),O=m("p"),O.innerHTML=Ft,qe=p(),d(ee.$$.fragment),De=p(),te=m("p"),te.innerHTML=It,Pe=p(),le=m("p"),le.innerHTML=kt,Ke=p(),d(se.$$.fragment),Oe=p(),ne=m("p"),ne.innerHTML=Nt,et=p(),ae=m("p"),ae.innerHTML=Et,tt=p(),d(ie.$$.fragment),lt=p(),pe=m("p"),pe.textContent=Yt,st=p(),re=m("p"),re.innerHTML=Ht,nt=p(),d(oe.$$.fragment),at=p(),ce=m("p"),ce.innerHTML=Lt,it=p(),fe=m("ul"),fe.innerHTML=zt,pt=p(),x=m("blockquote"),x.innerHTML=St,rt=p(),me=m("p"),me.textContent=Qt,ot=p(),d(ue.$$.fragment),ct=p(),d(v.$$.fragment),ft=p(),Me=m("p"),Me.textContent=At,mt=p(),d(X.$$.fragment),ut=p(),d(de.$$.fragment),Mt=p(),ye=m("p"),ye.textContent=qt,dt=p(),Je=m("ul"),Je.innerHTML=Dt,yt=p(),d(be.$$.fragment),Jt=p(),he=m("p"),this.h()},l(e){const t=al("svelte-u9bgzb",document.head);a=u(t,"META",{name:!0,content:!0}),t.forEach(l),o=r(e),n=u(e,"P",{}),el(n).forEach(l),f=r(e),y(i.$$.fragment,e),c=r(e),y($.$$.fragment,e),w=r(e),C=u(e,"P",{"data-svelte-h":!0}),M(C)!=="svelte-583d0v"&&(C.innerHTML=_t),we=r(e),W=u(e,"P",{"data-svelte-h":!0}),M(W)!=="svelte-11ie2pv"&&(W.innerHTML=ht),ge=r(e),R=u(e,"P",{"data-svelte-h":!0}),M(R)!=="svelte-79domf"&&(R.innerHTML=$t),Ze=r(e),B=u(e,"P",{"data-svelte-h":!0}),M(B)!=="svelte-1l0wcm7"&&(B.textContent=Ut),je=r(e),y(V.$$.fragment,e),xe=r(e),G=u(e,"P",{"data-svelte-h":!0}),M(G)!=="svelte-1por4m9"&&(G.textContent=wt),ve=r(e),y(g.$$.fragment,e),Xe=r(e),Z=u(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),M(Z)!=="svelte-snmpgn"&&(Z.innerHTML=gt),Ce=r(e),F=u(e,"P",{"data-svelte-h":!0}),M(F)!=="svelte-cfitki"&&(F.textContent=Zt),We=r(e),y(I.$$.fragment,e),Re=r(e),k=u(e,"P",{"data-svelte-h":!0}),M(k)!=="svelte-b5atr0"&&(k.textContent=jt),Be=r(e),y(N.$$.fragment,e),Ve=r(e),E=u(e,"P",{"data-svelte-h":!0}),M(E)!=="svelte-h13mpn"&&(E.textContent=xt),Ge=r(e),y(Y.$$.fragment,e),Fe=r(e),H=u(e,"P",{"data-svelte-h":!0}),M(H)!=="svelte-13r470a"&&(H.innerHTML=vt),Ie=r(e),j=u(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),M(j)!=="svelte-aoxkq0"&&(j.innerHTML=Xt),ke=r(e),y(L.$$.fragment,e),Ne=r(e),z=u(e,"P",{"data-svelte-h":!0}),M(z)!=="svelte-11ybobz"&&(z.innerHTML=Ct),Ee=r(e),S=u(e,"P",{"data-svelte-h":!0}),M(S)!=="svelte-yyke9b"&&(S.textContent=Wt),Ye=r(e),y(Q.$$.fragment,e),He=r(e),A=u(e,"P",{"data-svelte-h":!0}),M(A)!=="svelte-1fmbksz"&&(A.textContent=Rt),Le=r(e),q=u(e,"UL",{"data-svelte-h":!0}),M(q)!=="svelte-1v241ru"&&(q.innerHTML=Bt),ze=r(e),y(D.$$.fragment,e),Se=r(e),P=u(e,"P",{"data-svelte-h":!0}),M(P)!=="svelte-188nunv"&&(P.innerHTML=Vt),Qe=r(e),K=u(e,"P",{"data-svelte-h":!0}),M(K)!=="svelte-1rv31ld"&&(K.innerHTML=Gt),Ae=r(e),O=u(e,"P",{"data-svelte-h":!0}),M(O)!=="svelte-t2slq7"&&(O.innerHTML=Ft),qe=r(e),y(ee.$$.fragment,e),De=r(e),te=u(e,"P",{"data-svelte-h":!0}),M(te)!=="svelte-162yif"&&(te.innerHTML=It),Pe=r(e),le=u(e,"P",{"data-svelte-h":!0}),M(le)!=="svelte-1kypmdn"&&(le.innerHTML=kt),Ke=r(e),y(se.$$.fragment,e),Oe=r(e),ne=u(e,"P",{"data-svelte-h":!0}),M(ne)!=="svelte-16ltvar"&&(ne.innerHTML=Nt),et=r(e),ae=u(e,"P",{"data-svelte-h":!0}),M(ae)!=="svelte-1m9gut4"&&(ae.innerHTML=Et),tt=r(e),y(ie.$$.fragment,e),lt=r(e),pe=u(e,"P",{"data-svelte-h":!0}),M(pe)!=="svelte-1fd8wg2"&&(pe.textContent=Yt),st=r(e),re=u(e,"P",{"data-svelte-h":!0}),M(re)!=="svelte-he73wu"&&(re.innerHTML=Ht),nt=r(e),y(oe.$$.fragment,e),at=r(e),ce=u(e,"P",{"data-svelte-h":!0}),M(ce)!=="svelte-1b8hdsd"&&(ce.innerHTML=Lt),it=r(e),fe=u(e,"UL",{"data-svelte-h":!0}),M(fe)!=="svelte-1ch14mg"&&(fe.innerHTML=zt),pt=r(e),x=u(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),M(x)!=="svelte-1shho7l"&&(x.innerHTML=St),rt=r(e),me=u(e,"P",{"data-svelte-h":!0}),M(me)!=="svelte-xksh79"&&(me.textContent=Qt),ot=r(e),y(ue.$$.fragment,e),ct=r(e),y(v.$$.fragment,e),ft=r(e),Me=u(e,"P",{"data-svelte-h":!0}),M(Me)!=="svelte-eky57p"&&(Me.textContent=At),mt=r(e),y(X.$$.fragment,e),ut=r(e),y(de.$$.fragment,e),Mt=r(e),ye=u(e,"P",{"data-svelte-h":!0}),M(ye)!=="svelte-1jignpy"&&(ye.textContent=qt),dt=r(e),Je=u(e,"UL",{"data-svelte-h":!0}),M(Je)!=="svelte-g6dwxa"&&(Je.innerHTML=Dt),yt=r(e),y(be.$$.fragment,e),Jt=r(e),he=u(e,"P",{}),el(he).forEach(l),this.h()},h(){$e(a,"name","hf:doc:metadata"),$e(a,"content",Tl),$e(Z,"class","tip"),$e(j,"class","tip"),$e(x,"class","warning")},m(e,t){il(document.head,a),s(e,o,t),s(e,n,t),s(e,f,t),J(i,e,t),s(e,c,t),J($,e,t),s(e,w,t),s(e,C,t),s(e,we,t),s(e,W,t),s(e,ge,t),s(e,R,t),s(e,Ze,t),s(e,B,t),s(e,je,t),J(V,e,t),s(e,xe,t),s(e,G,t),s(e,ve,t),J(g,e,t),s(e,Xe,t),s(e,Z,t),s(e,Ce,t),s(e,F,t),s(e,We,t),J(I,e,t),s(e,Re,t),s(e,k,t),s(e,Be,t),J(N,e,t),s(e,Ve,t),s(e,E,t),s(e,Ge,t),J(Y,e,t),s(e,Fe,t),s(e,H,t),s(e,Ie,t),s(e,j,t),s(e,ke,t),J(L,e,t),s(e,Ne,t),s(e,z,t),s(e,Ee,t),s(e,S,t),s(e,Ye,t),J(Q,e,t),s(e,He,t),s(e,A,t),s(e,Le,t),s(e,q,t),s(e,ze,t),J(D,e,t),s(e,Se,t),s(e,P,t),s(e,Qe,t),s(e,K,t),s(e,Ae,t),s(e,O,t),s(e,qe,t),J(ee,e,t),s(e,De,t),s(e,te,t),s(e,Pe,t),s(e,le,t),s(e,Ke,t),J(se,e,t),s(e,Oe,t),s(e,ne,t),s(e,et,t),s(e,ae,t),s(e,tt,t),J(ie,e,t),s(e,lt,t),s(e,pe,t),s(e,st,t),s(e,re,t),s(e,nt,t),J(oe,e,t),s(e,at,t),s(e,ce,t),s(e,it,t),s(e,fe,t),s(e,pt,t),s(e,x,t),s(e,rt,t),s(e,me,t),s(e,ot,t),J(ue,e,t),s(e,ct,t),J(v,e,t),s(e,ft,t),s(e,Me,t),s(e,mt,t),J(X,e,t),s(e,ut,t),J(de,e,t),s(e,Mt,t),s(e,ye,t),s(e,dt,t),s(e,Je,t),s(e,yt,t),J(be,e,t),s(e,Jt,t),s(e,he,t),bt=!0},p(e,[t]){const Pt={};t&2&&(Pt.$$scope={dirty:t,ctx:e}),g.$set(Pt);const Kt={};t&2&&(Kt.$$scope={dirty:t,ctx:e}),v.$set(Kt);const Ot={};t&2&&(Ot.$$scope={dirty:t,ctx:e}),X.$set(Ot)},i(e){bt||(b(i.$$.fragment,e),b($.$$.fragment,e),b(V.$$.fragment,e),b(g.$$.fragment,e),b(I.$$.fragment,e),b(N.$$.fragment,e),b(Y.$$.fragment,e),b(L.$$.fragment,e),b(Q.$$.fragment,e),b(D.$$.fragment,e),b(ee.$$.fragment,e),b(se.$$.fragment,e),b(ie.$$.fragment,e),b(oe.$$.fragment,e),b(ue.$$.fragment,e),b(v.$$.fragment,e),b(X.$$.fragment,e),b(de.$$.fragment,e),b(be.$$.fragment,e),bt=!0)},o(e){T(i.$$.fragment,e),T($.$$.fragment,e),T(V.$$.fragment,e),T(g.$$.fragment,e),T(I.$$.fragment,e),T(N.$$.fragment,e),T(Y.$$.fragment,e),T(L.$$.fragment,e),T(Q.$$.fragment,e),T(D.$$.fragment,e),T(ee.$$.fragment,e),T(se.$$.fragment,e),T(ie.$$.fragment,e),T(oe.$$.fragment,e),T(ue.$$.fragment,e),T(v.$$.fragment,e),T(X.$$.fragment,e),T(de.$$.fragment,e),T(be.$$.fragment,e),bt=!1},d(e){e&&(l(o),l(n),l(f),l(c),l(w),l(C),l(we),l(W),l(ge),l(R),l(Ze),l(B),l(je),l(xe),l(G),l(ve),l(Xe),l(Z),l(Ce),l(F),l(We),l(Re),l(k),l(Be),l(Ve),l(E),l(Ge),l(Fe),l(H),l(Ie),l(j),l(ke),l(Ne),l(z),l(Ee),l(S),l(Ye),l(He),l(A),l(Le),l(q),l(ze),l(Se),l(P),l(Qe),l(K),l(Ae),l(O),l(qe),l(De),l(te),l(Pe),l(le),l(Ke),l(Oe),l(ne),l(et),l(ae),l(tt),l(lt),l(pe),l(st),l(re),l(nt),l(at),l(ce),l(it),l(fe),l(pt),l(x),l(rt),l(me),l(ot),l(ct),l(ft),l(Me),l(mt),l(ut),l(Mt),l(ye),l(dt),l(Je),l(yt),l(Jt),l(he)),l(a),_(i,e),_($,e),_(V,e),_(g,e),_(I,e),_(N,e),_(Y,e),_(L,e),_(Q,e),_(D,e),_(ee,e),_(se,e),_(ie,e),_(oe,e),_(ue,e),_(v,e),_(X,e),_(de,e),_(be,e)}}}const Tl='{"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 _l(h){return ll(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Zl extends sl{constructor(a){super(),nl(this,a,_l,bl,tl,{})}}export{Zl as component};
