import{S as $s,i as Ss,s as xs,e as n,k as p,w,t as o,M as Is,c as a,d as s,m as c,a as i,x as P,h as l,b as r,G as e,g as h,y as D,q as $,o as S,B as x,v as Es,L as Us}from"../../../../chunks/vendor-hf-doc-builder.js";import{D as ie}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as ks}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ds}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ls}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function js(Ue){let g,C,b,_,I;return _=new ks({props:{code:`import requests
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionUpscalePipeline
import torch

# load model and scheduler
model_id = "stabilityai/stable-diffusion-x4-upscaler"
pipeline = StableDiffusionUpscalePipeline.from_pretrained(
    model_id, revision="fp16", torch_dtype=torch.float16
)
pipeline = pipeline.to("cuda")

# let's download an  image
url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale/low_res_cat.png"
response = requests.get(url)
low_res_img = Image.open(BytesIO(response.content)).convert("RGB")
low_res_img = low_res_img.resize((128, 128))
prompt = "a white cat"

upscaled_image = pipeline(prompt=prompt, image=low_res_img).images[0]
upscaled_image.save("upsampled_cat.png")`,highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">import</span> requests
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> PIL <span class="hljs-keyword">import</span> Image
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> io <span class="hljs-keyword">import</span> BytesIO
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> StableDiffusionUpscalePipeline
<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-comment"># load model and scheduler</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>model_id = <span class="hljs-string">&quot;stabilityai/stable-diffusion-x4-upscaler&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = StableDiffusionUpscalePipeline.from_pretrained(
<span class="hljs-meta">... </span>    model_id, revision=<span class="hljs-string">&quot;fp16&quot;</span>, torch_dtype=torch.float16
<span class="hljs-meta">... </span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>pipeline = pipeline.to(<span class="hljs-string">&quot;cuda&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># let&#x27;s download an  image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>url = <span class="hljs-string">&quot;https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale/low_res_cat.png&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>response = requests.get(url)
<span class="hljs-meta">&gt;&gt;&gt; </span>low_res_img = Image.<span class="hljs-built_in">open</span>(BytesIO(response.content)).convert(<span class="hljs-string">&quot;RGB&quot;</span>)
<span class="hljs-meta">&gt;&gt;&gt; </span>low_res_img = low_res_img.resize((<span class="hljs-number">128</span>, <span class="hljs-number">128</span>))
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;a white cat&quot;</span>

<span class="hljs-meta">&gt;&gt;&gt; </span>upscaled_image = pipeline(prompt=prompt, image=low_res_img).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span>upscaled_image.save(<span class="hljs-string">&quot;upsampled_cat.png&quot;</span>)`}}),{c(){g=n("p"),C=o("Examples:"),b=p(),w(_.$$.fragment)},l(d){g=a(d,"P",{});var E=i(g);C=l(E,"Examples:"),E.forEach(s),b=c(d),P(_.$$.fragment,d)},m(d,E){h(d,g,E),e(g,C),h(d,b,E),D(_,d,E),I=!0},p:Us,i(d){I||($(_.$$.fragment,d),I=!0)},o(d){S(_.$$.fragment,d),I=!1},d(d){d&&s(g),d&&s(b),x(_,d)}}}function Cs(Ue){let g,C,b,_,I,d,E,me,Ke,ke,j,T,he,z,He,ge,Je,Le,v,Qe,G,Xe,Ye,W,Ze,et,V,tt,st,oe,nt,at,je,le,it,Ce,re,B,_e,ot,lt,F,rt,Te,pe,pt,qe,ce,R,be,ct,dt,K,ft,Ae,f,H,ut,ve,mt,ht,J,gt,de,_t,bt,vt,U,Q,yt,ye,wt,Pt,q,Dt,k,X,$t,we,St,xt,Pe,It,Et,A,Y,Ut,Z,kt,De,Lt,jt,Ct,y,ee,Tt,$e,qt,At,Se,Mt,Ot,xe,Nt,zt,M,te,Gt,Ie,Wt,Vt,O,se,Bt,ne,Ft,Ee,Rt,Kt,Me;return d=new Ds({}),z=new Ds({}),H=new ie({props:{name:"class diffusers.StableDiffusionUpscalePipeline",anchor:"diffusers.StableDiffusionUpscalePipeline",parameters:[{name:"vae",val:": AutoencoderKL"},{name:"text_encoder",val:": CLIPTextModel"},{name:"tokenizer",val:": CLIPTokenizer"},{name:"unet",val:": UNet2DConditionModel"},{name:"low_res_scheduler",val:": DDPMScheduler"},{name:"scheduler",val:": KarrasDiffusionSchedulers"},{name:"max_noise_level",val:": int = 350"}],parametersDescription:[{anchor:"diffusers.StableDiffusionUpscalePipeline.vae",description:`<strong>vae</strong> (<a href="/docs/diffusers/main/en/api/models#diffusers.AutoencoderKL">AutoencoderKL</a>) &#x2014;
Variational Auto-Encoder (VAE) Model to encode and decode images to and from latent representations.`,name:"vae"},{anchor:"diffusers.StableDiffusionUpscalePipeline.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.StableDiffusionUpscalePipeline.tokenizer",description:`<strong>tokenizer</strong> (<code>CLIPTokenizer</code>) &#x2014;
Tokenizer of class
<a href="https://huggingface.co/docs/transformers/v4.21.0/en/model_doc/clip#transformers.CLIPTokenizer" rel="nofollow">CLIPTokenizer</a>.`,name:"tokenizer"},{anchor:"diffusers.StableDiffusionUpscalePipeline.unet",description:'<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014; Conditional U-Net architecture to denoise the encoded image latents.',name:"unet"},{anchor:"diffusers.StableDiffusionUpscalePipeline.low_res_scheduler",description:`<strong>low_res_scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler used to add initial noise to the low res conditioning image. It must be an instance of
<a href="/docs/diffusers/main/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>.`,name:"low_res_scheduler"},{anchor:"diffusers.StableDiffusionUpscalePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
A scheduler to be used in combination with <code>unet</code> to denoise the encoded image latents. Can be one of
<a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/main/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py#L54"}}),Q=new ie({props:{name:"__call__",anchor:"diffusers.StableDiffusionUpscalePipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image, typing.List[PIL.Image.Image]]"},{name:"num_inference_steps",val:": int = 75"},{name:"guidance_scale",val:": float = 9.0"},{name:"noise_level",val:": int = 20"},{name:"negative_prompt",val:": typing.Union[str, typing.List[str], NoneType] = None"},{name:"num_images_per_prompt",val:": typing.Optional[int] = 1"},{name:"eta",val:": float = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"latents",val:": typing.Optional[torch.FloatTensor] = None"},{name:"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:": typing.Optional[int] = 1"}],parametersDescription:[{anchor:"diffusers.StableDiffusionUpscalePipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>) &#x2014;
The prompt or prompts to guide the image generation.`,name:"prompt"},{anchor:"diffusers.StableDiffusionUpscalePipeline.__call__.image",description:`<strong>image</strong> (<code>PIL.Image.Image</code> or List<code>PIL.Image.Image</code> or <code>torch.FloatTensor</code>) &#x2014;
<code>Image</code>, or tensor representing an image batch which will be upscaled. *`,name:"image"},{anchor:"diffusers.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__call__.num_images_per_prompt",description:`<strong>num_images_per_prompt</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate per prompt.`,name:"num_images_per_prompt"},{anchor:"diffusers.StableDiffusionUpscalePipeline.__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/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">schedulers.DDIMScheduler</a>, will be ignored for others.`,name:"eta"},{anchor:"diffusers.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__call__.return_dict",description:`<strong>return_dict</strong> (<code>bool</code>, <em>optional</em>, defaults to <code>True</code>) &#x2014;
Whether or not to return a <a href="/docs/diffusers/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput">StableDiffusionPipelineOutput</a> instead of a
plain tuple.`,name:"return_dict"},{anchor:"diffusers.StableDiffusionUpscalePipeline.__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.StableDiffusionUpscalePipeline.__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/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py#L325",returnDescription:`
<p><a
  href="/docs/diffusers/main/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/main/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),q=new Ls({props:{anchor:"diffusers.StableDiffusionUpscalePipeline.__call__.example",$$slots:{default:[js]},$$scope:{ctx:Ue}}}),X=new ie({props:{name:"enable_attention_slicing",anchor:"diffusers.StableDiffusionUpscalePipeline.enable_attention_slicing",parameters:[{name:"slice_size",val:": typing.Union[str, int, NoneType] = 'auto'"}],parametersDescription:[{anchor:"diffusers.StableDiffusionUpscalePipeline.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>, maxium 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/main/src/diffusers/pipelines/pipeline_utils.py#L876"}}),Y=new ie({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionUpscalePipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L892"}}),ee=new ie({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionUpscalePipeline.enable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L841"}}),te=new ie({props:{name:"disable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionUpscalePipeline.disable_xformers_memory_efficient_attention",parameters:[],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L853"}}),se=new ie({props:{name:"enable_sequential_cpu_offload",anchor:"diffusers.StableDiffusionUpscalePipeline.enable_sequential_cpu_offload",parameters:[{name:"gpu_id",val:" = 0"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py#L102"}}),{c(){g=n("meta"),C=p(),b=n("h1"),_=n("a"),I=n("span"),w(d.$$.fragment),E=p(),me=n("span"),Ke=o("Super-Resolution"),ke=p(),j=n("h2"),T=n("a"),he=n("span"),w(z.$$.fragment),He=p(),ge=n("span"),Je=o("StableDiffusionUpscalePipeline"),Le=p(),v=n("p"),Qe=o("The upscaler diffusion model was created by the researchers and engineers from "),G=n("a"),Xe=o("CompVis"),Ye=o(", "),W=n("a"),Ze=o("Stability AI"),et=o(", and "),V=n("a"),tt=o("LAION"),st=o(", as part of Stable Diffusion 2.0. "),oe=n("a"),nt=o("StableDiffusionUpscalePipeline"),at=o(" can be used to enhance the resolution of input images by a factor of 4."),je=p(),le=n("p"),it=o("The original codebase can be found here:"),Ce=p(),re=n("ul"),B=n("li"),_e=n("em"),ot=o("Stable Diffusion v2"),lt=o(": "),F=n("a"),rt=o("Stability-AI/stablediffusion"),Te=p(),pe=n("p"),pt=o("Available Checkpoints are:"),qe=p(),ce=n("ul"),R=n("li"),be=n("em"),ct=o("stabilityai/stable-diffusion-x4-upscaler (x4 resolution resolution)"),dt=o(": "),K=n("a"),ft=o("stable-diffusion-x4-upscaler"),Ae=p(),f=n("div"),w(H.$$.fragment),ut=p(),ve=n("p"),mt=o("Pipeline for text-guided image super-resolution using Stable Diffusion 2."),ht=p(),J=n("p"),gt=o("This model inherits from "),de=n("a"),_t=o("DiffusionPipeline"),bt=o(`. 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.)`),vt=p(),U=n("div"),w(Q.$$.fragment),yt=p(),ye=n("p"),wt=o("Function invoked when calling the pipeline for generation."),Pt=p(),w(q.$$.fragment),Dt=p(),k=n("div"),w(X.$$.fragment),$t=p(),we=n("p"),St=o("Enable sliced attention computation."),xt=p(),Pe=n("p"),It=o(`When this option is enabled, the attention module will split 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.`),Et=p(),A=n("div"),w(Y.$$.fragment),Ut=p(),Z=n("p"),kt=o("Disable sliced attention computation. If "),De=n("code"),Lt=o("enable_attention_slicing"),jt=o(` was previously invoked, this method will go
back to computing attention in one step.`),Ct=p(),y=n("div"),w(ee.$$.fragment),Tt=p(),$e=n("p"),qt=o("Enable memory efficient attention as implemented in xformers."),At=p(),Se=n("p"),Mt=o(`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),Ot=p(),xe=n("p"),Nt=o(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),zt=p(),M=n("div"),w(te.$$.fragment),Gt=p(),Ie=n("p"),Wt=o("Disable memory efficient attention as implemented in xformers."),Vt=p(),O=n("div"),w(se.$$.fragment),Bt=p(),ne=n("p"),Ft=o(`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
`),Ee=n("code"),Rt=o("torch.device('meta') and loaded to GPU only when their specific submodule has its "),Kt=o("forward` method called."),this.h()},l(t){const u=Is('[data-svelte="svelte-1phssyn"]',document.head);g=a(u,"META",{name:!0,content:!0}),u.forEach(s),C=c(t),b=a(t,"H1",{class:!0});var ae=i(b);_=a(ae,"A",{id:!0,class:!0,href:!0});var Ht=i(_);I=a(Ht,"SPAN",{});var Jt=i(I);P(d.$$.fragment,Jt),Jt.forEach(s),Ht.forEach(s),E=c(ae),me=a(ae,"SPAN",{});var Qt=i(me);Ke=l(Qt,"Super-Resolution"),Qt.forEach(s),ae.forEach(s),ke=c(t),j=a(t,"H2",{class:!0});var Oe=i(j);T=a(Oe,"A",{id:!0,class:!0,href:!0});var Xt=i(T);he=a(Xt,"SPAN",{});var Yt=i(he);P(z.$$.fragment,Yt),Yt.forEach(s),Xt.forEach(s),He=c(Oe),ge=a(Oe,"SPAN",{});var Zt=i(ge);Je=l(Zt,"StableDiffusionUpscalePipeline"),Zt.forEach(s),Oe.forEach(s),Le=c(t),v=a(t,"P",{});var L=i(v);Qe=l(L,"The upscaler diffusion model was created by the researchers and engineers from "),G=a(L,"A",{href:!0,rel:!0});var es=i(G);Xe=l(es,"CompVis"),es.forEach(s),Ye=l(L,", "),W=a(L,"A",{href:!0,rel:!0});var ts=i(W);Ze=l(ts,"Stability AI"),ts.forEach(s),et=l(L,", and "),V=a(L,"A",{href:!0,rel:!0});var ss=i(V);tt=l(ss,"LAION"),ss.forEach(s),st=l(L,", as part of Stable Diffusion 2.0. "),oe=a(L,"A",{href:!0});var ns=i(oe);nt=l(ns,"StableDiffusionUpscalePipeline"),ns.forEach(s),at=l(L," can be used to enhance the resolution of input images by a factor of 4."),L.forEach(s),je=c(t),le=a(t,"P",{});var as=i(le);it=l(as,"The original codebase can be found here:"),as.forEach(s),Ce=c(t),re=a(t,"UL",{});var is=i(re);B=a(is,"LI",{});var Ne=i(B);_e=a(Ne,"EM",{});var os=i(_e);ot=l(os,"Stable Diffusion v2"),os.forEach(s),lt=l(Ne,": "),F=a(Ne,"A",{href:!0,rel:!0});var ls=i(F);rt=l(ls,"Stability-AI/stablediffusion"),ls.forEach(s),Ne.forEach(s),is.forEach(s),Te=c(t),pe=a(t,"P",{});var rs=i(pe);pt=l(rs,"Available Checkpoints are:"),rs.forEach(s),qe=c(t),ce=a(t,"UL",{});var ps=i(ce);R=a(ps,"LI",{});var ze=i(R);be=a(ze,"EM",{});var cs=i(be);ct=l(cs,"stabilityai/stable-diffusion-x4-upscaler (x4 resolution resolution)"),cs.forEach(s),dt=l(ze,": "),K=a(ze,"A",{href:!0,rel:!0});var ds=i(K);ft=l(ds,"stable-diffusion-x4-upscaler"),ds.forEach(s),ze.forEach(s),ps.forEach(s),Ae=c(t),f=a(t,"DIV",{class:!0});var m=i(f);P(H.$$.fragment,m),ut=c(m),ve=a(m,"P",{});var fs=i(ve);mt=l(fs,"Pipeline for text-guided image super-resolution using Stable Diffusion 2."),fs.forEach(s),ht=c(m),J=a(m,"P",{});var Ge=i(J);gt=l(Ge,"This model inherits from "),de=a(Ge,"A",{href:!0});var us=i(de);_t=l(us,"DiffusionPipeline"),us.forEach(s),bt=l(Ge,`. 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.)`),Ge.forEach(s),vt=c(m),U=a(m,"DIV",{class:!0});var fe=i(U);P(Q.$$.fragment,fe),yt=c(fe),ye=a(fe,"P",{});var ms=i(ye);wt=l(ms,"Function invoked when calling the pipeline for generation."),ms.forEach(s),Pt=c(fe),P(q.$$.fragment,fe),fe.forEach(s),Dt=c(m),k=a(m,"DIV",{class:!0});var ue=i(k);P(X.$$.fragment,ue),$t=c(ue),we=a(ue,"P",{});var hs=i(we);St=l(hs,"Enable sliced attention computation."),hs.forEach(s),xt=c(ue),Pe=a(ue,"P",{});var gs=i(Pe);It=l(gs,`When this option is enabled, the attention module will split 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.`),gs.forEach(s),ue.forEach(s),Et=c(m),A=a(m,"DIV",{class:!0});var We=i(A);P(Y.$$.fragment,We),Ut=c(We),Z=a(We,"P",{});var Ve=i(Z);kt=l(Ve,"Disable sliced attention computation. If "),De=a(Ve,"CODE",{});var _s=i(De);Lt=l(_s,"enable_attention_slicing"),_s.forEach(s),jt=l(Ve,` was previously invoked, this method will go
back to computing attention in one step.`),Ve.forEach(s),We.forEach(s),Ct=c(m),y=a(m,"DIV",{class:!0});var N=i(y);P(ee.$$.fragment,N),Tt=c(N),$e=a(N,"P",{});var bs=i($e);qt=l(bs,"Enable memory efficient attention as implemented in xformers."),bs.forEach(s),At=c(N),Se=a(N,"P",{});var vs=i(Se);Mt=l(vs,`When this option is enabled, you should observe lower GPU memory usage and a potential speed up at inference
time. Speed up at training time is not guaranteed.`),vs.forEach(s),Ot=c(N),xe=a(N,"P",{});var ys=i(xe);Nt=l(ys,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),ys.forEach(s),N.forEach(s),zt=c(m),M=a(m,"DIV",{class:!0});var Be=i(M);P(te.$$.fragment,Be),Gt=c(Be),Ie=a(Be,"P",{});var ws=i(Ie);Wt=l(ws,"Disable memory efficient attention as implemented in xformers."),ws.forEach(s),Be.forEach(s),Vt=c(m),O=a(m,"DIV",{class:!0});var Fe=i(O);P(se.$$.fragment,Fe),Bt=c(Fe),ne=a(Fe,"P",{});var Re=i(ne);Ft=l(Re,`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
`),Ee=a(Re,"CODE",{});var Ps=i(Ee);Rt=l(Ps,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),Ps.forEach(s),Kt=l(Re,"forward` method called."),Re.forEach(s),Fe.forEach(s),m.forEach(s),this.h()},h(){r(g,"name","hf:doc:metadata"),r(g,"content",JSON.stringify(Ts)),r(_,"id","superresolution"),r(_,"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"),r(_,"href","#superresolution"),r(b,"class","relative group"),r(T,"id","diffusers.StableDiffusionUpscalePipeline"),r(T,"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"),r(T,"href","#diffusers.StableDiffusionUpscalePipeline"),r(j,"class","relative group"),r(G,"href","https://github.com/CompVis"),r(G,"rel","nofollow"),r(W,"href","https://stability.ai/"),r(W,"rel","nofollow"),r(V,"href","https://laion.ai/"),r(V,"rel","nofollow"),r(oe,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/upscale#diffusers.StableDiffusionUpscalePipeline"),r(F,"href","https://github.com/Stability-AI/stablediffusion#image-upscaling-with-stable-diffusion"),r(F,"rel","nofollow"),r(K,"href","https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler"),r(K,"rel","nofollow"),r(de,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),r(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(k,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(A,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),r(f,"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,u){e(document.head,g),h(t,C,u),h(t,b,u),e(b,_),e(_,I),D(d,I,null),e(b,E),e(b,me),e(me,Ke),h(t,ke,u),h(t,j,u),e(j,T),e(T,he),D(z,he,null),e(j,He),e(j,ge),e(ge,Je),h(t,Le,u),h(t,v,u),e(v,Qe),e(v,G),e(G,Xe),e(v,Ye),e(v,W),e(W,Ze),e(v,et),e(v,V),e(V,tt),e(v,st),e(v,oe),e(oe,nt),e(v,at),h(t,je,u),h(t,le,u),e(le,it),h(t,Ce,u),h(t,re,u),e(re,B),e(B,_e),e(_e,ot),e(B,lt),e(B,F),e(F,rt),h(t,Te,u),h(t,pe,u),e(pe,pt),h(t,qe,u),h(t,ce,u),e(ce,R),e(R,be),e(be,ct),e(R,dt),e(R,K),e(K,ft),h(t,Ae,u),h(t,f,u),D(H,f,null),e(f,ut),e(f,ve),e(ve,mt),e(f,ht),e(f,J),e(J,gt),e(J,de),e(de,_t),e(J,bt),e(f,vt),e(f,U),D(Q,U,null),e(U,yt),e(U,ye),e(ye,wt),e(U,Pt),D(q,U,null),e(f,Dt),e(f,k),D(X,k,null),e(k,$t),e(k,we),e(we,St),e(k,xt),e(k,Pe),e(Pe,It),e(f,Et),e(f,A),D(Y,A,null),e(A,Ut),e(A,Z),e(Z,kt),e(Z,De),e(De,Lt),e(Z,jt),e(f,Ct),e(f,y),D(ee,y,null),e(y,Tt),e(y,$e),e($e,qt),e(y,At),e(y,Se),e(Se,Mt),e(y,Ot),e(y,xe),e(xe,Nt),e(f,zt),e(f,M),D(te,M,null),e(M,Gt),e(M,Ie),e(Ie,Wt),e(f,Vt),e(f,O),D(se,O,null),e(O,Bt),e(O,ne),e(ne,Ft),e(ne,Ee),e(Ee,Rt),e(ne,Kt),Me=!0},p(t,[u]){const ae={};u&2&&(ae.$$scope={dirty:u,ctx:t}),q.$set(ae)},i(t){Me||($(d.$$.fragment,t),$(z.$$.fragment,t),$(H.$$.fragment,t),$(Q.$$.fragment,t),$(q.$$.fragment,t),$(X.$$.fragment,t),$(Y.$$.fragment,t),$(ee.$$.fragment,t),$(te.$$.fragment,t),$(se.$$.fragment,t),Me=!0)},o(t){S(d.$$.fragment,t),S(z.$$.fragment,t),S(H.$$.fragment,t),S(Q.$$.fragment,t),S(q.$$.fragment,t),S(X.$$.fragment,t),S(Y.$$.fragment,t),S(ee.$$.fragment,t),S(te.$$.fragment,t),S(se.$$.fragment,t),Me=!1},d(t){s(g),t&&s(C),t&&s(b),x(d),t&&s(ke),t&&s(j),x(z),t&&s(Le),t&&s(v),t&&s(je),t&&s(le),t&&s(Ce),t&&s(re),t&&s(Te),t&&s(pe),t&&s(qe),t&&s(ce),t&&s(Ae),t&&s(f),x(H),x(Q),x(q),x(X),x(Y),x(ee),x(te),x(se)}}}const Ts={local:"superresolution",sections:[{local:"diffusers.StableDiffusionUpscalePipeline",title:"StableDiffusionUpscalePipeline"}],title:"Super-Resolution"};function qs(Ue){return Es(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Gs extends $s{constructor(g){super();Ss(this,g,qs,Cs,xs,{})}}export{Gs as default,Ts as metadata};
