import{S as yn,i as vn,s as wn,e as a,k as u,w as $,t as l,M as $n,c as s,d as n,m,a as o,x as U,h as r,b as p,G as e,g as _,y as T,q as J,o as M,B as D,v as Un,L as bn}from"../../../../chunks/vendor-hf-doc-builder.js";import{T as hn}from"../../../../chunks/Tip-hf-doc-builder.js";import{D as se}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as _n}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Yt}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as gn}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Tn(C){let c,y,d,f,v,i,h,V,L,A,x,Z,j,oe,G,k,ie;return{c(){c=a("p"),y=l("Make sure to check out the Stable Diffusion "),d=a("a"),f=l("Tips"),v=l(" section to learn how to explore the tradeoff between scheduler speed and quality, and how to reuse pipeline components efficiently!"),i=u(),h=a("p"),V=l("If you\u2019re interested in using one of the official checkpoints for a task, explore the "),L=a("a"),A=l("CompVis"),x=l(", "),Z=a("a"),j=l("Runway"),oe=l(", and "),G=a("a"),k=l("Stability AI"),ie=l(" Hub organizations!"),this.h()},l(P){c=s(P,"P",{});var I=o(c);y=r(I,"Make sure to check out the Stable Diffusion "),d=s(I,"A",{href:!0});var Me=o(d);f=r(Me,"Tips"),Me.forEach(n),v=r(I," section to learn how to explore the tradeoff between scheduler speed and quality, and how to reuse pipeline components efficiently!"),I.forEach(n),i=m(P),h=s(P,"P",{});var S=o(h);V=r(S,"If you\u2019re interested in using one of the official checkpoints for a task, explore the "),L=s(S,"A",{href:!0,rel:!0});var le=o(L);A=r(le,"CompVis"),le.forEach(n),x=r(S,", "),Z=s(S,"A",{href:!0,rel:!0});var W=o(Z);j=r(W,"Runway"),W.forEach(n),oe=r(S,", and "),G=s(S,"A",{href:!0,rel:!0});var re=o(G);k=r(re,"Stability AI"),re.forEach(n),ie=r(S," Hub organizations!"),S.forEach(n),this.h()},h(){p(d,"href","overview#tips"),p(L,"href","https://huggingface.co/CompVis"),p(L,"rel","nofollow"),p(Z,"href","https://huggingface.co/runwayml"),p(Z,"rel","nofollow"),p(G,"href","https://huggingface.co/stabilityai"),p(G,"rel","nofollow")},m(P,I){_(P,c,I),e(c,y),e(c,d),e(d,f),e(c,v),_(P,i,I),_(P,h,I),e(h,V),e(h,L),e(L,A),e(h,x),e(h,Z),e(Z,j),e(h,oe),e(h,G),e(G,k),e(h,ie)},d(P){P&&n(c),P&&n(i),P&&n(h)}}}function Jn(C){let c,y,d,f,v;return f=new _n({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMFN0YWJsZURpZmZ1c2lvbkxhdGVudFVwc2NhbGVQaXBlbGluZSUyQyUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEElMEFwaXBlbGluZSUyMCUzRCUyMFN0YWJsZURpZmZ1c2lvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMEElMjAlMjAlMjAlMjAlMjJDb21wVmlzJTJGc3RhYmxlLWRpZmZ1c2lvbi12MS00JTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2JTBBKSUwQXBpcGVsaW5lLnRvKCUyMmN1ZGElMjIpJTBBJTBBbW9kZWxfaWQlMjAlM0QlMjAlMjJzdGFiaWxpdHlhaSUyRnNkLXgyLWxhdGVudC11cHNjYWxlciUyMiUwQXVwc2NhbGVyJTIwJTNEJTIwU3RhYmxlRGlmZnVzaW9uTGF0ZW50VXBzY2FsZVBpcGVsaW5lLmZyb21fcHJldHJhaW5lZChtb2RlbF9pZCUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEF1cHNjYWxlci50byglMjJjdWRhJTIyKSUwQSUwQXByb21wdCUyMCUzRCUyMCUyMmElMjBwaG90byUyMG9mJTIwYW4lMjBhc3Ryb25hdXQlMjBoaWdoJTIwcmVzb2x1dGlvbiUyQyUyMHVucmVhbCUyMGVuZ2luZSUyQyUyMHVsdHJhJTIwcmVhbGlzdGljJTIyJTBBZ2VuZXJhdG9yJTIwJTNEJTIwdG9yY2gubWFudWFsX3NlZWQoMzMpJTBBJTBBbG93X3Jlc19sYXRlbnRzJTIwJTNEJTIwcGlwZWxpbmUocHJvbXB0JTJDJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTIwb3V0cHV0X3R5cGUlM0QlMjJsYXRlbnQlMjIpLmltYWdlcyUwQSUwQXdpdGglMjB0b3JjaC5ub19ncmFkKCklM0ElMEElMjAlMjAlMjAlMjBpbWFnZSUyMCUzRCUyMHBpcGVsaW5lLmRlY29kZV9sYXRlbnRzKGxvd19yZXNfbGF0ZW50cyklMEFpbWFnZSUyMCUzRCUyMHBpcGVsaW5lLm51bXB5X3RvX3BpbChpbWFnZSklNUIwJTVEJTBBJTBBaW1hZ2Uuc2F2ZSglMjIuLiUyRmltYWdlcyUyRmExLnBuZyUyMiklMEElMEF1cHNjYWxlZF9pbWFnZSUyMCUzRCUyMHVwc2NhbGVyKCUwQSUyMCUyMCUyMCUyMHByb21wdCUzRHByb21wdCUyQyUwQSUyMCUyMCUyMCUyMGltYWdlJTNEbG93X3Jlc19sYXRlbnRzJTJDJTBBJTIwJTIwJTIwJTIwbnVtX2luZmVyZW5jZV9zdGVwcyUzRDIwJTJDJTBBJTIwJTIwJTIwJTIwZ3VpZGFuY2Vfc2NhbGUlM0QwJTJDJTBBJTIwJTIwJTIwJTIwZ2VuZXJhdG9yJTNEZ2VuZXJhdG9yJTJDJTBBKS5pbWFnZXMlNUIwJTVEJTBBJTBBdXBzY2FsZWRfaW1hZ2Uuc2F2ZSglMjIuLiUyRmltYWdlcyUyRmEyLnBuZyUyMik=",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionLatentUpscalePipeline, StableDiffusionPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> torch


<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionPipeline.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>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>model_id = <span class="hljs-string">&quot;stabilityai/sd-x2-latent-upscaler&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>upscaler.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;a photo of an astronaut high resolution, unreal engine, ultra realistic&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>generator = torch.manual_seed(<span class="hljs-number">33</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>low_res_latents = pipeline(prompt, generator=generator, output_type=<span class="hljs-string">&quot;latent&quot;</span>).images

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">with</span> torch.no_grad():
<span class="hljs-meta">... </span>    image = pipeline.decode_latents(low_res_latents)
<span class="hljs-meta">&gt;&gt;&gt; </span>image = pipeline.numpy_to_pil(image)[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>image.save(<span class="hljs-string">&quot;../images/a1.png&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span>upscaled_image = upscaler(
<span class="hljs-meta">... </span>    prompt=prompt,
<span class="hljs-meta">... </span>    image=low_res_latents,
<span class="hljs-meta">... </span>    num_inference_steps=<span class="hljs-number">20</span>,
<span class="hljs-meta">... </span>    guidance_scale=<span class="hljs-number">0</span>,
<span class="hljs-meta">... </span>    generator=generator,
<span class="hljs-meta">... </span>).images[<span class="hljs-number">0</span>]

<span class="hljs-meta">&gt;&gt;&gt; </span>upscaled_image.save(<span class="hljs-string">&quot;../images/a2.png&quot;</span>)`}}),{c(){c=a("p"),y=l("Examples:"),d=u(),$(f.$$.fragment)},l(i){c=s(i,"P",{});var h=o(c);y=r(h,"Examples:"),h.forEach(n),d=m(i),U(f.$$.fragment,i)},m(i,h){_(i,c,h),e(c,y),_(i,d,h),T(f,i,h),v=!0},p:bn,i(i){v||(J(f.$$.fragment,i),v=!0)},o(i){M(f.$$.fragment,i),v=!1},d(i){i&&n(c),i&&n(d),D(f,i)}}}function Mn(C){let c,y;return{c(){c=a("p"),y=l(`\u26A0\uFE0F When memory efficient attention and sliced attention are both enabled, memory efficient attention takes
precedent.`)},l(d){c=s(d,"P",{});var f=o(c);y=r(f,`\u26A0\uFE0F When memory efficient attention and sliced attention are both enabled, memory efficient attention takes
precedent.`),f.forEach(n)},m(d,f){_(d,c,f),e(c,y)},d(d){d&&n(c)}}}function Dn(C){let c,y,d,f,v;return f=new _n({props:{code:"aW1wb3J0JTIwdG9yY2glMEFmcm9tJTIwZGlmZnVzZXJzJTIwaW1wb3J0JTIwRGlmZnVzaW9uUGlwZWxpbmUlMEFmcm9tJTIweGZvcm1lcnMub3BzJTIwaW1wb3J0JTIwTWVtb3J5RWZmaWNpZW50QXR0ZW50aW9uRmxhc2hBdHRlbnRpb25PcCUwQSUwQXBpcGUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIyc3RhYmlsaXR5YWklMkZzdGFibGUtZGlmZnVzaW9uLTItMSUyMiUyQyUyMHRvcmNoX2R0eXBlJTNEdG9yY2guZmxvYXQxNiklMEFwaXBlJTIwJTNEJTIwcGlwZS50byglMjJjdWRhJTIyKSUwQXBpcGUuZW5hYmxlX3hmb3JtZXJzX21lbW9yeV9lZmZpY2llbnRfYXR0ZW50aW9uKGF0dGVudGlvbl9vcCUzRE1lbW9yeUVmZmljaWVudEF0dGVudGlvbkZsYXNoQXR0ZW50aW9uT3ApJTBBJTIzJTIwV29ya2Fyb3VuZCUyMGZvciUyMG5vdCUyMGFjY2VwdGluZyUyMGF0dGVudGlvbiUyMHNoYXBlJTIwdXNpbmclMjBWQUUlMjBmb3IlMjBGbGFzaCUyMEF0dGVudGlvbiUwQXBpcGUudmFlLmVuYWJsZV94Zm9ybWVyc19tZW1vcnlfZWZmaWNpZW50X2F0dGVudGlvbihhdHRlbnRpb25fb3AlM0ROb25lKQ==",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> DiffusionPipeline
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> xformers.ops <span class="hljs-keyword">import</span> MemoryEfficientAttentionFlashAttentionOp

<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;stabilityai/stable-diffusion-2-1&quot;</span>, torch_dtype=torch.float16)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe = pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># Workaround for not accepting attention shape using VAE for Flash Attention</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipe.vae.enable_xformers_memory_efficient_attention(attention_op=<span class="hljs-literal">None</span>)`}}),{c(){c=a("p"),y=l("Examples:"),d=u(),$(f.$$.fragment)},l(i){c=s(i,"P",{});var h=o(c);y=r(h,"Examples:"),h.forEach(n),d=m(i),U(f.$$.fragment,i)},m(i,h){_(i,c,h),e(c,y),_(i,d,h),T(f,i,h),v=!0},p:bn,i(i){v||(J(f.$$.fragment,i),v=!0)},o(i){M(f.$$.fragment,i),v=!1},d(i){i&&n(c),i&&n(d),D(f,i)}}}function xn(C){let c,y,d,f,v,i,h,V,L,A,x,Z,j,oe,G,k,ie,P,I,Me,S,le,W,re,N,z,Pe,pe,ot,Se,it,Fe,b,ce,lt,Ee,rt,pt,fe,ct,De,ft,dt,ut,B,de,mt,Le,ht,gt,Y,bt,q,ue,_t,R,yt,Ze,vt,wt,je,$t,Ut,Tt,Q,me,Jt,Ge,Mt,Dt,O,he,xt,ge,It,ke,Pt,St,Et,E,be,Lt,_e,Zt,ye,jt,Gt,kt,H,Wt,K,Ct,ee,ve,Bt,we,Vt,$e,Nt,Rt,Xe,F,te,We,Ue,Ft,Ce,Xt,Ae,X,Te,At,Be,zt,ze;return i=new Yt({}),W=new hn({props:{$$slots:{default:[Tn]},$$scope:{ctx:C}}}),pe=new Yt({}),ce=new se({props:{name:"class diffusers.StableDiffusionLatentUpscalePipeline",anchor:"diffusers.StableDiffusionLatentUpscalePipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"scheduler",val:": EulerDiscreteScheduler"}],parametersDescription:[{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/v0.19.2/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.StableDiffusionLatentUpscalePipeline.text_encoder",description:`<strong>text_encoder</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIPTextModel</a>) &#x2014;
Frozen text-encoder (<a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a>).`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/v4.31.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>) &#x2014;
A <code>CLIPTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.19.2/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.19.2/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A <a href="/docs/diffusers/v0.19.2/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a> to be used in combination with <code>unet</code> to denoise the encoded image latents.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py#L61"}}),de=new se({props:{name:"__call__",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image, numpy.ndarray, typing.List[torch.FloatTensor], typing.List[PIL.Image.Image], typing.List[numpy.ndarray]] = None"},{name:"num_inference_steps",val:": int = 75"},{name:"guidance_scale",val:": float = 9.0"},{name:"negative_prompt",val:": typing.Union[typing.List[str], str, NoneType] = None"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"callback",val:": typing.Union[typing.Callable[[int, int, torch.FloatTensor], NoneType], NoneType] = None"},{name:"callback_steps",val:": int = 1"}],parametersDescription:[{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The prompt or prompts to guide image upscaling.`,name:"prompt"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__call__.image",description:`<strong>image</strong> (<code>torch.FloatTensor</code>, <code>PIL.Image.Image</code>, <code>np.ndarray</code>, <code>List[torch.FloatTensor]</code>, <code>List[PIL.Image.Image]</code>, or <code>List[np.ndarray]</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to be upscaled. If it&#x2019;s a tensor, it can be either a
latent output from a Stable Diffusion model or an image tensor in the range <code>[-1, 1]</code>. It is considered
a <code>latent</code> if <code>image.shape[1]</code> is <code>4</code>; otherwise, it is considered to be an image representation and
encoded using this pipeline&#x2019;s <code>vae</code> encoder.`,name:"image"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/v0.19.2/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/v0.19.2/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__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.StableDiffusionLatentUpscalePipeline.__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"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py#L256",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.19.2/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> is returned,
otherwise a <code>tuple</code> is returned where the first element is a list with the generated images.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.19.2/en/api/pipelines/stable_diffusion/inpaint#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),Y=new gn({props:{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__call__.example",$$slots:{default:[Jn]},$$scope:{ctx:C}}}),ue=new se({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:": int = 0"},{name:"device",val:": typing.Union[torch.device, str] = 'cuda'"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/pipeline_utils.py#L1178"}}),me=new se({props:{name:"enable_attention_slicing",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_attention_slicing",parameters:[{name:"slice_size",val:": typing.Union[str, int, NoneType] = 'auto'"}],parametersDescription:[{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_attention_slicing.slice_size",description:`<strong>slice_size</strong> (<code>str</code> or <code>int</code>, <em>optional</em>, defaults to <code>&quot;auto&quot;</code>) &#x2014;
When <code>&quot;auto&quot;</code>, halves the input to the attention heads, so attention will be computed in two steps. If
<code>&quot;max&quot;</code>, maximum amount of memory will be saved by running only one slice at a time. If a number is
provided, uses as many slices as <code>attention_head_dim // slice_size</code>. In this case, <code>attention_head_dim</code>
must be a multiple of <code>slice_size</code>.`,name:"slice_size"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/pipeline_utils.py#L1669"}}),he=new se({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/pipeline_utils.py#L1684"}}),be=new se({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_xformers_memory_efficient_attention",parameters:[{name:"attention_op",val:": typing.Optional[typing.Callable] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_xformers_memory_efficient_attention.attention_op",description:`<strong>attention_op</strong> (<code>Callable</code>, <em>optional</em>) &#x2014;
Override the default <code>None</code> operator for use as <code>op</code> argument to the
<a href="https://facebookresearch.github.io/xformers/components/ops.html#xformers.ops.memory_efficient_attention" rel="nofollow"><code>memory_efficient_attention()</code></a>
function of xFormers.`,name:"attention_op"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/pipeline_utils.py#L1608"}}),H=new hn({props:{warning:!0,$$slots:{default:[Mn]},$$scope:{ctx:C}}}),K=new gn({props:{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[Dn]},$$scope:{ctx:C}}}),ve=new se({props:{name:"disable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.disable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/pipeline_utils.py#L1643"}}),Ue=new Yt({}),Te=new se({props:{name:"class diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"},{name:"nsfw_content_detected",val:": typing.Optional[typing.List[bool]]"}],parametersDescription:[{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"},{anchor:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput.nsfw_content_detected",description:`<strong>nsfw_content_detected</strong> (<code>List[bool]</code>) &#x2014;
List indicating whether the corresponding generated image contains &#x201C;not-safe-for-work&#x201D; (nsfw) content or
<code>None</code> if safety checking could not be performed.`,name:"nsfw_content_detected"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/pipelines/stable_diffusion/__init__.py#L22"}}),{c(){c=a("meta"),y=u(),d=a("h1"),f=a("a"),v=a("span"),$(i.$$.fragment),h=u(),V=a("span"),L=l("Latent upscaler"),A=u(),x=a("p"),Z=l("The Stable Diffusion latent upscaler model was created by "),j=a("a"),oe=l("Katherine Crowson"),G=l(" in collaboration with "),k=a("a"),ie=l("Stability AI"),P=l(". It is used to enhance the output image resolution by a factor of 2 (see this demo "),I=a("a"),Me=l("notebook"),S=l(" for a demonstration of the original implementation)."),le=u(),$(W.$$.fragment),re=u(),N=a("h2"),z=a("a"),Pe=a("span"),$(pe.$$.fragment),ot=u(),Se=a("span"),it=l("StableDiffusionLatentUpscalePipeline"),Fe=u(),b=a("div"),$(ce.$$.fragment),lt=u(),Ee=a("p"),rt=l("Pipeline for upscaling Stable Diffusion output image resolution by a factor of 2."),pt=u(),fe=a("p"),ct=l("This model inherits from "),De=a("a"),ft=l("DiffusionPipeline"),dt=l(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),ut=u(),B=a("div"),$(de.$$.fragment),mt=u(),Le=a("p"),ht=l("The call function to the pipeline for generation."),gt=u(),$(Y.$$.fragment),bt=u(),q=a("div"),$(ue.$$.fragment),_t=u(),R=a("p"),yt=l(`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Ze=a("code"),vt=l("torch.device('meta') and loaded to GPU only when their specific submodule has its "),wt=l("forward"),je=a("code"),$t=l("method called. Note that offloading happens on a submodule basis. Memory savings are higher than with"),Ut=l("enable_model_cpu_offload`, but performance is lower."),Tt=u(),Q=a("div"),$(me.$$.fragment),Jt=u(),Ge=a("p"),Mt=l(`Enable sliced attention computation. When this option is enabled, the attention module splits the input tensor
in slices to compute attention in several steps. This is useful to save some memory in exchange for a small
speed decrease.`),Dt=u(),O=a("div"),$(he.$$.fragment),xt=u(),ge=a("p"),It=l("Disable sliced attention computation. If "),ke=a("code"),Pt=l("enable_attention_slicing"),St=l(` was previously called, attention is
computed in one step.`),Et=u(),E=a("div"),$(be.$$.fragment),Lt=u(),_e=a("p"),Zt=l("Enable memory efficient attention from "),ye=a("a"),jt=l("xFormers"),Gt=l(`. When this
option is enabled, you should observe lower GPU memory usage and a potential speed up during inference. Speed
up during training is not guaranteed.`),kt=u(),$(H.$$.fragment),Wt=u(),$(K.$$.fragment),Ct=u(),ee=a("div"),$(ve.$$.fragment),Bt=u(),we=a("p"),Vt=l("Disable memory efficient attention from "),$e=a("a"),Nt=l("xFormers"),Rt=l("."),Xe=u(),F=a("h2"),te=a("a"),We=a("span"),$(Ue.$$.fragment),Ft=u(),Ce=a("span"),Xt=l("StableDiffusionPipelineOutput"),Ae=u(),X=a("div"),$(Te.$$.fragment),At=u(),Be=a("p"),zt=l("Output class for Stable Diffusion pipelines."),this.h()},l(t){const g=$n('[data-svelte="svelte-1phssyn"]',document.head);c=s(g,"META",{name:!0,content:!0}),g.forEach(n),y=m(t),d=s(t,"H1",{class:!0});var Je=o(d);f=s(Je,"A",{id:!0,class:!0,href:!0});var Ve=o(f);v=s(Ve,"SPAN",{});var Ne=o(v);U(i.$$.fragment,Ne),Ne.forEach(n),Ve.forEach(n),h=m(Je),V=s(Je,"SPAN",{});var Re=o(V);L=r(Re,"Latent upscaler"),Re.forEach(n),Je.forEach(n),A=m(t),x=s(t,"P",{});var ne=o(x);Z=r(ne,"The Stable Diffusion latent upscaler model was created by "),j=s(ne,"A",{href:!0,rel:!0});var qt=o(j);oe=r(qt,"Katherine Crowson"),qt.forEach(n),G=r(ne," in collaboration with "),k=s(ne,"A",{href:!0,rel:!0});var Qt=o(k);ie=r(Qt,"Stability AI"),Qt.forEach(n),P=r(ne,". It is used to enhance the output image resolution by a factor of 2 (see this demo "),I=s(ne,"A",{href:!0,rel:!0});var Ot=o(I);Me=r(Ot,"notebook"),Ot.forEach(n),S=r(ne," for a demonstration of the original implementation)."),ne.forEach(n),le=m(t),U(W.$$.fragment,t),re=m(t),N=s(t,"H2",{class:!0});var Ye=o(N);z=s(Ye,"A",{id:!0,class:!0,href:!0});var Ht=o(z);Pe=s(Ht,"SPAN",{});var Kt=o(Pe);U(pe.$$.fragment,Kt),Kt.forEach(n),Ht.forEach(n),ot=m(Ye),Se=s(Ye,"SPAN",{});var en=o(Se);it=r(en,"StableDiffusionLatentUpscalePipeline"),en.forEach(n),Ye.forEach(n),Fe=m(t),b=s(t,"DIV",{class:!0});var w=o(b);U(ce.$$.fragment,w),lt=m(w),Ee=s(w,"P",{});var tn=o(Ee);rt=r(tn,"Pipeline for upscaling Stable Diffusion output image resolution by a factor of 2."),tn.forEach(n),pt=m(w),fe=s(w,"P",{});var qe=o(fe);ct=r(qe,"This model inherits from "),De=s(qe,"A",{href:!0});var nn=o(De);ft=r(nn,"DiffusionPipeline"),nn.forEach(n),dt=r(qe,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),qe.forEach(n),ut=m(w),B=s(w,"DIV",{class:!0});var xe=o(B);U(de.$$.fragment,xe),mt=m(xe),Le=s(xe,"P",{});var an=o(Le);ht=r(an,"The call function to the pipeline for generation."),an.forEach(n),gt=m(xe),U(Y.$$.fragment,xe),xe.forEach(n),bt=m(w),q=s(w,"DIV",{class:!0});var Qe=o(q);U(ue.$$.fragment,Qe),_t=m(Qe),R=s(Qe,"P",{});var Ie=o(R);yt=r(Ie,`Offloads all models to CPU using accelerate, significantly reducing memory usage. When called, unet,
text_encoder, vae and safety checker have their state dicts saved to CPU and then are moved to a
`),Ze=s(Ie,"CODE",{});var sn=o(Ze);vt=r(sn,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),sn.forEach(n),wt=r(Ie,"forward"),je=s(Ie,"CODE",{});var on=o(je);$t=r(on,"method called. Note that offloading happens on a submodule basis. Memory savings are higher than with"),on.forEach(n),Ut=r(Ie,"enable_model_cpu_offload`, but performance is lower."),Ie.forEach(n),Qe.forEach(n),Tt=m(w),Q=s(w,"DIV",{class:!0});var Oe=o(Q);U(me.$$.fragment,Oe),Jt=m(Oe),Ge=s(Oe,"P",{});var ln=o(Ge);Mt=r(ln,`Enable sliced attention computation. When this option is enabled, the attention module splits the input tensor
in slices to compute attention in several steps. This is useful to save some memory in exchange for a small
speed decrease.`),ln.forEach(n),Oe.forEach(n),Dt=m(w),O=s(w,"DIV",{class:!0});var He=o(O);U(he.$$.fragment,He),xt=m(He),ge=s(He,"P",{});var Ke=o(ge);It=r(Ke,"Disable sliced attention computation. If "),ke=s(Ke,"CODE",{});var rn=o(ke);Pt=r(rn,"enable_attention_slicing"),rn.forEach(n),St=r(Ke,` was previously called, attention is
computed in one step.`),Ke.forEach(n),He.forEach(n),Et=m(w),E=s(w,"DIV",{class:!0});var ae=o(E);U(be.$$.fragment,ae),Lt=m(ae),_e=s(ae,"P",{});var et=o(_e);Zt=r(et,"Enable memory efficient attention from "),ye=s(et,"A",{href:!0,rel:!0});var pn=o(ye);jt=r(pn,"xFormers"),pn.forEach(n),Gt=r(et,`. When this
option is enabled, you should observe lower GPU memory usage and a potential speed up during inference. Speed
up during training is not guaranteed.`),et.forEach(n),kt=m(ae),U(H.$$.fragment,ae),Wt=m(ae),U(K.$$.fragment,ae),ae.forEach(n),Ct=m(w),ee=s(w,"DIV",{class:!0});var tt=o(ee);U(ve.$$.fragment,tt),Bt=m(tt),we=s(tt,"P",{});var nt=o(we);Vt=r(nt,"Disable memory efficient attention from "),$e=s(nt,"A",{href:!0,rel:!0});var cn=o($e);Nt=r(cn,"xFormers"),cn.forEach(n),Rt=r(nt,"."),nt.forEach(n),tt.forEach(n),w.forEach(n),Xe=m(t),F=s(t,"H2",{class:!0});var at=o(F);te=s(at,"A",{id:!0,class:!0,href:!0});var fn=o(te);We=s(fn,"SPAN",{});var dn=o(We);U(Ue.$$.fragment,dn),dn.forEach(n),fn.forEach(n),Ft=m(at),Ce=s(at,"SPAN",{});var un=o(Ce);Xt=r(un,"StableDiffusionPipelineOutput"),un.forEach(n),at.forEach(n),Ae=m(t),X=s(t,"DIV",{class:!0});var st=o(X);U(Te.$$.fragment,st),At=m(st),Be=s(st,"P",{});var mn=o(Be);zt=r(mn,"Output class for Stable Diffusion pipelines."),mn.forEach(n),st.forEach(n),this.h()},h(){p(c,"name","hf:doc:metadata"),p(c,"content",JSON.stringify(In)),p(f,"id","latent-upscaler"),p(f,"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"),p(f,"href","#latent-upscaler"),p(d,"class","relative group"),p(j,"href","https://github.com/crowsonkb/k-diffusion"),p(j,"rel","nofollow"),p(k,"href","https://stability.ai/"),p(k,"rel","nofollow"),p(I,"href","https://colab.research.google.com/drive/1o1qYJcFeywzCIdkfKJy7cTpgZTCM2EI4"),p(I,"rel","nofollow"),p(z,"id","diffusers.StableDiffusionLatentUpscalePipeline"),p(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"),p(z,"href","#diffusers.StableDiffusionLatentUpscalePipeline"),p(N,"class","relative group"),p(De,"href","/docs/diffusers/v0.19.2/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(B,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(Q,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(ye,"href","https://facebookresearch.github.io/xformers/"),p(ye,"rel","nofollow"),p(E,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p($e,"href","https://facebookresearch.github.io/xformers/"),p($e,"rel","nofollow"),p(ee,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(b,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(te,"id","diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),p(te,"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"),p(te,"href","#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"),p(F,"class","relative group"),p(X,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,g){e(document.head,c),_(t,y,g),_(t,d,g),e(d,f),e(f,v),T(i,v,null),e(d,h),e(d,V),e(V,L),_(t,A,g),_(t,x,g),e(x,Z),e(x,j),e(j,oe),e(x,G),e(x,k),e(k,ie),e(x,P),e(x,I),e(I,Me),e(x,S),_(t,le,g),T(W,t,g),_(t,re,g),_(t,N,g),e(N,z),e(z,Pe),T(pe,Pe,null),e(N,ot),e(N,Se),e(Se,it),_(t,Fe,g),_(t,b,g),T(ce,b,null),e(b,lt),e(b,Ee),e(Ee,rt),e(b,pt),e(b,fe),e(fe,ct),e(fe,De),e(De,ft),e(fe,dt),e(b,ut),e(b,B),T(de,B,null),e(B,mt),e(B,Le),e(Le,ht),e(B,gt),T(Y,B,null),e(b,bt),e(b,q),T(ue,q,null),e(q,_t),e(q,R),e(R,yt),e(R,Ze),e(Ze,vt),e(R,wt),e(R,je),e(je,$t),e(R,Ut),e(b,Tt),e(b,Q),T(me,Q,null),e(Q,Jt),e(Q,Ge),e(Ge,Mt),e(b,Dt),e(b,O),T(he,O,null),e(O,xt),e(O,ge),e(ge,It),e(ge,ke),e(ke,Pt),e(ge,St),e(b,Et),e(b,E),T(be,E,null),e(E,Lt),e(E,_e),e(_e,Zt),e(_e,ye),e(ye,jt),e(_e,Gt),e(E,kt),T(H,E,null),e(E,Wt),T(K,E,null),e(b,Ct),e(b,ee),T(ve,ee,null),e(ee,Bt),e(ee,we),e(we,Vt),e(we,$e),e($e,Nt),e(we,Rt),_(t,Xe,g),_(t,F,g),e(F,te),e(te,We),T(Ue,We,null),e(F,Ft),e(F,Ce),e(Ce,Xt),_(t,Ae,g),_(t,X,g),T(Te,X,null),e(X,At),e(X,Be),e(Be,zt),ze=!0},p(t,[g]){const Je={};g&2&&(Je.$$scope={dirty:g,ctx:t}),W.$set(Je);const Ve={};g&2&&(Ve.$$scope={dirty:g,ctx:t}),Y.$set(Ve);const Ne={};g&2&&(Ne.$$scope={dirty:g,ctx:t}),H.$set(Ne);const Re={};g&2&&(Re.$$scope={dirty:g,ctx:t}),K.$set(Re)},i(t){ze||(J(i.$$.fragment,t),J(W.$$.fragment,t),J(pe.$$.fragment,t),J(ce.$$.fragment,t),J(de.$$.fragment,t),J(Y.$$.fragment,t),J(ue.$$.fragment,t),J(me.$$.fragment,t),J(he.$$.fragment,t),J(be.$$.fragment,t),J(H.$$.fragment,t),J(K.$$.fragment,t),J(ve.$$.fragment,t),J(Ue.$$.fragment,t),J(Te.$$.fragment,t),ze=!0)},o(t){M(i.$$.fragment,t),M(W.$$.fragment,t),M(pe.$$.fragment,t),M(ce.$$.fragment,t),M(de.$$.fragment,t),M(Y.$$.fragment,t),M(ue.$$.fragment,t),M(me.$$.fragment,t),M(he.$$.fragment,t),M(be.$$.fragment,t),M(H.$$.fragment,t),M(K.$$.fragment,t),M(ve.$$.fragment,t),M(Ue.$$.fragment,t),M(Te.$$.fragment,t),ze=!1},d(t){n(c),t&&n(y),t&&n(d),D(i),t&&n(A),t&&n(x),t&&n(le),D(W,t),t&&n(re),t&&n(N),D(pe),t&&n(Fe),t&&n(b),D(ce),D(de),D(Y),D(ue),D(me),D(he),D(be),D(H),D(K),D(ve),t&&n(Xe),t&&n(F),D(Ue),t&&n(Ae),t&&n(X),D(Te)}}}const In={local:"latent-upscaler",sections:[{local:"diffusers.StableDiffusionLatentUpscalePipeline",title:"StableDiffusionLatentUpscalePipeline"},{local:"diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput",title:"StableDiffusionPipelineOutput"}],title:"Latent upscaler"};function Pn(C){return Un(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class kn extends yn{constructor(c){super();vn(this,c,Pn,xn,wn,{})}}export{kn as default,In as metadata};
