import{s as aa,o as ra,n as Fe}from"../chunks/scheduler.8c3d61f6.js";import{S as oa,i as sa,g as n,s as o,r as g,A as na,h as i,f as d,c as s,j as T,u as _,x as u,k as U,y as t,a as v,v as b,d as y,t as x,w}from"../chunks/index.da70eac4.js";import{T as ia}from"../chunks/Tip.1d9b8c37.js";import{D as J}from"../chunks/Docstring.f5e3af6d.js";import{C as He}from"../chunks/CodeBlock.a9c4becf.js";import{E as Qe}from"../chunks/ExampleCodeBlock.21e67bb6.js";import{H as ta,E as la}from"../chunks/getInferenceSnippets.07305897.js";function da(C){let r,M='Refer to the <a href="../../tutorials/using_peft_for_inference.md">Inference with PEFT</a> tutorial for an overview of how to use PEFT in Diffusers for inference.';return{c(){r=n("p"),r.innerHTML=M},l(c){r=i(c,"P",{"data-svelte-h":!0}),u(r)!=="svelte-1yhqcl5"&&(r.innerHTML=M)},m(c,l){v(c,r,l)},p:Fe,d(c){c&&d(r)}}}function pa(C){let r,M="Example:",c,l,h;return l=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZXMlM0QlMjJjaW5lbWF0aWMlMjIlMEEpJTBBcGlwZWxpbmUuZGVsZXRlX2FkYXB0ZXJzKCUyMmNpbmVtYXRpYyUyMik=",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;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_lora_weights(
    <span class="hljs-string">&quot;jbilcke-hf/sdxl-cinematic-1&quot;</span>, weight_name=<span class="hljs-string">&quot;pytorch_lora_weights.safetensors&quot;</span>, adapter_names=<span class="hljs-string">&quot;cinematic&quot;</span>
)
pipeline.delete_adapters(<span class="hljs-string">&quot;cinematic&quot;</span>)`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(l.$$.fragment)},l(a){r=i(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(l.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(l,a,$),h=!0},p:Fe,i(a){h||(y(l.$$.fragment,a),h=!0)},o(a){x(l.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(l,a)}}}function fa(C){let r,M="Example:",c,l,h;return l=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmNpbmVtYXRpYyUyMiUwQSklMEFwaXBlbGluZS5kaXNhYmxlX2xvcmEoKQ==",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;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_lora_weights(
    <span class="hljs-string">&quot;jbilcke-hf/sdxl-cinematic-1&quot;</span>, weight_name=<span class="hljs-string">&quot;pytorch_lora_weights.safetensors&quot;</span>, adapter_name=<span class="hljs-string">&quot;cinematic&quot;</span>
)
pipeline.disable_lora()`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(l.$$.fragment)},l(a){r=i(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(l.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(l,a,$),h=!0},p:Fe,i(a){h||(y(l.$$.fragment,a),h=!0)},o(a){x(l.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(l,a)}}}function ca(C){let r,M="Example:",c,l,h;return l=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmNpbmVtYXRpYyUyMiUwQSklMEFwaXBlbGluZS5lbmFibGVfbG9yYSgp",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;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_lora_weights(
    <span class="hljs-string">&quot;jbilcke-hf/sdxl-cinematic-1&quot;</span>, weight_name=<span class="hljs-string">&quot;pytorch_lora_weights.safetensors&quot;</span>, adapter_name=<span class="hljs-string">&quot;cinematic&quot;</span>
)
pipeline.enable_lora()`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(l.$$.fragment)},l(a){r=i(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(l.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(l,a,$),h=!0},p:Fe,i(a){h||(y(l.$$.fragment,a),h=!0)},o(a){x(l.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(l,a)}}}function ma(C){let r,M="Example:",c,l,h;return l=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmNpbmVtYXRpYyUyMiUwQSklMEFwaXBlbGluZS5sb2FkX2xvcmFfd2VpZ2h0cyglMjJuZXJpanMlMkZwaXhlbC1hcnQteGwlMjIlMkMlMjB3ZWlnaHRfbmFtZSUzRCUyMnBpeGVsLWFydC14bC5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMnBpeGVsJTIyKSUwQXBpcGVsaW5lLnNldF9hZGFwdGVycyglNUIlMjJjaW5lbWF0aWMlMjIlMkMlMjAlMjJwaXhlbCUyMiU1RCUyQyUyMGFkYXB0ZXJfd2VpZ2h0cyUzRCU1QjAuNSUyQyUyMDAuNSU1RCk=",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;stabilityai/stable-diffusion-xl-base-1.0&quot;</span>, torch_dtype=torch.float16
).to(<span class="hljs-string">&quot;cuda&quot;</span>)
pipeline.load_lora_weights(
    <span class="hljs-string">&quot;jbilcke-hf/sdxl-cinematic-1&quot;</span>, weight_name=<span class="hljs-string">&quot;pytorch_lora_weights.safetensors&quot;</span>, adapter_name=<span class="hljs-string">&quot;cinematic&quot;</span>
)
pipeline.load_lora_weights(<span class="hljs-string">&quot;nerijs/pixel-art-xl&quot;</span>, weight_name=<span class="hljs-string">&quot;pixel-art-xl.safetensors&quot;</span>, adapter_name=<span class="hljs-string">&quot;pixel&quot;</span>)
pipeline.set_adapters([<span class="hljs-string">&quot;cinematic&quot;</span>, <span class="hljs-string">&quot;pixel&quot;</span>], adapter_weights=[<span class="hljs-number">0.5</span>, <span class="hljs-number">0.5</span>])`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(l.$$.fragment)},l(a){r=i(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(l.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(l,a,$),h=!0},p:Fe,i(a){h||(y(l.$$.fragment,a),h=!0)},o(a){x(l.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(l,a)}}}function ha(C){let r,M,c,l,h,a,$,kt='Diffusers supports loading adapters such as <a href="../../using-diffusers/loading_adapters">LoRA</a> with the <a href="https://huggingface.co/docs/peft/index" rel="nofollow">PEFT</a> library with the <a href="/docs/diffusers/main/en/api/loaders/peft#diffusers.loaders.PeftAdapterMixin">PeftAdapterMixin</a> class. This allows modeling classes in Diffusers like <a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>, <a href="/docs/diffusers/main/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> to operate with an adapter.',Le,q,Ve,z,Ee,p,N,ze,fe,It=`A class containing all functions for loading and using adapters weights that are supported in PEFT library. For
more details about adapters and injecting them in a base model, check out the PEFT
<a href="https://huggingface.co/docs/peft/index" rel="nofollow">documentation</a>.`,Ne,ce,Wt="Install the latest version of PEFT, and use this mixin to:",Ke,me,At="<li>Attach new adapters in the model.</li> <li>Attach multiple adapters and iteratively activate/deactivate them.</li> <li>Activate/deactivate all adapters from the model.</li> <li>Get a list of the active adapters.</li>",Oe,P,K,et,he,Xt="Gets the current list of active adapters of the model.",tt,ue,Rt=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
<a href="https://huggingface.co/docs/peft" rel="nofollow">documentation</a>.`,at,Z,O,rt,ge,Ft=`Adds a new adapter to the current model for training. If no adapter name is passed, a default name is assigned
to the adapter to follow the convention of the PEFT library.`,ot,_e,Lt=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them in the PEFT
<a href="https://huggingface.co/docs/peft" rel="nofollow">documentation</a>.`,st,j,ee,nt,be,Vt="Delete an adapter’s LoRA layers from the underlying model.",it,D,lt,G,te,dt,ye,Et="Disable all adapters attached to the model and fallback to inference with the base model only.",pt,xe,qt=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
<a href="https://huggingface.co/docs/peft" rel="nofollow">documentation</a>.`,ft,k,ae,ct,we,Dt="Disables the active LoRA layers of the underlying model.",mt,B,ht,I,re,ut,$e,Bt=`Enable adapters that are attached to the model. The model uses <code>self.active_adapters()</code> to retrieve the list of
adapters to enable.`,gt,ve,St=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
<a href="https://huggingface.co/docs/peft" rel="nofollow">documentation</a>.`,_t,W,oe,bt,Me,Yt="Enables the active LoRA layers of the underlying model.",yt,S,xt,A,se,wt,Te,Qt="Enables the possibility to hotswap LoRA adapters.",$t,Ue,Ht=`Calling this method is only required when hotswapping adapters and if the model is compiled or if the ranks of
the loaded adapters differ.`,vt,Y,ne,Mt,Je,zt="Loads a LoRA adapter into the underlying model.",Tt,Q,ie,Ut,Ce,Nt="Save the LoRA parameters corresponding to the underlying model.",Jt,X,le,Ct,Pe,Kt="Sets a specific adapter by forcing the model to only use that adapter and disables the other adapters.",Pt,Ze,Ot=`If you are not familiar with adapters and PEFT methods, we invite you to read more about them on the PEFT
<a href="https://huggingface.co/docs/peft" rel="nofollow">documentation</a>.`,Zt,R,de,jt,je,ea="Set the currently active adapters for use in the UNet.",Gt,H,qe,pe,De,Re,Be;return h=new ta({props:{title:"PEFT",local:"peft",headingTag:"h1"}}),q=new ia({props:{$$slots:{default:[da]},$$scope:{ctx:C}}}),z=new ta({props:{title:"PeftAdapterMixin",local:"diffusers.loaders.PeftAdapterMixin",headingTag:"h2"}}),N=new J({props:{name:"class diffusers.loaders.PeftAdapterMixin",anchor:"diffusers.loaders.PeftAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L84"}}),K=new J({props:{name:"active_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.active_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L680"}}),O=new J({props:{name:"add_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.add_adapter",parameters:[{name:"adapter_config",val:""},{name:"adapter_name",val:": str = 'default'"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.add_adapter.adapter_config",description:`<strong>adapter_config</strong> (<code>[~peft.PeftConfig]</code>) &#x2014;
The configuration of the adapter to add; supported adapters are non-prefix tuning and adaption prompt
methods.`,name:"adapter_config"},{anchor:"diffusers.loaders.PeftAdapterMixin.add_adapter.adapter_name",description:`<strong>adapter_name</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;default&quot;</code>) &#x2014;
The name of the adapter to add. If no name is passed, a default name is assigned to the adapter.`,name:"adapter_name"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L548"}}),ee=new J({props:{name:"delete_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.delete_adapters",parameters:[{name:"adapter_names",val:": typing.Union[typing.List[str], str]"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.delete_adapters.adapter_names",description:`<strong>adapter_names</strong> (<code>Union[List[str], str]</code>) &#x2014;
The names (single string or list of strings) of the adapter to delete.`,name:"adapter_names"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L798"}}),D=new Qe({props:{anchor:"diffusers.loaders.PeftAdapterMixin.delete_adapters.example",$$slots:{default:[pa]},$$scope:{ctx:C}}}),te=new J({props:{name:"disable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.disable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L635"}}),ae=new J({props:{name:"disable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L752"}}),B=new Qe({props:{anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora.example",$$slots:{default:[fa]},$$scope:{ctx:C}}}),re=new J({props:{name:"enable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.enable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L657"}}),oe=new J({props:{name:"enable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L775"}}),S=new Qe({props:{anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora.example",$$slots:{default:[ca]},$$scope:{ctx:C}}}),se=new J({props:{name:"enable_lora_hotswap",anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora_hotswap",parameters:[{name:"target_rank",val:": int = 128"},{name:"check_compiled",val:": typing.Literal['error', 'warn', 'ignore'] = 'error'"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora_hotswap.target_rank",description:`<strong>target_rank</strong> (<code>int</code>, <em>optional</em>, defaults to <code>128</code>) &#x2014;
The highest rank among all the adapters that will be loaded.`,name:"target_rank"},{anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora_hotswap.check_compiled",description:`<strong>check_compiled</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;error&quot;</code>) &#x2014;
How to handle the case when the model is already compiled, which should generally be avoided. The
options are:</p>
<ul>
<li>&#x201C;error&#x201D; (default): raise an error</li>
<li>&#x201C;warn&#x201D;: issue a warning</li>
<li>&#x201C;ignore&#x201D;: do nothing</li>
</ul>`,name:"check_compiled"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L834"}}),ne=new J({props:{name:"load_lora_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter",parameters:[{name:"pretrained_model_name_or_path_or_dict",val:""},{name:"prefix",val:" = 'transformer'"},{name:"hotswap",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter.pretrained_model_name_or_path_or_dict",description:`<strong>pretrained_model_name_or_path_or_dict</strong> (<code>str</code> or <code>os.PathLike</code> or <code>dict</code>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> (for example <code>google/ddpm-celebahq-256</code>) of a pretrained model hosted on
the Hub.</li>
<li>A path to a <em>directory</em> (for example <code>./my_model_directory</code>) containing the model weights saved
with <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.save_pretrained">ModelMixin.save_pretrained()</a>.</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_or_dict"},{anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter.prefix",description:"<strong>prefix</strong> (<code>str</code>, <em>optional</em>) &#x2014; Prefix to filter the state dict.",name:"prefix"},{anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter.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.PeftAdapterMixin.load_lora_adapter.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.PeftAdapterMixin.load_lora_adapter.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.PeftAdapterMixin.load_lora_adapter.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.PeftAdapterMixin.load_lora_adapter.token",description:`<strong>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:"token"},{anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter.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.PeftAdapterMixin.load_lora_adapter.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.PeftAdapterMixin.load_lora_adapter.network_alphas",description:`<strong>network_alphas</strong> (<code>Dict[str, float]</code>) &#x2014;
The value of the network alpha used for stable learning and preventing underflow. This value has the
same meaning as the <code>--network_alpha</code> option in the kohya-ss trainer script. Refer to <a href="https://github.com/darkstorm2150/sd-scripts/blob/main/docs/train_network_README-en.md#execute-learning" rel="nofollow">this
link</a>.`,name:"network_alphas"},{anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter.low_cpu_mem_usage",description:`<strong>low_cpu_mem_usage</strong> (<code>bool</code>, <em>optional</em>) &#x2014;
Speed up model loading by only loading the pretrained LoRA weights and not initializing the random
weights.`,name:"low_cpu_mem_usage"},{anchor:"diffusers.loaders.PeftAdapterMixin.load_lora_adapter.hotswap",description:`<strong>hotswap</strong>  &#x2014; (<code>bool</code>, <em>optional</em>)
Defaults to <code>False</code>. Whether to substitute an existing (LoRA) adapter with the newly loaded adapter
in-place. This means that, instead of loading an additional adapter, this will take the existing
adapter weights and replace them with the weights of the new adapter. This can be faster and more
memory efficient. However, the main advantage of hotswapping is that when the model is compiled with
torch.compile, loading the new adapter does not require recompilation of the model. When using
hotswapping, the passed <code>adapter_name</code> should be the name of an already loaded adapter.</p>
<p>If the new adapter and the old adapter have different ranks and/or LoRA alphas (i.e. scaling), you need
to call an additional method before loading the adapter:`,name:"hotswap"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L118"}}),ie=new J({props:{name:"save_lora_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter",parameters:[{name:"save_directory",val:""},{name:"adapter_name",val:": str = 'default'"},{name:"upcast_before_saving",val:": bool = False"},{name:"safe_serialization",val:": bool = True"},{name:"weight_name",val:": typing.Optional[str] = None"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory to save LoRA parameters to. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.adapter_name",description:`<strong>adapter_name</strong> &#x2014; (<code>str</code>, defaults to &#x201C;default&#x201D;): The name of the adapter to serialize. Useful when the
underlying model has multiple adapters loaded.`,name:"adapter_name"},{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.upcast_before_saving",description:`<strong>upcast_before_saving</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to cast the underlying model to <code>torch.float32</code> before serialization.`,name:"upcast_before_saving"},{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.save_function",description:`<strong>save_function</strong> (<code>Callable</code>) &#x2014;
The function to use to save the state dictionary. Useful during distributed training when you need to
replace <code>torch.save</code> with another method. Can be configured with the environment variable
<code>DIFFUSERS_SAVE_MODE</code>.`,name:"save_function"},{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.safe_serialization",description:`<strong>safe_serialization</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to save the model using <code>safetensors</code> or the traditional PyTorch way with <code>pickle</code>.`,name:"safe_serialization"},{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.weight_name",description:"<strong>weight_name</strong> &#x2014; (<code>str</code>, <em>optional</em>, defaults to <code>None</code>): Name of the file to serialize the state dict with.",name:"weight_name"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L429"}}),le=new J({props:{name:"set_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.set_adapter",parameters:[{name:"adapter_name",val:": typing.Union[str, typing.List[str]]"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapter.adapter_name",description:`<strong>adapter_name</strong> (Union[str, List[str]])) &#x2014;
The list of adapters to set or the adapter name in the case of a single adapter.`,name:"adapter_name"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L586"}}),de=new J({props:{name:"set_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.set_adapters",parameters:[{name:"adapter_names",val:": typing.Union[typing.List[str], str]"},{name:"weights",val:": typing.Union[float, typing.Dict, typing.List[float], typing.List[typing.Dict], typing.List[NoneType], NoneType] = None"}],parametersDescription:[{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapters.adapter_names",description:`<strong>adapter_names</strong> (<code>List[str]</code> or <code>str</code>) &#x2014;
The names of the adapters to use.`,name:"adapter_names"},{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapters.adapter_weights",description:`<strong>adapter_weights</strong> (<code>Union[List[float], float]</code>, <em>optional</em>) &#x2014;
The adapter(s) weights to use with the UNet. If <code>None</code>, the weights are set to <code>1.0</code> for all the
adapters.`,name:"adapter_weights"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/peft.py#L492"}}),H=new Qe({props:{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapters.example",$$slots:{default:[ma]},$$scope:{ctx:C}}}),pe=new la({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/loaders/peft.md"}}),{c(){r=n("meta"),M=o(),c=n("p"),l=o(),g(h.$$.fragment),a=o(),$=n("p"),$.innerHTML=kt,Le=o(),g(q.$$.fragment),Ve=o(),g(z.$$.fragment),Ee=o(),p=n("div"),g(N.$$.fragment),ze=o(),fe=n("p"),fe.innerHTML=It,Ne=o(),ce=n("p"),ce.textContent=Wt,Ke=o(),me=n("ul"),me.innerHTML=At,Oe=o(),P=n("div"),g(K.$$.fragment),et=o(),he=n("p"),he.textContent=Xt,tt=o(),ue=n("p"),ue.innerHTML=Rt,at=o(),Z=n("div"),g(O.$$.fragment),rt=o(),ge=n("p"),ge.textContent=Ft,ot=o(),_e=n("p"),_e.innerHTML=Lt,st=o(),j=n("div"),g(ee.$$.fragment),nt=o(),be=n("p"),be.textContent=Vt,it=o(),g(D.$$.fragment),lt=o(),G=n("div"),g(te.$$.fragment),dt=o(),ye=n("p"),ye.textContent=Et,pt=o(),xe=n("p"),xe.innerHTML=qt,ft=o(),k=n("div"),g(ae.$$.fragment),ct=o(),we=n("p"),we.textContent=Dt,mt=o(),g(B.$$.fragment),ht=o(),I=n("div"),g(re.$$.fragment),ut=o(),$e=n("p"),$e.innerHTML=Bt,gt=o(),ve=n("p"),ve.innerHTML=St,_t=o(),W=n("div"),g(oe.$$.fragment),bt=o(),Me=n("p"),Me.textContent=Yt,yt=o(),g(S.$$.fragment),xt=o(),A=n("div"),g(se.$$.fragment),wt=o(),Te=n("p"),Te.textContent=Qt,$t=o(),Ue=n("p"),Ue.textContent=Ht,vt=o(),Y=n("div"),g(ne.$$.fragment),Mt=o(),Je=n("p"),Je.textContent=zt,Tt=o(),Q=n("div"),g(ie.$$.fragment),Ut=o(),Ce=n("p"),Ce.textContent=Nt,Jt=o(),X=n("div"),g(le.$$.fragment),Ct=o(),Pe=n("p"),Pe.textContent=Kt,Pt=o(),Ze=n("p"),Ze.innerHTML=Ot,Zt=o(),R=n("div"),g(de.$$.fragment),jt=o(),je=n("p"),je.textContent=ea,Gt=o(),g(H.$$.fragment),qe=o(),g(pe.$$.fragment),De=o(),Re=n("p"),this.h()},l(e){const m=na("svelte-u9bgzb",document.head);r=i(m,"META",{name:!0,content:!0}),m.forEach(d),M=s(e),c=i(e,"P",{}),T(c).forEach(d),l=s(e),_(h.$$.fragment,e),a=s(e),$=i(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-19ge5s3"&&($.innerHTML=kt),Le=s(e),_(q.$$.fragment,e),Ve=s(e),_(z.$$.fragment,e),Ee=s(e),p=i(e,"DIV",{class:!0});var f=T(p);_(N.$$.fragment,f),ze=s(f),fe=i(f,"P",{"data-svelte-h":!0}),u(fe)!=="svelte-16jad6u"&&(fe.innerHTML=It),Ne=s(f),ce=i(f,"P",{"data-svelte-h":!0}),u(ce)!=="svelte-jgx411"&&(ce.textContent=Wt),Ke=s(f),me=i(f,"UL",{"data-svelte-h":!0}),u(me)!=="svelte-70o87y"&&(me.innerHTML=At),Oe=s(f),P=i(f,"DIV",{class:!0});var F=T(P);_(K.$$.fragment,F),et=s(F),he=i(F,"P",{"data-svelte-h":!0}),u(he)!=="svelte-1i9yvzx"&&(he.textContent=Xt),tt=s(F),ue=i(F,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-pm6rj0"&&(ue.innerHTML=Rt),F.forEach(d),at=s(f),Z=i(f,"DIV",{class:!0});var L=T(Z);_(O.$$.fragment,L),rt=s(L),ge=i(L,"P",{"data-svelte-h":!0}),u(ge)!=="svelte-ayg1h"&&(ge.textContent=Ft),ot=s(L),_e=i(L,"P",{"data-svelte-h":!0}),u(_e)!=="svelte-m719pe"&&(_e.innerHTML=Lt),L.forEach(d),st=s(f),j=i(f,"DIV",{class:!0});var V=T(j);_(ee.$$.fragment,V),nt=s(V),be=i(V,"P",{"data-svelte-h":!0}),u(be)!=="svelte-1oumhy2"&&(be.textContent=Vt),it=s(V),_(D.$$.fragment,V),V.forEach(d),lt=s(f),G=i(f,"DIV",{class:!0});var E=T(G);_(te.$$.fragment,E),dt=s(E),ye=i(E,"P",{"data-svelte-h":!0}),u(ye)!=="svelte-stjif2"&&(ye.textContent=Et),pt=s(E),xe=i(E,"P",{"data-svelte-h":!0}),u(xe)!=="svelte-pm6rj0"&&(xe.innerHTML=qt),E.forEach(d),ft=s(f),k=i(f,"DIV",{class:!0});var Ge=T(k);_(ae.$$.fragment,Ge),ct=s(Ge),we=i(Ge,"P",{"data-svelte-h":!0}),u(we)!=="svelte-1w71mps"&&(we.textContent=Dt),mt=s(Ge),_(B.$$.fragment,Ge),Ge.forEach(d),ht=s(f),I=i(f,"DIV",{class:!0});var ke=T(I);_(re.$$.fragment,ke),ut=s(ke),$e=i(ke,"P",{"data-svelte-h":!0}),u($e)!=="svelte-hmbjwp"&&($e.innerHTML=Bt),gt=s(ke),ve=i(ke,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-pm6rj0"&&(ve.innerHTML=St),ke.forEach(d),_t=s(f),W=i(f,"DIV",{class:!0});var Ie=T(W);_(oe.$$.fragment,Ie),bt=s(Ie),Me=i(Ie,"P",{"data-svelte-h":!0}),u(Me)!=="svelte-9erqj1"&&(Me.textContent=Yt),yt=s(Ie),_(S.$$.fragment,Ie),Ie.forEach(d),xt=s(f),A=i(f,"DIV",{class:!0});var We=T(A);_(se.$$.fragment,We),wt=s(We),Te=i(We,"P",{"data-svelte-h":!0}),u(Te)!=="svelte-w22v11"&&(Te.textContent=Qt),$t=s(We),Ue=i(We,"P",{"data-svelte-h":!0}),u(Ue)!=="svelte-zdadya"&&(Ue.textContent=Ht),We.forEach(d),vt=s(f),Y=i(f,"DIV",{class:!0});var Se=T(Y);_(ne.$$.fragment,Se),Mt=s(Se),Je=i(Se,"P",{"data-svelte-h":!0}),u(Je)!=="svelte-mffm0u"&&(Je.textContent=zt),Se.forEach(d),Tt=s(f),Q=i(f,"DIV",{class:!0});var Ye=T(Q);_(ie.$$.fragment,Ye),Ut=s(Ye),Ce=i(Ye,"P",{"data-svelte-h":!0}),u(Ce)!=="svelte-1wrxd29"&&(Ce.textContent=Nt),Ye.forEach(d),Jt=s(f),X=i(f,"DIV",{class:!0});var Ae=T(X);_(le.$$.fragment,Ae),Ct=s(Ae),Pe=i(Ae,"P",{"data-svelte-h":!0}),u(Pe)!=="svelte-1kp30gn"&&(Pe.textContent=Kt),Pt=s(Ae),Ze=i(Ae,"P",{"data-svelte-h":!0}),u(Ze)!=="svelte-pm6rj0"&&(Ze.innerHTML=Ot),Ae.forEach(d),Zt=s(f),R=i(f,"DIV",{class:!0});var Xe=T(R);_(de.$$.fragment,Xe),jt=s(Xe),je=i(Xe,"P",{"data-svelte-h":!0}),u(je)!=="svelte-38gdgn"&&(je.textContent=ea),Gt=s(Xe),_(H.$$.fragment,Xe),Xe.forEach(d),f.forEach(d),qe=s(e),_(pe.$$.fragment,e),De=s(e),Re=i(e,"P",{}),T(Re).forEach(d),this.h()},h(){U(r,"name","hf:doc:metadata"),U(r,"content",ua),U(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),U(p,"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,m){t(document.head,r),v(e,M,m),v(e,c,m),v(e,l,m),b(h,e,m),v(e,a,m),v(e,$,m),v(e,Le,m),b(q,e,m),v(e,Ve,m),b(z,e,m),v(e,Ee,m),v(e,p,m),b(N,p,null),t(p,ze),t(p,fe),t(p,Ne),t(p,ce),t(p,Ke),t(p,me),t(p,Oe),t(p,P),b(K,P,null),t(P,et),t(P,he),t(P,tt),t(P,ue),t(p,at),t(p,Z),b(O,Z,null),t(Z,rt),t(Z,ge),t(Z,ot),t(Z,_e),t(p,st),t(p,j),b(ee,j,null),t(j,nt),t(j,be),t(j,it),b(D,j,null),t(p,lt),t(p,G),b(te,G,null),t(G,dt),t(G,ye),t(G,pt),t(G,xe),t(p,ft),t(p,k),b(ae,k,null),t(k,ct),t(k,we),t(k,mt),b(B,k,null),t(p,ht),t(p,I),b(re,I,null),t(I,ut),t(I,$e),t(I,gt),t(I,ve),t(p,_t),t(p,W),b(oe,W,null),t(W,bt),t(W,Me),t(W,yt),b(S,W,null),t(p,xt),t(p,A),b(se,A,null),t(A,wt),t(A,Te),t(A,$t),t(A,Ue),t(p,vt),t(p,Y),b(ne,Y,null),t(Y,Mt),t(Y,Je),t(p,Tt),t(p,Q),b(ie,Q,null),t(Q,Ut),t(Q,Ce),t(p,Jt),t(p,X),b(le,X,null),t(X,Ct),t(X,Pe),t(X,Pt),t(X,Ze),t(p,Zt),t(p,R),b(de,R,null),t(R,jt),t(R,je),t(R,Gt),b(H,R,null),v(e,qe,m),b(pe,e,m),v(e,De,m),v(e,Re,m),Be=!0},p(e,[m]){const f={};m&2&&(f.$$scope={dirty:m,ctx:e}),q.$set(f);const F={};m&2&&(F.$$scope={dirty:m,ctx:e}),D.$set(F);const L={};m&2&&(L.$$scope={dirty:m,ctx:e}),B.$set(L);const V={};m&2&&(V.$$scope={dirty:m,ctx:e}),S.$set(V);const E={};m&2&&(E.$$scope={dirty:m,ctx:e}),H.$set(E)},i(e){Be||(y(h.$$.fragment,e),y(q.$$.fragment,e),y(z.$$.fragment,e),y(N.$$.fragment,e),y(K.$$.fragment,e),y(O.$$.fragment,e),y(ee.$$.fragment,e),y(D.$$.fragment,e),y(te.$$.fragment,e),y(ae.$$.fragment,e),y(B.$$.fragment,e),y(re.$$.fragment,e),y(oe.$$.fragment,e),y(S.$$.fragment,e),y(se.$$.fragment,e),y(ne.$$.fragment,e),y(ie.$$.fragment,e),y(le.$$.fragment,e),y(de.$$.fragment,e),y(H.$$.fragment,e),y(pe.$$.fragment,e),Be=!0)},o(e){x(h.$$.fragment,e),x(q.$$.fragment,e),x(z.$$.fragment,e),x(N.$$.fragment,e),x(K.$$.fragment,e),x(O.$$.fragment,e),x(ee.$$.fragment,e),x(D.$$.fragment,e),x(te.$$.fragment,e),x(ae.$$.fragment,e),x(B.$$.fragment,e),x(re.$$.fragment,e),x(oe.$$.fragment,e),x(S.$$.fragment,e),x(se.$$.fragment,e),x(ne.$$.fragment,e),x(ie.$$.fragment,e),x(le.$$.fragment,e),x(de.$$.fragment,e),x(H.$$.fragment,e),x(pe.$$.fragment,e),Be=!1},d(e){e&&(d(M),d(c),d(l),d(a),d($),d(Le),d(Ve),d(Ee),d(p),d(qe),d(De),d(Re)),d(r),w(h,e),w(q,e),w(z,e),w(N),w(K),w(O),w(ee),w(D),w(te),w(ae),w(B),w(re),w(oe),w(S),w(se),w(ne),w(ie),w(le),w(de),w(H),w(pe,e)}}}const ua='{"title":"PEFT","local":"peft","sections":[{"title":"PeftAdapterMixin","local":"diffusers.loaders.PeftAdapterMixin","sections":[],"depth":2}],"depth":1}';function ga(C){return ra(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ma extends oa{constructor(r){super(),sa(this,r,ga,ha,aa,{})}}export{Ma as component};
