import{S as ri,i as li,s as di,e as a,k as d,w,t as n,M as ci,c as s,d as t,m as c,a as r,x as P,h as i,b as f,G as e,g as _,y as I,q as M,o as S,B as $,v as pi,L as wn}from"../../../chunks/vendor-hf-doc-builder.js";import{T as fi}from"../../../chunks/Tip-hf-doc-builder.js";import{D as Ie}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Pn}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as vn}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as yn}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function ui(j){let p,v,h,u,x,l,g,G;return{c(){p=a("p"),v=n("Make sure to check out the Schedulers "),h=a("a"),u=n("guide"),x=n(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),l=a("a"),g=n("reuse components across pipelines"),G=n(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(A){p=s(A,"P",{});var k=r(p);v=i(k,"Make sure to check out the Schedulers "),h=s(k,"A",{href:!0});var Z=r(h);u=i(Z,"guide"),Z.forEach(t),x=i(k," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),l=s(k,"A",{href:!0});var N=r(l);g=i(N,"reuse components across pipelines"),N.forEach(t),G=i(k," section to learn how to efficiently load the same components into multiple pipelines."),k.forEach(t),this.h()},h(){f(h,"href","/using-diffusers/schedulers"),f(l,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(A,k){_(A,p,k),e(p,v),e(p,h),e(h,u),e(p,x),e(p,l),e(l,g),e(p,G)},d(A){A&&t(p)}}}function mi(j){let p,v,h,u,x;return u=new Pn({props:{code:"aW1wb3J0JTIwUElMJTBBaW1wb3J0JTIwcmVxdWVzdHMlMEFpbXBvcnQlMjB0b3JjaCUwQWZyb20lMjBpbyUyMGltcG9ydCUyMEJ5dGVzSU8lMEElMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uSW5zdHJ1Y3RQaXgyUGl4UGlwZWxpbmUlMEElMEElMEFkZWYlMjBkb3dubG9hZF9pbWFnZSh1cmwpJTNBJTBBJTIwJTIwJTIwJTIwcmVzcG9uc2UlMjAlM0QlMjByZXF1ZXN0cy5nZXQodXJsKSUwQSUyMCUyMCUyMCUyMHJldHVybiUyMFBJTC5JbWFnZS5vcGVuKEJ5dGVzSU8ocmVzcG9uc2UuY29udGVudCkpLmNvbnZlcnQoJTIyUkdCJTIyKSUwQSUwQSUwQWltZ191cmwlMjAlM0QlMjAlMjJodHRwcyUzQSUyRiUyRmh1Z2dpbmdmYWNlLmNvJTJGZGF0YXNldHMlMkZkaWZmdXNlcnMlMkZkaWZmdXNlcnMtaW1hZ2VzLWRvY3MlMkZyZXNvbHZlJTJGbWFpbiUyRm1vdW50YWluLnBuZyUyMiUwQSUwQWltYWdlJTIwJTNEJTIwZG93bmxvYWRfaW1hZ2UoaW1nX3VybCkucmVzaXplKCg1MTIlMkMlMjA1MTIpKSUwQSUwQXBpcGUlMjAlM0QlMjBTdGFibGVEaWZmdXNpb25JbnN0cnVjdFBpeDJQaXhQaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTBBJTIwJTIwJTIwJTIwJTIydGltYnJvb2tzJTJGaW5zdHJ1Y3QtcGl4MnBpeCUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiUwQSklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMm1ha2UlMjB0aGUlMjBtb3VudGFpbnMlMjBzbm93eSUyMiUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlM0Rwcm9tcHQlMkMlMjBpbWFnZSUzRGltYWdlKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> PIL
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionInstructPix2PixPipeline


<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">def</span> <span class="hljs-title function_">download_image</span>(<span class="hljs-params">url</span>):
<span class="hljs-meta">... </span>    response = requests.get(url)
<span class="hljs-meta">... </span>    <span class="hljs-keyword">return</span> PIL.Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>img_url = <span class="hljs-string">&quot;https://huggingface.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>image = download_image(img_url).resize((<span class="hljs-number">512</span>, <span class="hljs-number">512</span>))

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;timbrooks/instruct-pix2pix&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;make the mountains snowy&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt=prompt, image=image).images[<span class="hljs-number">0</span>]`}}),{c(){p=a("p"),v=n("Examples:"),h=d(),w(u.$$.fragment)},l(l){p=s(l,"P",{});var g=r(p);v=i(g,"Examples:"),g.forEach(t),h=c(l),P(u.$$.fragment,l)},m(l,g){_(l,p,g),e(p,v),_(l,h,g),I(u,l,g),x=!0},p:wn,i(l){x||(M(u.$$.fragment,l),x=!0)},o(l){S(u.$$.fragment,l),x=!1},d(l){l&&t(p),l&&t(h),$(u,l)}}}function hi(j){let p,v,h,u,x;return u=new Pn({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTIyc2QtY29uY2VwdHMtbGlicmFyeSUyRmNhdC10b3klMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMCUzQ2NhdC10b3klM0UlMjBiYWNrcGFjayUyMiUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTApLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmNhdC1iYWNrcGFjay5wbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipe.load_textual_inversion(<span class="hljs-string">&quot;sd-concepts-library/cat-toy&quot;</span>)

prompt = <span class="hljs-string">&quot;A &lt;cat-toy&gt; backpack&quot;</span>

image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;cat-backpack.png&quot;</span>)`}}),{c(){p=a("p"),v=n("To load a textual inversion embedding vector in \u{1F917} Diffusers format:"),h=d(),w(u.$$.fragment)},l(l){p=s(l,"P",{});var g=r(p);v=i(g,"To load a textual inversion embedding vector in \u{1F917} Diffusers format:"),g.forEach(t),h=c(l),P(u.$$.fragment,l)},m(l,g){_(l,p,g),e(p,v),_(l,h,g),I(u,l,g),x=!0},p:wn,i(l){x||(M(u.$$.fragment,l),x=!0)},o(l){S(u.$$.fragment,l),x=!1},d(l){l&&t(p),l&&t(h),$(u,l)}}}function gi(j){let p,v,h,u,x;return u=new Pn({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEFtb2RlbF9pZCUyMCUzRCUyMCUyMnJ1bndheW1sJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS01JTIyJTBBcGlwZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNikudG8oJTIyY3VkYSUyMiklMEElMEFwaXBlLmxvYWRfdGV4dHVhbF9pbnZlcnNpb24oJTIyLiUyRmNoYXJ0dXJuZXJ2Mi5wdCUyMiUyQyUyMHRva2VuJTNEJTIyY2hhcnR1cm5lcnYyJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMmNoYXJ0dXJuZXJ2MiUyQyUyMG11bHRpcGxlJTIwdmlld3MlMjBvZiUyMHRoZSUyMHNhbWUlMjBjaGFyYWN0ZXIlMjBpbiUyMHRoZSUyMHNhbWUlMjBvdXRmaXQlMkMlMjBhJTIwY2hhcmFjdGVyJTIwdHVybmFyb3VuZCUyMG9mJTIwYSUyMHdvbWFuJTIwd2VhcmluZyUyMGElMjBibGFjayUyMGphY2tldCUyMGFuZCUyMHJlZCUyMHNoaXJ0JTJDJTIwYmVzdCUyMHF1YWxpdHklMkMlMjBpbnRyaWNhdGUlMjBkZXRhaWxzLiUyMiUwQSUwQWltYWdlJTIwJTNEJTIwcGlwZShwcm9tcHQlMkMlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTApLmltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKCUyMmNoYXJhY3Rlci5wbmclMjIp",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionPipeline
<span class="hljs-keyword">import</span> torch

model_id = <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to(<span class="hljs-string">&quot;cuda&quot;</span>)

pipe.load_textual_inversion(<span class="hljs-string">&quot;./charturnerv2.pt&quot;</span>, token=<span class="hljs-string">&quot;charturnerv2&quot;</span>)

prompt = <span class="hljs-string">&quot;charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details.&quot;</span>

image = pipe(prompt, num_inference_steps=<span class="hljs-number">50</span>).images[<span class="hljs-number">0</span>]
image.save(<span class="hljs-string">&quot;character.png&quot;</span>)`}}),{c(){p=a("p"),v=n("locally:"),h=d(),w(u.$$.fragment)},l(l){p=s(l,"P",{});var g=r(p);v=i(g,"locally:"),g.forEach(t),h=c(l),P(u.$$.fragment,l)},m(l,g){_(l,p,g),e(p,v),_(l,h,g),I(u,l,g),x=!0},p:wn,i(l){x||(M(u.$$.fragment,l),x=!0)},o(l){S(u.$$.fragment,l),x=!1},d(l){l&&t(p),l&&t(h),$(u,l)}}}function _i(j){let p,v,h,u,x,l,g,G,A,k,Z,N,kt,Ut,pt,Me,Et,ft,Se,Be,Jt,ut,U,Lt,ae,Ct,jt,se,Zt,Nt,re,Wt,Gt,mt,Q,ht,B,V,Fe,le,At,Re,Bt,gt,b,de,Ft,qe,Rt,qt,ce,Yt,$e,Xt,Qt,Vt,Ye,zt,Ht,F,De,Te,Ot,Kt,eo,ke,Ue,to,oo,no,Ee,Je,io,ao,so,W,pe,ro,Xe,lo,co,z,po,D,fe,fo,ue,uo,Le,mo,ho,go,Qe,_o,bo,H,xo,me,vo,he,yo,wo,Po,O,Io,T,ge,Mo,L,So,Ve,$o,Do,ze,To,ko,He,Uo,Eo,Jo,_e,Lo,Oe,Co,jo,Zo,be,No,Ce,Wo,Go,Ao,R,Bo,je,Fo,Ro,Ke,qo,Yo,Xo,q,Qo,Ze,Vo,zo,et,Ho,Oo,Ko,K,xe,en,tt,tn,on,ee,ve,nn,C,an,ot,sn,rn,nt,ln,dn,it,cn,pn,_t,Y,te,at,ye,fn,st,un,bt,X,we,mn,rt,hn,xt;return l=new vn({}),Q=new fi({props:{$$slots:{default:[ui]},$$scope:{ctx:j}}}),le=new vn({}),de=new Ie({props:{name:"class diffusers.StableDiffusionInstructPix2PixPipeline",anchor:"diffusers.StableDiffusionInstructPix2PixPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPImageProcessor"},{name:"requires_safety_checker",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIPTextModel</a>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>StableDiffusionSafetyChecker</code>) &#x2014;
Classification module that estimates whether generated images could be considered offensive or harmful.
Please refer to the <a href="https://huggingface.co/runwayml/stable-diffusion-v1-5" rel="nofollow">model card</a> for more details
about a model&#x2019;s potential harms.`,name:"safety_checker"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPImageProcessor" rel="nofollow">CLIPImageProcessor</a>) &#x2014;
A <code>CLIPImageProcessor</code> to extract features from generated images; used as inputs to the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py#L71"}}),pe=new Ie({props:{name:"__call__",anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image, numpy.ndarray, typing.List[torch.FloatTensor], typing.List[PIL.Image.Image], typing.List[numpy.ndarray]] = None"},{name:"num_inference_steps",val:": int = 100"},{name:"guidance_scale",val:": float = 7.5"},{name:"image_guidance_scale",val:": float = 1.5"},{name:"negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"}],parametersDescription:[{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide image generation. If not defined, you need to pass <code>prompt_embeds</code>.`,name:"prompt"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code> <code>np.ndarray</code>, <code>PIL.Image.Image</code>, <code>List[torch.FloatTensor]</code>, <code>List[PIL.Image.Image]</code>, or <code>List[np.ndarray]</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to be repainted according to <code>prompt</code>. Can also accept
image latents as <code>image</code>, but if passing latents directly it is not encoded again.`,name:"image"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 100) &#x2014;
The number of denoising steps. More denoising steps usually lead to a higher quality image at the
expense of slower inference.`,name:"num_inference_steps"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 7.5) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.image_guidance_scale",description:`<strong>image_guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 1.5) &#x2014;
Push the generated image towards the inital <code>image</code>. Image guidance scale is enabled by setting
<code>image_guidance_scale &gt; 1</code>. Higher image guidance scale encourages generated images that are closely
linked to the source <code>image</code>, usually at the expense of lower image quality. This pipeline requires a
value of at least <code>1</code>.`,name:"image_guidance_scale"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide what to not include in image generation. If not defined, you need to
pass <code>negative_prompt_embeds</code> instead. Ignored when not using guidance (<code>guidance_scale &lt; 1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs (prompt weighting). If not
provided, text embeddings are generated from the <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs (prompt weighting). If
not provided, <code>negative_prompt_embeds</code> are generated from the <code>negative_prompt</code> input argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.callback",description:`<strong>callback</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
A function that calls every <code>callback_steps</code> steps during inference. The function is called with the
following arguments: <code>callback(step: int, timestep: int, latents: torch.FloatTensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The frequency at which the <code>callback</code> function is called. If not specified, the callback is called at
every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py#L146",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
\u201Cnot-safe-for-work\u201D (nsfw) content.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),z=new yn({props:{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.example",$$slots:{default:[mi]},$$scope:{ctx:j}}}),fe=new Ie({props:{name:"load_textual_inversion",anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion",parameters:[{name:"pretrained_model_name_or_path",val:": typing.Union[str, typing.List[str], typing.Dict[str, torch.Tensor], typing.List[typing.Dict[str, torch.Tensor]]]"},{name:"token",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.pretrained_model_name_or_path",description:`<strong>pretrained_model_name_or_path</strong> (<code>str</code> or <code>os.PathLike</code> or <code>List[str or os.PathLike]</code> or <code>Dict</code> or <code>List[Dict]</code>) &#x2014;
Can be either one of the following or a list of them:</p>
<ul>
<li>A string, the <em>model id</em> (for example <code>sd-concepts-library/low-poly-hd-logos-icons</code>) of a
pretrained model hosted on the Hub.</li>
<li>A path to a <em>directory</em> (for example <code>./my_text_inversion_directory/</code>) containing the textual
inversion weights.</li>
<li>A path to a <em>file</em> (for example <code>./my_text_inversions.pt</code>) containing textual inversion weights.</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"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.token",description:`<strong>token</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
Override the token to use for the textual inversion weights. If <code>pretrained_model_name_or_path</code> is a
list, then <code>token</code> must also be a list of equal length.`,name:"token"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.weight_name",description:`<strong>weight_name</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Name of a custom weight file. This should be used when:</p>
<ul>
<li>The saved textual inversion file is in &#x1F917; Diffusers format, but was saved under a specific weight
name such as <code>text_inv.bin</code>.</li>
<li>The saved textual inversion file is in the Automatic1111 format.</li>
</ul>`,name:"weight_name"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.use_auth_token",description:`<strong>use_auth_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:"use_auth_token"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.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.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.mirror",description:`<strong>mirror</strong> (<code>str</code>, <em>optional</em>) &#x2014;
Mirror source to resolve accessibility issues if you&#x2019;re downloading a model in China. We do not
guarantee the timeliness or safety of the source, and you should refer to the mirror site for more
information.`,name:"mirror"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders.py#L641"}}),H=new yn({props:{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.example",$$slots:{default:[hi]},$$scope:{ctx:j}}}),O=new yn({props:{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_textual_inversion.example-2",$$slots:{default:[gi]},$$scope:{ctx:j}}}),ge=new Ie({props:{name:"load_lora_weights",anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_lora_weights",parameters:[{name:"pretrained_model_name_or_path_or_dict",val:": typing.Union[str, typing.Dict[str, torch.Tensor]]"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_lora_weights.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;
See <a href="/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.lora_state_dict">lora_state_dict()</a>.`,name:"pretrained_model_name_or_path_or_dict"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.load_lora_weights.kwargs",description:`<strong>kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
See <a href="/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.lora_state_dict">lora_state_dict()</a>.`,name:"kwargs"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders.py#L918"}}),xe=new Ie({props:{name:"save_lora_weights",anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights",parameters:[{name:"save_directory",val:": typing.Union[str, os.PathLike]"},{name:"unet_lora_layers",val:": typing.Dict[str, typing.Union[torch.nn.modules.module.Module, torch.Tensor]] = None"},{name:"text_encoder_lora_layers",val:": typing.Dict[str, torch.nn.modules.module.Module] = None"},{name:"is_main_process",val:": bool = True"},{name:"weight_name",val:": str = None"},{name:"save_function",val:": typing.Callable = None"},{name:"safe_serialization",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights.save_directory",description:`<strong>save_directory</strong> (<code>str</code> or <code>os.PathLike</code>) &#x2014;
Directory to save LoRA parameters to. Will be created if it doesn&#x2019;t exist.`,name:"save_directory"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights.unet_lora_layers",description:`<strong>unet_lora_layers</strong> (<code>Dict[str, torch.nn.Module]</code> or <code>Dict[str, torch.Tensor]</code>) &#x2014;
State dict of the LoRA layers corresponding to the <code>unet</code>.`,name:"unet_lora_layers"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights.text_encoder_lora_layers",description:`<strong>text_encoder_lora_layers</strong> (<code>Dict[str, torch.nn.Module]</code> or <code>Dict[str, torch.Tensor]</code>) &#x2014;
State dict of the LoRA layers corresponding to the <code>text_encoder</code>. Must explicitly pass the text
encoder LoRA state dict because it comes from &#x1F917; Transformers.`,name:"text_encoder_lora_layers"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights.is_main_process",description:`<strong>is_main_process</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether the process calling this is the main process or not. Useful during distributed training and you
need to call this function on all processes. In this case, set <code>is_main_process=True</code> only on the main
process to avoid race conditions.`,name:"is_main_process"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights.save_function",description:`<strong>save_function</strong> (<code>Callable</code>) &#x2014;
The function to use to save the state dictionary. Useful during distributed training when you need to
replace <code>torch.save</code> with another method. Can be configured with the environment variable
<code>DIFFUSERS_SAVE_MODE</code>.`,name:"save_function"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders.py#L1411"}}),ve=new Ie({props:{name:"enable_model_cpu_offload",anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.enable_model_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_instruct_pix2pix.py#L422"}}),ye=new vn({}),we=new Ie({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/__init__.py#L22"}}),{c(){p=a("meta"),v=d(),h=a("h1"),u=a("a"),x=a("span"),w(l.$$.fragment),g=d(),G=a("span"),A=n("InstructPix2Pix"),k=d(),Z=a("p"),N=a("a"),kt=n("InstructPix2Pix: Learning to Follow Image Editing Instructions"),Ut=n(" is by Tim Brooks, Aleksander Holynski and Alexei A. Efros."),pt=d(),Me=a("p"),Et=n("The abstract from the paper is:"),ft=d(),Se=a("p"),Be=a("em"),Jt=n("We propose a method for editing images from human instructions: given an input image and a written instruction that tells the model what to do, our model follows these instructions to edit the image. To obtain training data for this problem, we combine the knowledge of two large pretrained models \u2014 a language model (GPT-3) and a text-to-image model (Stable Diffusion) \u2014 to generate a large dataset of image editing examples. Our conditional diffusion model, InstructPix2Pix, is trained on our generated data, and generalizes to real images and user-written instructions at inference time. Since it performs edits in the forward pass and does not require per example fine-tuning or inversion, our model edits images quickly, in a matter of seconds. We show compelling editing results for a diverse collection of input images and written instructions."),ut=d(),U=a("p"),Lt=n("You can find additional information about InstructPix2Pix on the "),ae=a("a"),Ct=n("project page"),jt=n(", "),se=a("a"),Zt=n("original codebase"),Nt=n(", and try it out in a "),re=a("a"),Wt=n("demo"),Gt=n("."),mt=d(),w(Q.$$.fragment),ht=d(),B=a("h2"),V=a("a"),Fe=a("span"),w(le.$$.fragment),At=d(),Re=a("span"),Bt=n("StableDiffusionInstructPix2PixPipeline"),gt=d(),b=a("div"),w(de.$$.fragment),Ft=d(),qe=a("p"),Rt=n("Pipeline for pixel-level image editing by following text instructions (based on Stable Diffusion)."),qt=d(),ce=a("p"),Yt=n("This model inherits from "),$e=a("a"),Xt=n("DiffusionPipeline"),Qt=n(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Vt=d(),Ye=a("p"),zt=n("The pipeline also inherits the following loading methods:"),Ht=d(),F=a("ul"),De=a("li"),Te=a("a"),Ot=n("load_textual_inversion()"),Kt=n(" for loading textual inversion embeddings"),eo=d(),ke=a("li"),Ue=a("a"),to=n("load_lora_weights()"),oo=n(" for loading LoRA weights"),no=d(),Ee=a("li"),Je=a("a"),io=n("save_lora_weights()"),ao=n(" for saving LoRA weights"),so=d(),W=a("div"),w(pe.$$.fragment),ro=d(),Xe=a("p"),lo=n("The call function to the pipeline for generation."),co=d(),w(z.$$.fragment),po=d(),D=a("div"),w(fe.$$.fragment),fo=d(),ue=a("p"),uo=n("Load textual inversion embeddings into the text encoder of "),Le=a("a"),mo=n("StableDiffusionPipeline"),ho=n(` (both \u{1F917} Diffusers and
Automatic1111 formats are supported).`),go=d(),Qe=a("p"),_o=n("Example:"),bo=d(),w(H.$$.fragment),xo=d(),me=a("p"),vo=n(`To load a textual inversion embedding vector in Automatic1111 format, make sure to download the vector first
(for example from `),he=a("a"),yo=n("civitAI"),wo=n(") and then load the vector"),Po=d(),w(O.$$.fragment),Io=d(),T=a("div"),w(ge.$$.fragment),Mo=d(),L=a("p"),So=n("Load LoRA weights specified in "),Ve=a("code"),$o=n("pretrained_model_name_or_path_or_dict"),Do=n(" into "),ze=a("code"),To=n("self.unet"),ko=n(` and
`),He=a("code"),Uo=n("self.text_encoder"),Eo=n("."),Jo=d(),_e=a("p"),Lo=n("All kwargs are forwarded to "),Oe=a("code"),Co=n("self.lora_state_dict"),jo=n("."),Zo=d(),be=a("p"),No=n("See "),Ce=a("a"),Wo=n("lora_state_dict()"),Go=n(" for more details on how the state dict is loaded."),Ao=d(),R=a("p"),Bo=n("See "),je=a("a"),Fo=n("load_lora_into_unet()"),Ro=n(` for more details on how the state dict is loaded into
`),Ke=a("code"),qo=n("self.unet"),Yo=n("."),Xo=d(),q=a("p"),Qo=n("See "),Ze=a("a"),Vo=n("load_lora_into_text_encoder()"),zo=n(` for more details on how the state dict is loaded
into `),et=a("code"),Ho=n("self.text_encoder"),Oo=n("."),Ko=d(),K=a("div"),w(xe.$$.fragment),en=d(),tt=a("p"),tn=n("Save the LoRA parameters corresponding to the UNet and text encoder."),on=d(),ee=a("div"),w(ve.$$.fragment),nn=d(),C=a("p"),an=n(`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),ot=a("code"),sn=n("forward"),rn=n(` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),nt=a("code"),ln=n("enable_sequential_cpu_offload"),dn=n(`, but performance is much better due to the
iterative execution of the `),it=a("code"),cn=n("unet"),pn=n("."),_t=d(),Y=a("h2"),te=a("a"),at=a("span"),w(ye.$$.fragment),fn=d(),st=a("span"),un=n("StableDiffusionPipelineOutput"),bt=d(),X=a("div"),w(we.$$.fragment),mn=d(),rt=a("p"),hn=n("Output class for Stable Diffusion pipelines."),this.h()},l(o){const m=ci('[data-svelte="svelte-1phssyn"]',document.head);p=s(m,"META",{name:!0,content:!0}),m.forEach(t),v=c(o),h=s(o,"H1",{class:!0});var Pe=r(h);u=s(Pe,"A",{id:!0,class:!0,href:!0});var lt=r(u);x=s(lt,"SPAN",{});var dt=r(x);P(l.$$.fragment,dt),dt.forEach(t),lt.forEach(t),g=c(Pe),G=s(Pe,"SPAN",{});var ct=r(G);A=i(ct,"InstructPix2Pix"),ct.forEach(t),Pe.forEach(t),k=c(o),Z=s(o,"P",{});var gn=r(Z);N=s(gn,"A",{href:!0,rel:!0});var In=r(N);kt=i(In,"InstructPix2Pix: Learning to Follow Image Editing Instructions"),In.forEach(t),Ut=i(gn," is by Tim Brooks, Aleksander Holynski and Alexei A. Efros."),gn.forEach(t),pt=c(o),Me=s(o,"P",{});var Mn=r(Me);Et=i(Mn,"The abstract from the paper is:"),Mn.forEach(t),ft=c(o),Se=s(o,"P",{});var Sn=r(Se);Be=s(Sn,"EM",{});var $n=r(Be);Jt=i($n,"We propose a method for editing images from human instructions: given an input image and a written instruction that tells the model what to do, our model follows these instructions to edit the image. To obtain training data for this problem, we combine the knowledge of two large pretrained models \u2014 a language model (GPT-3) and a text-to-image model (Stable Diffusion) \u2014 to generate a large dataset of image editing examples. Our conditional diffusion model, InstructPix2Pix, is trained on our generated data, and generalizes to real images and user-written instructions at inference time. Since it performs edits in the forward pass and does not require per example fine-tuning or inversion, our model edits images quickly, in a matter of seconds. We show compelling editing results for a diverse collection of input images and written instructions."),$n.forEach(t),Sn.forEach(t),ut=c(o),U=s(o,"P",{});var oe=r(U);Lt=i(oe,"You can find additional information about InstructPix2Pix on the "),ae=s(oe,"A",{href:!0,rel:!0});var Dn=r(ae);Ct=i(Dn,"project page"),Dn.forEach(t),jt=i(oe,", "),se=s(oe,"A",{href:!0,rel:!0});var Tn=r(se);Zt=i(Tn,"original codebase"),Tn.forEach(t),Nt=i(oe,", and try it out in a "),re=s(oe,"A",{href:!0,rel:!0});var kn=r(re);Wt=i(kn,"demo"),kn.forEach(t),Gt=i(oe,"."),oe.forEach(t),mt=c(o),P(Q.$$.fragment,o),ht=c(o),B=s(o,"H2",{class:!0});var vt=r(B);V=s(vt,"A",{id:!0,class:!0,href:!0});var Un=r(V);Fe=s(Un,"SPAN",{});var En=r(Fe);P(le.$$.fragment,En),En.forEach(t),Un.forEach(t),At=c(vt),Re=s(vt,"SPAN",{});var Jn=r(Re);Bt=i(Jn,"StableDiffusionInstructPix2PixPipeline"),Jn.forEach(t),vt.forEach(t),gt=c(o),b=s(o,"DIV",{class:!0});var y=r(b);P(de.$$.fragment,y),Ft=c(y),qe=s(y,"P",{});var Ln=r(qe);Rt=i(Ln,"Pipeline for pixel-level image editing by following text instructions (based on Stable Diffusion)."),Ln.forEach(t),qt=c(y),ce=s(y,"P",{});var yt=r(ce);Yt=i(yt,"This model inherits from "),$e=s(yt,"A",{href:!0});var Cn=r($e);Xt=i(Cn,"DiffusionPipeline"),Cn.forEach(t),Qt=i(yt,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),yt.forEach(t),Vt=c(y),Ye=s(y,"P",{});var jn=r(Ye);zt=i(jn,"The pipeline also inherits the following loading methods:"),jn.forEach(t),Ht=c(y),F=s(y,"UL",{});var Ne=r(F);De=s(Ne,"LI",{});var _n=r(De);Te=s(_n,"A",{href:!0});var Zn=r(Te);Ot=i(Zn,"load_textual_inversion()"),Zn.forEach(t),Kt=i(_n," for loading textual inversion embeddings"),_n.forEach(t),eo=c(Ne),ke=s(Ne,"LI",{});var bn=r(ke);Ue=s(bn,"A",{href:!0});var Nn=r(Ue);to=i(Nn,"load_lora_weights()"),Nn.forEach(t),oo=i(bn," for loading LoRA weights"),bn.forEach(t),no=c(Ne),Ee=s(Ne,"LI",{});var xn=r(Ee);Je=s(xn,"A",{href:!0});var Wn=r(Je);io=i(Wn,"save_lora_weights()"),Wn.forEach(t),ao=i(xn," for saving LoRA weights"),xn.forEach(t),Ne.forEach(t),so=c(y),W=s(y,"DIV",{class:!0});var We=r(W);P(pe.$$.fragment,We),ro=c(We),Xe=s(We,"P",{});var Gn=r(Xe);lo=i(Gn,"The call function to the pipeline for generation."),Gn.forEach(t),co=c(We),P(z.$$.fragment,We),We.forEach(t),po=c(y),D=s(y,"DIV",{class:!0});var E=r(D);P(fe.$$.fragment,E),fo=c(E),ue=s(E,"P",{});var wt=r(ue);uo=i(wt,"Load textual inversion embeddings into the text encoder of "),Le=s(wt,"A",{href:!0});var An=r(Le);mo=i(An,"StableDiffusionPipeline"),An.forEach(t),ho=i(wt,` (both \u{1F917} Diffusers and
Automatic1111 formats are supported).`),wt.forEach(t),go=c(E),Qe=s(E,"P",{});var Bn=r(Qe);_o=i(Bn,"Example:"),Bn.forEach(t),bo=c(E),P(H.$$.fragment,E),xo=c(E),me=s(E,"P",{});var Pt=r(me);vo=i(Pt,`To load a textual inversion embedding vector in Automatic1111 format, make sure to download the vector first
(for example from `),he=s(Pt,"A",{href:!0,rel:!0});var Fn=r(he);yo=i(Fn,"civitAI"),Fn.forEach(t),wo=i(Pt,") and then load the vector"),Pt.forEach(t),Po=c(E),P(O.$$.fragment,E),E.forEach(t),Io=c(y),T=s(y,"DIV",{class:!0});var J=r(T);P(ge.$$.fragment,J),Mo=c(J),L=s(J,"P",{});var ne=r(L);So=i(ne,"Load LoRA weights specified in "),Ve=s(ne,"CODE",{});var Rn=r(Ve);$o=i(Rn,"pretrained_model_name_or_path_or_dict"),Rn.forEach(t),Do=i(ne," into "),ze=s(ne,"CODE",{});var qn=r(ze);To=i(qn,"self.unet"),qn.forEach(t),ko=i(ne,` and
`),He=s(ne,"CODE",{});var Yn=r(He);Uo=i(Yn,"self.text_encoder"),Yn.forEach(t),Eo=i(ne,"."),ne.forEach(t),Jo=c(J),_e=s(J,"P",{});var It=r(_e);Lo=i(It,"All kwargs are forwarded to "),Oe=s(It,"CODE",{});var Xn=r(Oe);Co=i(Xn,"self.lora_state_dict"),Xn.forEach(t),jo=i(It,"."),It.forEach(t),Zo=c(J),be=s(J,"P",{});var Mt=r(be);No=i(Mt,"See "),Ce=s(Mt,"A",{href:!0});var Qn=r(Ce);Wo=i(Qn,"lora_state_dict()"),Qn.forEach(t),Go=i(Mt," for more details on how the state dict is loaded."),Mt.forEach(t),Ao=c(J),R=s(J,"P",{});var Ge=r(R);Bo=i(Ge,"See "),je=s(Ge,"A",{href:!0});var Vn=r(je);Fo=i(Vn,"load_lora_into_unet()"),Vn.forEach(t),Ro=i(Ge,` for more details on how the state dict is loaded into
`),Ke=s(Ge,"CODE",{});var zn=r(Ke);qo=i(zn,"self.unet"),zn.forEach(t),Yo=i(Ge,"."),Ge.forEach(t),Xo=c(J),q=s(J,"P",{});var Ae=r(q);Qo=i(Ae,"See "),Ze=s(Ae,"A",{href:!0});var Hn=r(Ze);Vo=i(Hn,"load_lora_into_text_encoder()"),Hn.forEach(t),zo=i(Ae,` for more details on how the state dict is loaded
into `),et=s(Ae,"CODE",{});var On=r(et);Ho=i(On,"self.text_encoder"),On.forEach(t),Oo=i(Ae,"."),Ae.forEach(t),J.forEach(t),Ko=c(y),K=s(y,"DIV",{class:!0});var St=r(K);P(xe.$$.fragment,St),en=c(St),tt=s(St,"P",{});var Kn=r(tt);tn=i(Kn,"Save the LoRA parameters corresponding to the UNet and text encoder."),Kn.forEach(t),St.forEach(t),on=c(y),ee=s(y,"DIV",{class:!0});var $t=r(ee);P(ve.$$.fragment,$t),nn=c($t),C=s($t,"P",{});var ie=r(C);an=i(ie,`Offload all models to CPU to reduce memory usage with a low impact on performance. Moves one whole model at a
time to the GPU when its `),ot=s(ie,"CODE",{});var ei=r(ot);sn=i(ei,"forward"),ei.forEach(t),rn=i(ie,` method is called, and the model remains in GPU until the next model runs.
Memory savings are lower than using `),nt=s(ie,"CODE",{});var ti=r(nt);ln=i(ti,"enable_sequential_cpu_offload"),ti.forEach(t),dn=i(ie,`, but performance is much better due to the
iterative execution of the `),it=s(ie,"CODE",{});var oi=r(it);cn=i(oi,"unet"),oi.forEach(t),pn=i(ie,"."),ie.forEach(t),$t.forEach(t),y.forEach(t),_t=c(o),Y=s(o,"H2",{class:!0});var Dt=r(Y);te=s(Dt,"A",{id:!0,class:!0,href:!0});var ni=r(te);at=s(ni,"SPAN",{});var ii=r(at);P(ye.$$.fragment,ii),ii.forEach(t),ni.forEach(t),fn=c(Dt),st=s(Dt,"SPAN",{});var ai=r(st);un=i(ai,"StableDiffusionPipelineOutput"),ai.forEach(t),Dt.forEach(t),bt=c(o),X=s(o,"DIV",{class:!0});var Tt=r(X);P(we.$$.fragment,Tt),mn=c(Tt),rt=s(Tt,"P",{});var si=r(rt);hn=i(si,"Output class for Stable Diffusion pipelines."),si.forEach(t),Tt.forEach(t),this.h()},h(){f(p,"name","hf:doc:metadata"),f(p,"content",JSON.stringify(bi)),f(u,"id","instructpix2pix"),f(u,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(u,"href","#instructpix2pix"),f(h,"class","relative group"),f(N,"href","https://huggingface.co/papers/2211.09800"),f(N,"rel","nofollow"),f(ae,"href","https://www.timothybrooks.com/instruct-pix2pix"),f(ae,"rel","nofollow"),f(se,"href","https://github.com/timothybrooks/instruct-pix2pix"),f(se,"rel","nofollow"),f(re,"href","https://huggingface.co/spaces/timbrooks/instruct-pix2pix"),f(re,"rel","nofollow"),f(V,"id","diffusers.StableDiffusionInstructPix2PixPipeline"),f(V,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(V,"href","#diffusers.StableDiffusionInstructPix2PixPipeline"),f(B,"class","relative group"),f($e,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),f(Te,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline.load_textual_inversion"),f(Ue,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline.load_lora_weights"),f(Je,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/inpaint#diffusers.StableDiffusionInpaintPipeline.save_lora_weights"),f(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Le,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),f(he,"href","https://civitai.com/models/3036?modelVersionId=9857"),f(he,"rel","nofollow"),f(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(Ce,"href","/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.lora_state_dict"),f(je,"href","/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.load_lora_into_unet"),f(Ze,"href","/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.load_lora_into_text_encoder"),f(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(te,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),f(te,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),f(te,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),f(Y,"class","relative group"),f(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(o,m){e(document.head,p),_(o,v,m),_(o,h,m),e(h,u),e(u,x),I(l,x,null),e(h,g),e(h,G),e(G,A),_(o,k,m),_(o,Z,m),e(Z,N),e(N,kt),e(Z,Ut),_(o,pt,m),_(o,Me,m),e(Me,Et),_(o,ft,m),_(o,Se,m),e(Se,Be),e(Be,Jt),_(o,ut,m),_(o,U,m),e(U,Lt),e(U,ae),e(ae,Ct),e(U,jt),e(U,se),e(se,Zt),e(U,Nt),e(U,re),e(re,Wt),e(U,Gt),_(o,mt,m),I(Q,o,m),_(o,ht,m),_(o,B,m),e(B,V),e(V,Fe),I(le,Fe,null),e(B,At),e(B,Re),e(Re,Bt),_(o,gt,m),_(o,b,m),I(de,b,null),e(b,Ft),e(b,qe),e(qe,Rt),e(b,qt),e(b,ce),e(ce,Yt),e(ce,$e),e($e,Xt),e(ce,Qt),e(b,Vt),e(b,Ye),e(Ye,zt),e(b,Ht),e(b,F),e(F,De),e(De,Te),e(Te,Ot),e(De,Kt),e(F,eo),e(F,ke),e(ke,Ue),e(Ue,to),e(ke,oo),e(F,no),e(F,Ee),e(Ee,Je),e(Je,io),e(Ee,ao),e(b,so),e(b,W),I(pe,W,null),e(W,ro),e(W,Xe),e(Xe,lo),e(W,co),I(z,W,null),e(b,po),e(b,D),I(fe,D,null),e(D,fo),e(D,ue),e(ue,uo),e(ue,Le),e(Le,mo),e(ue,ho),e(D,go),e(D,Qe),e(Qe,_o),e(D,bo),I(H,D,null),e(D,xo),e(D,me),e(me,vo),e(me,he),e(he,yo),e(me,wo),e(D,Po),I(O,D,null),e(b,Io),e(b,T),I(ge,T,null),e(T,Mo),e(T,L),e(L,So),e(L,Ve),e(Ve,$o),e(L,Do),e(L,ze),e(ze,To),e(L,ko),e(L,He),e(He,Uo),e(L,Eo),e(T,Jo),e(T,_e),e(_e,Lo),e(_e,Oe),e(Oe,Co),e(_e,jo),e(T,Zo),e(T,be),e(be,No),e(be,Ce),e(Ce,Wo),e(be,Go),e(T,Ao),e(T,R),e(R,Bo),e(R,je),e(je,Fo),e(R,Ro),e(R,Ke),e(Ke,qo),e(R,Yo),e(T,Xo),e(T,q),e(q,Qo),e(q,Ze),e(Ze,Vo),e(q,zo),e(q,et),e(et,Ho),e(q,Oo),e(b,Ko),e(b,K),I(xe,K,null),e(K,en),e(K,tt),e(tt,tn),e(b,on),e(b,ee),I(ve,ee,null),e(ee,nn),e(ee,C),e(C,an),e(C,ot),e(ot,sn),e(C,rn),e(C,nt),e(nt,ln),e(C,dn),e(C,it),e(it,cn),e(C,pn),_(o,_t,m),_(o,Y,m),e(Y,te),e(te,at),I(ye,at,null),e(Y,fn),e(Y,st),e(st,un),_(o,bt,m),_(o,X,m),I(we,X,null),e(X,mn),e(X,rt),e(rt,hn),xt=!0},p(o,[m]){const Pe={};m&2&&(Pe.$$scope={dirty:m,ctx:o}),Q.$set(Pe);const lt={};m&2&&(lt.$$scope={dirty:m,ctx:o}),z.$set(lt);const dt={};m&2&&(dt.$$scope={dirty:m,ctx:o}),H.$set(dt);const ct={};m&2&&(ct.$$scope={dirty:m,ctx:o}),O.$set(ct)},i(o){xt||(M(l.$$.fragment,o),M(Q.$$.fragment,o),M(le.$$.fragment,o),M(de.$$.fragment,o),M(pe.$$.fragment,o),M(z.$$.fragment,o),M(fe.$$.fragment,o),M(H.$$.fragment,o),M(O.$$.fragment,o),M(ge.$$.fragment,o),M(xe.$$.fragment,o),M(ve.$$.fragment,o),M(ye.$$.fragment,o),M(we.$$.fragment,o),xt=!0)},o(o){S(l.$$.fragment,o),S(Q.$$.fragment,o),S(le.$$.fragment,o),S(de.$$.fragment,o),S(pe.$$.fragment,o),S(z.$$.fragment,o),S(fe.$$.fragment,o),S(H.$$.fragment,o),S(O.$$.fragment,o),S(ge.$$.fragment,o),S(xe.$$.fragment,o),S(ve.$$.fragment,o),S(ye.$$.fragment,o),S(we.$$.fragment,o),xt=!1},d(o){t(p),o&&t(v),o&&t(h),$(l),o&&t(k),o&&t(Z),o&&t(pt),o&&t(Me),o&&t(ft),o&&t(Se),o&&t(ut),o&&t(U),o&&t(mt),$(Q,o),o&&t(ht),o&&t(B),$(le),o&&t(gt),o&&t(b),$(de),$(pe),$(z),$(fe),$(H),$(O),$(ge),$(xe),$(ve),o&&t(_t),o&&t(Y),$(ye),o&&t(bt),o&&t(X),$(we)}}}const bi={local:"instructpix2pix",sections:[{local:"diffusers.StableDiffusionInstructPix2PixPipeline",title:"StableDiffusionInstructPix2PixPipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"InstructPix2Pix"};function xi(j){return pi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Si extends ri{constructor(p){super();li(this,p,xi,_i,di,{})}}export{Si as default,bi as metadata};
