Buckets:
| import{s as Xe,o as Ve,n as Fe}from"../chunks/scheduler.53228c21.js";import{S as qe,i as Qe,e as r,s as i,c as h,h as Ye,a as l,d as n,b as s,f as H,j as m,g as _,k as P,l as a,m as o,n as b,t as x,o as v,p as y}from"../chunks/index.100fac89.js";import{C as Ke}from"../chunks/CopyLLMTxtMenu.2e0d31a4.js";import{D as ie}from"../chunks/Docstring.95cca3f7.js";import{C as et}from"../chunks/CodeBlock.d30a6509.js";import{E as tt}from"../chunks/ExampleCodeBlock.1209a48b.js";import{H as je,E as nt}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.b400f367.js";function it(se){let c,$="Examples:",A,g,u;return g=new et({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwU3RhYmxlRGlmZnVzaW9uQXR0ZW5kQW5kRXhjaXRlUGlwZWxpbmUlMEElMEFwaXBlJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uQXR0ZW5kQW5kRXhjaXRlUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUwQSUyMCUyMCUyMCUyMCUyMkNvbXBWaXMlMkZzdGFibGUtZGlmZnVzaW9uLXYxLTQlMjIlMkMlMjB0b3JjaF9kdHlwZSUzRHRvcmNoLmZsb2F0MTYlMEEpLnRvKCUyMmN1ZGElMjIpJTBBJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyYSUyMGNhdCUyMGFuZCUyMGElMjBmcm9nJTIyJTBBJTBBJTIzJTIwdXNlJTIwZ2V0X2luZGljZXMlMjBmdW5jdGlvbiUyMHRvJTIwZmluZCUyMG91dCUyMGluZGljZXMlMjBvZiUyMHRoZSUyMHRva2VucyUyMHlvdSUyMHdhbnQlMjB0byUyMGFsdGVyJTBBcGlwZS5nZXRfaW5kaWNlcyhwcm9tcHQpJTBBJTBBdG9rZW5faW5kaWNlcyUyMCUzRCUyMCU1QjIlMkMlMjA1JTVEJTBBc2VlZCUyMCUzRCUyMDYxNDElMEFnZW5lcmF0b3IlMjAlM0QlMjB0b3JjaC5HZW5lcmF0b3IoJTIyY3VkYSUyMikubWFudWFsX3NlZWQoc2VlZCklMEElMEFpbWFnZXMlMjAlM0QlMjBwaXBlKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMHRva2VuX2luZGljZXMlM0R0b2tlbl9pbmRpY2VzJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0Q3LjUlMkMlMEElMjAlMjAlMjAlMjBnZW5lcmF0b3IlM0RnZW5lcmF0b3IlMkMlMEElMjAlMjAlMjAlMjBudW1faW5mZXJlbmNlX3N0ZXBzJTNENTAlMkMlMEElMjAlMjAlMjAlMjBtYXhfaXRlcl90b19hbHRlciUzRDI1JTJDJTBBKS5pbWFnZXMlMEElMEFpbWFnZSUyMCUzRCUyMGltYWdlcyU1QjAlNUQlMEFpbWFnZS5zYXZlKGYlMjIuLiUyRmltYWdlcyUyRiU3QnByb21wdCU3RF8lN0JzZWVkJTdELnBuZyUyMik=",highlighted:`<span class="hljs-meta">>>> </span><span class="hljs-keyword">import</span> torch | |
| <span class="hljs-meta">>>> </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionAttendAndExcitePipeline | |
| <span class="hljs-meta">>>> </span>pipe = StableDiffusionAttendAndExcitePipeline.from_pretrained( | |
| <span class="hljs-meta">... </span> <span class="hljs-string">"CompVis/stable-diffusion-v1-4"</span>, torch_dtype=torch.float16 | |
| <span class="hljs-meta">... </span>).to(<span class="hljs-string">"cuda"</span>) | |
| <span class="hljs-meta">>>> </span>prompt = <span class="hljs-string">"a cat and a frog"</span> | |
| <span class="hljs-meta">>>> </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">>>> </span>pipe.get_indices(prompt) | |
| {<span class="hljs-number">0</span>: <span class="hljs-string">'<|startoftext|>'</span>, <span class="hljs-number">1</span>: <span class="hljs-string">'a</w>'</span>, <span class="hljs-number">2</span>: <span class="hljs-string">'cat</w>'</span>, <span class="hljs-number">3</span>: <span class="hljs-string">'and</w>'</span>, <span class="hljs-number">4</span>: <span class="hljs-string">'a</w>'</span>, <span class="hljs-number">5</span>: <span class="hljs-string">'frog</w>'</span>, <span class="hljs-number">6</span>: <span class="hljs-string">'<|endoftext|>'</span>} | |
| <span class="hljs-meta">>>> </span>token_indices = [<span class="hljs-number">2</span>, <span class="hljs-number">5</span>] | |
| <span class="hljs-meta">>>> </span>seed = <span class="hljs-number">6141</span> | |
| <span class="hljs-meta">>>> </span>generator = torch.Generator(<span class="hljs-string">"cuda"</span>).manual_seed(seed) | |
| <span class="hljs-meta">>>> </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">>>> </span>image = images[<span class="hljs-number">0</span>] | |
| <span class="hljs-meta">>>> </span>image.save(<span class="hljs-string">f"../images/<span class="hljs-subst">{prompt}</span>_<span class="hljs-subst">{seed}</span>.png"</span>)`,wrap:!1}}),{c(){c=r("p"),c.textContent=$,A=i(),h(g.$$.fragment)},l(f){c=l(f,"P",{"data-svelte-h":!0}),m(c)!=="svelte-kvfsh7"&&(c.textContent=$),A=s(f),_(g.$$.fragment,f)},m(f,D){o(f,c,D),o(f,A,D),b(g,f,D),u=!0},p:Fe,i(f){u||(x(g.$$.fragment,f),u=!0)},o(f){v(g.$$.fragment,f),u=!1},d(f){f&&(n(c),n(A)),y(g,f)}}}function st(se){let c,$,A,g,u,f="<p>This pipeline is deprecated but it can still be used. However, we won’t test the pipeline anymore and won’t accept any changes to it. If you run into any issues, reinstall the last Diffusers version that supported this model.</p>",D,C,oe,j,ae,I,Ie='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,Le="The abstract from the paper is:",le,U,Ue="<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,N,Ne='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>.',pe,E,Ze='<p>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-a-pipeline">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.</p>',ce,Z,fe,d,J,ye,X,Je="Pipeline for text-to-image generation using Stable Diffusion and Attend-and-Excite.",Ae,V,Be=`This model inherits from <a href="/docs/diffusers/pr_12747/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.).`,we,F,Ge="The pipeline also inherits the following loading methods:",Me,q,ze='<li><a href="/docs/diffusers/pr_12747/en/api/loaders/textual_inversion#diffusers.loaders.TextualInversionLoaderMixin.load_textual_inversion">load_textual_inversion()</a> for loading textual inversion embeddings</li>',Pe,w,B,De,Q,We="The call function to the pipeline for generation.",Ee,T,Te,S,G,Se,Y,Oe="Encodes the prompt into text encoder hidden states.",ke,k,z,$e,K,Re="Utility function to list the indices of the tokens you wish to alte",me,W,ue,M,O,Ce,ee,He="Output class for Stable Diffusion pipelines.",ge,R,he,ne,_e;return C=new Ke({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),j=new je({props:{title:"Attend-and-Excite",local:"attend-and-excite",headingTag:"h1"}}),Z=new je({props:{title:"StableDiffusionAttendAndExcitePipeline",local:"diffusers.StableDiffusionAttendAndExcitePipeline",headingTag:"h2"}}),J=new ie({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/pr_12747/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) — | |
| 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>) — | |
| 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>) — | |
| A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/pr_12747/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) — | |
| A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/pr_12747/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) — | |
| 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/pr_12747/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/pr_12747/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/pr_12747/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.safety_checker",description:`<strong>safety_checker</strong> (<code>StableDiffusionSafetyChecker</code>) — | |
| Classification module that estimates whether generated images could be considered offensive or harmful. | |
| Please refer to the <a href="https://huggingface.co/stable-diffusion-v1-5/stable-diffusion-v1-5" rel="nofollow">model card</a> for | |
| more details about a model’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>) — | |
| 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/vr_12747/src/diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L182"}}),B=new ie({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[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": int = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.Tensor] = None"},{name:"prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Optional[typing.Callable[[int, int, torch.Tensor], NoneType]] = None"},{name:"callback_steps",val:": int = 1"},{name:"cross_attention_kwargs",val:": typing.Optional[typing.Dict[str, typing.Any]] = 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)"},{name:"clip_skip",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| 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>) — | |
| 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>) — | |
| 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>) — | |
| 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) — | |
| 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) — | |
| 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 > 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>) — | |
| 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 < 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) — | |
| 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) — | |
| Corresponds to parameter eta (η) from the <a href="https://huggingface.co/papers/2010.02502" rel="nofollow">DDIM</a> paper. Only | |
| applies to the <a href="/docs/diffusers/pr_12747/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>) — | |
| 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.Tensor</code>, <em>optional</em>) — | |
| 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.Tensor</code>, <em>optional</em>) — | |
| 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.Tensor</code>, <em>optional</em>) — | |
| 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>"pil"</code>) — | |
| 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>) — | |
| Whether or not to return a <a href="/docs/diffusers/pr_12747/en/api/pipelines/stable_diffusion/depth2img#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>) — | |
| 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.Tensor)</code>.`,name:"callback"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.callback_steps",description:`<strong>callback_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 1) — | |
| 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>) — | |
| 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>) — | |
| 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) — | |
| 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) — | |
| 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>) — | |
| 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/vr_12747/src/diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L749",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script> | |
| <p>If <code>return_dict</code> is <code>True</code>, <a | |
| href="/docs/diffusers/pr_12747/en/api/pipelines/stable_diffusion/depth2img#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/pr_12747/en/api/pipelines/stable_diffusion/depth2img#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput" | |
| >StableDiffusionPipelineOutput</a> or <code>tuple</code></p> | |
| `}}),T=new tt({props:{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.__call__.example",$$slots:{default:[it]},$$scope:{ctx:se}}}),G=new ie({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.Tensor] = None"},{name:"negative_prompt_embeds",val:": typing.Optional[torch.Tensor] = None"},{name:"lora_scale",val:": typing.Optional[float] = None"},{name:"clip_skip",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) — | |
| prompt to be encoded`,name:"prompt"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.device",description:`<strong>device</strong> — (<code>torch.device</code>): | |
| torch device`,name:"device"},{anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.encode_prompt.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>) — | |
| 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>) — | |
| 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>) — | |
| 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.Tensor</code>, <em>optional</em>) — | |
| 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.Tensor</code>, <em>optional</em>) — | |
| 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>) — | |
| 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>) — | |
| 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/vr_12747/src/diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L296"}}),z=new ie({props:{name:"get_indices",anchor:"diffusers.StableDiffusionAttendAndExcitePipeline.get_indices",parameters:[{name:"prompt",val:": str"}],source:"https://github.com/huggingface/diffusers/blob/vr_12747/src/diffusers/pipelines/stable_diffusion_attend_and_excite/pipeline_stable_diffusion_attend_and_excite.py#L743"}}),W=new je({props:{title:"StableDiffusionPipelineOutput",local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",headingTag:"h2"}}),O=new ie({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>) — | |
| 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>) — | |
| List indicating whether the corresponding generated image contains “not-safe-for-work” (nsfw) content or | |
| <code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/vr_12747/src/diffusers/pipelines/stable_diffusion/pipeline_output.py#L11"}}),R=new nt({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/pipelines/attend_and_excite.md"}}),{c(){c=r("meta"),$=i(),A=r("p"),g=i(),u=r("blockquote"),u.innerHTML=f,D=i(),h(C.$$.fragment),oe=i(),h(j.$$.fragment),ae=i(),I=r("p"),I.innerHTML=Ie,re=i(),L=r("p"),L.textContent=Le,le=i(),U=r("p"),U.innerHTML=Ue,de=i(),N=r("p"),N.innerHTML=Ne,pe=i(),E=r("blockquote"),E.innerHTML=Ze,ce=i(),h(Z.$$.fragment),fe=i(),d=r("div"),h(J.$$.fragment),ye=i(),X=r("p"),X.textContent=Je,Ae=i(),V=r("p"),V.innerHTML=Be,we=i(),F=r("p"),F.textContent=Ge,Me=i(),q=r("ul"),q.innerHTML=ze,Pe=i(),w=r("div"),h(B.$$.fragment),De=i(),Q=r("p"),Q.textContent=We,Ee=i(),h(T.$$.fragment),Te=i(),S=r("div"),h(G.$$.fragment),Se=i(),Y=r("p"),Y.textContent=Oe,ke=i(),k=r("div"),h(z.$$.fragment),$e=i(),K=r("p"),K.textContent=Re,me=i(),h(W.$$.fragment),ue=i(),M=r("div"),h(O.$$.fragment),Ce=i(),ee=r("p"),ee.textContent=He,ge=i(),h(R.$$.fragment),he=i(),ne=r("p"),this.h()},l(e){const t=Ye("svelte-u9bgzb",document.head);c=l(t,"META",{name:!0,content:!0}),t.forEach(n),$=s(e),A=l(e,"P",{}),H(A).forEach(n),g=s(e),u=l(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(u)!=="svelte-124tjg"&&(u.innerHTML=f),D=s(e),_(C.$$.fragment,e),oe=s(e),_(j.$$.fragment,e),ae=s(e),I=l(e,"P",{"data-svelte-h":!0}),m(I)!=="svelte-oxdtcr"&&(I.innerHTML=Ie),re=s(e),L=l(e,"P",{"data-svelte-h":!0}),m(L)!=="svelte-1cwsb16"&&(L.textContent=Le),le=s(e),U=l(e,"P",{"data-svelte-h":!0}),m(U)!=="svelte-lkgois"&&(U.innerHTML=Ue),de=s(e),N=l(e,"P",{"data-svelte-h":!0}),m(N)!=="svelte-oxzb6"&&(N.innerHTML=Ne),pe=s(e),E=l(e,"BLOCKQUOTE",{class:!0,"data-svelte-h":!0}),m(E)!=="svelte-r1jcqf"&&(E.innerHTML=Ze),ce=s(e),_(Z.$$.fragment,e),fe=s(e),d=l(e,"DIV",{class:!0});var p=H(d);_(J.$$.fragment,p),ye=s(p),X=l(p,"P",{"data-svelte-h":!0}),m(X)!=="svelte-1t0tlj6"&&(X.textContent=Je),Ae=s(p),V=l(p,"P",{"data-svelte-h":!0}),m(V)!=="svelte-kt0ufr"&&(V.innerHTML=Be),we=s(p),F=l(p,"P",{"data-svelte-h":!0}),m(F)!=="svelte-14s6m4u"&&(F.textContent=Ge),Me=s(p),q=l(p,"UL",{"data-svelte-h":!0}),m(q)!=="svelte-9wphzh"&&(q.innerHTML=ze),Pe=s(p),w=l(p,"DIV",{class:!0});var te=H(w);_(B.$$.fragment,te),De=s(te),Q=l(te,"P",{"data-svelte-h":!0}),m(Q)!=="svelte-50j04k"&&(Q.textContent=We),Ee=s(te),_(T.$$.fragment,te),te.forEach(n),Te=s(p),S=l(p,"DIV",{class:!0});var be=H(S);_(G.$$.fragment,be),Se=s(be),Y=l(be,"P",{"data-svelte-h":!0}),m(Y)!=="svelte-16q0ax1"&&(Y.textContent=Oe),be.forEach(n),ke=s(p),k=l(p,"DIV",{class:!0});var xe=H(k);_(z.$$.fragment,xe),$e=s(xe),K=l(xe,"P",{"data-svelte-h":!0}),m(K)!=="svelte-98zxno"&&(K.textContent=Re),xe.forEach(n),p.forEach(n),me=s(e),_(W.$$.fragment,e),ue=s(e),M=l(e,"DIV",{class:!0});var ve=H(M);_(O.$$.fragment,ve),Ce=s(ve),ee=l(ve,"P",{"data-svelte-h":!0}),m(ee)!=="svelte-1qpjiuf"&&(ee.textContent=He),ve.forEach(n),ge=s(e),_(R.$$.fragment,e),he=s(e),ne=l(e,"P",{}),H(ne).forEach(n),this.h()},h(){P(c,"name","hf:doc:metadata"),P(c,"content",ot),P(u,"class","warning"),P(E,"class","tip"),P(w,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),P(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),P(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),P(d,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),P(M,"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,t){a(document.head,c),o(e,$,t),o(e,A,t),o(e,g,t),o(e,u,t),o(e,D,t),b(C,e,t),o(e,oe,t),b(j,e,t),o(e,ae,t),o(e,I,t),o(e,re,t),o(e,L,t),o(e,le,t),o(e,U,t),o(e,de,t),o(e,N,t),o(e,pe,t),o(e,E,t),o(e,ce,t),b(Z,e,t),o(e,fe,t),o(e,d,t),b(J,d,null),a(d,ye),a(d,X),a(d,Ae),a(d,V),a(d,we),a(d,F),a(d,Me),a(d,q),a(d,Pe),a(d,w),b(B,w,null),a(w,De),a(w,Q),a(w,Ee),b(T,w,null),a(d,Te),a(d,S),b(G,S,null),a(S,Se),a(S,Y),a(d,ke),a(d,k),b(z,k,null),a(k,$e),a(k,K),o(e,me,t),b(W,e,t),o(e,ue,t),o(e,M,t),b(O,M,null),a(M,Ce),a(M,ee),o(e,ge,t),b(R,e,t),o(e,he,t),o(e,ne,t),_e=!0},p(e,[t]){const p={};t&2&&(p.$$scope={dirty:t,ctx:e}),T.$set(p)},i(e){_e||(x(C.$$.fragment,e),x(j.$$.fragment,e),x(Z.$$.fragment,e),x(J.$$.fragment,e),x(B.$$.fragment,e),x(T.$$.fragment,e),x(G.$$.fragment,e),x(z.$$.fragment,e),x(W.$$.fragment,e),x(O.$$.fragment,e),x(R.$$.fragment,e),_e=!0)},o(e){v(C.$$.fragment,e),v(j.$$.fragment,e),v(Z.$$.fragment,e),v(J.$$.fragment,e),v(B.$$.fragment,e),v(T.$$.fragment,e),v(G.$$.fragment,e),v(z.$$.fragment,e),v(W.$$.fragment,e),v(O.$$.fragment,e),v(R.$$.fragment,e),_e=!1},d(e){e&&(n($),n(A),n(g),n(u),n(D),n(oe),n(ae),n(I),n(re),n(L),n(le),n(U),n(de),n(N),n(pe),n(E),n(ce),n(fe),n(d),n(me),n(ue),n(M),n(ge),n(he),n(ne)),n(c),y(C,e),y(j,e),y(Z,e),y(J),y(B),y(T),y(G),y(z),y(W,e),y(O),y(R,e)}}}const ot='{"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 at(se){return Ve(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ut extends qe{constructor(c){super(),Qe(this,c,at,st,Xe,{})}}export{ut as component}; | |
Xet Storage Details
- Size:
- 35.2 kB
- Xet hash:
- 4593348c3e9d866f81dc80c1d1e63ddc8801360c2a4dec9b890f77b5c37297fb
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.