Buckets:
| import{s as aa,o as ra,n as Le}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 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 la}from"../chunks/Tip.1d9b8c37.js";import{D as J}from"../chunks/Docstring.d7448bb3.js";import{C as He}from"../chunks/CodeBlock.a9c4becf.js";import{E as Qe}from"../chunks/ExampleCodeBlock.bdbc5937.js";import{H as ta,E as ia}from"../chunks/getInferenceSnippets.1d18021a.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:Le,d(c){c&&d(r)}}}function pa(C){let r,M="Example:",c,i,h;return i=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">"stabilityai/stable-diffusion-xl-base-1.0"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipeline.load_lora_weights( | |
| <span class="hljs-string">"jbilcke-hf/sdxl-cinematic-1"</span>, weight_name=<span class="hljs-string">"pytorch_lora_weights.safetensors"</span>, adapter_names=<span class="hljs-string">"cinematic"</span> | |
| ) | |
| pipeline.delete_adapters(<span class="hljs-string">"cinematic"</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:Le,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:"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">"stabilityai/stable-diffusion-xl-base-1.0"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipeline.load_lora_weights( | |
| <span class="hljs-string">"jbilcke-hf/sdxl-cinematic-1"</span>, weight_name=<span class="hljs-string">"pytorch_lora_weights.safetensors"</span>, adapter_name=<span class="hljs-string">"cinematic"</span> | |
| ) | |
| pipeline.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:Le,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:"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">"stabilityai/stable-diffusion-xl-base-1.0"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipeline.load_lora_weights( | |
| <span class="hljs-string">"jbilcke-hf/sdxl-cinematic-1"</span>, weight_name=<span class="hljs-string">"pytorch_lora_weights.safetensors"</span>, adapter_name=<span class="hljs-string">"cinematic"</span> | |
| ) | |
| pipeline.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:Le,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:"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">"stabilityai/stable-diffusion-xl-base-1.0"</span>, torch_dtype=torch.float16 | |
| ).to(<span class="hljs-string">"cuda"</span>) | |
| pipeline.load_lora_weights( | |
| <span class="hljs-string">"jbilcke-hf/sdxl-cinematic-1"</span>, weight_name=<span class="hljs-string">"pytorch_lora_weights.safetensors"</span>, adapter_name=<span class="hljs-string">"cinematic"</span> | |
| ) | |
| pipeline.load_lora_weights(<span class="hljs-string">"nerijs/pixel-art-xl"</span>, weight_name=<span class="hljs-string">"pixel-art-xl.safetensors"</span>, adapter_name=<span class="hljs-string">"pixel"</span>) | |
| pipeline.set_adapters([<span class="hljs-string">"cinematic"</span>, <span class="hljs-string">"pixel"</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:Le,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,$,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/pr_11739/en/api/loaders/peft#diffusers.loaders.PeftAdapterMixin">PeftAdapterMixin</a> class. This allows modeling classes in Diffusers like <a href="/docs/diffusers/pr_11739/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>, <a href="/docs/diffusers/pr_11739/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> to operate with an adapter.',Fe,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,Lt=`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,Ft=`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.",lt,B,it,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,Bt="Disables the active LoRA layers of the underlying model.",mt,D,ht,I,re,ut,$e,Dt=`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,St="Enables the active LoRA layers of the underlying model.",yt,Y,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,S,ne,Mt,Je,zt="Loads a LoRA adapter into the underlying model.",Tt,Q,le,Ut,Ce,Nt="Save the LoRA parameters corresponding to the underlying model.",Jt,X,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,R,de,jt,je,ea="Set the currently active adapters for use in the UNet.",Gt,H,qe,pe,Be,Re,De;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 J({props:{name:"class diffusers.loaders.PeftAdapterMixin",anchor:"diffusers.loaders.PeftAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_11739/src/diffusers/loaders/peft.py#L67"}}),K=new J({props:{name:"active_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.active_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_11739/src/diffusers/loaders/peft.py#L629"}}),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>) — | |
| 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>"default"</code>) — | |
| 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_11739/src/diffusers/loaders/peft.py#L497"}}),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>) — | |
| The names (single string or list of strings) of the adapter to delete.`,name:"adapter_names"}],source:"https://github.com/huggingface/diffusers/blob/vr_11739/src/diffusers/loaders/peft.py#L747"}}),B=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/vr_11739/src/diffusers/loaders/peft.py#L584"}}),ae=new J({props:{name:"disable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_11739/src/diffusers/loaders/peft.py#L701"}}),D=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/vr_11739/src/diffusers/loaders/peft.py#L606"}}),oe=new J({props:{name:"enable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_11739/src/diffusers/loaders/peft.py#L724"}}),Y=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>) — | |
| 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>"error"</code>) — | |
| How to handle the case when the model is already compiled, which should generally be avoided. The | |
| options are:</p> | |
| <ul> | |
| <li>“error” (default): raise an error</li> | |
| <li>“warn”: issue a warning</li> | |
| <li>“ignore”: do nothing</li> | |
| </ul>`,name:"check_compiled"}],source:"https://github.com/huggingface/diffusers/blob/vr_11739/src/diffusers/loaders/peft.py#L783"}}),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>) — | |
| 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_11739/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>) — 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>) — | |
| 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>) — | |
| 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>) — | |
| A dictionary of proxy servers to use by protocol or endpoint, for example, <code>{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}</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>) — | |
| Whether to only load local model weights and configuration files or not. If set to <code>True</code>, the model | |
| won’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>) — | |
| 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>"main"</code>) — | |
| 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>""</code>) — | |
| 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>) — | |
| 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>) — | |
| 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> — (<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_11739/src/diffusers/loaders/peft.py#L101"}}),le=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>) — | |
| Directory to save LoRA parameters to. Will be created if it doesn’t exist.`,name:"save_directory"},{anchor:"diffusers.loaders.PeftAdapterMixin.save_lora_adapter.adapter_name",description:`<strong>adapter_name</strong> — (<code>str</code>, defaults to “default”): 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>) — | |
| 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>) — | |
| 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> — (<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_11739/src/diffusers/loaders/peft.py#L373"}}),ie=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]])) — | |
| 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_11739/src/diffusers/loaders/peft.py#L535"}}),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>) — | |
| 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>) — | |
| 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_11739/src/diffusers/loaders/peft.py#L441"}}),H=new Qe({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=kt,Fe=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=Lt,ot=o(),_e=n("p"),_e.innerHTML=Ft,st=o(),j=n("div"),g(ee.$$.fragment),nt=o(),be=n("p"),be.textContent=Vt,lt=o(),g(B.$$.fragment),it=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=Bt,mt=o(),g(D.$$.fragment),ht=o(),I=n("div"),g(re.$$.fragment),ut=o(),$e=n("p"),$e.innerHTML=Dt,gt=o(),ve=n("p"),ve.innerHTML=Yt,_t=o(),W=n("div"),g(oe.$$.fragment),bt=o(),Me=n("p"),Me.textContent=St,yt=o(),g(Y.$$.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(),S=n("div"),g(ne.$$.fragment),Mt=o(),Je=n("p"),Je.textContent=zt,Tt=o(),Q=n("div"),g(le.$$.fragment),Ut=o(),Ce=n("p"),Ce.textContent=Nt,Jt=o(),X=n("div"),g(ie.$$.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),Be=o(),Re=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-d5s1gy"&&($.innerHTML=kt),Fe=s(e),_(q.$$.fragment,e),Ve=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=At),Oe=s(f),P=l(f,"DIV",{class:!0});var L=T(P);_(K.$$.fragment,L),et=s(L),he=l(L,"P",{"data-svelte-h":!0}),u(he)!=="svelte-1i9yvzx"&&(he.textContent=Xt),tt=s(L),ue=l(L,"P",{"data-svelte-h":!0}),u(ue)!=="svelte-pm6rj0"&&(ue.innerHTML=Rt),L.forEach(d),at=s(f),Z=l(f,"DIV",{class:!0});var F=T(Z);_(O.$$.fragment,F),rt=s(F),ge=l(F,"P",{"data-svelte-h":!0}),u(ge)!=="svelte-ayg1h"&&(ge.textContent=Lt),ot=s(F),_e=l(F,"P",{"data-svelte-h":!0}),u(_e)!=="svelte-m719pe"&&(_e.innerHTML=Ft),F.forEach(d),st=s(f),j=l(f,"DIV",{class:!0});var V=T(j);_(ee.$$.fragment,V),nt=s(V),be=l(V,"P",{"data-svelte-h":!0}),u(be)!=="svelte-1oumhy2"&&(be.textContent=Vt),lt=s(V),_(B.$$.fragment,V),V.forEach(d),it=s(f),G=l(f,"DIV",{class:!0});var E=T(G);_(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),k=l(f,"DIV",{class:!0});var Ge=T(k);_(ae.$$.fragment,Ge),ct=s(Ge),we=l(Ge,"P",{"data-svelte-h":!0}),u(we)!=="svelte-1w71mps"&&(we.textContent=Bt),mt=s(Ge),_(D.$$.fragment,Ge),Ge.forEach(d),ht=s(f),I=l(f,"DIV",{class:!0});var ke=T(I);_(re.$$.fragment,ke),ut=s(ke),$e=l(ke,"P",{"data-svelte-h":!0}),u($e)!=="svelte-hmbjwp"&&($e.innerHTML=Dt),gt=s(ke),ve=l(ke,"P",{"data-svelte-h":!0}),u(ve)!=="svelte-pm6rj0"&&(ve.innerHTML=Yt),ke.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=St),yt=s(Ie),_(Y.$$.fragment,Ie),Ie.forEach(d),xt=s(f),A=l(f,"DIV",{class:!0});var We=T(A);_(se.$$.fragment,We),wt=s(We),Te=l(We,"P",{"data-svelte-h":!0}),u(Te)!=="svelte-w22v11"&&(Te.textContent=Qt),$t=s(We),Ue=l(We,"P",{"data-svelte-h":!0}),u(Ue)!=="svelte-zdadya"&&(Ue.textContent=Ht),We.forEach(d),vt=s(f),S=l(f,"DIV",{class:!0});var Ye=T(S);_(ne.$$.fragment,Ye),Mt=s(Ye),Je=l(Ye,"P",{"data-svelte-h":!0}),u(Je)!=="svelte-mffm0u"&&(Je.textContent=zt),Ye.forEach(d),Tt=s(f),Q=l(f,"DIV",{class:!0});var Se=T(Q);_(le.$$.fragment,Se),Ut=s(Se),Ce=l(Se,"P",{"data-svelte-h":!0}),u(Ce)!=="svelte-1wrxd29"&&(Ce.textContent=Nt),Se.forEach(d),Jt=s(f),X=l(f,"DIV",{class:!0});var Ae=T(X);_(ie.$$.fragment,Ae),Ct=s(Ae),Pe=l(Ae,"P",{"data-svelte-h":!0}),u(Pe)!=="svelte-1kp30gn"&&(Pe.textContent=Kt),Pt=s(Ae),Ze=l(Ae,"P",{"data-svelte-h":!0}),u(Ze)!=="svelte-pm6rj0"&&(Ze.innerHTML=Ot),Ae.forEach(d),Zt=s(f),R=l(f,"DIV",{class:!0});var Xe=T(R);_(de.$$.fragment,Xe),jt=s(Xe),je=l(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),Be=s(e),Re=l(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(S,"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,i,m),b(h,e,m),v(e,a,m),v(e,$,m),v(e,Fe,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,lt),b(B,j,null),t(p,it),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(D,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(Y,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,S),b(ne,S,null),t(S,Mt),t(S,Je),t(p,Tt),t(p,Q),b(le,Q,null),t(Q,Ut),t(Q,Ce),t(p,Jt),t(p,X),b(ie,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,Be,m),v(e,Re,m),De=!0},p(e,[m]){const f={};m&2&&(f.$$scope={dirty:m,ctx:e}),q.$set(f);const L={};m&2&&(L.$$scope={dirty:m,ctx:e}),B.$set(L);const F={};m&2&&(F.$$scope={dirty:m,ctx:e}),D.$set(F);const V={};m&2&&(V.$$scope={dirty:m,ctx:e}),Y.$set(V);const E={};m&2&&(E.$$scope={dirty:m,ctx:e}),H.$set(E)},i(e){De||(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(B.$$.fragment,e),y(te.$$.fragment,e),y(ae.$$.fragment,e),y(D.$$.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),De=!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(B.$$.fragment,e),x(te.$$.fragment,e),x(ae.$$.fragment,e),x(D.$$.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),De=!1},d(e){e&&(d(M),d(c),d(i),d(a),d($),d(Fe),d(Ve),d(Ee),d(p),d(qe),d(Be),d(Re)),d(r),w(h,e),w(q,e),w(z,e),w(N),w(K),w(O),w(ee),w(B),w(te),w(ae),w(D),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:
- 34.9 kB
- Xet hash:
- c9527c7c6171abbfcb40e24569d86bc5ac2e75fa7fa6d85d052c15803b844b24
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.