Buckets:
| import{s as sa,o as na,n as ze}from"../chunks/scheduler.53228c21.js";import{S as la,i as ia,e as s,s as r,c as g,h as da,a as n,d as i,b as o,f as J,g as _,j as h,k as T,l as t,m as v,n as b,t as y,o as x,p as w}from"../chunks/index.100fac89.js";import{C as pa}from"../chunks/CopyLLMTxtMenu.6af7d1d2.js";import{D as U}from"../chunks/Docstring.0359da8d.js";import{C as Ne}from"../chunks/CodeBlock.d30a6509.js";import{E as He}from"../chunks/ExampleCodeBlock.48f836be.js";import{H as oa,E as fa}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.ca59d7f8.js";function ca(C){let l,M="Example:",u,p,m;return p=new Ne({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">"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.unet.delete_adapters(<span class="hljs-string">"cinematic"</span>)`,wrap:!1}}),{c(){l=s("p"),l.textContent=M,u=r(),g(p.$$.fragment)},l(a){l=n(a,"P",{"data-svelte-h":!0}),h(l)!=="svelte-11lpom8"&&(l.textContent=M),u=o(a),_(p.$$.fragment,a)},m(a,$){v(a,l,$),v(a,u,$),b(p,a,$),m=!0},p:ze,i(a){m||(y(p.$$.fragment,a),m=!0)},o(a){x(p.$$.fragment,a),m=!1},d(a){a&&(i(l),i(u)),w(p,a)}}}function ma(C){let l,M="Example:",u,p,m;return p=new Ne({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">"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.unet.disable_lora()`,wrap:!1}}),{c(){l=s("p"),l.textContent=M,u=r(),g(p.$$.fragment)},l(a){l=n(a,"P",{"data-svelte-h":!0}),h(l)!=="svelte-11lpom8"&&(l.textContent=M),u=o(a),_(p.$$.fragment,a)},m(a,$){v(a,l,$),v(a,u,$),b(p,a,$),m=!0},p:ze,i(a){m||(y(p.$$.fragment,a),m=!0)},o(a){x(p.$$.fragment,a),m=!1},d(a){a&&(i(l),i(u)),w(p,a)}}}function ha(C){let l,M="Example:",u,p,m;return p=new Ne({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">"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.unet.enable_lora()`,wrap:!1}}),{c(){l=s("p"),l.textContent=M,u=r(),g(p.$$.fragment)},l(a){l=n(a,"P",{"data-svelte-h":!0}),h(l)!=="svelte-11lpom8"&&(l.textContent=M),u=o(a),_(p.$$.fragment,a)},m(a,$){v(a,l,$),v(a,u,$),b(p,a,$),m=!0},p:ze,i(a){m||(y(p.$$.fragment,a),m=!0)},o(a){x(p.$$.fragment,a),m=!1},d(a){a&&(i(l),i(u)),w(p,a)}}}function ua(C){let l,M="Example:",u,p,m;return p=new Ne({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">"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.unet.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(){l=s("p"),l.textContent=M,u=r(),g(p.$$.fragment)},l(a){l=n(a,"P",{"data-svelte-h":!0}),h(l)!=="svelte-11lpom8"&&(l.textContent=M),u=o(a),_(p.$$.fragment,a)},m(a,$){v(a,l,$),v(a,u,$),b(p,a,$),m=!0},p:ze,i(a){m||(y(p.$$.fragment,a),m=!0)},o(a){x(p.$$.fragment,a),m=!1},d(a){a&&(i(l),i(u)),w(p,a)}}}function ga(C){let l,M,u,p,m,a,$,Xe,H,Wt='Diffusers supports loading adapters such as <a href="../../tutorials/using_peft_for_inference">LoRA</a> with the <a href="https://huggingface.co/docs/peft/index" rel="nofollow">PEFT</a> library with the <a href="/docs/diffusers/pr_12747/en/api/loaders/peft#diffusers.loaders.PeftAdapterMixin">PeftAdapterMixin</a> class. This allows modeling classes in Diffusers like <a href="/docs/diffusers/pr_12747/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>, <a href="/docs/diffusers/pr_12747/en/api/models/sd3_transformer2d#diffusers.SD3Transformer2DModel">SD3Transformer2DModel</a> to operate with an adapter.',Ee,F,Vt='<p>Refer to the <a href="../../tutorials/using_peft_for_inference">Inference with PEFT</a> tutorial for an overview of how to use PEFT in Diffusers for inference.</p>',Fe,z,qe,d,N,Ke,fe,Lt=`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>.`,Oe,ce,Rt="Install the latest version of PEFT, and use this mixin to:",et,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>",tt,P,K,at,he,Xt="Gets the current list of active adapters of the model.",rt,ue,Et=`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>.`,ot,Z,O,st,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.`,nt,_e,qt=`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>.`,lt,k,ee,it,be,Bt="Delete an adapter’s LoRA layers from the underlying model.",dt,q,pt,G,te,ft,ye,Dt="Disable all adapters attached to the model and fallback to inference with the base model only.",ct,xe,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>.`,mt,j,ae,ht,we,Qt="Disables the active LoRA layers of the underlying model.",ut,B,gt,I,re,_t,$e,St=`Enable adapters that are attached to the model. The model uses <code>self.active_adapters()</code> to retrieve the list of | |
| adapters to enable.`,bt,ve,Ht=`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>.`,yt,W,oe,xt,Me,zt="Enables the active LoRA layers of the underlying model.",wt,D,$t,V,se,vt,Te,Nt="Enables the possibility to hotswap LoRA adapters.",Mt,Je,Kt=`Calling this method is only required when hotswapping adapters and if the model is compiled or if the ranks of | |
| the loaded adapters differ.`,Tt,Y,ne,Jt,Ue,Ot="Loads a LoRA adapter into the underlying model.",Ut,Q,le,Ct,Ce,ea="Save the LoRA parameters corresponding to the underlying model.",Pt,L,ie,Zt,Pe,ta="Sets a specific adapter by forcing the model to only use that adapter and disables the other adapters.",kt,Ze,aa=`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>.`,Gt,R,de,jt,ke,ra="Set the currently active adapters for use in the diffusion network (e.g. unet, transformer, etc.).",It,S,Be,pe,De,Ae,Ye;return m=new pa({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),$=new oa({props:{title:"PEFT",local:"peft",headingTag:"h1"}}),z=new oa({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_12747/src/diffusers/loaders/peft.py#L71"}}),K=new U({props:{name:"active_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.active_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12747/src/diffusers/loaders/peft.py#L639"}}),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>) — | |
| 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_12747/src/diffusers/loaders/peft.py#L507"}}),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>) — | |
| The names (single string or list of strings) of the adapter to delete.`,name:"adapter_names"}],source:"https://github.com/huggingface/diffusers/blob/vr_12747/src/diffusers/loaders/peft.py#L762"}}),q=new He({props:{anchor:"diffusers.loaders.PeftAdapterMixin.delete_adapters.example",$$slots:{default:[ca]},$$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_12747/src/diffusers/loaders/peft.py#L594"}}),ae=new U({props:{name:"disable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12747/src/diffusers/loaders/peft.py#L716"}}),B=new He({props:{anchor:"diffusers.loaders.PeftAdapterMixin.disable_lora.example",$$slots:{default:[ma]},$$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_12747/src/diffusers/loaders/peft.py#L616"}}),oe=new U({props:{name:"enable_lora",anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora",parameters:[],source:"https://github.com/huggingface/diffusers/blob/vr_12747/src/diffusers/loaders/peft.py#L739"}}),D=new He({props:{anchor:"diffusers.loaders.PeftAdapterMixin.enable_lora.example",$$slots:{default:[ha]},$$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>) — | |
| 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_12747/src/diffusers/loaders/peft.py#L800"}}),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>) — | |
| 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_12747/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_12747/src/diffusers/loaders/peft.py#L94"}}),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>) — | |
| 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_12747/src/diffusers/loaders/peft.py#L383"}}),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]])) — | |
| 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_12747/src/diffusers/loaders/peft.py#L545"}}),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>) — | |
| 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_12747/src/diffusers/loaders/peft.py#L451"}}),S=new He({props:{anchor:"diffusers.loaders.PeftAdapterMixin.set_adapters.example",$$slots:{default:[ua]},$$scope:{ctx:C}}}),pe=new fa({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/loaders/peft.md"}}),{c(){l=s("meta"),M=r(),u=s("p"),p=r(),g(m.$$.fragment),a=r(),g($.$$.fragment),Xe=r(),H=s("p"),H.innerHTML=Wt,Ee=r(),F=s("blockquote"),F.innerHTML=Vt,Fe=r(),g(z.$$.fragment),qe=r(),d=s("div"),g(N.$$.fragment),Ke=r(),fe=s("p"),fe.innerHTML=Lt,Oe=r(),ce=s("p"),ce.textContent=Rt,et=r(),me=s("ul"),me.innerHTML=At,tt=r(),P=s("div"),g(K.$$.fragment),at=r(),he=s("p"),he.textContent=Xt,rt=r(),ue=s("p"),ue.innerHTML=Et,ot=r(),Z=s("div"),g(O.$$.fragment),st=r(),ge=s("p"),ge.textContent=Ft,nt=r(),_e=s("p"),_e.innerHTML=qt,lt=r(),k=s("div"),g(ee.$$.fragment),it=r(),be=s("p"),be.textContent=Bt,dt=r(),g(q.$$.fragment),pt=r(),G=s("div"),g(te.$$.fragment),ft=r(),ye=s("p"),ye.textContent=Dt,ct=r(),xe=s("p"),xe.innerHTML=Yt,mt=r(),j=s("div"),g(ae.$$.fragment),ht=r(),we=s("p"),we.textContent=Qt,ut=r(),g(B.$$.fragment),gt=r(),I=s("div"),g(re.$$.fragment),_t=r(),$e=s("p"),$e.innerHTML=St,bt=r(),ve=s("p"),ve.innerHTML=Ht,yt=r(),W=s("div"),g(oe.$$.fragment),xt=r(),Me=s("p"),Me.textContent=zt,wt=r(),g(D.$$.fragment),$t=r(),V=s("div"),g(se.$$.fragment),vt=r(),Te=s("p"),Te.textContent=Nt,Mt=r(),Je=s("p"),Je.textContent=Kt,Tt=r(),Y=s("div"),g(ne.$$.fragment),Jt=r(),Ue=s("p"),Ue.textContent=Ot,Ut=r(),Q=s("div"),g(le.$$.fragment),Ct=r(),Ce=s("p"),Ce.textContent=ea,Pt=r(),L=s("div"),g(ie.$$.fragment),Zt=r(),Pe=s("p"),Pe.textContent=ta,kt=r(),Ze=s("p"),Ze.innerHTML=aa,Gt=r(),R=s("div"),g(de.$$.fragment),jt=r(),ke=s("p"),ke.textContent=ra,It=r(),g(S.$$.fragment),Be=r(),g(pe.$$.fragment),De=r(),Ae=s("p"),this.h()},l(e){const c=da("svelte-u9bgzb",document.head);l=n(c,"META",{name:!0,content:!0}),c.forEach(i),M=o(e),u=n(e,"P",{}),J(u).forEach(i),p=o(e),_(m.$$.fragment,e),a=o(e),_($.$$.fragment,e),Xe=o(e),H=n(e,"P",{"data-svelte-h":!0}),h(H)!=="svelte-2n5nhc"&&(H.innerHTML=Wt),Ee=o(e),F=n(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),h(F)!=="svelte-kcid51"&&(F.innerHTML=Vt),Fe=o(e),_(z.$$.fragment,e),qe=o(e),d=n(e,"DIV",{class:!0});var f=J(d);_(N.$$.fragment,f),Ke=o(f),fe=n(f,"P",{"data-svelte-h":!0}),h(fe)!=="svelte-16jad6u"&&(fe.innerHTML=Lt),Oe=o(f),ce=n(f,"P",{"data-svelte-h":!0}),h(ce)!=="svelte-jgx411"&&(ce.textContent=Rt),et=o(f),me=n(f,"UL",{"data-svelte-h":!0}),h(me)!=="svelte-70o87y"&&(me.innerHTML=At),tt=o(f),P=n(f,"DIV",{class:!0});var A=J(P);_(K.$$.fragment,A),at=o(A),he=n(A,"P",{"data-svelte-h":!0}),h(he)!=="svelte-1i9yvzx"&&(he.textContent=Xt),rt=o(A),ue=n(A,"P",{"data-svelte-h":!0}),h(ue)!=="svelte-pm6rj0"&&(ue.innerHTML=Et),A.forEach(i),ot=o(f),Z=n(f,"DIV",{class:!0});var X=J(Z);_(O.$$.fragment,X),st=o(X),ge=n(X,"P",{"data-svelte-h":!0}),h(ge)!=="svelte-ayg1h"&&(ge.textContent=Ft),nt=o(X),_e=n(X,"P",{"data-svelte-h":!0}),h(_e)!=="svelte-m719pe"&&(_e.innerHTML=qt),X.forEach(i),lt=o(f),k=n(f,"DIV",{class:!0});var E=J(k);_(ee.$$.fragment,E),it=o(E),be=n(E,"P",{"data-svelte-h":!0}),h(be)!=="svelte-1oumhy2"&&(be.textContent=Bt),dt=o(E),_(q.$$.fragment,E),E.forEach(i),pt=o(f),G=n(f,"DIV",{class:!0});var Ge=J(G);_(te.$$.fragment,Ge),ft=o(Ge),ye=n(Ge,"P",{"data-svelte-h":!0}),h(ye)!=="svelte-stjif2"&&(ye.textContent=Dt),ct=o(Ge),xe=n(Ge,"P",{"data-svelte-h":!0}),h(xe)!=="svelte-pm6rj0"&&(xe.innerHTML=Yt),Ge.forEach(i),mt=o(f),j=n(f,"DIV",{class:!0});var je=J(j);_(ae.$$.fragment,je),ht=o(je),we=n(je,"P",{"data-svelte-h":!0}),h(we)!=="svelte-1w71mps"&&(we.textContent=Qt),ut=o(je),_(B.$$.fragment,je),je.forEach(i),gt=o(f),I=n(f,"DIV",{class:!0});var Ie=J(I);_(re.$$.fragment,Ie),_t=o(Ie),$e=n(Ie,"P",{"data-svelte-h":!0}),h($e)!=="svelte-hmbjwp"&&($e.innerHTML=St),bt=o(Ie),ve=n(Ie,"P",{"data-svelte-h":!0}),h(ve)!=="svelte-pm6rj0"&&(ve.innerHTML=Ht),Ie.forEach(i),yt=o(f),W=n(f,"DIV",{class:!0});var We=J(W);_(oe.$$.fragment,We),xt=o(We),Me=n(We,"P",{"data-svelte-h":!0}),h(Me)!=="svelte-9erqj1"&&(Me.textContent=zt),wt=o(We),_(D.$$.fragment,We),We.forEach(i),$t=o(f),V=n(f,"DIV",{class:!0});var Ve=J(V);_(se.$$.fragment,Ve),vt=o(Ve),Te=n(Ve,"P",{"data-svelte-h":!0}),h(Te)!=="svelte-w22v11"&&(Te.textContent=Nt),Mt=o(Ve),Je=n(Ve,"P",{"data-svelte-h":!0}),h(Je)!=="svelte-zdadya"&&(Je.textContent=Kt),Ve.forEach(i),Tt=o(f),Y=n(f,"DIV",{class:!0});var Qe=J(Y);_(ne.$$.fragment,Qe),Jt=o(Qe),Ue=n(Qe,"P",{"data-svelte-h":!0}),h(Ue)!=="svelte-mffm0u"&&(Ue.textContent=Ot),Qe.forEach(i),Ut=o(f),Q=n(f,"DIV",{class:!0});var Se=J(Q);_(le.$$.fragment,Se),Ct=o(Se),Ce=n(Se,"P",{"data-svelte-h":!0}),h(Ce)!=="svelte-1wrxd29"&&(Ce.textContent=ea),Se.forEach(i),Pt=o(f),L=n(f,"DIV",{class:!0});var Le=J(L);_(ie.$$.fragment,Le),Zt=o(Le),Pe=n(Le,"P",{"data-svelte-h":!0}),h(Pe)!=="svelte-1kp30gn"&&(Pe.textContent=ta),kt=o(Le),Ze=n(Le,"P",{"data-svelte-h":!0}),h(Ze)!=="svelte-pm6rj0"&&(Ze.innerHTML=aa),Le.forEach(i),Gt=o(f),R=n(f,"DIV",{class:!0});var Re=J(R);_(de.$$.fragment,Re),jt=o(Re),ke=n(Re,"P",{"data-svelte-h":!0}),h(ke)!=="svelte-hnq104"&&(ke.textContent=ra),It=o(Re),_(S.$$.fragment,Re),Re.forEach(i),f.forEach(i),Be=o(e),_(pe.$$.fragment,e),De=o(e),Ae=n(e,"P",{}),J(Ae).forEach(i),this.h()},h(){T(l,"name","hf:doc:metadata"),T(l,"content",_a),T(F,"class","tip"),T(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(Y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(R,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),T(d,"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,c){t(document.head,l),v(e,M,c),v(e,u,c),v(e,p,c),b(m,e,c),v(e,a,c),b($,e,c),v(e,Xe,c),v(e,H,c),v(e,Ee,c),v(e,F,c),v(e,Fe,c),b(z,e,c),v(e,qe,c),v(e,d,c),b(N,d,null),t(d,Ke),t(d,fe),t(d,Oe),t(d,ce),t(d,et),t(d,me),t(d,tt),t(d,P),b(K,P,null),t(P,at),t(P,he),t(P,rt),t(P,ue),t(d,ot),t(d,Z),b(O,Z,null),t(Z,st),t(Z,ge),t(Z,nt),t(Z,_e),t(d,lt),t(d,k),b(ee,k,null),t(k,it),t(k,be),t(k,dt),b(q,k,null),t(d,pt),t(d,G),b(te,G,null),t(G,ft),t(G,ye),t(G,ct),t(G,xe),t(d,mt),t(d,j),b(ae,j,null),t(j,ht),t(j,we),t(j,ut),b(B,j,null),t(d,gt),t(d,I),b(re,I,null),t(I,_t),t(I,$e),t(I,bt),t(I,ve),t(d,yt),t(d,W),b(oe,W,null),t(W,xt),t(W,Me),t(W,wt),b(D,W,null),t(d,$t),t(d,V),b(se,V,null),t(V,vt),t(V,Te),t(V,Mt),t(V,Je),t(d,Tt),t(d,Y),b(ne,Y,null),t(Y,Jt),t(Y,Ue),t(d,Ut),t(d,Q),b(le,Q,null),t(Q,Ct),t(Q,Ce),t(d,Pt),t(d,L),b(ie,L,null),t(L,Zt),t(L,Pe),t(L,kt),t(L,Ze),t(d,Gt),t(d,R),b(de,R,null),t(R,jt),t(R,ke),t(R,It),b(S,R,null),v(e,Be,c),b(pe,e,c),v(e,De,c),v(e,Ae,c),Ye=!0},p(e,[c]){const f={};c&2&&(f.$$scope={dirty:c,ctx:e}),q.$set(f);const A={};c&2&&(A.$$scope={dirty:c,ctx:e}),B.$set(A);const X={};c&2&&(X.$$scope={dirty:c,ctx:e}),D.$set(X);const E={};c&2&&(E.$$scope={dirty:c,ctx:e}),S.$set(E)},i(e){Ye||(y(m.$$.fragment,e),y($.$$.fragment,e),y(z.$$.fragment,e),y(N.$$.fragment,e),y(K.$$.fragment,e),y(O.$$.fragment,e),y(ee.$$.fragment,e),y(q.$$.fragment,e),y(te.$$.fragment,e),y(ae.$$.fragment,e),y(B.$$.fragment,e),y(re.$$.fragment,e),y(oe.$$.fragment,e),y(D.$$.fragment,e),y(se.$$.fragment,e),y(ne.$$.fragment,e),y(le.$$.fragment,e),y(ie.$$.fragment,e),y(de.$$.fragment,e),y(S.$$.fragment,e),y(pe.$$.fragment,e),Ye=!0)},o(e){x(m.$$.fragment,e),x($.$$.fragment,e),x(z.$$.fragment,e),x(N.$$.fragment,e),x(K.$$.fragment,e),x(O.$$.fragment,e),x(ee.$$.fragment,e),x(q.$$.fragment,e),x(te.$$.fragment,e),x(ae.$$.fragment,e),x(B.$$.fragment,e),x(re.$$.fragment,e),x(oe.$$.fragment,e),x(D.$$.fragment,e),x(se.$$.fragment,e),x(ne.$$.fragment,e),x(le.$$.fragment,e),x(ie.$$.fragment,e),x(de.$$.fragment,e),x(S.$$.fragment,e),x(pe.$$.fragment,e),Ye=!1},d(e){e&&(i(M),i(u),i(p),i(a),i(Xe),i(H),i(Ee),i(F),i(Fe),i(qe),i(d),i(Be),i(De),i(Ae)),i(l),w(m,e),w($,e),w(z,e),w(N),w(K),w(O),w(ee),w(q),w(te),w(ae),w(B),w(re),w(oe),w(D),w(se),w(ne),w(le),w(ie),w(de),w(S),w(pe,e)}}}const _a='{"title":"PEFT","local":"peft","sections":[{"title":"PeftAdapterMixin","local":"diffusers.loaders.PeftAdapterMixin","sections":[],"depth":2}],"depth":1}';function ba(C){return na(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ja extends la{constructor(l){super(),ia(this,l,ba,ga,sa,{})}}export{Ja as component}; | |
Xet Storage Details
- Size:
- 35.1 kB
- Xet hash:
- 77a8a0c1f9caa38a264a138cdba8f34e645d6c86d98a22db181fe1ae2b4a2667
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.