import{S as on,i as sn,s as rn,e as n,k as l,w as D,t as d,M as ln,c as a,d as i,m as c,a as o,x,h as p,b as s,N as cn,G as t,g as f,y as T,L as dn,q as E,o as k,B as $,v as pn}from"../../../chunks/vendor-hf-doc-builder.js";import{D as fi}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as fn}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Oe}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function un(ui){let _,qe,b,L,he,U,mt,ge,ht,Fe,I,gt,z,_t,bt,Ue,ne,vt,ze,ae,_e,St,He,H,be,wt,yt,We,A,ve,m,Se,Pt,Dt,we,xt,Tt,oe,Et,kt,se,$t,Lt,ye,h,Pe,W,It,At,De,xe,Nt,jt,re,B,le,mi,Ct,ce,R,Gt,Be,v,N,Te,V,Mt,Ee,Ot,Re,de,K,qt,pe,Ft,Ut,Ve,S,j,ke,J,zt,$e,Ht,Ke,C,Wt,fe,Bt,Rt,Je,Q,Qe,ue,Vt,Ye,w,G,Le,Y,Kt,Ie,Jt,Xe,y,X,Qt,Ae,Yt,Ze,P,M,Ne,Z,Xt,je,Zt,et,u,ee,ei,Ce,ti,ii,te,ni,me,ai,oi,si,Ge,ri,li,O,ie,ci,Me,di,tt;return U=new Oe({}),V=new Oe({}),J=new Oe({}),Q=new fn({props:{code:`import torch
from diffusers import SemanticStableDiffusionPipeline

pipe = SemanticStableDiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16)
pipe = pipe.to("cuda")

out = pipe(
    prompt="a photo of the face of a woman",
    num_images_per_prompt=1,
    guidance_scale=7,
    editing_prompt=[
        "smiling, smile",  # Concepts to apply
        "glasses, wearing glasses",
        "curls, wavy hair, curly hair",
        "beard, full beard, mustache",
    ],
    reverse_editing_direction=[False, False, False, False],  # Direction of guidance i.e. increase all concepts
    edit_warmup_steps=[10, 10, 10, 10],  # Warmup period for each concept
    edit_guidance_scale=[4, 5, 5, 5.4],  # Guidance scale for each concept
    edit_threshold=[
        0.99,
        0.975,
        0.925,
        0.96,
    ],  # 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
    edit_momentum_scale=0.3,  # Momentum scale that will be added to the latent guidance
    edit_mom_beta=0.6,  # Momentum beta
    edit_weights=[1, 1, 1, 1, 1],  # Weights of the individual concepts against each other
)`,highlighted:`<span class="hljs-keyword">import</span> torch
<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> SemanticStableDiffusionPipeline

pipe = SemanticStableDiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;runwayml/stable-diffusion-v1-5&quot;</span>, torch_dtype=torch.float16)
pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

out = pipe(
    prompt=<span class="hljs-string">&quot;a photo of the face of a woman&quot;</span>,
    num_images_per_prompt=<span class="hljs-number">1</span>,
    guidance_scale=<span class="hljs-number">7</span>,
    editing_prompt=[
        <span class="hljs-string">&quot;smiling, smile&quot;</span>,  <span class="hljs-comment"># Concepts to apply</span>
        <span class="hljs-string">&quot;glasses, wearing glasses&quot;</span>,
        <span class="hljs-string">&quot;curls, wavy hair, curly hair&quot;</span>,
        <span class="hljs-string">&quot;beard, full beard, mustache&quot;</span>,
    ],
    reverse_editing_direction=[<span class="hljs-literal">False</span>, <span class="hljs-literal">False</span>, <span class="hljs-literal">False</span>, <span class="hljs-literal">False</span>],  <span class="hljs-comment"># Direction of guidance i.e. increase all concepts</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>
    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>
    edit_threshold=[
        <span class="hljs-number">0.99</span>,
        <span class="hljs-number">0.975</span>,
        <span class="hljs-number">0.925</span>,
        <span class="hljs-number">0.96</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>
    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>
    edit_mom_beta=<span class="hljs-number">0.6</span>,  <span class="hljs-comment"># Momentum beta</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>
)`}}),Y=new Oe({}),X=new fi({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>. PIL images or numpy array present the denoised images of the diffusion pipeline.`,name:"images"},{anchor:"diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List of flags denoting whether the corresponding generated image likely represents &#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.16.0/src/diffusers/pipelines/semantic_stable_diffusion/__init__.py#L13"}}),Z=new Oe({}),ee=new fi({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/v0.16.0/en/api/models#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> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.SemanticStableDiffusionPipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.SemanticStableDiffusionPipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.16.0/en/api/models#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.SemanticStableDiffusionPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.16.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 latens. Can be one of
<a href="/docs/diffusers/v0.16.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.16.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.16.0/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/CompVis/stable-diffusion-v1-4" rel="nofollow">model card</a> for details.`,name:"safety_checker"},{anchor:"diffusers.SemanticStableDiffusionPipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<code>CLIPImageProcessor</code>) &#x2014;
Model that extracts features from generated images to be used as inputs for the <code>safety_checker</code>.`,name:"feature_extractor"}],source:"https://github.com/huggingface/diffusers/blob/v0.16.0/src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py#L61"}}),ie=new fi({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 the image generation.`,name:"prompt"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to self.unet.config.sample_size * self.vae_scale_factor) &#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 self.unet.config.sample_size * self.vae_scale_factor) &#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;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,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 not to guide the image generation. Ignored when not using guidance (i.e., ignored
if <code>guidance_scale</code> is less than <code>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;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/v0.16.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.SemanticStableDiffusionPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</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 will ge 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 generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.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/v0.16.0/en/api/pipelines/stable_diffusion/overview#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 will be called every <code>callback_steps</code> steps during inference. The function will be
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 will be called. If not specified, the callback will be
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&gt;</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 list values should correspond to <code>editing_prompt</code>.
<code>edit_guidance_scale</code> is defined as <code>s_e</code> of equation 6 of <a href="https://arxiv.org/pdf/2301.12247.pdf" rel="nofollow">SEGA
Paper</a>.`,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 will not be applied. Momentum
will still be calculated for those steps and applied once all warmup periods are over.
<code>edit_warmup_steps</code> is defined as <code>delta</code> (&#x3B4;) of <a href="https://arxiv.org/pdf/2301.12247.pdf" rel="nofollow">SEGA Paper</a>.`,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 will no longer be 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 will be disabled. Momentum is already built up during warmup, i.e. for diffusion steps smaller
than <code>sld_warmup_steps</code>. Momentum will only be added to latent guidance once all warmup periods are
finished. <code>edit_momentum_scale</code> is defined as <code>s_m</code> of equation 7 of <a href="https://arxiv.org/pdf/2301.12247.pdf" rel="nofollow">SEGA
Paper</a>.`,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 will be kept. Momentum is already built up during warmup, i.e. for diffusion steps smaller
than <code>edit_warmup_steps</code>. <code>edit_mom_beta</code> is defined as <code>beta_m</code> (&#x3B2;) of equation 8 of <a href="https://arxiv.org/pdf/2301.12247.pdf" rel="nofollow">SEGA
Paper</a>.`,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. <code>edit_mom_beta</code> is defined as <code>g_i</code> of equation 9 of <a href="https://arxiv.org/pdf/2301.12247.pdf" rel="nofollow">SEGA
Paper</a>.`,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/v0.16.0/src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py#L227",returnDescription:`
<p><a
  href="/docs/diffusers/v0.16.0/en/api/pipelines/semantic_stable_diffusion#diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"
>SemanticStableDiffusionPipelineOutput</a> if <code>return_dict</code> is True,
otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.16.0/en/api/pipelines/semantic_stable_diffusion#diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"
>SemanticStableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),{c(){_=n("meta"),qe=l(),b=n("h1"),L=n("a"),he=n("span"),D(U.$$.fragment),mt=l(),ge=n("span"),ht=d("Semantic Guidance"),Fe=l(),I=n("p"),gt=d("Semantic Guidance for Diffusion Models was proposed in "),z=n("a"),_t=d("SEGA: Instructing Diffusion using Semantic Dimensions"),bt=d(` and provides strong semantic control over the 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, and stay true to the original image composition.`),Ue=l(),ne=n("p"),vt=d("The abstract of the paper is the following:"),ze=l(),ae=n("p"),_e=n("em"),St=d("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."),He=l(),H=n("p"),be=n("em"),wt=d("Overview"),yt=d(":"),We=l(),A=n("table"),ve=n("thead"),m=n("tr"),Se=n("th"),Pt=d("Pipeline"),Dt=l(),we=n("th"),xt=d("Tasks"),Tt=l(),oe=n("th"),Et=d("Colab"),kt=l(),se=n("th"),$t=d("Demo"),Lt=l(),ye=n("tbody"),h=n("tr"),Pe=n("td"),W=n("a"),It=d("pipeline_semantic_stable_diffusion.py"),At=l(),De=n("td"),xe=n("em"),Nt=d("Text-to-Image Generation"),jt=l(),re=n("td"),B=n("a"),le=n("img"),Ct=l(),ce=n("td"),R=n("a"),Gt=d("Coming Soon"),Be=l(),v=n("h2"),N=n("a"),Te=n("span"),D(V.$$.fragment),Mt=l(),Ee=n("span"),Ot=d("Tips"),Re=l(),de=n("ul"),K=n("li"),qt=d("The Semantic Guidance pipeline can be used with any "),pe=n("a"),Ft=d("Stable Diffusion"),Ut=d(" checkpoint."),Ve=l(),S=n("h3"),j=n("a"),ke=n("span"),D(J.$$.fragment),zt=l(),$e=n("span"),Ht=d("Run Semantic Guidance"),Ke=l(),C=n("p"),Wt=d("The interface of "),fe=n("a"),Bt=d("SemanticStableDiffusionPipeline"),Rt=d(` provides several additional parameters to influence the image generation.
Exemplary usage may look like this:`),Je=l(),D(Q.$$.fragment),Qe=l(),ue=n("p"),Vt=d("For more examples check the Colab notebook."),Ye=l(),w=n("h2"),G=n("a"),Le=n("span"),D(Y.$$.fragment),Kt=l(),Ie=n("span"),Jt=d("StableDiffusionSafePipelineOutput"),Xe=l(),y=n("div"),D(X.$$.fragment),Qt=l(),Ae=n("p"),Yt=d("Output class for Stable Diffusion pipelines."),Ze=l(),P=n("h2"),M=n("a"),Ne=n("span"),D(Z.$$.fragment),Xt=l(),je=n("span"),Zt=d("SemanticStableDiffusionPipeline"),et=l(),u=n("div"),D(ee.$$.fragment),ei=l(),Ce=n("p"),ti=d("Pipeline for text-to-image generation with latent editing."),ii=l(),te=n("p"),ni=d("This model inherits from "),me=n("a"),ai=d("DiffusionPipeline"),oi=d(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),si=l(),Ge=n("p"),ri=d("This model builds on the implementation of [\u2018StableDiffusionPipeline\u2019]"),li=l(),O=n("div"),D(ie.$$.fragment),ci=l(),Me=n("p"),di=d("Function invoked when calling the pipeline for generation."),this.h()},l(e){const r=ln('[data-svelte="svelte-1phssyn"]',document.head);_=a(r,"META",{name:!0,content:!0}),r.forEach(i),qe=c(e),b=a(e,"H1",{class:!0});var it=o(b);L=a(it,"A",{id:!0,class:!0,href:!0});var hi=o(L);he=a(hi,"SPAN",{});var gi=o(he);x(U.$$.fragment,gi),gi.forEach(i),hi.forEach(i),mt=c(it),ge=a(it,"SPAN",{});var _i=o(ge);ht=p(_i,"Semantic Guidance"),_i.forEach(i),it.forEach(i),Fe=c(e),I=a(e,"P",{});var nt=o(I);gt=p(nt,"Semantic Guidance for Diffusion Models was proposed in "),z=a(nt,"A",{href:!0,rel:!0});var bi=o(z);_t=p(bi,"SEGA: Instructing Diffusion using Semantic Dimensions"),bi.forEach(i),bt=p(nt,` and provides strong semantic control over the 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, and stay true to the original image composition.`),nt.forEach(i),Ue=c(e),ne=a(e,"P",{});var vi=o(ne);vt=p(vi,"The abstract of the paper is the following:"),vi.forEach(i),ze=c(e),ae=a(e,"P",{});var Si=o(ae);_e=a(Si,"EM",{});var wi=o(_e);St=p(wi,"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."),wi.forEach(i),Si.forEach(i),He=c(e),H=a(e,"P",{});var pi=o(H);be=a(pi,"EM",{});var yi=o(be);wt=p(yi,"Overview"),yi.forEach(i),yt=p(pi,":"),pi.forEach(i),We=c(e),A=a(e,"TABLE",{});var at=o(A);ve=a(at,"THEAD",{});var Pi=o(ve);m=a(Pi,"TR",{});var q=o(m);Se=a(q,"TH",{});var Di=o(Se);Pt=p(Di,"Pipeline"),Di.forEach(i),Dt=c(q),we=a(q,"TH",{});var xi=o(we);xt=p(xi,"Tasks"),xi.forEach(i),Tt=c(q),oe=a(q,"TH",{align:!0});var Ti=o(oe);Et=p(Ti,"Colab"),Ti.forEach(i),kt=c(q),se=a(q,"TH",{align:!0});var Ei=o(se);$t=p(Ei,"Demo"),Ei.forEach(i),q.forEach(i),Pi.forEach(i),Lt=c(at),ye=a(at,"TBODY",{});var ki=o(ye);h=a(ki,"TR",{});var F=o(h);Pe=a(F,"TD",{});var $i=o(Pe);W=a($i,"A",{href:!0,rel:!0});var Li=o(W);It=p(Li,"pipeline_semantic_stable_diffusion.py"),Li.forEach(i),$i.forEach(i),At=c(F),De=a(F,"TD",{});var Ii=o(De);xe=a(Ii,"EM",{});var Ai=o(xe);Nt=p(Ai,"Text-to-Image Generation"),Ai.forEach(i),Ii.forEach(i),jt=c(F),re=a(F,"TD",{align:!0});var Ni=o(re);B=a(Ni,"A",{href:!0,rel:!0});var ji=o(B);le=a(ji,"IMG",{src:!0,alt:!0}),ji.forEach(i),Ni.forEach(i),Ct=c(F),ce=a(F,"TD",{align:!0});var Ci=o(ce);R=a(Ci,"A",{href:!0,rel:!0});var Gi=o(R);Gt=p(Gi,"Coming Soon"),Gi.forEach(i),Ci.forEach(i),F.forEach(i),ki.forEach(i),at.forEach(i),Be=c(e),v=a(e,"H2",{class:!0});var ot=o(v);N=a(ot,"A",{id:!0,class:!0,href:!0});var Mi=o(N);Te=a(Mi,"SPAN",{});var Oi=o(Te);x(V.$$.fragment,Oi),Oi.forEach(i),Mi.forEach(i),Mt=c(ot),Ee=a(ot,"SPAN",{});var qi=o(Ee);Ot=p(qi,"Tips"),qi.forEach(i),ot.forEach(i),Re=c(e),de=a(e,"UL",{});var Fi=o(de);K=a(Fi,"LI",{});var st=o(K);qt=p(st,"The Semantic Guidance pipeline can be used with any "),pe=a(st,"A",{href:!0});var Ui=o(pe);Ft=p(Ui,"Stable Diffusion"),Ui.forEach(i),Ut=p(st," checkpoint."),st.forEach(i),Fi.forEach(i),Ve=c(e),S=a(e,"H3",{class:!0});var rt=o(S);j=a(rt,"A",{id:!0,class:!0,href:!0});var zi=o(j);ke=a(zi,"SPAN",{});var Hi=o(ke);x(J.$$.fragment,Hi),Hi.forEach(i),zi.forEach(i),zt=c(rt),$e=a(rt,"SPAN",{});var Wi=o($e);Ht=p(Wi,"Run Semantic Guidance"),Wi.forEach(i),rt.forEach(i),Ke=c(e),C=a(e,"P",{});var lt=o(C);Wt=p(lt,"The interface of "),fe=a(lt,"A",{href:!0});var Bi=o(fe);Bt=p(Bi,"SemanticStableDiffusionPipeline"),Bi.forEach(i),Rt=p(lt,` provides several additional parameters to influence the image generation.
Exemplary usage may look like this:`),lt.forEach(i),Je=c(e),x(Q.$$.fragment,e),Qe=c(e),ue=a(e,"P",{});var Ri=o(ue);Vt=p(Ri,"For more examples check the Colab notebook."),Ri.forEach(i),Ye=c(e),w=a(e,"H2",{class:!0});var ct=o(w);G=a(ct,"A",{id:!0,class:!0,href:!0});var Vi=o(G);Le=a(Vi,"SPAN",{});var Ki=o(Le);x(Y.$$.fragment,Ki),Ki.forEach(i),Vi.forEach(i),Kt=c(ct),Ie=a(ct,"SPAN",{});var Ji=o(Ie);Jt=p(Ji,"StableDiffusionSafePipelineOutput"),Ji.forEach(i),ct.forEach(i),Xe=c(e),y=a(e,"DIV",{class:!0});var dt=o(y);x(X.$$.fragment,dt),Qt=c(dt),Ae=a(dt,"P",{});var Qi=o(Ae);Yt=p(Qi,"Output class for Stable Diffusion pipelines."),Qi.forEach(i),dt.forEach(i),Ze=c(e),P=a(e,"H2",{class:!0});var pt=o(P);M=a(pt,"A",{id:!0,class:!0,href:!0});var Yi=o(M);Ne=a(Yi,"SPAN",{});var Xi=o(Ne);x(Z.$$.fragment,Xi),Xi.forEach(i),Yi.forEach(i),Xt=c(pt),je=a(pt,"SPAN",{});var Zi=o(je);Zt=p(Zi,"SemanticStableDiffusionPipeline"),Zi.forEach(i),pt.forEach(i),et=c(e),u=a(e,"DIV",{class:!0});var g=o(u);x(ee.$$.fragment,g),ei=c(g),Ce=a(g,"P",{});var en=o(Ce);ti=p(en,"Pipeline for text-to-image generation with latent editing."),en.forEach(i),ii=c(g),te=a(g,"P",{});var ft=o(te);ni=p(ft,"This model inherits from "),me=a(ft,"A",{href:!0});var tn=o(me);ai=p(tn,"DiffusionPipeline"),tn.forEach(i),oi=p(ft,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),ft.forEach(i),si=c(g),Ge=a(g,"P",{});var nn=o(Ge);ri=p(nn,"This model builds on the implementation of [\u2018StableDiffusionPipeline\u2019]"),nn.forEach(i),li=c(g),O=a(g,"DIV",{class:!0});var ut=o(O);x(ie.$$.fragment,ut),ci=c(ut),Me=a(ut,"P",{});var an=o(Me);di=p(an,"Function invoked when calling the pipeline for generation."),an.forEach(i),ut.forEach(i),g.forEach(i),this.h()},h(){s(_,"name","hf:doc:metadata"),s(_,"content",JSON.stringify(mn)),s(L,"id","semantic-guidance"),s(L,"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"),s(L,"href","#semantic-guidance"),s(b,"class","relative group"),s(z,"href","https://arxiv.org/abs/2301.12247"),s(z,"rel","nofollow"),s(oe,"align","center"),s(se,"align","center"),s(W,"href","https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/semantic_stable_diffusion/pipeline_semantic_stable_diffusion.py"),s(W,"rel","nofollow"),cn(le.src,mi="https://colab.research.google.com/assets/colab-badge.svg")||s(le,"src",mi),s(le,"alt","Open In Colab"),s(B,"href","https://colab.research.google.com/github/ml-research/semantic-image-editing/blob/main/examples/SemanticGuidance.ipynb"),s(B,"rel","nofollow"),s(re,"align","center"),s(R,"href","https://huggingface.co/AIML-TUDA"),s(R,"rel","nofollow"),s(ce,"align","center"),s(N,"id","tips"),s(N,"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"),s(N,"href","#tips"),s(v,"class","relative group"),s(pe,"href","./stable_diffusion/text2img"),s(j,"id","run-semantic-guidance"),s(j,"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"),s(j,"href","#run-semantic-guidance"),s(S,"class","relative group"),s(fe,"href","/docs/diffusers/v0.16.0/en/api/pipelines/semantic_stable_diffusion#diffusers.SemanticStableDiffusionPipeline"),s(G,"id","diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"),s(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"),s(G,"href","#diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput"),s(w,"class","relative group"),s(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),s(M,"id","diffusers.SemanticStableDiffusionPipeline"),s(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"),s(M,"href","#diffusers.SemanticStableDiffusionPipeline"),s(P,"class","relative group"),s(me,"href","/docs/diffusers/v0.16.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),s(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),s(u,"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){t(document.head,_),f(e,qe,r),f(e,b,r),t(b,L),t(L,he),T(U,he,null),t(b,mt),t(b,ge),t(ge,ht),f(e,Fe,r),f(e,I,r),t(I,gt),t(I,z),t(z,_t),t(I,bt),f(e,Ue,r),f(e,ne,r),t(ne,vt),f(e,ze,r),f(e,ae,r),t(ae,_e),t(_e,St),f(e,He,r),f(e,H,r),t(H,be),t(be,wt),t(H,yt),f(e,We,r),f(e,A,r),t(A,ve),t(ve,m),t(m,Se),t(Se,Pt),t(m,Dt),t(m,we),t(we,xt),t(m,Tt),t(m,oe),t(oe,Et),t(m,kt),t(m,se),t(se,$t),t(A,Lt),t(A,ye),t(ye,h),t(h,Pe),t(Pe,W),t(W,It),t(h,At),t(h,De),t(De,xe),t(xe,Nt),t(h,jt),t(h,re),t(re,B),t(B,le),t(h,Ct),t(h,ce),t(ce,R),t(R,Gt),f(e,Be,r),f(e,v,r),t(v,N),t(N,Te),T(V,Te,null),t(v,Mt),t(v,Ee),t(Ee,Ot),f(e,Re,r),f(e,de,r),t(de,K),t(K,qt),t(K,pe),t(pe,Ft),t(K,Ut),f(e,Ve,r),f(e,S,r),t(S,j),t(j,ke),T(J,ke,null),t(S,zt),t(S,$e),t($e,Ht),f(e,Ke,r),f(e,C,r),t(C,Wt),t(C,fe),t(fe,Bt),t(C,Rt),f(e,Je,r),T(Q,e,r),f(e,Qe,r),f(e,ue,r),t(ue,Vt),f(e,Ye,r),f(e,w,r),t(w,G),t(G,Le),T(Y,Le,null),t(w,Kt),t(w,Ie),t(Ie,Jt),f(e,Xe,r),f(e,y,r),T(X,y,null),t(y,Qt),t(y,Ae),t(Ae,Yt),f(e,Ze,r),f(e,P,r),t(P,M),t(M,Ne),T(Z,Ne,null),t(P,Xt),t(P,je),t(je,Zt),f(e,et,r),f(e,u,r),T(ee,u,null),t(u,ei),t(u,Ce),t(Ce,ti),t(u,ii),t(u,te),t(te,ni),t(te,me),t(me,ai),t(te,oi),t(u,si),t(u,Ge),t(Ge,ri),t(u,li),t(u,O),T(ie,O,null),t(O,ci),t(O,Me),t(Me,di),tt=!0},p:dn,i(e){tt||(E(U.$$.fragment,e),E(V.$$.fragment,e),E(J.$$.fragment,e),E(Q.$$.fragment,e),E(Y.$$.fragment,e),E(X.$$.fragment,e),E(Z.$$.fragment,e),E(ee.$$.fragment,e),E(ie.$$.fragment,e),tt=!0)},o(e){k(U.$$.fragment,e),k(V.$$.fragment,e),k(J.$$.fragment,e),k(Q.$$.fragment,e),k(Y.$$.fragment,e),k(X.$$.fragment,e),k(Z.$$.fragment,e),k(ee.$$.fragment,e),k(ie.$$.fragment,e),tt=!1},d(e){i(_),e&&i(qe),e&&i(b),$(U),e&&i(Fe),e&&i(I),e&&i(Ue),e&&i(ne),e&&i(ze),e&&i(ae),e&&i(He),e&&i(H),e&&i(We),e&&i(A),e&&i(Be),e&&i(v),$(V),e&&i(Re),e&&i(de),e&&i(Ve),e&&i(S),$(J),e&&i(Ke),e&&i(C),e&&i(Je),$(Q,e),e&&i(Qe),e&&i(ue),e&&i(Ye),e&&i(w),$(Y),e&&i(Xe),e&&i(y),$(X),e&&i(Ze),e&&i(P),$(Z),e&&i(et),e&&i(u),$(ee),$(ie)}}}const mn={local:"semantic-guidance",sections:[{local:"tips",sections:[{local:"run-semantic-guidance",title:"Run Semantic Guidance"}],title:"Tips"},{local:"diffusers.pipelines.semantic_stable_diffusion.SemanticStableDiffusionPipelineOutput",title:"StableDiffusionSafePipelineOutput"},{local:"diffusers.SemanticStableDiffusionPipeline",title:"SemanticStableDiffusionPipeline"}],title:"Semantic Guidance"};function hn(ui){return pn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Sn extends on{constructor(_){super();sn(this,_,hn,un,rn,{})}}export{Sn as default,mn as metadata};
