import{s as ue,o as he,n as se}from"../chunks/scheduler.182ea377.js";import{S as ge,i as _e,g as u,s as d,r as $,A as $e,h,f as r,c as l,j as D,u as x,x as H,k as V,y as m,a as p,v as b,d as w,t as v,w as P}from"../chunks/index.abf12888.js";import{T as xe}from"../chunks/Tip.230e2334.js";import{D as R}from"../chunks/Docstring.93f6f462.js";import{C as me}from"../chunks/CodeBlock.57fe6e13.js";import{E as ce}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as fe}from"../chunks/Heading.16916d63.js";function be(y){let a,g='Learn how to load an IP-Adapter checkpoint and image in the IP-Adapter <a href="../../using-diffusers/loading_adapters#ip-adapter">loading</a> guide, and you can see how to use it in the <a href="../../using-diffusers/ip_adapter">usage</a> guide.';return{c(){a=u("p"),a.innerHTML=g},l(s){a=h(s,"P",{"data-svelte-h":!0}),H(a)!=="svelte-xt8bs9"&&(a.innerHTML=g)},m(s,n){p(s,a,n)},p:se,d(s){s&&r(a)}}}function we(y){let a,g="Example:",s,n,i;return n=new me({props:{code:"cGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoMC41KQ==",highlighted:'pipeline.set_ip_adapter_scale(<span class="hljs-number">0.5</span>)',wrap:!1}}),{c(){a=u("p"),a.textContent=g,s=d(),$(n.$$.fragment)},l(t){a=h(t,"P",{"data-svelte-h":!0}),H(a)!=="svelte-11lpom8"&&(a.textContent=g),s=l(t),x(n.$$.fragment,t)},m(t,c){p(t,a,c),p(t,s,c),b(n,t,c),i=!0},p:se,i(t){i||(w(n.$$.fragment,t),i=!0)},o(t){v(n.$$.fragment,t),i=!1},d(t){t&&(r(a),r(s)),P(n,t)}}}function ve(y){let a,g="Examples:",s,n,i;return n=new me({props:{code:"JTIzJTIwQXNzdW1pbmclMjAlNjBwaXBlbGluZSU2MCUyMGlzJTIwYWxyZWFkeSUyMGxvYWRlZCUyMHdpdGglMjB0aGUlMjBJUCUyMEFkYXB0ZXIlMjB3ZWlnaHRzLiUwQXBpcGVsaW5lLnVubG9hZF9pcF9hZGFwdGVyKCklMEEuLi4=",highlighted:'<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Assuming `pipeline` is already loaded with the IP Adapter weights.</span>\n<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.unload_ip_adapter()\n<span class="hljs-meta">&gt;&gt;&gt; </span>...',wrap:!1}}),{c(){a=u("p"),a.textContent=g,s=d(),$(n.$$.fragment)},l(t){a=h(t,"P",{"data-svelte-h":!0}),H(a)!=="svelte-kvfsh7"&&(a.textContent=g),s=l(t),x(n.$$.fragment,t)},m(t,c){p(t,a,c),p(t,s,c),b(n,t,c),i=!0},p:se,i(t){i||(w(n.$$.fragment,t),i=!0)},o(t){v(n.$$.fragment,t),i=!1},d(t){t&&(r(a),r(s)),P(n,t)}}}function Pe(y){let a,g,s,n,i,t,c,ie='<a href="https://hf.co/papers/2308.06721" rel="nofollow">IP-Adapter</a> is a lightweight adapter that enables prompting a diffusion model with an image. This method decouples the cross-attention layers of the image and text features. The image features are generated from an image encoder.',S,C,J,U,Y,f,E,K,B,de="Mixin for handling IP Adapters.",O,F,L,ee,M,j,te,W,le="Sets the conditioning scale between text and image.",ae,k,oe,I,G,re,X,pe="Unloads the IP Adapter weights",ne,T,N,q,Q;return i=new fe({props:{title:"IP-Adapter",local:"ip-adapter",headingTag:"h1"}}),C=new xe({props:{$$slots:{default:[be]},$$scope:{ctx:y}}}),U=new fe({props:{title:"IPAdapterMixin",local:"diffusers.loaders.IPAdapterMixin",headingTag:"h2"}}),E=new R({props:{name:"class diffusers.loaders.IPAdapterMixin",anchor:"diffusers.loaders.IPAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/ip_adapter.py#L43"}}),L=new R({props:{name:"load_ip_adapter",anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter",parameters:[{name:"pretrained_model_name_or_path_or_dict",val:": Union"},{name:"subfolder",val:": Union"},{name:"weight_name",val:": Union"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter.pretrained_model_name_or_path_or_dict",description:`<strong>pretrained_model_name_or_path_or_dict</strong> (<code>str</code> or <code>os.PathLike</code> or <code>dict</code>) &#x2014;
Can be either:</p>
<ul>
<li>A string, the <em>model id</em> (for example <code>google/ddpm-celebahq-256</code>) of a pretrained model hosted on
the Hub.</li>
<li>A path to a <em>directory</em> (for example <code>./my_model_directory</code>) containing the model weights saved
with <a href="/docs/diffusers/main/en/api/models/overview#diffusers.ModelMixin.save_pretrained">ModelMixin.save_pretrained()</a>.</li>
<li>A <a href="https://pytorch.org/tutorials/beginner/saving_loading_models.html#what-is-a-state-dict" rel="nofollow">torch state
dict</a>.</li>
</ul>`,name:"pretrained_model_name_or_path_or_dict"},{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_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.IPAdapterMixin.load_ip_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.IPAdapterMixin.load_ip_adapter.resume_download",description:`<strong>resume_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether or not to resume downloading the model weights and configuration files. If set to <code>False</code>, any
incompletely downloaded files are deleted.`,name:"resume_download"},{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_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.IPAdapterMixin.load_ip_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.IPAdapterMixin.load_ip_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.IPAdapterMixin.load_ip_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.IPAdapterMixin.load_ip_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"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/ip_adapter.py#L46"}}),j=new R({props:{name:"set_ip_adapter_scale",anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale",parameters:[{name:"scale",val:""}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/ip_adapter.py#L182"}}),k=new ce({props:{anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale.example",$$slots:{default:[we]},$$scope:{ctx:y}}}),G=new R({props:{name:"unload_ip_adapter",anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/ip_adapter.py#L204"}}),T=new ce({props:{anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter.example",$$slots:{default:[ve]},$$scope:{ctx:y}}}),{c(){a=u("meta"),g=d(),s=u("p"),n=d(),$(i.$$.fragment),t=d(),c=u("p"),c.innerHTML=ie,S=d(),$(C.$$.fragment),J=d(),$(U.$$.fragment),Y=d(),f=u("div"),$(E.$$.fragment),K=d(),B=u("p"),B.textContent=de,O=d(),F=u("div"),$(L.$$.fragment),ee=d(),M=u("div"),$(j.$$.fragment),te=d(),W=u("p"),W.textContent=le,ae=d(),$(k.$$.fragment),oe=d(),I=u("div"),$(G.$$.fragment),re=d(),X=u("p"),X.textContent=pe,ne=d(),$(T.$$.fragment),N=d(),q=u("p"),this.h()},l(e){const o=$e("svelte-u9bgzb",document.head);a=h(o,"META",{name:!0,content:!0}),o.forEach(r),g=l(e),s=h(e,"P",{}),D(s).forEach(r),n=l(e),x(i.$$.fragment,e),t=l(e),c=h(e,"P",{"data-svelte-h":!0}),H(c)!=="svelte-nxzt54"&&(c.innerHTML=ie),S=l(e),x(C.$$.fragment,e),J=l(e),x(U.$$.fragment,e),Y=l(e),f=h(e,"DIV",{class:!0});var _=D(f);x(E.$$.fragment,_),K=l(_),B=h(_,"P",{"data-svelte-h":!0}),H(B)!=="svelte-geelri"&&(B.textContent=de),O=l(_),F=h(_,"DIV",{class:!0});var z=D(F);x(L.$$.fragment,z),z.forEach(r),ee=l(_),M=h(_,"DIV",{class:!0});var A=D(M);x(j.$$.fragment,A),te=l(A),W=h(A,"P",{"data-svelte-h":!0}),H(W)!=="svelte-70igws"&&(W.textContent=le),ae=l(A),x(k.$$.fragment,A),A.forEach(r),oe=l(_),I=h(_,"DIV",{class:!0});var Z=D(I);x(G.$$.fragment,Z),re=l(Z),X=h(Z,"P",{"data-svelte-h":!0}),H(X)!=="svelte-io61ja"&&(X.textContent=pe),ne=l(Z),x(T.$$.fragment,Z),Z.forEach(r),_.forEach(r),N=l(e),q=h(e,"P",{}),D(q).forEach(r),this.h()},h(){V(a,"name","hf:doc:metadata"),V(a,"content",Me),V(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(f,"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,o){m(document.head,a),p(e,g,o),p(e,s,o),p(e,n,o),b(i,e,o),p(e,t,o),p(e,c,o),p(e,S,o),b(C,e,o),p(e,J,o),b(U,e,o),p(e,Y,o),p(e,f,o),b(E,f,null),m(f,K),m(f,B),m(f,O),m(f,F),b(L,F,null),m(f,ee),m(f,M),b(j,M,null),m(M,te),m(M,W),m(M,ae),b(k,M,null),m(f,oe),m(f,I),b(G,I,null),m(I,re),m(I,X),m(I,ne),b(T,I,null),p(e,N,o),p(e,q,o),Q=!0},p(e,[o]){const _={};o&2&&(_.$$scope={dirty:o,ctx:e}),C.$set(_);const z={};o&2&&(z.$$scope={dirty:o,ctx:e}),k.$set(z);const A={};o&2&&(A.$$scope={dirty:o,ctx:e}),T.$set(A)},i(e){Q||(w(i.$$.fragment,e),w(C.$$.fragment,e),w(U.$$.fragment,e),w(E.$$.fragment,e),w(L.$$.fragment,e),w(j.$$.fragment,e),w(k.$$.fragment,e),w(G.$$.fragment,e),w(T.$$.fragment,e),Q=!0)},o(e){v(i.$$.fragment,e),v(C.$$.fragment,e),v(U.$$.fragment,e),v(E.$$.fragment,e),v(L.$$.fragment,e),v(j.$$.fragment,e),v(k.$$.fragment,e),v(G.$$.fragment,e),v(T.$$.fragment,e),Q=!1},d(e){e&&(r(g),r(s),r(n),r(t),r(c),r(S),r(J),r(Y),r(f),r(N),r(q)),r(a),P(i,e),P(C,e),P(U,e),P(E),P(L),P(j),P(k),P(G),P(T)}}}const Me='{"title":"IP-Adapter","local":"ip-adapter","sections":[{"title":"IPAdapterMixin","local":"diffusers.loaders.IPAdapterMixin","sections":[],"depth":2}],"depth":1}';function Ie(y){return he(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Le extends ge{constructor(a){super(),_e(this,a,Ie,Pe,ue,{})}}export{Le as component};
