import{s as et,o as tt,n as Ke}from"../chunks/scheduler.182ea377.js";import{S as nt,i as st,g as o,s as i,r as h,A as it,h as r,f as t,c as a,j as E,u as _,x as u,k as S,y as s,a as p,v as b,d as x,t as v,w as A}from"../chunks/index.abf12888.js";import{T as at}from"../chunks/Tip.230e2334.js";import{D as H}from"../chunks/Docstring.93f6f462.js";import{C as ot}from"../chunks/CodeBlock.57fe6e13.js";import{E as rt}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as Je}from"../chunks/Heading.16916d63.js";function lt(X){let l,M='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){l=o("p"),l.innerHTML=M},l(m){l=r(m,"P",{"data-svelte-h":!0}),u(l)!=="svelte-1wmc0l4"&&(l.innerHTML=M)},m(m,g){p(m,l,g)},p:Ke,d(m){m&&t(l)}}}function dt(X){let l,M="Examples:",m,g,w;return g=new ot({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>)`,wrap:!1}}),{c(){l=o("p"),l.textContent=M,m=i(),h(g.$$.fragment)},l(f){l=r(f,"P",{"data-svelte-h":!0}),u(l)!=="svelte-kvfsh7"&&(l.textContent=M),m=a(f),_(g.$$.fragment,f)},m(f,y){p(f,l,y),p(f,m,y),b(g,f,y),w=!0},p:Ke,i(f){w||(x(g.$$.fragment,f),w=!0)},o(f){v(g.$$.fragment,f),w=!1},d(f){f&&(t(l),t(m)),A(g,f)}}}function ct(X){let l,M,m,g,w,f,y,Ne='Attend-and-Excite for Stable Diffusion was proposed in <a href="https://attendandexcite.github.io/Attend-and-Excite/" rel="nofollow">Attend-and-Excite: Attention-Based Semantic Guidance for Text-to-Image Diffusion Models</a> and provides textual attention control over image generation.',re,L,Be="The abstract from the paper is:",le,Z,We="<em>Recent text-to-image generative models have demonstrated an unparalleled ability to generate diverse and creative imagery guided by a target text prompt. While revolutionary, current state-of-the-art diffusion models may still fail in generating images that fully convey the semantics in the given text prompt. We analyze the publicly available Stable Diffusion model and assess the existence of catastrophic neglect, where the model fails to generate one or more of the subjects from the input prompt. Moreover, we find that in some cases the model also fails to correctly bind attributes (e.g., colors) to their corresponding subjects. To help mitigate these failure cases, we introduce the concept of Generative Semantic Nursing (GSN), where we seek to intervene in the generative process on the fly during inference time to improve the faithfulness of the generated images. Using an attention-based formulation of GSN, dubbed Attend-and-Excite, we guide the model to refine the cross-attention units to attend to all subject tokens in the text prompt and strengthen - or excite - their activations, encouraging the model to generate all subjects described in the text prompt. We compare our approach to alternative approaches and demonstrate that it conveys the desired concepts more faithfully across a range of text prompts.</em>",de,J,Ge='You can find additional information about Attend-and-Excite on the <a href="https://attendandexcite.github.io/Attend-and-Excite/" rel="nofollow">project page</a>, the <a href="https://github.com/AttendAndExcite/Attend-and-Excite" rel="nofollow">original codebase</a>, or try it out in a <a href="https://huggingface.co/spaces/AttendAndExcite/Attend-and-Excite" rel="nofollow">demo</a>.',ce,k,pe,N,fe,d,B,we,q,ze="Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite.",ye,Q,Re=`This model inherits from <a href="/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,Me,Y,Fe="The pipeline also inherits the following loading methods:",Pe,K,Ve='<li><a href="/docs/diffusers/main/en/api/loaders/textual_inversion#diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion">load_textual_inversion()</a> for loading textual inversion embeddings</li>',$e,P,W,De,ee,Oe="The call function to the pipeline for generation.",Ee,C,Se,T,G,ke,te,He=`Disable sliced VAE decoding. If <code>enable_vae_slicing</code> was previously enabled, this method will go back to
computing decoding in one step.`,Ce,j,z,Te,ne,Xe=`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.`,je,I,R,Ie,se,qe="Encodes the prompt into text encoder hidden states.",Ue,U,F,Le,ie,Qe="Utility function to list the indices of the tokens you wish to alte",me,V,ue,$,O,Ze,ae,Ye="Output class for Stable Diffusion pipelines.",ge,oe,he;return w=new Je({props:{title:"Attend-and-Excite",local:"attend-and-excite",headingTag:"h1"}}),k=new at({props:{$$slots:{default:[lt]},$$scope:{ctx:X}}}),N=new Je({props:{title:"StableDiffusionAttendAndExcitePipeline",local:"diffusers.StableDiffusionAttendAndExcitePipeline",headingTag:"h2"}}),B=new H({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_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L173"}}),W=new H({props:{name:"__call__",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__",parameters:[{name:"prompt",val:": Union"},{name:"token_indices",val:": Union"},{name:"height",val:": Optional = None"},{name:"width",val:": Optional = None"},{name:"num_inference_steps",val:": int = 50"},{name:"guidance_scale",val:": float = 7.5"},{name:"negative_prompt",val:": Union = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": Union = None"},{name:"latents",val:": Optional = None"},{name:"prompt_embeds",val:": Optional = None"},{name:"negative_prompt_embeds",val:": Optional = None"},{name:"output_type",val:": Optional = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": Optional = None"},{name:"callback_steps",val:": int = 1"},{name:"cross_attention_kwargs",val:": Optional = 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:": Optional = (16, 16)"},{name:"clip_skip",val:": Optional = None"}],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/upscale#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"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.clip_skip",description:`<strong>clip_skip</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that
the output of the pre-final layer will be used for computing the prompt embeddings.`,name:"clip_skip"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L746",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/upscale#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images and the
second element is a list of <code>bool</code>s indicating whether the corresponding generated image contains
“not-safe-for-work” (nsfw) content.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/upscale#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),C=new rt({props:{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.example",$$slots:{default:[dt]},$$scope:{ctx:X}}}),G=new H({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_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L258"}}),z=new H({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_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L250"}}),R=new H({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:": Optional = None"},{name:"negative_prompt_embeds",val:": Optional = None"},{name:"lora_scale",val:": Optional = None"},{name:"clip_skip",val:": Optional = 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"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.clip_skip",description:`<strong>clip_skip</strong> (<code>int</code>, <em>optional</em>) &#x2014;
Number of layers to be skipped from CLIP while computing the prompt embeddings. A value of 1 means that
the output of the pre-final layer will be used for computing the prompt embeddings.`,name:"clip_skip"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L299"}}),F=new H({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_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L740"}}),V=new Je({props:{title:"StableDiffusionPipelineOutput",local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",headingTag:"h2"}}),O=new H({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": Union"},{name:"nsfw_content_detected",val:": Optional"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_output.py#L10"}}),{c(){l=o("meta"),M=i(),m=o("p"),g=i(),h(w.$$.fragment),f=i(),y=o("p"),y.innerHTML=Ne,re=i(),L=o("p"),L.textContent=Be,le=i(),Z=o("p"),Z.innerHTML=We,de=i(),J=o("p"),J.innerHTML=Ge,ce=i(),h(k.$$.fragment),pe=i(),h(N.$$.fragment),fe=i(),d=o("div"),h(B.$$.fragment),we=i(),q=o("p"),q.textContent=ze,ye=i(),Q=o("p"),Q.innerHTML=Re,Me=i(),Y=o("p"),Y.textContent=Fe,Pe=i(),K=o("ul"),K.innerHTML=Ve,$e=i(),P=o("div"),h(W.$$.fragment),De=i(),ee=o("p"),ee.textContent=Oe,Ee=i(),h(C.$$.fragment),Se=i(),T=o("div"),h(G.$$.fragment),ke=i(),te=o("p"),te.innerHTML=He,Ce=i(),j=o("div"),h(z.$$.fragment),Te=i(),ne=o("p"),ne.textContent=Xe,je=i(),I=o("div"),h(R.$$.fragment),Ie=i(),se=o("p"),se.textContent=qe,Ue=i(),U=o("div"),h(F.$$.fragment),Le=i(),ie=o("p"),ie.textContent=Qe,me=i(),h(V.$$.fragment),ue=i(),$=o("div"),h(O.$$.fragment),Ze=i(),ae=o("p"),ae.textContent=Ye,ge=i(),oe=o("p"),this.h()},l(e){const n=it("svelte-u9bgzb",document.head);l=r(n,"META",{name:!0,content:!0}),n.forEach(t),M=a(e),m=r(e,"P",{}),E(m).forEach(t),g=a(e),_(w.$$.fragment,e),f=a(e),y=r(e,"P",{"data-svelte-h":!0}),u(y)!=="svelte-oxdtcr"&&(y.innerHTML=Ne),re=a(e),L=r(e,"P",{"data-svelte-h":!0}),u(L)!=="svelte-1cwsb16"&&(L.textContent=Be),le=a(e),Z=r(e,"P",{"data-svelte-h":!0}),u(Z)!=="svelte-lkgois"&&(Z.innerHTML=We),de=a(e),J=r(e,"P",{"data-svelte-h":!0}),u(J)!=="svelte-oxzb6"&&(J.innerHTML=Ge),ce=a(e),_(k.$$.fragment,e),pe=a(e),_(N.$$.fragment,e),fe=a(e),d=r(e,"DIV",{class:!0});var c=E(d);_(B.$$.fragment,c),we=a(c),q=r(c,"P",{"data-svelte-h":!0}),u(q)!=="svelte-1t0tlj6"&&(q.textContent=ze),ye=a(c),Q=r(c,"P",{"data-svelte-h":!0}),u(Q)!=="svelte-496sm0"&&(Q.innerHTML=Re),Me=a(c),Y=r(c,"P",{"data-svelte-h":!0}),u(Y)!=="svelte-14s6m4u"&&(Y.textContent=Fe),Pe=a(c),K=r(c,"UL",{"data-svelte-h":!0}),u(K)!=="svelte-lbbuv4"&&(K.innerHTML=Ve),$e=a(c),P=r(c,"DIV",{class:!0});var D=E(P);_(W.$$.fragment,D),De=a(D),ee=r(D,"P",{"data-svelte-h":!0}),u(ee)!=="svelte-50j04k"&&(ee.textContent=Oe),Ee=a(D),_(C.$$.fragment,D),D.forEach(t),Se=a(c),T=r(c,"DIV",{class:!0});var _e=E(T);_(G.$$.fragment,_e),ke=a(_e),te=r(_e,"P",{"data-svelte-h":!0}),u(te)!=="svelte-1s3c06i"&&(te.innerHTML=He),_e.forEach(t),Ce=a(c),j=r(c,"DIV",{class:!0});var be=E(j);_(z.$$.fragment,be),Te=a(be),ne=r(be,"P",{"data-svelte-h":!0}),u(ne)!=="svelte-14bnrb6"&&(ne.textContent=Xe),be.forEach(t),je=a(c),I=r(c,"DIV",{class:!0});var xe=E(I);_(R.$$.fragment,xe),Ie=a(xe),se=r(xe,"P",{"data-svelte-h":!0}),u(se)!=="svelte-16q0ax1"&&(se.textContent=qe),xe.forEach(t),Ue=a(c),U=r(c,"DIV",{class:!0});var ve=E(U);_(F.$$.fragment,ve),Le=a(ve),ie=r(ve,"P",{"data-svelte-h":!0}),u(ie)!=="svelte-98zxno"&&(ie.textContent=Qe),ve.forEach(t),c.forEach(t),me=a(e),_(V.$$.fragment,e),ue=a(e),$=r(e,"DIV",{class:!0});var Ae=E($);_(O.$$.fragment,Ae),Ze=a(Ae),ae=r(Ae,"P",{"data-svelte-h":!0}),u(ae)!=="svelte-1qpjiuf"&&(ae.textContent=Ye),Ae.forEach(t),ge=a(e),oe=r(e,"P",{}),E(oe).forEach(t),this.h()},h(){S(l,"name","hf:doc:metadata"),S(l,"content",pt),S(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(T,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S(I,"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"),S(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),S($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,n){s(document.head,l),p(e,M,n),p(e,m,n),p(e,g,n),b(w,e,n),p(e,f,n),p(e,y,n),p(e,re,n),p(e,L,n),p(e,le,n),p(e,Z,n),p(e,de,n),p(e,J,n),p(e,ce,n),b(k,e,n),p(e,pe,n),b(N,e,n),p(e,fe,n),p(e,d,n),b(B,d,null),s(d,we),s(d,q),s(d,ye),s(d,Q),s(d,Me),s(d,Y),s(d,Pe),s(d,K),s(d,$e),s(d,P),b(W,P,null),s(P,De),s(P,ee),s(P,Ee),b(C,P,null),s(d,Se),s(d,T),b(G,T,null),s(T,ke),s(T,te),s(d,Ce),s(d,j),b(z,j,null),s(j,Te),s(j,ne),s(d,je),s(d,I),b(R,I,null),s(I,Ie),s(I,se),s(d,Ue),s(d,U),b(F,U,null),s(U,Le),s(U,ie),p(e,me,n),b(V,e,n),p(e,ue,n),p(e,$,n),b(O,$,null),s($,Ze),s($,ae),p(e,ge,n),p(e,oe,n),he=!0},p(e,[n]){const c={};n&2&&(c.$$scope={dirty:n,ctx:e}),k.$set(c);const D={};n&2&&(D.$$scope={dirty:n,ctx:e}),C.$set(D)},i(e){he||(x(w.$$.fragment,e),x(k.$$.fragment,e),x(N.$$.fragment,e),x(B.$$.fragment,e),x(W.$$.fragment,e),x(C.$$.fragment,e),x(G.$$.fragment,e),x(z.$$.fragment,e),x(R.$$.fragment,e),x(F.$$.fragment,e),x(V.$$.fragment,e),x(O.$$.fragment,e),he=!0)},o(e){v(w.$$.fragment,e),v(k.$$.fragment,e),v(N.$$.fragment,e),v(B.$$.fragment,e),v(W.$$.fragment,e),v(C.$$.fragment,e),v(G.$$.fragment,e),v(z.$$.fragment,e),v(R.$$.fragment,e),v(F.$$.fragment,e),v(V.$$.fragment,e),v(O.$$.fragment,e),he=!1},d(e){e&&(t(M),t(m),t(g),t(f),t(y),t(re),t(L),t(le),t(Z),t(de),t(J),t(ce),t(pe),t(fe),t(d),t(me),t(ue),t($),t(ge),t(oe)),t(l),A(w,e),A(k,e),A(N,e),A(B),A(W),A(C),A(G),A(z),A(R),A(F),A(V,e),A(O)}}}const pt='{"title":"Attend-and-Excite","local":"attend-and-excite","sections":[{"title":"StableDiffusionAttendAndExcitePipeline","local":"diffusers.StableDiffusionAttendAndExcitePipeline","sections":[],"depth":2},{"title":"StableDiffusionPipelineOutput","local":"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput","sections":[],"depth":2}],"depth":1}';function ft(X){return tt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vt extends nt{constructor(l){super(),st(this,l,ft,ct,et,{})}}export{vt as component};
