import{S as ri,i as li,s as di,e as s,k as d,w,t as n,M as ci,c as a,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 D,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=s("p"),v=n("Make sure to check out the Schedulers "),h=s("a"),u=n("guide"),x=n(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),l=s("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=a(A,"P",{});var k=r(p);v=i(k,"Make sure to check out the Schedulers "),h=a(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=a(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=s("p"),v=n("Examples:"),h=d(),w(u.$$.fragment)},l(l){p=a(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),D(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=s("p"),v=n("To load a textual inversion embedding vector in \u{1F917} Diffusers format:"),h=d(),w(u.$$.fragment)},l(l){p=a(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),D(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=s("p"),v=n("locally:"),h=d(),w(u.$$.fragment)},l(l){p=a(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),D(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,se,Ct,jt,ae,Zt,Nt,re,Wt,Gt,mt,Q,ht,B,V,Fe,le,At,Re,Bt,gt,b,de,Ft,qe,Rt,qt,ce,Yt,De,Xt,Qt,Vt,Ye,zt,Ht,F,$e,Te,Ot,Kt,eo,ke,Ue,to,oo,no,Ee,Je,io,so,ao,W,pe,ro,Xe,lo,co,z,po,$,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,Do,$o,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,sn,ot,an,rn,nt,ln,dn,it,cn,pn,_t,Y,te,st,ye,fn,at,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/upscale#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/upscale#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/upscale#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#L632"}}),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#L904"}}),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#L1407"}}),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=s("meta"),v=d(),h=s("h1"),u=s("a"),x=s("span"),w(l.$$.fragment),g=d(),G=s("span"),A=n("InstructPix2Pix"),k=d(),Z=s("p"),N=s("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=s("p"),Et=n("The abstract from the paper is:"),ft=d(),Se=s("p"),Be=s("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=s("p"),Lt=n("You can find additional information about InstructPix2Pix on the "),se=s("a"),Ct=n("project page"),jt=n(", "),ae=s("a"),Zt=n("original codebase"),Nt=n(", and try it out in a "),re=s("a"),Wt=n("demo"),Gt=n("."),mt=d(),w(Q.$$.fragment),ht=d(),B=s("h2"),V=s("a"),Fe=s("span"),w(le.$$.fragment),At=d(),Re=s("span"),Bt=n("StableDiffusionInstructPix2PixPipeline"),gt=d(),b=s("div"),w(de.$$.fragment),Ft=d(),qe=s("p"),Rt=n("Pipeline for pixel-level image editing by following text instructions (based on Stable Diffusion)."),qt=d(),ce=s("p"),Yt=n("This model inherits from "),De=s("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=s("p"),zt=n("The pipeline also inherits the following loading methods:"),Ht=d(),F=s("ul"),$e=s("li"),Te=s("a"),Ot=n("load_textual_inversion()"),Kt=n(" for loading textual inversion embeddings"),eo=d(),ke=s("li"),Ue=s("a"),to=n("load_lora_weights()"),oo=n(" for loading LoRA weights"),no=d(),Ee=s("li"),Je=s("a"),io=n("save_lora_weights()"),so=n(" for saving LoRA weights"),ao=d(),W=s("div"),w(pe.$$.fragment),ro=d(),Xe=s("p"),lo=n("The call function to the pipeline for generation."),co=d(),w(z.$$.fragment),po=d(),$=s("div"),w(fe.$$.fragment),fo=d(),ue=s("p"),uo=n("Load textual inversion embeddings into the text encoder of "),Le=s("a"),mo=n("StableDiffusionPipeline"),ho=n(` (both \u{1F917} Diffusers and
Automatic1111 formats are supported).`),go=d(),Qe=s("p"),_o=n("Example:"),bo=d(),w(H.$$.fragment),xo=d(),me=s("p"),vo=n(`To load a textual inversion embedding vector in Automatic1111 format, make sure to download the vector first
(for example from `),he=s("a"),yo=n("civitAI"),wo=n(") and then load the vector"),Po=d(),w(O.$$.fragment),Io=d(),T=s("div"),w(ge.$$.fragment),Mo=d(),L=s("p"),So=n("Load LoRA weights specified in "),Ve=s("code"),Do=n("pretrained_model_name_or_path_or_dict"),$o=n(" into "),ze=s("code"),To=n("self.unet"),ko=n(` and
`),He=s("code"),Uo=n("self.text_encoder"),Eo=n("."),Jo=d(),_e=s("p"),Lo=n("All kwargs are forwarded to "),Oe=s("code"),Co=n("self.lora_state_dict"),jo=n("."),Zo=d(),be=s("p"),No=n("See "),Ce=s("a"),Wo=n("lora_state_dict()"),Go=n(" for more details on how the state dict is loaded."),Ao=d(),R=s("p"),Bo=n("See "),je=s("a"),Fo=n("load_lora_into_unet()"),Ro=n(` for more details on how the state dict is loaded into
`),Ke=s("code"),qo=n("self.unet"),Yo=n("."),Xo=d(),q=s("p"),Qo=n("See "),Ze=s("a"),Vo=n("load_lora_into_text_encoder()"),zo=n(` for more details on how the state dict is loaded
into `),et=s("code"),Ho=n("self.text_encoder"),Oo=n("."),Ko=d(),K=s("div"),w(xe.$$.fragment),en=d(),tt=s("p"),tn=n("Save the LoRA parameters corresponding to the UNet and text encoder."),on=d(),ee=s("div"),w(ve.$$.fragment),nn=d(),C=s("p"),sn=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=s("code"),an=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=s("code"),ln=n("enable_sequential_cpu_offload"),dn=n(`, but performance is much better due to the
iterative execution of the `),it=s("code"),cn=n("unet"),pn=n("."),_t=d(),Y=s("h2"),te=s("a"),st=s("span"),w(ye.$$.fragment),fn=d(),at=s("span"),un=n("StableDiffusionPipelineOutput"),bt=d(),X=s("div"),w(we.$$.fragment),mn=d(),rt=s("p"),hn=n("Output class for Stable Diffusion pipelines."),this.h()},l(o){const m=ci('[data-svelte="svelte-1phssyn"]',document.head);p=a(m,"META",{name:!0,content:!0}),m.forEach(t),v=c(o),h=a(o,"H1",{class:!0});var Pe=r(h);u=a(Pe,"A",{id:!0,class:!0,href:!0});var lt=r(u);x=a(lt,"SPAN",{});var dt=r(x);P(l.$$.fragment,dt),dt.forEach(t),lt.forEach(t),g=c(Pe),G=a(Pe,"SPAN",{});var ct=r(G);A=i(ct,"InstructPix2Pix"),ct.forEach(t),Pe.forEach(t),k=c(o),Z=a(o,"P",{});var gn=r(Z);N=a(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=a(o,"P",{});var Mn=r(Me);Et=i(Mn,"The abstract from the paper is:"),Mn.forEach(t),ft=c(o),Se=a(o,"P",{});var Sn=r(Se);Be=a(Sn,"EM",{});var Dn=r(Be);Jt=i(Dn,"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."),Dn.forEach(t),Sn.forEach(t),ut=c(o),U=a(o,"P",{});var oe=r(U);Lt=i(oe,"You can find additional information about InstructPix2Pix on the "),se=a(oe,"A",{href:!0,rel:!0});var $n=r(se);Ct=i($n,"project page"),$n.forEach(t),jt=i(oe,", "),ae=a(oe,"A",{href:!0,rel:!0});var Tn=r(ae);Zt=i(Tn,"original codebase"),Tn.forEach(t),Nt=i(oe,", and try it out in a "),re=a(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=a(o,"H2",{class:!0});var vt=r(B);V=a(vt,"A",{id:!0,class:!0,href:!0});var Un=r(V);Fe=a(Un,"SPAN",{});var En=r(Fe);P(le.$$.fragment,En),En.forEach(t),Un.forEach(t),At=c(vt),Re=a(vt,"SPAN",{});var Jn=r(Re);Bt=i(Jn,"StableDiffusionInstructPix2PixPipeline"),Jn.forEach(t),vt.forEach(t),gt=c(o),b=a(o,"DIV",{class:!0});var y=r(b);P(de.$$.fragment,y),Ft=c(y),qe=a(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=a(y,"P",{});var yt=r(ce);Yt=i(yt,"This model inherits from "),De=a(yt,"A",{href:!0});var Cn=r(De);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=a(y,"P",{});var jn=r(Ye);zt=i(jn,"The pipeline also inherits the following loading methods:"),jn.forEach(t),Ht=c(y),F=a(y,"UL",{});var Ne=r(F);$e=a(Ne,"LI",{});var _n=r($e);Te=a(_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=a(Ne,"LI",{});var bn=r(ke);Ue=a(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=a(Ne,"LI",{});var xn=r(Ee);Je=a(xn,"A",{href:!0});var Wn=r(Je);io=i(Wn,"save_lora_weights()"),Wn.forEach(t),so=i(xn," for saving LoRA weights"),xn.forEach(t),Ne.forEach(t),ao=c(y),W=a(y,"DIV",{class:!0});var We=r(W);P(pe.$$.fragment,We),ro=c(We),Xe=a(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),$=a(y,"DIV",{class:!0});var E=r($);P(fe.$$.fragment,E),fo=c(E),ue=a(E,"P",{});var wt=r(ue);uo=i(wt,"Load textual inversion embeddings into the text encoder of "),Le=a(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=a(E,"P",{});var Bn=r(Qe);_o=i(Bn,"Example:"),Bn.forEach(t),bo=c(E),P(H.$$.fragment,E),xo=c(E),me=a(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=a(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=a(y,"DIV",{class:!0});var J=r(T);P(ge.$$.fragment,J),Mo=c(J),L=a(J,"P",{});var ne=r(L);So=i(ne,"Load LoRA weights specified in "),Ve=a(ne,"CODE",{});var Rn=r(Ve);Do=i(Rn,"pretrained_model_name_or_path_or_dict"),Rn.forEach(t),$o=i(ne," into "),ze=a(ne,"CODE",{});var qn=r(ze);To=i(qn,"self.unet"),qn.forEach(t),ko=i(ne,` and
`),He=a(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=a(J,"P",{});var It=r(_e);Lo=i(It,"All kwargs are forwarded to "),Oe=a(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=a(J,"P",{});var Mt=r(be);No=i(Mt,"See "),Ce=a(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=a(J,"P",{});var Ge=r(R);Bo=i(Ge,"See "),je=a(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=a(Ge,"CODE",{});var zn=r(Ke);qo=i(zn,"self.unet"),zn.forEach(t),Yo=i(Ge,"."),Ge.forEach(t),Xo=c(J),q=a(J,"P",{});var Ae=r(q);Qo=i(Ae,"See "),Ze=a(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=a(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=a(y,"DIV",{class:!0});var St=r(K);P(xe.$$.fragment,St),en=c(St),tt=a(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=a(y,"DIV",{class:!0});var Dt=r(ee);P(ve.$$.fragment,Dt),nn=c(Dt),C=a(Dt,"P",{});var ie=r(C);sn=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=a(ie,"CODE",{});var ei=r(ot);an=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=a(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=a(ie,"CODE",{});var oi=r(it);cn=i(oi,"unet"),oi.forEach(t),pn=i(ie,"."),ie.forEach(t),Dt.forEach(t),y.forEach(t),_t=c(o),Y=a(o,"H2",{class:!0});var $t=r(Y);te=a($t,"A",{id:!0,class:!0,href:!0});var ni=r(te);st=a(ni,"SPAN",{});var ii=r(st);P(ye.$$.fragment,ii),ii.forEach(t),ni.forEach(t),fn=c($t),at=a($t,"SPAN",{});var si=r(at);un=i(si,"StableDiffusionPipelineOutput"),si.forEach(t),$t.forEach(t),bt=c(o),X=a(o,"DIV",{class:!0});var Tt=r(X);P(we.$$.fragment,Tt),mn=c(Tt),rt=a(Tt,"P",{});var ai=r(rt);hn=i(ai,"Output class for Stable Diffusion pipelines."),ai.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(se,"href","https://www.timothybrooks.com/instruct-pix2pix"),f(se,"rel","nofollow"),f(ae,"href","https://github.com/timothybrooks/instruct-pix2pix"),f(ae,"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(De,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),f(Te,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_textual_inversion"),f(Ue,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.load_lora_weights"),f(Je,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/depth2img#diffusers.StableDiffusionDepth2ImgPipeline.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($,"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,se),e(se,Ct),e(U,jt),e(U,ae),e(ae,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,De),e(De,Xt),e(ce,Qt),e(b,Vt),e(b,Ye),e(Ye,zt),e(b,Ht),e(b,F),e(F,$e),e($e,Te),e(Te,Ot),e($e,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,so),e(b,ao),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,$),I(fe,$,null),e($,fo),e($,ue),e(ue,uo),e(ue,Le),e(Le,mo),e(ue,ho),e($,go),e($,Qe),e(Qe,_o),e($,bo),I(H,$,null),e($,xo),e($,me),e(me,vo),e(me,he),e(he,yo),e(me,wo),e($,Po),I(O,$,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,Do),e(L,$o),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,sn),e(C,ot),e(ot,an),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,st),I(ye,st,null),e(Y,fn),e(Y,at),e(at,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),D(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),D(Q,o),o&&t(ht),o&&t(B),D(le),o&&t(gt),o&&t(b),D(de),D(pe),D(z),D(fe),D(H),D(O),D(ge),D(xe),D(ve),o&&t(_t),o&&t(Y),D(ye),o&&t(bt),o&&t(X),D(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};
