import{s as ae,n as ie,o as le}from"../chunks/scheduler.53228c21.js";import{S as oe,i as re,e as l,s as a,c as v,h as pe,a as o,d as s,b as i,f as ne,g as M,j as I,k as Q,l as me,m as n,n as Z,t as B,o as W,p as x}from"../chunks/index.100fac89.js";import{C as de}from"../chunks/CopyLLMTxtMenu.494046bd.js";import{C as N}from"../chunks/CodeBlock.d30a6509.js";import{H as ue,E as ce}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.8999c127.js";function Je(P){let r,_,$,U,d,X,u,G,c,D='<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.',V,J,K='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>.',R,f,H,T,A='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.',S,w,Y,p,O='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/load_txt_embed.png"/>',k,y,ee="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.",q,g,te="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.",L,h,E,m,se='<img src="https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/load_neg_embed.png"/>',C,b,F,j,z;return d=new de({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),u=new ue({props:{title:"Textual Inversion",local:"textual-inversion",headingTag:"h1"}}),f=new N({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}}),w=new N({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}}),h=new N({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}}),b=new ce({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/using-diffusers/textual_inversion_inference.md"}}),{c(){r=l("meta"),_=a(),$=l("p"),U=a(),v(d.$$.fragment),X=a(),v(u.$$.fragment),G=a(),c=l("p"),c.innerHTML=D,V=a(),J=l("p"),J.innerHTML=K,R=a(),v(f.$$.fragment),H=a(),T=l("p"),T.innerHTML=A,S=a(),v(w.$$.fragment),Y=a(),p=l("div"),p.innerHTML=O,k=a(),y=l("p"),y.innerHTML=ee,q=a(),g=l("p"),g.innerHTML=te,L=a(),v(h.$$.fragment),E=a(),m=l("div"),m.innerHTML=se,C=a(),v(b.$$.fragment),F=a(),j=l("p"),this.h()},l(e){const t=pe("svelte-u9bgzb",document.head);r=o(t,"META",{name:!0,content:!0}),t.forEach(s),_=i(e),$=o(e,"P",{}),ne($).forEach(s),U=i(e),M(d.$$.fragment,e),X=i(e),M(u.$$.fragment,e),G=i(e),c=o(e,"P",{"data-svelte-h":!0}),I(c)!=="svelte-1lyyk6k"&&(c.innerHTML=D),V=i(e),J=o(e,"P",{"data-svelte-h":!0}),I(J)!=="svelte-6wftzp"&&(J.innerHTML=K),R=i(e),M(f.$$.fragment,e),H=i(e),T=o(e,"P",{"data-svelte-h":!0}),I(T)!=="svelte-1ufp13t"&&(T.innerHTML=A),S=i(e),M(w.$$.fragment,e),Y=i(e),p=o(e,"DIV",{class:!0,"data-svelte-h":!0}),I(p)!=="svelte-vwb4li"&&(p.innerHTML=O),k=i(e),y=o(e,"P",{"data-svelte-h":!0}),I(y)!=="svelte-9fjq1k"&&(y.innerHTML=ee),q=i(e),g=o(e,"P",{"data-svelte-h":!0}),I(g)!=="svelte-19ybne4"&&(g.innerHTML=te),L=i(e),M(h.$$.fragment,e),E=i(e),m=o(e,"DIV",{class:!0,"data-svelte-h":!0}),I(m)!=="svelte-j6euo"&&(m.innerHTML=se),C=i(e),M(b.$$.fragment,e),F=i(e),j=o(e,"P",{}),ne(j).forEach(s),this.h()},h(){Q(r,"name","hf:doc:metadata"),Q(r,"content",fe),Q(p,"class","flex justify-center"),Q(m,"class","flex justify-center")},m(e,t){me(document.head,r),n(e,_,t),n(e,$,t),n(e,U,t),Z(d,e,t),n(e,X,t),Z(u,e,t),n(e,G,t),n(e,c,t),n(e,V,t),n(e,J,t),n(e,R,t),Z(f,e,t),n(e,H,t),n(e,T,t),n(e,S,t),Z(w,e,t),n(e,Y,t),n(e,p,t),n(e,k,t),n(e,y,t),n(e,q,t),n(e,g,t),n(e,L,t),Z(h,e,t),n(e,E,t),n(e,m,t),n(e,C,t),Z(b,e,t),n(e,F,t),n(e,j,t),z=!0},p:ie,i(e){z||(B(d.$$.fragment,e),B(u.$$.fragment,e),B(f.$$.fragment,e),B(w.$$.fragment,e),B(h.$$.fragment,e),B(b.$$.fragment,e),z=!0)},o(e){W(d.$$.fragment,e),W(u.$$.fragment,e),W(f.$$.fragment,e),W(w.$$.fragment,e),W(h.$$.fragment,e),W(b.$$.fragment,e),z=!1},d(e){e&&(s(_),s($),s(U),s(X),s(G),s(c),s(V),s(J),s(R),s(H),s(T),s(S),s(Y),s(p),s(k),s(y),s(q),s(g),s(L),s(E),s(m),s(C),s(F),s(j)),s(r),x(d,e),x(u,e),x(f,e),x(w,e),x(h,e),x(b,e)}}}const fe='{"title":"Textual Inversion","local":"textual-inversion","sections":[],"depth":1}';function Te(P){return le(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ie extends oe{constructor(r){super(),re(this,r,Te,Je,ae,{})}}export{Ie as component};
