import{s as Ce,o as ze,n as ve}from"../chunks/scheduler.182ea377.js";import{S as Le,i as Ee,g as p,s as n,r as h,A as Ue,h as m,f as a,c as d,j as U,u as _,x as k,k as F,y as l,a as c,v as $,d as x,t as b,w as v}from"../chunks/index.abf12888.js";import{T as Fe}from"../chunks/Tip.230e2334.js";import{D as K}from"../chunks/Docstring.93f6f462.js";import{C as Te}from"../chunks/CodeBlock.57fe6e13.js";import{E as ke}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as be}from"../chunks/Heading.16916d63.js";function qe(T){let o,w='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=p("p"),o.innerHTML=w},l(i){o=m(i,"P",{"data-svelte-h":!0}),k(o)!=="svelte-xt8bs9"&&(o.innerHTML=w)},m(i,s){c(i,o,s)},p:ve,d(i){i&&a(o)}}}function De(T){let o,w="Example:",i,s,f;return s=new Te({props:{code:"cGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoMC41KQ==",highlighted:'pipeline.set_ip_adapter_scale(<span class="hljs-number">0.5</span>)',wrap:!1}}),{c(){o=p("p"),o.textContent=w,i=n(),h(s.$$.fragment)},l(t){o=m(t,"P",{"data-svelte-h":!0}),k(o)!=="svelte-11lpom8"&&(o.textContent=w),i=d(t),_(s.$$.fragment,t)},m(t,g){c(t,o,g),c(t,i,g),$(s,t,g),f=!0},p:ve,i(t){f||(x(s.$$.fragment,t),f=!0)},o(t){b(s.$$.fragment,t),f=!1},d(t){t&&(a(o),a(i)),v(s,t)}}}function We(T){let o,w="Examples:",i,s,f;return s=new Te({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=p("p"),o.textContent=w,i=n(),h(s.$$.fragment)},l(t){o=m(t,"P",{"data-svelte-h":!0}),k(o)!=="svelte-kvfsh7"&&(o.textContent=w),i=d(t),_(s.$$.fragment,t)},m(t,g){c(t,o,g),c(t,i,g),$(s,t,g),f=!0},p:ve,i(t){f||(x(s.$$.fragment,t),f=!0)},o(t){b(s.$$.fragment,t),f=!1},d(t){t&&(a(o),a(i)),v(s,t)}}}function He(T){let o,w,i,s,f,t,g,we='<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.',te,C,oe,q,ae,u,D,le,X,Pe="Mixin for handling IP Adapters.",ce,Z,W,pe,M,H,me,S,Ie="Sets the conditioning scale between text and image.",fe,z,ge,y,j,ue,J,Me="Unloads the IP Adapter weights",he,L,re,G,se,I,V,_e,N,ye="Image processor for IP Adapter image masks.",$e,E,B,xe,R,Ae=`Downsamples the provided mask tensor to match the expected dimensions for scaled dot-product attention.
If the aspect ratio of the mask does not match the aspect ratio of the output image, a warning is issued.`,ne,O,de;return f=new be({props:{title:"IP-Adapter",local:"ip-adapter",headingTag:"h1"}}),C=new Fe({props:{$$slots:{default:[qe]},$$scope:{ctx:T}}}),q=new be({props:{title:"IPAdapterMixin",local:"diffusers.loaders.IPAdapterMixin",headingTag:"h2"}}),D=new K({props:{name:"class diffusers.loaders.IPAdapterMixin",anchor:"diffusers.loaders.IPAdapterMixin",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.27.2/src/diffusers/loaders/ip_adapter.py#L46"}}),W=new K({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/v0.27.2/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/v0.27.2/src/diffusers/loaders/ip_adapter.py#L49"}}),H=new K({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/v0.27.2/src/diffusers/loaders/ip_adapter.py#L230"}}),z=new ke({props:{anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale.example",$$slots:{default:[De]},$$scope:{ctx:T}}}),j=new K({props:{name:"unload_ip_adapter",anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.27.2/src/diffusers/loaders/ip_adapter.py#L252"}}),L=new ke({props:{anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter.example",$$slots:{default:[We]},$$scope:{ctx:T}}}),G=new be({props:{title:"IPAdapterMaskProcessor",local:"diffusers.image_processor.IPAdapterMaskProcessor",headingTag:"h2"}}),V=new K({props:{name:"class diffusers.image_processor.IPAdapterMaskProcessor",anchor:"diffusers.image_processor.IPAdapterMaskProcessor",parameters:[{name:"do_resize",val:": bool = True"},{name:"vae_scale_factor",val:": int = 8"},{name:"resample",val:": str = 'lanczos'"},{name:"do_normalize",val:": bool = False"},{name:"do_binarize",val:": bool = True"},{name:"do_convert_grayscale",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to downscale the image&#x2019;s (height, width) dimensions to multiples of <code>vae_scale_factor</code>.`,name:"do_resize"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.vae_scale_factor",description:`<strong>vae_scale_factor</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8</code>) &#x2014;
VAE scale factor. If <code>do_resize</code> is <code>True</code>, the image is automatically resized to multiples of this factor.`,name:"vae_scale_factor"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.resample",description:`<strong>resample</strong> (<code>str</code>, <em>optional</em>, defaults to <code>lanczos</code>) &#x2014;
Resampling filter to use when resizing the image.`,name:"resample"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether to normalize the image to [-1,1].`,name:"do_normalize"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.do_binarize",description:`<strong>do_binarize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to binarize the image to 0/1.`,name:"do_binarize"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.do_convert_grayscale",description:`<strong>do_convert_grayscale</strong> (<code>bool</code>, <em>optional</em>, defaults to be <code>True</code>) &#x2014;
Whether to convert the images to grayscale format.`,name:"do_convert_grayscale"}],source:"https://github.com/huggingface/diffusers/blob/v0.27.2/src/diffusers/image_processor.py#L889"}}),B=new K({props:{name:"downsample",anchor:"diffusers.image_processor.IPAdapterMaskProcessor.downsample",parameters:[{name:"mask",val:": FloatTensor"},{name:"batch_size",val:": int"},{name:"num_queries",val:": int"},{name:"value_embed_dim",val:": int"}],parametersDescription:[{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.downsample.mask",description:`<strong>mask</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input mask tensor generated with <code>IPAdapterMaskProcessor.preprocess()</code>.`,name:"mask"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.downsample.batch_size",description:`<strong>batch_size</strong> (<code>int</code>) &#x2014;
The batch size.`,name:"batch_size"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.downsample.num_queries",description:`<strong>num_queries</strong> (<code>int</code>) &#x2014;
The number of queries.`,name:"num_queries"},{anchor:"diffusers.image_processor.IPAdapterMaskProcessor.downsample.value_embed_dim",description:`<strong>value_embed_dim</strong> (<code>int</code>) &#x2014;
The dimensionality of the value embeddings.`,name:"value_embed_dim"}],source:"https://github.com/huggingface/diffusers/blob/v0.27.2/src/diffusers/image_processor.py#L930",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>The downsampled mask tensor.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.FloatTensor</code></p>
`}}),{c(){o=p("meta"),w=n(),i=p("p"),s=n(),h(f.$$.fragment),t=n(),g=p("p"),g.innerHTML=we,te=n(),h(C.$$.fragment),oe=n(),h(q.$$.fragment),ae=n(),u=p("div"),h(D.$$.fragment),le=n(),X=p("p"),X.textContent=Pe,ce=n(),Z=p("div"),h(W.$$.fragment),pe=n(),M=p("div"),h(H.$$.fragment),me=n(),S=p("p"),S.textContent=Ie,fe=n(),h(z.$$.fragment),ge=n(),y=p("div"),h(j.$$.fragment),ue=n(),J=p("p"),J.textContent=Me,he=n(),h(L.$$.fragment),re=n(),h(G.$$.fragment),se=n(),I=p("div"),h(V.$$.fragment),_e=n(),N=p("p"),N.textContent=ye,$e=n(),E=p("div"),h(B.$$.fragment),xe=n(),R=p("p"),R.textContent=Ae,ne=n(),O=p("p"),this.h()},l(e){const r=Ue("svelte-u9bgzb",document.head);o=m(r,"META",{name:!0,content:!0}),r.forEach(a),w=d(e),i=m(e,"P",{}),U(i).forEach(a),s=d(e),_(f.$$.fragment,e),t=d(e),g=m(e,"P",{"data-svelte-h":!0}),k(g)!=="svelte-nxzt54"&&(g.innerHTML=we),te=d(e),_(C.$$.fragment,e),oe=d(e),_(q.$$.fragment,e),ae=d(e),u=m(e,"DIV",{class:!0});var P=U(u);_(D.$$.fragment,P),le=d(P),X=m(P,"P",{"data-svelte-h":!0}),k(X)!=="svelte-geelri"&&(X.textContent=Pe),ce=d(P),Z=m(P,"DIV",{class:!0});var ee=U(Z);_(W.$$.fragment,ee),ee.forEach(a),pe=d(P),M=m(P,"DIV",{class:!0});var A=U(M);_(H.$$.fragment,A),me=d(A),S=m(A,"P",{"data-svelte-h":!0}),k(S)!=="svelte-70igws"&&(S.textContent=Ie),fe=d(A),_(z.$$.fragment,A),A.forEach(a),ge=d(P),y=m(P,"DIV",{class:!0});var Y=U(y);_(j.$$.fragment,Y),ue=d(Y),J=m(Y,"P",{"data-svelte-h":!0}),k(J)!=="svelte-io61ja"&&(J.textContent=Me),he=d(Y),_(L.$$.fragment,Y),Y.forEach(a),P.forEach(a),re=d(e),_(G.$$.fragment,e),se=d(e),I=m(e,"DIV",{class:!0});var Q=U(I);_(V.$$.fragment,Q),_e=d(Q),N=m(Q,"P",{"data-svelte-h":!0}),k(N)!=="svelte-mxmwf6"&&(N.textContent=ye),$e=d(Q),E=m(Q,"DIV",{class:!0});var ie=U(E);_(B.$$.fragment,ie),xe=d(ie),R=m(ie,"P",{"data-svelte-h":!0}),k(R)!=="svelte-s1oaru"&&(R.textContent=Ae),ie.forEach(a),Q.forEach(a),ne=d(e),O=m(e,"P",{}),U(O).forEach(a),this.h()},h(){F(o,"name","hf:doc:metadata"),F(o,"content",je),F(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),F(I,"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,r){l(document.head,o),c(e,w,r),c(e,i,r),c(e,s,r),$(f,e,r),c(e,t,r),c(e,g,r),c(e,te,r),$(C,e,r),c(e,oe,r),$(q,e,r),c(e,ae,r),c(e,u,r),$(D,u,null),l(u,le),l(u,X),l(u,ce),l(u,Z),$(W,Z,null),l(u,pe),l(u,M),$(H,M,null),l(M,me),l(M,S),l(M,fe),$(z,M,null),l(u,ge),l(u,y),$(j,y,null),l(y,ue),l(y,J),l(y,he),$(L,y,null),c(e,re,r),$(G,e,r),c(e,se,r),c(e,I,r),$(V,I,null),l(I,_e),l(I,N),l(I,$e),l(I,E),$(B,E,null),l(E,xe),l(E,R),c(e,ne,r),c(e,O,r),de=!0},p(e,[r]){const P={};r&2&&(P.$$scope={dirty:r,ctx:e}),C.$set(P);const ee={};r&2&&(ee.$$scope={dirty:r,ctx:e}),z.$set(ee);const A={};r&2&&(A.$$scope={dirty:r,ctx:e}),L.$set(A)},i(e){de||(x(f.$$.fragment,e),x(C.$$.fragment,e),x(q.$$.fragment,e),x(D.$$.fragment,e),x(W.$$.fragment,e),x(H.$$.fragment,e),x(z.$$.fragment,e),x(j.$$.fragment,e),x(L.$$.fragment,e),x(G.$$.fragment,e),x(V.$$.fragment,e),x(B.$$.fragment,e),de=!0)},o(e){b(f.$$.fragment,e),b(C.$$.fragment,e),b(q.$$.fragment,e),b(D.$$.fragment,e),b(W.$$.fragment,e),b(H.$$.fragment,e),b(z.$$.fragment,e),b(j.$$.fragment,e),b(L.$$.fragment,e),b(G.$$.fragment,e),b(V.$$.fragment,e),b(B.$$.fragment,e),de=!1},d(e){e&&(a(w),a(i),a(s),a(t),a(g),a(te),a(oe),a(ae),a(u),a(re),a(se),a(I),a(ne),a(O)),a(o),v(f,e),v(C,e),v(q,e),v(D),v(W),v(H),v(z),v(j),v(L),v(G,e),v(V),v(B)}}}const je='{"title":"IP-Adapter","local":"ip-adapter","sections":[{"title":"IPAdapterMixin","local":"diffusers.loaders.IPAdapterMixin","sections":[],"depth":2},{"title":"IPAdapterMaskProcessor","local":"diffusers.image_processor.IPAdapterMaskProcessor","sections":[],"depth":2}],"depth":1}';function Ge(T){return ze(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Re extends Le{constructor(o){super(),Ee(this,o,Ge,He,Ce,{})}}export{Re as component};
