import{S as Ht,i as Qt,s as Yt,e as s,k as f,w as E,t as o,M as Kt,c as i,d as n,m as u,a,x as M,h as r,b as l,G as t,g as m,y as D,q as P,o as S,B as $,v as en,L as tn}from"../../../chunks/vendor-hf-doc-builder.js";import{T as nn}from"../../../chunks/Tip-hf-doc-builder.js";import{D as fe}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as sn}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Pt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as an}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function on(oe){let p,w,h,g,b,d,v,j;return{c(){p=s("p"),w=o("Make sure to check out the Schedulers "),h=s("a"),g=o("guide"),b=o(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),d=s("a"),v=o("reuse components across pipelines"),j=o(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(I){p=i(I,"P",{});var y=a(p);w=r(y,"Make sure to check out the Schedulers "),h=i(y,"A",{href:!0});var k=a(h);g=r(k,"guide"),k.forEach(n),b=r(y," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),d=i(y,"A",{href:!0});var re=a(d);v=r(re,"reuse components across pipelines"),re.forEach(n),j=r(y," section to learn how to efficiently load the same components into multiple pipelines."),y.forEach(n),this.h()},h(){l(h,"href","/using-diffusers/schedulers"),l(d,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(I,y){m(I,p,y),t(p,w),t(p,h),t(h,g),t(p,b),t(p,d),t(d,v),t(p,j)},d(I){I&&n(p)}}}function rn(oe){let p,w,h,g,b;return g=new sn({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uQXR0ZW5kQW5kRXhjaXRlUGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uQXR0ZW5kQW5kRXhjaXRlUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyYSUyMGNhdCUyMGFuZCUyMGElMjBmcm9nJTIyJTBBJTBBJTIzJTIwdXNlJTIwZ2V0X2luZGljZXMlMjBmdW5jdGlvbiUyMHRvJTIwZmluZCUyMG91dCUyMGluZGljZXMlMjBvZiUyMHRoZSUyMHRva2VucyUyMHlvdSUyMHdhbnQlMjB0byUyMGFsdGVyJTBBcGlwZS5nZXRfaW5kaWNlcyhwcm9tcHQpJTBBJTBBdG9rZW5faW5kaWNlcyUyMCUzRCUyMCU1QjIlMkMlMjA1JTVEJTBBc2VlZCUyMCUzRCUyMDYxNDElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoc2VlZCklMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuX2luZGljZXMlM0R0b2tlbl9pbmRpY2VzJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMEElMjAlMjAlMjAlMjBtYXhfaXRlcl90b19hbHRlciUzRDI1JTJDJTBBKS5pbWFnZXMlMEElMEFpbWFnZSUyMCUzRCUyMGltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKGYlMjIuLiUyRmltYWdlcyUyRiU3QnByb21wdCU3RF8lN0JzZWVkJTdELnBuZyUyMik=",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> StableDiffusionAttendAndExcitePipeline

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = StableDiffusionAttendAndExcitePipeline.from_pretrained(
<span class="hljs-meta">... </span>    <span class="hljs-string">&quot;CompVis/stable-diffusion-v1-4&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>).to(<span class="hljs-string">&quot;cuda&quot;</span>)


<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;a cat and a frog&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># use get_indices function to find out indices of the tokens you want to alter</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.get_indices(prompt)
{<span class="hljs-number">0</span>: <span class="hljs-string">&#x27;&lt;|startoftext|&gt;&#x27;</span>, <span class="hljs-number">1</span>: <span class="hljs-string">&#x27;a&lt;/w&gt;&#x27;</span>, <span class="hljs-number">2</span>: <span class="hljs-string">&#x27;cat&lt;/w&gt;&#x27;</span>, <span class="hljs-number">3</span>: <span class="hljs-string">&#x27;and&lt;/w&gt;&#x27;</span>, <span class="hljs-number">4</span>: <span class="hljs-string">&#x27;a&lt;/w&gt;&#x27;</span>, <span class="hljs-number">5</span>: <span class="hljs-string">&#x27;frog&lt;/w&gt;&#x27;</span>, <span class="hljs-number">6</span>: <span class="hljs-string">&#x27;&lt;|endoftext|&gt;&#x27;</span>}

<span class="hljs-meta">&gt;&gt;&gt; </span>token_indices = [<span class="hljs-number">2</span>, <span class="hljs-number">5</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>seed = <span class="hljs-number">6141</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generator = torch.Generator(<span class="hljs-string">&quot;cuda&quot;</span>).manual_seed(seed)

<span class="hljs-meta">&gt;&gt;&gt; </span>images = pipe(
<span class="hljs-meta">... </span>    prompt=prompt,
<span class="hljs-meta">... </span>    token_indices=token_indices,
<span class="hljs-meta">... </span>    guidance_scale=<span class="hljs-number">7.5</span>,
<span class="hljs-meta">... </span>    generator=generator,
<span class="hljs-meta">... </span>    num_inference_steps=<span class="hljs-number">50</span>,
<span class="hljs-meta">... </span>    max_iter_to_alter=<span class="hljs-number">25</span>,
<span class="hljs-meta">... </span>).images

<span class="hljs-meta">&gt;&gt;&gt; </span>image = images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">f&quot;../images/<span class="hljs-subst">{prompt}</span>_<span class="hljs-subst">{seed}</span>.png&quot;</span>)`}}),{c(){p=s("p"),w=o("Examples:"),h=f(),E(g.$$.fragment)},l(d){p=i(d,"P",{});var v=a(p);w=r(v,"Examples:"),v.forEach(n),h=u(d),M(g.$$.fragment,d)},m(d,v){m(d,p,v),t(p,w),m(d,h,v),D(g,d,v),b=!0},p:tn,i(d){b||(P(g.$$.fragment,d),b=!0)},o(d){S(g.$$.fragment,d),b=!1},d(d){d&&n(p),d&&n(h),$(g,d)}}}function ln(oe){let p,w,h,g,b,d,v,j,I,y,k,re,V,ze,Fe,Me,le,Ve,De,de,ue,Re,Pe,A,Oe,R,Xe,qe,O,He,Qe,X,Ye,Ke,Se,J,$e,U,Z,me,q,et,he,tt,ke,_,H,nt,ge,st,it,Q,at,ce,ot,rt,lt,T,Y,dt,_e,ct,pt,N,ft,B,K,ut,ee,mt,be,ht,gt,_t,G,te,bt,ve,vt,xt,W,ne,yt,xe,wt,Te,C,z,ye,se,At,we,Et,je,L,ie,Mt,Ae,Dt,Ie;return d=new Pt({}),J=new nn({props:{$$slots:{default:[on]},$$scope:{ctx:oe}}}),q=new Pt({}),H=new fe({props:{name:"class diffusers.StableDiffusionAttendAndExcitePipeline",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline",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.StableDiffusionAttendAndExcitePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.19.0/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/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.StableDiffusionAttendAndExcitePipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.19.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.19.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/v0.19.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.19.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.19.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.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.StableDiffusionAttendAndExcitePipeline.feature_extractor",description:`<strong>feature_extractor</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/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/v0.19.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L165"}}),Y=new fe({props:{name:"__call__",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"token_indices",val:": typing.Union[typing.List[int], typing.List[typing.List[int]]]"},{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:": 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:"max_iter_to_alter",val:": int = 25"},{name:"thresholds",val:": dict = {0: 0.05, 10: 0.5, 20: 0.8}"},{name:"scale_factor",val:": int = 20"},{name:"attn_res",val:": typing.Optional[typing.Tuple[int]] = (16, 16)"}],parametersDescription:[{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__call__.token_indices",description:`<strong>token_indices</strong> (<code>List[int]</code>) &#x2014;
The token indices to alter with attend-and-excite.`,name:"token_indices"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/v0.19.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.19.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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.StableDiffusionAttendAndExcitePipeline.__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/cross_attention.py" rel="nofollow"><code>self.processor</code></a>.`,name:"cross_attention_kwargs"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.max_iter_to_alter",description:`<strong>max_iter_to_alter</strong> (<code>int</code>, <em>optional</em>, defaults to <code>25</code>) &#x2014;
Number of denoising steps to apply attend-and-excite. The <code>max_iter_to_alter</code> denoising steps are when
attend-and-excite is applied. For example, if <code>max_iter_to_alter</code> is <code>25</code> and there are a total of <code>30</code>
denoising steps, the first <code>25</code> denoising steps applies attend-and-excite and the last <code>5</code> will not.`,name:"max_iter_to_alter"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.thresholds",description:`<strong>thresholds</strong> (<code>dict</code>, <em>optional</em>, defaults to <code>{0 -- 0.05, 10: 0.5, 20: 0.8}</code>):
Dictionary defining the iterations and desired thresholds to apply iterative latent refinement in.`,name:"thresholds"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.scale_factor",description:`<strong>scale_factor</strong> (<code>int</code>, <em>optional</em>, default to 20) &#x2014;
Scale factor to control the step size of each attend-and-excite update.`,name:"scale_factor"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.attn_res",description:`<strong>attn_res</strong> (<code>tuple</code>, <em>optional</em>, default computed from width and height) &#x2014;
The 2D resolution of the semantic attention map.`,name:"attn_res"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L674",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.19.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
\u201Cnot-safe-for-work\u201D (nsfw) content.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.19.0/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),N=new an({props:{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.example",$$slots:{default:[rn]},$$scope:{ctx:oe}}}),K=new fe({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L244"}}),te=new fe({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L236"}}),ne=new fe({props:{name:"get_indices",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.get_indices",parameters:[{name:"prompt",val:": str"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L668"}}),se=new Pt({}),ie=new fe({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.0/src/diffusers/pipelines/stable_diffusion/__init__.py#L22"}}),{c(){p=s("meta"),w=f(),h=s("h1"),g=s("a"),b=s("span"),E(d.$$.fragment),v=f(),j=s("span"),I=o("Attend-and-Excite"),y=f(),k=s("p"),re=o("Attend-and-Excite for Stable Diffusion was proposed in "),V=s("a"),ze=o("Attend-and-Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models"),Fe=o(" and provides textual attention control over image generation."),Me=f(),le=s("p"),Ve=o("The abstract from the paper is:"),De=f(),de=s("p"),ue=s("em"),Re=o("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."),Pe=f(),A=s("p"),Oe=o("You can find additional information about Attend-and-Excite on the "),R=s("a"),Xe=o("project page"),qe=o(", the "),O=s("a"),He=o("original codebase"),Qe=o(", or try it out in a "),X=s("a"),Ye=o("demo"),Ke=o("."),Se=f(),E(J.$$.fragment),$e=f(),U=s("h2"),Z=s("a"),me=s("span"),E(q.$$.fragment),et=f(),he=s("span"),tt=o("StableDiffusionAttendAndExcitePipeline"),ke=f(),_=s("div"),E(H.$$.fragment),nt=f(),ge=s("p"),st=o("Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite."),it=f(),Q=s("p"),at=o("This model inherits from "),ce=s("a"),ot=o("DiffusionPipeline"),rt=o(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),lt=f(),T=s("div"),E(Y.$$.fragment),dt=f(),_e=s("p"),ct=o("The call function to the pipeline for generation."),pt=f(),E(N.$$.fragment),ft=f(),B=s("div"),E(K.$$.fragment),ut=f(),ee=s("p"),mt=o("Disable sliced VAE decoding. If "),be=s("code"),ht=o("enable_vae_slicing"),gt=o(` was previously enabled, this method will go back to
computing decoding in one step.`),_t=f(),G=s("div"),E(te.$$.fragment),bt=f(),ve=s("p"),vt=o(`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.`),xt=f(),W=s("div"),E(ne.$$.fragment),yt=f(),xe=s("p"),wt=o("Utility function to list the indices of the tokens you wish to alte"),Te=f(),C=s("h2"),z=s("a"),ye=s("span"),E(se.$$.fragment),At=f(),we=s("span"),Et=o("StableDiffusionPipelineOutput"),je=f(),L=s("div"),E(ie.$$.fragment),Mt=f(),Ae=s("p"),Dt=o("Output class for Stable Diffusion pipelines."),this.h()},l(e){const c=Kt('[data-svelte="svelte-1phssyn"]',document.head);p=i(c,"META",{name:!0,content:!0}),c.forEach(n),w=u(e),h=i(e,"H1",{class:!0});var ae=a(h);g=i(ae,"A",{id:!0,class:!0,href:!0});var Ee=a(g);b=i(Ee,"SPAN",{});var St=a(b);M(d.$$.fragment,St),St.forEach(n),Ee.forEach(n),v=u(ae),j=i(ae,"SPAN",{});var $t=a(j);I=r($t,"Attend-and-Excite"),$t.forEach(n),ae.forEach(n),y=u(e),k=i(e,"P",{});var Ue=a(k);re=r(Ue,"Attend-and-Excite for Stable Diffusion was proposed in "),V=i(Ue,"A",{href:!0,rel:!0});var kt=a(V);ze=r(kt,"Attend-and-Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models"),kt.forEach(n),Fe=r(Ue," and provides textual attention control over image generation."),Ue.forEach(n),Me=u(e),le=i(e,"P",{});var Tt=a(le);Ve=r(Tt,"The abstract from the paper is:"),Tt.forEach(n),De=u(e),de=i(e,"P",{});var jt=a(de);ue=i(jt,"EM",{});var It=a(ue);Re=r(It,"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."),It.forEach(n),jt.forEach(n),Pe=u(e),A=i(e,"P",{});var F=a(A);Oe=r(F,"You can find additional information about Attend-and-Excite on the "),R=i(F,"A",{href:!0,rel:!0});var Ut=a(R);Xe=r(Ut,"project page"),Ut.forEach(n),qe=r(F,", the "),O=i(F,"A",{href:!0,rel:!0});var Ct=a(O);He=r(Ct,"original codebase"),Ct.forEach(n),Qe=r(F,", or try it out in a "),X=i(F,"A",{href:!0,rel:!0});var Lt=a(X);Ye=r(Lt,"demo"),Lt.forEach(n),Ke=r(F,"."),F.forEach(n),Se=u(e),M(J.$$.fragment,e),$e=u(e),U=i(e,"H2",{class:!0});var Ce=a(U);Z=i(Ce,"A",{id:!0,class:!0,href:!0});var Jt=a(Z);me=i(Jt,"SPAN",{});var Zt=a(me);M(q.$$.fragment,Zt),Zt.forEach(n),Jt.forEach(n),et=u(Ce),he=i(Ce,"SPAN",{});var Nt=a(he);tt=r(Nt,"StableDiffusionAttendAndExcitePipeline"),Nt.forEach(n),Ce.forEach(n),ke=u(e),_=i(e,"DIV",{class:!0});var x=a(_);M(H.$$.fragment,x),nt=u(x),ge=i(x,"P",{});var Bt=a(ge);st=r(Bt,"Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite."),Bt.forEach(n),it=u(x),Q=i(x,"P",{});var Le=a(Q);at=r(Le,"This model inherits from "),ce=i(Le,"A",{href:!0});var Gt=a(ce);ot=r(Gt,"DiffusionPipeline"),Gt.forEach(n),rt=r(Le,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Le.forEach(n),lt=u(x),T=i(x,"DIV",{class:!0});var pe=a(T);M(Y.$$.fragment,pe),dt=u(pe),_e=i(pe,"P",{});var Wt=a(_e);ct=r(Wt,"The call function to the pipeline for generation."),Wt.forEach(n),pt=u(pe),M(N.$$.fragment,pe),pe.forEach(n),ft=u(x),B=i(x,"DIV",{class:!0});var Je=a(B);M(K.$$.fragment,Je),ut=u(Je),ee=i(Je,"P",{});var Ze=a(ee);mt=r(Ze,"Disable sliced VAE decoding. If "),be=i(Ze,"CODE",{});var zt=a(be);ht=r(zt,"enable_vae_slicing"),zt.forEach(n),gt=r(Ze,` was previously enabled, this method will go back to
computing decoding in one step.`),Ze.forEach(n),Je.forEach(n),_t=u(x),G=i(x,"DIV",{class:!0});var Ne=a(G);M(te.$$.fragment,Ne),bt=u(Ne),ve=i(Ne,"P",{});var Ft=a(ve);vt=r(Ft,`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.`),Ft.forEach(n),Ne.forEach(n),xt=u(x),W=i(x,"DIV",{class:!0});var Be=a(W);M(ne.$$.fragment,Be),yt=u(Be),xe=i(Be,"P",{});var Vt=a(xe);wt=r(Vt,"Utility function to list the indices of the tokens you wish to alte"),Vt.forEach(n),Be.forEach(n),x.forEach(n),Te=u(e),C=i(e,"H2",{class:!0});var Ge=a(C);z=i(Ge,"A",{id:!0,class:!0,href:!0});var Rt=a(z);ye=i(Rt,"SPAN",{});var Ot=a(ye);M(se.$$.fragment,Ot),Ot.forEach(n),Rt.forEach(n),At=u(Ge),we=i(Ge,"SPAN",{});var Xt=a(we);Et=r(Xt,"StableDiffusionPipelineOutput"),Xt.forEach(n),Ge.forEach(n),je=u(e),L=i(e,"DIV",{class:!0});var We=a(L);M(ie.$$.fragment,We),Mt=u(We),Ae=i(We,"P",{});var qt=a(Ae);Dt=r(qt,"Output class for Stable Diffusion pipelines."),qt.forEach(n),We.forEach(n),this.h()},h(){l(p,"name","hf:doc:metadata"),l(p,"content",JSON.stringify(dn)),l(g,"id","attendandexcite"),l(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"),l(g,"href","#attendandexcite"),l(h,"class","relative group"),l(V,"href","https://attendandexcite.github.io/Attend-and-Excite/"),l(V,"rel","nofollow"),l(R,"href","https://attendandexcite.github.io/Attend-and-Excite/"),l(R,"rel","nofollow"),l(O,"href","https://github.com/AttendAndExcite/Attend-and-Excite"),l(O,"rel","nofollow"),l(X,"href","https://huggingface.co/spaces/AttendAndExcite/Attend-and-Excite"),l(X,"rel","nofollow"),l(Z,"id","diffusers.StableDiffusionAttendAndExcitePipeline"),l(Z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(Z,"href","#diffusers.StableDiffusionAttendAndExcitePipeline"),l(U,"class","relative group"),l(ce,"href","/docs/diffusers/v0.19.0/en/api/pipelines/overview#diffusers.DiffusionPipeline"),l(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(_,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),l(z,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),l(z,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),l(z,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),l(C,"class","relative group"),l(L,"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,c){t(document.head,p),m(e,w,c),m(e,h,c),t(h,g),t(g,b),D(d,b,null),t(h,v),t(h,j),t(j,I),m(e,y,c),m(e,k,c),t(k,re),t(k,V),t(V,ze),t(k,Fe),m(e,Me,c),m(e,le,c),t(le,Ve),m(e,De,c),m(e,de,c),t(de,ue),t(ue,Re),m(e,Pe,c),m(e,A,c),t(A,Oe),t(A,R),t(R,Xe),t(A,qe),t(A,O),t(O,He),t(A,Qe),t(A,X),t(X,Ye),t(A,Ke),m(e,Se,c),D(J,e,c),m(e,$e,c),m(e,U,c),t(U,Z),t(Z,me),D(q,me,null),t(U,et),t(U,he),t(he,tt),m(e,ke,c),m(e,_,c),D(H,_,null),t(_,nt),t(_,ge),t(ge,st),t(_,it),t(_,Q),t(Q,at),t(Q,ce),t(ce,ot),t(Q,rt),t(_,lt),t(_,T),D(Y,T,null),t(T,dt),t(T,_e),t(_e,ct),t(T,pt),D(N,T,null),t(_,ft),t(_,B),D(K,B,null),t(B,ut),t(B,ee),t(ee,mt),t(ee,be),t(be,ht),t(ee,gt),t(_,_t),t(_,G),D(te,G,null),t(G,bt),t(G,ve),t(ve,vt),t(_,xt),t(_,W),D(ne,W,null),t(W,yt),t(W,xe),t(xe,wt),m(e,Te,c),m(e,C,c),t(C,z),t(z,ye),D(se,ye,null),t(C,At),t(C,we),t(we,Et),m(e,je,c),m(e,L,c),D(ie,L,null),t(L,Mt),t(L,Ae),t(Ae,Dt),Ie=!0},p(e,[c]){const ae={};c&2&&(ae.$$scope={dirty:c,ctx:e}),J.$set(ae);const Ee={};c&2&&(Ee.$$scope={dirty:c,ctx:e}),N.$set(Ee)},i(e){Ie||(P(d.$$.fragment,e),P(J.$$.fragment,e),P(q.$$.fragment,e),P(H.$$.fragment,e),P(Y.$$.fragment,e),P(N.$$.fragment,e),P(K.$$.fragment,e),P(te.$$.fragment,e),P(ne.$$.fragment,e),P(se.$$.fragment,e),P(ie.$$.fragment,e),Ie=!0)},o(e){S(d.$$.fragment,e),S(J.$$.fragment,e),S(q.$$.fragment,e),S(H.$$.fragment,e),S(Y.$$.fragment,e),S(N.$$.fragment,e),S(K.$$.fragment,e),S(te.$$.fragment,e),S(ne.$$.fragment,e),S(se.$$.fragment,e),S(ie.$$.fragment,e),Ie=!1},d(e){n(p),e&&n(w),e&&n(h),$(d),e&&n(y),e&&n(k),e&&n(Me),e&&n(le),e&&n(De),e&&n(de),e&&n(Pe),e&&n(A),e&&n(Se),$(J,e),e&&n($e),e&&n(U),$(q),e&&n(ke),e&&n(_),$(H),$(Y),$(N),$(K),$(te),$(ne),e&&n(Te),e&&n(C),$(se),e&&n(je),e&&n(L),$(ie)}}}const dn={local:"attendandexcite",sections:[{local:"diffusers.StableDiffusionAttendAndExcitePipeline",title:"StableDiffusionAttendAndExcitePipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"Attend-and-Excite"};function cn(oe){return en(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class _n extends Ht{constructor(p){super();Qt(this,p,cn,ln,Yt,{})}}export{_n as default,dn as metadata};
