import{s as $e,o as Be,n as Te}from"../chunks/scheduler.53228c21.js";import{S as Ve,i as Xe,e as u,s as a,c as g,h as Ce,a as f,d as s,b as i,f as D,g as x,j as U,k as S,l as d,m as p,n as y,t as T,o as v,p as _}from"../chunks/index.100fac89.js";import{C as Re}from"../chunks/CopyLLMTxtMenu.4f0519ef.js";import{D as ie}from"../chunks/Docstring.d02a9fa5.js";import{C as ve}from"../chunks/CodeBlock.d30a6509.js";import{E as ye}from"../chunks/ExampleCodeBlock.38517eb4.js";import{H as We,E as ze}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.62dbb7c4.js";function Fe(j){let n,J="To load a Textual Inversion embedding vector in 🤗 Diffusers format:",c,l,r;return l=new ve({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=J,c=a(),g(l.$$.fragment)},l(t){n=f(t,"P",{"data-svelte-h":!0}),U(n)!=="svelte-1gc783q"&&(n.textContent=J),c=i(t),x(l.$$.fragment,t)},m(t,m){p(t,n,m),p(t,c,m),y(l,t,m),r=!0},p:Te,i(t){r||(T(l.$$.fragment,t),r=!0)},o(t){v(l.$$.fragment,t),r=!1},d(t){t&&(s(n),s(c)),_(l,t)}}}function Le(j){let n,J="locally:",c,l,r;return l=new ve({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=J,c=a(),g(l.$$.fragment)},l(t){n=f(t,"P",{"data-svelte-h":!0}),U(n)!=="svelte-4c75kq"&&(n.textContent=J),c=i(t),x(l.$$.fragment,t)},m(t,m){p(t,n,m),p(t,c,m),y(l,t,m),r=!0},p:Te,i(t){r||(T(l.$$.fragment,t),r=!0)},o(t){v(l.$$.fragment,t),r=!1},d(t){t&&(s(n),s(c)),_(l,t)}}}function Ee(j){let n,J="Example:",c,l,r;return l=new ve({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmxlLWRpZmZ1c2lvbi12MS01JTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyKSUwQSUwQSUyMyUyMEV4YW1wbGUlMjAxJTBBcGlwZWxpbmUubG9hZF90ZXh0dWFsX2ludmVyc2lvbiglMjJzZC1jb25jZXB0cy1saWJyYXJ5JTJGZ3RhNS1hcnR3b3JrJTIyKSUwQXBpcGVsaW5lLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTIyc2QtY29uY2VwdHMtbGlicmFyeSUyRm1vZWItc3R5bGUlMjIpJTBBJTBBJTIzJTIwUmVtb3ZlJTIwYWxsJTIwdG9rZW4lMjBlbWJlZGRpbmdzJTBBcGlwZWxpbmUudW5sb2FkX3RleHR1YWxfaW52ZXJzaW9uKCklMEElMEElMjMlMjBFeGFtcGxlJTIwMiUwQXBpcGVsaW5lLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTIyc2QtY29uY2VwdHMtbGlicmFyeSUyRm1vZWItc3R5bGUlMjIpJTBBcGlwZWxpbmUubG9hZF90ZXh0dWFsX2ludmVyc2lvbiglMjJzZC1jb25jZXB0cy1saWJyYXJ5JTJGZ3RhNS1hcnR3b3JrJTIyKSUwQSUwQSUyM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V4dF9lbmNvZGVyXzIlMkMlMjB0b2tlbml6ZXIlM0RwaXBlbGluZS50b2tlbml6ZXJfMiUwQSk=",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=J,c=a(),g(l.$$.fragment)},l(t){n=f(t,"P",{"data-svelte-h":!0}),U(n)!=="svelte-11lpom8"&&(n.textContent=J),c=i(t),x(l.$$.fragment,t)},m(t,m){p(t,n,m),p(t,c,m),y(l,t,m),r=!0},p:Te,i(t){r||(T(l.$$.fragment,t),r=!0)},o(t){v(l.$$.fragment,t),r=!1},d(t){t&&(s(n),s(c)),_(l,t)}}}function Se(j){let n,J,c,l,r,t,m,O,B,_e="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.",ee,V,Je="<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.",te,I,we='<p>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.</p>',ne,X,oe,M,C,re,Q,Ue="Load Textual Inversion tokens and embeddings to the tokenizer and text encoder.",de,h,R,pe,q,Ze=`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).`,ce,N,je="Example:",me,k,ue,Y,Ie=`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`,fe,G,he,W,z,Me,H,ke=`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.`,be,Z,F,ge,P,Ge='Unload Textual Inversion embeddings from the text encoder of <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline">StableDiffusionPipeline</a>',xe,$,se,L,le,K,ae;return r=new Re({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),m=new We({props:{title:"Textual Inversion",local:"textual-inversion",headingTag:"h1"}}),X=new We({props:{title:"TextualInversionLoaderMixin",local:"diffusers.loaders.TextualInversionLoaderMixin",headingTag:"h2"}}),C=new ie({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"}}),R=new ie({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"}}),k=new ye({props:{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.example",$$slots:{default:[Fe]},$$scope:{ctx:j}}}),G=new ye({props:{anchor:"diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion.example-2",$$slots:{default:[Le]},$$scope:{ctx:j}}}),z=new ie({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 ie({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"}}),$=new ye({props:{anchor:"diffusers.loaders.TextualInversionLoaderMixin.unload_textual_inversion.example",$$slots:{default:[Ee]},$$scope:{ctx:j}}}),L=new ze({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/loaders/textual_inversion.md"}}),{c(){n=u("meta"),J=a(),c=u("p"),l=a(),g(r.$$.fragment),t=a(),g(m.$$.fragment),O=a(),B=u("p"),B.textContent=_e,ee=a(),V=u("p"),V.innerHTML=Je,te=a(),I=u("blockquote"),I.innerHTML=we,ne=a(),g(X.$$.fragment),oe=a(),M=u("div"),g(C.$$.fragment),re=a(),Q=u("p"),Q.textContent=Ue,de=a(),h=u("div"),g(R.$$.fragment),pe=a(),q=u("p"),q.innerHTML=Ze,ce=a(),N=u("p"),N.textContent=je,me=a(),g(k.$$.fragment),ue=a(),Y=u("p"),Y.innerHTML=Ie,fe=a(),g(G.$$.fragment),he=a(),W=u("div"),g(z.$$.fragment),Me=a(),H=u("p"),H.textContent=ke,be=a(),Z=u("div"),g(F.$$.fragment),ge=a(),P=u("p"),P.innerHTML=Ge,xe=a(),g($.$$.fragment),se=a(),g(L.$$.fragment),le=a(),K=u("p"),this.h()},l(e){const o=Ce("svelte-u9bgzb",document.head);n=f(o,"META",{name:!0,content:!0}),o.forEach(s),J=i(e),c=f(e,"P",{}),D(c).forEach(s),l=i(e),x(r.$$.fragment,e),t=i(e),x(m.$$.fragment,e),O=i(e),B=f(e,"P",{"data-svelte-h":!0}),U(B)!=="svelte-17iorh0"&&(B.textContent=_e),ee=i(e),V=f(e,"P",{"data-svelte-h":!0}),U(V)!=="svelte-16c4ckr"&&(V.innerHTML=Je),te=i(e),I=f(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),U(I)!=="svelte-13ll1no"&&(I.innerHTML=we),ne=i(e),x(X.$$.fragment,e),oe=i(e),M=f(e,"DIV",{class:!0});var w=D(M);x(C.$$.fragment,w),re=i(w),Q=f(w,"P",{"data-svelte-h":!0}),U(Q)!=="svelte-7bntze"&&(Q.textContent=Ue),de=i(w),h=f(w,"DIV",{class:!0});var b=D(h);x(R.$$.fragment,b),pe=i(b),q=f(b,"P",{"data-svelte-h":!0}),U(q)!=="svelte-1lv88wo"&&(q.innerHTML=Ze),ce=i(b),N=f(b,"P",{"data-svelte-h":!0}),U(N)!=="svelte-11lpom8"&&(N.textContent=je),me=i(b),x(k.$$.fragment,b),ue=i(b),Y=f(b,"P",{"data-svelte-h":!0}),U(Y)!=="svelte-15d7mv5"&&(Y.innerHTML=Ie),fe=i(b),x(G.$$.fragment,b),b.forEach(s),he=i(w),W=f(w,"DIV",{class:!0});var E=D(W);x(z.$$.fragment,E),Me=i(E),H=f(E,"P",{"data-svelte-h":!0}),U(H)!=="svelte-gjjmbb"&&(H.textContent=ke),E.forEach(s),be=i(w),Z=f(w,"DIV",{class:!0});var A=D(Z);x(F.$$.fragment,A),ge=i(A),P=f(A,"P",{"data-svelte-h":!0}),U(P)!=="svelte-11w0m6j"&&(P.innerHTML=Ge),xe=i(A),x($.$$.fragment,A),A.forEach(s),w.forEach(s),se=i(e),x(L.$$.fragment,e),le=i(e),K=f(e,"P",{}),D(K).forEach(s),this.h()},h(){S(n,"name","hf:doc:metadata"),S(n,"content",Qe),S(I,"class","tip"),S(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(M,"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,o){d(document.head,n),p(e,J,o),p(e,c,o),p(e,l,o),y(r,e,o),p(e,t,o),y(m,e,o),p(e,O,o),p(e,B,o),p(e,ee,o),p(e,V,o),p(e,te,o),p(e,I,o),p(e,ne,o),y(X,e,o),p(e,oe,o),p(e,M,o),y(C,M,null),d(M,re),d(M,Q),d(M,de),d(M,h),y(R,h,null),d(h,pe),d(h,q),d(h,ce),d(h,N),d(h,me),y(k,h,null),d(h,ue),d(h,Y),d(h,fe),y(G,h,null),d(M,he),d(M,W),y(z,W,null),d(W,Me),d(W,H),d(M,be),d(M,Z),y(F,Z,null),d(Z,ge),d(Z,P),d(Z,xe),y($,Z,null),p(e,se,o),y(L,e,o),p(e,le,o),p(e,K,o),ae=!0},p(e,[o]){const w={};o&2&&(w.$$scope={dirty:o,ctx:e}),k.$set(w);const b={};o&2&&(b.$$scope={dirty:o,ctx:e}),G.$set(b);const E={};o&2&&(E.$$scope={dirty:o,ctx:e}),$.$set(E)},i(e){ae||(T(r.$$.fragment,e),T(m.$$.fragment,e),T(X.$$.fragment,e),T(C.$$.fragment,e),T(R.$$.fragment,e),T(k.$$.fragment,e),T(G.$$.fragment,e),T(z.$$.fragment,e),T(F.$$.fragment,e),T($.$$.fragment,e),T(L.$$.fragment,e),ae=!0)},o(e){v(r.$$.fragment,e),v(m.$$.fragment,e),v(X.$$.fragment,e),v(C.$$.fragment,e),v(R.$$.fragment,e),v(k.$$.fragment,e),v(G.$$.fragment,e),v(z.$$.fragment,e),v(F.$$.fragment,e),v($.$$.fragment,e),v(L.$$.fragment,e),ae=!1},d(e){e&&(s(J),s(c),s(l),s(t),s(O),s(B),s(ee),s(V),s(te),s(I),s(ne),s(oe),s(M),s(se),s(le),s(K)),s(n),_(r,e),_(m,e),_(X,e),_(C),_(R),_(k),_(G),_(z),_(F),_($),_(L,e)}}}const Qe='{"title":"Textual Inversion","local":"textual-inversion","sections":[{"title":"TextualInversionLoaderMixin","local":"diffusers.loaders.TextualInversionLoaderMixin","sections":[],"depth":2}],"depth":1}';function qe(j){return Be(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Oe extends Ve{constructor(n){super(),Xe(this,n,qe,Se,$e,{})}}export{Oe as component};
