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

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