import{S as on,i as an,s as rn,e as i,k as p,w as A,t as a,M as ln,c as s,d as n,m as f,a as o,x as w,h as r,b as l,G as t,g as u,y as E,q as D,o as P,B as S,v as dn,L as cn}from"../../../chunks/vendor-hf-doc-builder.js";import{T as pn}from"../../../chunks/Tip-hf-doc-builder.js";import{D as le}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as fn}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ut}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as mn}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function un(de){let m,M,h,_,v,d,x,j;return{c(){m=i("p"),M=a("Make sure to check out the Schedulers "),h=i("a"),_=a("guide"),v=a(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),d=i("a"),x=a("reuse components across pipelines"),j=a(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(I){m=s(I,"P",{});var y=o(m);M=r(y,"Make sure to check out the Schedulers "),h=s(y,"A",{href:!0});var k=o(h);_=r(k,"guide"),k.forEach(n),v=r(y," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),d=s(y,"A",{href:!0});var ce=o(d);x=r(ce,"reuse components across pipelines"),ce.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){u(I,m,y),t(m,M),t(m,h),t(h,_),t(m,v),t(m,d),t(d,x),t(m,j)},d(I){I&&n(m)}}}function hn(de){let m,M,h,_,v;return _=new fn({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(){m=i("p"),M=a("Examples:"),h=p(),A(_.$$.fragment)},l(d){m=s(d,"P",{});var x=o(m);M=r(x,"Examples:"),x.forEach(n),h=f(d),w(_.$$.fragment,d)},m(d,x){u(d,m,x),t(m,M),u(d,h,x),E(_,d,x),v=!0},p:cn,i(d){v||(D(_.$$.fragment,d),v=!0)},o(d){P(_.$$.fragment,d),v=!1},d(d){d&&n(m),d&&n(h),S(_,d)}}}function gn(de){let m,M,h,_,v,d,x,j,I,y,k,ce,R,Oe,Xe,Me,pe,qe,$e,fe,he,He,ke,$,Qe,O,Ye,Ke,X,et,tt,q,nt,it,Te,N,je,U,J,ge,H,st,_e,ot,Ie,g,Q,at,be,rt,lt,Y,dt,me,ct,pt,ft,T,K,mt,ve,ut,ht,Z,gt,B,ee,_t,te,bt,xe,vt,xt,yt,G,ne,At,ye,wt,Et,W,ie,Dt,Ae,Pt,St,F,se,Mt,we,$t,Ue,C,z,Ee,oe,kt,De,Tt,Ce,L,ae,jt,Pe,It,Le;return d=new Ut({}),N=new pn({props:{$$slots:{default:[un]},$$scope:{ctx:de}}}),H=new Ut({}),Q=new le({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/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.StableDiffusionAttendAndExcitePipeline.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.StableDiffusionAttendAndExcitePipeline.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.StableDiffusionAttendAndExcitePipeline.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.StableDiffusionAttendAndExcitePipeline.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.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/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/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L165"}}),K=new le({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/main/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/main/en/api/pipelines/stable_diffusion/img2img#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/attention_processor.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/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L707",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
\u201Cnot-safe-for-work\u201D (nsfw) content.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/img2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),Z=new mn({props:{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.example",$$slots:{default:[hn]},$$scope:{ctx:de}}}),ee=new le({props:{name:"disable_vae_slicing",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.disable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L244"}}),ne=new le({props:{name:"enable_vae_slicing",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.enable_vae_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L236"}}),ie=new le({props:{name:"encode_prompt",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt",parameters:[{name:"prompt",val:""},{name:"device",val:""},{name:"num_images_per_prompt",val:""},{name:"do_classifier_free_guidance",val:""},{name:"negative_prompt",val:" = None"},{name:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"lora_scale",val:": typing.Optional[float] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
prompt to be encoded
device &#x2014; (<code>torch.device</code>):
torch device`,name:"prompt"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) &#x2014;
number of images that should be generated per prompt`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.do_classifier_free_guidance",description:`<strong>do_classifier_free_guidance</strong> (<code>bool</code>) &#x2014;
whether to use classifier free guidance or not`,name:"do_classifier_free_guidance"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.negative_prompt",description:`<strong>negative_prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts not to guide the image generation. If not defined, one has to pass
<code>negative_prompt_embeds</code> instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code> is
less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.lora_scale",description:`<strong>lora_scale</strong> (<code>float</code>, <em>optional</em>) &#x2014;
A lora scale that will be applied to all LoRA layers of the text encoder if LoRA layers are loaded.`,name:"lora_scale"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L283"}}),se=new le({props:{name:"get_indices",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.get_indices",parameters:[{name:"prompt",val:": str"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_attend_and_excite.py#L701"}}),oe=new Ut({}),ae=new le({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/__init__.py#L22"}}),{c(){m=i("meta"),M=p(),h=i("h1"),_=i("a"),v=i("span"),A(d.$$.fragment),x=p(),j=i("span"),I=a("Attend-and-Excite"),y=p(),k=i("p"),ce=a("Attend-and-Excite for Stable Diffusion was proposed in "),R=i("a"),Oe=a("Attend-and-Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models"),Xe=a(" and provides textual attention control over image generation."),Me=p(),pe=i("p"),qe=a("The abstract from the paper is:"),$e=p(),fe=i("p"),he=i("em"),He=a("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."),ke=p(),$=i("p"),Qe=a("You can find additional information about Attend-and-Excite on the "),O=i("a"),Ye=a("project page"),Ke=a(", the "),X=i("a"),et=a("original codebase"),tt=a(", or try it out in a "),q=i("a"),nt=a("demo"),it=a("."),Te=p(),A(N.$$.fragment),je=p(),U=i("h2"),J=i("a"),ge=i("span"),A(H.$$.fragment),st=p(),_e=i("span"),ot=a("StableDiffusionAttendAndExcitePipeline"),Ie=p(),g=i("div"),A(Q.$$.fragment),at=p(),be=i("p"),rt=a("Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite."),lt=p(),Y=i("p"),dt=a("This model inherits from "),me=i("a"),ct=a("DiffusionPipeline"),pt=a(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),ft=p(),T=i("div"),A(K.$$.fragment),mt=p(),ve=i("p"),ut=a("The call function to the pipeline for generation."),ht=p(),A(Z.$$.fragment),gt=p(),B=i("div"),A(ee.$$.fragment),_t=p(),te=i("p"),bt=a("Disable sliced VAE decoding. If "),xe=i("code"),vt=a("enable_vae_slicing"),xt=a(` was previously enabled, this method will go back to
computing decoding in one step.`),yt=p(),G=i("div"),A(ne.$$.fragment),At=p(),ye=i("p"),wt=a(`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.`),Et=p(),W=i("div"),A(ie.$$.fragment),Dt=p(),Ae=i("p"),Pt=a("Encodes the prompt into text encoder hidden states."),St=p(),F=i("div"),A(se.$$.fragment),Mt=p(),we=i("p"),$t=a("Utility function to list the indices of the tokens you wish to alte"),Ue=p(),C=i("h2"),z=i("a"),Ee=i("span"),A(oe.$$.fragment),kt=p(),De=i("span"),Tt=a("StableDiffusionPipelineOutput"),Ce=p(),L=i("div"),A(ae.$$.fragment),jt=p(),Pe=i("p"),It=a("Output class for Stable Diffusion pipelines."),this.h()},l(e){const c=ln('[data-svelte="svelte-1phssyn"]',document.head);m=s(c,"META",{name:!0,content:!0}),c.forEach(n),M=f(e),h=s(e,"H1",{class:!0});var re=o(h);_=s(re,"A",{id:!0,class:!0,href:!0});var Se=o(_);v=s(Se,"SPAN",{});var Ct=o(v);w(d.$$.fragment,Ct),Ct.forEach(n),Se.forEach(n),x=f(re),j=s(re,"SPAN",{});var Lt=o(j);I=r(Lt,"Attend-and-Excite"),Lt.forEach(n),re.forEach(n),y=f(e),k=s(e,"P",{});var Ne=o(k);ce=r(Ne,"Attend-and-Excite for Stable Diffusion was proposed in "),R=s(Ne,"A",{href:!0,rel:!0});var Nt=o(R);Oe=r(Nt,"Attend-and-Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models"),Nt.forEach(n),Xe=r(Ne," and provides textual attention control over image generation."),Ne.forEach(n),Me=f(e),pe=s(e,"P",{});var Jt=o(pe);qe=r(Jt,"The abstract from the paper is:"),Jt.forEach(n),$e=f(e),fe=s(e,"P",{});var Zt=o(fe);he=s(Zt,"EM",{});var Bt=o(he);He=r(Bt,"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."),Bt.forEach(n),Zt.forEach(n),ke=f(e),$=s(e,"P",{});var V=o($);Qe=r(V,"You can find additional information about Attend-and-Excite on the "),O=s(V,"A",{href:!0,rel:!0});var Gt=o(O);Ye=r(Gt,"project page"),Gt.forEach(n),Ke=r(V,", the "),X=s(V,"A",{href:!0,rel:!0});var Wt=o(X);et=r(Wt,"original codebase"),Wt.forEach(n),tt=r(V,", or try it out in a "),q=s(V,"A",{href:!0,rel:!0});var Ft=o(q);nt=r(Ft,"demo"),Ft.forEach(n),it=r(V,"."),V.forEach(n),Te=f(e),w(N.$$.fragment,e),je=f(e),U=s(e,"H2",{class:!0});var Je=o(U);J=s(Je,"A",{id:!0,class:!0,href:!0});var zt=o(J);ge=s(zt,"SPAN",{});var Vt=o(ge);w(H.$$.fragment,Vt),Vt.forEach(n),zt.forEach(n),st=f(Je),_e=s(Je,"SPAN",{});var Rt=o(_e);ot=r(Rt,"StableDiffusionAttendAndExcitePipeline"),Rt.forEach(n),Je.forEach(n),Ie=f(e),g=s(e,"DIV",{class:!0});var b=o(g);w(Q.$$.fragment,b),at=f(b),be=s(b,"P",{});var Ot=o(be);rt=r(Ot,"Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite."),Ot.forEach(n),lt=f(b),Y=s(b,"P",{});var Ze=o(Y);dt=r(Ze,"This model inherits from "),me=s(Ze,"A",{href:!0});var Xt=o(me);ct=r(Xt,"DiffusionPipeline"),Xt.forEach(n),pt=r(Ze,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),Ze.forEach(n),ft=f(b),T=s(b,"DIV",{class:!0});var ue=o(T);w(K.$$.fragment,ue),mt=f(ue),ve=s(ue,"P",{});var qt=o(ve);ut=r(qt,"The call function to the pipeline for generation."),qt.forEach(n),ht=f(ue),w(Z.$$.fragment,ue),ue.forEach(n),gt=f(b),B=s(b,"DIV",{class:!0});var Be=o(B);w(ee.$$.fragment,Be),_t=f(Be),te=s(Be,"P",{});var Ge=o(te);bt=r(Ge,"Disable sliced VAE decoding. If "),xe=s(Ge,"CODE",{});var Ht=o(xe);vt=r(Ht,"enable_vae_slicing"),Ht.forEach(n),xt=r(Ge,` was previously enabled, this method will go back to
computing decoding in one step.`),Ge.forEach(n),Be.forEach(n),yt=f(b),G=s(b,"DIV",{class:!0});var We=o(G);w(ne.$$.fragment,We),At=f(We),ye=s(We,"P",{});var Qt=o(ye);wt=r(Qt,`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.`),Qt.forEach(n),We.forEach(n),Et=f(b),W=s(b,"DIV",{class:!0});var Fe=o(W);w(ie.$$.fragment,Fe),Dt=f(Fe),Ae=s(Fe,"P",{});var Yt=o(Ae);Pt=r(Yt,"Encodes the prompt into text encoder hidden states."),Yt.forEach(n),Fe.forEach(n),St=f(b),F=s(b,"DIV",{class:!0});var ze=o(F);w(se.$$.fragment,ze),Mt=f(ze),we=s(ze,"P",{});var Kt=o(we);$t=r(Kt,"Utility function to list the indices of the tokens you wish to alte"),Kt.forEach(n),ze.forEach(n),b.forEach(n),Ue=f(e),C=s(e,"H2",{class:!0});var Ve=o(C);z=s(Ve,"A",{id:!0,class:!0,href:!0});var en=o(z);Ee=s(en,"SPAN",{});var tn=o(Ee);w(oe.$$.fragment,tn),tn.forEach(n),en.forEach(n),kt=f(Ve),De=s(Ve,"SPAN",{});var nn=o(De);Tt=r(nn,"StableDiffusionPipelineOutput"),nn.forEach(n),Ve.forEach(n),Ce=f(e),L=s(e,"DIV",{class:!0});var Re=o(L);w(ae.$$.fragment,Re),jt=f(Re),Pe=s(Re,"P",{});var sn=o(Pe);It=r(sn,"Output class for Stable Diffusion pipelines."),sn.forEach(n),Re.forEach(n),this.h()},h(){l(m,"name","hf:doc:metadata"),l(m,"content",JSON.stringify(_n)),l(_,"id","attendandexcite"),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"),l(_,"href","#attendandexcite"),l(h,"class","relative group"),l(R,"href","https://attendandexcite.github.io/Attend-and-Excite/"),l(R,"rel","nofollow"),l(O,"href","https://attendandexcite.github.io/Attend-and-Excite/"),l(O,"rel","nofollow"),l(X,"href","https://github.com/AttendAndExcite/Attend-and-Excite"),l(X,"rel","nofollow"),l(q,"href","https://huggingface.co/spaces/AttendAndExcite/Attend-and-Excite"),l(q,"rel","nofollow"),l(J,"id","diffusers.StableDiffusionAttendAndExcitePipeline"),l(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"),l(J,"href","#diffusers.StableDiffusionAttendAndExcitePipeline"),l(U,"class","relative group"),l(me,"href","/docs/diffusers/main/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(F,"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(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,m),u(e,M,c),u(e,h,c),t(h,_),t(_,v),E(d,v,null),t(h,x),t(h,j),t(j,I),u(e,y,c),u(e,k,c),t(k,ce),t(k,R),t(R,Oe),t(k,Xe),u(e,Me,c),u(e,pe,c),t(pe,qe),u(e,$e,c),u(e,fe,c),t(fe,he),t(he,He),u(e,ke,c),u(e,$,c),t($,Qe),t($,O),t(O,Ye),t($,Ke),t($,X),t(X,et),t($,tt),t($,q),t(q,nt),t($,it),u(e,Te,c),E(N,e,c),u(e,je,c),u(e,U,c),t(U,J),t(J,ge),E(H,ge,null),t(U,st),t(U,_e),t(_e,ot),u(e,Ie,c),u(e,g,c),E(Q,g,null),t(g,at),t(g,be),t(be,rt),t(g,lt),t(g,Y),t(Y,dt),t(Y,me),t(me,ct),t(Y,pt),t(g,ft),t(g,T),E(K,T,null),t(T,mt),t(T,ve),t(ve,ut),t(T,ht),E(Z,T,null),t(g,gt),t(g,B),E(ee,B,null),t(B,_t),t(B,te),t(te,bt),t(te,xe),t(xe,vt),t(te,xt),t(g,yt),t(g,G),E(ne,G,null),t(G,At),t(G,ye),t(ye,wt),t(g,Et),t(g,W),E(ie,W,null),t(W,Dt),t(W,Ae),t(Ae,Pt),t(g,St),t(g,F),E(se,F,null),t(F,Mt),t(F,we),t(we,$t),u(e,Ue,c),u(e,C,c),t(C,z),t(z,Ee),E(oe,Ee,null),t(C,kt),t(C,De),t(De,Tt),u(e,Ce,c),u(e,L,c),E(ae,L,null),t(L,jt),t(L,Pe),t(Pe,It),Le=!0},p(e,[c]){const re={};c&2&&(re.$$scope={dirty:c,ctx:e}),N.$set(re);const Se={};c&2&&(Se.$$scope={dirty:c,ctx:e}),Z.$set(Se)},i(e){Le||(D(d.$$.fragment,e),D(N.$$.fragment,e),D(H.$$.fragment,e),D(Q.$$.fragment,e),D(K.$$.fragment,e),D(Z.$$.fragment,e),D(ee.$$.fragment,e),D(ne.$$.fragment,e),D(ie.$$.fragment,e),D(se.$$.fragment,e),D(oe.$$.fragment,e),D(ae.$$.fragment,e),Le=!0)},o(e){P(d.$$.fragment,e),P(N.$$.fragment,e),P(H.$$.fragment,e),P(Q.$$.fragment,e),P(K.$$.fragment,e),P(Z.$$.fragment,e),P(ee.$$.fragment,e),P(ne.$$.fragment,e),P(ie.$$.fragment,e),P(se.$$.fragment,e),P(oe.$$.fragment,e),P(ae.$$.fragment,e),Le=!1},d(e){n(m),e&&n(M),e&&n(h),S(d),e&&n(y),e&&n(k),e&&n(Me),e&&n(pe),e&&n($e),e&&n(fe),e&&n(ke),e&&n($),e&&n(Te),S(N,e),e&&n(je),e&&n(U),S(H),e&&n(Ie),e&&n(g),S(Q),S(K),S(Z),S(ee),S(ne),S(ie),S(se),e&&n(Ue),e&&n(C),S(oe),e&&n(Ce),e&&n(L),S(ae)}}}const _n={local:"attendandexcite",sections:[{local:"diffusers.StableDiffusionAttendAndExcitePipeline",title:"StableDiffusionAttendAndExcitePipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"Attend-and-Excite"};function bn(de){return dn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Dn extends on{constructor(m){super();an(this,m,bn,gn,rn,{})}}export{Dn as default,_n as metadata};
