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 p,G as e,g as _,y as I,q as S,o as M,B as $,v as fi,L as wn}from"../../../chunks/vendor-hf-doc-builder.js";import{T as pi}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 f,v,h,u,x,l,g,G;return{c(){f=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){f=a(A,"P",{});var k=r(f);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(){p(h,"href","/using-diffusers/schedulers"),p(l,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(A,k){_(A,f,k),e(f,v),e(f,h),e(h,u),e(f,x),e(f,l),e(l,g),e(f,G)},d(A){A&&t(f)}}}function mi(j){let f,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(){f=s("p"),v=n("Examples:"),h=d(),w(u.$$.fragment)},l(l){f=a(l,"P",{});var g=r(f);v=i(g,"Examples:"),g.forEach(t),h=c(l),P(u.$$.fragment,l)},m(l,g){_(l,f,g),e(f,v),_(l,h,g),I(u,l,g),x=!0},p:wn,i(l){x||(S(u.$$.fragment,l),x=!0)},o(l){M(u.$$.fragment,l),x=!1},d(l){l&&t(f),l&&t(h),$(u,l)}}}function hi(j){let f,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(){f=s("p"),v=n("To load a textual inversion embedding vector in \u{1F917} Diffusers format:"),h=d(),w(u.$$.fragment)},l(l){f=a(l,"P",{});var g=r(f);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,f,g),e(f,v),_(l,h,g),I(u,l,g),x=!0},p:wn,i(l){x||(S(u.$$.fragment,l),x=!0)},o(l){M(u.$$.fragment,l),x=!1},d(l){l&&t(f),l&&t(h),$(u,l)}}}function gi(j){let f,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(){f=s("p"),v=n("locally:"),h=d(),w(u.$$.fragment)},l(l){f=a(l,"P",{});var g=r(f);v=i(g,"locally:"),g.forEach(t),h=c(l),P(u.$$.fragment,l)},m(l,g){_(l,f,g),e(f,v),_(l,h,g),I(u,l,g),x=!0},p:wn,i(l){x||(S(u.$$.fragment,l),x=!0)},o(l){M(u.$$.fragment,l),x=!1},d(l){l&&t(f),l&&t(h),$(u,l)}}}function _i(j){let f,v,h,u,x,l,g,G,A,k,Z,N,kt,Ut,ft,Se,Et,pt,Me,Be,Jt,ut,U,Lt,se,Ct,jt,ae,Zt,Nt,re,Wt,Gt,mt,Q,ht,B,z,Fe,le,At,Re,Bt,gt,b,de,Ft,qe,Rt,qt,ce,Yt,$e,Xt,Qt,zt,Ye,Vt,Ht,F,De,Te,Ot,Kt,eo,ke,Ue,to,oo,no,Ee,Je,io,so,ao,W,fe,ro,Xe,lo,co,V,fo,D,pe,po,ue,uo,Le,mo,ho,go,Qe,_o,bo,H,xo,me,vo,he,yo,wo,Po,O,Io,T,ge,So,L,Mo,ze,$o,Do,Ve,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,zo,Vo,et,Ho,Oo,Ko,K,xe,en,tt,tn,on,ee,ve,nn,C,sn,ot,an,rn,nt,ln,dn,it,cn,fn,_t,Y,te,st,ye,pn,at,un,bt,X,we,mn,rt,hn,xt;return l=new vn({}),Q=new pi({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"}}),fe=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[PIL.Image.Image, numpy.ndarray, torch.FloatTensor, typing.List[PIL.Image.Image], typing.List[numpy.ndarray], typing.List[torch.FloatTensor]] = 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/img2img#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/img2img#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/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),V=new yn({props:{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.__call__.example",$$slots:{default:[mi]},$$scope:{ctx:j}}}),pe=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[typing.List[str], 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#L656"}}),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#L928"}}),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 = True"}],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"},{anchor:"diffusers.StableDiffusionInstructPix2PixPipeline.save_lora_weights.safe_serialization",description:`<strong>safe_serialization</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether to save the model using <code>safetensors</code> or the traditional PyTorch way with <code>pickle</code>.`,name:"safe_serialization"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/loaders.py#L1534"}}),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#L415"}}),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(){f=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."),ft=d(),Se=s("p"),Et=n("The abstract from the paper is:"),pt=d(),Me=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"),z=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 "),$e=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.).`),zt=d(),Ye=s("p"),Vt=n("The pipeline also inherits the following loading methods:"),Ht=d(),F=s("ul"),De=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(fe.$$.fragment),ro=d(),Xe=s("p"),lo=n("The call function to the pipeline for generation."),co=d(),w(V.$$.fragment),fo=d(),D=s("div"),w(pe.$$.fragment),po=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),So=d(),L=s("p"),Mo=n("Load LoRA weights specified in "),ze=s("code"),$o=n("pretrained_model_name_or_path_or_dict"),Do=n(" into "),Ve=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"),zo=n("load_lora_into_text_encoder()"),Vo=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"),fn=n("."),_t=d(),Y=s("h2"),te=s("a"),st=s("span"),w(ye.$$.fragment),pn=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);f=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),ft=c(o),Se=a(o,"P",{});var Sn=r(Se);Et=i(Sn,"The abstract from the paper is:"),Sn.forEach(t),pt=c(o),Me=a(o,"P",{});var Mn=r(Me);Be=a(Mn,"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),Mn.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 Dn=r(se);Ct=i(Dn,"project page"),Dn.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);z=a(vt,"A",{id:!0,class:!0,href:!0});var Un=r(z);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 "),$e=a(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),zt=c(y),Ye=a(y,"P",{});var jn=r(Ye);Vt=i(jn,"The pipeline also inherits the following loading methods:"),jn.forEach(t),Ht=c(y),F=a(y,"UL",{});var Ne=r(F);De=a(Ne,"LI",{});var _n=r(De);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(fe.$$.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(V.$$.fragment,We),We.forEach(t),fo=c(y),D=a(y,"DIV",{class:!0});var E=r(D);P(pe.$$.fragment,E),po=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),So=c(J),L=a(J,"P",{});var ne=r(L);Mo=i(ne,"Load LoRA weights specified in "),ze=a(ne,"CODE",{});var Rn=r(ze);$o=i(Rn,"pretrained_model_name_or_path_or_dict"),Rn.forEach(t),Do=i(ne," into "),Ve=a(ne,"CODE",{});var qn=r(Ve);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 St=r(be);No=i(St,"See "),Ce=a(St,"A",{href:!0});var Qn=r(Ce);Wo=i(Qn,"lora_state_dict()"),Qn.forEach(t),Go=i(St," for more details on how the state dict is loaded."),St.forEach(t),Ao=c(J),R=a(J,"P",{});var Ge=r(R);Bo=i(Ge,"See "),je=a(Ge,"A",{href:!0});var zn=r(je);Fo=i(zn,"load_lora_into_unet()"),zn.forEach(t),Ro=i(Ge,` for more details on how the state dict is loaded into
`),Ke=a(Ge,"CODE",{});var Vn=r(Ke);qo=i(Vn,"self.unet"),Vn.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);zo=i(Hn,"load_lora_into_text_encoder()"),Hn.forEach(t),Vo=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 Mt=r(K);P(xe.$$.fragment,Mt),en=c(Mt),tt=a(Mt,"P",{});var Kn=r(tt);tn=i(Kn,"Save the LoRA parameters corresponding to the UNet and text encoder."),Kn.forEach(t),Mt.forEach(t),on=c(y),ee=a(y,"DIV",{class:!0});var $t=r(ee);P(ve.$$.fragment,$t),nn=c($t),C=a($t,"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),fn=i(ie,"."),ie.forEach(t),$t.forEach(t),y.forEach(t),_t=c(o),Y=a(o,"H2",{class:!0});var Dt=r(Y);te=a(Dt,"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),pn=c(Dt),at=a(Dt,"SPAN",{});var si=r(at);un=i(si,"StableDiffusionPipelineOutput"),si.forEach(t),Dt.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(){p(f,"name","hf:doc:metadata"),p(f,"content",JSON.stringify(bi)),p(u,"id","instructpix2pix"),p(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"),p(u,"href","#instructpix2pix"),p(h,"class","relative group"),p(N,"href","https://huggingface.co/papers/2211.09800"),p(N,"rel","nofollow"),p(se,"href","https://www.timothybrooks.com/instruct-pix2pix"),p(se,"rel","nofollow"),p(ae,"href","https://github.com/timothybrooks/instruct-pix2pix"),p(ae,"rel","nofollow"),p(re,"href","https://huggingface.co/spaces/timbrooks/instruct-pix2pix"),p(re,"rel","nofollow"),p(z,"id","diffusers.StableDiffusionInstructPix2PixPipeline"),p(z,"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"),p(z,"href","#diffusers.StableDiffusionInstructPix2PixPipeline"),p(B,"class","relative group"),p($e,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(Te,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_textual_inversion"),p(Ue,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.load_lora_weights"),p(Je,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.StableDiffusionImg2ImgPipeline.save_lora_weights"),p(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Le,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),p(he,"href","https://civitai.com/models/3036?modelVersionId=9857"),p(he,"rel","nofollow"),p(D,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Ce,"href","/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.lora_state_dict"),p(je,"href","/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.load_lora_into_unet"),p(Ze,"href","/docs/diffusers/main/en/api/loaders#diffusers.loaders.LoraLoaderMixin.load_lora_into_text_encoder"),p(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(K,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(te,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),p(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"),p(te,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),p(Y,"class","relative group"),p(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,f),_(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,ft,m),_(o,Se,m),e(Se,Et),_(o,pt,m),_(o,Me,m),e(Me,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,z),e(z,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,zt),e(b,Ye),e(Ye,Vt),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,so),e(b,ao),e(b,W),I(fe,W,null),e(W,ro),e(W,Xe),e(Xe,lo),e(W,co),I(V,W,null),e(b,fo),e(b,D),I(pe,D,null),e(D,po),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,So),e(T,L),e(L,Mo),e(L,ze),e(ze,$o),e(L,Do),e(L,Ve),e(Ve,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,zo),e(q,Vo),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,fn),_(o,_t,m),_(o,Y,m),e(Y,te),e(te,st),I(ye,st,null),e(Y,pn),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}),V.$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||(S(l.$$.fragment,o),S(Q.$$.fragment,o),S(le.$$.fragment,o),S(de.$$.fragment,o),S(fe.$$.fragment,o),S(V.$$.fragment,o),S(pe.$$.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=!0)},o(o){M(l.$$.fragment,o),M(Q.$$.fragment,o),M(le.$$.fragment,o),M(de.$$.fragment,o),M(fe.$$.fragment,o),M(V.$$.fragment,o),M(pe.$$.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=!1},d(o){t(f),o&&t(v),o&&t(h),$(l),o&&t(k),o&&t(Z),o&&t(ft),o&&t(Se),o&&t(pt),o&&t(Me),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),$(fe),$(V),$(pe),$(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 fi(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Mi extends ri{constructor(f){super();li(this,f,xi,_i,di,{})}}export{Mi as default,bi as metadata};
