Buckets:
| import"../chunks/DsnmJJEf.js";import{i as $,h as K,C as O,H as c,D as a,E as ee,s as oe,a as p}from"../chunks/BtE7mKSK.js";import{p as ae,o as re,s as e,f as l,a as i,b as se,c as r,d as h,r as s,n as w}from"../chunks/jDjavuwI.js";import{E as m}from"../chunks/SrSJA0zO.js";const te='{"title":"IP-Adapter","local":"ip-adapter","sections":[{"title":"IPAdapterMixin","local":"diffusers.loaders.IPAdapterMixin","sections":[],"depth":2},{"title":"SD3IPAdapterMixin","local":"diffusers.loaders.SD3IPAdapterMixin","sections":[],"depth":2},{"title":"IPAdapterMaskProcessor","local":"diffusers.IPAdapterMaskProcessor","sections":[],"depth":2}],"depth":1}';var de=h('<meta name="hf:doc:metadata"/>'),x=h("<p>Example:</p> <!>",1),ne=h("<p>Examples:</p> <!>",1),ie=h(`<p></p> <!> <!> <p><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.</p> <blockquote class="tip"><p>Learn how to load and use an IP-Adapter checkpoint and image in the <a href="../../using-diffusers/ip_adapter">IP-Adapter</a> guide,.</p></blockquote> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Mixin for handling IP Adapters.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Set IP-Adapter scales per-transformer block. Input <code>scale</code> could be a single config or a list of configs for | |
| granular control over each IP-Adapter behavior. A config can be a float or a dictionary.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Unloads the IP Adapter weights</p> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Mixin for handling StableDiffusion 3 IP Adapters.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Checks if IP-Adapter is loaded and scale > 0.</p> <p>IP-Adapter scale controls the influence of the image prompt versus text prompt. When this value is set to 0, | |
| the image context is irrelevant.</p></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Set IP-Adapter scale, which controls image prompt conditioning. A value of 1.0 means the model is only | |
| conditioned on the image prompt, and 0.0 only conditioned by the text prompt. Lowering this value encourages | |
| the model to produce more diverse images, but they may not be as aligned with the image prompt.</p> <!></div> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Unloads the IP Adapter weights.</p> <!></div></div> <!> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>Image processor for IP Adapter image masks.</p> <div class="docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"><!> <p>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.</p></div></div> <!> <p></p>`,1);function he(F,W){ae(W,!1),re(()=>{new URLSearchParams(window.location.search).get("fw")}),$();var I=ie();K("15j3v5e",t=>{var n=de();oe(n,"content",te),i(t,n)});var P=e(l(I),2);O(P,{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"});var T=e(P,2);c(T,{title:"IP-Adapter",local:"ip-adapter",headingTag:"h1"});var A=e(T,6);c(A,{title:"IPAdapterMixin",local:"diffusers.loaders.IPAdapterMixin",headingTag:"h2"});var f=e(A,2),U=r(f);a(U,{name:"class diffusers.loaders.IPAdapterMixin",anchor:"diffusers.loaders.IPAdapterMixin",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L54",parameters:[]});var u=e(U,4),L=r(u);a(L,{name:"load_ip_adapter",anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L57",parameters:[{name:"pretrained_model_name_or_path_or_dict",val:": str | list[str] | dict[str, torch.Tensor]"},{name:"subfolder",val:": str | list[str]"},{name:"weight_name",val:": str | list[str]"},{name:"image_encoder_folder",val:": str | None = '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>) — | |
| 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/pr_13966/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>) — | |
| 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>) — | |
| The name of the weight file to load. If a list is passed, it should have the same length as | |
| <code>subfolder</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>) — | |
| 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="image_encoder"</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="different_subfolder/image_encoder"</code>.`,name:"image_encoder_folder"},{anchor:"diffusers.loaders.IPAdapterMixin.load_ip_adapter.cache_dir",description:`<strong>cache_dir</strong> (<code>str | os.PathLike</code>, <em>optional</em>) — | |
| 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>) — | |
| 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.proxies",description:`<strong>proxies</strong> (<code>dict[str, str]</code>, <em>optional</em>) — | |
| A dictionary of proxy servers to use by protocol or endpoint, for example, <code>{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}</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>) — | |
| Whether to only load local model weights and configuration files or not. If set to <code>True</code>, the model | |
| won’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>) — | |
| 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>"main"</code>) — | |
| 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 >= 1.9.0 else <code>False</code>) — | |
| 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 >= 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"}]}),s(u);var g=e(u,2),j=r(g);a(j,{name:"set_ip_adapter_scale",anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L252",parameters:[{name:"scale",val:""}]});var X=e(j,4);m(X,{anchor:"diffusers.loaders.IPAdapterMixin.set_ip_adapter_scale.example",children:(t,n)=>{var o=x(),d=e(l(o),2);p(d,{code:"JTIzJTIwVG8lMjB1c2UlMjBvcmlnaW5hbCUyMElQLUFkYXB0ZXIlMEFzY2FsZSUyMCUzRCUyMDEuMCUwQXBpcGVsaW5lLnNldF9pcF9hZGFwdGVyX3NjYWxlKHNjYWxlKSUwQSUwQSUyMyUyMFRvJTIwdXNlJTIwc3R5bGUlMjBibG9jayUyMG9ubHklMEFzY2FsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMnVwJTIyJTNBJTIwJTdCJTIyYmxvY2tfMCUyMiUzQSUyMCU1QjAuMCUyQyUyMDEuMCUyQyUyMDAuMCU1RCU3RCUyQyUwQSU3RCUwQXBpcGVsaW5lLnNldF9pcF9hZGFwdGVyX3NjYWxlKHNjYWxlKSUwQSUwQSUyMyUyMFRvJTIwdXNlJTIwc3R5bGUlMkJsYXlvdXQlMjBibG9ja3MlMEFzY2FsZSUyMCUzRCUyMCU3QiUwQSUyMCUyMCUyMCUyMCUyMmRvd24lMjIlM0ElMjAlN0IlMjJibG9ja18yJTIyJTNBJTIwJTVCMC4wJTJDJTIwMS4wJTVEJTdEJTJDJTBBJTIwJTIwJTIwJTIwJTIydXAlMjIlM0ElMjAlN0IlMjJibG9ja18wJTIyJTNBJTIwJTVCMC4wJTJDJTIwMS4wJTJDJTIwMC4wJTVEJTdEJTJDJTBBJTdEJTBBcGlwZWxpbmUuc2V0X2lwX2FkYXB0ZXJfc2NhbGUoc2NhbGUpJTBBJTBBJTIzJTIwVG8lMjB1c2UlMjBzdHlsZSUyMGFuZCUyMGxheW91dCUyMGZyb20lMjAyJTIwcmVmZXJlbmNlJTIwaW1hZ2VzJTBBc2NhbGVzJTIwJTNEJTIwJTVCJTdCJTIyZG93biUyMiUzQSUyMCU3QiUyMmJsb2NrXzIlMjIlM0ElMjAlNUIwLjAlMkMlMjAxLjAlNUQlN0QlN0QlMkMlMjAlN0IlMjJ1cCUyMiUzQSUyMCU3QiUyMmJsb2NrXzAlMjIlM0ElMjAlNUIwLjAlMkMlMjAxLjAlMkMlMjAwLjAlNUQlN0QlN0QlNUQlMEFwaXBlbGluZS5zZXRfaXBfYWRhcHRlcl9zY2FsZShzY2FsZXMp",highlighted:`<span class="hljs-comment"># To use original IP-Adapter</span> | |
| scale = <span class="hljs-number">1.0</span> | |
| pipeline.set_ip_adapter_scale(scale) | |
| <span class="hljs-comment"># To use style block only</span> | |
| scale = { | |
| <span class="hljs-string">"up"</span>: {<span class="hljs-string">"block_0"</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>, <span class="hljs-number">0.0</span>]}, | |
| } | |
| pipeline.set_ip_adapter_scale(scale) | |
| <span class="hljs-comment"># To use style+layout blocks</span> | |
| scale = { | |
| <span class="hljs-string">"down"</span>: {<span class="hljs-string">"block_2"</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>]}, | |
| <span class="hljs-string">"up"</span>: {<span class="hljs-string">"block_0"</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>, <span class="hljs-number">0.0</span>]}, | |
| } | |
| pipeline.set_ip_adapter_scale(scale) | |
| <span class="hljs-comment"># To use style and layout from 2 reference images</span> | |
| scales = [{<span class="hljs-string">"down"</span>: {<span class="hljs-string">"block_2"</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>]}}, {<span class="hljs-string">"up"</span>: {<span class="hljs-string">"block_0"</span>: [<span class="hljs-number">0.0</span>, <span class="hljs-number">1.0</span>, <span class="hljs-number">0.0</span>]}}] | |
| pipeline.set_ip_adapter_scale(scales)`,lang:"py",wrap:!1}),i(t,o)},$$slots:{default:!0}}),s(g);var J=e(g,2),k=r(J);a(k,{name:"unload_ip_adapter",anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L305",parameters:[]});var Z=e(k,4);m(Z,{anchor:"diffusers.loaders.IPAdapterMixin.unload_ip_adapter.example",children:(t,n)=>{var o=ne(),d=e(l(o),2);p(d,{code:"JTIzJTIwQXNzdW1pbmclMjAlNjBwaXBlbGluZSU2MCUyMGlzJTIwYWxyZWFkeSUyMGxvYWRlZCUyMHdpdGglMjB0aGUlMjBJUCUyMEFkYXB0ZXIlMjB3ZWlnaHRzLiUwQXBpcGVsaW5lLnVubG9hZF9pcF9hZGFwdGVyKCklMEEuLi4=",highlighted:'<span class="hljs-meta">>>> </span><span class="hljs-comment"># Assuming `pipeline` is already loaded with the IP Adapter weights.</span>\n<span class="hljs-meta">>>> </span>pipeline.unload_ip_adapter()\n<span class="hljs-meta">>>> </span>...',lang:"python",wrap:!1}),i(t,o)},$$slots:{default:!0}}),s(J),s(f);var z=e(f,2);c(z,{title:"SD3IPAdapterMixin",local:"diffusers.loaders.SD3IPAdapterMixin",headingTag:"h2"});var _=e(z,2),C=r(_);a(C,{name:"class diffusers.loaders.SD3IPAdapterMixin",anchor:"diffusers.loaders.SD3IPAdapterMixin",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L897",parameters:[]});var b=e(C,4),Q=r(b);a(Q,{name:"is_ip_adapter_active",anchor:"diffusers.loaders.SD3IPAdapterMixin.is_ip_adapter_active",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L900",parameters:[],returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>True when IP-Adapter is loaded and any layer has scale > 0.</p> | |
| `,returnType:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p><code>bool</code></p> | |
| `}),w(4),s(b);var M=e(b,2),E=r(M);a(E,{name:"load_ip_adapter",anchor:"diffusers.loaders.SD3IPAdapterMixin.load_ip_adapter",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L918",parameters:[{name:"pretrained_model_name_or_path_or_dict",val:": str | dict[str, torch.Tensor]"},{name:"weight_name",val:": str = 'ip-adapter.safetensors'"},{name:"subfolder",val:": str | None = None"},{name:"image_encoder_folder",val:": str | None = 'image_encoder'"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.loaders.SD3IPAdapterMixin.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>) — | |
| Can be either: | |
| <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/pr_13966/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.SD3IPAdapterMixin.load_ip_adapter.weight_name",description:`<strong>weight_name</strong> (<code>str</code>, defaults to “ip-adapter.safetensors”) — | |
| The name of the weight file to load. If a list is passed, it should have the same length as | |
| <code>subfolder</code>.`,name:"weight_name"},{anchor:"diffusers.loaders.SD3IPAdapterMixin.load_ip_adapter.subfolder",description:`<strong>subfolder</strong> (<code>str</code>, <em>optional</em>) — | |
| 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.SD3IPAdapterMixin.load_ip_adapter.image_encoder_folder",description:`<strong>image_encoder_folder</strong> (<code>str</code>, <em>optional</em>, defaults to <code>image_encoder</code>) — | |
| 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="image_encoder"</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="different_subfolder/image_encoder"</code>.`,name:"image_encoder_folder"},{anchor:"diffusers.loaders.SD3IPAdapterMixin.load_ip_adapter.cache_dir",description:`<strong>cache_dir</strong> (<code>str | os.PathLike</code>, <em>optional</em>) — | |
| 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.SD3IPAdapterMixin.load_ip_adapter.force_download",description:`<strong>force_download</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| 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.SD3IPAdapterMixin.load_ip_adapter.proxies",description:`<strong>proxies</strong> (<code>dict[str, str]</code>, <em>optional</em>) — | |
| A dictionary of proxy servers to use by protocol or endpoint, for example, <code>{'http': 'foo.bar:3128', 'http://hostname': 'foo.bar:4012'}</code>. The proxies are used on each request.`,name:"proxies"},{anchor:"diffusers.loaders.SD3IPAdapterMixin.load_ip_adapter.local_files_only",description:`<strong>local_files_only</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to only load local model weights and configuration files or not. If set to <code>True</code>, the model | |
| won’t be downloaded from the Hub.`,name:"local_files_only"},{anchor:"diffusers.loaders.SD3IPAdapterMixin.load_ip_adapter.token",description:`<strong>token</strong> (<code>str</code> or <em>bool</em>, <em>optional</em>) — | |
| 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.SD3IPAdapterMixin.load_ip_adapter.revision",description:`<strong>revision</strong> (<code>str</code>, <em>optional</em>, defaults to <code>"main"</code>) — | |
| 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.SD3IPAdapterMixin.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 >= 1.9.0 else <code>False</code>) — | |
| 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 >= 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"}]}),s(M);var y=e(M,2),S=r(y);a(S,{name:"set_ip_adapter_scale",anchor:"diffusers.loaders.SD3IPAdapterMixin.set_ip_adapter_scale",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L1066",parameters:[{name:"scale",val:": float"}],parametersDescription:[{anchor:"diffusers.loaders.SD3IPAdapterMixin.set_ip_adapter_scale.scale",description:`<strong>scale</strong> (float) — | |
| IP-Adapter scale to be set.`,name:"scale"}]});var V=e(S,4);m(V,{anchor:"diffusers.loaders.SD3IPAdapterMixin.set_ip_adapter_scale.example",children:(t,n)=>{var o=x(),d=e(l(o),2);p(d,{code:"JTIzJTIwQXNzdW1pbmclMjAlNjBwaXBlbGluZSU2MCUyMGlzJTIwYWxyZWFkeSUyMGxvYWRlZCUyMHdpdGglMjB0aGUlMjBJUCUyMEFkYXB0ZXIlMjB3ZWlnaHRzLiUwQXBpcGVsaW5lLnNldF9pcF9hZGFwdGVyX3NjYWxlKDAuNiklMEEuLi4=",highlighted:'<span class="hljs-meta">>>> </span><span class="hljs-comment"># Assuming `pipeline` is already loaded with the IP Adapter weights.</span>\n<span class="hljs-meta">>>> </span>pipeline.set_ip_adapter_scale(<span class="hljs-number">0.6</span>)\n<span class="hljs-meta">>>> </span>...',lang:"python",wrap:!1}),i(t,o)},$$slots:{default:!0}}),s(y);var G=e(y,2),B=r(G);a(B,{name:"unload_ip_adapter",anchor:"diffusers.loaders.SD3IPAdapterMixin.unload_ip_adapter",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/loaders/ip_adapter.py#L1089",parameters:[]});var Y=e(B,4);m(Y,{anchor:"diffusers.loaders.SD3IPAdapterMixin.unload_ip_adapter.example",children:(t,n)=>{var o=x(),d=e(l(o),2);p(d,{code:"JTIzJTIwQXNzdW1pbmclMjAlNjBwaXBlbGluZSU2MCUyMGlzJTIwYWxyZWFkeSUyMGxvYWRlZCUyMHdpdGglMjB0aGUlMjBJUCUyMEFkYXB0ZXIlMjB3ZWlnaHRzLiUwQXBpcGVsaW5lLnVubG9hZF9pcF9hZGFwdGVyKCklMEEuLi4=",highlighted:'<span class="hljs-meta">>>> </span><span class="hljs-comment"># Assuming `pipeline` is already loaded with the IP Adapter weights.</span>\n<span class="hljs-meta">>>> </span>pipeline.unload_ip_adapter()\n<span class="hljs-meta">>>> </span>...',lang:"python",wrap:!1}),i(t,o)},$$slots:{default:!0}}),s(G),s(_);var D=e(_,2);c(D,{title:"IPAdapterMaskProcessor",local:"diffusers.IPAdapterMaskProcessor",headingTag:"h2"});var v=e(D,2),N=r(v);a(N,{name:"class diffusers.IPAdapterMaskProcessor",anchor:"diffusers.IPAdapterMaskProcessor",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/image_processor.py#L1270",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.IPAdapterMaskProcessor.do_resize",description:`<strong>do_resize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to downscale the image’s (height, width) dimensions to multiples of <code>vae_scale_factor</code>.`,name:"do_resize"},{anchor:"diffusers.IPAdapterMaskProcessor.vae_scale_factor",description:`<strong>vae_scale_factor</strong> (<code>int</code>, <em>optional</em>, defaults to <code>8</code>) — | |
| 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.IPAdapterMaskProcessor.resample",description:`<strong>resample</strong> (<code>str</code>, <em>optional</em>, defaults to <code>lanczos</code>) — | |
| Resampling filter to use when resizing the image.`,name:"resample"},{anchor:"diffusers.IPAdapterMaskProcessor.do_normalize",description:`<strong>do_normalize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>False</code>) — | |
| Whether to normalize the image to [-1,1].`,name:"do_normalize"},{anchor:"diffusers.IPAdapterMaskProcessor.do_binarize",description:`<strong>do_binarize</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) — | |
| Whether to binarize the image to 0/1.`,name:"do_binarize"},{anchor:"diffusers.IPAdapterMaskProcessor.do_convert_grayscale",description:`<strong>do_convert_grayscale</strong> (<code>bool</code>, <em>optional</em>, defaults to be <code>True</code>) — | |
| Whether to convert the images to grayscale format.`,name:"do_convert_grayscale"}]});var q=e(N,4),H=r(q);a(H,{name:"downsample",anchor:"diffusers.IPAdapterMaskProcessor.downsample",source:"https://github.com/huggingface/diffusers/blob/vr_13966/src/diffusers/image_processor.py#L1311",parameters:[{name:"mask",val:": Tensor"},{name:"batch_size",val:": int"},{name:"num_queries",val:": int"},{name:"value_embed_dim",val:": int"}],parametersDescription:[{anchor:"diffusers.IPAdapterMaskProcessor.downsample.mask",description:`<strong>mask</strong> (<code>torch.Tensor</code>) — | |
| The input mask tensor generated with <code>IPAdapterMaskProcessor.preprocess()</code>.`,name:"mask"},{anchor:"diffusers.IPAdapterMaskProcessor.downsample.batch_size",description:`<strong>batch_size</strong> (<code>int</code>) — | |
| The batch size.`,name:"batch_size"},{anchor:"diffusers.IPAdapterMaskProcessor.downsample.num_queries",description:`<strong>num_queries</strong> (<code>int</code>) — | |
| The number of queries.`,name:"num_queries"},{anchor:"diffusers.IPAdapterMaskProcessor.downsample.value_embed_dim",description:`<strong>value_embed_dim</strong> (<code>int</code>) — | |
| The dimensionality of the value embeddings.`,name:"value_embed_dim"}],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.Tensor</code></p> | |
| `}),w(2),s(q),s(v);var R=e(v,2);ee(R,{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/loaders/ip_adapter.md"}),w(2),i(F,I),se()}export{he as component}; | |
Xet Storage Details
- Size:
- 26.8 kB
- Xet hash:
- 6cd51318ffae5860e070e4f041ff9b320fc1c2ebd943193489c65d767027dd6c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.