import{S as pt,i as dt,s as ft,e as s,k as h,w as C,t as p,M as mt,c as i,d as t,m as g,a as o,x as P,h as d,b as c,G as n,g as u,y as A,q as x,o as k,B as $,v as ut,L as ht}from"../../../chunks/vendor-hf-doc-builder.js";import{T as gt}from"../../../chunks/Tip-hf-doc-builder.js";import{D as Ye}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as _t}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Re}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as yt}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Mt(X){let l,w,f,m,_,a,y,v;return{c(){l=s("p"),w=p("Make sure to check out the Schedulers "),f=s("a"),m=p("guide"),_=p(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),a=s("a"),y=p("reuse components across pipelines"),v=p(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(U){l=i(U,"P",{});var M=o(l);w=d(M,"Make sure to check out the Schedulers "),f=i(M,"A",{href:!0});var S=o(f);m=d(S,"guide"),S.forEach(t),_=d(M," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),a=i(M,"A",{href:!0});var H=o(a);y=d(H,"reuse components across pipelines"),H.forEach(t),v=d(M," section to learn how to efficiently load the same components into multiple pipelines."),M.forEach(t),this.h()},h(){c(f,"href","/using-diffusers/schedulers"),c(a,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(U,M){u(U,l,M),n(l,w),n(l,f),n(f,m),n(l,_),n(l,a),n(a,y),n(l,v)},d(U){U&&t(l)}}}function bt(X){let l,w,f,m,_;return m=new _t({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU2VtYW50aWNTdGFibGVEaWZmdXNpb25QaXBlbGluZSUwQSUwQXBpcGUlMjAlM0QlMjBTZW1hbnRpY1N0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjA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MjBkaW1lbnNpb25zJTBBJTIwJTIwJTIwJTIwZWRpdF9tb21lbnR1bV9zY2FsZSUzRDAuMyUyQyUyMCUyMCUyMyUyME1vbWVudHVtJTIwc2NhbGUlMjB0aGF0JTIwd2lsbCUyMGJlJTIwYWRkZWQlMjB0byUyMHRoZSUyMGxhdGVudCUyMGd1aWRhbmNlJTBBJTIwJTIwJTIwJTIwZWRpdF9tb21fYmV0YSUzRDAuNiUyQyUyMCUyMCUyMyUyME1vbWVudHVtJTIwYmV0YSUwQSUyMCUyMCUyMCUyMGVkaXRfd2VpZ2h0cyUzRCU1QjElMkMlMjAxJTJDJTIwMSUyQyUyMDElMkMlMjAxJTVEJTJDJTIwJTIwJTIzJTIwV2VpZ2h0cyUyMG9mJTIwdGhlJTIwaW5kaXZpZHVhbCUyMGNvbmNlcHRzJTIwYWdhaW5zdCUyMGVhY2glMjBvdGhlciUwQSklMEFpbWFnZSUyMCUzRCUyMG91dC5pbWFnZXMlNUIwJTVE",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> SemanticStableDiffusionPipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = SemanticStableDiffusionPipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&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>out = pipe(
<span class="hljs-meta">... </span>    prompt=<span class="hljs-string">&quot;a photo of the face of a woman&quot;</span>,
<span class="hljs-meta">... </span>    num_images_per_prompt=<span class="hljs-number">1</span>,
<span class="hljs-meta">... </span>    guidance_scale=<span class="hljs-number">7</span>,
<span class="hljs-meta">... </span>    editing_prompt=[
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;smiling, smile&quot;</span>,  <span class="hljs-comment"># Concepts to apply</span>
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;glasses, wearing glasses&quot;</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;curls, wavy hair, curly hair&quot;</span>,
<span class="hljs-meta">... </span>        <span class="hljs-string">&quot;beard, full beard, mustache&quot;</span>,
<span class="hljs-meta">... </span>    ],
<span class="hljs-meta">... </span>    reverse_editing_direction=[
<span class="hljs-meta">... </span>        <span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>        <span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>        <span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>        <span class="hljs-literal">False</span>,
<span class="hljs-meta">... </span>    ],  <span class="hljs-comment"># Direction of guidance i.e. increase all concepts</span>
<span class="hljs-meta">... </span>    edit_warmup_steps=[<span class="hljs-number">10</span>, <span class="hljs-number">10</span>, <span class="hljs-number">10</span>, <span class="hljs-number">10</span>],  <span class="hljs-comment"># Warmup period for each concept</span>
<span class="hljs-meta">... </span>    edit_guidance_scale=[<span class="hljs-number">4</span>, <span class="hljs-number">5</span>, <span class="hljs-number">5</span>, <span class="hljs-number">5.4</span>],  <span class="hljs-comment"># Guidance scale for each concept</span>
<span class="hljs-meta">... </span>    edit_threshold=[
<span class="hljs-meta">... </span>        <span class="hljs-number">0.99</span>,
<span class="hljs-meta">... </span>        <span class="hljs-number">0.975</span>,
<span class="hljs-meta">... </span>        <span class="hljs-number">0.925</span>,
<span class="hljs-meta">... </span>        <span class="hljs-number">0.96</span>,
<span class="hljs-meta">... </span>    ],  <span class="hljs-comment"># Threshold for each concept. Threshold equals the percentile of the latent space that will be discarded. I.e. threshold=0.99 uses 1% of the latent dimensions</span>
<span class="hljs-meta">... </span>    edit_momentum_scale=<span class="hljs-number">0.3</span>,  <span class="hljs-comment"># Momentum scale that will be added to the latent guidance</span>
<span class="hljs-meta">... </span>    edit_mom_beta=<span class="hljs-number">0.6</span>,  <span class="hljs-comment"># Momentum beta</span>
<span class="hljs-meta">... </span>    edit_weights=[<span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>, <span class="hljs-number">1</span>],  <span class="hljs-comment"># Weights of the individual concepts against each other</span>
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = out.images[<span class="hljs-number">0</span>]`}}),{c(){l=s("p"),w=p("Examples:"),f=h(),C(m.$$.fragment)},l(a){l=i(a,"P",{});var y=o(l);w=d(y,"Examples:"),y.forEach(t),f=g(a),P(m.$$.fragment,a)},m(a,y){u(a,l,y),n(l,w),u(a,f,y),A(m,a,y),_=!0},p:ht,i(a){_||(x(m.$$.fragment,a),_=!0)},o(a){k(m.$$.fragment,a),_=!1},d(a){a&&t(l),a&&t(f),$(m,a)}}}function wt(X){let l,w,f,m,_,a,y,v,U,M,S,H,L,je,ve,de,O,Ue,fe,F,ne,Te,me,N,ue,T,E,se,W,Je,ie,Ie,he,b,Q,De,ae,Ce,Pe,J,Ae,q,xe,ke,K,$e,Ne,Ee,j,V,Ge,oe,Be,Ze,G,ge,I,B,le,Y,Le,re,We,_e,D,R,Qe,ce,Ve,ye;return a=new Re({}),N=new gt({props:{$$slots:{default:[Mt]},$$scope:{ctx:X}}}),W=new Re({}),Q=new Ye({props:{name:"class diffusers.SemanticStableDiffusionPipeline",anchor:"diffusers.SemanticStableDiffusionPipeline",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.SemanticStableDiffusionPipeline.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.SemanticStableDiffusionPipeline.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.SemanticStableDiffusionPipeline.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.SemanticStableDiffusionPipeline.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.SemanticStableDiffusionPipeline.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.SemanticStableDiffusionPipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>Q16SafetyChecker</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.SemanticStableDiffusionPipeline.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/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py#L21"}}),V=new Ye({props:{name:"__call__",anchor:"diffusers.SemanticStableDiffusionPipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{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:": 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:"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:"editing_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"editing_prompt_embeddings",val:": typing.Optional[torch.Tensor] = None"},{name:"reverse_editing_direction",val:": typing.Union[bool, typing.List[bool], NoneType] = False"},{name:"edit_guidance_scale",val:": typing.Union[float, typing.List[float], NoneType] = 5"},{name:"edit_warmup_steps",val:": typing.Union[int, typing.List[int], NoneType] = 10"},{name:"edit_cooldown_steps",val:": typing.Union[int, typing.List[int], NoneType] = None"},{name:"edit_threshold",val:": typing.Union[float, typing.List[float], NoneType] = 0.9"},{name:"edit_momentum_scale",val:": typing.Optional[float] = 0.1"},{name:"edit_mom_beta",val:": typing.Optional[float] = 0.4"},{name:"edit_weights",val:": typing.Optional[typing.List[float]] = None"},{name:"sem_guidance",val:": typing.Optional[typing.List[torch.Tensor]] = None"}],parametersDescription:[{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The prompt or prompts to guide image generation.`,name:"prompt"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__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.SemanticStableDiffusionPipeline.__call__.editing_prompt",description:`<strong>editing_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to use for semantic guidance. Semantic guidance is disabled by setting
<code>editing_prompt = None</code>. Guidance direction of prompt should be specified via
<code>reverse_editing_direction</code>.`,name:"editing_prompt"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.editing_prompt_embeddings",description:`<strong>editing_prompt_embeddings</strong> (<code>torch.Tensor</code>, <em>optional</em>) &#x2014;
Pre-computed embeddings to use for semantic guidance. Guidance direction of embedding should be
specified via <code>reverse_editing_direction</code>.`,name:"editing_prompt_embeddings"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.reverse_editing_direction",description:`<strong>reverse_editing_direction</strong> (<code>bool</code> or <code>List[bool]</code>, <em>optional</em>, defaults to <code>False</code>) &#x2014;
Whether the corresponding prompt in <code>editing_prompt</code> should be increased or decreased.`,name:"reverse_editing_direction"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_guidance_scale",description:`<strong>edit_guidance_scale</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to 5) &#x2014;
Guidance scale for semantic guidance. If provided as a list, values should correspond to
<code>editing_prompt</code>.`,name:"edit_guidance_scale"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_warmup_steps",description:`<strong>edit_warmup_steps</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to 10) &#x2014;
Number of diffusion steps (for each prompt) for which semantic guidance is not applied. Momentum is
calculated for those steps and applied once all warmup periods are over.`,name:"edit_warmup_steps"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_cooldown_steps",description:`<strong>edit_cooldown_steps</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Number of diffusion steps (for each prompt) after which semantic guidance is longer applied.`,name:"edit_cooldown_steps"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_threshold",description:`<strong>edit_threshold</strong> (<code>float</code> or <code>List[float]</code>, <em>optional</em>, defaults to 0.9) &#x2014;
Threshold of semantic guidance.`,name:"edit_threshold"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_momentum_scale",description:`<strong>edit_momentum_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 0.1) &#x2014;
Scale of the momentum to be added to the semantic guidance at each diffusion step. If set to 0.0,
momentum is disabled. Momentum is already built up during warmup (for diffusion steps smaller than
<code>sld_warmup_steps</code>). Momentum is only added to latent guidance once all warmup periods are finished.`,name:"edit_momentum_scale"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_mom_beta",description:`<strong>edit_mom_beta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.4) &#x2014;
Defines how semantic guidance momentum builds up. <code>edit_mom_beta</code> indicates how much of the previous
momentum is kept. Momentum is already built up during warmup (for diffusion steps smaller than
<code>edit_warmup_steps</code>).`,name:"edit_mom_beta"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.edit_weights",description:`<strong>edit_weights</strong> (<code>List[float]</code>, <em>optional</em>, defaults to <code>None</code>) &#x2014;
Indicates how much each individual concept should influence the overall guidance. If no weights are
provided all concepts are applied equally.`,name:"edit_weights"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.sem_guidance",description:`<strong>sem_guidance</strong> (<code>List[torch.Tensor]</code>, <em>optional</em>) &#x2014;
List of pre-generated guidance vectors to be applied at generation. Length of the list has to
correspond to <code>num_inference_steps</code>.`,name:"sem_guidance"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py#L206",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>,
<a
  href="/docs/diffusers/main/en/api/pipelines/semantic_stable_diffusion#diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"
>SemanticStableDiffusionPipelineOutput</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/semantic_stable_diffusion#diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"
>SemanticStableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),G=new yt({props:{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.example",$$slots:{default:[bt]},$$scope:{ctx:X}}}),Y=new Re({}),R=new Ye({props:{name:"class diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput",anchor:"diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput",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.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput.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.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput.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/semantic_stable_diffusion/__init__.py#L13"}}),{c(){l=s("meta"),w=h(),f=s("h1"),m=s("a"),_=s("span"),C(a.$$.fragment),y=h(),v=s("span"),U=p("Semantic Guidance"),M=h(),S=s("p"),H=p("Semantic Guidance for Diffusion Models was proposed in "),L=s("a"),je=p("SEGA: Instructing Diffusion using Semantic Dimensions"),ve=p(` and provides strong semantic control over image generation.
Small changes to the text prompt usually result in entirely different output images. However, with SEGA a variety of changes to the image are enabled that can be controlled easily and intuitively, while staying true to the original image composition.`),de=h(),O=s("p"),Ue=p("The abstract from the paper is:"),fe=h(),F=s("p"),ne=s("em"),Te=p("Text-to-image diffusion models have recently received a lot of interest for their astonishing ability to produce high-fidelity images from text only. However, achieving one-shot generation that aligns with the user\u2019s intent is nearly impossible, yet small changes to the input prompt often result in very different images. This leaves the user with little semantic control. To put the user in control, we show how to interact with the diffusion process to flexibly steer it along semantic directions. This semantic guidance (SEGA) allows for subtle and extensive edits, changes in composition and style, as well as optimizing the overall artistic conception. We demonstrate SEGA\u2019s effectiveness on a variety of tasks and provide evidence for its versatility and flexibility."),me=h(),C(N.$$.fragment),ue=h(),T=s("h2"),E=s("a"),se=s("span"),C(W.$$.fragment),Je=h(),ie=s("span"),Ie=p("SemanticStableDiffusionPipeline"),he=h(),b=s("div"),C(Q.$$.fragment),De=h(),ae=s("p"),Ce=p("Pipeline for text-to-image generation using Stable Diffusion with latent editing."),Pe=h(),J=s("p"),Ae=p("This model inherits from "),q=s("a"),xe=p("DiffusionPipeline"),ke=p(" and builds on the "),K=s("a"),$e=p("StableDiffusionPipeline"),Ne=p(`. Check the superclass
documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular
device, etc.).`),Ee=h(),j=s("div"),C(V.$$.fragment),Ge=h(),oe=s("p"),Be=p("The call function to the pipeline for generation."),Ze=h(),C(G.$$.fragment),ge=h(),I=s("h2"),B=s("a"),le=s("span"),C(Y.$$.fragment),Le=h(),re=s("span"),We=p("StableDiffusionSafePipelineOutput"),_e=h(),D=s("div"),C(R.$$.fragment),Qe=h(),ce=s("p"),Ve=p("Output class for Stable Diffusion pipelines."),this.h()},l(e){const r=mt('[data-svelte="svelte-1phssyn"]',document.head);l=i(r,"META",{name:!0,content:!0}),r.forEach(t),w=g(e),f=i(e,"H1",{class:!0});var z=o(f);m=i(z,"A",{id:!0,class:!0,href:!0});var pe=o(m);_=i(pe,"SPAN",{});var ze=o(_);P(a.$$.fragment,ze),ze.forEach(t),pe.forEach(t),y=g(z),v=i(z,"SPAN",{});var Xe=o(v);U=d(Xe,"Semantic Guidance"),Xe.forEach(t),z.forEach(t),M=g(e),S=i(e,"P",{});var Me=o(S);H=d(Me,"Semantic Guidance for Diffusion Models was proposed in "),L=i(Me,"A",{href:!0,rel:!0});var He=o(L);je=d(He,"SEGA: Instructing Diffusion using Semantic Dimensions"),He.forEach(t),ve=d(Me,` and provides strong semantic control over image generation.
Small changes to the text prompt usually result in entirely different output images. However, with SEGA a variety of changes to the image are enabled that can be controlled easily and intuitively, while staying true to the original image composition.`),Me.forEach(t),de=g(e),O=i(e,"P",{});var Oe=o(O);Ue=d(Oe,"The abstract from the paper is:"),Oe.forEach(t),fe=g(e),F=i(e,"P",{});var Fe=o(F);ne=i(Fe,"EM",{});var qe=o(ne);Te=d(qe,"Text-to-image diffusion models have recently received a lot of interest for their astonishing ability to produce high-fidelity images from text only. However, achieving one-shot generation that aligns with the user\u2019s intent is nearly impossible, yet small changes to the input prompt often result in very different images. This leaves the user with little semantic control. To put the user in control, we show how to interact with the diffusion process to flexibly steer it along semantic directions. This semantic guidance (SEGA) allows for subtle and extensive edits, changes in composition and style, as well as optimizing the overall artistic conception. We demonstrate SEGA\u2019s effectiveness on a variety of tasks and provide evidence for its versatility and flexibility."),qe.forEach(t),Fe.forEach(t),me=g(e),P(N.$$.fragment,e),ue=g(e),T=i(e,"H2",{class:!0});var be=o(T);E=i(be,"A",{id:!0,class:!0,href:!0});var Ke=o(E);se=i(Ke,"SPAN",{});var et=o(se);P(W.$$.fragment,et),et.forEach(t),Ke.forEach(t),Je=g(be),ie=i(be,"SPAN",{});var tt=o(ie);Ie=d(tt,"SemanticStableDiffusionPipeline"),tt.forEach(t),be.forEach(t),he=g(e),b=i(e,"DIV",{class:!0});var Z=o(b);P(Q.$$.fragment,Z),De=g(Z),ae=i(Z,"P",{});var nt=o(ae);Ce=d(nt,"Pipeline for text-to-image generation using Stable Diffusion with latent editing."),nt.forEach(t),Pe=g(Z),J=i(Z,"P",{});var ee=o(J);Ae=d(ee,"This model inherits from "),q=i(ee,"A",{href:!0});var st=o(q);xe=d(st,"DiffusionPipeline"),st.forEach(t),ke=d(ee," and builds on the "),K=i(ee,"A",{href:!0});var it=o(K);$e=d(it,"StableDiffusionPipeline"),it.forEach(t),Ne=d(ee,`. Check the superclass
documentation for the generic methods implemented for all pipelines (downloading, saving, running on a particular
device, etc.).`),ee.forEach(t),Ee=g(Z),j=i(Z,"DIV",{class:!0});var te=o(j);P(V.$$.fragment,te),Ge=g(te),oe=i(te,"P",{});var at=o(oe);Be=d(at,"The call function to the pipeline for generation."),at.forEach(t),Ze=g(te),P(G.$$.fragment,te),te.forEach(t),Z.forEach(t),ge=g(e),I=i(e,"H2",{class:!0});var we=o(I);B=i(we,"A",{id:!0,class:!0,href:!0});var ot=o(B);le=i(ot,"SPAN",{});var lt=o(le);P(Y.$$.fragment,lt),lt.forEach(t),ot.forEach(t),Le=g(we),re=i(we,"SPAN",{});var rt=o(re);We=d(rt,"StableDiffusionSafePipelineOutput"),rt.forEach(t),we.forEach(t),_e=g(e),D=i(e,"DIV",{class:!0});var Se=o(D);P(R.$$.fragment,Se),Qe=g(Se),ce=i(Se,"P",{});var ct=o(ce);Ve=d(ct,"Output class for Stable Diffusion pipelines."),ct.forEach(t),Se.forEach(t),this.h()},h(){c(l,"name","hf:doc:metadata"),c(l,"content",JSON.stringify(St)),c(m,"id","semantic-guidance"),c(m,"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"),c(m,"href","#semantic-guidance"),c(f,"class","relative group"),c(L,"href","https://huggingface.co/papers/2301.12247"),c(L,"rel","nofollow"),c(E,"id","diffusers.SemanticStableDiffusionPipeline"),c(E,"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"),c(E,"href","#diffusers.SemanticStableDiffusionPipeline"),c(T,"class","relative group"),c(q,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),c(K,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/text2img#diffusers.StableDiffusionPipeline"),c(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(B,"id","diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"),c(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"),c(B,"href","#diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"),c(I,"class","relative group"),c(D,"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,r){n(document.head,l),u(e,w,r),u(e,f,r),n(f,m),n(m,_),A(a,_,null),n(f,y),n(f,v),n(v,U),u(e,M,r),u(e,S,r),n(S,H),n(S,L),n(L,je),n(S,ve),u(e,de,r),u(e,O,r),n(O,Ue),u(e,fe,r),u(e,F,r),n(F,ne),n(ne,Te),u(e,me,r),A(N,e,r),u(e,ue,r),u(e,T,r),n(T,E),n(E,se),A(W,se,null),n(T,Je),n(T,ie),n(ie,Ie),u(e,he,r),u(e,b,r),A(Q,b,null),n(b,De),n(b,ae),n(ae,Ce),n(b,Pe),n(b,J),n(J,Ae),n(J,q),n(q,xe),n(J,ke),n(J,K),n(K,$e),n(J,Ne),n(b,Ee),n(b,j),A(V,j,null),n(j,Ge),n(j,oe),n(oe,Be),n(j,Ze),A(G,j,null),u(e,ge,r),u(e,I,r),n(I,B),n(B,le),A(Y,le,null),n(I,Le),n(I,re),n(re,We),u(e,_e,r),u(e,D,r),A(R,D,null),n(D,Qe),n(D,ce),n(ce,Ve),ye=!0},p(e,[r]){const z={};r&2&&(z.$$scope={dirty:r,ctx:e}),N.$set(z);const pe={};r&2&&(pe.$$scope={dirty:r,ctx:e}),G.$set(pe)},i(e){ye||(x(a.$$.fragment,e),x(N.$$.fragment,e),x(W.$$.fragment,e),x(Q.$$.fragment,e),x(V.$$.fragment,e),x(G.$$.fragment,e),x(Y.$$.fragment,e),x(R.$$.fragment,e),ye=!0)},o(e){k(a.$$.fragment,e),k(N.$$.fragment,e),k(W.$$.fragment,e),k(Q.$$.fragment,e),k(V.$$.fragment,e),k(G.$$.fragment,e),k(Y.$$.fragment,e),k(R.$$.fragment,e),ye=!1},d(e){t(l),e&&t(w),e&&t(f),$(a),e&&t(M),e&&t(S),e&&t(de),e&&t(O),e&&t(fe),e&&t(F),e&&t(me),$(N,e),e&&t(ue),e&&t(T),$(W),e&&t(he),e&&t(b),$(Q),$(V),$(G),e&&t(ge),e&&t(I),$(Y),e&&t(_e),e&&t(D),$(R)}}}const St={local:"semantic-guidance",sections:[{local:"diffusers.SemanticStableDiffusionPipeline",title:"SemanticStableDiffusionPipeline"},{local:"diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput",title:"StableDiffusionSafePipelineOutput"}],title:"Semantic Guidance"};function jt(X){return ut(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ct extends pt{constructor(l){super();dt(this,l,jt,wt,ft,{})}}export{Ct as default,St as metadata};
