import{s as Be,o as Je,n as Ke}from"../chunks/scheduler.182ea377.js";import{S as Oe,i as Qe,g as n,s as a,r as _,A as We,h as s,f as i,c as r,j as y,u as b,x as p,k as E,y as t,a as m,v as x,d as P,t as T,w}from"../chunks/index.abf12888.js";import{T as Xe}from"../chunks/Tip.230e2334.js";import{D as re}from"../chunks/Docstring.93f6f462.js";import{H as Ne}from"../chunks/Heading.16916d63.js";function Ye(se){let f,L='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(){f=n("p"),f.innerHTML=L},l(u){f=s(u,"P",{"data-svelte-h":!0}),p(f)!=="svelte-1yhqcl5"&&(f.innerHTML=L)},m(u,k){m(u,f,k)},p:Ke,d(u){u&&i(f)}}}function Ze(se){let f,L,u,k,C,oe,A,Ae='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/v0.27.1/en/api/loaders/peft#diffusers.loaders.PeftAdapterMixin">PeftAdapterMixin</a> class. This allows modeling classes in Diffusers like <a href="/docs/diffusers/v0.27.1/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a> to load an adapter.',ie,M,de,H,le,o,F,me,q,He=`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 transformer-based model, check out the PEFT <a href="https://huggingface.co/docs/peft/index" rel="nofollow">documentation</a>.`,ue,z,Fe="Install the latest version of PEFT, and use this mixin to:",ce,S,De="<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>",he,c,D,ge,R,Ie="Gets the current list of active adapters of the model.",ve,G,je=`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>.`,$e,h,I,_e,N,Ue=`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.`,be,B,Ve=`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>.`,xe,g,j,Pe,J,ke="Disable all adapters attached to the model and fallback to inference with the base model only.",Te,K,qe=`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>.`,we,v,U,Me,O,ze=`Enable adapters that are attached to the model. The model uses <code>self.active_adapters()</code> to retrieve the
list of adapters to enable.`,ye,Q,Se=`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>.`,Ee,$,V,Le,W,Re="Sets a specific adapter by forcing the model to only use that adapter and disables the other adapters.",Ce,X,Ge=`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>.`,fe,ne,pe;return C=new Ne({props:{title:"PEFT",local:"peft",headingTag:"h1"}}),M=new Xe({props:{$$slots:{default:[Ye]},$$scope:{ctx:se}}}),H=new Ne({props:{title:"PeftAdapterMixin",local:"diffusers.loaders.PeftAdapterMixin",headingTag:"h2"}}),F=new re({props:{name:"class diffusers.loaders.PeftAdapterMixin",anchor:"diffusers.loaders.PeftAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.27.1/src/diffusers/loaders/peft.py#L20"}}),D=new re({props:{name:"active_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.active_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.27.1/src/diffusers/loaders/peft.py#L167"}}),I=new re({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/v0.27.1/src/diffusers/loaders/peft.py#L35"}}),j=new re({props:{name:"disable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.disable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.27.1/src/diffusers/loaders/peft.py#L122"}}),U=new re({props:{name:"enable_adapters",anchor:"diffusers.loaders.PeftAdapterMixin.enable_adapters",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.27.1/src/diffusers/loaders/peft.py#L144"}}),V=new re({props:{name:"set_adapter",anchor:"diffusers.loaders.PeftAdapterMixin.set_adapter",parameters:[{name:"adapter_name",val:": Union"}],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/v0.27.1/src/diffusers/loaders/peft.py#L73"}}),{c(){f=n("meta"),L=a(),u=n("p"),k=a(),_(C.$$.fragment),oe=a(),A=n("p"),A.innerHTML=Ae,ie=a(),_(M.$$.fragment),de=a(),_(H.$$.fragment),le=a(),o=n("div"),_(F.$$.fragment),me=a(),q=n("p"),q.innerHTML=He,ue=a(),z=n("p"),z.textContent=Fe,ce=a(),S=n("ul"),S.innerHTML=De,he=a(),c=n("div"),_(D.$$.fragment),ge=a(),R=n("p"),R.textContent=Ie,ve=a(),G=n("p"),G.innerHTML=je,$e=a(),h=n("div"),_(I.$$.fragment),_e=a(),N=n("p"),N.textContent=Ue,be=a(),B=n("p"),B.innerHTML=Ve,xe=a(),g=n("div"),_(j.$$.fragment),Pe=a(),J=n("p"),J.textContent=ke,Te=a(),K=n("p"),K.innerHTML=qe,we=a(),v=n("div"),_(U.$$.fragment),Me=a(),O=n("p"),O.innerHTML=ze,ye=a(),Q=n("p"),Q.innerHTML=Se,Ee=a(),$=n("div"),_(V.$$.fragment),Le=a(),W=n("p"),W.textContent=Re,Ce=a(),X=n("p"),X.innerHTML=Ge,fe=a(),ne=n("p"),this.h()},l(e){const l=We("svelte-u9bgzb",document.head);f=s(l,"META",{name:!0,content:!0}),l.forEach(i),L=r(e),u=s(e,"P",{}),y(u).forEach(i),k=r(e),b(C.$$.fragment,e),oe=r(e),A=s(e,"P",{"data-svelte-h":!0}),p(A)!=="svelte-3zuzep"&&(A.innerHTML=Ae),ie=r(e),b(M.$$.fragment,e),de=r(e),b(H.$$.fragment,e),le=r(e),o=s(e,"DIV",{class:!0});var d=y(o);b(F.$$.fragment,d),me=r(d),q=s(d,"P",{"data-svelte-h":!0}),p(q)!=="svelte-opsxtu"&&(q.innerHTML=He),ue=r(d),z=s(d,"P",{"data-svelte-h":!0}),p(z)!=="svelte-jgx411"&&(z.textContent=Fe),ce=r(d),S=s(d,"UL",{"data-svelte-h":!0}),p(S)!=="svelte-70o87y"&&(S.innerHTML=De),he=r(d),c=s(d,"DIV",{class:!0});var Y=y(c);b(D.$$.fragment,Y),ge=r(Y),R=s(Y,"P",{"data-svelte-h":!0}),p(R)!=="svelte-1i9yvzx"&&(R.textContent=Ie),ve=r(Y),G=s(Y,"P",{"data-svelte-h":!0}),p(G)!=="svelte-pm6rj0"&&(G.innerHTML=je),Y.forEach(i),$e=r(d),h=s(d,"DIV",{class:!0});var Z=y(h);b(I.$$.fragment,Z),_e=r(Z),N=s(Z,"P",{"data-svelte-h":!0}),p(N)!=="svelte-ayg1h"&&(N.textContent=Ue),be=r(Z),B=s(Z,"P",{"data-svelte-h":!0}),p(B)!=="svelte-m719pe"&&(B.innerHTML=Ve),Z.forEach(i),xe=r(d),g=s(d,"DIV",{class:!0});var ee=y(g);b(j.$$.fragment,ee),Pe=r(ee),J=s(ee,"P",{"data-svelte-h":!0}),p(J)!=="svelte-stjif2"&&(J.textContent=ke),Te=r(ee),K=s(ee,"P",{"data-svelte-h":!0}),p(K)!=="svelte-pm6rj0"&&(K.innerHTML=qe),ee.forEach(i),we=r(d),v=s(d,"DIV",{class:!0});var te=y(v);b(U.$$.fragment,te),Me=r(te),O=s(te,"P",{"data-svelte-h":!0}),p(O)!=="svelte-jhdt8t"&&(O.innerHTML=ze),ye=r(te),Q=s(te,"P",{"data-svelte-h":!0}),p(Q)!=="svelte-pm6rj0"&&(Q.innerHTML=Se),te.forEach(i),Ee=r(d),$=s(d,"DIV",{class:!0});var ae=y($);b(V.$$.fragment,ae),Le=r(ae),W=s(ae,"P",{"data-svelte-h":!0}),p(W)!=="svelte-1kp30gn"&&(W.textContent=Re),Ce=r(ae),X=s(ae,"P",{"data-svelte-h":!0}),p(X)!=="svelte-pm6rj0"&&(X.innerHTML=Ge),ae.forEach(i),d.forEach(i),fe=r(e),ne=s(e,"P",{}),y(ne).forEach(i),this.h()},h(){E(f,"name","hf:doc:metadata"),E(f,"content",et),E(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),E(o,"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,l){t(document.head,f),m(e,L,l),m(e,u,l),m(e,k,l),x(C,e,l),m(e,oe,l),m(e,A,l),m(e,ie,l),x(M,e,l),m(e,de,l),x(H,e,l),m(e,le,l),m(e,o,l),x(F,o,null),t(o,me),t(o,q),t(o,ue),t(o,z),t(o,ce),t(o,S),t(o,he),t(o,c),x(D,c,null),t(c,ge),t(c,R),t(c,ve),t(c,G),t(o,$e),t(o,h),x(I,h,null),t(h,_e),t(h,N),t(h,be),t(h,B),t(o,xe),t(o,g),x(j,g,null),t(g,Pe),t(g,J),t(g,Te),t(g,K),t(o,we),t(o,v),x(U,v,null),t(v,Me),t(v,O),t(v,ye),t(v,Q),t(o,Ee),t(o,$),x(V,$,null),t($,Le),t($,W),t($,Ce),t($,X),m(e,fe,l),m(e,ne,l),pe=!0},p(e,[l]){const d={};l&2&&(d.$$scope={dirty:l,ctx:e}),M.$set(d)},i(e){pe||(P(C.$$.fragment,e),P(M.$$.fragment,e),P(H.$$.fragment,e),P(F.$$.fragment,e),P(D.$$.fragment,e),P(I.$$.fragment,e),P(j.$$.fragment,e),P(U.$$.fragment,e),P(V.$$.fragment,e),pe=!0)},o(e){T(C.$$.fragment,e),T(M.$$.fragment,e),T(H.$$.fragment,e),T(F.$$.fragment,e),T(D.$$.fragment,e),T(I.$$.fragment,e),T(j.$$.fragment,e),T(U.$$.fragment,e),T(V.$$.fragment,e),pe=!1},d(e){e&&(i(L),i(u),i(k),i(oe),i(A),i(ie),i(de),i(le),i(o),i(fe),i(ne)),i(f),w(C,e),w(M,e),w(H,e),w(F),w(D),w(I),w(j),w(U),w(V)}}}const et='{"title":"PEFT","local":"peft","sections":[{"title":"PeftAdapterMixin","local":"diffusers.loaders.PeftAdapterMixin","sections":[],"depth":2}],"depth":1}';function tt(se){return Je(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class it extends Oe{constructor(f){super(),Qe(this,f,tt,Ze,Be,{})}}export{it as component};
