import{S as Is,i as Us,s as js,e as n,k as p,w as P,t as r,M as As,c as a,d as s,m as c,a as o,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 Ls,L as Es}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 Ss}from"../../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function Cs(re){let m,I,_,d,y;return d=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(){m=n("p"),I=r("Examples:"),_=p(),P(d.$$.fragment)},l(i){m=a(i,"P",{});var v=o(m);I=l(v,"Examples:"),v.forEach(s),_=c(i),x(d.$$.fragment,i)},m(i,v){g(i,m,v),e(m,I),g(i,_,v),D(d,i,v),y=!0},p:Es,i(i){y||(S(d.$$.fragment,i),y=!0)},o(i){E(d.$$.fragment,i),y=!1},d(i){i&&s(m),i&&s(_),k(d,i)}}}function Ts(re){let m,I,_,d,y;return d=new ks({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=n("p"),I=r("Examples:"),_=p(),P(d.$$.fragment)},l(i){m=a(i,"P",{});var v=o(m);I=l(v,"Examples:"),v.forEach(s),_=c(i),x(d.$$.fragment,i)},m(i,v){g(i,m,v),e(m,I),g(i,_,v),D(d,i,v),y=!0},p:Es,i(i){y||(S(d.$$.fragment,i),y=!0)},o(i){E(d.$$.fragment,i),y=!1},d(i){i&&s(m),i&&s(_),k(d,i)}}}function qs(re){let m,I,_,d,y,i,v,ge,Je,Ae,C,T,_e,z,Qe,be,Xe,Le,w,Ye,G,Ze,et,W,tt,st,V,nt,at,le,ot,it,Ce,pe,rt,Te,ce,B,ve,lt,pt,R,ct,qe,fe,ft,Me,de,K,ye,dt,ut,H,mt,Oe,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,Ot,Ee,Nt,Ft,ke,zt,Gt,O,Wt,N,se,Vt,Ie,Bt,Rt,F,ne,Kt,ae,Ht,Ue,Jt,Qt,Ne;return i=new Ds({}),z=new Ds({}),J=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/v0.12.0/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/v0.12.0/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/v0.12.0/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/v0.12.0/en/api/schedulers/ddpm#diffusers.DDPMScheduler">DDPMScheduler</a>.`,name:"low_res_scheduler"},{anchor:"diffusers.StableDiffusionUpscalePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.12.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.12.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, <a href="/docs/diffusers/v0.12.0/en/api/schedulers/lms_discrete#diffusers.LMSDiscreteScheduler">LMSDiscreteScheduler</a>, or <a href="/docs/diffusers/v0.12.0/en/api/schedulers/pndm#diffusers.PNDMScheduler">PNDMScheduler</a>.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py#L54"}}),X=new ie({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:": typing.Optional[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/v0.12.0/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/v0.12.0/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/v0.12.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py#L358",returnDescription:`
<p><a
  href="/docs/diffusers/v0.12.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.12.0/en/api/pipelines/stable_diffusion/overview#diffusers.pipelines.stable_diffusion.StableDiffusionPipelineOutput"
>StableDiffusionPipelineOutput</a> or <code>tuple</code></p>
`}}),q=new Ss({props:{anchor:"diffusers.StableDiffusionUpscalePipeline.__call__.example",$$slots:{default:[Cs]},$$scope:{ctx:re}}}),Y=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/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L902"}}),Z=new ie({props:{name:"disable_attention_slicing",anchor:"diffusers.StableDiffusionUpscalePipeline.disable_attention_slicing",parameters:[],source:"https://github.com/huggingface/diffusers/blob/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L918"}}),te=new ie({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/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L845"}}),O=new Ss({props:{anchor:"diffusers.StableDiffusionUpscalePipeline.enable_xformers_memory_efficient_attention.example",$$slots:{default:[Ts]},$$scope:{ctx:re}}}),se=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/v0.12.0/src/diffusers/pipelines/pipeline_utils.py#L877"}}),ne=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/v0.12.0/src/diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py#L102"}}),{c(){m=n("meta"),I=p(),_=n("h1"),d=n("a"),y=n("span"),P(i.$$.fragment),v=p(),ge=n("span"),Je=r("Super-Resolution"),Ae=p(),C=n("h2"),T=n("a"),_e=n("span"),P(z.$$.fragment),Qe=p(),be=n("span"),Xe=r("StableDiffusionUpscalePipeline"),Le=p(),w=n("p"),Ye=r("The upscaler diffusion model was created by the researchers and engineers from "),G=n("a"),Ze=r("CompVis"),et=r(", "),W=n("a"),tt=r("Stability AI"),st=r(", and "),V=n("a"),nt=r("LAION"),at=r(", as part of Stable Diffusion 2.0. "),le=n("a"),ot=r("StableDiffusionUpscalePipeline"),it=r(" can be used to enhance the resolution of input images by a factor of 4."),Ce=p(),pe=n("p"),rt=r("The original codebase can be found here:"),Te=p(),ce=n("ul"),B=n("li"),ve=n("em"),lt=r("Stable Diffusion v2"),pt=r(": "),R=n("a"),ct=r("Stability-AI/stablediffusion"),qe=p(),fe=n("p"),ft=r("Available Checkpoints are:"),Me=p(),de=n("ul"),K=n("li"),ye=n("em"),dt=r("stabilityai/stable-diffusion-x4-upscaler (x4 resolution resolution)"),ut=r(": "),H=n("a"),mt=r("stable-diffusion-x4-upscaler"),Oe=p(),h=n("div"),P(J.$$.fragment),ht=p(),we=n("p"),gt=r("Pipeline for text-guided image super-resolution using Stable Diffusion 2."),_t=p(),Q=n("p"),bt=r("This model inherits from "),ue=n("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=n("div"),P(X.$$.fragment),$t=p(),$e=n("p"),Pt=r("Function invoked when calling the pipeline for generation."),xt=p(),P(q.$$.fragment),Dt=p(),j=n("div"),P(Y.$$.fragment),St=p(),Pe=n("p"),Et=r("Enable sliced attention computation."),kt=p(),xe=n("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=n("div"),P(Z.$$.fragment),jt=p(),ee=n("p"),At=r("Disable sliced attention computation. If "),De=n("code"),Lt=r("enable_attention_slicing"),Ct=r(` was previously invoked, this method will go
back to computing attention in one step.`),Tt=p(),$=n("div"),P(te.$$.fragment),qt=p(),Se=n("p"),Mt=r("Enable memory efficient attention as implemented in xformers."),Ot=p(),Ee=n("p"),Nt=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=n("p"),zt=r(`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),Gt=p(),P(O.$$.fragment),Wt=p(),N=n("div"),P(se.$$.fragment),Vt=p(),Ie=n("p"),Bt=r("Disable memory efficient attention as implemented in xformers."),Rt=p(),F=n("div"),P(ne.$$.fragment),Kt=p(),ae=n("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=n("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=As('[data-svelte="svelte-1phssyn"]',document.head);m=a(u,"META",{name:!0,content:!0}),u.forEach(s),I=c(t),_=a(t,"H1",{class:!0});var oe=o(_);d=a(oe,"A",{id:!0,class:!0,href:!0});var je=o(d);y=a(je,"SPAN",{});var Xt=o(y);x(i.$$.fragment,Xt),Xt.forEach(s),je.forEach(s),v=c(oe),ge=a(oe,"SPAN",{});var Yt=o(ge);Je=l(Yt,"Super-Resolution"),Yt.forEach(s),oe.forEach(s),Ae=c(t),C=a(t,"H2",{class:!0});var Fe=o(C);T=a(Fe,"A",{id:!0,class:!0,href:!0});var Zt=o(T);_e=a(Zt,"SPAN",{});var es=o(_e);x(z.$$.fragment,es),es.forEach(s),Zt.forEach(s),Qe=c(Fe),be=a(Fe,"SPAN",{});var ts=o(be);Xe=l(ts,"StableDiffusionUpscalePipeline"),ts.forEach(s),Fe.forEach(s),Le=c(t),w=a(t,"P",{});var A=o(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 ss=o(G);Ze=l(ss,"CompVis"),ss.forEach(s),et=l(A,", "),W=a(A,"A",{href:!0,rel:!0});var ns=o(W);tt=l(ns,"Stability AI"),ns.forEach(s),st=l(A,", and "),V=a(A,"A",{href:!0,rel:!0});var as=o(V);nt=l(as,"LAION"),as.forEach(s),at=l(A,", as part of Stable Diffusion 2.0. "),le=a(A,"A",{href:!0});var os=o(le);ot=l(os,"StableDiffusionUpscalePipeline"),os.forEach(s),it=l(A," can be used to enhance the resolution of input images by a factor of 4."),A.forEach(s),Ce=c(t),pe=a(t,"P",{});var is=o(pe);rt=l(is,"The original codebase can be found here:"),is.forEach(s),Te=c(t),ce=a(t,"UL",{});var rs=o(ce);B=a(rs,"LI",{});var ze=o(B);ve=a(ze,"EM",{});var ls=o(ve);lt=l(ls,"Stable Diffusion v2"),ls.forEach(s),pt=l(ze,": "),R=a(ze,"A",{href:!0,rel:!0});var ps=o(R);ct=l(ps,"Stability-AI/stablediffusion"),ps.forEach(s),ze.forEach(s),rs.forEach(s),qe=c(t),fe=a(t,"P",{});var cs=o(fe);ft=l(cs,"Available Checkpoints are:"),cs.forEach(s),Me=c(t),de=a(t,"UL",{});var fs=o(de);K=a(fs,"LI",{});var Ge=o(K);ye=a(Ge,"EM",{});var ds=o(ye);dt=l(ds,"stabilityai/stable-diffusion-x4-upscaler (x4 resolution resolution)"),ds.forEach(s),ut=l(Ge,": "),H=a(Ge,"A",{href:!0,rel:!0});var us=o(H);mt=l(us,"stable-diffusion-x4-upscaler"),us.forEach(s),Ge.forEach(s),fs.forEach(s),Oe=c(t),h=a(t,"DIV",{class:!0});var b=o(h);x(J.$$.fragment,b),ht=c(b),we=a(b,"P",{});var ms=o(we);gt=l(ms,"Pipeline for text-guided image super-resolution using Stable Diffusion 2."),ms.forEach(s),_t=c(b),Q=a(b,"P",{});var We=o(Q);bt=l(We,"This model inherits from "),ue=a(We,"A",{href:!0});var hs=o(ue);vt=l(hs,"DiffusionPipeline"),hs.forEach(s),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(s),wt=c(b),U=a(b,"DIV",{class:!0});var me=o(U);x(X.$$.fragment,me),$t=c(me),$e=a(me,"P",{});var gs=o($e);Pt=l(gs,"Function invoked when calling the pipeline for generation."),gs.forEach(s),xt=c(me),x(q.$$.fragment,me),me.forEach(s),Dt=c(b),j=a(b,"DIV",{class:!0});var he=o(j);x(Y.$$.fragment,he),St=c(he),Pe=a(he,"P",{});var _s=o(Pe);Et=l(_s,"Enable sliced attention computation."),_s.forEach(s),kt=c(he),xe=a(he,"P",{});var bs=o(xe);It=l(bs,`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.`),bs.forEach(s),he.forEach(s),Ut=c(b),M=a(b,"DIV",{class:!0});var Ve=o(M);x(Z.$$.fragment,Ve),jt=c(Ve),ee=a(Ve,"P",{});var Be=o(ee);At=l(Be,"Disable sliced attention computation. If "),De=a(Be,"CODE",{});var vs=o(De);Lt=l(vs,"enable_attention_slicing"),vs.forEach(s),Ct=l(Be,` was previously invoked, this method will go
back to computing attention in one step.`),Be.forEach(s),Ve.forEach(s),Tt=c(b),$=a(b,"DIV",{class:!0});var L=o($);x(te.$$.fragment,L),qt=c(L),Se=a(L,"P",{});var ys=o(Se);Mt=l(ys,"Enable memory efficient attention as implemented in xformers."),ys.forEach(s),Ot=c(L),Ee=a(L,"P",{});var ws=o(Ee);Nt=l(ws,`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.`),ws.forEach(s),Ft=c(L),ke=a(L,"P",{});var $s=o(ke);zt=l($s,`Warning: When Memory Efficient Attention and Sliced attention are both enabled, the Memory Efficient Attention
is used.`),$s.forEach(s),Gt=c(L),x(O.$$.fragment,L),L.forEach(s),Wt=c(b),N=a(b,"DIV",{class:!0});var Re=o(N);x(se.$$.fragment,Re),Vt=c(Re),Ie=a(Re,"P",{});var Ps=o(Ie);Bt=l(Ps,"Disable memory efficient attention as implemented in xformers."),Ps.forEach(s),Re.forEach(s),Rt=c(b),F=a(b,"DIV",{class:!0});var Ke=o(F);x(ne.$$.fragment,Ke),Kt=c(Ke),ae=a(Ke,"P",{});var He=o(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 xs=o(Ue);Jt=l(xs,"torch.device('meta') and loaded to GPU only when their specific submodule has its "),xs.forEach(s),Qt=l(He,"forward` method called."),He.forEach(s),Ke.forEach(s),b.forEach(s),this.h()},h(){f(m,"name","hf:doc:metadata"),f(m,"content",JSON.stringify(Ms)),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/v0.12.0/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/v0.12.0/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(N,"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(i,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,st),e(w,V),e(V,nt),e(w,at),e(w,le),e(le,ot),e(w,it),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,Oe,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($,Ot),e($,Ee),e(Ee,Nt),e($,Ft),e($,ke),e(ke,zt),e($,Gt),D(O,$,null),e(h,Wt),e(h,N),D(se,N,null),e(N,Vt),e(N,Ie),e(Ie,Bt),e(h,Rt),e(h,F),D(ne,F,null),e(F,Kt),e(F,ae),e(ae,Ht),e(ae,Ue),e(Ue,Jt),e(ae,Qt),Ne=!0},p(t,[u]){const oe={};u&2&&(oe.$$scope={dirty:u,ctx:t}),q.$set(oe);const je={};u&2&&(je.$$scope={dirty:u,ctx:t}),O.$set(je)},i(t){Ne||(S(i.$$.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(O.$$.fragment,t),S(se.$$.fragment,t),S(ne.$$.fragment,t),Ne=!0)},o(t){E(i.$$.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(O.$$.fragment,t),E(se.$$.fragment,t),E(ne.$$.fragment,t),Ne=!1},d(t){s(m),t&&s(I),t&&s(_),k(i),t&&s(Ae),t&&s(C),k(z),t&&s(Le),t&&s(w),t&&s(Ce),t&&s(pe),t&&s(Te),t&&s(ce),t&&s(qe),t&&s(fe),t&&s(Me),t&&s(de),t&&s(Oe),t&&s(h),k(J),k(X),k(q),k(Y),k(Z),k(te),k(O),k(se),k(ne)}}}const Ms={local:"superresolution",sections:[{local:"diffusers.StableDiffusionUpscalePipeline",title:"StableDiffusionUpscalePipeline"}],title:"Super-Resolution"};function Os(re){return Ls(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vs extends Is{constructor(m){super();Us(this,m,Os,qs,js,{})}}export{Vs as default,Ms as metadata};
