import{S as yi,i as $i,s as ki,e as a,k as h,w as m,t as p,M as xi,c as i,d as t,m as f,a as r,x as d,h as u,b as s,N as oo,G as o,g as l,y as v,L as Ei,q as g,o as _,B as b,v as Ai}from"../../chunks/vendor-hf-doc-builder.js";import{I as $e}from"../../chunks/IconCopyLink-hf-doc-builder.js";import{C as at}from"../../chunks/CodeBlock-hf-doc-builder.js";function Pi(ka){let k,it,x,S,ze,V,ao,He,io,nt,ke,no,rt,j,xe,xa,ro,F,so,J,lo,po,st,c,uo,Q,ho,fo,X,co,mo,K,vo,go,lt,E,D,Re,Z,_o,Ge,bo,pt,N,Ee,Ea,wo,Ae,yo,ee,$o,ut,Pe,ko,ht,Ie,xo,ft,A,M,Be,te,Eo,Le,Ao,ct,O,Po,oe,Io,To,mt,ae,qo,ie,Te,Aa,dt,ne,So,re,qe,Pa,vt,C,jo,se,Do,No,gt,P,z,We,le,Mo,Ye,Oo,_t,w,Co,Ue,zo,Ho,pe,Ro,Go,bt,I,H,Ve,ue,Bo,Fe,Lo,wt,Se,Wo,yt,he,$t,R,Yo,fe,Uo,Vo,kt,ce,xt,T,G,Je,me,Fo,Qe,Jo,Et,y,Qo,Xe,Xo,Ko,de,Zo,ea,At,B,ta,ve,oa,aa,Pt,je,ia,It,ge,Tt,L,na,Ke,ra,sa,qt,St,jt,W,la,_e,pa,ua,Dt,De,ha,Nt,be,Mt,Ne,fa,Ot,q,Y,Ze,we,ca,et,ma,Ct,$,da,tt,va,ga,ot,_a,ba,zt,ye,Ht;return V=new $e({}),Z=new $e({}),te=new $e({}),le=new $e({}),ue=new $e({}),he=new at({props:{code:"pip install diffusers[training] accelerate transformers",highlighted:"pip install diffusers[training] accelerate transformers"}}),ce=new at({props:{code:"accelerate config",highlighted:"accelerate config"}}),me=new $e({}),ge=new at({props:{code:"huggingface-cli login",highlighted:"huggingface-cli login"}}),be=new at({props:{code:`export MODEL_NAME="CompVis/stable-diffusion-v1-4"
export DATA_DIR="path-to-dir-containing-images"

accelerate launch textual_inversion.py \\
  --pretrained_model_name_or_path=$MODEL_NAME --use_auth_token \\
  --train_data_dir=$DATA_DIR \\
  --learnable_property="object" \\
  --placeholder_token="<cat-toy>" --initializer_token="toy" \\
  --resolution=512 \\
  --train_batch_size=1 \\
  --gradient_accumulation_steps=4 \\
  --max_train_steps=3000 \\
  --learning_rate=5.0e-04 --scale_lr \\
  --lr_scheduler="constant" \\
  --lr_warmup_steps=0 \\
  --output_dir="textual_inversion_cat"`,highlighted:`<span class="hljs-built_in">export</span> MODEL_NAME=<span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-built_in">export</span> DATA_DIR=<span class="hljs-string">&quot;path-to-dir-containing-images&quot;</span>

accelerate launch textual_inversion.py \\
  --pretrained_model_name_or_path=<span class="hljs-variable">$MODEL_NAME</span> --use_auth_token \\
  --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>`}}),we=new $e({}),ye=new at({props:{code:`from torch import autocast
from diffusers import StableDiffusionPipeline

model_id = "path-to-your-trained-model"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")

prompt = "A <cat-toy> backpack"

with autocast("cuda"):
    image = pipe(prompt, num_inference_steps=50, guidance_scale=7.5).images[0]

image.save("cat-backpack.png")`,highlighted:`<span class="hljs-keyword">from</span> torch <span class="hljs-keyword">import</span> autocast
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline

model_id = <span class="hljs-string">&quot;path-to-your-trained-model&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;A &lt;cat-toy&gt; backpack&quot;</span>

<span class="hljs-keyword">with</span> autocast(<span class="hljs-string">&quot;cuda&quot;</span>):
    image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>, guidance_scale=<span class="hljs-number">7.5</span>).images[<span class="hljs-number">0</span>]

image.save(<span class="hljs-string">&quot;cat-backpack.png&quot;</span>)`}}),{c(){k=a("meta"),it=h(),x=a("h1"),S=a("a"),ze=a("span"),m(V.$$.fragment),ao=h(),He=a("span"),io=p("Textual Inversion"),nt=h(),ke=a("p"),no=p("Textual Inversion is a technique for capturing novel concepts from a small number of example images in a way that can later be used to control text-to-image pipelines. It does so by learning new \u2018words\u2019 in the embedding space of the pipeline\u2019s text encoder. These special words can then be used within text prompts to achieve very fine-grained control of the resulting images."),rt=h(),j=a("p"),xe=a("img"),ro=h(),F=a("em"),so=p("By using just 3-5 images you can teach new concepts to a model such as Stable Diffusion for personalized image generation ("),J=a("a"),lo=p("image source"),po=p(")."),st=h(),c=a("p"),uo=p("This technique was introduced in "),Q=a("a"),ho=p("An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion"),fo=p(". The paper demonstrated the concept using a "),X=a("a"),co=p("latent diffusion model"),mo=p(" but the idea has since been applied to other variants such as "),K=a("a"),vo=p("Stable Diffusion"),go=p("."),lt=h(),E=a("h2"),D=a("a"),Re=a("span"),m(Z.$$.fragment),_o=h(),Ge=a("span"),bo=p("How It Works"),pt=h(),N=a("p"),Ee=a("img"),wo=h(),Ae=a("em"),yo=p("Architecture Overview from the "),ee=a("a"),$o=p("textual inversion blog post"),ut=h(),Pe=a("p"),ko=p("Before a text prompt can be used in a diffusion model, it must first be processed into a numerical representation. This typically involves tokenizing the text, converting each token to an embedding and then feeding those embeddings through a model (typically a transformer) whose output will be used as the conditioning for the diffusion model."),ht=h(),Ie=a("p"),xo=p("Textual inversion learns a new token embedding (v* in the diagram above). A prompt (that includes a token which will be mapped to this new embedding) is used in conjunction with a noised version of one or more training images as inputs to the generator model, which attempts to predict the denoised version of the image. The embedding is optimized based on how well the model does at this task - an embedding that better captures the object or style shown by the training images will give more useful information to the diffusion model and thus result in a lower denoising loss. After many steps (typically several thousand) with a variety of prompt and image variants the learned embedding should hopefully capture the essence of the new concept being taught."),ft=h(),A=a("h2"),M=a("a"),Be=a("span"),m(te.$$.fragment),Eo=h(),Le=a("span"),Ao=p("Usage"),ct=h(),O=a("p"),Po=p("To train your own textual inversions, see the "),oe=a("a"),Io=p("example script here"),To=p("."),mt=h(),ae=a("p"),qo=p(`There is also a notebook for training:
`),ie=a("a"),Te=a("img"),dt=h(),ne=a("p"),So=p(`And one for inference:
`),re=a("a"),qe=a("img"),vt=h(),C=a("p"),jo=p("In addition to using concepts you have trained yourself, there is a community-created collection of trained textual inversions in the new "),se=a("a"),Do=p("Stable Diffusion public concepts library"),No=p(" which you can also use from the inference notebook above. Over time this will hopefully grow into a useful resource as more examples are added."),gt=h(),P=a("h2"),z=a("a"),We=a("span"),m(le.$$.fragment),Mo=h(),Ye=a("span"),Oo=p("Example: Running locally"),_t=h(),w=a("p"),Co=p("The "),Ue=a("code"),zo=p("textual_inversion.py"),Ho=p(" script "),pe=a("a"),Ro=p("here"),Go=p(" shows how to implement the training procedure and adapt it for stable diffusion."),bt=h(),I=a("h3"),H=a("a"),Ve=a("span"),m(ue.$$.fragment),Bo=h(),Fe=a("span"),Lo=p("Installing the dependencies"),wt=h(),Se=a("p"),Wo=p("Before running the scripts, make sure to install the library\u2019s training dependencies:"),yt=h(),m(he.$$.fragment),$t=h(),R=a("p"),Yo=p("And initialize an "),fe=a("a"),Uo=p("\u{1F917}Accelerate"),Vo=p(" environment with:"),kt=h(),m(ce.$$.fragment),xt=h(),T=a("h3"),G=a("a"),Je=a("span"),m(me.$$.fragment),Fo=h(),Qe=a("span"),Jo=p("Cat toy example"),Et=h(),y=a("p"),Qo=p("You need to accept the model license before downloading or using the weights. In this example we\u2019ll use model version "),Xe=a("code"),Xo=p("v1-4"),Ko=p(", so you\u2019ll need to visit "),de=a("a"),Zo=p("its card"),ea=p(", read the license and tick the checkbox if you agree."),At=h(),B=a("p"),ta=p("You have to be a registered user in \u{1F917} Hugging Face Hub, and you\u2019ll also need to use an access token for the code to work. For more information on access tokens, please refer to "),ve=a("a"),oa=p("this section of the documentation"),aa=p("."),Pt=h(),je=a("p"),ia=p("Run the following command to authenticate your token"),It=h(),m(ge.$$.fragment),Tt=h(),L=a("p"),na=p("If you have already cloned the repo, then you won\u2019t need to go through these steps. You can simple remove the "),Ke=a("code"),ra=p("--use_auth_token"),sa=p(" arg from the following command."),qt=h(),St=a("br"),jt=h(),W=a("p"),la=p("Now let\u2019s get our dataset.Download 3-4 images from "),_e=a("a"),pa=p("here"),ua=p(" and save them in a directory. This will be our training data."),Dt=h(),De=a("p"),ha=p("And launch the training using"),Nt=h(),m(be.$$.fragment),Mt=h(),Ne=a("p"),fa=p("A full training run takes ~1 hour on one V100 GPU."),Ot=h(),q=a("h3"),Y=a("a"),Ze=a("span"),m(we.$$.fragment),ca=h(),et=a("span"),ma=p("Inference"),Ct=h(),$=a("p"),da=p("Once you have trained a model using above command, the inference can be done simply using the "),tt=a("code"),va=p("StableDiffusionPipeline"),ga=p(". Make sure to include the "),ot=a("code"),_a=p("placeholder_token"),ba=p(" in your prompt."),zt=h(),m(ye.$$.fragment),this.h()},l(e){const n=xi('[data-svelte="svelte-1phssyn"]',document.head);k=i(n,"META",{name:!0,content:!0}),n.forEach(t),it=f(e),x=i(e,"H1",{class:!0});var Rt=r(x);S=i(Rt,"A",{id:!0,class:!0,href:!0});var Ia=r(S);ze=i(Ia,"SPAN",{});var Ta=r(ze);d(V.$$.fragment,Ta),Ta.forEach(t),Ia.forEach(t),ao=f(Rt),He=i(Rt,"SPAN",{});var qa=r(He);io=u(qa,"Textual Inversion"),qa.forEach(t),Rt.forEach(t),nt=f(e),ke=i(e,"P",{});var Sa=r(ke);no=u(Sa,"Textual Inversion is a technique for capturing novel concepts from a small number of example images in a way that can later be used to control text-to-image pipelines. It does so by learning new \u2018words\u2019 in the embedding space of the pipeline\u2019s text encoder. These special words can then be used within text prompts to achieve very fine-grained control of the resulting images."),Sa.forEach(t),rt=f(e),j=i(e,"P",{});var Gt=r(j);xe=i(Gt,"IMG",{src:!0,alt:!0}),ro=f(Gt),F=i(Gt,"EM",{});var Bt=r(F);so=u(Bt,"By using just 3-5 images you can teach new concepts to a model such as Stable Diffusion for personalized image generation ("),J=i(Bt,"A",{href:!0,rel:!0});var ja=r(J);lo=u(ja,"image source"),ja.forEach(t),po=u(Bt,")."),Bt.forEach(t),Gt.forEach(t),st=f(e),c=i(e,"P",{});var U=r(c);uo=u(U,"This technique was introduced in "),Q=i(U,"A",{href:!0,rel:!0});var Da=r(Q);ho=u(Da,"An Image is Worth One Word: Personalizing Text-to-Image Generation using Textual Inversion"),Da.forEach(t),fo=u(U,". The paper demonstrated the concept using a "),X=i(U,"A",{href:!0,rel:!0});var Na=r(X);co=u(Na,"latent diffusion model"),Na.forEach(t),mo=u(U," but the idea has since been applied to other variants such as "),K=i(U,"A",{href:!0,rel:!0});var Ma=r(K);vo=u(Ma,"Stable Diffusion"),Ma.forEach(t),go=u(U,"."),U.forEach(t),lt=f(e),E=i(e,"H2",{class:!0});var Lt=r(E);D=i(Lt,"A",{id:!0,class:!0,href:!0});var Oa=r(D);Re=i(Oa,"SPAN",{});var Ca=r(Re);d(Z.$$.fragment,Ca),Ca.forEach(t),Oa.forEach(t),_o=f(Lt),Ge=i(Lt,"SPAN",{});var za=r(Ge);bo=u(za,"How It Works"),za.forEach(t),Lt.forEach(t),pt=f(e),N=i(e,"P",{});var Wt=r(N);Ee=i(Wt,"IMG",{src:!0,alt:!0}),wo=f(Wt),Ae=i(Wt,"EM",{});var wa=r(Ae);yo=u(wa,"Architecture Overview from the "),ee=i(wa,"A",{href:!0,rel:!0});var Ha=r(ee);$o=u(Ha,"textual inversion blog post"),Ha.forEach(t),wa.forEach(t),Wt.forEach(t),ut=f(e),Pe=i(e,"P",{});var Ra=r(Pe);ko=u(Ra,"Before a text prompt can be used in a diffusion model, it must first be processed into a numerical representation. This typically involves tokenizing the text, converting each token to an embedding and then feeding those embeddings through a model (typically a transformer) whose output will be used as the conditioning for the diffusion model."),Ra.forEach(t),ht=f(e),Ie=i(e,"P",{});var Ga=r(Ie);xo=u(Ga,"Textual inversion learns a new token embedding (v* in the diagram above). A prompt (that includes a token which will be mapped to this new embedding) is used in conjunction with a noised version of one or more training images as inputs to the generator model, which attempts to predict the denoised version of the image. The embedding is optimized based on how well the model does at this task - an embedding that better captures the object or style shown by the training images will give more useful information to the diffusion model and thus result in a lower denoising loss. After many steps (typically several thousand) with a variety of prompt and image variants the learned embedding should hopefully capture the essence of the new concept being taught."),Ga.forEach(t),ft=f(e),A=i(e,"H2",{class:!0});var Yt=r(A);M=i(Yt,"A",{id:!0,class:!0,href:!0});var Ba=r(M);Be=i(Ba,"SPAN",{});var La=r(Be);d(te.$$.fragment,La),La.forEach(t),Ba.forEach(t),Eo=f(Yt),Le=i(Yt,"SPAN",{});var Wa=r(Le);Ao=u(Wa,"Usage"),Wa.forEach(t),Yt.forEach(t),ct=f(e),O=i(e,"P",{});var Ut=r(O);Po=u(Ut,"To train your own textual inversions, see the "),oe=i(Ut,"A",{href:!0,rel:!0});var Ya=r(oe);Io=u(Ya,"example script here"),Ya.forEach(t),To=u(Ut,"."),Ut.forEach(t),mt=f(e),ae=i(e,"P",{});var ya=r(ae);qo=u(ya,`There is also a notebook for training:
`),ie=i(ya,"A",{href:!0,rel:!0});var Ua=r(ie);Te=i(Ua,"IMG",{src:!0,alt:!0}),Ua.forEach(t),ya.forEach(t),dt=f(e),ne=i(e,"P",{});var $a=r(ne);So=u($a,`And one for inference:
`),re=i($a,"A",{href:!0,rel:!0});var Va=r(re);qe=i(Va,"IMG",{src:!0,alt:!0}),Va.forEach(t),$a.forEach(t),vt=f(e),C=i(e,"P",{});var Vt=r(C);jo=u(Vt,"In addition to using concepts you have trained yourself, there is a community-created collection of trained textual inversions in the new "),se=i(Vt,"A",{href:!0,rel:!0});var Fa=r(se);Do=u(Fa,"Stable Diffusion public concepts library"),Fa.forEach(t),No=u(Vt," which you can also use from the inference notebook above. Over time this will hopefully grow into a useful resource as more examples are added."),Vt.forEach(t),gt=f(e),P=i(e,"H2",{class:!0});var Ft=r(P);z=i(Ft,"A",{id:!0,class:!0,href:!0});var Ja=r(z);We=i(Ja,"SPAN",{});var Qa=r(We);d(le.$$.fragment,Qa),Qa.forEach(t),Ja.forEach(t),Mo=f(Ft),Ye=i(Ft,"SPAN",{});var Xa=r(Ye);Oo=u(Xa,"Example: Running locally"),Xa.forEach(t),Ft.forEach(t),_t=f(e),w=i(e,"P",{});var Me=r(w);Co=u(Me,"The "),Ue=i(Me,"CODE",{});var Ka=r(Ue);zo=u(Ka,"textual_inversion.py"),Ka.forEach(t),Ho=u(Me," script "),pe=i(Me,"A",{href:!0,rel:!0});var Za=r(pe);Ro=u(Za,"here"),Za.forEach(t),Go=u(Me," shows how to implement the training procedure and adapt it for stable diffusion."),Me.forEach(t),bt=f(e),I=i(e,"H3",{class:!0});var Jt=r(I);H=i(Jt,"A",{id:!0,class:!0,href:!0});var ei=r(H);Ve=i(ei,"SPAN",{});var ti=r(Ve);d(ue.$$.fragment,ti),ti.forEach(t),ei.forEach(t),Bo=f(Jt),Fe=i(Jt,"SPAN",{});var oi=r(Fe);Lo=u(oi,"Installing the dependencies"),oi.forEach(t),Jt.forEach(t),wt=f(e),Se=i(e,"P",{});var ai=r(Se);Wo=u(ai,"Before running the scripts, make sure to install the library\u2019s training dependencies:"),ai.forEach(t),yt=f(e),d(he.$$.fragment,e),$t=f(e),R=i(e,"P",{});var Qt=r(R);Yo=u(Qt,"And initialize an "),fe=i(Qt,"A",{href:!0,rel:!0});var ii=r(fe);Uo=u(ii,"\u{1F917}Accelerate"),ii.forEach(t),Vo=u(Qt," environment with:"),Qt.forEach(t),kt=f(e),d(ce.$$.fragment,e),xt=f(e),T=i(e,"H3",{class:!0});var Xt=r(T);G=i(Xt,"A",{id:!0,class:!0,href:!0});var ni=r(G);Je=i(ni,"SPAN",{});var ri=r(Je);d(me.$$.fragment,ri),ri.forEach(t),ni.forEach(t),Fo=f(Xt),Qe=i(Xt,"SPAN",{});var si=r(Qe);Jo=u(si,"Cat toy example"),si.forEach(t),Xt.forEach(t),Et=f(e),y=i(e,"P",{});var Oe=r(y);Qo=u(Oe,"You need to accept the model license before downloading or using the weights. In this example we\u2019ll use model version "),Xe=i(Oe,"CODE",{});var li=r(Xe);Xo=u(li,"v1-4"),li.forEach(t),Ko=u(Oe,", so you\u2019ll need to visit "),de=i(Oe,"A",{href:!0,rel:!0});var pi=r(de);Zo=u(pi,"its card"),pi.forEach(t),ea=u(Oe,", read the license and tick the checkbox if you agree."),Oe.forEach(t),At=f(e),B=i(e,"P",{});var Kt=r(B);ta=u(Kt,"You have to be a registered user in \u{1F917} Hugging Face Hub, and you\u2019ll also need to use an access token for the code to work. For more information on access tokens, please refer to "),ve=i(Kt,"A",{href:!0,rel:!0});var ui=r(ve);oa=u(ui,"this section of the documentation"),ui.forEach(t),aa=u(Kt,"."),Kt.forEach(t),Pt=f(e),je=i(e,"P",{});var hi=r(je);ia=u(hi,"Run the following command to authenticate your token"),hi.forEach(t),It=f(e),d(ge.$$.fragment,e),Tt=f(e),L=i(e,"P",{});var Zt=r(L);na=u(Zt,"If you have already cloned the repo, then you won\u2019t need to go through these steps. You can simple remove the "),Ke=i(Zt,"CODE",{});var fi=r(Ke);ra=u(fi,"--use_auth_token"),fi.forEach(t),sa=u(Zt," arg from the following command."),Zt.forEach(t),qt=f(e),St=i(e,"BR",{}),jt=f(e),W=i(e,"P",{});var eo=r(W);la=u(eo,"Now let\u2019s get our dataset.Download 3-4 images from "),_e=i(eo,"A",{href:!0,rel:!0});var ci=r(_e);pa=u(ci,"here"),ci.forEach(t),ua=u(eo," and save them in a directory. This will be our training data."),eo.forEach(t),Dt=f(e),De=i(e,"P",{});var mi=r(De);ha=u(mi,"And launch the training using"),mi.forEach(t),Nt=f(e),d(be.$$.fragment,e),Mt=f(e),Ne=i(e,"P",{});var di=r(Ne);fa=u(di,"A full training run takes ~1 hour on one V100 GPU."),di.forEach(t),Ot=f(e),q=i(e,"H3",{class:!0});var to=r(q);Y=i(to,"A",{id:!0,class:!0,href:!0});var vi=r(Y);Ze=i(vi,"SPAN",{});var gi=r(Ze);d(we.$$.fragment,gi),gi.forEach(t),vi.forEach(t),ca=f(to),et=i(to,"SPAN",{});var _i=r(et);ma=u(_i,"Inference"),_i.forEach(t),to.forEach(t),Ct=f(e),$=i(e,"P",{});var Ce=r($);da=u(Ce,"Once you have trained a model using above command, the inference can be done simply using the "),tt=i(Ce,"CODE",{});var bi=r(tt);va=u(bi,"StableDiffusionPipeline"),bi.forEach(t),ga=u(Ce,". Make sure to include the "),ot=i(Ce,"CODE",{});var wi=r(ot);_a=u(wi,"placeholder_token"),wi.forEach(t),ba=u(Ce," in your prompt."),Ce.forEach(t),zt=f(e),d(ye.$$.fragment,e),this.h()},h(){s(k,"name","hf:doc:metadata"),s(k,"content",JSON.stringify(Ii)),s(S,"id","textual-inversion"),s(S,"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"),s(S,"href","#textual-inversion"),s(x,"class","relative group"),oo(xe.src,xa="https://textual-inversion.github.io/static/images/editing/colorful_teapot.JPG")||s(xe,"src",xa),s(xe,"alt","Textual Inversion example"),s(J,"href","https://github.com/rinongal/textual_inversion"),s(J,"rel","nofollow"),s(Q,"href","https://arxiv.org/abs/2208.01618"),s(Q,"rel","nofollow"),s(X,"href","https://github.com/CompVis/latent-diffusion"),s(X,"rel","nofollow"),s(K,"href","https://huggingface.co/docs/diffusers/main/en/conceptual/stable_diffusion"),s(K,"rel","nofollow"),s(D,"id","how-it-works"),s(D,"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"),s(D,"href","#how-it-works"),s(E,"class","relative group"),oo(Ee.src,Ea="https://textual-inversion.github.io/static/images/training/training.JPG")||s(Ee,"src",Ea),s(Ee,"alt","Diagram from the paper showing overview"),s(ee,"href","https://textual-inversion.github.io/"),s(ee,"rel","nofollow"),s(M,"id","usage"),s(M,"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"),s(M,"href","#usage"),s(A,"class","relative group"),s(oe,"href","https://github.com/huggingface/diffusers/tree/main/examples/textual_inversion"),s(oe,"rel","nofollow"),oo(Te.src,Aa="https://colab.research.google.com/assets/colab-badge.svg")||s(Te,"src",Aa),s(Te,"alt","Open In Colab"),s(ie,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/sd_textual_inversion_training.ipynb"),s(ie,"rel","nofollow"),oo(qe.src,Pa="https://colab.research.google.com/assets/colab-badge.svg")||s(qe,"src",Pa),s(qe,"alt","Open In Colab"),s(re,"href","https://colab.research.google.com/github/huggingface/notebooks/blob/main/diffusers/stable_conceptualizer_inference.ipynb"),s(re,"rel","nofollow"),s(se,"href","https://huggingface.co/sd-concepts-library"),s(se,"rel","nofollow"),s(z,"id","example-running-locally"),s(z,"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"),s(z,"href","#example-running-locally"),s(P,"class","relative group"),s(pe,"href","https://github.com/huggingface/diffusers/blob/main/examples/textual_inversion"),s(pe,"rel","nofollow"),s(H,"id","installing-the-dependencies"),s(H,"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"),s(H,"href","#installing-the-dependencies"),s(I,"class","relative group"),s(fe,"href","https://github.com/huggingface/accelerate/"),s(fe,"rel","nofollow"),s(G,"id","cat-toy-example"),s(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"),s(G,"href","#cat-toy-example"),s(T,"class","relative group"),s(de,"href","https://huggingface.co/CompVis/stable-diffusion-v1-4"),s(de,"rel","nofollow"),s(ve,"href","https://huggingface.co/docs/hub/security-tokens"),s(ve,"rel","nofollow"),s(_e,"href","https://drive.google.com/drive/folders/1fmJMs25nxS_rSNqS5hTcRdLem_YQXbq5"),s(_e,"rel","nofollow"),s(Y,"id","inference"),s(Y,"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"),s(Y,"href","#inference"),s(q,"class","relative group")},m(e,n){o(document.head,k),l(e,it,n),l(e,x,n),o(x,S),o(S,ze),v(V,ze,null),o(x,ao),o(x,He),o(He,io),l(e,nt,n),l(e,ke,n),o(ke,no),l(e,rt,n),l(e,j,n),o(j,xe),o(j,ro),o(j,F),o(F,so),o(F,J),o(J,lo),o(F,po),l(e,st,n),l(e,c,n),o(c,uo),o(c,Q),o(Q,ho),o(c,fo),o(c,X),o(X,co),o(c,mo),o(c,K),o(K,vo),o(c,go),l(e,lt,n),l(e,E,n),o(E,D),o(D,Re),v(Z,Re,null),o(E,_o),o(E,Ge),o(Ge,bo),l(e,pt,n),l(e,N,n),o(N,Ee),o(N,wo),o(N,Ae),o(Ae,yo),o(Ae,ee),o(ee,$o),l(e,ut,n),l(e,Pe,n),o(Pe,ko),l(e,ht,n),l(e,Ie,n),o(Ie,xo),l(e,ft,n),l(e,A,n),o(A,M),o(M,Be),v(te,Be,null),o(A,Eo),o(A,Le),o(Le,Ao),l(e,ct,n),l(e,O,n),o(O,Po),o(O,oe),o(oe,Io),o(O,To),l(e,mt,n),l(e,ae,n),o(ae,qo),o(ae,ie),o(ie,Te),l(e,dt,n),l(e,ne,n),o(ne,So),o(ne,re),o(re,qe),l(e,vt,n),l(e,C,n),o(C,jo),o(C,se),o(se,Do),o(C,No),l(e,gt,n),l(e,P,n),o(P,z),o(z,We),v(le,We,null),o(P,Mo),o(P,Ye),o(Ye,Oo),l(e,_t,n),l(e,w,n),o(w,Co),o(w,Ue),o(Ue,zo),o(w,Ho),o(w,pe),o(pe,Ro),o(w,Go),l(e,bt,n),l(e,I,n),o(I,H),o(H,Ve),v(ue,Ve,null),o(I,Bo),o(I,Fe),o(Fe,Lo),l(e,wt,n),l(e,Se,n),o(Se,Wo),l(e,yt,n),v(he,e,n),l(e,$t,n),l(e,R,n),o(R,Yo),o(R,fe),o(fe,Uo),o(R,Vo),l(e,kt,n),v(ce,e,n),l(e,xt,n),l(e,T,n),o(T,G),o(G,Je),v(me,Je,null),o(T,Fo),o(T,Qe),o(Qe,Jo),l(e,Et,n),l(e,y,n),o(y,Qo),o(y,Xe),o(Xe,Xo),o(y,Ko),o(y,de),o(de,Zo),o(y,ea),l(e,At,n),l(e,B,n),o(B,ta),o(B,ve),o(ve,oa),o(B,aa),l(e,Pt,n),l(e,je,n),o(je,ia),l(e,It,n),v(ge,e,n),l(e,Tt,n),l(e,L,n),o(L,na),o(L,Ke),o(Ke,ra),o(L,sa),l(e,qt,n),l(e,St,n),l(e,jt,n),l(e,W,n),o(W,la),o(W,_e),o(_e,pa),o(W,ua),l(e,Dt,n),l(e,De,n),o(De,ha),l(e,Nt,n),v(be,e,n),l(e,Mt,n),l(e,Ne,n),o(Ne,fa),l(e,Ot,n),l(e,q,n),o(q,Y),o(Y,Ze),v(we,Ze,null),o(q,ca),o(q,et),o(et,ma),l(e,Ct,n),l(e,$,n),o($,da),o($,tt),o(tt,va),o($,ga),o($,ot),o(ot,_a),o($,ba),l(e,zt,n),v(ye,e,n),Ht=!0},p:Ei,i(e){Ht||(g(V.$$.fragment,e),g(Z.$$.fragment,e),g(te.$$.fragment,e),g(le.$$.fragment,e),g(ue.$$.fragment,e),g(he.$$.fragment,e),g(ce.$$.fragment,e),g(me.$$.fragment,e),g(ge.$$.fragment,e),g(be.$$.fragment,e),g(we.$$.fragment,e),g(ye.$$.fragment,e),Ht=!0)},o(e){_(V.$$.fragment,e),_(Z.$$.fragment,e),_(te.$$.fragment,e),_(le.$$.fragment,e),_(ue.$$.fragment,e),_(he.$$.fragment,e),_(ce.$$.fragment,e),_(me.$$.fragment,e),_(ge.$$.fragment,e),_(be.$$.fragment,e),_(we.$$.fragment,e),_(ye.$$.fragment,e),Ht=!1},d(e){t(k),e&&t(it),e&&t(x),b(V),e&&t(nt),e&&t(ke),e&&t(rt),e&&t(j),e&&t(st),e&&t(c),e&&t(lt),e&&t(E),b(Z),e&&t(pt),e&&t(N),e&&t(ut),e&&t(Pe),e&&t(ht),e&&t(Ie),e&&t(ft),e&&t(A),b(te),e&&t(ct),e&&t(O),e&&t(mt),e&&t(ae),e&&t(dt),e&&t(ne),e&&t(vt),e&&t(C),e&&t(gt),e&&t(P),b(le),e&&t(_t),e&&t(w),e&&t(bt),e&&t(I),b(ue),e&&t(wt),e&&t(Se),e&&t(yt),b(he,e),e&&t($t),e&&t(R),e&&t(kt),b(ce,e),e&&t(xt),e&&t(T),b(me),e&&t(Et),e&&t(y),e&&t(At),e&&t(B),e&&t(Pt),e&&t(je),e&&t(It),b(ge,e),e&&t(Tt),e&&t(L),e&&t(qt),e&&t(St),e&&t(jt),e&&t(W),e&&t(Dt),e&&t(De),e&&t(Nt),b(be,e),e&&t(Mt),e&&t(Ne),e&&t(Ot),e&&t(q),b(we),e&&t(Ct),e&&t($),e&&t(zt),b(ye,e)}}}const Ii={local:"textual-inversion",sections:[{local:"how-it-works",title:"How It Works"},{local:"usage",title:"Usage"},{local:"example-running-locally",sections:[{local:"installing-the-dependencies",title:"Installing the dependencies"},{local:"cat-toy-example",title:"Cat toy example"},{local:"inference",title:"Inference"}],title:"Example: Running locally "}],title:"Textual Inversion"};function Ti(ka){return Ai(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Di extends yi{constructor(k){super();$i(this,k,Ti,Pi,ki,{})}}export{Di as default,Ii as metadata};
