import{S as Rr,i as Br,s as Sr,e as r,k as h,w as E,t as a,M as Yr,c as n,d as t,m as d,a as f,x,h as l,b as u,N as Fr,G as o,g as p,y as k,q as U,o as J,B as j,v as Vr,L as Il}from"../../chunks/vendor-hf-doc-builder.js";import{T as na}from"../../chunks/Tip-hf-doc-builder.js";import{I as mt}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as D}from"../../chunks/CodeBlock-hf-doc-builder.js";import{D as Dr}from"../../chunks/DocNotebookDropdown-hf-doc-builder.js";import{F as Cr,M as ia}from"../../chunks/Markdown-hf-doc-builder.js";function zr(X){let i,b,s,g,y;return{c(){i=r("p"),b=a("There is a community-created collection of trained Textual Inversion models in the "),s=r("a"),g=a("Stable Diffusion Textual Inversion Concepts Library"),y=a(" which are readily available for inference. Over time, this\u2019ll hopefully grow into a useful resource as more concepts are added!"),this.h()},l(w){i=n(w,"P",{});var $=f(i);b=l($,"There is a community-created collection of trained Textual Inversion models in the "),s=n($,"A",{href:!0,rel:!0});var I=f(s);g=l(I,"Stable Diffusion Textual Inversion Concepts Library"),I.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(){u(s,"href","https://huggingface.co/sd-concepts-library"),u(s,"rel","nofollow")},m(w,$){p(w,i,$),o(i,b),o(i,s),o(s,g),o(i,y)},d(w){w&&t(i)}}}function Qr(X){let i,b,s,g,y;return{c(){i=r("p"),b=a("\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"),g=a("how Textual Inversion works"),y=a(" in the section below if you\u2019re curious!"),this.h()},l(w){i=n(w,"P",{});var $=f(i);b=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 I=f(s);g=l(I,"how Textual Inversion works"),I.forEach(t),y=l($," in the section below if you\u2019re curious!"),$.forEach(t),this.h()},h(){u(s,"href","#how-it-works")},m(w,$){p(w,i,$),o(i,b),o(i,s),o(s,g),o(i,y)},d(w){w&&t(i)}}}function Lr(X){let i,b,s,g,y,w,$,I,F,T,A;return T=new D({props:{code:"LS1udW1fdmVjdG9ycyUzRDU=",highlighted:"--num_vectors=5"}}),{c(){i=r("p"),b=a("\u{1F4A1} If you want to increase the trainable capacity, you can associate your placeholder token, "),s=r("em"),g=a("e.g."),y=h(),w=r("code"),$=a("<cat-toy>"),I=a(` 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:`),F=h(),E(T.$$.fragment)},l(v){i=n(v,"P",{});var M=f(i);b=l(M,"\u{1F4A1} If you want to increase the trainable capacity, you can associate your placeholder token, "),s=n(M,"EM",{});var N=f(s);g=l(N,"e.g."),N.forEach(t),y=d(M),w=n(M,"CODE",{});var z=f(w);$=l(z,"<cat-toy>"),z.forEach(t),I=l(M,` 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:`),M.forEach(t),F=d(v),x(T.$$.fragment,v)},m(v,M){p(v,i,M),o(i,b),o(i,s),o(s,g),o(i,y),o(i,w),o(w,$),o(i,I),p(v,F,M),k(T,v,M),A=!0},p:Il,i(v){A||(U(T.$$.fragment,v),A=!0)},o(v){J(T.$$.fragment,v),A=!1},d(v){v&&t(i),v&&t(F),j(T,v)}}}function Pr(X){let i,b,s,g;return i=new D({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 na({props:{$$slots:{default:[Lr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment),b=h(),E(s.$$.fragment)},l(y){x(i.$$.fragment,y),b=d(y),x(s.$$.fragment,y)},m(y,w){k(i,y,w),p(y,b,w),k(s,y,w),g=!0},p(y,w){const $={};w&2&&($.$$scope={dirty:w,ctx:y}),s.$set($)},i(y){g||(U(i.$$.fragment,y),U(s.$$.fragment,y),g=!0)},o(y){J(i.$$.fragment,y),J(s.$$.fragment,y),g=!1},d(y){j(i,y),y&&t(b),j(s,y)}}}function Hr(X){let i,b;return i=new ia({props:{$$slots:{default:[Pr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){x(i.$$.fragment,s)},m(s,g){k(i,s,g),b=!0},p(s,g){const y={};g&2&&(y.$$scope={dirty:g,ctx:s}),i.$set(y)},i(s){b||(U(i.$$.fragment,s),b=!0)},o(s){J(i.$$.fragment,s),b=!1},d(s){j(i,s)}}}function qr(X){let i,b,s,g,y,w,$,I,F,T,A,v,M,N,z,fe,R,Q,oe,B,ae,S,le,Y,L,q,O,Z,re;return T=new D({props:{code:"cGlwJTIwaW5zdGFsbCUyMC1VJTIwLXIlMjByZXF1aXJlbWVudHNfZmxheC50eHQ=",highlighted:"pip install -U -r requirements_flax.txt"}}),Z=new D({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"),b=a("If you have access to TPUs, try out the "),s=r("a"),g=a("Flax training script"),y=a(" 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"),w=h(),$=r("p"),I=a("Before you begin, make sure you install the Flax specific dependencies:"),F=h(),E(T.$$.fragment),A=h(),v=r("p"),M=a("Specify the "),N=r("code"),z=a("MODEL_NAME"),fe=a(" environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),R=r("a"),Q=r("code"),oe=a("pretrained_model_name_or_path"),B=a(" argument."),ae=h(),S=r("p"),le=a("Then you can launch the "),Y=r("a"),L=a("training script"),q=a(":"),O=h(),E(Z.$$.fragment),this.h()},l(_){i=n(_,"P",{});var G=f(i);b=l(G,"If you have access to TPUs, try out the "),s=n(G,"A",{href:!0,rel:!0});var me=f(s);g=l(me,"Flax training script"),me.forEach(t),y=l(G," 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"),G.forEach(t),w=d(_),$=n(_,"P",{});var P=f($);I=l(P,"Before you begin, make sure you install the Flax specific dependencies:"),P.forEach(t),F=d(_),x(T.$$.fragment,_),A=d(_),v=n(_,"P",{});var C=f(v);M=l(C,"Specify the "),N=n(C,"CODE",{});var he=f(N);z=l(he,"MODEL_NAME"),he.forEach(t),fe=l(C," environment variable (either a Hub model repository id or a path to the directory containing the model weights) and pass it to the "),R=n(C,"A",{href:!0,rel:!0});var V=f(R);Q=n(V,"CODE",{});var ne=f(Q);oe=l(ne,"pretrained_model_name_or_path"),ne.forEach(t),V.forEach(t),B=l(C," argument."),C.forEach(t),ae=d(_),S=n(_,"P",{});var ie=f(S);le=l(ie,"Then you can launch the "),Y=n(ie,"A",{href:!0,rel:!0});var pe=f(Y);L=l(pe,"training script"),pe.forEach(t),q=l(ie,":"),ie.forEach(t),O=d(_),x(Z.$$.fragment,_),this.h()},h(){u(s,"href","https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion_flax.py"),u(s,"rel","nofollow"),u(R,"href","https://huggingface.co/docs/diffusers/en/api/diffusion_pipeline#diffusers.DiffusionPipeline.from_pretrained.pretrained_model_name_or_path"),u(R,"rel","nofollow"),u(Y,"href","https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion/textual_inversion_flax.py"),u(Y,"rel","nofollow")},m(_,G){p(_,i,G),o(i,b),o(i,s),o(s,g),o(i,y),p(_,w,G),p(_,$,G),o($,I),p(_,F,G),k(T,_,G),p(_,A,G),p(_,v,G),o(v,M),o(v,N),o(N,z),o(v,fe),o(v,R),o(R,Q),o(Q,oe),o(v,B),p(_,ae,G),p(_,S,G),o(S,le),o(S,Y),o(Y,L),o(S,q),p(_,O,G),k(Z,_,G),re=!0},p:Il,i(_){re||(U(T.$$.fragment,_),U(Z.$$.fragment,_),re=!0)},o(_){J(T.$$.fragment,_),J(Z.$$.fragment,_),re=!1},d(_){_&&t(i),_&&t(w),_&&t($),_&&t(F),j(T,_),_&&t(A),_&&t(v),_&&t(ae),_&&t(S),_&&t(O),j(Z,_)}}}function Or(X){let i,b;return i=new ia({props:{$$slots:{default:[qr]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){x(i.$$.fragment,s)},m(s,g){k(i,s,g),b=!0},p(s,g){const y={};g&2&&(y.$$scope={dirty:g,ctx:s}),i.$set(y)},i(s){b||(U(i.$$.fragment,s),b=!0)},o(s){J(i.$$.fragment,s),b=!1},d(s){j(i,s)}}}function Kr(X){let i,b,s,g,y;return{c(){i=r("p"),b=a("\u{1F4A1} The community has created a large library of different textual inversion embedding vectors, called "),s=r("a"),g=a("sd-concepts-library"),y=a(`.
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(w){i=n(w,"P",{});var $=f(i);b=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 I=f(s);g=l(I,"sd-concepts-library"),I.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(){u(s,"href","https://huggingface.co/sd-concepts-library"),u(s,"rel","nofollow")},m(w,$){p(w,i,$),o(i,b),o(i,s),o(s,g),o(i,y)},d(w){w&&t(i)}}}function en(X){let i,b,s,g,y,w,$,I,F,T,A,v,M,N,z,fe,R,Q,oe,B,ae,S,le,Y,L,q,O,Z,re,_,G,me,P,C,he,V,ne,ie,pe,H,je;return i=new na({props:{$$slots:{default:[Kr]},$$scope:{ctx:X}}}),T=new D({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>)`}}),Q=new D({props:{code:"cGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCUyMnNkLWNvbmNlcHRzLWxpYnJhcnklMkZjYXQtdG95JTIyKQ==",highlighted:'pipe.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/cat-toy&quot;</span>)'}}),q=new D({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>)`}}),H=new D({props:{code:"cGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCUyMi4lMkZjaGFydHVybmVydjIucHQlMjIp",highlighted:'pipe.load_textual_inversion(<span class="hljs-string">&quot;./charturnerv2.pt&quot;</span>)'}}),{c(){E(i.$$.fragment),b=h(),s=r("p"),g=a(`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"),w=r("code"),$=a("runwayml/stable-diffusion-v1-5"),I=a(`
was used as a base model so we load it first:`),F=h(),E(T.$$.fragment),A=h(),v=r("p"),M=a("Next, we need to load the textual inversion embedding vector which can be done via the "),N=r("code"),z=a("TextualInversionLoaderMixin.load_textual_inversion"),fe=a(`
function. Here we\u2019ll load the embeddings of the \u201D<cat-toy>\u201D example from before.`),R=h(),E(Q.$$.fragment),oe=h(),B=r("p"),ae=a("Now we can run the pipeline making sure that the placeholder token "),S=r("code"),le=a("<cat-toy>"),Y=a(" is used in our prompt."),L=h(),E(q.$$.fragment),O=h(),Z=r("p"),re=a("The function "),_=r("code"),G=a("TextualInversionLoaderMixin.load_textual_inversion"),me=a(` can not only
load textual embedding vectors saved in Diffusers\u2019 format, but also embedding vectors
saved in `),P=r("a"),C=a("Automatic1111"),he=a(` format.
To do so, you can first download an embedding vector from `),V=r("a"),ne=a("civitAI"),ie=a(`
and then load it locally:`),pe=h(),E(H.$$.fragment),this.h()},l(m){x(i.$$.fragment,m),b=d(m),s=n(m,"P",{});var W=f(s);g=l(W,`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(W,"A",{href:!0});var K=f(y);w=n(K,"CODE",{});var De=f(w);$=l(De,"runwayml/stable-diffusion-v1-5"),De.forEach(t),K.forEach(t),I=l(W,`
was used as a base model so we load it first:`),W.forEach(t),F=d(m),x(T.$$.fragment,m),A=d(m),v=n(m,"P",{});var ce=f(v);M=l(ce,"Next, we need to load the textual inversion embedding vector which can be done via the "),N=n(ce,"CODE",{});var ht=f(N);z=l(ht,"TextualInversionLoaderMixin.load_textual_inversion"),ht.forEach(t),fe=l(ce,`
function. Here we\u2019ll load the embeddings of the \u201D<cat-toy>\u201D example from before.`),ce.forEach(t),R=d(m),x(Q.$$.fragment,m),oe=d(m),B=n(m,"P",{});var $e=f(B);ae=l($e,"Now we can run the pipeline making sure that the placeholder token "),S=n($e,"CODE",{});var de=f(S);le=l(de,"<cat-toy>"),de.forEach(t),Y=l($e," is used in our prompt."),$e.forEach(t),L=d(m),x(q.$$.fragment,m),O=d(m),Z=n(m,"P",{});var te=f(Z);re=l(te,"The function "),_=n(te,"CODE",{});var ue=f(_);G=l(ue,"TextualInversionLoaderMixin.load_textual_inversion"),ue.forEach(t),me=l(te,` can not only
load textual embedding vectors saved in Diffusers\u2019 format, but also embedding vectors
saved in `),P=n(te,"A",{href:!0,rel:!0});var dt=f(P);C=l(dt,"Automatic1111"),dt.forEach(t),he=l(te,` format.
To do so, you can first download an embedding vector from `),V=n(te,"A",{href:!0,rel:!0});var ye=f(V);ne=l(ye,"civitAI"),ye.forEach(t),ie=l(te,`
and then load it locally:`),te.forEach(t),pe=d(m),x(H.$$.fragment,m),this.h()},h(){u(y,"href","runwayml/stable-diffusion-v1-5"),u(P,"href","https://github.com/AUTOMATIC1111/stable-diffusion-webui"),u(P,"rel","nofollow"),u(V,"href","https://civitai.com/models/3036?modelVersionId=8387"),u(V,"rel","nofollow")},m(m,W){k(i,m,W),p(m,b,W),p(m,s,W),o(s,g),o(s,y),o(y,w),o(w,$),o(s,I),p(m,F,W),k(T,m,W),p(m,A,W),p(m,v,W),o(v,M),o(v,N),o(N,z),o(v,fe),p(m,R,W),k(Q,m,W),p(m,oe,W),p(m,B,W),o(B,ae),o(B,S),o(S,le),o(B,Y),p(m,L,W),k(q,m,W),p(m,O,W),p(m,Z,W),o(Z,re),o(Z,_),o(_,G),o(Z,me),o(Z,P),o(P,C),o(Z,he),o(Z,V),o(V,ne),o(Z,ie),p(m,pe,W),k(H,m,W),je=!0},p(m,W){const K={};W&2&&(K.$$scope={dirty:W,ctx:m}),i.$set(K)},i(m){je||(U(i.$$.fragment,m),U(T.$$.fragment,m),U(Q.$$.fragment,m),U(q.$$.fragment,m),U(H.$$.fragment,m),je=!0)},o(m){J(i.$$.fragment,m),J(T.$$.fragment,m),J(Q.$$.fragment,m),J(q.$$.fragment,m),J(H.$$.fragment,m),je=!1},d(m){j(i,m),m&&t(b),m&&t(s),m&&t(F),j(T,m),m&&t(A),m&&t(v),m&&t(R),j(Q,m),m&&t(oe),m&&t(B),m&&t(L),j(q,m),m&&t(O),m&&t(Z),m&&t(pe),j(H,m)}}}function tn(X){let i,b;return i=new ia({props:{$$slots:{default:[en]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){x(i.$$.fragment,s)},m(s,g){k(i,s,g),b=!0},p(s,g){const y={};g&2&&(y.$$scope={dirty:g,ctx:s}),i.$set(y)},i(s){b||(U(i.$$.fragment,s),b=!0)},o(s){J(i.$$.fragment,s),b=!1},d(s){j(i,s)}}}function on(X){let i,b,s,g,y,w,$,I,F,T,A;return T=new D({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"),b=a("Currently there is no "),s=r("code"),g=a("load_textual_inversion"),y=a(` function for Flax so one has to make sure the textual inversion
embedding vector is saved as part of the model after training.`),w=h(),$=r("p"),I=a("The model can then be run just like any other Flax model:"),F=h(),E(T.$$.fragment)},l(v){i=n(v,"P",{});var M=f(i);b=l(M,"Currently there is no "),s=n(M,"CODE",{});var N=f(s);g=l(N,"load_textual_inversion"),N.forEach(t),y=l(M,` function for Flax so one has to make sure the textual inversion
embedding vector is saved as part of the model after training.`),M.forEach(t),w=d(v),$=n(v,"P",{});var z=f($);I=l(z,"The model can then be run just like any other Flax model:"),z.forEach(t),F=d(v),x(T.$$.fragment,v)},m(v,M){p(v,i,M),o(i,b),o(i,s),o(s,g),o(i,y),p(v,w,M),p(v,$,M),o($,I),p(v,F,M),k(T,v,M),A=!0},p:Il,i(v){A||(U(T.$$.fragment,v),A=!0)},o(v){J(T.$$.fragment,v),A=!1},d(v){v&&t(i),v&&t(w),v&&t($),v&&t(F),j(T,v)}}}function an(X){let i,b;return i=new ia({props:{$$slots:{default:[on]},$$scope:{ctx:X}}}),{c(){E(i.$$.fragment)},l(s){x(i.$$.fragment,s)},m(s,g){k(i,s,g),b=!0},p(s,g){const y={};g&2&&(y.$$scope={dirty:g,ctx:s}),i.$set(y)},i(s){b||(U(i.$$.fragment,s),b=!0)},o(s){J(i.$$.fragment,s),b=!1},d(s){j(i,s)}}}function ln(X){let i,b,s,g,y,w,$,I,F,T,A,v,M,N,z,fe,R,Q,oe,B,ae,S,le,Y,L,q,O,Z,re,_,G,me,P,C,he,V,ne,ie,pe,H,je,m,W,K,De,ce,ht,$e,de,te,ue,dt,ye,sa,fa,mo,ze,ho,yt,pa,yo,Qe,vo,vt,ca,go,Le,bo,ve,ua,Pe,ma,ha,At,da,ya,wo,Me,Ie,Nt,He,va,Xt,ga,_o,gt,ba,$o,qe,Mo,Te,We,Gt,Oe,wa,Ft,_a,To,Ze,$a,Ct,Ma,Ta,Eo,Ke,xo,bt,Ea,ko,et,Uo,Ee,Ae,Rt,tt,xa,Bt,ka,Jo,ge,Ua,ot,Ja,ja,wt,Ia,Wa,jo,at,Io,se,Za,St,Aa,Na,lt,Yt,Xa,Ga,Vt,Fa,Ca,Wo,ee,Ra,rt,Ba,Sa,Dt,Ya,Va,zt,Da,za,Qt,Qa,La,Zo,Ne,Ao,Xe,No,xe,Ge,Lt,nt,Pa,Pt,Ha,Xo,_t,qa,Go,be,Fe,Ht,Oa,Ka,qt,el,tl,ol,$t,Ot,al,ll,rl,ke,Kt,nl,il,eo,sl,fl,to,pl,Fo,it,Co,Ue,Ce,oo,st,cl,ao,ul,Ro,Re,ml,Mt,hl,dl,Bo,Tt,yl,So,Be,Yo,Je,Se,lo,ft,vl,ro,gl,Vo,Et,xt,Wl,Do,pt,bl,kt,wl,zo,we,_l,no,$l,Ml,io,Tl,El,Qo,Ye,xl,so,kl,Ul,Lo;return w=new mt({}),A=new Dr({props:{classNames:"absolute z-10 right-0 top-0",options:[{label:"Mixed",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/text_inversion.ipynb"},{label:"PyTorch",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/text_inversion.ipynb"},{label:"TensorFlow",value:"https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/text_inversion.ipynb"},{label:"Mixed",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/text_inversion.ipynb"},{label:"PyTorch",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/pytorch/text_inversion.ipynb"},{label:"TensorFlow",value:"https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/diffusers_doc/en/tensorflow/text_inversion.ipynb"}]}}),K=new na({props:{$$slots:{default:[zr]},$$scope:{ctx:X}}}),de=new D({props:{code:"cGlwJTIwaW5zdGFsbCUyMGRpZmZ1c2VycyUyMGFjY2VsZXJhdGUlMjB0cmFuc2Zvcm1lcnM=",highlighted:"pip install diffusers accelerate transformers"}}),ze=new D({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZw==",highlighted:"accelerate config"}}),Qe=new D({props:{code:"YWNjZWxlcmF0ZSUyMGNvbmZpZyUyMGRlZmF1bHQ=",highlighted:"accelerate config default"}}),Le=new D({props:{code:"ZnJvbSUyMGFjY2VsZXJhdGUudXRpbHMlMjBpbXBvcnQlMjB3cml0ZV9iYXNpY19jb25maWclMEElMEF3cml0ZV9iYXNpY19jb25maWcoKQ==",highlighted:`from accelerate.utils import write_basic_config

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