Buckets:

rtrm's picture
download
raw
35 kB
import{s as aa,o as ra,n as Ae}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 l,f as d,c as s,j as T,u as _,x as u,k as J,y as t,a as v,v as b,d as y,t as x,w}from"../chunks/index.da70eac4.js";import{T as la}from"../chunks/Tip.1d9b8c37.js";import{D as U}from"../chunks/Docstring.8928dec8.js";import{C as He}from"../chunks/CodeBlock.a9c4becf.js";import{E as Se}from"../chunks/ExampleCodeBlock.3d7cfea3.js";import{H as ta,E as ia}from"../chunks/getInferenceSnippets.8d281f31.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=l(c,"P",{"data-svelte-h":!0}),u(r)!=="svelte-1yhqcl5"&&(r.innerHTML=M)},m(c,i){v(c,r,i)},p:Ae,d(c){c&&d(r)}}}function pa(C){let r,M="Example:",c,i,h;return i=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZXMlM0QlMjJjaW5lbWF0aWMlMjIlMEEpJTBBcGlwZWxpbmUudW5ldC5kZWxldGVfYWRhcHRlcnMoJTIyY2luZW1hdGljJTIyKQ==",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.unet.delete_adapters(<span class="hljs-string">&quot;cinematic&quot;</span>)`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(i.$$.fragment)},l(a){r=l(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(i.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(i,a,$),h=!0},p:Ae,i(a){h||(y(i.$$.fragment,a),h=!0)},o(a){x(i.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(i,a)}}}function fa(C){let r,M="Example:",c,i,h;return i=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmNpbmVtYXRpYyUyMiUwQSklMEFwaXBlbGluZS51bmV0LmRpc2FibGVfbG9yYSgp",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.unet.disable_lora()`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(i.$$.fragment)},l(a){r=l(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(i.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(i,a,$),h=!0},p:Ae,i(a){h||(y(i.$$.fragment,a),h=!0)},o(a){x(i.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(i,a)}}}function ca(C){let r,M="Example:",c,i,h;return i=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmNpbmVtYXRpYyUyMiUwQSklMEFwaXBlbGluZS51bmV0LmVuYWJsZV9sb3JhKCk=",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.unet.enable_lora()`,wrap:!1}}),{c(){r=n("p"),r.textContent=M,c=o(),g(i.$$.fragment)},l(a){r=l(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(i.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(i,a,$),h=!0},p:Ae,i(a){h||(y(i.$$.fragment,a),h=!0)},o(a){x(i.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(i,a)}}}function ma(C){let r,M="Example:",c,i,h;return i=new He({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMEF1dG9QaXBlbGluZUZvclRleHQySW1hZ2UlMEFpbXBvcnQlMjB0b3JjaCUwQSUwQXBpcGVsaW5lJTIwJTNEJTIwQXV0b1BpcGVsaW5lRm9yVGV4dDJJbWFnZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLXhsLWJhc2UtMS4wJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKS50byglMjJjdWRhJTIyKSUwQXBpcGVsaW5lLmxvYWRfbG9yYV93ZWlnaHRzKCUwQSUyMCUyMCUyMCUyMCUyMmpiaWxja2UtaGYlMkZzZHhsLWNpbmVtYXRpYy0xJTIyJTJDJTIwd2VpZ2h0X25hbWUlM0QlMjJweXRvcmNoX2xvcmFfd2VpZ2h0cy5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMmNpbmVtYXRpYyUyMiUwQSklMEFwaXBlbGluZS5sb2FkX2xvcmFfd2VpZ2h0cyglMjJuZXJpanMlMkZwaXhlbC1hcnQteGwlMjIlMkMlMjB3ZWlnaHRfbmFtZSUzRCUyMnBpeGVsLWFydC14bC5zYWZldGVuc29ycyUyMiUyQyUyMGFkYXB0ZXJfbmFtZSUzRCUyMnBpeGVsJTIyKSUwQXBpcGVsaW5lLnVuZXQuc2V0X2FkYXB0ZXJzKCU1QiUyMmNpbmVtYXRpYyUyMiUyQyUyMCUyMnBpeGVsJTIyJTVEJTJDJTIwYWRhcHRlcl93ZWlnaHRzJTNEJTVCMC41JTJDJTIwMC41JTVEKQ==",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.unet.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(i.$$.fragment)},l(a){r=l(a,"P",{"data-svelte-h":!0}),u(r)!=="svelte-11lpom8"&&(r.textContent=M),c=s(a),_(i.$$.fragment,a)},m(a,$){v(a,r,$),v(a,c,$),b(i,a,$),h=!0},p:Ae,i(a){h||(y(i.$$.fragment,a),h=!0)},o(a){x(i.$$.fragment,a),h=!1},d(a){a&&(d(r),d(c)),w(i,a)}}}function ha(C){let r,M,c,i,h,a,$,jt='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/pr_12242/en/api/loaders/peft#diffusers.loaders.PeftAdapterMixin">PeftAdapterMixin</a> class. This allows modeling classes in Diffusers like <a href="/docs/diffusers/pr_12242/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>, <a href="/docs/diffusers/pr_12242/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> to operate with an adapter.',Xe,q,Fe,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,Vt="<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,Rt="Gets the current list of active adapters of the model.",tt,ue,Lt=`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,At=`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,Xt=`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,G,ee,nt,be,Ft="Delete an adapter’s LoRA layers from the underlying model.",lt,D,it,k,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,j,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,Yt=`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,Qt="Enables the active LoRA layers of the underlying model.",yt,Y,xt,V,se,wt,Te,St="Enables the possibility to hotswap LoRA adapters.",$t,Je,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,Q,ne,Mt,Ue,zt="Loads a LoRA adapter into the underlying model.",Tt,S,le,Jt,Ce,Nt="Save the LoRA parameters corresponding to the underlying model.",Ut,R,ie,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,L,de,Gt,Ge,ea="Set the currently active adapters for use in the diffusion network (e.g. unet, transformer, etc.).",kt,H,qe,pe,De,Le,Be;return h=new ta({props:{title:"PEFT",local:"peft",headingTag:"h1"}}),q=new la({props:{$$slots:{default:[da]},$$scope:{ctx:C}}}),z=new ta({props:{title:"PeftAdapterMixin",local:"diffusers.loaders.PeftAdapterMixin",headingTag:"h2"}}),N=new U({props:{name:"class diffusers.loaders.PeftAdapterMixin",anchor:"diffusers.loaders.PeftAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12242/src/diffusers/loaders/peft.py#L68"}}),K=new U({props:{name:"active_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.active_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12242/src/diffusers/loaders/peft.py#L636"}}),O=new U({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/vr_12242/src/diffusers/loaders/peft.py#L504"}}),ee=new U({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/vr_12242/src/diffusers/loaders/peft.py#L759"}}),D=new Se({props:{anchor:"diffusers.loaders.PeftAdapterMixin.delete_adapters.example",$$slots:{default:[pa]},$$scope:{ctx:C}}}),te=new U({props:{name:"disable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.disable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12242/src/diffusers/loaders/peft.py#L591"}}),ae=new U({props:{name:"disable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12242/src/diffusers/loaders/peft.py#L713"}}),B=new Se({props:{anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora.example",$$slots:{default:[fa]},$$scope:{ctx:C}}}),re=new U({props:{name:"enable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.enable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12242/src/diffusers/loaders/peft.py#L613"}}),oe=new U({props:{name:"enable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12242/src/diffusers/loaders/peft.py#L736"}}),Y=new Se({props:{anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora.example",$$slots:{default:[ca]},$$scope:{ctx:C}}}),se=new U({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/vr_12242/src/diffusers/loaders/peft.py#L795"}}),ne=new U({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/pr_12242/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/vr_12242/src/diffusers/loaders/peft.py#L91"}}),le=new U({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.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/vr_12242/src/diffusers/loaders/peft.py#L380"}}),ie=new U({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/vr_12242/src/diffusers/loaders/peft.py#L542"}}),de=new U({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/vr_12242/src/diffusers/loaders/peft.py#L448"}}),H=new Se({props:{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapters.example",$$slots:{default:[ma]},$$scope:{ctx:C}}}),pe=new ia({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"),i=o(),g(h.$$.fragment),a=o(),$=n("p"),$.innerHTML=jt,Xe=o(),g(q.$$.fragment),Fe=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=Vt,Oe=o(),P=n("div"),g(K.$$.fragment),et=o(),he=n("p"),he.textContent=Rt,tt=o(),ue=n("p"),ue.innerHTML=Lt,at=o(),Z=n("div"),g(O.$$.fragment),rt=o(),ge=n("p"),ge.textContent=At,ot=o(),_e=n("p"),_e.innerHTML=Xt,st=o(),G=n("div"),g(ee.$$.fragment),nt=o(),be=n("p"),be.textContent=Ft,lt=o(),g(D.$$.fragment),it=o(),k=n("div"),g(te.$$.fragment),dt=o(),ye=n("p"),ye.textContent=Et,pt=o(),xe=n("p"),xe.innerHTML=qt,ft=o(),j=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=Yt,_t=o(),W=n("div"),g(oe.$$.fragment),bt=o(),Me=n("p"),Me.textContent=Qt,yt=o(),g(Y.$$.fragment),xt=o(),V=n("div"),g(se.$$.fragment),wt=o(),Te=n("p"),Te.textContent=St,$t=o(),Je=n("p"),Je.textContent=Ht,vt=o(),Q=n("div"),g(ne.$$.fragment),Mt=o(),Ue=n("p"),Ue.textContent=zt,Tt=o(),S=n("div"),g(le.$$.fragment),Jt=o(),Ce=n("p"),Ce.textContent=Nt,Ut=o(),R=n("div"),g(ie.$$.fragment),Ct=o(),Pe=n("p"),Pe.textContent=Kt,Pt=o(),Ze=n("p"),Ze.innerHTML=Ot,Zt=o(),L=n("div"),g(de.$$.fragment),Gt=o(),Ge=n("p"),Ge.textContent=ea,kt=o(),g(H.$$.fragment),qe=o(),g(pe.$$.fragment),De=o(),Le=n("p"),this.h()},l(e){const m=na("svelte-u9bgzb",document.head);r=l(m,"META",{name:!0,content:!0}),m.forEach(d),M=s(e),c=l(e,"P",{}),T(c).forEach(d),i=s(e),_(h.$$.fragment,e),a=s(e),$=l(e,"P",{"data-svelte-h":!0}),u($)!=="svelte-1dc08ec"&&($.innerHTML=jt),Xe=s(e),_(q.$$.fragment,e),Fe=s(e),_(z.$$.fragment,e),Ee=s(e),p=l(e,"DIV",{class:!0});var f=T(p);_(N.$$.fragment,f),ze=s(f),fe=l(f,"P",{"data-svelte-h":!0}),u(fe)!=="svelte-16jad6u"&&(fe.innerHTML=It),Ne=s(f),ce=l(f,"P",{"data-svelte-h":!0}),u(ce)!=="svelte-jgx411"&&(ce.textContent=Wt),Ke=s(f),me=l(f,"UL",{"data-svelte-h":!0}),u(me)!=="svelte-70o87y"&&(me.innerHTML=Vt),Oe=s(f),P=l(f,"DIV",{class:!0});var A=T(P);_(K.$$.fragment,A),et=s(A),he=l(A,"P",{"data-svelte-h":!0}),u(he)!=="svelte-1i9yvzx"&&(he.textContent=Rt),tt=s(A),ue=l(A,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-pm6rj0"&&(ue.innerHTML=Lt),A.forEach(d),at=s(f),Z=l(f,"DIV",{class:!0});var X=T(Z);_(O.$$.fragment,X),rt=s(X),ge=l(X,"P",{"data-svelte-h":!0}),u(ge)!=="svelte-ayg1h"&&(ge.textContent=At),ot=s(X),_e=l(X,"P",{"data-svelte-h":!0}),u(_e)!=="svelte-m719pe"&&(_e.innerHTML=Xt),X.forEach(d),st=s(f),G=l(f,"DIV",{class:!0});var F=T(G);_(ee.$$.fragment,F),nt=s(F),be=l(F,"P",{"data-svelte-h":!0}),u(be)!=="svelte-1oumhy2"&&(be.textContent=Ft),lt=s(F),_(D.$$.fragment,F),F.forEach(d),it=s(f),k=l(f,"DIV",{class:!0});var E=T(k);_(te.$$.fragment,E),dt=s(E),ye=l(E,"P",{"data-svelte-h":!0}),u(ye)!=="svelte-stjif2"&&(ye.textContent=Et),pt=s(E),xe=l(E,"P",{"data-svelte-h":!0}),u(xe)!=="svelte-pm6rj0"&&(xe.innerHTML=qt),E.forEach(d),ft=s(f),j=l(f,"DIV",{class:!0});var ke=T(j);_(ae.$$.fragment,ke),ct=s(ke),we=l(ke,"P",{"data-svelte-h":!0}),u(we)!=="svelte-1w71mps"&&(we.textContent=Dt),mt=s(ke),_(B.$$.fragment,ke),ke.forEach(d),ht=s(f),I=l(f,"DIV",{class:!0});var je=T(I);_(re.$$.fragment,je),ut=s(je),$e=l(je,"P",{"data-svelte-h":!0}),u($e)!=="svelte-hmbjwp"&&($e.innerHTML=Bt),gt=s(je),ve=l(je,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-pm6rj0"&&(ve.innerHTML=Yt),je.forEach(d),_t=s(f),W=l(f,"DIV",{class:!0});var Ie=T(W);_(oe.$$.fragment,Ie),bt=s(Ie),Me=l(Ie,"P",{"data-svelte-h":!0}),u(Me)!=="svelte-9erqj1"&&(Me.textContent=Qt),yt=s(Ie),_(Y.$$.fragment,Ie),Ie.forEach(d),xt=s(f),V=l(f,"DIV",{class:!0});var We=T(V);_(se.$$.fragment,We),wt=s(We),Te=l(We,"P",{"data-svelte-h":!0}),u(Te)!=="svelte-w22v11"&&(Te.textContent=St),$t=s(We),Je=l(We,"P",{"data-svelte-h":!0}),u(Je)!=="svelte-zdadya"&&(Je.textContent=Ht),We.forEach(d),vt=s(f),Q=l(f,"DIV",{class:!0});var Ye=T(Q);_(ne.$$.fragment,Ye),Mt=s(Ye),Ue=l(Ye,"P",{"data-svelte-h":!0}),u(Ue)!=="svelte-mffm0u"&&(Ue.textContent=zt),Ye.forEach(d),Tt=s(f),S=l(f,"DIV",{class:!0});var Qe=T(S);_(le.$$.fragment,Qe),Jt=s(Qe),Ce=l(Qe,"P",{"data-svelte-h":!0}),u(Ce)!=="svelte-1wrxd29"&&(Ce.textContent=Nt),Qe.forEach(d),Ut=s(f),R=l(f,"DIV",{class:!0});var Ve=T(R);_(ie.$$.fragment,Ve),Ct=s(Ve),Pe=l(Ve,"P",{"data-svelte-h":!0}),u(Pe)!=="svelte-1kp30gn"&&(Pe.textContent=Kt),Pt=s(Ve),Ze=l(Ve,"P",{"data-svelte-h":!0}),u(Ze)!=="svelte-pm6rj0"&&(Ze.innerHTML=Ot),Ve.forEach(d),Zt=s(f),L=l(f,"DIV",{class:!0});var Re=T(L);_(de.$$.fragment,Re),Gt=s(Re),Ge=l(Re,"P",{"data-svelte-h":!0}),u(Ge)!=="svelte-hnq104"&&(Ge.textContent=ea),kt=s(Re),_(H.$$.fragment,Re),Re.forEach(d),f.forEach(d),qe=s(e),_(pe.$$.fragment,e),De=s(e),Le=l(e,"P",{}),T(Le).forEach(d),this.h()},h(){J(r,"name","hf:doc:metadata"),J(r,"content",ua),J(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),J(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,i,m),b(h,e,m),v(e,a,m),v(e,$,m),v(e,Xe,m),b(q,e,m),v(e,Fe,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,G),b(ee,G,null),t(G,nt),t(G,be),t(G,lt),b(D,G,null),t(p,it),t(p,k),b(te,k,null),t(k,dt),t(k,ye),t(k,pt),t(k,xe),t(p,ft),t(p,j),b(ae,j,null),t(j,ct),t(j,we),t(j,mt),b(B,j,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(Y,W,null),t(p,xt),t(p,V),b(se,V,null),t(V,wt),t(V,Te),t(V,$t),t(V,Je),t(p,vt),t(p,Q),b(ne,Q,null),t(Q,Mt),t(Q,Ue),t(p,Tt),t(p,S),b(le,S,null),t(S,Jt),t(S,Ce),t(p,Ut),t(p,R),b(ie,R,null),t(R,Ct),t(R,Pe),t(R,Pt),t(R,Ze),t(p,Zt),t(p,L),b(de,L,null),t(L,Gt),t(L,Ge),t(L,kt),b(H,L,null),v(e,qe,m),b(pe,e,m),v(e,De,m),v(e,Le,m),Be=!0},p(e,[m]){const f={};m&2&&(f.$$scope={dirty:m,ctx:e}),q.$set(f);const A={};m&2&&(A.$$scope={dirty:m,ctx:e}),D.$set(A);const X={};m&2&&(X.$$scope={dirty:m,ctx:e}),B.$set(X);const F={};m&2&&(F.$$scope={dirty:m,ctx:e}),Y.$set(F);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(Y.$$.fragment,e),y(se.$$.fragment,e),y(ne.$$.fragment,e),y(le.$$.fragment,e),y(ie.$$.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(Y.$$.fragment,e),x(se.$$.fragment,e),x(ne.$$.fragment,e),x(le.$$.fragment,e),x(ie.$$.fragment,e),x(de.$$.fragment,e),x(H.$$.fragment,e),x(pe.$$.fragment,e),Be=!1},d(e){e&&(d(M),d(c),d(i),d(a),d($),d(Xe),d(Fe),d(Ee),d(p),d(qe),d(De),d(Le)),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(Y),w(se),w(ne),w(le),w(ie),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};

Xet Storage Details

Size:
35 kB
·
Xet hash:
730752a91a912df55584c418e395354449f1e5ffb61a6593d3eb3f4741bf1c28

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.