import{s as Ve,o as Qe,n as Be}from"../chunks/scheduler.182ea377.js";import{S as Xe,i as Re,g as r,s as o,r as h,A as Ye,h as l,f as t,c as s,j as E,u as _,x as g,k,y as i,a as d,v as b,d as v,t as w,w as x}from"../chunks/index.1ea56653.js";import{H as je,g as Ke}from"../chunks/Heading.71ac6e9f.js";import{T as et}from"../chunks/Tip.67abc998.js";import{D as V}from"../chunks/Docstring.59aaf0cd.js";import{C as tt}from"../chunks/CodeBlock.82c2494b.js";import{E as nt}from"../chunks/ExampleCodeBlock.95ae1d71.js";function it(Q){let a,$='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){a=r("p"),a.innerHTML=$},l(m){a=l(m,"P",{"data-svelte-h":!0}),g(a)!=="svelte-1wmc0l4"&&(a.innerHTML=$)},m(m,u){d(m,a,u)},p:Be,d(m){m&&t(a)}}}function ot(Q){let a,$="Examples:",m,u,y;return u=new tt({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>]`,wrap:!1}}),{c(){a=r("p"),a.textContent=$,m=o(),h(u.$$.fragment)},l(c){a=l(c,"P",{"data-svelte-h":!0}),g(a)!=="svelte-kvfsh7"&&(a.textContent=$),m=s(c),_(u.$$.fragment,c)},m(c,M){d(c,a,M),d(c,m,M),b(u,c,M),y=!0},p:Be,i(c){y||(v(u.$$.fragment,c),y=!0)},o(c){w(u.$$.fragment,c),y=!1},d(c){c&&(t(a),t(m)),x(u,c)}}}function st(Q){let a,$,m,u,y,c,M,Ne='<a href="https://huggingface.co/papers/2303.08084" rel="nofollow">Editing Implicit Assumptions in Text-to-Image Diffusion Models</a> 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.',se,A,Ae="The abstract from the paper is:",ae,J,Je="<em>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 “source” under-specified prompt for which the model makes an implicit assumption (e.g., “a pack of roses”), and a “destination” prompt that describes the same setting, but with a specified desired attribute (e.g., “a pack of blue roses”). TIME then updates the model’s 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’s 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.</em>",re,O,Oe='You can find additional information about model editing on the <a href="https://time-diffusion.github.io/" rel="nofollow">project page</a>, <a href="https://github.com/bahjat-kawar/time-diffusion" rel="nofollow">original codebase</a>, and try it out in a <a href="https://huggingface.co/spaces/bahjat-kawar/time-diffusion" rel="nofollow">demo</a>.',le,S,de,G,pe,p,F,we,X,Ge="Pipeline for text-to-image model editing.",xe,R,Fe=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,ye,P,U,Me,Y,Ue="The call function to the pipeline for generation.",$e,I,Pe,C,Z,Te,K,Ze=`Disable sliced VAE decoding. If <code>enable_vae_slicing</code> was previously enabled, this method will go back to
computing decoding in one step.`,De,L,W,Ee,ee,We='Apply model editing via closed-form solution (see Eq. 5 in the TIME <a href="https://arxiv.org/abs/2303.08084" rel="nofollow">paper</a>).',ke,j,z,Se,te,ze=`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.`,Ie,N,H,Ce,ne,He="Encodes the prompt into text encoder hidden states.",ce,q,fe,T,B,Le,ie,qe="Output class for Stable Diffusion pipelines.",me,oe,ue;return y=new je({props:{title:"Text-to-image model editing",local:"text-to-image-model-editing",headingTag:"h1"}}),S=new et({props:{$$slots:{default:[it]},$$scope:{ctx:Q}}}),G=new je({props:{title:"StableDiffusionModelEditingPipeline",local:"diffusers.StableDiffusionModelEditingPipeline",headingTag:"h2"}}),F=new V({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/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.StableDiffusionModelEditingPipeline.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.StableDiffusionModelEditingPipeline.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.StableDiffusionModelEditingPipeline.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.StableDiffusionModelEditingPipeline.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.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> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPFeatureExtractor" rel="nofollow">CLIPFeatureExtractor</a>) &#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/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L39"}}),U=new V({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[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"},{name:"cross_attention_kwargs",val:": typing.Union[typing.Dict[str, typing.Any], NoneType] = None"},{name:"clip_skip",val:": typing.Optional[int] = 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/main/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/main/en/api/pipelines/stable_diffusion/image_variation#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"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.clip_skip",description:`<strong>clip_skip</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that
the output of the pre-final layer will be used for computing the prompt embeddings.`,name:"clip_skip"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L615",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/image_variation#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
“not-safe-for-work” (nsfw) content.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/image_variation#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),I=new nt({props:{anchor:"diffusers.StableDiffusionModelEditingPipeline.__call__.example",$$slots:{default:[ot]},$$scope:{ctx:Q}}}),Z=new V({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionModelEditingPipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L159"}}),W=new V({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/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L497"}}),z=new V({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionModelEditingPipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L151"}}),H=new V({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"},{name:"clip_skip",val:": typing.Optional[int] = 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"},{anchor:"diffusers.StableDiffusionModelEditingPipeline.encode_prompt.clip_skip",description:`<strong>clip_skip</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that
the output of the pre-final layer will be used for computing the prompt embeddings.`,name:"clip_skip"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_model_editing.py#L200"}}),q=new je({props:{title:"StableDiffusionPipelineOutput",local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",headingTag:"h2"}}),B=new V({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/pipeline_output.py#L11"}}),{c(){a=r("meta"),$=o(),m=r("p"),u=o(),h(y.$$.fragment),c=o(),M=r("p"),M.innerHTML=Ne,se=o(),A=r("p"),A.textContent=Ae,ae=o(),J=r("p"),J.innerHTML=Je,re=o(),O=r("p"),O.innerHTML=Oe,le=o(),h(S.$$.fragment),de=o(),h(G.$$.fragment),pe=o(),p=r("div"),h(F.$$.fragment),we=o(),X=r("p"),X.textContent=Ge,xe=o(),R=r("p"),R.innerHTML=Fe,ye=o(),P=r("div"),h(U.$$.fragment),Me=o(),Y=r("p"),Y.textContent=Ue,$e=o(),h(I.$$.fragment),Pe=o(),C=r("div"),h(Z.$$.fragment),Te=o(),K=r("p"),K.innerHTML=Ze,De=o(),L=r("div"),h(W.$$.fragment),Ee=o(),ee=r("p"),ee.innerHTML=We,ke=o(),j=r("div"),h(z.$$.fragment),Se=o(),te=r("p"),te.textContent=ze,Ie=o(),N=r("div"),h(H.$$.fragment),Ce=o(),ne=r("p"),ne.textContent=He,ce=o(),h(q.$$.fragment),fe=o(),T=r("div"),h(B.$$.fragment),Le=o(),ie=r("p"),ie.textContent=qe,me=o(),oe=r("p"),this.h()},l(e){const n=Ye("svelte-u9bgzb",document.head);a=l(n,"META",{name:!0,content:!0}),n.forEach(t),$=s(e),m=l(e,"P",{}),E(m).forEach(t),u=s(e),_(y.$$.fragment,e),c=s(e),M=l(e,"P",{"data-svelte-h":!0}),g(M)!=="svelte-1osizax"&&(M.innerHTML=Ne),se=s(e),A=l(e,"P",{"data-svelte-h":!0}),g(A)!=="svelte-1cwsb16"&&(A.textContent=Ae),ae=s(e),J=l(e,"P",{"data-svelte-h":!0}),g(J)!=="svelte-1ukz77s"&&(J.innerHTML=Je),re=s(e),O=l(e,"P",{"data-svelte-h":!0}),g(O)!=="svelte-1kivouf"&&(O.innerHTML=Oe),le=s(e),_(S.$$.fragment,e),de=s(e),_(G.$$.fragment,e),pe=s(e),p=l(e,"DIV",{class:!0});var f=E(p);_(F.$$.fragment,f),we=s(f),X=l(f,"P",{"data-svelte-h":!0}),g(X)!=="svelte-b3647n"&&(X.textContent=Ge),xe=s(f),R=l(f,"P",{"data-svelte-h":!0}),g(R)!=="svelte-496sm0"&&(R.innerHTML=Fe),ye=s(f),P=l(f,"DIV",{class:!0});var D=E(P);_(U.$$.fragment,D),Me=s(D),Y=l(D,"P",{"data-svelte-h":!0}),g(Y)!=="svelte-50j04k"&&(Y.textContent=Ue),$e=s(D),_(I.$$.fragment,D),D.forEach(t),Pe=s(f),C=l(f,"DIV",{class:!0});var ge=E(C);_(Z.$$.fragment,ge),Te=s(ge),K=l(ge,"P",{"data-svelte-h":!0}),g(K)!=="svelte-1s3c06i"&&(K.innerHTML=Ze),ge.forEach(t),De=s(f),L=l(f,"DIV",{class:!0});var he=E(L);_(W.$$.fragment,he),Ee=s(he),ee=l(he,"P",{"data-svelte-h":!0}),g(ee)!=="svelte-sddn55"&&(ee.innerHTML=We),he.forEach(t),ke=s(f),j=l(f,"DIV",{class:!0});var _e=E(j);_(z.$$.fragment,_e),Se=s(_e),te=l(_e,"P",{"data-svelte-h":!0}),g(te)!=="svelte-14bnrb6"&&(te.textContent=ze),_e.forEach(t),Ie=s(f),N=l(f,"DIV",{class:!0});var be=E(N);_(H.$$.fragment,be),Ce=s(be),ne=l(be,"P",{"data-svelte-h":!0}),g(ne)!=="svelte-16q0ax1"&&(ne.textContent=He),be.forEach(t),f.forEach(t),ce=s(e),_(q.$$.fragment,e),fe=s(e),T=l(e,"DIV",{class:!0});var ve=E(T);_(B.$$.fragment,ve),Le=s(ve),ie=l(ve,"P",{"data-svelte-h":!0}),g(ie)!=="svelte-1qpjiuf"&&(ie.textContent=qe),ve.forEach(t),me=s(e),oe=l(e,"P",{}),E(oe).forEach(t),this.h()},h(){k(a,"name","hf:doc:metadata"),k(a,"content",at),k(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(C,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(L,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(N,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(p,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),k(T,"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,n){i(document.head,a),d(e,$,n),d(e,m,n),d(e,u,n),b(y,e,n),d(e,c,n),d(e,M,n),d(e,se,n),d(e,A,n),d(e,ae,n),d(e,J,n),d(e,re,n),d(e,O,n),d(e,le,n),b(S,e,n),d(e,de,n),b(G,e,n),d(e,pe,n),d(e,p,n),b(F,p,null),i(p,we),i(p,X),i(p,xe),i(p,R),i(p,ye),i(p,P),b(U,P,null),i(P,Me),i(P,Y),i(P,$e),b(I,P,null),i(p,Pe),i(p,C),b(Z,C,null),i(C,Te),i(C,K),i(p,De),i(p,L),b(W,L,null),i(L,Ee),i(L,ee),i(p,ke),i(p,j),b(z,j,null),i(j,Se),i(j,te),i(p,Ie),i(p,N),b(H,N,null),i(N,Ce),i(N,ne),d(e,ce,n),b(q,e,n),d(e,fe,n),d(e,T,n),b(B,T,null),i(T,Le),i(T,ie),d(e,me,n),d(e,oe,n),ue=!0},p(e,[n]){const f={};n&2&&(f.$$scope={dirty:n,ctx:e}),S.$set(f);const D={};n&2&&(D.$$scope={dirty:n,ctx:e}),I.$set(D)},i(e){ue||(v(y.$$.fragment,e),v(S.$$.fragment,e),v(G.$$.fragment,e),v(F.$$.fragment,e),v(U.$$.fragment,e),v(I.$$.fragment,e),v(Z.$$.fragment,e),v(W.$$.fragment,e),v(z.$$.fragment,e),v(H.$$.fragment,e),v(q.$$.fragment,e),v(B.$$.fragment,e),ue=!0)},o(e){w(y.$$.fragment,e),w(S.$$.fragment,e),w(G.$$.fragment,e),w(F.$$.fragment,e),w(U.$$.fragment,e),w(I.$$.fragment,e),w(Z.$$.fragment,e),w(W.$$.fragment,e),w(z.$$.fragment,e),w(H.$$.fragment,e),w(q.$$.fragment,e),w(B.$$.fragment,e),ue=!1},d(e){e&&(t($),t(m),t(u),t(c),t(M),t(se),t(A),t(ae),t(J),t(re),t(O),t(le),t(de),t(pe),t(p),t(ce),t(fe),t(T),t(me),t(oe)),t(a),x(y,e),x(S,e),x(G,e),x(F),x(U),x(I),x(Z),x(W),x(z),x(H),x(q,e),x(B)}}}const at='{"title":"Text-to-image model editing","local":"text-to-image-model-editing","sections":[{"title":"StableDiffusionModelEditingPipeline","local":"diffusers.StableDiffusionModelEditingPipeline","sections":[],"depth":2},{"title":"StableDiffusionPipelineOutput","local":"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput","sections":[],"depth":2}],"depth":1}';function rt(Q){return Qe(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=Ke}),[]}class gt extends Xe{constructor(a){super(),Re(this,a,rt,st,Ve,{})}}export{gt as component};
