import{S as xa,i as Da,s as Ea,e as n,k as p,w as $,t as l,M as Ia,c as s,d as a,m as f,a as o,x as T,h as r,b as c,G as e,g as b,y as J,q as M,o as x,B as D,v as Pa,L as Ja}from"../../../../chunks/vendor-hf-doc-builder.js";import{T as Sa}from"../../../../chunks/Tip-hf-doc-builder.js";import{D as pe}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as Ma}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as $a}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ta}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function La(Z){let d,v,h,u,w;return u=new Ma({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(){d=n("p"),v=l("Examples:"),h=p(),$(u.$$.fragment)},l(i){d=s(i,"P",{});var y=o(d);v=r(y,"Examples:"),y.forEach(a),h=f(i),T(u.$$.fragment,i)},m(i,y){b(i,d,y),e(d,v),b(i,h,y),J(u,i,y),w=!0},p:Ja,i(i){w||(M(u.$$.fragment,i),w=!0)},o(i){x(u.$$.fragment,i),w=!1},d(i){i&&a(d),i&&a(h),D(u,i)}}}function Za(Z){let d,v;return{c(){d=n("p"),v=l(`\u26A0\uFE0F When memory efficient attention and sliced attention are both enabled, memory efficient attention takes
precedent.`)},l(h){d=s(h,"P",{});var u=o(d);v=r(u,`\u26A0\uFE0F When memory efficient attention and sliced attention are both enabled, memory efficient attention takes
precedent.`),u.forEach(a)},m(h,u){b(h,d,u),e(d,v)},d(h){h&&a(d)}}}function ja(Z){let d,v,h,u,w;return u=new Ma({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(){d=n("p"),v=l("Examples:"),h=p(),$(u.$$.fragment)},l(i){d=s(i,"P",{});var y=o(d);v=r(y,"Examples:"),y.forEach(a),h=f(i),T(u.$$.fragment,i)},m(i,y){b(i,d,y),e(d,v),b(i,h,y),J(u,i,y),w=!0},p:Ja,i(i){w||(M(u.$$.fragment,i),w=!0)},o(i){x(u.$$.fragment,i),w=!1},d(i){i&&a(d),i&&a(h),D(u,i)}}}function Ga(Z){let d,v,h,u,w,i,y,ye,He,Le,L,j,ve,R,Oe,we,Ke,Ze,E,et,N,tt,at,X,nt,st,fe,ot,it,je,de,lt,Ge,ue,Ue,z,rt,ke,me,ct,We,he,A,$e,pt,ft,Y,dt,Ce,g,q,ut,Te,mt,ht,Q,gt,ge,bt,_t,yt,I,H,vt,Je,wt,Ut,G,$t,k,O,Tt,K,Jt,Me,Mt,xt,Dt,P,ee,Et,xe,It,Pt,De,St,Lt,W,te,Zt,ae,jt,Ee,Gt,kt,Wt,U,ne,Ct,se,Bt,oe,Vt,Ft,Rt,Ie,Nt,Xt,C,zt,B,At,V,ie,Yt,le,qt,re,Qt,Ht,Be;return i=new $a({}),R=new $a({}),q=new pe({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.18.0/en/api/models/autoencoderkl#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.text_encoder",description:`<strong>text_encoder</strong> (<code>CLIPTextModel</code>) &#x2014;
Frozen text-encoder. Stable Diffusion uses the text portion of
<a href="https://huggingface.co/docs/transformers/model_doc/clip#transformers.CLIPTextModel" rel="nofollow">CLIP</a>, specifically
the <a href="https://huggingface.co/openai/clip-vit-large-patch14" rel="nofollow">clip-vit-large-patch14</a> variant.`,name:"text_encoder"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/main/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/v0.18.0/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.18.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/v0.18.0/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py#L61"}}),H=new pe({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 the 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 which will 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
will be considered a <code>latent</code> if <code>image.shape[1]</code> is <code>4</code>; otherwise, it will be 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;
Guidance scale as defined in <a href="https://arxiv.org/abs/2207.12598" rel="nofollow">Classifier-Free Diffusion Guidance</a>.
<code>guidance_scale</code> is defined as <code>w</code> of equation 2. of <a href="https://arxiv.org/pdf/2205.11487.pdf" rel="nofollow">Imagen
Paper</a>. Guidance scale is enabled by setting <code>guidance_scale &gt; 1</code>. Higher guidance scale encourages to generate images that are closely linked to the text <code>prompt</code>,
usually at the expense of lower image quality.`,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 not to guide the image generation. Ignored when not using guidance (i.e., ignored
if <code>guidance_scale</code> is less than <code>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;) in the DDIM paper: <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">https://arxiv.org/abs/2010.02502</a>. Only applies to
<a href="/docs/diffusers/v0.18.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
One or a list of <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow">torch generator(s)</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 will ge 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 generate image. Choose between
<a href="https://pillow.readthedocs.io/en/stable/" rel="nofollow">PIL</a>: <code>PIL.Image.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.18.0/en/api/pipelines/stable_diffusion/overview#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 will be called every <code>callback_steps</code> steps during inference. The function will be
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 will be called. If not specified, the callback will be
called at every step.`,name:"callback_steps"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py#L295",returnDescription:`
<p><a
  href="/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> if <code>return_dict</code> is True, otherwise a <code>tuple. When returning a tuple, the first element is a list with the generated images, and the second element is a list of </code>bool<code>s denoting whether the corresponding generated image likely represents "not-safe-for-work" (nsfw) content, according to the </code>safety_checker\`.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),G=new Ta({props:{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.__call__.example",$$slots:{default:[La]},$$scope:{ctx:Z}}}),O=new pe({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_latent_upscale.py#L104"}}),ee=new pe({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.18.0/src/diffusers/pipelines/pipeline_utils.py#L1461"}}),te=new pe({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/pipeline_utils.py#L1477"}}),ne=new pe({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.18.0/src/diffusers/pipelines/pipeline_utils.py#L1399"}}),C=new Sa({props:{warning:!0,$$slots:{default:[Za]},$$scope:{ctx:Z}}}),B=new Ta({props:{anchor:"diffusers.StableDiffusionLatentUpscalePipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[ja]},$$scope:{ctx:Z}}}),ie=new pe({props:{name:"disable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionLatentUpscalePipeline.disable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.18.0/src/diffusers/pipelines/pipeline_utils.py#L1435"}}),{c(){d=n("meta"),v=p(),h=n("h1"),u=n("a"),w=n("span"),$(i.$$.fragment),y=p(),ye=n("span"),He=l("Stable Diffusion Latent Upscaler"),Le=p(),L=n("h2"),j=n("a"),ve=n("span"),$(R.$$.fragment),Oe=p(),we=n("span"),Ke=l("StableDiffusionLatentUpscalePipeline"),Ze=p(),E=n("p"),et=l("The Stable Diffusion Latent Upscaler model was created by "),N=n("a"),tt=l("Katherine Crowson"),at=l(" in collaboration with "),X=n("a"),nt=l("Stability AI"),st=l(". It can be used on top of any "),fe=n("a"),ot=l("StableDiffusionUpscalePipeline"),it=l(" checkpoint to enhance its output image resolution by a factor of 2."),je=p(),de=n("p"),lt=l("A notebook that demonstrates the original implementation can be found here:"),Ge=p(),ue=n("ul"),Ue=n("li"),z=n("a"),rt=l("Stable Diffusion Upscaler Demo"),ke=p(),me=n("p"),ct=l("Available Checkpoints are:"),We=p(),he=n("ul"),A=n("li"),$e=n("em"),pt=l("stabilityai/latent-upscaler"),ft=l(": "),Y=n("a"),dt=l("stabilityai/sd-x2-latent-upscaler"),Ce=p(),g=n("div"),$(q.$$.fragment),ut=p(),Te=n("p"),mt=l("Pipeline to upscale the resolution of Stable Diffusion output images by a factor of 2."),ht=p(),Q=n("p"),gt=l("This model inherits from "),ge=n("a"),bt=l("DiffusionPipeline"),_t=l(`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),yt=p(),I=n("div"),$(H.$$.fragment),vt=p(),Je=n("p"),wt=l("Function invoked when calling the pipeline for generation."),Ut=p(),$(G.$$.fragment),$t=p(),k=n("div"),$(O.$$.fragment),Tt=p(),K=n("p"),Jt=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
`),Me=n("code"),Mt=l("torch.device('meta') and loaded to GPU only when their specific submodule has its "),xt=l("forward` method called."),Dt=p(),P=n("div"),$(ee.$$.fragment),Et=p(),xe=n("p"),It=l("Enable sliced attention computation."),Pt=p(),De=n("p"),St=l(`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.`),Lt=p(),W=n("div"),$(te.$$.fragment),Zt=p(),ae=n("p"),jt=l("Disable sliced attention computation. If "),Ee=n("code"),Gt=l("enable_attention_slicing"),kt=l(` was previously called, attention is
computed in one step.`),Wt=p(),U=n("div"),$(ne.$$.fragment),Ct=p(),se=n("p"),Bt=l("Enable memory efficient attention from "),oe=n("a"),Vt=l("xFormers"),Ft=l("."),Rt=p(),Ie=n("p"),Nt=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.`),Xt=p(),$(C.$$.fragment),zt=p(),$(B.$$.fragment),At=p(),V=n("div"),$(ie.$$.fragment),Yt=p(),le=n("p"),qt=l("Disable memory efficient attention from "),re=n("a"),Qt=l("xFormers"),Ht=l("."),this.h()},l(t){const m=Ia('[data-svelte="svelte-1phssyn"]',document.head);d=s(m,"META",{name:!0,content:!0}),m.forEach(a),v=f(t),h=s(t,"H1",{class:!0});var ce=o(h);u=s(ce,"A",{id:!0,class:!0,href:!0});var Pe=o(u);w=s(Pe,"SPAN",{});var Se=o(w);T(i.$$.fragment,Se),Se.forEach(a),Pe.forEach(a),y=f(ce),ye=s(ce,"SPAN",{});var Ot=o(ye);He=r(Ot,"Stable Diffusion Latent Upscaler"),Ot.forEach(a),ce.forEach(a),Le=f(t),L=s(t,"H2",{class:!0});var Ve=o(L);j=s(Ve,"A",{id:!0,class:!0,href:!0});var Kt=o(j);ve=s(Kt,"SPAN",{});var ea=o(ve);T(R.$$.fragment,ea),ea.forEach(a),Kt.forEach(a),Oe=f(Ve),we=s(Ve,"SPAN",{});var ta=o(we);Ke=r(ta,"StableDiffusionLatentUpscalePipeline"),ta.forEach(a),Ve.forEach(a),Ze=f(t),E=s(t,"P",{});var F=o(E);et=r(F,"The Stable Diffusion Latent Upscaler model was created by "),N=s(F,"A",{href:!0,rel:!0});var aa=o(N);tt=r(aa,"Katherine Crowson"),aa.forEach(a),at=r(F," in collaboration with "),X=s(F,"A",{href:!0,rel:!0});var na=o(X);nt=r(na,"Stability AI"),na.forEach(a),st=r(F,". It can be used on top of any "),fe=s(F,"A",{href:!0});var sa=o(fe);ot=r(sa,"StableDiffusionUpscalePipeline"),sa.forEach(a),it=r(F," checkpoint to enhance its output image resolution by a factor of 2."),F.forEach(a),je=f(t),de=s(t,"P",{});var oa=o(de);lt=r(oa,"A notebook that demonstrates the original implementation can be found here:"),oa.forEach(a),Ge=f(t),ue=s(t,"UL",{});var ia=o(ue);Ue=s(ia,"LI",{});var la=o(Ue);z=s(la,"A",{href:!0,rel:!0});var ra=o(z);rt=r(ra,"Stable Diffusion Upscaler Demo"),ra.forEach(a),la.forEach(a),ia.forEach(a),ke=f(t),me=s(t,"P",{});var ca=o(me);ct=r(ca,"Available Checkpoints are:"),ca.forEach(a),We=f(t),he=s(t,"UL",{});var pa=o(he);A=s(pa,"LI",{});var Fe=o(A);$e=s(Fe,"EM",{});var fa=o($e);pt=r(fa,"stabilityai/latent-upscaler"),fa.forEach(a),ft=r(Fe,": "),Y=s(Fe,"A",{href:!0,rel:!0});var da=o(Y);dt=r(da,"stabilityai/sd-x2-latent-upscaler"),da.forEach(a),Fe.forEach(a),pa.forEach(a),Ce=f(t),g=s(t,"DIV",{class:!0});var _=o(g);T(q.$$.fragment,_),ut=f(_),Te=s(_,"P",{});var ua=o(Te);mt=r(ua,"Pipeline to upscale the resolution of Stable Diffusion output images by a factor of 2."),ua.forEach(a),ht=f(_),Q=s(_,"P",{});var Re=o(Q);gt=r(Re,"This model inherits from "),ge=s(Re,"A",{href:!0});var ma=o(ge);bt=r(ma,"DiffusionPipeline"),ma.forEach(a),_t=r(Re,`. Check the superclass documentation for the generic methods the
library implements for all the pipelines (such as downloading or saving, running on a particular device, etc.)`),Re.forEach(a),yt=f(_),I=s(_,"DIV",{class:!0});var be=o(I);T(H.$$.fragment,be),vt=f(be),Je=s(be,"P",{});var ha=o(Je);wt=r(ha,"Function invoked when calling the pipeline for generation."),ha.forEach(a),Ut=f(be),T(G.$$.fragment,be),be.forEach(a),$t=f(_),k=s(_,"DIV",{class:!0});var Ne=o(k);T(O.$$.fragment,Ne),Tt=f(Ne),K=s(Ne,"P",{});var Xe=o(K);Jt=r(Xe,`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
`),Me=s(Xe,"CODE",{});var ga=o(Me);Mt=r(ga,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),ga.forEach(a),xt=r(Xe,"forward` method called."),Xe.forEach(a),Ne.forEach(a),Dt=f(_),P=s(_,"DIV",{class:!0});var _e=o(P);T(ee.$$.fragment,_e),Et=f(_e),xe=s(_e,"P",{});var ba=o(xe);It=r(ba,"Enable sliced attention computation."),ba.forEach(a),Pt=f(_e),De=s(_e,"P",{});var _a=o(De);St=r(_a,`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.`),_a.forEach(a),_e.forEach(a),Lt=f(_),W=s(_,"DIV",{class:!0});var ze=o(W);T(te.$$.fragment,ze),Zt=f(ze),ae=s(ze,"P",{});var Ae=o(ae);jt=r(Ae,"Disable sliced attention computation. If "),Ee=s(Ae,"CODE",{});var ya=o(Ee);Gt=r(ya,"enable_attention_slicing"),ya.forEach(a),kt=r(Ae,` was previously called, attention is
computed in one step.`),Ae.forEach(a),ze.forEach(a),Wt=f(_),U=s(_,"DIV",{class:!0});var S=o(U);T(ne.$$.fragment,S),Ct=f(S),se=s(S,"P",{});var Ye=o(se);Bt=r(Ye,"Enable memory efficient attention from "),oe=s(Ye,"A",{href:!0,rel:!0});var va=o(oe);Vt=r(va,"xFormers"),va.forEach(a),Ft=r(Ye,"."),Ye.forEach(a),Rt=f(S),Ie=s(S,"P",{});var wa=o(Ie);Nt=r(wa,`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.`),wa.forEach(a),Xt=f(S),T(C.$$.fragment,S),zt=f(S),T(B.$$.fragment,S),S.forEach(a),At=f(_),V=s(_,"DIV",{class:!0});var qe=o(V);T(ie.$$.fragment,qe),Yt=f(qe),le=s(qe,"P",{});var Qe=o(le);qt=r(Qe,"Disable memory efficient attention from "),re=s(Qe,"A",{href:!0,rel:!0});var Ua=o(re);Qt=r(Ua,"xFormers"),Ua.forEach(a),Ht=r(Qe,"."),Qe.forEach(a),qe.forEach(a),_.forEach(a),this.h()},h(){c(d,"name","hf:doc:metadata"),c(d,"content",JSON.stringify(ka)),c(u,"id","stable-diffusion-latent-upscaler"),c(u,"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"),c(u,"href","#stable-diffusion-latent-upscaler"),c(h,"class","relative group"),c(j,"id","diffusers.StableDiffusionLatentUpscalePipeline"),c(j,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),c(j,"href","#diffusers.StableDiffusionLatentUpscalePipeline"),c(L,"class","relative group"),c(N,"href","https://github.com/crowsonkb/k-diffusion"),c(N,"rel","nofollow"),c(X,"href","https://stability.ai/"),c(X,"rel","nofollow"),c(fe,"href","/docs/diffusers/v0.18.0/en/api/pipelines/stable_diffusion/upscale#diffusers.StableDiffusionUpscalePipeline"),c(z,"href","https://colab.research.google.com/drive/1o1qYJcFeywzCIdkfKJy7cTpgZTCM2EI4"),c(z,"rel","nofollow"),c(Y,"href","https://huggingface.co/stabilityai/sd-x2-latent-upscaler"),c(Y,"rel","nofollow"),c(ge,"href","/docs/diffusers/v0.18.0/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),c(I,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(oe,"href","https://facebookresearch.github.io/xformers/"),c(oe,"rel","nofollow"),c(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(re,"href","https://facebookresearch.github.io/xformers/"),c(re,"rel","nofollow"),c(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),c(g,"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,m){e(document.head,d),b(t,v,m),b(t,h,m),e(h,u),e(u,w),J(i,w,null),e(h,y),e(h,ye),e(ye,He),b(t,Le,m),b(t,L,m),e(L,j),e(j,ve),J(R,ve,null),e(L,Oe),e(L,we),e(we,Ke),b(t,Ze,m),b(t,E,m),e(E,et),e(E,N),e(N,tt),e(E,at),e(E,X),e(X,nt),e(E,st),e(E,fe),e(fe,ot),e(E,it),b(t,je,m),b(t,de,m),e(de,lt),b(t,Ge,m),b(t,ue,m),e(ue,Ue),e(Ue,z),e(z,rt),b(t,ke,m),b(t,me,m),e(me,ct),b(t,We,m),b(t,he,m),e(he,A),e(A,$e),e($e,pt),e(A,ft),e(A,Y),e(Y,dt),b(t,Ce,m),b(t,g,m),J(q,g,null),e(g,ut),e(g,Te),e(Te,mt),e(g,ht),e(g,Q),e(Q,gt),e(Q,ge),e(ge,bt),e(Q,_t),e(g,yt),e(g,I),J(H,I,null),e(I,vt),e(I,Je),e(Je,wt),e(I,Ut),J(G,I,null),e(g,$t),e(g,k),J(O,k,null),e(k,Tt),e(k,K),e(K,Jt),e(K,Me),e(Me,Mt),e(K,xt),e(g,Dt),e(g,P),J(ee,P,null),e(P,Et),e(P,xe),e(xe,It),e(P,Pt),e(P,De),e(De,St),e(g,Lt),e(g,W),J(te,W,null),e(W,Zt),e(W,ae),e(ae,jt),e(ae,Ee),e(Ee,Gt),e(ae,kt),e(g,Wt),e(g,U),J(ne,U,null),e(U,Ct),e(U,se),e(se,Bt),e(se,oe),e(oe,Vt),e(se,Ft),e(U,Rt),e(U,Ie),e(Ie,Nt),e(U,Xt),J(C,U,null),e(U,zt),J(B,U,null),e(g,At),e(g,V),J(ie,V,null),e(V,Yt),e(V,le),e(le,qt),e(le,re),e(re,Qt),e(le,Ht),Be=!0},p(t,[m]){const ce={};m&2&&(ce.$$scope={dirty:m,ctx:t}),G.$set(ce);const Pe={};m&2&&(Pe.$$scope={dirty:m,ctx:t}),C.$set(Pe);const Se={};m&2&&(Se.$$scope={dirty:m,ctx:t}),B.$set(Se)},i(t){Be||(M(i.$$.fragment,t),M(R.$$.fragment,t),M(q.$$.fragment,t),M(H.$$.fragment,t),M(G.$$.fragment,t),M(O.$$.fragment,t),M(ee.$$.fragment,t),M(te.$$.fragment,t),M(ne.$$.fragment,t),M(C.$$.fragment,t),M(B.$$.fragment,t),M(ie.$$.fragment,t),Be=!0)},o(t){x(i.$$.fragment,t),x(R.$$.fragment,t),x(q.$$.fragment,t),x(H.$$.fragment,t),x(G.$$.fragment,t),x(O.$$.fragment,t),x(ee.$$.fragment,t),x(te.$$.fragment,t),x(ne.$$.fragment,t),x(C.$$.fragment,t),x(B.$$.fragment,t),x(ie.$$.fragment,t),Be=!1},d(t){a(d),t&&a(v),t&&a(h),D(i),t&&a(Le),t&&a(L),D(R),t&&a(Ze),t&&a(E),t&&a(je),t&&a(de),t&&a(Ge),t&&a(ue),t&&a(ke),t&&a(me),t&&a(We),t&&a(he),t&&a(Ce),t&&a(g),D(q),D(H),D(G),D(O),D(ee),D(te),D(ne),D(C),D(B),D(ie)}}}const ka={local:"stable-diffusion-latent-upscaler",sections:[{local:"diffusers.StableDiffusionLatentUpscalePipeline",title:"StableDiffusionLatentUpscalePipeline"}],title:"Stable Diffusion Latent Upscaler"};function Wa(Z){return Pa(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Xa extends xa{constructor(d){super();Da(this,d,Wa,Ga,Ea,{})}}export{Xa as default,ka as metadata};
