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

<span class="hljs-meta">&gt;&gt;&gt; </span>model_ckpt = <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionModelEditingPipeline.from_pretrained(model_ckpt)

<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>source_prompt = <span class="hljs-string">&quot;A pack of roses&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>destination_prompt = <span class="hljs-string">&quot;A pack of blue roses&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.edit_model(source_prompt, destination_prompt)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A field of roses&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipe(prompt).images[<span class="hljs-number">0</span>]`}}),{c(){m=o("p"),T=r("Examples:"),g=c(),E(_.$$.fragment)},l(d){m=n(d,"P",{});var w=s(m);T=l(w,"Examples:"),w.forEach(i),g=f(d),x(_.$$.fragment,d)},m(d,w){u(d,m,w),t(m,T),u(d,g,w),M(_,d,w),v=!0},p:fi,i(d){v||(D(_.$$.fragment,d),v=!0)},o(d){$(_.$$.fragment,d),v=!1},d(d){d&&i(m),d&&i(g),P(_,d)}}}function bi(ce){let m,T,g,_,v,d,w,j,N,y,k,I,ze,Qe,Te,fe,Xe,Se,me,he,He,ke,S,Ye,z,Re,Ke,Q,et,tt,X,it,ot,Ie,C,Ae,L,G,_e,H,nt,be,st,je,h,Y,at,ve,rt,lt,R,dt,ue,pt,ct,ft,A,K,mt,we,ut,gt,W,ht,U,ee,_t,te,bt,ye,vt,wt,yt,Z,ie,Et,oe,xt,ne,Mt,Dt,$t,F,se,Pt,Ee,Tt,St,q,ae,kt,xe,It,Ne,J,B,Me,re,At,De,jt,Le,O,le,Nt,$e,Lt,Je;return d=new Ot({}),C=new mi({props:{$$slots:{default:[hi]},$$scope:{ctx:ce}}}),H=new Ot({}),Y=new pe({props:{name:"class diffusers.StableDiffusionModelEditingPipeline",anchor:"diffusers.StableDiffusionModelEditingPipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": SchedulerMixin"},{name:"safety_checker",val:": StableDiffusionSafetyChecker"},{name:"feature_extractor",val:": CLIPFeatureExtractor"},{name:"requires_safety_checker",val:": bool = True"},{name:"with_to_k",val:": bool = True"},{name:"with_augs",val:": list = ['A photo of ', 'An image of ', 'A picture of ']"}],parametersDescription:[{anchor:"diffusers.StableDiffusionModelEditingPipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.21.0/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.StableDiffusionModelEditingPipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#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.StableDiffusionModelEditingPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.21.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.21.0/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/v0.21.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.21.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.21.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.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.StableDiffusionModelEditingPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPFeatureExtractor</code>) &#x2014;
A <code>CLIPFeatureExtractor</code> to extract features from generated images; used as inputs to the <code>safety_checker</code>.`,name:"feature_extractor"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.with_to_k",description:`<strong>with_to_k</strong> (<code>bool</code>) &#x2014;
Whether to edit the key projection matrices along with the value projection matrices.`,name:"with_to_k"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.with_augs",description:`<strong>with_augs</strong> (<code>list</code>) &#x2014;
Textual augmentations to apply while editing the text-to-image model. Set to <code>[]</code> for no augmentations.`,name:"with_augs"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L39"}}),K=new pe({props:{name:"__call__",anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": typing.Union[str, typing.List[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"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 50) &#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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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/v0.21.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.__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.StableDiffusionModelEditingPipeline.__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"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.cross_attention_kwargs",description:`<strong>cross_attention_kwargs</strong> (<code>dict</code>, <em>optional</em>) &#x2014;
A kwargs dictionary that if specified is passed along to the <code>AttentionProcessor</code> as defined in
<a href="https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L586",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.21.0/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/v0.21.0/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),W=new gi({props:{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.example",$$slots:{default:[_i]},$$scope:{ctx:ce}}}),ee=new pe({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionModelEditingPipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L159"}}),ie=new pe({props:{name:"edit_model",anchor:"diffusers.StableDiffusionModelEditingPipeline.edit_model",parameters:[{name:"source_prompt",val:": str"},{name:"destination_prompt",val:": str"},{name:"lamb",val:": float = 0.1"},{name:"restart_params",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.StableDiffusionModelEditingPipeline.edit_model.source_prompt",description:`<strong>source_prompt</strong> (<code>str</code>) &#x2014;
The source prompt containing the concept to be edited.`,name:"source_prompt"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.edit_model.destination_prompt",description:`<strong>destination_prompt</strong> (<code>str</code>) &#x2014;
The destination prompt. Must contain all words from <code>source_prompt</code> with additional ones to specify the
target edit.`,name:"destination_prompt"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.edit_model.lamb",description:`<strong>lamb</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
The lambda parameter specifying the regularization intesity. Smaller values increase the editing power.`,name:"lamb"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.edit_model.restart_params",description:`<strong>restart_params</strong> (<code>bool</code>, <em>optional</em>, defaults to True) &#x2014;
Restart the model parameters to their pre-trained version before editing. This is done to avoid edit
compounding. When it is <code>False</code>, edits accumulate.`,name:"restart_params"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L468"}}),se=new pe({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionModelEditingPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L151"}}),ae=new pe({props:{name:"encode_prompt",anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt",parameters:[{name:"prompt",val:""},{name:"device",val:""},{name:"num_images_per_prompt",val:""},{name:"do_classifier_free_guidance",val:""},{name:"negative_prompt",val:" = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"lora_scale",val:": typing.Optional[float] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded
device &#x2014; (<code>torch.device</code>):
torch device`,name:"prompt"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) &#x2014;
number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>) &#x2014;
whether to use classifier free guidance or not`,name:"do_classifier_free_guidance"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.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, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.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, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.lora_scale",description:`<strong>lora_scale</strong> (<code>float</code>, <em>optional</em>) &#x2014;
A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded.`,name:"lora_scale"}],source:"https://github.com/huggingface/diffusers/blob/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L198"}}),re=new Ot({}),le=new pe({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/v0.21.0/src/diffusers/pipelines/stable_diffusion/pipeline_output.py#L15"}}),{c(){m=o("meta"),T=c(),g=o("h1"),_=o("a"),v=o("span"),E(d.$$.fragment),w=c(),j=o("span"),N=r("Text-to-image model editing"),y=c(),k=o("p"),I=o("a"),ze=r("Editing Implicit Assumptions in Text-to-Image Diffusion Models"),Qe=r(" is by Hadas Orgad, Bahjat Kawar, and Yonatan Belinkov. This pipeline enables editing diffusion model weights, such that its assumptions of a given concept are changed. The resulting change is expected to take effect in all prompt generations related to the edited concept."),Te=c(),fe=o("p"),Xe=r("The abstract from the paper is:"),Se=c(),me=o("p"),he=o("em"),He=r("Text-to-image diffusion models often make implicit assumptions about the world when generating images. While some assumptions are useful (e.g., the sky is blue), they can also be outdated, incorrect, or reflective of social biases present in the training data. Thus, there is a need to control these assumptions without requiring explicit user input or costly re-training. In this work, we aim to edit a given implicit assumption in a pre-trained diffusion model. Our Text-to-Image Model Editing method, TIME for short, receives a pair of inputs: a \u201Csource\u201D under-specified prompt for which the model makes an implicit assumption (e.g., \u201Ca pack of roses\u201D), and a \u201Cdestination\u201D prompt that describes the same setting, but with a specified desired attribute (e.g., \u201Ca pack of blue roses\u201D). TIME then updates the model\u2019s cross-attention layers, as these layers assign visual meaning to textual tokens. We edit the projection matrices in these layers such that the source prompt is projected close to the destination prompt. Our method is highly efficient, as it modifies a mere 2.2% of the model\u2019s parameters in under one second. To evaluate model editing approaches, we introduce TIMED (TIME Dataset), containing 147 source and destination prompt pairs from various domains. Our experiments (using Stable Diffusion) show that TIME is successful in model editing, generalizes well for related prompts unseen during editing, and imposes minimal effect on unrelated generations."),ke=c(),S=o("p"),Ye=r("You can find additional information about model editing on the "),z=o("a"),Re=r("project page"),Ke=r(", "),Q=o("a"),et=r("original codebase"),tt=r(", and try it out in a "),X=o("a"),it=r("demo"),ot=r("."),Ie=c(),E(C.$$.fragment),Ae=c(),L=o("h2"),G=o("a"),_e=o("span"),E(H.$$.fragment),nt=c(),be=o("span"),st=r("StableDiffusionModelEditingPipeline"),je=c(),h=o("div"),E(Y.$$.fragment),at=c(),ve=o("p"),rt=r("Pipeline for text-to-image model editing."),lt=c(),R=o("p"),dt=r("This model inherits from "),ue=o("a"),pt=r("DiffusionPipeline"),ct=r(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),ft=c(),A=o("div"),E(K.$$.fragment),mt=c(),we=o("p"),ut=r("The call function to the pipeline for generation."),gt=c(),E(W.$$.fragment),ht=c(),U=o("div"),E(ee.$$.fragment),_t=c(),te=o("p"),bt=r("Disable sliced VAE decoding. If "),ye=o("code"),vt=r("enable_vae_slicing"),wt=r(` was previously enabled, this method will go back to
computing decoding in one step.`),yt=c(),Z=o("div"),E(ie.$$.fragment),Et=c(),oe=o("p"),xt=r("Apply model editing via closed-form solution (see Eq. 5 in the TIME "),ne=o("a"),Mt=r("paper"),Dt=r(")."),$t=c(),F=o("div"),E(se.$$.fragment),Pt=c(),Ee=o("p"),Tt=r(`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),St=c(),q=o("div"),E(ae.$$.fragment),kt=c(),xe=o("p"),It=r("Encodes the prompt into text encoder hidden states."),Ne=c(),J=o("h2"),B=o("a"),Me=o("span"),E(re.$$.fragment),At=c(),De=o("span"),jt=r("StableDiffusionPipelineOutput"),Le=c(),O=o("div"),E(le.$$.fragment),Nt=c(),$e=o("p"),Lt=r("Output class for Stable Diffusion pipelines."),this.h()},l(e){const p=pi('[data-svelte="svelte-1phssyn"]',document.head);m=n(p,"META",{name:!0,content:!0}),p.forEach(i),T=f(e),g=n(e,"H1",{class:!0});var de=s(g);_=n(de,"A",{id:!0,class:!0,href:!0});var Pe=s(_);v=n(Pe,"SPAN",{});var Ct=s(v);x(d.$$.fragment,Ct),Ct.forEach(i),Pe.forEach(i),w=f(de),j=n(de,"SPAN",{});var Gt=s(j);N=l(Gt,"Text-to-image model editing"),Gt.forEach(i),de.forEach(i),y=f(e),k=n(e,"P",{});var Jt=s(k);I=n(Jt,"A",{href:!0,rel:!0});var Wt=s(I);ze=l(Wt,"Editing Implicit Assumptions in Text-to-Image Diffusion Models"),Wt.forEach(i),Qe=l(Jt," is by Hadas Orgad, Bahjat Kawar, and Yonatan Belinkov. This pipeline enables editing diffusion model weights, such that its assumptions of a given concept are changed. The resulting change is expected to take effect in all prompt generations related to the edited concept."),Jt.forEach(i),Te=f(e),fe=n(e,"P",{});var Ut=s(fe);Xe=l(Ut,"The abstract from the paper is:"),Ut.forEach(i),Se=f(e),me=n(e,"P",{});var Zt=s(me);he=n(Zt,"EM",{});var Ft=s(he);He=l(Ft,"Text-to-image diffusion models often make implicit assumptions about the world when generating images. While some assumptions are useful (e.g., the sky is blue), they can also be outdated, incorrect, or reflective of social biases present in the training data. Thus, there is a need to control these assumptions without requiring explicit user input or costly re-training. In this work, we aim to edit a given implicit assumption in a pre-trained diffusion model. Our Text-to-Image Model Editing method, TIME for short, receives a pair of inputs: a \u201Csource\u201D under-specified prompt for which the model makes an implicit assumption (e.g., \u201Ca pack of roses\u201D), and a \u201Cdestination\u201D prompt that describes the same setting, but with a specified desired attribute (e.g., \u201Ca pack of blue roses\u201D). TIME then updates the model\u2019s cross-attention layers, as these layers assign visual meaning to textual tokens. We edit the projection matrices in these layers such that the source prompt is projected close to the destination prompt. Our method is highly efficient, as it modifies a mere 2.2% of the model\u2019s parameters in under one second. To evaluate model editing approaches, we introduce TIMED (TIME Dataset), containing 147 source and destination prompt pairs from various domains. Our experiments (using Stable Diffusion) show that TIME is successful in model editing, generalizes well for related prompts unseen during editing, and imposes minimal effect on unrelated generations."),Ft.forEach(i),Zt.forEach(i),ke=f(e),S=n(e,"P",{});var V=s(S);Ye=l(V,"You can find additional information about model editing on the "),z=n(V,"A",{href:!0,rel:!0});var qt=s(z);Re=l(qt,"project page"),qt.forEach(i),Ke=l(V,", "),Q=n(V,"A",{href:!0,rel:!0});var Bt=s(Q);et=l(Bt,"original codebase"),Bt.forEach(i),tt=l(V,", and try it out in a "),X=n(V,"A",{href:!0,rel:!0});var Vt=s(X);it=l(Vt,"demo"),Vt.forEach(i),ot=l(V,"."),V.forEach(i),Ie=f(e),x(C.$$.fragment,e),Ae=f(e),L=n(e,"H2",{class:!0});var Oe=s(L);G=n(Oe,"A",{id:!0,class:!0,href:!0});var zt=s(G);_e=n(zt,"SPAN",{});var Qt=s(_e);x(H.$$.fragment,Qt),Qt.forEach(i),zt.forEach(i),nt=f(Oe),be=n(Oe,"SPAN",{});var Xt=s(be);st=l(Xt,"StableDiffusionModelEditingPipeline"),Xt.forEach(i),Oe.forEach(i),je=f(e),h=n(e,"DIV",{class:!0});var b=s(h);x(Y.$$.fragment,b),at=f(b),ve=n(b,"P",{});var Ht=s(ve);rt=l(Ht,"Pipeline for text-to-image model editing."),Ht.forEach(i),lt=f(b),R=n(b,"P",{});var Ce=s(R);dt=l(Ce,"This model inherits from "),ue=n(Ce,"A",{href:!0});var Yt=s(ue);pt=l(Yt,"DiffusionPipeline"),Yt.forEach(i),ct=l(Ce,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Ce.forEach(i),ft=f(b),A=n(b,"DIV",{class:!0});var ge=s(A);x(K.$$.fragment,ge),mt=f(ge),we=n(ge,"P",{});var Rt=s(we);ut=l(Rt,"The call function to the pipeline for generation."),Rt.forEach(i),gt=f(ge),x(W.$$.fragment,ge),ge.forEach(i),ht=f(b),U=n(b,"DIV",{class:!0});var Ge=s(U);x(ee.$$.fragment,Ge),_t=f(Ge),te=n(Ge,"P",{});var We=s(te);bt=l(We,"Disable sliced VAE decoding. If "),ye=n(We,"CODE",{});var Kt=s(ye);vt=l(Kt,"enable_vae_slicing"),Kt.forEach(i),wt=l(We,` was previously enabled, this method will go back to
computing decoding in one step.`),We.forEach(i),Ge.forEach(i),yt=f(b),Z=n(b,"DIV",{class:!0});var Ue=s(Z);x(ie.$$.fragment,Ue),Et=f(Ue),oe=n(Ue,"P",{});var Ze=s(oe);xt=l(Ze,"Apply model editing via closed-form solution (see Eq. 5 in the TIME "),ne=n(Ze,"A",{href:!0,rel:!0});var ei=s(ne);Mt=l(ei,"paper"),ei.forEach(i),Dt=l(Ze,")."),Ze.forEach(i),Ue.forEach(i),$t=f(b),F=n(b,"DIV",{class:!0});var Fe=s(F);x(se.$$.fragment,Fe),Pt=f(Fe),Ee=n(Fe,"P",{});var ti=s(Ee);Tt=l(ti,`Enable sliced VAE decoding. When this option is enabled, the VAE will split the input tensor in slices to
compute decoding in several steps. This is useful to save some memory and allow larger batch sizes.`),ti.forEach(i),Fe.forEach(i),St=f(b),q=n(b,"DIV",{class:!0});var qe=s(q);x(ae.$$.fragment,qe),kt=f(qe),xe=n(qe,"P",{});var ii=s(xe);It=l(ii,"Encodes the prompt into text encoder hidden states."),ii.forEach(i),qe.forEach(i),b.forEach(i),Ne=f(e),J=n(e,"H2",{class:!0});var Be=s(J);B=n(Be,"A",{id:!0,class:!0,href:!0});var oi=s(B);Me=n(oi,"SPAN",{});var ni=s(Me);x(re.$$.fragment,ni),ni.forEach(i),oi.forEach(i),At=f(Be),De=n(Be,"SPAN",{});var si=s(De);jt=l(si,"StableDiffusionPipelineOutput"),si.forEach(i),Be.forEach(i),Le=f(e),O=n(e,"DIV",{class:!0});var Ve=s(O);x(le.$$.fragment,Ve),Nt=f(Ve),$e=n(Ve,"P",{});var ai=s($e);Lt=l(ai,"Output class for Stable Diffusion pipelines."),ai.forEach(i),Ve.forEach(i),this.h()},h(){a(m,"name","hf:doc:metadata"),a(m,"content",JSON.stringify(vi)),a(_,"id","texttoimage-model-editing"),a(_,"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"),a(_,"href","#texttoimage-model-editing"),a(g,"class","relative group"),a(I,"href","https://huggingface.co/papers/2303.08084"),a(I,"rel","nofollow"),a(z,"href","https://time-diffusion.github.io/"),a(z,"rel","nofollow"),a(Q,"href","https://github.com/bahjat-kawar/time-diffusion"),a(Q,"rel","nofollow"),a(X,"href","https://huggingface.co/spaces/bahjat-kawar/time-diffusion"),a(X,"rel","nofollow"),a(G,"id","diffusers.StableDiffusionModelEditingPipeline"),a(G,"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"),a(G,"href","#diffusers.StableDiffusionModelEditingPipeline"),a(L,"class","relative group"),a(ue,"href","/docs/diffusers/v0.21.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),a(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(ne,"href","https://arxiv.org/abs/2303.08084"),a(ne,"rel","nofollow"),a(Z,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(B,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),a(B,"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"),a(B,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),a(J,"class","relative group"),a(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,p){t(document.head,m),u(e,T,p),u(e,g,p),t(g,_),t(_,v),M(d,v,null),t(g,w),t(g,j),t(j,N),u(e,y,p),u(e,k,p),t(k,I),t(I,ze),t(k,Qe),u(e,Te,p),u(e,fe,p),t(fe,Xe),u(e,Se,p),u(e,me,p),t(me,he),t(he,He),u(e,ke,p),u(e,S,p),t(S,Ye),t(S,z),t(z,Re),t(S,Ke),t(S,Q),t(Q,et),t(S,tt),t(S,X),t(X,it),t(S,ot),u(e,Ie,p),M(C,e,p),u(e,Ae,p),u(e,L,p),t(L,G),t(G,_e),M(H,_e,null),t(L,nt),t(L,be),t(be,st),u(e,je,p),u(e,h,p),M(Y,h,null),t(h,at),t(h,ve),t(ve,rt),t(h,lt),t(h,R),t(R,dt),t(R,ue),t(ue,pt),t(R,ct),t(h,ft),t(h,A),M(K,A,null),t(A,mt),t(A,we),t(we,ut),t(A,gt),M(W,A,null),t(h,ht),t(h,U),M(ee,U,null),t(U,_t),t(U,te),t(te,bt),t(te,ye),t(ye,vt),t(te,wt),t(h,yt),t(h,Z),M(ie,Z,null),t(Z,Et),t(Z,oe),t(oe,xt),t(oe,ne),t(ne,Mt),t(oe,Dt),t(h,$t),t(h,F),M(se,F,null),t(F,Pt),t(F,Ee),t(Ee,Tt),t(h,St),t(h,q),M(ae,q,null),t(q,kt),t(q,xe),t(xe,It),u(e,Ne,p),u(e,J,p),t(J,B),t(B,Me),M(re,Me,null),t(J,At),t(J,De),t(De,jt),u(e,Le,p),u(e,O,p),M(le,O,null),t(O,Nt),t(O,$e),t($e,Lt),Je=!0},p(e,[p]){const de={};p&2&&(de.$$scope={dirty:p,ctx:e}),C.$set(de);const Pe={};p&2&&(Pe.$$scope={dirty:p,ctx:e}),W.$set(Pe)},i(e){Je||(D(d.$$.fragment,e),D(C.$$.fragment,e),D(H.$$.fragment,e),D(Y.$$.fragment,e),D(K.$$.fragment,e),D(W.$$.fragment,e),D(ee.$$.fragment,e),D(ie.$$.fragment,e),D(se.$$.fragment,e),D(ae.$$.fragment,e),D(re.$$.fragment,e),D(le.$$.fragment,e),Je=!0)},o(e){$(d.$$.fragment,e),$(C.$$.fragment,e),$(H.$$.fragment,e),$(Y.$$.fragment,e),$(K.$$.fragment,e),$(W.$$.fragment,e),$(ee.$$.fragment,e),$(ie.$$.fragment,e),$(se.$$.fragment,e),$(ae.$$.fragment,e),$(re.$$.fragment,e),$(le.$$.fragment,e),Je=!1},d(e){i(m),e&&i(T),e&&i(g),P(d),e&&i(y),e&&i(k),e&&i(Te),e&&i(fe),e&&i(Se),e&&i(me),e&&i(ke),e&&i(S),e&&i(Ie),P(C,e),e&&i(Ae),e&&i(L),P(H),e&&i(je),e&&i(h),P(Y),P(K),P(W),P(ee),P(ie),P(se),P(ae),e&&i(Ne),e&&i(J),P(re),e&&i(Le),e&&i(O),P(le)}}}const vi={local:"texttoimage-model-editing",sections:[{local:"diffusers.StableDiffusionModelEditingPipeline",title:"StableDiffusionModelEditingPipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"Text-to-image model editing"};function wi(ce){return ci(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Pi extends ri{constructor(m){super();li(this,m,wi,bi,di,{})}}export{Pi as default,vi as metadata};
