import{s as se,n as ae,o as ne}from"../chunks/scheduler.8c3d61f6.js";import{S as ie,i as le,g as l,s as n,r as M,A as oe,h as o,f as s,c as i,j as te,u as Z,x as b,k as Q,y as re,a,v as B,d as W,t as j,w as x}from"../chunks/index.da70eac4.js";import{C as z}from"../chunks/CodeBlock.a9c4becf.js";import{H as pe,E as me}from"../chunks/getInferenceSnippets.4986d68f.js";function de(C){let r,_,I,U,d,$,c,N='<a href="https://huggingface.co/papers/2208.01618" rel="nofollow">Textual Inversion</a> is a method for generating personalized images of a concept. It works by fine-tuning a models word embeddings on 3-5 images of the concept (for example, pixel art) that is associated with a unique token (<code>&lt;sks&gt;</code>). This allows you to use the <code>&lt;sks&gt;</code> token in your prompt to trigger the model to generate pixel art images.',X,u,P='Textual Inversion weights are very lightweight and typically only a few KBs because they’re only word embeddings. However, this also means the word embeddings need to be loaded after loading a model with <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline.from_pretrained">from_pretrained()</a>.',G,J,V,f,D='Load the word embeddings with <a href="/docs/diffusers/main/en/api/loaders/textual_inversion#diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion">load_textual_inversion()</a> and include the unique token in the prompt to activate its generation.',R,T,H,p,A='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/load_txt_embed.png"/>',S,w,K="Textual Inversion can also be trained to learn <em>negative embeddings</em> to steer generation away from unwanted characteristics such as “blurry” or “ugly”. It is useful for improving image quality.",Y,y,O="EasyNegative is a widely used negative embedding that contains multiple learned negative concepts. Load the negative embeddings and specify the file name and token associated with the negative embeddings. Pass the token to <code>negative_prompt</code> in your pipeline to activate it.",k,g,q,m,ee='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/load_neg_embed.png"/>',E,h,L,v,F;return d=new pe({props:{title:"Textual Inversion",local:"textual-inversion",headingTag:"h1"}}),J=new z({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKQ==",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image

pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)`,wrap:!1}}),T=new z({props:{code:"cGlwZWxpbmUubG9hZF90ZXh0dWFsX2ludmVyc2lvbiglMjJzZC1jb25jZXB0cy1saWJyYXJ5JTJGZ3RhNS1hcnR3b3JrJTIyKSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjBjdXRlJTIwYnJvd24lMjBiZWFyJTIwZWF0aW5nJTIwYSUyMHNsaWNlJTIwb2YlMjBwaXp6YSUyQyUyMHN0dW5uaW5nJTIwY29sb3IlMjBzY2hlbWUlMkMlMjBtYXN0ZXJwaWVjZSUyQyUyMGlsbHVzdHJhdGlvbiUyQyUyMCUzQ2d0YTUtYXJ0d29yayUzRSUyMHN0eWxlJTIyJTBBcGlwZWxpbmUocHJvbXB0KS5pbWFnZXMlNUIwJTVE",highlighted:`pipeline.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/gta5-artwork&quot;</span>)
prompt = <span class="hljs-string">&quot;A cute brown bear eating a slice of pizza, stunning color scheme, masterpiece, illustration, &lt;gta5-artwork&gt; style&quot;</span>
pipeline(prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),g=new z({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZSUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTBBJTIwJTIwJTIwJTIwJTIyRXZpbEVuZ2luZSUyRmVhc3luZWdhdGl2ZSUyMiUyQyUwQSUyMCUyMCUyMCUyMHdlaWdodF9uYW1lJTNEJTIyZWFzeW5lZ2F0aXZlLnNhZmV0ZW5zb3JzJTIyJTJDJTBBJTIwJTIwJTIwJTIwdG9rZW4lM0QlMjJlYXN5bmVnYXRpdmUlMjIlMEEpJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMGN1dGUlMjBicm93biUyMGJlYXIlMjBlYXRpbmclMjBhJTIwc2xpY2UlMjBvZiUyMHBpenphJTJDJTIwc3R1bm5pbmclMjBjb2xvciUyMHNjaGVtZSUyQyUyMG1hc3RlcnBpZWNlJTJDJTIwaWxsdXN0cmF0aW9uJTIyJTBBbmVnYXRpdmVfcHJvbXB0JTIwJTNEJTIwJTIyZWFzeW5lZ2F0aXZlJTIyJTBBcGlwZWxpbmUocHJvbXB0JTJDJTIwbmVnYXRpdmVfcHJvbXB0KS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image

pipeline = AutoPipelineForText2Image.from_pretrained(
    <span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>,
    torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_textual_inversion(
    <span class="hljs-string">&quot;EvilEngine/easynegative&quot;</span>,
    weight_name=<span class="hljs-string">&quot;easynegative.safetensors&quot;</span>,
    token=<span class="hljs-string">&quot;easynegative&quot;</span>
)
prompt = <span class="hljs-string">&quot;A cute brown bear eating a slice of pizza, stunning color scheme, masterpiece, illustration&quot;</span>
negative_prompt = <span class="hljs-string">&quot;easynegative&quot;</span>
pipeline(prompt, negative_prompt).images[<span class="hljs-number">0</span>]`,wrap:!1}}),h=new me({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/textual_inversion_inference.md"}}),{c(){r=l("meta"),_=n(),I=l("p"),U=n(),M(d.$$.fragment),$=n(),c=l("p"),c.innerHTML=N,X=n(),u=l("p"),u.innerHTML=P,G=n(),M(J.$$.fragment),V=n(),f=l("p"),f.innerHTML=D,R=n(),M(T.$$.fragment),H=n(),p=l("div"),p.innerHTML=A,S=n(),w=l("p"),w.innerHTML=K,Y=n(),y=l("p"),y.innerHTML=O,k=n(),M(g.$$.fragment),q=n(),m=l("div"),m.innerHTML=ee,E=n(),M(h.$$.fragment),L=n(),v=l("p"),this.h()},l(e){const t=oe("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(s),_=i(e),I=o(e,"P",{}),te(I).forEach(s),U=i(e),Z(d.$$.fragment,e),$=i(e),c=o(e,"P",{"data-svelte-h":!0}),b(c)!=="svelte-1lyyk6k"&&(c.innerHTML=N),X=i(e),u=o(e,"P",{"data-svelte-h":!0}),b(u)!=="svelte-6wftzp"&&(u.innerHTML=P),G=i(e),Z(J.$$.fragment,e),V=i(e),f=o(e,"P",{"data-svelte-h":!0}),b(f)!=="svelte-1ufp13t"&&(f.innerHTML=D),R=i(e),Z(T.$$.fragment,e),H=i(e),p=o(e,"DIV",{class:!0,"data-svelte-h":!0}),b(p)!=="svelte-vwb4li"&&(p.innerHTML=A),S=i(e),w=o(e,"P",{"data-svelte-h":!0}),b(w)!=="svelte-9fjq1k"&&(w.innerHTML=K),Y=i(e),y=o(e,"P",{"data-svelte-h":!0}),b(y)!=="svelte-19ybne4"&&(y.innerHTML=O),k=i(e),Z(g.$$.fragment,e),q=i(e),m=o(e,"DIV",{class:!0,"data-svelte-h":!0}),b(m)!=="svelte-j6euo"&&(m.innerHTML=ee),E=i(e),Z(h.$$.fragment,e),L=i(e),v=o(e,"P",{}),te(v).forEach(s),this.h()},h(){Q(r,"name","hf:doc:metadata"),Q(r,"content",ce),Q(p,"class","flex justify-center"),Q(m,"class","flex justify-center")},m(e,t){re(document.head,r),a(e,_,t),a(e,I,t),a(e,U,t),B(d,e,t),a(e,$,t),a(e,c,t),a(e,X,t),a(e,u,t),a(e,G,t),B(J,e,t),a(e,V,t),a(e,f,t),a(e,R,t),B(T,e,t),a(e,H,t),a(e,p,t),a(e,S,t),a(e,w,t),a(e,Y,t),a(e,y,t),a(e,k,t),B(g,e,t),a(e,q,t),a(e,m,t),a(e,E,t),B(h,e,t),a(e,L,t),a(e,v,t),F=!0},p:ae,i(e){F||(W(d.$$.fragment,e),W(J.$$.fragment,e),W(T.$$.fragment,e),W(g.$$.fragment,e),W(h.$$.fragment,e),F=!0)},o(e){j(d.$$.fragment,e),j(J.$$.fragment,e),j(T.$$.fragment,e),j(g.$$.fragment,e),j(h.$$.fragment,e),F=!1},d(e){e&&(s(_),s(I),s(U),s($),s(c),s(X),s(u),s(G),s(V),s(f),s(R),s(H),s(p),s(S),s(w),s(Y),s(y),s(k),s(q),s(m),s(E),s(L),s(v)),s(r),x(d,e),x(J,e),x(T,e),x(g,e),x(h,e)}}}const ce='{"title":"Textual Inversion","local":"textual-inversion","sections":[],"depth":1}';function ue(C){return ne(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ye extends ie{constructor(r){super(),le(this,r,ue,de,se,{})}}export{ye as component};
