import{s as $e,o as Ge,n as ae}from"../chunks/scheduler.8c3d61f6.js";import{S as ke,i as We,g as u,s as i,r as x,A as Be,h as f,f as l,c as r,j as P,u as y,x as U,k as A,y as p,a as c,v as T,d as v,t as _,w as J}from"../chunks/index.da70eac4.js";import{T as Ve}from"../chunks/Tip.1d9b8c37.js";import{D as le}from"../chunks/Docstring.dcbc19b1.js";import{C as ye}from"../chunks/CodeBlock.a9c4becf.js";import{E as xe}from"../chunks/ExampleCodeBlock.da4c0768.js";import{H as Ie,E as Xe}from"../chunks/getInferenceSnippets.86beaec3.js";function Re(Z){let n,h='To learn more about how to load Textual Inversion embeddings, see the <a href="../../using-diffusers/loading_adapters#textual-inversion">Textual Inversion</a> loading guide.';return{c(){n=u("p"),n.innerHTML=h},l(a){n=f(a,"P",{"data-svelte-h":!0}),U(n)!=="svelte-1n8qarv"&&(n.innerHTML=h)},m(a,o){c(a,n,o)},p:ae,d(a){a&&l(n)}}}function Ce(Z){let n,h="To load a Textual Inversion embedding vector in 🤗 Diffusers format:",a,o,d;return o=new ye({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCUyMnNkLWNvbmNlcHRzLWxpYnJhcnklMkZjYXQtdG95JTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMkElMjAlM0NjYXQtdG95JTNFJTIwYmFja3BhY2slMjIlMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJjYXQtYmFja3BhY2sucG5nJTIyKQ==",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;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipe.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/cat-toy&quot;</span>)

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>)`,wrap:!1}}),{c(){n=u("p"),n.textContent=h,a=i(),x(o.$$.fragment)},l(t){n=f(t,"P",{"data-svelte-h":!0}),U(n)!=="svelte-1gc783q"&&(n.textContent=h),a=r(t),y(o.$$.fragment,t)},m(t,m){c(t,n,m),c(t,a,m),T(o,t,m),d=!0},p:ae,i(t){d||(v(o.$$.fragment,t),d=!0)},o(t){_(o.$$.fragment,t),d=!1},d(t){t&&(l(n),l(a)),J(o,t)}}}function ze(Z){let n,h="locally:",a,o,d;return o=new ye({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyRnN0YWJsZS1kaWZmdXNpb24tdjEtNSUyMiUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQobW9kZWxfaWQlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYpLnRvKCUyMmN1ZGElMjIpJTBBJTBBcGlwZS5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCUyMi4lMkZjaGFydHVybmVydjIucHQlMjIlMkMlMjB0b2tlbiUzRCUyMmNoYXJ0dXJuZXJ2MiUyMiklMEElMEFwcm9tcHQlMjAlM0QlMjAlMjJjaGFydHVybmVydjIlMkMlMjBtdWx0aXBsZSUyMHZpZXdzJTIwb2YlMjB0aGUlMjBzYW1lJTIwY2hhcmFjdGVyJTIwaW4lMjB0aGUlMjBzYW1lJTIwb3V0Zml0JTJDJTIwYSUyMGNoYXJhY3RlciUyMHR1cm5hcm91bmQlMjBvZiUyMGElMjB3b21hbiUyMHdlYXJpbmclMjBhJTIwYmxhY2slMjBqYWNrZXQlMjBhbmQlMjByZWQlMjBzaGlydCUyQyUyMGJlc3QlMjBxdWFsaXR5JTJDJTIwaW50cmljYXRlJTIwZGV0YWlscy4lMjIlMEElMEFpbWFnZSUyMCUzRCUyMHBpcGUocHJvbXB0JTJDJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDUwKS5pbWFnZXMlNUIwJTVEJTBBaW1hZ2Uuc2F2ZSglMjJjaGFyYWN0ZXIucG5nJTIyKQ==",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;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipe.load_textual_inversion(<span class="hljs-string">&quot;./charturnerv2.pt&quot;</span>, token=<span class="hljs-string">&quot;charturnerv2&quot;</span>)

prompt = <span class="hljs-string">&quot;charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details.&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;character.png&quot;</span>)`,wrap:!1}}),{c(){n=u("p"),n.textContent=h,a=i(),x(o.$$.fragment)},l(t){n=f(t,"P",{"data-svelte-h":!0}),U(n)!=="svelte-4c75kq"&&(n.textContent=h),a=r(t),y(o.$$.fragment,t)},m(t,m){c(t,n,m),c(t,a,m),T(o,t,m),d=!0},p:ae,i(t){d||(v(o.$$.fragment,t),d=!0)},o(t){_(o.$$.fragment,t),d=!1},d(t){t&&(l(n),l(a)),J(o,t)}}}function Fe(Z){let n,h="Example:",a,o,d;return o=new ye({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyKSUwQSUwQSUyMyUyMEV4YW1wbGUlMjAxJTBBcGlwZWxpbmUubG9hZF90ZXh0dWFsX2ludmVyc2lvbiglMjJzZC1jb25jZXB0cy1saWJyYXJ5JTJGZ3RhNS1hcnR3b3JrJTIyKSUwQXBpcGVsaW5lLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTIyc2QtY29uY2VwdHMtbGlicmFyeSUyRm1vZWItc3R5bGUlMjIpJTBBJTBBJTIzJTIwUmVtb3ZlJTIwYWxsJTIwdG9rZW4lMjBlbWJlZGRpbmdzJTBBcGlwZWxpbmUudW5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCklMEElMEElMjMlMjBFeGFtcGxlJTIwMiUwQXBpcGVsaW5lLmxvYWRfdGV4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JTBBKSUwQXBpcGVsaW5lLnVubG9hZF90ZXh0dWFsX2ludmVyc2lvbiglMEElMjAlMjAlMjAlMjB0b2tlbnMlM0QlNUIlMjIlM0NzMCUzRSUyMiUyQyUyMCUyMiUzQ3MxJTNFJTIyJTVEJTJDJTIwdGV4dF9lbmNvZGVyJTNEcGlwZWxpbmUudGV4dF9lbmNvZGVyXzIlMkMlMjB0b2tlbml6ZXIlM0RwaXBlbGluZS50b2tlbml6ZXJfMiUwQSk=",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> AutoPipelineForText2Image
<span class="hljs-keyword">import</span> torch

pipeline = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">&quot;stable-diffusion-v1-5/stable-diffusion-v1-5&quot;</span>)

<span class="hljs-comment"># Example 1</span>
pipeline.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/gta5-artwork&quot;</span>)
pipeline.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/moeb-style&quot;</span>)

<span class="hljs-comment"># Remove all token embeddings</span>
pipeline.unload_textual_inversion()

<span class="hljs-comment"># Example 2</span>
pipeline.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/moeb-style&quot;</span>)
pipeline.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/gta5-artwork&quot;</span>)

<span class="hljs-comment"># Remove just one token</span>
pipeline.unload_textual_inversion(<span class="hljs-string">&quot;&lt;moe-bius&gt;&quot;</span>)

<span class="hljs-comment"># Example 3: unload from SDXL</span>
pipeline = AutoPipelineForText2Image.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>)
embedding_path = hf_hub_download(
    repo_id=<span class="hljs-string">&quot;linoyts/web_y2k&quot;</span>, filename=<span class="hljs-string">&quot;web_y2k_emb.safetensors&quot;</span>, repo_type=<span class="hljs-string">&quot;model&quot;</span>
)

<span class="hljs-comment"># load embeddings to the text encoders</span>
state_dict = load_file(embedding_path)

<span class="hljs-comment"># load embeddings of text_encoder 1 (CLIP ViT-L/14)</span>
pipeline.load_textual_inversion(
    state_dict[<span class="hljs-string">&quot;clip_l&quot;</span>],
    tokens=[<span class="hljs-string">&quot;&lt;s0&gt;&quot;</span>, <span class="hljs-string">&quot;&lt;s1&gt;&quot;</span>],
    text_encoder=pipeline.text_encoder,
    tokenizer=pipeline.tokenizer,
)
<span class="hljs-comment"># load embeddings of text_encoder 2 (CLIP ViT-G/14)</span>
pipeline.load_textual_inversion(
    state_dict[<span class="hljs-string">&quot;clip_g&quot;</span>],
    tokens=[<span class="hljs-string">&quot;&lt;s0&gt;&quot;</span>, <span class="hljs-string">&quot;&lt;s1&gt;&quot;</span>],
    text_encoder=pipeline.text_encoder_2,
    tokenizer=pipeline.tokenizer_2,
)

<span class="hljs-comment"># Unload explicitly from both text encoders and tokenizers</span>
pipeline.unload_textual_inversion(
    tokens=[<span class="hljs-string">&quot;&lt;s0&gt;&quot;</span>, <span class="hljs-string">&quot;&lt;s1&gt;&quot;</span>], text_encoder=pipeline.text_encoder, tokenizer=pipeline.tokenizer
)
pipeline.unload_textual_inversion(
    tokens=[<span class="hljs-string">&quot;&lt;s0&gt;&quot;</span>, <span class="hljs-string">&quot;&lt;s1&gt;&quot;</span>], text_encoder=pipeline.text_encoder_2, tokenizer=pipeline.tokenizer_2
)`,wrap:!1}}),{c(){n=u("p"),n.textContent=h,a=i(),x(o.$$.fragment)},l(t){n=f(t,"P",{"data-svelte-h":!0}),U(n)!=="svelte-11lpom8"&&(n.textContent=h),a=r(t),y(o.$$.fragment,t)},m(t,m){c(t,n,m),c(t,a,m),T(o,t,m),d=!0},p:ae,i(t){d||(v(o.$$.fragment,t),d=!0)},o(t){_(o.$$.fragment,t),d=!1},d(t){t&&(l(n),l(a)),J(o,t)}}}function Ee(Z){let n,h,a,o,d,t,m,Te="Textual Inversion is a training method for personalizing models by learning new text embeddings from a few example images. The file produced from training is extremely small (a few KBs) and the new embeddings can be loaded into the text encoder.",K,V,ve="<code>TextualInversionLoaderMixin</code> provides a function for loading Textual Inversion embeddings from Diffusers and Automatic1111 into the text encoder and loading a special token to activate the embeddings.",O,$,ee,X,te,b,R,ie,S,_e="Load Textual Inversion tokens and embeddings to the tokenizer and text encoder.",re,M,C,de,Q,Je=`Load Textual Inversion embeddings into the text encoder of <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a> (both 🤗 Diffusers and
Automatic1111 formats are supported).`,pe,q,we="Example:",ce,G,me,N,Ue=`To load a Textual Inversion embedding vector in Automatic1111 format, make sure to download the vector first
(for example from <a href="https://civitai.com/models/3036?modelVersionId=9857" rel="nofollow">civitAI</a>) and then load the vector`,ue,k,fe,W,z,he,Y,Ze=`Processes prompts that include a special token corresponding to a multi-vector textual inversion embedding to
be replaced with multiple special tokens each corresponding to one of the vectors. If the prompt has no textual
inversion token or if the textual inversion token is a single vector, the input prompt is returned.`,Me,j,F,be,H,je='Unload Textual Inversion embeddings from the text encoder of <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a>',ge,B,ne,E,oe,D,se;return d=new Ie({props:{title:"Textual Inversion",local:"textual-inversion",headingTag:"h1"}}),$=new Ve({props:{$$slots:{default:[Re]},$$scope:{ctx:Z}}}),X=new Ie({props:{title:"TextualInversionLoaderMixin",local:"diffusers.loaders.TextualInversionLoaderMixin",headingTag:"h2"}}),R=new le({props:{name:"class diffusers.loaders.TextualInversionLoaderMixin",anchor:"diffusers.loaders.TextualInversionLoaderMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/textual_inversion.py#L110"}}),C=new le({props:{name:"load_textual_inversion",anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, typing.List[str], typing.Dict[str, torch.Tensor], typing.List[typing.Dict[str, torch.Tensor]]]"},{name:"token",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"tokenizer",val:": typing.Optional[ForwardRef('PreTrainedTokenizer')] = None"},{name:"text_encoder",val:": typing.Optional[ForwardRef('PreTrainedModel')] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code> or <code>List[str or os.PathLike]</code> or <code>Dict</code> or <code>List[Dict]</code>) &#x2014;
Can be either one of the following or a list of them:</p>
<ul>
<li>A string, the <em>model id</em> (for example <code>sd-concepts-library/low-poly-hd-logos-icons</code>) of a
pretrained model hosted on the Hub.</li>
<li>A path to a <em>directory</em> (for example <code>./my_text_inversion_directory/</code>) containing the textual
inversion weights.</li>
<li>A path to a <em>file</em> (for example <code>./my_text_inversions.pt</code>) containing textual inversion weights.</li>
<li>A <a href="https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict" rel="nofollow">torch state
dict</a>.</li>
</ul>`,name:"pretrained_model_name_or_path"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.token",description:`<strong>token</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
Override the token to use for the textual inversion weights. If <code>pretrained_model_name_or_path</code> is a
list, then <code>token</code> must also be a list of equal length.`,name:"token"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIPTextModel</a>, <em>optional</em>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).
If not specified, function will take self.tokenizer.`,name:"text_encoder"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>, <em>optional</em>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text. If not specified, function will take self.tokenizer.`,name:"tokenizer"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.weight_name",description:`<strong>weight_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of a custom weight file. This should be used when:</p>
<ul>
<li>The saved textual inversion file is in &#x1F917; Diffusers format, but was saved under a specific weight
name such as <code>text_inv.bin</code>.</li>
<li>The saved textual inversion file is in the Automatic1111 format.</li>
</ul>`,name:"weight_name"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.cache_dir",description:`<strong>cache_dir</strong> (<code>Union[str, os.PathLike]</code>, <em>optional</em>) &#x2014;
Path to a directory where a downloaded pretrained model configuration is cached if the standard cache
is not used.`,name:"cache_dir"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to force the (re-)download of the model weights and configuration files, overriding the
cached versions if they exist.`,name:"force_download"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.proxies",description:`<strong>proxies</strong> (<code>Dict[str, str]</code>, <em>optional</em>) &#x2014;
A dictionary of proxy servers to use by protocol or endpoint, for example, <code>{&apos;http&apos;: &apos;foo.bar:3128&apos;, &apos;http://hostname&apos;: &apos;foo.bar:4012&apos;}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.local_files_only",description:`<strong>local_files_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to only load local model weights and configuration files or not. If set to <code>True</code>, the model
won&#x2019;t be downloaded from the Hub.`,name:"local_files_only"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.hf_token",description:`<strong>hf_token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) &#x2014;
The token to use as HTTP bearer authorization for remote files. If <code>True</code>, the token generated from
<code>diffusers-cli login</code> (stored in <code>~/.huggingface</code>) is used.`,name:"hf_token"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;main&quot;</code>) &#x2014;
The specific model version to use. It can be a branch name, a tag name, a commit id, or any identifier
allowed by Git.`,name:"revision"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.subfolder",description:`<strong>subfolder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;&quot;</code>) &#x2014;
The subfolder location of a model file within a larger model repository on the Hub or locally.`,name:"subfolder"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to resolve accessibility issues if you&#x2019;re downloading a model in China. We do not
guarantee the timeliness or safety of the source, and you should refer to the mirror site for more
information.`,name:"mirror"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/textual_inversion.py#L263"}}),G=new xe({props:{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.example",$$slots:{default:[Ce]},$$scope:{ctx:Z}}}),k=new xe({props:{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.example-2",$$slots:{default:[ze]},$$scope:{ctx:Z}}}),z=new le({props:{name:"maybe_convert_prompt",anchor:"diffusers.loaders.TextualInversionLoaderMixin.maybe_convert_prompt",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"tokenizer",val:": PreTrainedTokenizer"}],parametersDescription:[{anchor:"diffusers.loaders.TextualInversionLoaderMixin.maybe_convert_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or list of <code>str</code>) &#x2014;
The prompt or prompts to guide the image generation.`,name:"prompt"},{anchor:"diffusers.loaders.TextualInversionLoaderMixin.maybe_convert_prompt.tokenizer",description:`<strong>tokenizer</strong> (<code>PreTrainedTokenizer</code>) &#x2014;
The tokenizer responsible for encoding the prompt into input tokens.`,name:"tokenizer"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/textual_inversion.py#L115",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The converted prompt</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>str</code> or list of <code>str</code></p>
`}}),F=new le({props:{name:"unload_textual_inversion",anchor:"diffusers.loaders.TextualInversionLoaderMixin.unload_textual_inversion",parameters:[{name:"tokens",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"tokenizer",val:": typing.Optional[ForwardRef('PreTrainedTokenizer')] = None"},{name:"text_encoder",val:": typing.Optional[ForwardRef('PreTrainedModel')] = None"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/textual_inversion.py#L459"}}),B=new xe({props:{anchor:"diffusers.loaders.TextualInversionLoaderMixin.unload_textual_inversion.example",$$slots:{default:[Fe]},$$scope:{ctx:Z}}}),E=new Xe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/loaders/textual_inversion.md"}}),{c(){n=u("meta"),h=i(),a=u("p"),o=i(),x(d.$$.fragment),t=i(),m=u("p"),m.textContent=Te,K=i(),V=u("p"),V.innerHTML=ve,O=i(),x($.$$.fragment),ee=i(),x(X.$$.fragment),te=i(),b=u("div"),x(R.$$.fragment),ie=i(),S=u("p"),S.textContent=_e,re=i(),M=u("div"),x(C.$$.fragment),de=i(),Q=u("p"),Q.innerHTML=Je,pe=i(),q=u("p"),q.textContent=we,ce=i(),x(G.$$.fragment),me=i(),N=u("p"),N.innerHTML=Ue,ue=i(),x(k.$$.fragment),fe=i(),W=u("div"),x(z.$$.fragment),he=i(),Y=u("p"),Y.textContent=Ze,Me=i(),j=u("div"),x(F.$$.fragment),be=i(),H=u("p"),H.innerHTML=je,ge=i(),x(B.$$.fragment),ne=i(),x(E.$$.fragment),oe=i(),D=u("p"),this.h()},l(e){const s=Be("svelte-u9bgzb",document.head);n=f(s,"META",{name:!0,content:!0}),s.forEach(l),h=r(e),a=f(e,"P",{}),P(a).forEach(l),o=r(e),y(d.$$.fragment,e),t=r(e),m=f(e,"P",{"data-svelte-h":!0}),U(m)!=="svelte-17iorh0"&&(m.textContent=Te),K=r(e),V=f(e,"P",{"data-svelte-h":!0}),U(V)!=="svelte-16c4ckr"&&(V.innerHTML=ve),O=r(e),y($.$$.fragment,e),ee=r(e),y(X.$$.fragment,e),te=r(e),b=f(e,"DIV",{class:!0});var w=P(b);y(R.$$.fragment,w),ie=r(w),S=f(w,"P",{"data-svelte-h":!0}),U(S)!=="svelte-7bntze"&&(S.textContent=_e),re=r(w),M=f(w,"DIV",{class:!0});var g=P(M);y(C.$$.fragment,g),de=r(g),Q=f(g,"P",{"data-svelte-h":!0}),U(Q)!=="svelte-1lv88wo"&&(Q.innerHTML=Je),pe=r(g),q=f(g,"P",{"data-svelte-h":!0}),U(q)!=="svelte-11lpom8"&&(q.textContent=we),ce=r(g),y(G.$$.fragment,g),me=r(g),N=f(g,"P",{"data-svelte-h":!0}),U(N)!=="svelte-15d7mv5"&&(N.innerHTML=Ue),ue=r(g),y(k.$$.fragment,g),g.forEach(l),fe=r(w),W=f(w,"DIV",{class:!0});var L=P(W);y(z.$$.fragment,L),he=r(L),Y=f(L,"P",{"data-svelte-h":!0}),U(Y)!=="svelte-gjjmbb"&&(Y.textContent=Ze),L.forEach(l),Me=r(w),j=f(w,"DIV",{class:!0});var I=P(j);y(F.$$.fragment,I),be=r(I),H=f(I,"P",{"data-svelte-h":!0}),U(H)!=="svelte-11w0m6j"&&(H.innerHTML=je),ge=r(I),y(B.$$.fragment,I),I.forEach(l),w.forEach(l),ne=r(e),y(E.$$.fragment,e),oe=r(e),D=f(e,"P",{}),P(D).forEach(l),this.h()},h(){A(n,"name","hf:doc:metadata"),A(n,"content",Le),A(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),A(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,s){p(document.head,n),c(e,h,s),c(e,a,s),c(e,o,s),T(d,e,s),c(e,t,s),c(e,m,s),c(e,K,s),c(e,V,s),c(e,O,s),T($,e,s),c(e,ee,s),T(X,e,s),c(e,te,s),c(e,b,s),T(R,b,null),p(b,ie),p(b,S),p(b,re),p(b,M),T(C,M,null),p(M,de),p(M,Q),p(M,pe),p(M,q),p(M,ce),T(G,M,null),p(M,me),p(M,N),p(M,ue),T(k,M,null),p(b,fe),p(b,W),T(z,W,null),p(W,he),p(W,Y),p(b,Me),p(b,j),T(F,j,null),p(j,be),p(j,H),p(j,ge),T(B,j,null),c(e,ne,s),T(E,e,s),c(e,oe,s),c(e,D,s),se=!0},p(e,[s]){const w={};s&2&&(w.$$scope={dirty:s,ctx:e}),$.$set(w);const g={};s&2&&(g.$$scope={dirty:s,ctx:e}),G.$set(g);const L={};s&2&&(L.$$scope={dirty:s,ctx:e}),k.$set(L);const I={};s&2&&(I.$$scope={dirty:s,ctx:e}),B.$set(I)},i(e){se||(v(d.$$.fragment,e),v($.$$.fragment,e),v(X.$$.fragment,e),v(R.$$.fragment,e),v(C.$$.fragment,e),v(G.$$.fragment,e),v(k.$$.fragment,e),v(z.$$.fragment,e),v(F.$$.fragment,e),v(B.$$.fragment,e),v(E.$$.fragment,e),se=!0)},o(e){_(d.$$.fragment,e),_($.$$.fragment,e),_(X.$$.fragment,e),_(R.$$.fragment,e),_(C.$$.fragment,e),_(G.$$.fragment,e),_(k.$$.fragment,e),_(z.$$.fragment,e),_(F.$$.fragment,e),_(B.$$.fragment,e),_(E.$$.fragment,e),se=!1},d(e){e&&(l(h),l(a),l(o),l(t),l(m),l(K),l(V),l(O),l(ee),l(te),l(b),l(ne),l(oe),l(D)),l(n),J(d,e),J($,e),J(X,e),J(R),J(C),J(G),J(k),J(z),J(F),J(B),J(E,e)}}}const Le='{"title":"Textual Inversion","local":"textual-inversion","sections":[{"title":"TextualInversionLoaderMixin","local":"diffusers.loaders.TextualInversionLoaderMixin","sections":[],"depth":2}],"depth":1}';function Se(Z){return Ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class De extends ke{constructor(n){super(),We(this,n,Se,Ee,$e,{})}}export{De as component};
