import{S as Un,i as jn,s as An,e as s,k as p,w as P,t as r,M as Ln,c as a,d as n,m as c,a as i,x,h as l,b as f,G as e,g,y as D,q as S,o as E,B as k,v as Cn,L as kn}from"../../../../chunks/vendor-hf-doc-builder.js";import{D as oe}from"../../../../chunks/Docstring-hf-doc-builder.js";import{C as In}from"../../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Sn}from"../../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as En}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Tn(re){let m,I,_,d,y;return d=new In({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(){m=s("p"),I=r("Examples:"),_=p(),P(d.$$.fragment)},l(o){m=a(o,"P",{});var v=i(m);I=l(v,"Examples:"),v.forEach(n),_=c(o),x(d.$$.fragment,o)},m(o,v){g(o,m,v),e(m,I),g(o,_,v),D(d,o,v),y=!0},p:kn,i(o){y||(S(d.$$.fragment,o),y=!0)},o(o){E(d.$$.fragment,o),y=!1},d(o){o&&n(m),o&&n(_),k(d,o)}}}function qn(re){let m,I,_,d,y;return d=new In({props:{code:`import torch
from diffusers import DiffusionPipeline
from xformers.ops import MemoryEfficientAttentionFlashAttentionOp

pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-2-1", torch_dtype=torch.float16)
pipe = pipe.to("cuda")
pipe.enable_xformers_memory_efficient_attention(attention_op=MemoryEfficientAttentionFlashAttentionOp)
# Workaround for not accepting attention shape using VAE for Flash Attention
pipe.vae.enable_xformers_memory_efficient_attention(attention_op=None)`,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(){m=s("p"),I=r("Examples:"),_=p(),P(d.$$.fragment)},l(o){m=a(o,"P",{});var v=i(m);I=l(v,"Examples:"),v.forEach(n),_=c(o),x(d.$$.fragment,o)},m(o,v){g(o,m,v),e(m,I),g(o,_,v),D(d,o,v),y=!0},p:kn,i(o){y||(S(d.$$.fragment,o),y=!0)},o(o){E(d.$$.fragment,o),y=!1},d(o){o&&n(m),o&&n(_),k(d,o)}}}function Mn(re){let m,I,_,d,y,o,v,ge,Je,Ae,C,T,_e,z,Qe,be,Xe,Le,w,Ye,G,Ze,et,W,tt,nt,V,st,at,le,it,ot,Ce,pe,rt,Te,ce,B,ve,lt,pt,R,ct,qe,fe,ft,Me,de,K,ye,dt,ut,H,mt,Ne,h,J,ht,we,gt,_t,Q,bt,ue,vt,yt,wt,U,X,$t,$e,Pt,xt,q,Dt,j,Y,St,Pe,Et,kt,xe,It,Ut,M,Z,jt,ee,At,De,Lt,Ct,Tt,$,te,qt,Se,Mt,Nt,Ee,Ot,Ft,ke,zt,Gt,N,Wt,O,ne,Vt,Ie,Bt,Rt,F,se,Kt,ae,Ht,Ue,Jt,Qt,Oe;return o=new Sn({}),z=new Sn({}),J=new oe({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#L53"}}),X=new oe({props:{name:"__call__",anchor:"diffusers.StableDiffusionUpscalePipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]] = None"},{name:"image",val:": typing.Union[torch.FloatTensor, PIL.Image.Image, typing.List[PIL.Image.Image]] = None"},{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:"prompt_embeds",val:": typing.Optional[torch.FloatTensor] = None"},{name:"negative_prompt_embeds",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.StableDiffusionUpscalePipeline.__call__.prompt",description:`<strong>prompt</strong> (<code>str</code> or <code>List[str]</code>, <em>optional</em>) &#x2014;
The prompt or prompts to guide the image generation. If not defined, one has to pass <code>prompt_embeds</code>.
instead.`,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. If not defined, one has to pass
<code>negative_prompt_embeds</code>. instead. Ignored when not using guidance (i.e., ignored if <code>guidance_scale</code>
is less than <code>1</code>).`,name:"negative_prompt"},{anchor:"diffusers.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__.prompt_embeds",description:`<strong>prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt weighting. If not
provided, text embeddings will be generated from <code>prompt</code> input argument.`,name:"prompt_embeds"},{anchor:"diffusers.StableDiffusionUpscalePipeline.__call__.negative_prompt_embeds",description:`<strong>negative_prompt_embeds</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated negative text embeddings. Can be used to easily tweak text inputs, <em>e.g.</em> prompt
weighting. If not provided, negative_prompt_embeds will be generated from <code>negative_prompt</code> input
argument.`,name:"negative_prompt_embeds"},{anchor:"diffusers.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#L373",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 En({props:{anchor:"diffusers.StableDiffusionUpscalePipeline.__call__.example",$$slots:{default:[Tn]},$$scope:{ctx:re}}}),Y=new oe({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#L1033"}}),Z=new oe({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#L1049"}}),te=new oe({props:{name:"enable_xformers_memory_efficient_attention",anchor:"diffusers.StableDiffusionUpscalePipeline.enable_xformers_memory_efficient_attention",parameters:[{name:"attention_op",val:": typing.Optional[typing.Callable] = None"}],parametersDescription:[{anchor:"diffusers.StableDiffusionUpscalePipeline.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/main/src/diffusers/pipelines/pipeline_utils.py#L976"}}),N=new En({props:{anchor:"diffusers.StableDiffusionUpscalePipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[qn]},$$scope:{ctx:re}}}),ne=new oe({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#L1008"}}),se=new oe({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#L117"}}),{c(){m=s("meta"),I=p(),_=s("h1"),d=s("a"),y=s("span"),P(o.$$.fragment),v=p(),ge=s("span"),Je=r("Super-Resolution"),Ae=p(),C=s("h2"),T=s("a"),_e=s("span"),P(z.$$.fragment),Qe=p(),be=s("span"),Xe=r("StableDiffusionUpscalePipeline"),Le=p(),w=s("p"),Ye=r("The upscaler diffusion model was created by the researchers and engineers from "),G=s("a"),Ze=r("CompVis"),et=r(", "),W=s("a"),tt=r("Stability AI"),nt=r(", and "),V=s("a"),st=r("LAION"),at=r(", as part of Stable Diffusion 2.0. "),le=s("a"),it=r("StableDiffusionUpscalePipeline"),ot=r(" can be used to enhance the resolution of input images by a factor of 4."),Ce=p(),pe=s("p"),rt=r("The original codebase can be found here:"),Te=p(),ce=s("ul"),B=s("li"),ve=s("em"),lt=r("Stable Diffusion v2"),pt=r(": "),R=s("a"),ct=r("Stability-AI/stablediffusion"),qe=p(),fe=s("p"),ft=r("Available Checkpoints are:"),Me=p(),de=s("ul"),K=s("li"),ye=s("em"),dt=r("stabilityai/stable-diffusion-x4-upscaler (x4 resolution resolution)"),ut=r(": "),H=s("a"),mt=r("stable-diffusion-x4-upscaler"),Ne=p(),h=s("div"),P(J.$$.fragment),ht=p(),we=s("p"),gt=r("Pipeline for text-guided image super-resolution using Stable Diffusion 2."),_t=p(),Q=s("p"),bt=r("This model inherits from "),ue=s("a"),vt=r("DiffusionPipeline"),yt=r(`. 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.)`),wt=p(),U=s("div"),P(X.$$.fragment),$t=p(),$e=s("p"),Pt=r("Function invoked when calling the pipeline for generation."),xt=p(),P(q.$$.fragment),Dt=p(),j=s("div"),P(Y.$$.fragment),St=p(),Pe=s("p"),Et=r("Enable sliced attention computation."),kt=p(),xe=s("p"),It=r(`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.`),Ut=p(),M=s("div"),P(Z.$$.fragment),jt=p(),ee=s("p"),At=r("Disable sliced attention computation. If "),De=s("code"),Lt=r("enable_attention_slicing"),Ct=r(` was previously invoked, this method will go
back to computing attention in one step.`),Tt=p(),$=s("div"),P(te.$$.fragment),qt=p(),Se=s("p"),Mt=r("Enable memory efficient attention as implemented in xformers."),Nt=p(),Ee=s("p"),Ot=r(`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.`),Ft=p(),ke=s("p"),zt=r(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Gt=p(),P(N.$$.fragment),Wt=p(),O=s("div"),P(ne.$$.fragment),Vt=p(),Ie=s("p"),Bt=r("Disable memory efficient attention as implemented in xformers."),Rt=p(),F=s("div"),P(se.$$.fragment),Kt=p(),ae=s("p"),Ht=r(`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
`),Ue=s("code"),Jt=r("torch.device('meta') and loaded to GPU only when their specific submodule has its "),Qt=r("forward` method called."),this.h()},l(t){const u=Ln('[data-svelte="svelte-1phssyn"]',document.head);m=a(u,"META",{name:!0,content:!0}),u.forEach(n),I=c(t),_=a(t,"H1",{class:!0});var ie=i(_);d=a(ie,"A",{id:!0,class:!0,href:!0});var je=i(d);y=a(je,"SPAN",{});var Xt=i(y);x(o.$$.fragment,Xt),Xt.forEach(n),je.forEach(n),v=c(ie),ge=a(ie,"SPAN",{});var Yt=i(ge);Je=l(Yt,"Super-Resolution"),Yt.forEach(n),ie.forEach(n),Ae=c(t),C=a(t,"H2",{class:!0});var Fe=i(C);T=a(Fe,"A",{id:!0,class:!0,href:!0});var Zt=i(T);_e=a(Zt,"SPAN",{});var en=i(_e);x(z.$$.fragment,en),en.forEach(n),Zt.forEach(n),Qe=c(Fe),be=a(Fe,"SPAN",{});var tn=i(be);Xe=l(tn,"StableDiffusionUpscalePipeline"),tn.forEach(n),Fe.forEach(n),Le=c(t),w=a(t,"P",{});var A=i(w);Ye=l(A,"The upscaler diffusion model was created by the researchers and engineers from "),G=a(A,"A",{href:!0,rel:!0});var nn=i(G);Ze=l(nn,"CompVis"),nn.forEach(n),et=l(A,", "),W=a(A,"A",{href:!0,rel:!0});var sn=i(W);tt=l(sn,"Stability AI"),sn.forEach(n),nt=l(A,", and "),V=a(A,"A",{href:!0,rel:!0});var an=i(V);st=l(an,"LAION"),an.forEach(n),at=l(A,", as part of Stable Diffusion 2.0. "),le=a(A,"A",{href:!0});var on=i(le);it=l(on,"StableDiffusionUpscalePipeline"),on.forEach(n),ot=l(A," can be used to enhance the resolution of input images by a factor of 4."),A.forEach(n),Ce=c(t),pe=a(t,"P",{});var rn=i(pe);rt=l(rn,"The original codebase can be found here:"),rn.forEach(n),Te=c(t),ce=a(t,"UL",{});var ln=i(ce);B=a(ln,"LI",{});var ze=i(B);ve=a(ze,"EM",{});var pn=i(ve);lt=l(pn,"Stable Diffusion v2"),pn.forEach(n),pt=l(ze,": "),R=a(ze,"A",{href:!0,rel:!0});var cn=i(R);ct=l(cn,"Stability-AI/stablediffusion"),cn.forEach(n),ze.forEach(n),ln.forEach(n),qe=c(t),fe=a(t,"P",{});var fn=i(fe);ft=l(fn,"Available Checkpoints are:"),fn.forEach(n),Me=c(t),de=a(t,"UL",{});var dn=i(de);K=a(dn,"LI",{});var Ge=i(K);ye=a(Ge,"EM",{});var un=i(ye);dt=l(un,"stabilityai/stable-diffusion-x4-upscaler (x4 resolution resolution)"),un.forEach(n),ut=l(Ge,": "),H=a(Ge,"A",{href:!0,rel:!0});var mn=i(H);mt=l(mn,"stable-diffusion-x4-upscaler"),mn.forEach(n),Ge.forEach(n),dn.forEach(n),Ne=c(t),h=a(t,"DIV",{class:!0});var b=i(h);x(J.$$.fragment,b),ht=c(b),we=a(b,"P",{});var hn=i(we);gt=l(hn,"Pipeline for text-guided image super-resolution using Stable Diffusion 2."),hn.forEach(n),_t=c(b),Q=a(b,"P",{});var We=i(Q);bt=l(We,"This model inherits from "),ue=a(We,"A",{href:!0});var gn=i(ue);vt=l(gn,"DiffusionPipeline"),gn.forEach(n),yt=l(We,`. 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.)`),We.forEach(n),wt=c(b),U=a(b,"DIV",{class:!0});var me=i(U);x(X.$$.fragment,me),$t=c(me),$e=a(me,"P",{});var _n=i($e);Pt=l(_n,"Function invoked when calling the pipeline for generation."),_n.forEach(n),xt=c(me),x(q.$$.fragment,me),me.forEach(n),Dt=c(b),j=a(b,"DIV",{class:!0});var he=i(j);x(Y.$$.fragment,he),St=c(he),Pe=a(he,"P",{});var bn=i(Pe);Et=l(bn,"Enable sliced attention computation."),bn.forEach(n),kt=c(he),xe=a(he,"P",{});var vn=i(xe);It=l(vn,`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.`),vn.forEach(n),he.forEach(n),Ut=c(b),M=a(b,"DIV",{class:!0});var Ve=i(M);x(Z.$$.fragment,Ve),jt=c(Ve),ee=a(Ve,"P",{});var Be=i(ee);At=l(Be,"Disable sliced attention computation. If "),De=a(Be,"CODE",{});var yn=i(De);Lt=l(yn,"enable_attention_slicing"),yn.forEach(n),Ct=l(Be,` was previously invoked, this method will go
back to computing attention in one step.`),Be.forEach(n),Ve.forEach(n),Tt=c(b),$=a(b,"DIV",{class:!0});var L=i($);x(te.$$.fragment,L),qt=c(L),Se=a(L,"P",{});var wn=i(Se);Mt=l(wn,"Enable memory efficient attention as implemented in xformers."),wn.forEach(n),Nt=c(L),Ee=a(L,"P",{});var $n=i(Ee);Ot=l($n,`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.`),$n.forEach(n),Ft=c(L),ke=a(L,"P",{});var Pn=i(ke);zt=l(Pn,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Pn.forEach(n),Gt=c(L),x(N.$$.fragment,L),L.forEach(n),Wt=c(b),O=a(b,"DIV",{class:!0});var Re=i(O);x(ne.$$.fragment,Re),Vt=c(Re),Ie=a(Re,"P",{});var xn=i(Ie);Bt=l(xn,"Disable memory efficient attention as implemented in xformers."),xn.forEach(n),Re.forEach(n),Rt=c(b),F=a(b,"DIV",{class:!0});var Ke=i(F);x(se.$$.fragment,Ke),Kt=c(Ke),ae=a(Ke,"P",{});var He=i(ae);Ht=l(He,`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
`),Ue=a(He,"CODE",{});var Dn=i(Ue);Jt=l(Dn,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),Dn.forEach(n),Qt=l(He,"forward` method called."),He.forEach(n),Ke.forEach(n),b.forEach(n),this.h()},h(){f(m,"name","hf:doc:metadata"),f(m,"content",JSON.stringify(Nn)),f(d,"id","superresolution"),f(d,"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"),f(d,"href","#superresolution"),f(_,"class","relative group"),f(T,"id","diffusers.StableDiffusionUpscalePipeline"),f(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"),f(T,"href","#diffusers.StableDiffusionUpscalePipeline"),f(C,"class","relative group"),f(G,"href","https://github.com/CompVis"),f(G,"rel","nofollow"),f(W,"href","https://stability.ai/"),f(W,"rel","nofollow"),f(V,"href","https://laion.ai/"),f(V,"rel","nofollow"),f(le,"href","/docs/diffusers/main/en/api/pipelines/stable_diffusion/upscale#diffusers.StableDiffusionUpscalePipeline"),f(R,"href","https://github.com/Stability-AI/stablediffusion#image-upscaling-with-stable-diffusion"),f(R,"rel","nofollow"),f(H,"href","https://huggingface.co/stabilityai/stable-diffusion-x4-upscaler"),f(H,"rel","nofollow"),f(ue,"href","/docs/diffusers/main/en/api/diffusion_pipeline#diffusers.DiffusionPipeline"),f(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f($,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(O,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(F,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),f(h,"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,m),g(t,I,u),g(t,_,u),e(_,d),e(d,y),D(o,y,null),e(_,v),e(_,ge),e(ge,Je),g(t,Ae,u),g(t,C,u),e(C,T),e(T,_e),D(z,_e,null),e(C,Qe),e(C,be),e(be,Xe),g(t,Le,u),g(t,w,u),e(w,Ye),e(w,G),e(G,Ze),e(w,et),e(w,W),e(W,tt),e(w,nt),e(w,V),e(V,st),e(w,at),e(w,le),e(le,it),e(w,ot),g(t,Ce,u),g(t,pe,u),e(pe,rt),g(t,Te,u),g(t,ce,u),e(ce,B),e(B,ve),e(ve,lt),e(B,pt),e(B,R),e(R,ct),g(t,qe,u),g(t,fe,u),e(fe,ft),g(t,Me,u),g(t,de,u),e(de,K),e(K,ye),e(ye,dt),e(K,ut),e(K,H),e(H,mt),g(t,Ne,u),g(t,h,u),D(J,h,null),e(h,ht),e(h,we),e(we,gt),e(h,_t),e(h,Q),e(Q,bt),e(Q,ue),e(ue,vt),e(Q,yt),e(h,wt),e(h,U),D(X,U,null),e(U,$t),e(U,$e),e($e,Pt),e(U,xt),D(q,U,null),e(h,Dt),e(h,j),D(Y,j,null),e(j,St),e(j,Pe),e(Pe,Et),e(j,kt),e(j,xe),e(xe,It),e(h,Ut),e(h,M),D(Z,M,null),e(M,jt),e(M,ee),e(ee,At),e(ee,De),e(De,Lt),e(ee,Ct),e(h,Tt),e(h,$),D(te,$,null),e($,qt),e($,Se),e(Se,Mt),e($,Nt),e($,Ee),e(Ee,Ot),e($,Ft),e($,ke),e(ke,zt),e($,Gt),D(N,$,null),e(h,Wt),e(h,O),D(ne,O,null),e(O,Vt),e(O,Ie),e(Ie,Bt),e(h,Rt),e(h,F),D(se,F,null),e(F,Kt),e(F,ae),e(ae,Ht),e(ae,Ue),e(Ue,Jt),e(ae,Qt),Oe=!0},p(t,[u]){const ie={};u&2&&(ie.$$scope={dirty:u,ctx:t}),q.$set(ie);const je={};u&2&&(je.$$scope={dirty:u,ctx:t}),N.$set(je)},i(t){Oe||(S(o.$$.fragment,t),S(z.$$.fragment,t),S(J.$$.fragment,t),S(X.$$.fragment,t),S(q.$$.fragment,t),S(Y.$$.fragment,t),S(Z.$$.fragment,t),S(te.$$.fragment,t),S(N.$$.fragment,t),S(ne.$$.fragment,t),S(se.$$.fragment,t),Oe=!0)},o(t){E(o.$$.fragment,t),E(z.$$.fragment,t),E(J.$$.fragment,t),E(X.$$.fragment,t),E(q.$$.fragment,t),E(Y.$$.fragment,t),E(Z.$$.fragment,t),E(te.$$.fragment,t),E(N.$$.fragment,t),E(ne.$$.fragment,t),E(se.$$.fragment,t),Oe=!1},d(t){n(m),t&&n(I),t&&n(_),k(o),t&&n(Ae),t&&n(C),k(z),t&&n(Le),t&&n(w),t&&n(Ce),t&&n(pe),t&&n(Te),t&&n(ce),t&&n(qe),t&&n(fe),t&&n(Me),t&&n(de),t&&n(Ne),t&&n(h),k(J),k(X),k(q),k(Y),k(Z),k(te),k(N),k(ne),k(se)}}}const Nn={local:"superresolution",sections:[{local:"diffusers.StableDiffusionUpscalePipeline",title:"StableDiffusionUpscalePipeline"}],title:"Super-Resolution"};function On(re){return Cn(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Bn extends Un{constructor(m){super();jn(this,m,On,Mn,An,{})}}export{Bn as default,Nn as metadata};
