import{S as Cr,i as Fr,s as Rr,e as r,k as d,w as E,t as o,M as Br,c as n,d as t,m as h,a as f,x as T,h as l,b as m,N as Xr,G as a,g as p,y as x,q as U,o as k,B as J,v as Sr,L as Jl}from"../../chunks/vendor-hf-doc-builder.js";import{T as ro}from"../../chunks/Tip-hf-doc-builder.js";import{I as ut}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as V}from"../../chunks/CodeBlock-hf-doc-builder.js";import{F as Gr,M as no}from"../../chunks/Markdown-hf-doc-builder.js";function Yr(X){let i,g,s,w,y;return{c(){i=r("p"),g=o("There is a community-created collection of trained Textual Inversion models in the "),s=r("a"),w=o("Stable Diffusion Textual Inversion Concepts Library"),y=o(" which are readily available for inference. Over time, this\u2019ll hopefully grow into a useful resource as more concepts are added!"),this.h()},l(_){i=n(_,"P",{});var $=f(i);g=l($,"There is a community-created collection of trained Textual Inversion models in the "),s=n($,"A",{href:!0,rel:!0});var W=f(s);w=l(W,"Stable Diffusion Textual Inversion Concepts Library"),W.forEach(t),y=l($," which are readily available for inference. Over time, this\u2019ll hopefully grow into a useful resource as more concepts are added!"),$.forEach(t),this.h()},h(){m(s,"href","https://huggingface.co/sd-concepts-library"),m(s,"rel","nofollow")},m(_,$){p(_,i,$),a(i,g),a(i,s),a(s,w),a(i,y)},d(_){_&&t(i)}}}function Vr(X){let i,g,s,w,y;return{c(){i=r("p"),g=o("\u{1F4A1} A full training run takes ~1 hour on one V100 GPU. While you\u2019re waiting for the training to complete, feel free to check out "),s=r("a"),w=o("how Textual Inversion works"),y=o(" in the section below if you\u2019re curious!"),this.h()},l(_){i=n(_,"P",{});var $=f(i);g=l($,"\u{1F4A1} A full training run takes ~1 hour on one V100 GPU. While you\u2019re waiting for the training to complete, feel free to check out "),s=n($,"A",{href:!0});var W=f(s);w=l(W,"how Textual Inversion works"),W.forEach(t),y=l($," in the section below if you\u2019re curious!"),$.forEach(t),this.h()},h(){m(s,"href","#how-it-works")},m(_,$){p(_,i,$),a(i,g),a(i,s),a(s,w),a(i,y)},d(_){_&&t(i)}}}function Dr(X){let i,g,s,w,y,_,$,W,G,M,I;return M=new V({props:{code:"LS1udW1fdmVjdG9ycyUzRDU=",highlighted:"--num_vectors=5"}}),{c(){i=r("p"),g=o("\u{1F4A1} If you want to increase the trainable capacity, you can associate your placeholder token, "),s=r("em"),w=o("e.g."),y=d(),_=r("code"),$=o("<cat-toy>"),W=o(` to
multiple embedding vectors. This can help the model to better capture the style of more (complex) images.
To enable training multiple embedding vectors, simply pass:`),G=d(),E(M.$$.fragment)},l(v){i=n(v,"P",{});var j=f(i);g=l(j,"\u{1F4A1} If you want to increase the trainable capacity, you can associate your placeholder token, "),s=n(j,"EM",{});var C=f(s);w=l(C,"e.g."),C.forEach(t),y=h(j),_=n(j,"CODE",{});var F=f(_);$=l(F,"<cat-toy>"),F.forEach(t),W=l(j,` to
multiple embedding vectors. This can help the model to better capture the style of more (complex) images.
To enable training multiple embedding vectors, simply pass:`),j.forEach(t),G=h(v),T(M.$$.fragment,v)},m(v,j){p(v,i,j),a(i,g),a(i,s),a(s,w),a(i,y),a(i,_),a(_,$),a(i,W),p(v,G,j),x(M,v,j),I=!0},p:Jl,i(v){I||(U(M.$$.fragment,v),I=!0)},o(v){k(M.$$.fragment,v),I=!1},d(v){v&&t(i),v&&t(G),J(M,v)}}}function Qr(X){let i,g,s,w;return i=new V({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBZXhwb3J0JTIwREFUQV9ESVIlM0QlMjIuJTJGY2F0JTIyJTBBJTBBYWNjZWxlcmF0ZSUyMGxhdW5jaCUyMHRleHR1YWxfaW52ZXJzaW9uLnB5JTIwJTVDJTBBJTIwJTIwLS1wcmV0cmFpbmVkX21vZGVsX25hbWVfb3JfcGF0aCUzRCUyNE1PREVMX05BTUUlMjAlNUMlMEElMjAlMjAtLXRyYWluX2RhdGFfZGlyJTNEJTI0REFUQV9ESVIlMjAlNUMlMEElMjAlMjAtLWxlYXJuYWJsZV9wcm9wZXJ0eSUzRCUyMm9iamVjdCUyMiUyMCU1QyUwQSUyMCUyMC0tcGxhY2Vob2xkZXJfdG9rZW4lM0QlMjIlM0NjYXQtdG95JTNFJTIyJTIwLS1pbml0aWFsaXplcl90b2tlbiUzRCUyMnRveSUyMiUyMCU1QyUwQSUyMCUyMC0tcmVzb2x1dGlvbiUzRDUxMiUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fYmF0Y2hfc2l6ZSUzRDElMjAlNUMlMEElMjAlMjAtLWdyYWRpZW50X2FjY3VtdWxhdGlvbl9zdGVwcyUzRDQlMjAlNUMlMEElMjAlMjAtLW1heF90cmFpbl9zdGVwcyUzRDMwMDAlMjAlNUMlMEElMjAlMjAtLWxlYXJuaW5nX3JhdGUlM0Q1LjBlLTA0JTIwLS1zY2FsZV9sciUyMCU1QyUwQSUyMCUyMC0tbHJfc2NoZWR1bGVyJTNEJTIyY29uc3RhbnQlMjIlMjAlNUMlMEElMjAlMjAtLWxyX3dhcm11cF9zdGVwcyUzRDAlMjAlNUMlMEElMjAlMjAtLW91dHB1dF9kaXIlM0QlMjJ0ZXh0dWFsX2ludmVyc2lvbl9jYXQlMjIlMjAlNUMlMEElMjAlMjAtLXB1c2hfdG9faHVi",highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
<span class="hljs-built_in">export</span> 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`}}),s=new ro({props:{$$slots:{default:[Dr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment),g=d(),E(s.$$.fragment)},l(y){T(i.$$.fragment,y),g=h(y),T(s.$$.fragment,y)},m(y,_){x(i,y,_),p(y,g,_),x(s,y,_),w=!0},p(y,_){const $={};_&2&&($.$$scope={dirty:_,ctx:y}),s.$set($)},i(y){w||(U(i.$$.fragment,y),U(s.$$.fragment,y),w=!0)},o(y){k(i.$$.fragment,y),k(s.$$.fragment,y),w=!1},d(y){J(i,y),y&&t(g),J(s,y)}}}function zr(X){let i,g;return i=new no({props:{$$slots:{default:[Qr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){T(i.$$.fragment,s)},m(s,w){x(i,s,w),g=!0},p(s,w){const y={};w&2&&(y.$$scope={dirty:w,ctx:s}),i.$set(y)},i(s){g||(U(i.$$.fragment,s),g=!0)},o(s){k(i.$$.fragment,s),g=!1},d(s){J(i,s)}}}function Lr(X){let i,g,s,w,y,_,$,W,G,M,I,v,j,C,F,fe,Q,R,oe,z,ee,B,H,P,te,S,ae,A,le;return M=new V({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:"pip install -U -r requirements_flax.txt"}}),A=new V({props:{code:"ZXhwb3J0JTIwTU9ERUxfTkFNRSUzRCUyMmR1b25nbmElMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQtZmxheCUyMiUwQWV4cG9ydCUyMERBVEFfRElSJTNEJTIyLiUyRmNhdCUyMiUwQSUwQXB5dGhvbiUyMHRleHR1YWxfaW52ZXJzaW9uX2ZsYXgucHklMjAlNUMlMEElMjAlMjAtLXByZXRyYWluZWRfbW9kZWxfbmFtZV9vcl9wYXRoJTNEJTI0TU9ERUxfTkFNRSUyMCU1QyUwQSUyMCUyMC0tdHJhaW5fZGF0YV9kaXIlM0QlMjREQVRBX0RJUiUyMCU1QyUwQSUyMCUyMC0tbGVhcm5hYmxlX3Byb3BlcnR5JTNEJTIyb2JqZWN0JTIyJTIwJTVDJTBBJTIwJTIwLS1wbGFjZWhvbGRlcl90b2tlbiUzRCUyMiUzQ2NhdC10b3klM0UlMjIlMjAtLWluaXRpYWxpemVyX3Rva2VuJTNEJTIydG95JTIyJTIwJTVDJTBBJTIwJTIwLS1yZXNvbHV0aW9uJTNENTEyJTIwJTVDJTBBJTIwJTIwLS10cmFpbl9iYXRjaF9zaXplJTNEMSUyMCU1QyUwQSUyMCUyMC0tbWF4X3RyYWluX3N0ZXBzJTNEMzAwMCUyMCU1QyUwQSUyMCUyMC0tbGVhcm5pbmdfcmF0ZSUzRDUuMGUtMDQlMjAtLXNjYWxlX2xyJTIwJTVDJTBBJTIwJTIwLS1vdXRwdXRfZGlyJTNEJTIydGV4dHVhbF9pbnZlcnNpb25fY2F0JTIyJTIwJTVDJTBBJTIwJTIwLS1wdXNoX3RvX2h1Yg==",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`}}),{c(){i=r("p"),g=o("If you have access to TPUs, try out the "),s=r("a"),w=o("Flax training script"),y=o(" to train even faster (this\u2019ll also work for GPUs). With the same configuration settings, the Flax training script should be at least 70% faster than the PyTorch training script! \u26A1\uFE0F"),_=d(),$=r("p"),W=o("Before you begin, make sure you install the Flax specific dependencies:"),G=d(),E(M.$$.fragment),I=d(),v=r("p"),j=o("Specify the "),C=r("code"),F=o("MODEL_NAME"),fe=o(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Q=r("a"),R=r("code"),oe=o("pretrained_model_name_or_path"),z=o(" argument."),ee=d(),B=r("p"),H=o("Then you can launch the "),P=r("a"),te=o("training script"),S=o(":"),ae=d(),E(A.$$.fragment),this.h()},l(b){i=n(b,"P",{});var N=f(i);g=l(N,"If you have access to TPUs, try out the "),s=n(N,"A",{href:!0,rel:!0});var D=f(s);w=l(D,"Flax training script"),D.forEach(t),y=l(N," to train even faster (this\u2019ll also work for GPUs). With the same configuration settings, the Flax training script should be at least 70% faster than the PyTorch training script! \u26A1\uFE0F"),N.forEach(t),_=h(b),$=n(b,"P",{});var q=f($);W=l(q,"Before you begin, make sure you install the Flax specific dependencies:"),q.forEach(t),G=h(b),T(M.$$.fragment,b),I=h(b),v=n(b,"P",{});var Y=f(v);j=l(Y,"Specify the "),C=n(Y,"CODE",{});var re=f(C);F=l(re,"MODEL_NAME"),re.forEach(t),fe=l(Y," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),Q=n(Y,"A",{href:!0,rel:!0});var O=f(Q);R=n(O,"CODE",{});var me=f(R);oe=l(me,"pretrained_model_name_or_path"),me.forEach(t),O.forEach(t),z=l(Y," argument."),Y.forEach(t),ee=h(b),B=n(b,"P",{});var L=f(B);H=l(L,"Then you can launch the "),P=n(L,"A",{href:!0,rel:!0});var pe=f(P);te=l(pe,"training script"),pe.forEach(t),S=l(L,":"),L.forEach(t),ae=h(b),T(A.$$.fragment,b),this.h()},h(){m(s,"href","https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion_flax.py"),m(s,"rel","nofollow"),m(Q,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),m(Q,"rel","nofollow"),m(P,"href","https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion_flax.py"),m(P,"rel","nofollow")},m(b,N){p(b,i,N),a(i,g),a(i,s),a(s,w),a(i,y),p(b,_,N),p(b,$,N),a($,W),p(b,G,N),x(M,b,N),p(b,I,N),p(b,v,N),a(v,j),a(v,C),a(C,F),a(v,fe),a(v,Q),a(Q,R),a(R,oe),a(v,z),p(b,ee,N),p(b,B,N),a(B,H),a(B,P),a(P,te),a(B,S),p(b,ae,N),x(A,b,N),le=!0},p:Jl,i(b){le||(U(M.$$.fragment,b),U(A.$$.fragment,b),le=!0)},o(b){k(M.$$.fragment,b),k(A.$$.fragment,b),le=!1},d(b){b&&t(i),b&&t(_),b&&t($),b&&t(G),J(M,b),b&&t(I),b&&t(v),b&&t(ee),b&&t(B),b&&t(ae),J(A,b)}}}function Hr(X){let i,g;return i=new no({props:{$$slots:{default:[Lr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){T(i.$$.fragment,s)},m(s,w){x(i,s,w),g=!0},p(s,w){const y={};w&2&&(y.$$scope={dirty:w,ctx:s}),i.$set(y)},i(s){g||(U(i.$$.fragment,s),g=!0)},o(s){k(i.$$.fragment,s),g=!1},d(s){J(i,s)}}}function Pr(X){let i,g,s,w,y;return{c(){i=r("p"),g=o("\u{1F4A1} The community has created a large library of different textual inversion embedding vectors, called "),s=r("a"),w=o("sd-concepts-library"),y=o(`.
Instead of training textual inversion embeddings from scratch you can also see whether a fitting textual inversion embedding has already been added to the libary.`),this.h()},l(_){i=n(_,"P",{});var $=f(i);g=l($,"\u{1F4A1} The community has created a large library of different textual inversion embedding vectors, called "),s=n($,"A",{href:!0,rel:!0});var W=f(s);w=l(W,"sd-concepts-library"),W.forEach(t),y=l($,`.
Instead of training textual inversion embeddings from scratch you can also see whether a fitting textual inversion embedding has already been added to the libary.`),$.forEach(t),this.h()},h(){m(s,"href","https://huggingface.co/sd-concepts-library"),m(s,"rel","nofollow")},m(_,$){p(_,i,$),a(i,g),a(i,s),a(s,w),a(i,y)},d(_){_&&t(i)}}}function qr(X){let i,g,s,w,y,_,$,W,G,M,I,v,j,C,F,fe,Q,R,oe,z,ee,B,H,P,te,S,ae,A,le,b,N,D,q,Y,re,O,me,L,pe,ce,be;return i=new ro({props:{$$slots:{default:[Pr]},$$scope:{ctx:X}}}),M=new V({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMik=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)`}}),R=new V({props:{code:"cGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCUyMnNkLWNvbmNlcHRzLWxpYnJhcnklMkZjYXQtdG95JTIyKQ==",highlighted:'pipe.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/cat-toy&quot;</span>)'}}),S=new V({props:{code:"cHJvbXB0JTIwJTNEJTIwJTIyQSUyMCUzQ2NhdC10b3klM0UlMjBiYWNrcGFjayUyMiUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTApLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmNhdC1iYWNrcGFjay5wbmclMjIp",highlighted:`prompt = <span class="hljs-string">&quot;A &lt;cat-toy&gt; backpack&quot;</span>

image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;cat-backpack.png&quot;</span>)`}}),ce=new V({props:{code:"cGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCUyMi4lMkZjaGFydHVybmVydjIucHQlMjIp",highlighted:'pipe.load_textual_inversion(<span class="hljs-string">&quot;./charturnerv2.pt&quot;</span>)'}}),{c(){E(i.$$.fragment),g=d(),s=r("p"),w=o(`To load the textual inversion embeddings you first need to load the base model that was used when training
your textual inversion embedding vectors. Here we assume that `),y=r("a"),_=r("code"),$=o("runwayml/stable-diffusion-v1-5"),W=o(`
was used as a base model so we load it first:`),G=d(),E(M.$$.fragment),I=d(),v=r("p"),j=o("Next, we need to load the textual inversion embedding vector which can be done via the "),C=r("code"),F=o("TextualInversionLoaderMixin.load_textual_inversion"),fe=o(`
function. Here we\u2019ll load the embeddings of the \u201D<cat-toy>\u201D example from before.`),Q=d(),E(R.$$.fragment),oe=d(),z=r("p"),ee=o("Now we can run the pipeline making sure that the placeholder token "),B=r("code"),H=o("<cat-toy>"),P=o(" is used in our prompt."),te=d(),E(S.$$.fragment),ae=d(),A=r("p"),le=o("The function "),b=r("code"),N=o("TextualInversionLoaderMixin.load_textual_inversion"),D=o(` can not only
load textual embedding vectors saved in Diffusers\u2019 format, but also embedding vectors
saved in `),q=r("a"),Y=o("Automatic1111"),re=o(` format.
To do so, you can first download an embedding vector from `),O=r("a"),me=o("civitAI"),L=o(`
and then load it locally:`),pe=d(),E(ce.$$.fragment),this.h()},l(u){T(i.$$.fragment,u),g=h(u),s=n(u,"P",{});var Z=f(s);w=l(Z,`To load the textual inversion embeddings you first need to load the base model that was used when training
your textual inversion embedding vectors. Here we assume that `),y=n(Z,"A",{href:!0});var ne=f(y);_=n(ne,"CODE",{});var mt=f(_);$=l(mt,"runwayml/stable-diffusion-v1-5"),mt.forEach(t),ne.forEach(t),W=l(Z,`
was used as a base model so we load it first:`),Z.forEach(t),G=h(u),T(M.$$.fragment,u),I=h(u),v=n(u,"P",{});var $e=f(v);j=l($e,"Next, we need to load the textual inversion embedding vector which can be done via the "),C=n($e,"CODE",{});var de=f(C);F=l(de,"TextualInversionLoaderMixin.load_textual_inversion"),de.forEach(t),fe=l($e,`
function. Here we\u2019ll load the embeddings of the \u201D<cat-toy>\u201D example from before.`),$e.forEach(t),Q=h(u),T(R.$$.fragment,u),oe=h(u),z=n(u,"P",{});var Me=f(z);ee=l(Me,"Now we can run the pipeline making sure that the placeholder token "),B=n(Me,"CODE",{});var ue=f(B);H=l(ue,"<cat-toy>"),ue.forEach(t),P=l(Me," is used in our prompt."),Me.forEach(t),te=h(u),T(S.$$.fragment,u),ae=h(u),A=n(u,"P",{});var ie=f(A);le=l(ie,"The function "),b=n(ie,"CODE",{});var he=f(b);N=l(he,"TextualInversionLoaderMixin.load_textual_inversion"),he.forEach(t),D=l(ie,` can not only
load textual embedding vectors saved in Diffusers\u2019 format, but also embedding vectors
saved in `),q=n(ie,"A",{href:!0,rel:!0});var dt=f(q);Y=l(dt,"Automatic1111"),dt.forEach(t),re=l(ie,` format.
To do so, you can first download an embedding vector from `),O=n(ie,"A",{href:!0,rel:!0});var ht=f(O);me=l(ht,"civitAI"),ht.forEach(t),L=l(ie,`
and then load it locally:`),ie.forEach(t),pe=h(u),T(ce.$$.fragment,u),this.h()},h(){m(y,"href","runwayml/stable-diffusion-v1-5"),m(q,"href","https://github.com/AUTOMATIC1111/stable-diffusion-webui"),m(q,"rel","nofollow"),m(O,"href","https://civitai.com/models/3036?modelVersionId=8387"),m(O,"rel","nofollow")},m(u,Z){x(i,u,Z),p(u,g,Z),p(u,s,Z),a(s,w),a(s,y),a(y,_),a(_,$),a(s,W),p(u,G,Z),x(M,u,Z),p(u,I,Z),p(u,v,Z),a(v,j),a(v,C),a(C,F),a(v,fe),p(u,Q,Z),x(R,u,Z),p(u,oe,Z),p(u,z,Z),a(z,ee),a(z,B),a(B,H),a(z,P),p(u,te,Z),x(S,u,Z),p(u,ae,Z),p(u,A,Z),a(A,le),a(A,b),a(b,N),a(A,D),a(A,q),a(q,Y),a(A,re),a(A,O),a(O,me),a(A,L),p(u,pe,Z),x(ce,u,Z),be=!0},p(u,Z){const ne={};Z&2&&(ne.$$scope={dirty:Z,ctx:u}),i.$set(ne)},i(u){be||(U(i.$$.fragment,u),U(M.$$.fragment,u),U(R.$$.fragment,u),U(S.$$.fragment,u),U(ce.$$.fragment,u),be=!0)},o(u){k(i.$$.fragment,u),k(M.$$.fragment,u),k(R.$$.fragment,u),k(S.$$.fragment,u),k(ce.$$.fragment,u),be=!1},d(u){J(i,u),u&&t(g),u&&t(s),u&&t(G),J(M,u),u&&t(I),u&&t(v),u&&t(Q),J(R,u),u&&t(oe),u&&t(z),u&&t(te),J(S,u),u&&t(ae),u&&t(A),u&&t(pe),J(ce,u)}}}function Or(X){let i,g;return i=new no({props:{$$slots:{default:[qr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){T(i.$$.fragment,s)},m(s,w){x(i,s,w),g=!0},p(s,w){const y={};w&2&&(y.$$scope={dirty:w,ctx:s}),i.$set(y)},i(s){g||(U(i.$$.fragment,s),g=!0)},o(s){k(i.$$.fragment,s),g=!1},d(s){J(i,s)}}}function Kr(X){let i,g,s,w,y,_,$,W,G,M,I;return M=new V({props:{code:"aW1wb3J0JTIwamF4JTBBaW1wb3J0JTIwbnVtcHklMjBhcyUyMG5wJTBBZnJvbSUyMGZsYXguamF4X3V0aWxzJTIwaW1wb3J0JTIwcmVwbGljYXRlJTBBZnJvbSUyMGZsYXgudHJhaW5pbmcuY29tbW9uX3V0aWxzJTIwaW1wb3J0JTIwc2hhcmQlMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRmxheFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBJTBBbW9kZWxfcGF0aCUyMCUzRCUyMCUyMnBhdGgtdG8teW91ci10cmFpbmVkLW1vZGVsJTIyJTBBcGlwZWxpbmUlMkMlMjBwYXJhbXMlMjAlM0QlMjBGbGF4U3RhYmxlRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKG1vZGVsX3BhdGglMkMlMjBkdHlwZSUzRGpheC5udW1weS5iZmxvYXQxNiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJBJTIwJTNDY2F0LXRveSUzRSUyMGJhY2twYWNrJTIyJTBBcHJuZ19zZWVkJTIwJTNEJTIwamF4LnJhbmRvbS5QUk5HS2V5KDApJTBBbnVtX2luZmVyZW5jZV9zdGVwcyUyMCUzRCUyMDUwJTBBJTBBbnVtX3NhbXBsZXMlMjAlM0QlMjBqYXguZGV2aWNlX2NvdW50KCklMEFwcm9tcHQlMjAlM0QlMjBudW1fc2FtcGxlcyUyMColMjAlNUJwcm9tcHQlNUQlMEFwcm9tcHRfaWRzJTIwJTNEJTIwcGlwZWxpbmUucHJlcGFyZV9pbnB1dHMocHJvbXB0KSUwQSUwQSUyMyUyMHNoYXJkJTIwaW5wdXRzJTIwYW5kJTIwcm5nJTBBcGFyYW1zJTIwJTNEJTIwcmVwbGljYXRlKHBhcmFtcyklMEFwcm5nX3NlZWQlMjAlM0QlMjBqYXgucmFuZG9tLnNwbGl0KHBybmdfc2VlZCUyQyUyMGpheC5kZXZpY2VfY291bnQoKSklMEFwcm9tcHRfaWRzJTIwJTNEJTIwc2hhcmQocHJvbXB0X2lkcyklMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlbGluZShwcm9tcHRfaWRzJTJDJTIwcGFyYW1zJTJDJTIwcHJuZ19zZWVkJTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUyQyUyMGppdCUzRFRydWUpLmltYWdlcyUwQWltYWdlcyUyMCUzRCUyMHBpcGVsaW5lLm51bXB5X3RvX3BpbChucC5hc2FycmF5KGltYWdlcy5yZXNoYXBlKChudW1fc2FtcGxlcyUyQyklMjAlMkIlMjBpbWFnZXMuc2hhcGUlNUItMyUzQSU1RCkpKSUwQWltYWdlLnNhdmUoJTIyY2F0LWJhY2twYWNrLnBuZyUyMik=",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; backpack&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;cat-backpack.png&quot;</span>)`}}),{c(){i=r("p"),g=o("Currently there is no "),s=r("code"),w=o("load_textual_inversion"),y=o(` function for Flax so one has to make sure the textual inversion
embedding vector is saved as part of the model after training.`),_=d(),$=r("p"),W=o("The model can then be run just like any other Flax model:"),G=d(),E(M.$$.fragment)},l(v){i=n(v,"P",{});var j=f(i);g=l(j,"Currently there is no "),s=n(j,"CODE",{});var C=f(s);w=l(C,"load_textual_inversion"),C.forEach(t),y=l(j,` function for Flax so one has to make sure the textual inversion
embedding vector is saved as part of the model after training.`),j.forEach(t),_=h(v),$=n(v,"P",{});var F=f($);W=l(F,"The model can then be run just like any other Flax model:"),F.forEach(t),G=h(v),T(M.$$.fragment,v)},m(v,j){p(v,i,j),a(i,g),a(i,s),a(s,w),a(i,y),p(v,_,j),p(v,$,j),a($,W),p(v,G,j),x(M,v,j),I=!0},p:Jl,i(v){I||(U(M.$$.fragment,v),I=!0)},o(v){k(M.$$.fragment,v),I=!1},d(v){v&&t(i),v&&t(_),v&&t($),v&&t(G),J(M,v)}}}function en(X){let i,g;return i=new no({props:{$$slots:{default:[Kr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){T(i.$$.fragment,s)},m(s,w){x(i,s,w),g=!0},p(s,w){const y={};w&2&&(y.$$scope={dirty:w,ctx:s}),i.$set(y)},i(s){g||(U(i.$$.fragment,s),g=!0)},o(s){k(i.$$.fragment,s),g=!1},d(s){J(i,s)}}}function tn(X){let i,g,s,w,y,_,$,W,G,M,I,v,j,C,F,fe,Q,R,oe,z,ee,B,H,P,te,S,ae,A,le,b,N,D,q,Y,re,O,me,L,pe,ce,be,u,Z,ne,mt,$e,de,Me,ue,ie,he,dt,ht,ma,De,da,yt,io,ha,Qe,ya,vt,so,va,ze,wa,ye,fo,Le,po,co,At,uo,mo,ga,Ee,Ie,Nt,He,ho,Xt,yo,_a,wt,vo,ba,Pe,$a,Te,We,Gt,qe,wo,Ct,go,Ma,Ze,_o,Ft,bo,$o,Ea,Oe,Ta,gt,Mo,xa,Ke,Ua,xe,Ae,Rt,et,Eo,Bt,To,ka,ve,xo,tt,Uo,ko,_t,Jo,jo,Ja,at,ja,se,Io,St,Wo,Zo,ot,Yt,Ao,No,Vt,Xo,Go,Ia,K,Co,lt,Fo,Ro,Dt,Bo,So,Qt,Yo,Vo,zt,Do,Qo,Wa,Ne,Za,Xe,Aa,Ue,Ge,Lt,rt,zo,Ht,Lo,Na,bt,Ho,Xa,we,Ce,Pt,Po,qo,qt,Oo,Ko,el,$t,Ot,tl,al,ol,ke,Kt,ll,rl,ea,nl,il,ta,sl,Ga,nt,Ca,Je,Fe,aa,it,fl,oa,pl,Fa,Re,cl,Mt,ul,ml,Ra,Et,dl,Ba,Be,Sa,je,Se,la,st,hl,ra,yl,Ya,Tt,xt,jl,Va,ft,vl,Ut,wl,Da,ge,gl,na,_l,bl,ia,$l,Ml,Qa,Ye,El,sa,Tl,xl,za;return _=new ut({}),u=new ro({props:{$$slots:{default:[Yr]},$$scope:{ctx:X}}}),de=new V({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRpZmZ1c2VycyUyMGFjY2VsZXJhdGUlMjB0cmFuc2Zvcm1lcnM=",highlighted:"pip install diffusers accelerate transformers"}}),De=new V({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),Qe=new V({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),ze=new V({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`from accelerate.utils import write_basic_config

write_basic_config()`}}),He=new ut({}),Pe=new V({props:{code:"LS1wdXNoX3RvX2h1Yg==",highlighted:"--push_to_hub"}}),qe=new ut({}),Oe=new V({props:{code:"LS1jaGVja3BvaW50aW5nX3N0ZXBzJTNENTAw",highlighted:"--checkpointing_steps=500"}}),Ke=new V({props:{code:"LS1yZXN1bWVfZnJvbV9jaGVja3BvaW50JTNEJTIyY2hlY2twb2ludC0xNTAwJTIy",highlighted:'--resume_from_checkpoint=<span class="hljs-string">&quot;checkpoint-1500&quot;</span>'}}),et=new ut({}),at=new V({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>
)`}}),Ne=new ro({props:{$$slots:{default:[Vr]},$$scope:{ctx:X}}}),Xe=new Gr({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[Hr],pytorch:[zr]},$$scope:{ctx:X}}}),rt=new ut({}),nt=new V({props:{code:"LS12YWxpZGF0aW9uX3Byb21wdCUzRCUyMkElMjAlM0NjYXQtdG95JTNFJTIwYmFja3BhY2slMjIlMEEtLW51bV92YWxpZGF0aW9uX2ltYWdlcyUzRDQlMEEtLXZhbGlkYXRpb25fc3RlcHMlM0QxMDA=",highlighted:`--validation_prompt=<span class="hljs-string">&quot;A &lt;cat-toy&gt; backpack&quot;</span>
--num_validation_images=4
--validation_steps=100`}}),it=new ut({}),Be=new Gr({props:{pytorch:!0,tensorflow:!1,jax:!0,$$slots:{jax:[en],pytorch:[Or]},$$scope:{ctx:X}}}),st=new ut({}),{c(){i=r("meta"),g=d(),s=r("h1"),w=r("a"),y=r("span"),E(_.$$.fragment),$=d(),W=r("span"),G=o("Textual Inversion"),M=d(),I=r("p"),v=r("a"),j=o("Textual Inversion"),C=o(" is a technique for capturing novel concepts from a small number of example images. While the technique was originally demonstrated with a "),F=r("a"),fe=o("latent diffusion model"),Q=o(", it has since been applied to other model variants like "),R=r("a"),oe=o("Stable Diffusion"),z=o(". The learned concepts can be used to better control the images generated from text-to-image pipelines. It learns new \u201Cwords\u201D in the text encoder\u2019s embedding space, which are used within text prompts for personalized image generation."),ee=d(),B=r("p"),H=r("img"),te=d(),S=r("small"),ae=o("By using just 3-5 images you can teach new concepts to a model such as Stable Diffusion for personalized image generation "),A=r("a"),le=o("(image source)"),b=o("."),N=d(),D=r("p"),q=o("This guide will show you how to train a "),Y=r("a"),re=r("code"),O=o("runwayml/stable-diffusion-v1-5"),me=o(" model with Textual Inversion. All the training scripts for Textual Inversion used in this guide can be found "),L=r("a"),pe=o("here"),ce=o(" if you\u2019re interested in taking a closer look at how things work under the hood."),be=d(),E(u.$$.fragment),Z=d(),ne=r("p"),mt=o("Before you begin, make sure you install the library\u2019s training dependencies:"),$e=d(),E(de.$$.fragment),Me=d(),ue=r("p"),ie=o("After all the dependencies have been set up, initialize a "),he=r("a"),dt=o("\u{1F917}Accelerate"),ht=o(" environment with:"),ma=d(),E(De.$$.fragment),da=d(),yt=r("p"),io=o("To setup a default \u{1F917} Accelerate environment without choosing any configurations:"),ha=d(),E(Qe.$$.fragment),ya=d(),vt=r("p"),so=o("Or if your environment doesn\u2019t support an interactive shell like a notebook, you can use:"),va=d(),E(ze.$$.fragment),wa=d(),ye=r("p"),fo=o("Finally, you try and "),Le=r("a"),po=o("install xFormers"),co=o(" to reduce your memory footprint with xFormers memory-efficient attention. Once you have xFormers installed, add the "),At=r("code"),uo=o("--enable_xformers_memory_efficient_attention"),mo=o(" argument to the training script. xFormers is not supported for Flax."),ga=d(),Ee=r("h2"),Ie=r("a"),Nt=r("span"),E(He.$$.fragment),ho=d(),Xt=r("span"),yo=o("Upload model to Hub"),_a=d(),wt=r("p"),vo=o("If you want to store your model on the Hub, add the following argument to the training script:"),ba=d(),E(Pe.$$.fragment),$a=d(),Te=r("h2"),We=r("a"),Gt=r("span"),E(qe.$$.fragment),wo=d(),Ct=r("span"),go=o("Save and load checkpoints"),Ma=d(),Ze=r("p"),_o=o("It is often a good idea to regularly save checkpoints of your model during training. This way, you can resume training from a saved checkpoint if your training is interrupted for any reason. To save a checkpoint, pass the following argument to the training script to save the full training state in a subfolder in "),Ft=r("code"),bo=o("output_dir"),$o=o(" every 500 steps:"),Ea=d(),E(Oe.$$.fragment),Ta=d(),gt=r("p"),Mo=o("To resume training from a saved checkpoint, pass the following argument to the training script and the specific checkpoint you\u2019d like to resume from:"),xa=d(),E(Ke.$$.fragment),Ua=d(),xe=r("h2"),Ae=r("a"),Rt=r("span"),E(et.$$.fragment),Eo=d(),Bt=r("span"),To=o("Finetuning"),ka=d(),ve=r("p"),xo=o("For your training dataset, download these "),tt=r("a"),Uo=o("images of a cat toy"),ko=o(" and store them in a directory. To use your own dataset, take a look at the "),_t=r("a"),Jo=o("Create a dataset for training"),jo=o(" guide."),Ja=d(),E(at.$$.fragment),ja=d(),se=r("p"),Io=o("Specify the "),St=r("code"),Wo=o("MODEL_NAME"),Zo=o(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),ot=r("a"),Yt=r("code"),Ao=o("pretrained_model_name_or_path"),No=o(" argument, and the "),Vt=r("code"),Xo=o("DATA_DIR"),Go=o(" environment variable to the path of the directory containing the images."),Ia=d(),K=r("p"),Co=o("Now you can launch the "),lt=r("a"),Fo=o("training script"),Ro=o(". The script creates and saves the following files to your repository: "),Dt=r("code"),Bo=o("learned_embeds.bin"),So=o(", "),Qt=r("code"),Yo=o("token_identifier.txt"),Vo=o(", and "),zt=r("code"),Do=o("type_of_concept.txt"),Qo=o("."),Wa=d(),E(Ne.$$.fragment),Za=d(),E(Xe.$$.fragment),Aa=d(),Ue=r("h3"),Ge=r("a"),Lt=r("span"),E(rt.$$.fragment),zo=d(),Ht=r("span"),Lo=o("Intermediate logging"),Na=d(),bt=r("p"),Ho=o("If you\u2019re interested in following along with your model training progress, you can save the generated images from the training process. Add the following arguments to the training script to enable intermediate logging:"),Xa=d(),we=r("ul"),Ce=r("li"),Pt=r("code"),Po=o("validation_prompt"),qo=o(", the prompt used to generate samples (this is set to "),qt=r("code"),Oo=o("None"),Ko=o(" by default and intermediate logging is disabled)"),el=d(),$t=r("li"),Ot=r("code"),tl=o("num_validation_images"),al=o(", the number of sample images to generate"),ol=d(),ke=r("li"),Kt=r("code"),ll=o("validation_steps"),rl=o(", the number of steps before generating "),ea=r("code"),nl=o("num_validation_images"),il=o(" from the "),ta=r("code"),sl=o("validation_prompt"),Ga=d(),E(nt.$$.fragment),Ca=d(),Je=r("h2"),Fe=r("a"),aa=r("span"),E(it.$$.fragment),fl=d(),oa=r("span"),pl=o("Inference"),Fa=d(),Re=r("p"),cl=o("Once you have trained a model, you can use it for inference with the "),Mt=r("a"),ul=o("StableDiffusionPipeline"),ml=o("."),Ra=d(),Et=r("p"),dl=o(`The textual inversion script will by default only save the textual inversion embedding vector(s) that have
been added to the text encoder embedding matrix and consequently been trained.`),Ba=d(),E(Be.$$.fragment),Sa=d(),je=r("h2"),Se=r("a"),la=r("span"),E(st.$$.fragment),hl=d(),ra=r("span"),yl=o("How it works"),Ya=d(),Tt=r("p"),xt=r("img"),Va=d(),ft=r("small"),vl=o("Architecture overview from the Textual Inversion "),Ut=r("a"),wl=o("blog post."),Da=d(),ge=r("p"),gl=o("Usually, text prompts are tokenized into an embedding before being passed to a model, which is often a transformer. Textual Inversion does something similar, but it learns a new token embedding, "),na=r("code"),_l=o("v*"),bl=o(", from a special token "),ia=r("code"),$l=o("S*"),Ml=o(" in the diagram above. The model output is used to condition the diffusion model, which helps the diffusion model understand the prompt and new concepts from just a few example images."),Qa=d(),Ye=r("p"),El=o("To do this, Textual Inversion uses a generator model and noisy versions of the training images. The generator tries to predict less noisy versions of the images, and the token embedding "),sa=r("code"),Tl=o("v*"),xl=o(" is optimized based on how well the generator does. If the token embedding successfully captures the new concept, it gives more useful information to the diffusion model and helps create clearer images with less noise. This optimization process typically occurs after several thousand steps of exposure to a variety of prompt and image variants."),this.h()},l(e){const c=Br('[data-svelte="svelte-1phssyn"]',document.head);i=n(c,"META",{name:!0,content:!0}),c.forEach(t),g=h(e),s=n(e,"H1",{class:!0});var pt=f(s);w=n(pt,"A",{id:!0,class:!0,href:!0});var fa=f(w);y=n(fa,"SPAN",{});var pa=f(y);T(_.$$.fragment,pa),pa.forEach(t),fa.forEach(t),$=h(pt),W=n(pt,"SPAN",{});var ca=f(W);G=l(ca,"Textual Inversion"),ca.forEach(t),pt.forEach(t),M=h(e),I=n(e,"P",{});var ct=f(I);v=n(ct,"A",{href:!0,rel:!0});var Il=f(v);j=l(Il,"Textual Inversion"),Il.forEach(t),C=l(ct," is a technique for capturing novel concepts from a small number of example images. While the technique was originally demonstrated with a "),F=n(ct,"A",{href:!0,rel:!0});var Wl=f(F);fe=l(Wl,"latent diffusion model"),Wl.forEach(t),Q=l(ct,", it has since been applied to other model variants like "),R=n(ct,"A",{href:!0,rel:!0});var Zl=f(R);oe=l(Zl,"Stable Diffusion"),Zl.forEach(t),z=l(ct,". The learned concepts can be used to better control the images generated from text-to-image pipelines. It learns new \u201Cwords\u201D in the text encoder\u2019s embedding space, which are used within text prompts for personalized image generation."),ct.forEach(t),ee=h(e),B=n(e,"P",{});var Al=f(B);H=n(Al,"IMG",{src:!0,alt:!0}),Al.forEach(t),te=h(e),S=n(e,"SMALL",{});var La=f(S);ae=l(La,"By using just 3-5 images you can teach new concepts to a model such as Stable Diffusion for personalized image generation "),A=n(La,"A",{href:!0});var Nl=f(A);le=l(Nl,"(image source)"),Nl.forEach(t),b=l(La,"."),La.forEach(t),N=h(e),D=n(e,"P",{});var kt=f(D);q=l(kt,"This guide will show you how to train a "),Y=n(kt,"A",{href:!0,rel:!0});var Xl=f(Y);re=n(Xl,"CODE",{});var Gl=f(re);O=l(Gl,"runwayml/stable-diffusion-v1-5"),Gl.forEach(t),Xl.forEach(t),me=l(kt," model with Textual Inversion. All the training scripts for Textual Inversion used in this guide can be found "),L=n(kt,"A",{href:!0,rel:!0});var Cl=f(L);pe=l(Cl,"here"),Cl.forEach(t),ce=l(kt," if you\u2019re interested in taking a closer look at how things work under the hood."),kt.forEach(t),be=h(e),T(u.$$.fragment,e),Z=h(e),ne=n(e,"P",{});var Fl=f(ne);mt=l(Fl,"Before you begin, make sure you install the library\u2019s training dependencies:"),Fl.forEach(t),$e=h(e),T(de.$$.fragment,e),Me=h(e),ue=n(e,"P",{});var Ha=f(ue);ie=l(Ha,"After all the dependencies have been set up, initialize a "),he=n(Ha,"A",{href:!0,rel:!0});var Rl=f(he);dt=l(Rl,"\u{1F917}Accelerate"),Rl.forEach(t),ht=l(Ha," environment with:"),Ha.forEach(t),ma=h(e),T(De.$$.fragment,e),da=h(e),yt=n(e,"P",{});var Bl=f(yt);io=l(Bl,"To setup a default \u{1F917} Accelerate environment without choosing any configurations:"),Bl.forEach(t),ha=h(e),T(Qe.$$.fragment,e),ya=h(e),vt=n(e,"P",{});var Sl=f(vt);so=l(Sl,"Or if your environment doesn\u2019t support an interactive shell like a notebook, you can use:"),Sl.forEach(t),va=h(e),T(ze.$$.fragment,e),wa=h(e),ye=n(e,"P",{});var Jt=f(ye);fo=l(Jt,"Finally, you try and "),Le=n(Jt,"A",{href:!0,rel:!0});var Yl=f(Le);po=l(Yl,"install xFormers"),Yl.forEach(t),co=l(Jt," to reduce your memory footprint with xFormers memory-efficient attention. Once you have xFormers installed, add the "),At=n(Jt,"CODE",{});var Vl=f(At);uo=l(Vl,"--enable_xformers_memory_efficient_attention"),Vl.forEach(t),mo=l(Jt," argument to the training script. xFormers is not supported for Flax."),Jt.forEach(t),ga=h(e),Ee=n(e,"H2",{class:!0});var Pa=f(Ee);Ie=n(Pa,"A",{id:!0,class:!0,href:!0});var Dl=f(Ie);Nt=n(Dl,"SPAN",{});var Ql=f(Nt);T(He.$$.fragment,Ql),Ql.forEach(t),Dl.forEach(t),ho=h(Pa),Xt=n(Pa,"SPAN",{});var zl=f(Xt);yo=l(zl,"Upload model to Hub"),zl.forEach(t),Pa.forEach(t),_a=h(e),wt=n(e,"P",{});var Ll=f(wt);vo=l(Ll,"If you want to store your model on the Hub, add the following argument to the training script:"),Ll.forEach(t),ba=h(e),T(Pe.$$.fragment,e),$a=h(e),Te=n(e,"H2",{class:!0});var qa=f(Te);We=n(qa,"A",{id:!0,class:!0,href:!0});var Hl=f(We);Gt=n(Hl,"SPAN",{});var Pl=f(Gt);T(qe.$$.fragment,Pl),Pl.forEach(t),Hl.forEach(t),wo=h(qa),Ct=n(qa,"SPAN",{});var ql=f(Ct);go=l(ql,"Save and load checkpoints"),ql.forEach(t),qa.forEach(t),Ma=h(e),Ze=n(e,"P",{});var Oa=f(Ze);_o=l(Oa,"It is often a good idea to regularly save checkpoints of your model during training. This way, you can resume training from a saved checkpoint if your training is interrupted for any reason. To save a checkpoint, pass the following argument to the training script to save the full training state in a subfolder in "),Ft=n(Oa,"CODE",{});var Ol=f(Ft);bo=l(Ol,"output_dir"),Ol.forEach(t),$o=l(Oa," every 500 steps:"),Oa.forEach(t),Ea=h(e),T(Oe.$$.fragment,e),Ta=h(e),gt=n(e,"P",{});var Kl=f(gt);Mo=l(Kl,"To resume training from a saved checkpoint, pass the following argument to the training script and the specific checkpoint you\u2019d like to resume from:"),Kl.forEach(t),xa=h(e),T(Ke.$$.fragment,e),Ua=h(e),xe=n(e,"H2",{class:!0});var Ka=f(xe);Ae=n(Ka,"A",{id:!0,class:!0,href:!0});var er=f(Ae);Rt=n(er,"SPAN",{});var tr=f(Rt);T(et.$$.fragment,tr),tr.forEach(t),er.forEach(t),Eo=h(Ka),Bt=n(Ka,"SPAN",{});var ar=f(Bt);To=l(ar,"Finetuning"),ar.forEach(t),Ka.forEach(t),ka=h(e),ve=n(e,"P",{});var jt=f(ve);xo=l(jt,"For your training dataset, download these "),tt=n(jt,"A",{href:!0,rel:!0});var or=f(tt);Uo=l(or,"images of a cat toy"),or.forEach(t),ko=l(jt," and store them in a directory. To use your own dataset, take a look at the "),_t=n(jt,"A",{href:!0});var lr=f(_t);Jo=l(lr,"Create a dataset for training"),lr.forEach(t),jo=l(jt," guide."),jt.forEach(t),Ja=h(e),T(at.$$.fragment,e),ja=h(e),se=n(e,"P",{});var Ve=f(se);Io=l(Ve,"Specify the "),St=n(Ve,"CODE",{});var rr=f(St);Wo=l(rr,"MODEL_NAME"),rr.forEach(t),Zo=l(Ve," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),ot=n(Ve,"A",{href:!0,rel:!0});var nr=f(ot);Yt=n(nr,"CODE",{});var ir=f(Yt);Ao=l(ir,"pretrained_model_name_or_path"),ir.forEach(t),nr.forEach(t),No=l(Ve," argument, and the "),Vt=n(Ve,"CODE",{});var sr=f(Vt);Xo=l(sr,"DATA_DIR"),sr.forEach(t),Go=l(Ve," environment variable to the path of the directory containing the images."),Ve.forEach(t),Ia=h(e),K=n(e,"P",{});var _e=f(K);Co=l(_e,"Now you can launch the "),lt=n(_e,"A",{href:!0,rel:!0});var fr=f(lt);Fo=l(fr,"training script"),fr.forEach(t),Ro=l(_e,". The script creates and saves the following files to your repository: "),Dt=n(_e,"CODE",{});var pr=f(Dt);Bo=l(pr,"learned_embeds.bin"),pr.forEach(t),So=l(_e,", "),Qt=n(_e,"CODE",{});var cr=f(Qt);Yo=l(cr,"token_identifier.txt"),cr.forEach(t),Vo=l(_e,", and "),zt=n(_e,"CODE",{});var ur=f(zt);Do=l(ur,"type_of_concept.txt"),ur.forEach(t),Qo=l(_e,"."),_e.forEach(t),Wa=h(e),T(Ne.$$.fragment,e),Za=h(e),T(Xe.$$.fragment,e),Aa=h(e),Ue=n(e,"H3",{class:!0});var eo=f(Ue);Ge=n(eo,"A",{id:!0,class:!0,href:!0});var mr=f(Ge);Lt=n(mr,"SPAN",{});var dr=f(Lt);T(rt.$$.fragment,dr),dr.forEach(t),mr.forEach(t),zo=h(eo),Ht=n(eo,"SPAN",{});var hr=f(Ht);Lo=l(hr,"Intermediate logging"),hr.forEach(t),eo.forEach(t),Na=h(e),bt=n(e,"P",{});var yr=f(bt);Ho=l(yr,"If you\u2019re interested in following along with your model training progress, you can save the generated images from the training process. Add the following arguments to the training script to enable intermediate logging:"),yr.forEach(t),Xa=h(e),we=n(e,"UL",{});var It=f(we);Ce=n(It,"LI",{});var ua=f(Ce);Pt=n(ua,"CODE",{});var vr=f(Pt);Po=l(vr,"validation_prompt"),vr.forEach(t),qo=l(ua,", the prompt used to generate samples (this is set to "),qt=n(ua,"CODE",{});var wr=f(qt);Oo=l(wr,"None"),wr.forEach(t),Ko=l(ua," by default and intermediate logging is disabled)"),ua.forEach(t),el=h(It),$t=n(It,"LI",{});var Ul=f($t);Ot=n(Ul,"CODE",{});var gr=f(Ot);tl=l(gr,"num_validation_images"),gr.forEach(t),al=l(Ul,", the number of sample images to generate"),Ul.forEach(t),ol=h(It),ke=n(It,"LI",{});var Wt=f(ke);Kt=n(Wt,"CODE",{});var _r=f(Kt);ll=l(_r,"validation_steps"),_r.forEach(t),rl=l(Wt,", the number of steps before generating "),ea=n(Wt,"CODE",{});var br=f(ea);nl=l(br,"num_validation_images"),br.forEach(t),il=l(Wt," from the "),ta=n(Wt,"CODE",{});var $r=f(ta);sl=l($r,"validation_prompt"),$r.forEach(t),Wt.forEach(t),It.forEach(t),Ga=h(e),T(nt.$$.fragment,e),Ca=h(e),Je=n(e,"H2",{class:!0});var to=f(Je);Fe=n(to,"A",{id:!0,class:!0,href:!0});var Mr=f(Fe);aa=n(Mr,"SPAN",{});var Er=f(aa);T(it.$$.fragment,Er),Er.forEach(t),Mr.forEach(t),fl=h(to),oa=n(to,"SPAN",{});var Tr=f(oa);pl=l(Tr,"Inference"),Tr.forEach(t),to.forEach(t),Fa=h(e),Re=n(e,"P",{});var ao=f(Re);cl=l(ao,"Once you have trained a model, you can use it for inference with the "),Mt=n(ao,"A",{href:!0});var xr=f(Mt);ul=l(xr,"StableDiffusionPipeline"),xr.forEach(t),ml=l(ao,"."),ao.forEach(t),Ra=h(e),Et=n(e,"P",{});var Ur=f(Et);dl=l(Ur,`The textual inversion script will by default only save the textual inversion embedding vector(s) that have
been added to the text encoder embedding matrix and consequently been trained.`),Ur.forEach(t),Ba=h(e),T(Be.$$.fragment,e),Sa=h(e),je=n(e,"H2",{class:!0});var oo=f(je);Se=n(oo,"A",{id:!0,class:!0,href:!0});var kr=f(Se);la=n(kr,"SPAN",{});var Jr=f(la);T(st.$$.fragment,Jr),Jr.forEach(t),kr.forEach(t),hl=h(oo),ra=n(oo,"SPAN",{});var jr=f(ra);yl=l(jr,"How it works"),jr.forEach(t),oo.forEach(t),Ya=h(e),Tt=n(e,"P",{});var Ir=f(Tt);xt=n(Ir,"IMG",{src:!0,alt:!0}),Ir.forEach(t),Va=h(e),ft=n(e,"SMALL",{});var kl=f(ft);vl=l(kl,"Architecture overview from the Textual Inversion "),Ut=n(kl,"A",{href:!0});var Wr=f(Ut);wl=l(Wr,"blog post."),Wr.forEach(t),kl.forEach(t),Da=h(e),ge=n(e,"P",{});var Zt=f(ge);gl=l(Zt,"Usually, text prompts are tokenized into an embedding before being passed to a model, which is often a transformer. Textual Inversion does something similar, but it learns a new token embedding, "),na=n(Zt,"CODE",{});var Zr=f(na);_l=l(Zr,"v*"),Zr.forEach(t),bl=l(Zt,", from a special token "),ia=n(Zt,"CODE",{});var Ar=f(ia);$l=l(Ar,"S*"),Ar.forEach(t),Ml=l(Zt," in the diagram above. The model output is used to condition the diffusion model, which helps the diffusion model understand the prompt and new concepts from just a few example images."),Zt.forEach(t),Qa=h(e),Ye=n(e,"P",{});var lo=f(Ye);El=l(lo,"To do this, Textual Inversion uses a generator model and noisy versions of the training images. The generator tries to predict less noisy versions of the images, and the token embedding "),sa=n(lo,"CODE",{});var Nr=f(sa);Tl=l(Nr,"v*"),Nr.forEach(t),xl=l(lo," is optimized based on how well the generator does. If the token embedding successfully captures the new concept, it gives more useful information to the diffusion model and helps create clearer images with less noise. This optimization process typically occurs after several thousand steps of exposure to a variety of prompt and image variants."),lo.forEach(t),this.h()},h(){m(i,"name","hf:doc:metadata"),m(i,"content",JSON.stringify(an)),m(w,"id","textual-inversion"),m(w,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(w,"href","#textual-inversion"),m(s,"class","relative group"),m(v,"href","https://arxiv.org/abs/2208.01618"),m(v,"rel","nofollow"),m(F,"href","https://github.com/CompVis/latent-diffusion"),m(F,"rel","nofollow"),m(R,"href","https://huggingface.co/docs/diffusers/main/en/conceptual/stable_diffusion"),m(R,"rel","nofollow"),Xr(H.src,P="https://textual-inversion.github.io/static/images/editing/colorful_teapot.JPG")||m(H,"src",P),m(H,"alt","Textual Inversion example"),m(A,"href","https://github.com/rinongal/textual_inversion"),m(Y,"href","https://huggingface.co/runwayml/stable-diffusion-v1-5"),m(Y,"rel","nofollow"),m(L,"href","https://github.com/huggingface/diffusers/tree/main/examples/textual_inversion"),m(L,"rel","nofollow"),m(he,"href","https://github.com/huggingface/accelerate/"),m(he,"rel","nofollow"),m(Le,"href","https://huggingface.co/docs/diffusers/main/en/training/optimization/xformers"),m(Le,"rel","nofollow"),m(Ie,"id","upload-model-to-hub"),m(Ie,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Ie,"href","#upload-model-to-hub"),m(Ee,"class","relative group"),m(We,"id","save-and-load-checkpoints"),m(We,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(We,"href","#save-and-load-checkpoints"),m(Te,"class","relative group"),m(Ae,"id","finetuning"),m(Ae,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Ae,"href","#finetuning"),m(xe,"class","relative group"),m(tt,"href","https://huggingface.co/datasets/diffusers/cat_toy_example"),m(tt,"rel","nofollow"),m(_t,"href","create_dataset"),m(ot,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),m(ot,"rel","nofollow"),m(lt,"href","https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion.py"),m(lt,"rel","nofollow"),m(Ge,"id","intermediate-logging"),m(Ge,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Ge,"href","#intermediate-logging"),m(Ue,"class","relative group"),m(Fe,"id","inference"),m(Fe,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Fe,"href","#inference"),m(Je,"class","relative group"),m(Mt,"href","/docs/diffusers/v0.18.2/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),m(Se,"id","how-it-works"),m(Se,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),m(Se,"href","#how-it-works"),m(je,"class","relative group"),Xr(xt.src,jl="https://textual-inversion.github.io/static/images/training/training.JPG")||m(xt,"src",jl),m(xt,"alt","Diagram from the paper showing overview"),m(Ut,"href","https://textual-inversion.github.io/")},m(e,c){a(document.head,i),p(e,g,c),p(e,s,c),a(s,w),a(w,y),x(_,y,null),a(s,$),a(s,W),a(W,G),p(e,M,c),p(e,I,c),a(I,v),a(v,j),a(I,C),a(I,F),a(F,fe),a(I,Q),a(I,R),a(R,oe),a(I,z),p(e,ee,c),p(e,B,c),a(B,H),p(e,te,c),p(e,S,c),a(S,ae),a(S,A),a(A,le),a(S,b),p(e,N,c),p(e,D,c),a(D,q),a(D,Y),a(Y,re),a(re,O),a(D,me),a(D,L),a(L,pe),a(D,ce),p(e,be,c),x(u,e,c),p(e,Z,c),p(e,ne,c),a(ne,mt),p(e,$e,c),x(de,e,c),p(e,Me,c),p(e,ue,c),a(ue,ie),a(ue,he),a(he,dt),a(ue,ht),p(e,ma,c),x(De,e,c),p(e,da,c),p(e,yt,c),a(yt,io),p(e,ha,c),x(Qe,e,c),p(e,ya,c),p(e,vt,c),a(vt,so),p(e,va,c),x(ze,e,c),p(e,wa,c),p(e,ye,c),a(ye,fo),a(ye,Le),a(Le,po),a(ye,co),a(ye,At),a(At,uo),a(ye,mo),p(e,ga,c),p(e,Ee,c),a(Ee,Ie),a(Ie,Nt),x(He,Nt,null),a(Ee,ho),a(Ee,Xt),a(Xt,yo),p(e,_a,c),p(e,wt,c),a(wt,vo),p(e,ba,c),x(Pe,e,c),p(e,$a,c),p(e,Te,c),a(Te,We),a(We,Gt),x(qe,Gt,null),a(Te,wo),a(Te,Ct),a(Ct,go),p(e,Ma,c),p(e,Ze,c),a(Ze,_o),a(Ze,Ft),a(Ft,bo),a(Ze,$o),p(e,Ea,c),x(Oe,e,c),p(e,Ta,c),p(e,gt,c),a(gt,Mo),p(e,xa,c),x(Ke,e,c),p(e,Ua,c),p(e,xe,c),a(xe,Ae),a(Ae,Rt),x(et,Rt,null),a(xe,Eo),a(xe,Bt),a(Bt,To),p(e,ka,c),p(e,ve,c),a(ve,xo),a(ve,tt),a(tt,Uo),a(ve,ko),a(ve,_t),a(_t,Jo),a(ve,jo),p(e,Ja,c),x(at,e,c),p(e,ja,c),p(e,se,c),a(se,Io),a(se,St),a(St,Wo),a(se,Zo),a(se,ot),a(ot,Yt),a(Yt,Ao),a(se,No),a(se,Vt),a(Vt,Xo),a(se,Go),p(e,Ia,c),p(e,K,c),a(K,Co),a(K,lt),a(lt,Fo),a(K,Ro),a(K,Dt),a(Dt,Bo),a(K,So),a(K,Qt),a(Qt,Yo),a(K,Vo),a(K,zt),a(zt,Do),a(K,Qo),p(e,Wa,c),x(Ne,e,c),p(e,Za,c),x(Xe,e,c),p(e,Aa,c),p(e,Ue,c),a(Ue,Ge),a(Ge,Lt),x(rt,Lt,null),a(Ue,zo),a(Ue,Ht),a(Ht,Lo),p(e,Na,c),p(e,bt,c),a(bt,Ho),p(e,Xa,c),p(e,we,c),a(we,Ce),a(Ce,Pt),a(Pt,Po),a(Ce,qo),a(Ce,qt),a(qt,Oo),a(Ce,Ko),a(we,el),a(we,$t),a($t,Ot),a(Ot,tl),a($t,al),a(we,ol),a(we,ke),a(ke,Kt),a(Kt,ll),a(ke,rl),a(ke,ea),a(ea,nl),a(ke,il),a(ke,ta),a(ta,sl),p(e,Ga,c),x(nt,e,c),p(e,Ca,c),p(e,Je,c),a(Je,Fe),a(Fe,aa),x(it,aa,null),a(Je,fl),a(Je,oa),a(oa,pl),p(e,Fa,c),p(e,Re,c),a(Re,cl),a(Re,Mt),a(Mt,ul),a(Re,ml),p(e,Ra,c),p(e,Et,c),a(Et,dl),p(e,Ba,c),x(Be,e,c),p(e,Sa,c),p(e,je,c),a(je,Se),a(Se,la),x(st,la,null),a(je,hl),a(je,ra),a(ra,yl),p(e,Ya,c),p(e,Tt,c),a(Tt,xt),p(e,Va,c),p(e,ft,c),a(ft,vl),a(ft,Ut),a(Ut,wl),p(e,Da,c),p(e,ge,c),a(ge,gl),a(ge,na),a(na,_l),a(ge,bl),a(ge,ia),a(ia,$l),a(ge,Ml),p(e,Qa,c),p(e,Ye,c),a(Ye,El),a(Ye,sa),a(sa,Tl),a(Ye,xl),za=!0},p(e,[c]){const pt={};c&2&&(pt.$$scope={dirty:c,ctx:e}),u.$set(pt);const fa={};c&2&&(fa.$$scope={dirty:c,ctx:e}),Ne.$set(fa);const pa={};c&2&&(pa.$$scope={dirty:c,ctx:e}),Xe.$set(pa);const ca={};c&2&&(ca.$$scope={dirty:c,ctx:e}),Be.$set(ca)},i(e){za||(U(_.$$.fragment,e),U(u.$$.fragment,e),U(de.$$.fragment,e),U(De.$$.fragment,e),U(Qe.$$.fragment,e),U(ze.$$.fragment,e),U(He.$$.fragment,e),U(Pe.$$.fragment,e),U(qe.$$.fragment,e),U(Oe.$$.fragment,e),U(Ke.$$.fragment,e),U(et.$$.fragment,e),U(at.$$.fragment,e),U(Ne.$$.fragment,e),U(Xe.$$.fragment,e),U(rt.$$.fragment,e),U(nt.$$.fragment,e),U(it.$$.fragment,e),U(Be.$$.fragment,e),U(st.$$.fragment,e),za=!0)},o(e){k(_.$$.fragment,e),k(u.$$.fragment,e),k(de.$$.fragment,e),k(De.$$.fragment,e),k(Qe.$$.fragment,e),k(ze.$$.fragment,e),k(He.$$.fragment,e),k(Pe.$$.fragment,e),k(qe.$$.fragment,e),k(Oe.$$.fragment,e),k(Ke.$$.fragment,e),k(et.$$.fragment,e),k(at.$$.fragment,e),k(Ne.$$.fragment,e),k(Xe.$$.fragment,e),k(rt.$$.fragment,e),k(nt.$$.fragment,e),k(it.$$.fragment,e),k(Be.$$.fragment,e),k(st.$$.fragment,e),za=!1},d(e){t(i),e&&t(g),e&&t(s),J(_),e&&t(M),e&&t(I),e&&t(ee),e&&t(B),e&&t(te),e&&t(S),e&&t(N),e&&t(D),e&&t(be),J(u,e),e&&t(Z),e&&t(ne),e&&t($e),J(de,e),e&&t(Me),e&&t(ue),e&&t(ma),J(De,e),e&&t(da),e&&t(yt),e&&t(ha),J(Qe,e),e&&t(ya),e&&t(vt),e&&t(va),J(ze,e),e&&t(wa),e&&t(ye),e&&t(ga),e&&t(Ee),J(He),e&&t(_a),e&&t(wt),e&&t(ba),J(Pe,e),e&&t($a),e&&t(Te),J(qe),e&&t(Ma),e&&t(Ze),e&&t(Ea),J(Oe,e),e&&t(Ta),e&&t(gt),e&&t(xa),J(Ke,e),e&&t(Ua),e&&t(xe),J(et),e&&t(ka),e&&t(ve),e&&t(Ja),J(at,e),e&&t(ja),e&&t(se),e&&t(Ia),e&&t(K),e&&t(Wa),J(Ne,e),e&&t(Za),J(Xe,e),e&&t(Aa),e&&t(Ue),J(rt),e&&t(Na),e&&t(bt),e&&t(Xa),e&&t(we),e&&t(Ga),J(nt,e),e&&t(Ca),e&&t(Je),J(it),e&&t(Fa),e&&t(Re),e&&t(Ra),e&&t(Et),e&&t(Ba),J(Be,e),e&&t(Sa),e&&t(je),J(st),e&&t(Ya),e&&t(Tt),e&&t(Va),e&&t(ft),e&&t(Da),e&&t(ge),e&&t(Qa),e&&t(Ye)}}}const an={local:"textual-inversion",sections:[{local:"upload-model-to-hub",title:"Upload model to Hub"},{local:"save-and-load-checkpoints",title:"Save and load checkpoints"},{local:"finetuning",sections:[{local:"intermediate-logging",title:"Intermediate logging"}],title:"Finetuning"},{local:"inference",title:"Inference"},{local:"how-it-works",title:"How it works"}],title:"Textual Inversion"};function on(X){return Sr(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class pn extends Cr{constructor(i){super();Fr(this,i,on,tn,Rr,{})}}export{pn as default,an as metadata};
