import{s as he,o as ge,n as se}from"../chunks/scheduler.182ea377.js";import{S as ue,i as _e,g as h,s as i,r as $,A as $e,h as g,f as r,c as l,j as X,u as x,x as G,k as Z,y as f,a as p,v as w,d as b,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 we(A){let o,u='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=h("p"),o.innerHTML=u},l(s){o=g(s,"P",{"data-svelte-h":!0}),G(o)!=="svelte-xt8bs9"&&(o.innerHTML=u)},m(s,n){p(s,o,n)},p:se,d(s){s&&r(o)}}}function be(A){let o,u="Example:",s,n,d;return n=new fe({props:{code:"cGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoMC41KQ==",highlighted:'pipeline.set_ip_adapter_scale(<span class="hljs-number">0.5</span>)',wrap:!1}}),{c(){o=h("p"),o.textContent=u,s=i(),$(n.$$.fragment)},l(t){o=g(t,"P",{"data-svelte-h":!0}),G(o)!=="svelte-11lpom8"&&(o.textContent=u),s=l(t),x(n.$$.fragment,t)},m(t,c){p(t,o,c),p(t,s,c),w(n,t,c),d=!0},p:se,i(t){d||(b(n.$$.fragment,t),d=!0)},o(t){v(n.$$.fragment,t),d=!1},d(t){t&&(r(o),r(s)),P(n,t)}}}function ve(A){let o,u="Examples:",s,n,d;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=h("p"),o.textContent=u,s=i(),$(n.$$.fragment)},l(t){o=g(t,"P",{"data-svelte-h":!0}),G(o)!=="svelte-kvfsh7"&&(o.textContent=u),s=l(t),x(n.$$.fragment,t)},m(t,c){p(t,o,c),p(t,s,c),w(n,t,c),d=!0},p:se,i(t){d||(b(n.$$.fragment,t),d=!0)},o(t){v(n.$$.fragment,t),d=!1},d(t){t&&(r(o),r(s)),P(n,t)}}}function Pe(A){let o,u,s,n,d,t,c,de='<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,T,J,L,N,m,U,K,F,ie="Mixin for handling IP Adapters.",O,B,E,ee,I,H,te,W,le="Sets the conditioning scale between text and image.",oe,C,ae,y,j,re,q,pe="Unloads the IP Adapter weights",ne,k,Y,D,Q;return d=new me({props:{title:"IP-Adapter",local:"ip-adapter",headingTag:"h1"}}),T=new xe({props:{$$slots:{default:[we]},$$scope:{ctx:A}}}),L=new me({props:{title:"IPAdapterMixin",local:"diffusers.loaders.IPAdapterMixin",headingTag:"h2"}}),U=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"}}),E=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:"image_encoder_folder",val:": Optional = 'image_encoder'"},{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>List[str]</code> or <code>os.PathLike</code> or <code>List[os.PathLike]</code> or <code>dict</code> or <code>List[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.subfolder",description:`<strong>subfolder</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The subfolder location of a model file within a larger model repository on the Hub or locally.
If a list is passed, it should have the same length as <code>weight_name</code>.`,name:"subfolder"},{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter.weight_name",description:`<strong>weight_name</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The name of the weight file to load. If a list is passed, it should have the same length as
<code>weight_name</code>.`,name:"weight_name"},{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter.image_encoder_folder",description:`<strong>image_encoder_folder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>image_encoder</code>) &#x2014;
The subfolder location of the image encoder within a larger model repository on the Hub or locally.
Pass <code>None</code> to not load the image encoder. If the image encoder is located in a folder inside <code>subfolder</code>,
you only need to pass the name of the folder that contains image encoder weights, e.g. <code>image_encoder_folder=&quot;image_encoder&quot;</code>.
If the image encoder is located in a folder other than <code>subfolder</code>, you should pass the path to the folder that contains image encoder weights,
for example, <code>image_encoder_folder=&quot;different_subfolder/image_encoder&quot;</code>.`,name:"image_encoder_folder"},{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.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"}}),H=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#L230"}}),C=new ce({props:{anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale.example",$$slots:{default:[be]},$$scope:{ctx:A}}}),j=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#L252"}}),k=new ce({props:{anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter.example",$$slots:{default:[ve]},$$scope:{ctx:A}}}),{c(){o=h("meta"),u=i(),s=h("p"),n=i(),$(d.$$.fragment),t=i(),c=h("p"),c.innerHTML=de,S=i(),$(T.$$.fragment),J=i(),$(L.$$.fragment),N=i(),m=h("div"),$(U.$$.fragment),K=i(),F=h("p"),F.textContent=ie,O=i(),B=h("div"),$(E.$$.fragment),ee=i(),I=h("div"),$(H.$$.fragment),te=i(),W=h("p"),W.textContent=le,oe=i(),$(C.$$.fragment),ae=i(),y=h("div"),$(j.$$.fragment),re=i(),q=h("p"),q.textContent=pe,ne=i(),$(k.$$.fragment),Y=i(),D=h("p"),this.h()},l(e){const a=$e("svelte-u9bgzb",document.head);o=g(a,"META",{name:!0,content:!0}),a.forEach(r),u=l(e),s=g(e,"P",{}),X(s).forEach(r),n=l(e),x(d.$$.fragment,e),t=l(e),c=g(e,"P",{"data-svelte-h":!0}),G(c)!=="svelte-nxzt54"&&(c.innerHTML=de),S=l(e),x(T.$$.fragment,e),J=l(e),x(L.$$.fragment,e),N=l(e),m=g(e,"DIV",{class:!0});var _=X(m);x(U.$$.fragment,_),K=l(_),F=g(_,"P",{"data-svelte-h":!0}),G(F)!=="svelte-geelri"&&(F.textContent=ie),O=l(_),B=g(_,"DIV",{class:!0});var V=X(B);x(E.$$.fragment,V),V.forEach(r),ee=l(_),I=g(_,"DIV",{class:!0});var M=X(I);x(H.$$.fragment,M),te=l(M),W=g(M,"P",{"data-svelte-h":!0}),G(W)!=="svelte-70igws"&&(W.textContent=le),oe=l(M),x(C.$$.fragment,M),M.forEach(r),ae=l(_),y=g(_,"DIV",{class:!0});var z=X(y);x(j.$$.fragment,z),re=l(z),q=g(z,"P",{"data-svelte-h":!0}),G(q)!=="svelte-io61ja"&&(q.textContent=pe),ne=l(z),x(k.$$.fragment,z),z.forEach(r),_.forEach(r),Y=l(e),D=g(e,"P",{}),X(D).forEach(r),this.h()},h(){Z(o,"name","hf:doc:metadata"),Z(o,"content",Ie),Z(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Z(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Z(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),Z(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,u,a),p(e,s,a),p(e,n,a),w(d,e,a),p(e,t,a),p(e,c,a),p(e,S,a),w(T,e,a),p(e,J,a),w(L,e,a),p(e,N,a),p(e,m,a),w(U,m,null),f(m,K),f(m,F),f(m,O),f(m,B),w(E,B,null),f(m,ee),f(m,I),w(H,I,null),f(I,te),f(I,W),f(I,oe),w(C,I,null),f(m,ae),f(m,y),w(j,y,null),f(y,re),f(y,q),f(y,ne),w(k,y,null),p(e,Y,a),p(e,D,a),Q=!0},p(e,[a]){const _={};a&2&&(_.$$scope={dirty:a,ctx:e}),T.$set(_);const V={};a&2&&(V.$$scope={dirty:a,ctx:e}),C.$set(V);const M={};a&2&&(M.$$scope={dirty:a,ctx:e}),k.$set(M)},i(e){Q||(b(d.$$.fragment,e),b(T.$$.fragment,e),b(L.$$.fragment,e),b(U.$$.fragment,e),b(E.$$.fragment,e),b(H.$$.fragment,e),b(C.$$.fragment,e),b(j.$$.fragment,e),b(k.$$.fragment,e),Q=!0)},o(e){v(d.$$.fragment,e),v(T.$$.fragment,e),v(L.$$.fragment,e),v(U.$$.fragment,e),v(E.$$.fragment,e),v(H.$$.fragment,e),v(C.$$.fragment,e),v(j.$$.fragment,e),v(k.$$.fragment,e),Q=!1},d(e){e&&(r(u),r(s),r(n),r(t),r(c),r(S),r(J),r(N),r(m),r(Y),r(D)),r(o),P(d,e),P(T,e),P(L,e),P(U),P(E),P(H),P(C),P(j),P(k)}}}const Ie='{"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 Ee extends ue{constructor(o){super(),_e(this,o,ye,Pe,he,{})}}export{Ee as component};
