import{s as ue,o as ge,n as se}from"../chunks/scheduler.182ea377.js";import{S as he,i as _e,g as u,s as d,r as $,A as $e,h as g,f as r,c as l,j as Z,u as x,x as H,k as D,y as f,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 fe}from"../chunks/CodeBlock.57fe6e13.js";import{E as ce}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as me}from"../chunks/Heading.16916d63.js";function be(A){let o,h='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(){o=u("p"),o.innerHTML=h},l(s){o=g(s,"P",{"data-svelte-h":!0}),H(o)!=="svelte-xt8bs9"&&(o.innerHTML=h)},m(s,n){p(s,o,n)},p:se,d(s){s&&r(o)}}}function we(A){let o,h="Example:",s,n,i;return n=new fe({props:{code:"cGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoMC41KQ==",highlighted:'pipeline.set_ip_adapter_scale(<span class="hljs-number">0.5</span>)',wrap:!1}}),{c(){o=u("p"),o.textContent=h,s=d(),$(n.$$.fragment)},l(t){o=g(t,"P",{"data-svelte-h":!0}),H(o)!=="svelte-11lpom8"&&(o.textContent=h),s=l(t),x(n.$$.fragment,t)},m(t,c){p(t,o,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(o),r(s)),P(n,t)}}}function ve(A){let o,h="Examples:",s,n,i;return n=new fe({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(){o=u("p"),o.textContent=h,s=d(),$(n.$$.fragment)},l(t){o=g(t,"P",{"data-svelte-h":!0}),H(o)!=="svelte-kvfsh7"&&(o.textContent=h),s=l(t),x(n.$$.fragment,t)},m(t,c){p(t,o,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(o),r(s)),P(n,t)}}}function Pe(A){let o,h,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,m,E,K,F,de="Mixin for handling IP Adapters.",O,B,L,ee,M,j,te,W,le="Sets the conditioning scale between text and image.",oe,T,ae,y,G,re,z,pe="Unloads the IP Adapter weights",ne,k,N,V,Q;return i=new me({props:{title:"IP-Adapter",local:"ip-adapter",headingTag:"h1"}}),C=new xe({props:{$$slots:{default:[be]},$$scope:{ctx:A}}}),U=new me({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#L46"}}),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"},{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter.low_cpu_mem_usage",description:`<strong>low_cpu_mem_usage</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code> if torch version &gt;= 1.9.0 else <code>False</code>) &#x2014;
Speed up model loading only loading the pretrained weights and not initializing the weights. This also
tries to not use more than 1x model size in CPU memory (including peak memory) while loading the model.
Only supported for PyTorch &gt;= 1.9.0. If you are using an older version of PyTorch, setting this
argument to <code>True</code> will raise an error.`,name:"low_cpu_mem_usage"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders/ip_adapter.py#L49"}}),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#L207"}}),T=new ce({props:{anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale.example",$$slots:{default:[we]},$$scope:{ctx:A}}}),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#L229"}}),k=new ce({props:{anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter.example",$$slots:{default:[ve]},$$scope:{ctx:A}}}),{c(){o=u("meta"),h=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(),m=u("div"),$(E.$$.fragment),K=d(),F=u("p"),F.textContent=de,O=d(),B=u("div"),$(L.$$.fragment),ee=d(),M=u("div"),$(j.$$.fragment),te=d(),W=u("p"),W.textContent=le,oe=d(),$(T.$$.fragment),ae=d(),y=u("div"),$(G.$$.fragment),re=d(),z=u("p"),z.textContent=pe,ne=d(),$(k.$$.fragment),N=d(),V=u("p"),this.h()},l(e){const a=$e("svelte-u9bgzb",document.head);o=g(a,"META",{name:!0,content:!0}),a.forEach(r),h=l(e),s=g(e,"P",{}),Z(s).forEach(r),n=l(e),x(i.$$.fragment,e),t=l(e),c=g(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),m=g(e,"DIV",{class:!0});var _=Z(m);x(E.$$.fragment,_),K=l(_),F=g(_,"P",{"data-svelte-h":!0}),H(F)!=="svelte-geelri"&&(F.textContent=de),O=l(_),B=g(_,"DIV",{class:!0});var q=Z(B);x(L.$$.fragment,q),q.forEach(r),ee=l(_),M=g(_,"DIV",{class:!0});var I=Z(M);x(j.$$.fragment,I),te=l(I),W=g(I,"P",{"data-svelte-h":!0}),H(W)!=="svelte-70igws"&&(W.textContent=le),oe=l(I),x(T.$$.fragment,I),I.forEach(r),ae=l(_),y=g(_,"DIV",{class:!0});var X=Z(y);x(G.$$.fragment,X),re=l(X),z=g(X,"P",{"data-svelte-h":!0}),H(z)!=="svelte-io61ja"&&(z.textContent=pe),ne=l(X),x(k.$$.fragment,X),X.forEach(r),_.forEach(r),N=l(e),V=g(e,"P",{}),Z(V).forEach(r),this.h()},h(){D(o,"name","hf:doc:metadata"),D(o,"content",Me),D(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),D(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),D(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),D(m,"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,a){f(document.head,o),p(e,h,a),p(e,s,a),p(e,n,a),b(i,e,a),p(e,t,a),p(e,c,a),p(e,S,a),b(C,e,a),p(e,J,a),b(U,e,a),p(e,Y,a),p(e,m,a),b(E,m,null),f(m,K),f(m,F),f(m,O),f(m,B),b(L,B,null),f(m,ee),f(m,M),b(j,M,null),f(M,te),f(M,W),f(M,oe),b(T,M,null),f(m,ae),f(m,y),b(G,y,null),f(y,re),f(y,z),f(y,ne),b(k,y,null),p(e,N,a),p(e,V,a),Q=!0},p(e,[a]){const _={};a&2&&(_.$$scope={dirty:a,ctx:e}),C.$set(_);const q={};a&2&&(q.$$scope={dirty:a,ctx:e}),T.$set(q);const I={};a&2&&(I.$$scope={dirty:a,ctx:e}),k.$set(I)},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(T.$$.fragment,e),w(G.$$.fragment,e),w(k.$$.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(T.$$.fragment,e),v(G.$$.fragment,e),v(k.$$.fragment,e),Q=!1},d(e){e&&(r(h),r(s),r(n),r(t),r(c),r(S),r(J),r(Y),r(m),r(N),r(V)),r(o),P(i,e),P(C,e),P(U,e),P(E),P(L),P(j),P(T),P(G),P(k)}}}const Me='{"title":"IP-Adapter","local":"ip-adapter","sections":[{"title":"IPAdapterMixin","local":"diffusers.loaders.IPAdapterMixin","sections":[],"depth":2}],"depth":1}';function ye(A){return ge(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Le extends he{constructor(o){super(),_e(this,o,ye,Pe,ue,{})}}export{Le as component};
