import{S as ts,i as ss,s as ns,e as i,k as u,w as b,t as d,M as is,c as a,d as s,m as f,a as o,x as v,h as c,b as p,G as t,g as h,y as w,q as T,o as D,B as I,v as as,L as Kt}from"../../../chunks/vendor-hf-doc-builder.js";import{T as os}from"../../../chunks/Tip-hf-doc-builder.js";import{D as xe}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as es}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Ye}from"../../../chunks/IconCopyLink-hf-doc-builder.js";import{E as Ft}from"../../../chunks/ExampleCodeBlock-hf-doc-builder.js";function rs(Z){let r,M,g,m,y,n,_,L;return{c(){r=i("p"),M=d("Make sure to check out the Schedulers "),g=i("a"),m=d("guide"),y=d(" to learn how to explore the tradeoff between scheduler speed and quality, and see the "),n=i("a"),_=d("reuse components across pipelines"),L=d(" section to learn how to efficiently load the same components into multiple pipelines."),this.h()},l(B){r=a(B,"P",{});var $=o(r);M=c($,"Make sure to check out the Schedulers "),g=a($,"A",{href:!0});var S=o(g);m=c(S,"guide"),S.forEach(s),y=c($," to learn how to explore the tradeoff between scheduler speed and quality, and see the "),n=a($,"A",{href:!0});var re=o(n);_=c(re,"reuse components across pipelines"),re.forEach(s),L=c($," section to learn how to efficiently load the same components into multiple pipelines."),$.forEach(s),this.h()},h(){p(g,"href","/using-diffusers/schedulers"),p(n,"href","/using-diffusers/loading#reuse-components-across-pipelines")},m(B,$){h(B,r,$),t(r,M),t(r,g),t(g,m),t(r,y),t(r,n),t(n,_),t(r,L)},d(B){B&&s(r)}}}function ls(Z){let r,M,g,m,y;return m=new es({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTBBJTBBJTIzJTIwbG9hZCUyMG1vZGVsJTIwYW5kJTIwc2NoZWR1bGVyJTBBbGRtJTIwJTNEJTIwRGlmZnVzaW9uUGlwZWxpbmUuZnJvbV9wcmV0cmFpbmVkKCUyMkNvbXBWaXMlMkZsZG0tdGV4dDJpbS1sYXJnZS0yNTYlMjIpJTBBJTBBJTIzJTIwcnVuJTIwcGlwZWxpbmUlMjBpbiUyMGluZmVyZW5jZSUyMChzYW1wbGUlMjByYW5kb20lMjBub2lzZSUyMGFuZCUyMGRlbm9pc2UpJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMHBhaW50aW5nJTIwb2YlMjBhJTIwc3F1aXJyZWwlMjBlYXRpbmclMjBhJTIwYnVyZ2VyJTIyJTBBaW1hZ2VzJTIwJTNEJTIwbGRtKCU1QnByb21wdCU1RCUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0Q1MCUyQyUyMGV0YSUzRDAuMyUyQyUyMGd1aWRhbmNlX3NjYWxlJTNENikuaW1hZ2VzJTBBJTBBJTIzJTIwc2F2ZSUyMGltYWdlcyUwQWZvciUyMGlkeCUyQyUyMGltYWdlJTIwaW4lMjBlbnVtZXJhdGUoaW1hZ2VzKSUzQSUwQSUyMCUyMCUyMCUyMGltYWdlLnNhdmUoZiUyMnNxdWlycmVsLSU3QmlkeCU3RC5wbmclMjIp",highlighted:`<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-comment"># load model and scheduler</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>ldm = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/ldm-text2im-large-256&quot;</span>)

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># run pipeline in inference (sample random noise and denoise)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>prompt = <span class="hljs-string">&quot;A painting of a squirrel eating a burger&quot;</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>images = ldm([prompt], num_inference_steps=<span class="hljs-number">50</span>, eta=<span class="hljs-number">0.3</span>, guidance_scale=<span class="hljs-number">6</span>).images

<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save images</span>
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">for</span> idx, image <span class="hljs-keyword">in</span> <span class="hljs-built_in">enumerate</span>(images):
<span class="hljs-meta">... </span>    image.save(<span class="hljs-string">f&quot;squirrel-<span class="hljs-subst">{idx}</span>.png&quot;</span>)`}}),{c(){r=i("p"),M=d("Example:"),g=u(),b(m.$$.fragment)},l(n){r=a(n,"P",{});var _=o(r);M=c(_,"Example:"),_.forEach(s),g=f(n),v(m.$$.fragment,n)},m(n,_){h(n,r,_),t(r,M),h(n,g,_),w(m,n,_),y=!0},p:Kt,i(n){y||(T(m.$$.fragment,n),y=!0)},o(n){D(m.$$.fragment,n),y=!1},d(n){n&&s(r),n&&s(g),I(m,n)}}}function ps(Z){let r,M,g,m,y;return m=new es({props:{code:"aW1wb3J0JTIwcmVxdWVzdHMlMEFmcm9tJTIwUElMJTIwaW1wb3J0JTIwSW1hZ2UlMEFmcm9tJTIwaW8lMjBpbXBvcnQlMjBCeXRlc0lPJTBBZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExETVN1cGVyUmVzb2x1dGlvblBpcGVsaW5lJTBBaW1wb3J0JTIwdG9yY2glMEElMEElMjMlMjBsb2FkJTIwbW9kZWwlMjBhbmQlMjBzY2hlZHVsZXIlMEFwaXBlbGluZSUyMCUzRCUyMExETVN1cGVyUmVzb2x1dGlvblBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJDb21wVmlzJTJGbGRtLXN1cGVyLXJlc29sdXRpb24tNHgtb3BlbmltYWdlcyUyMiklMEFwaXBlbGluZSUyMCUzRCUyMHBpcGVsaW5lLnRvKCUyMmN1ZGElMjIpJTBBJTBBJTIzJTIwbGV0J3MlMjBkb3dubG9hZCUyMGFuJTIwJTIwaW1hZ2UlMEF1cmwlMjAlM0QlMjAoJTBBJTIwJTIwJTIwJTIwJTIyaHR0cHMlM0ElMkYlMkZ1c2VyLWltYWdlcy5naXRodWJ1c2VyY29udGVudC5jb20lMkYzODA2MTY1OSUyRjE5OTcwNTg5Ni1iNDhlMTdiOC1iMjMxLTQ3Y2QtYTI3MC00ZmZhNWE5M2ZhM2UucG5nJTIyJTBBKSUwQXJlc3BvbnNlJTIwJTNEJTIwcmVxdWVzdHMuZ2V0KHVybCklMEFsb3dfcmVzX2ltZyUyMCUzRCUyMEltYWdlLm9wZW4oQnl0ZXNJTyhyZXNwb25zZS5jb250ZW50KSkuY29udmVydCglMjJSR0IlMjIpJTBBbG93X3Jlc19pbWclMjAlM0QlMjBsb3dfcmVzX2ltZy5yZXNpemUoKDEyOCUyQyUyMDEyOCkpJTBBJTBBJTIzJTIwcnVuJTIwcGlwZWxpbmUlMjBpbiUyMGluZmVyZW5jZSUyMChzYW1wbGUlMjByYW5kb20lMjBub2lzZSUyMGFuZCUyMGRlbm9pc2UpJTBBdXBzY2FsZWRfaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShsb3dfcmVzX2ltZyUyQyUyMG51bV9pbmZlcmVuY2Vfc3RlcHMlM0QxMDAlMkMlMjBldGElM0QxKS5pbWFnZXMlNUIwJTVEJTBBJTIzJTIwc2F2ZSUyMGltYWdlJTBBdXBzY2FsZWRfaW1hZ2Uuc2F2ZSglMjJsZG1fZ2VuZXJhdGVkX2ltYWdlLnBuZyUyMik=",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> LDMSuperResolutionPipeline
<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>pipeline = LDMSuperResolutionPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/ldm-super-resolution-4x-openimages&quot;</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-meta">... </span>    <span class="hljs-string">&quot;https://user-images.githubusercontent.com/38061659/199705896-b48e17b8-b231-47cd-a270-4ffa5a93fa3e.png&quot;</span>
<span class="hljs-meta">... </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><span class="hljs-comment"># run pipeline in inference (sample random noise and denoise)</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>upscaled_image = pipeline(low_res_img, num_inference_steps=<span class="hljs-number">100</span>, eta=<span class="hljs-number">1</span>).images[<span class="hljs-number">0</span>]
<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-comment"># save image</span>
<span class="hljs-meta">&gt;&gt;&gt; </span>upscaled_image.save(<span class="hljs-string">&quot;ldm_generated_image.png&quot;</span>)`}}),{c(){r=i("p"),M=d("Example:"),g=u(),b(m.$$.fragment)},l(n){r=a(n,"P",{});var _=o(r);M=c(_,"Example:"),_.forEach(s),g=f(n),v(m.$$.fragment,n)},m(n,_){h(n,r,_),t(r,M),h(n,g,_),w(m,n,_),y=!0},p:Kt,i(n){y||(T(m.$$.fragment,n),y=!0)},o(n){D(m.$$.fragment,n),y=!1},d(n){n&&s(r),n&&s(g),I(m,n)}}}function ds(Z){let r,M,g,m,y,n,_,L,B,$,S,re,Y,Qe,Xe,Se,le,He,je,pe,me,Fe,Ue,V,Ke,Q,et,tt,Le,C,Be,J,N,he,X,st,ge,nt,Je,P,H,it,_e,at,ot,F,rt,de,lt,pt,dt,j,K,ct,ye,ut,ft,R,Ee,E,W,Me,ee,mt,be,ht,ke,x,te,gt,ve,_t,yt,se,Mt,ce,bt,vt,wt,U,ne,Tt,we,Dt,It,z,Ge,k,q,Te,ie,$t,De,Pt,Ze,G,ae,xt,Ie,St,Ve;return n=new Ye({}),C=new os({props:{$$slots:{default:[rs]},$$scope:{ctx:Z}}}),X=new Ye({}),H=new xe({props:{name:"class diffusers.LDMTextToImagePipeline",anchor:"diffusers.LDMTextToImagePipeline",parameters:[{name:"vqvae",val:": typing.Union[diffusers.models.vq_model.VQModel, diffusers.models.autoencoder_kl.AutoencoderKL]"},{name:"bert",val:": PreTrainedModel"},{name:"tokenizer",val:": PreTrainedTokenizer"},{name:"unet",val:": typing.Union[diffusers.models.unet_2d.UNet2DModel, diffusers.models.unet_2d_condition.UNet2DConditionModel]"},{name:"scheduler",val:": typing.Union[diffusers.schedulers.scheduling_ddim.DDIMScheduler, diffusers.schedulers.scheduling_pndm.PNDMScheduler, diffusers.schedulers.scheduling_lms_discrete.LMSDiscreteScheduler]"}],parametersDescription:[{anchor:"diffusers.LDMTextToImagePipeline.vqvae",description:`<strong>vqvae</strong> (<a href="/docs/diffusers/main/en/api/models/vq#diffusers.VQModel">VQModel</a>) &#x2014;
Vector-quantized (VQ) model to encode and decode images to and from latent representations.`,name:"vqvae"},{anchor:"diffusers.LDMTextToImagePipeline.bert",description:`<strong>bert</strong> (<code>LDMBertModel</code>) &#x2014;
Text-encoder model based on <code>BERT</code>.`,name:"bert"},{anchor:"diffusers.LDMTextToImagePipeline.tokenizer",description:`<strong>tokenizer</strong> (<a href="https://huggingface.co/docs/transformers/main/en/model_doc/bert#transformers.BertTokenizer" rel="nofollow">BertTokenizer</a>) &#x2014;
A <code>BertTokenizer</code> to tokenize text.`,name:"tokenizer"},{anchor:"diffusers.LDMTextToImagePipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d-cond#diffusers.UNet2DConditionModel">UNet2DConditionModel</a>) &#x2014;
A <code>UNet2DConditionModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.LDMTextToImagePipeline.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/latent_diffusion/pipeline_latent_diffusion.py#L32"}}),K=new xe({props:{name:"__call__",anchor:"diffusers.LDMTextToImagePipeline.__call__",parameters:[{name:"prompt",val:": typing.Union[str, typing.List[str]]"},{name:"height",val:": typing.Optional[int] = None"},{name:"width",val:": typing.Optional[int] = None"},{name:"num_inference_steps",val:": typing.Optional[int] = 50"},{name:"guidance_scale",val:": typing.Optional[float] = 1.0"},{name:"eta",val:": typing.Optional[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:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.LDMTextToImagePipeline.__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.LDMTextToImagePipeline.__call__.height",description:`<strong>height</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The height in pixels of the generated image.`,name:"height"},{anchor:"diffusers.LDMTextToImagePipeline.__call__.width",description:`<strong>width</strong> (<code>int</code>, <em>optional</em>, defaults to <code>self.unet.config.sample_size * self.vae_scale_factor</code>) &#x2014;
The width in pixels of the generated image.`,name:"width"},{anchor:"diffusers.LDMTextToImagePipeline.__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.LDMTextToImagePipeline.__call__.guidance_scale",description:`<strong>guidance_scale</strong> (<code>float</code>, <em>optional</em>, defaults to 1.0) &#x2014;
A higher guidance scale value encourages the model to generate images closely linked to the text
<code>prompt</code> at the expense of lower image quality. Guidance scale is enabled when <code>guidance_scale &gt; 1</code>.`,name:"guidance_scale"},{anchor:"diffusers.LDMTextToImagePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.LDMTextToImagePipeline.__call__.latents",description:`<strong>latents</strong> (<code>torch.FloatTensor</code>, <em>optional</em>) &#x2014;
Pre-generated noisy latents sampled from a Gaussian distribution, to be used as inputs for image
generation. Can be used to tweak the same generation with different prompts. If not provided, a latents
tensor is generated by sampling using the supplied random <code>generator</code>.`,name:"latents"},{anchor:"diffusers.LDMTextToImagePipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.LDMTextToImagePipeline.__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/latent_diffusion#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion.py#L65",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images.</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),R=new Ft({props:{anchor:"diffusers.LDMTextToImagePipeline.__call__.example",$$slots:{default:[ls]},$$scope:{ctx:Z}}}),ee=new Ye({}),te=new xe({props:{name:"class diffusers.LDMSuperResolutionPipeline",anchor:"diffusers.LDMSuperResolutionPipeline",parameters:[{name:"vqvae",val:": VQModel"},{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": typing.Union[diffusers.schedulers.scheduling_ddim.DDIMScheduler, diffusers.schedulers.scheduling_pndm.PNDMScheduler, diffusers.schedulers.scheduling_lms_discrete.LMSDiscreteScheduler, diffusers.schedulers.scheduling_euler_discrete.EulerDiscreteScheduler, diffusers.schedulers.scheduling_euler_ancestral_discrete.EulerAncestralDiscreteScheduler, diffusers.schedulers.scheduling_dpmsolver_multistep.DPMSolverMultistepScheduler]"}],parametersDescription:[{anchor:"diffusers.LDMSuperResolutionPipeline.vqvae",description:`<strong>vqvae</strong> (<a href="/docs/diffusers/main/en/api/models/vq#diffusers.VQModel">VQModel</a>) &#x2014;
Vector-quantized (VQ) model to encode and decode images to and from latent representations.`,name:"vqvae"},{anchor:"diffusers.LDMSuperResolutionPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/main/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) &#x2014;
A <code>UNet2DModel</code> to denoise the encoded image.`,name:"unet"},{anchor:"diffusers.LDMSuperResolutionPipeline.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 latens. 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>, <a href="/docs/diffusers/main/en/api/schedulers/euler#diffusers.EulerDiscreteScheduler">EulerDiscreteScheduler</a>,
<a href="/docs/diffusers/main/en/api/schedulers/euler_ancestral#diffusers.EulerAncestralDiscreteScheduler">EulerAncestralDiscreteScheduler</a>, <a href="/docs/diffusers/main/en/api/schedulers/multistep_dpm_solver#diffusers.DPMSolverMultistepScheduler">DPMSolverMultistepScheduler</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/latent_diffusion/pipeline_latent_diffusion_superresolution.py#L32"}}),ne=new xe({props:{name:"__call__",anchor:"diffusers.LDMSuperResolutionPipeline.__call__",parameters:[{name:"image",val:": typing.Union[torch.Tensor, PIL.Image.Image] = None"},{name:"batch_size",val:": typing.Optional[int] = 1"},{name:"num_inference_steps",val:": typing.Optional[int] = 100"},{name:"eta",val:": typing.Optional[float] = 0.0"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.LDMSuperResolutionPipeline.__call__.image",description:`<strong>image</strong> (<code>torch.Tensor</code> or <code>PIL.Image.Image</code>) &#x2014;
<code>Image</code> or tensor representing an image batch to be used as the starting point for the process.`,name:"image"},{anchor:"diffusers.LDMSuperResolutionPipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
Number of images to generate.`,name:"batch_size"},{anchor:"diffusers.LDMSuperResolutionPipeline.__call__.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>, <em>optional</em>, defaults to 100) &#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.LDMSuperResolutionPipeline.__call__.eta",description:`<strong>eta</strong> (<code>float</code>, <em>optional</em>, defaults to 0.0) &#x2014;
Corresponds to parameter eta (&#x3B7;) from the <a href="https://arxiv.org/abs/2010.02502" rel="nofollow">DDIM</a> paper. Only applies
to the <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>, and is ignored in other schedulers.`,name:"eta"},{anchor:"diffusers.LDMSuperResolutionPipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code> or <code>List[torch.Generator]</code>, <em>optional</em>) &#x2014;
A <a href="https://pytorch.org/docs/stable/generated/torch.Generator.html" rel="nofollow"><code>torch.Generator</code></a> to make
generation deterministic.`,name:"generator"},{anchor:"diffusers.LDMSuperResolutionPipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <em>optional</em>, defaults to <code>&quot;pil&quot;</code>) &#x2014;
The output format of the generated image. Choose between <code>PIL.Image</code> or <code>np.array</code>.`,name:"output_type"},{anchor:"diffusers.LDMSuperResolutionPipeline.__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/latent_diffusion#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/latent_diffusion/pipeline_latent_diffusion_superresolution.py#L66",returnDescription:`
<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> is returned, otherwise a <code>tuple</code> is
returned where the first element is a list with the generated images</p>
`,returnType:`
<p><a
  href="/docs/diffusers/main/en/api/pipelines/latent_diffusion#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),z=new Ft({props:{anchor:"diffusers.LDMSuperResolutionPipeline.__call__.example",$$slots:{default:[ps]},$$scope:{ctx:Z}}}),ie=new Ye({}),ae=new xe({props:{name:"class diffusers.ImagePipelineOutput",anchor:"diffusers.ImagePipelineOutput",parameters:[{name:"images",val:": typing.Union[typing.List[PIL.Image.Image], numpy.ndarray]"}],parametersDescription:[{anchor:"diffusers.ImagePipelineOutput.images",description:`<strong>images</strong> (<code>List[PIL.Image.Image]</code> or <code>np.ndarray</code>) &#x2014;
List of denoised PIL images of length <code>batch_size</code> or NumPy array of shape <code>(batch_size, height, width, num_channels)</code>.`,name:"images"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/pipeline_utils.py#L113"}}),{c(){r=i("meta"),M=u(),g=i("h1"),m=i("a"),y=i("span"),b(n.$$.fragment),_=u(),L=i("span"),B=d("Latent Diffusion"),$=u(),S=i("p"),re=d("Latent Diffusion was proposed in "),Y=i("a"),Qe=d("High-Resolution Image Synthesis with Latent Diffusion Models"),Xe=d(" by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Bj\xF6rn Ommer."),Se=u(),le=i("p"),He=d("The abstract from the paper is:"),je=u(),pe=i("p"),me=i("em"),Fe=d("By decomposing the image formation process into a sequential application of denoising autoencoders, diffusion models (DMs) achieve state-of-the-art synthesis results on image data and beyond. Additionally, their formulation allows for a guiding mechanism to control the image generation process without retraining. However, since these models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. To enable DM training on limited computational resources while retaining their quality and flexibility, we apply them in the latent space of powerful pretrained autoencoders. In contrast to previous work, training diffusion models on such a representation allows for the first time to reach a near-optimal point between complexity reduction and detail preservation, greatly boosting visual fidelity. By introducing cross-attention layers into the model architecture, we turn diffusion models into powerful and flexible generators for general conditioning inputs such as text or bounding boxes and high-resolution synthesis becomes possible in a convolutional manner. Our latent diffusion models (LDMs) achieve a new state of the art for image inpainting and highly competitive performance on various tasks, including unconditional image generation, semantic scene synthesis, and super-resolution, while significantly reducing computational requirements compared to pixel-based DMs."),Ue=u(),V=i("p"),Ke=d("The original codebase can be found at "),Q=i("a"),et=d("Compvis/latent-diffusion"),tt=d("."),Le=u(),b(C.$$.fragment),Be=u(),J=i("h2"),N=i("a"),he=i("span"),b(X.$$.fragment),st=u(),ge=i("span"),nt=d("LDMTextToImagePipeline"),Je=u(),P=i("div"),b(H.$$.fragment),it=u(),_e=i("p"),at=d("Pipeline for text-to-image generation using latent diffusion."),ot=u(),F=i("p"),rt=d("This model inherits from "),de=i("a"),lt=d("DiffusionPipeline"),pt=d(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),dt=u(),j=i("div"),b(K.$$.fragment),ct=u(),ye=i("p"),ut=d("The call function to the pipeline for generation."),ft=u(),b(R.$$.fragment),Ee=u(),E=i("h2"),W=i("a"),Me=i("span"),b(ee.$$.fragment),mt=u(),be=i("span"),ht=d("LDMSuperResolutionPipeline"),ke=u(),x=i("div"),b(te.$$.fragment),gt=u(),ve=i("p"),_t=d("A pipeline for image super-resolution using latent diffusion."),yt=u(),se=i("p"),Mt=d("This model inherits from "),ce=i("a"),bt=d("DiffusionPipeline"),vt=d(`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),wt=u(),U=i("div"),b(ne.$$.fragment),Tt=u(),we=i("p"),Dt=d("The call function to the pipeline for generation."),It=u(),b(z.$$.fragment),Ge=u(),k=i("h2"),q=i("a"),Te=i("span"),b(ie.$$.fragment),$t=u(),De=i("span"),Pt=d("ImagePipelineOutput"),Ze=u(),G=i("div"),b(ae.$$.fragment),xt=u(),Ie=i("p"),St=d("Output class for image pipelines."),this.h()},l(e){const l=is('[data-svelte="svelte-1phssyn"]',document.head);r=a(l,"META",{name:!0,content:!0}),l.forEach(s),M=f(e),g=a(e,"H1",{class:!0});var oe=o(g);m=a(oe,"A",{id:!0,class:!0,href:!0});var $e=o(m);y=a($e,"SPAN",{});var Pe=o(y);v(n.$$.fragment,Pe),Pe.forEach(s),$e.forEach(s),_=f(oe),L=a(oe,"SPAN",{});var jt=o(L);B=c(jt,"Latent Diffusion"),jt.forEach(s),oe.forEach(s),$=f(e),S=a(e,"P",{});var Ce=o(S);re=c(Ce,"Latent Diffusion was proposed in "),Y=a(Ce,"A",{href:!0,rel:!0});var Ut=o(Y);Qe=c(Ut,"High-Resolution Image Synthesis with Latent Diffusion Models"),Ut.forEach(s),Xe=c(Ce," by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Bj\xF6rn Ommer."),Ce.forEach(s),Se=f(e),le=a(e,"P",{});var Lt=o(le);He=c(Lt,"The abstract from the paper is:"),Lt.forEach(s),je=f(e),pe=a(e,"P",{});var Bt=o(pe);me=a(Bt,"EM",{});var Jt=o(me);Fe=c(Jt,"By decomposing the image formation process into a sequential application of denoising autoencoders, diffusion models (DMs) achieve state-of-the-art synthesis results on image data and beyond. Additionally, their formulation allows for a guiding mechanism to control the image generation process without retraining. However, since these models typically operate directly in pixel space, optimization of powerful DMs often consumes hundreds of GPU days and inference is expensive due to sequential evaluations. To enable DM training on limited computational resources while retaining their quality and flexibility, we apply them in the latent space of powerful pretrained autoencoders. In contrast to previous work, training diffusion models on such a representation allows for the first time to reach a near-optimal point between complexity reduction and detail preservation, greatly boosting visual fidelity. By introducing cross-attention layers into the model architecture, we turn diffusion models into powerful and flexible generators for general conditioning inputs such as text or bounding boxes and high-resolution synthesis becomes possible in a convolutional manner. Our latent diffusion models (LDMs) achieve a new state of the art for image inpainting and highly competitive performance on various tasks, including unconditional image generation, semantic scene synthesis, and super-resolution, while significantly reducing computational requirements compared to pixel-based DMs."),Jt.forEach(s),Bt.forEach(s),Ue=f(e),V=a(e,"P",{});var Ne=o(V);Ke=c(Ne,"The original codebase can be found at "),Q=a(Ne,"A",{href:!0,rel:!0});var Et=o(Q);et=c(Et,"Compvis/latent-diffusion"),Et.forEach(s),tt=c(Ne,"."),Ne.forEach(s),Le=f(e),v(C.$$.fragment,e),Be=f(e),J=a(e,"H2",{class:!0});var Re=o(J);N=a(Re,"A",{id:!0,class:!0,href:!0});var kt=o(N);he=a(kt,"SPAN",{});var Gt=o(he);v(X.$$.fragment,Gt),Gt.forEach(s),kt.forEach(s),st=f(Re),ge=a(Re,"SPAN",{});var Zt=o(ge);nt=c(Zt,"LDMTextToImagePipeline"),Zt.forEach(s),Re.forEach(s),Je=f(e),P=a(e,"DIV",{class:!0});var O=o(P);v(H.$$.fragment,O),it=f(O),_e=a(O,"P",{});var Vt=o(_e);at=c(Vt,"Pipeline for text-to-image generation using latent diffusion."),Vt.forEach(s),ot=f(O),F=a(O,"P",{});var We=o(F);rt=c(We,"This model inherits from "),de=a(We,"A",{href:!0});var Ct=o(de);lt=c(Ct,"DiffusionPipeline"),Ct.forEach(s),pt=c(We,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),We.forEach(s),dt=f(O),j=a(O,"DIV",{class:!0});var ue=o(j);v(K.$$.fragment,ue),ct=f(ue),ye=a(ue,"P",{});var Nt=o(ye);ut=c(Nt,"The call function to the pipeline for generation."),Nt.forEach(s),ft=f(ue),v(R.$$.fragment,ue),ue.forEach(s),O.forEach(s),Ee=f(e),E=a(e,"H2",{class:!0});var ze=o(E);W=a(ze,"A",{id:!0,class:!0,href:!0});var Rt=o(W);Me=a(Rt,"SPAN",{});var Wt=o(Me);v(ee.$$.fragment,Wt),Wt.forEach(s),Rt.forEach(s),mt=f(ze),be=a(ze,"SPAN",{});var zt=o(be);ht=c(zt,"LDMSuperResolutionPipeline"),zt.forEach(s),ze.forEach(s),ke=f(e),x=a(e,"DIV",{class:!0});var A=o(x);v(te.$$.fragment,A),gt=f(A),ve=a(A,"P",{});var qt=o(ve);_t=c(qt,"A pipeline for image super-resolution using latent diffusion."),qt.forEach(s),yt=f(A),se=a(A,"P",{});var qe=o(se);Mt=c(qe,"This model inherits from "),ce=a(qe,"A",{href:!0});var Ot=o(ce);bt=c(Ot,"DiffusionPipeline"),Ot.forEach(s),vt=c(qe,`. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`),qe.forEach(s),wt=f(A),U=a(A,"DIV",{class:!0});var fe=o(U);v(ne.$$.fragment,fe),Tt=f(fe),we=a(fe,"P",{});var At=o(we);Dt=c(At,"The call function to the pipeline for generation."),At.forEach(s),It=f(fe),v(z.$$.fragment,fe),fe.forEach(s),A.forEach(s),Ge=f(e),k=a(e,"H2",{class:!0});var Oe=o(k);q=a(Oe,"A",{id:!0,class:!0,href:!0});var Yt=o(q);Te=a(Yt,"SPAN",{});var Qt=o(Te);v(ie.$$.fragment,Qt),Qt.forEach(s),Yt.forEach(s),$t=f(Oe),De=a(Oe,"SPAN",{});var Xt=o(De);Pt=c(Xt,"ImagePipelineOutput"),Xt.forEach(s),Oe.forEach(s),Ze=f(e),G=a(e,"DIV",{class:!0});var Ae=o(G);v(ae.$$.fragment,Ae),xt=f(Ae),Ie=a(Ae,"P",{});var Ht=o(Ie);St=c(Ht,"Output class for image pipelines."),Ht.forEach(s),Ae.forEach(s),this.h()},h(){p(r,"name","hf:doc:metadata"),p(r,"content",JSON.stringify(cs)),p(m,"id","latent-diffusion"),p(m,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(m,"href","#latent-diffusion"),p(g,"class","relative group"),p(Y,"href","https://huggingface.co/papers/2112.10752"),p(Y,"rel","nofollow"),p(Q,"href","https://github.com/CompVis/latent-diffusion"),p(Q,"rel","nofollow"),p(N,"id","diffusers.LDMTextToImagePipeline"),p(N,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(N,"href","#diffusers.LDMTextToImagePipeline"),p(J,"class","relative group"),p(de,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(j,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(P,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(W,"id","diffusers.LDMSuperResolutionPipeline"),p(W,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(W,"href","#diffusers.LDMSuperResolutionPipeline"),p(E,"class","relative group"),p(ce,"href","/docs/diffusers/main/en/api/pipelines/overview#diffusers.DiffusionPipeline"),p(U,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),p(q,"id","diffusers.ImagePipelineOutput"),p(q,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),p(q,"href","#diffusers.ImagePipelineOutput"),p(k,"class","relative group"),p(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(e,l){t(document.head,r),h(e,M,l),h(e,g,l),t(g,m),t(m,y),w(n,y,null),t(g,_),t(g,L),t(L,B),h(e,$,l),h(e,S,l),t(S,re),t(S,Y),t(Y,Qe),t(S,Xe),h(e,Se,l),h(e,le,l),t(le,He),h(e,je,l),h(e,pe,l),t(pe,me),t(me,Fe),h(e,Ue,l),h(e,V,l),t(V,Ke),t(V,Q),t(Q,et),t(V,tt),h(e,Le,l),w(C,e,l),h(e,Be,l),h(e,J,l),t(J,N),t(N,he),w(X,he,null),t(J,st),t(J,ge),t(ge,nt),h(e,Je,l),h(e,P,l),w(H,P,null),t(P,it),t(P,_e),t(_e,at),t(P,ot),t(P,F),t(F,rt),t(F,de),t(de,lt),t(F,pt),t(P,dt),t(P,j),w(K,j,null),t(j,ct),t(j,ye),t(ye,ut),t(j,ft),w(R,j,null),h(e,Ee,l),h(e,E,l),t(E,W),t(W,Me),w(ee,Me,null),t(E,mt),t(E,be),t(be,ht),h(e,ke,l),h(e,x,l),w(te,x,null),t(x,gt),t(x,ve),t(ve,_t),t(x,yt),t(x,se),t(se,Mt),t(se,ce),t(ce,bt),t(se,vt),t(x,wt),t(x,U),w(ne,U,null),t(U,Tt),t(U,we),t(we,Dt),t(U,It),w(z,U,null),h(e,Ge,l),h(e,k,l),t(k,q),t(q,Te),w(ie,Te,null),t(k,$t),t(k,De),t(De,Pt),h(e,Ze,l),h(e,G,l),w(ae,G,null),t(G,xt),t(G,Ie),t(Ie,St),Ve=!0},p(e,[l]){const oe={};l&2&&(oe.$$scope={dirty:l,ctx:e}),C.$set(oe);const $e={};l&2&&($e.$$scope={dirty:l,ctx:e}),R.$set($e);const Pe={};l&2&&(Pe.$$scope={dirty:l,ctx:e}),z.$set(Pe)},i(e){Ve||(T(n.$$.fragment,e),T(C.$$.fragment,e),T(X.$$.fragment,e),T(H.$$.fragment,e),T(K.$$.fragment,e),T(R.$$.fragment,e),T(ee.$$.fragment,e),T(te.$$.fragment,e),T(ne.$$.fragment,e),T(z.$$.fragment,e),T(ie.$$.fragment,e),T(ae.$$.fragment,e),Ve=!0)},o(e){D(n.$$.fragment,e),D(C.$$.fragment,e),D(X.$$.fragment,e),D(H.$$.fragment,e),D(K.$$.fragment,e),D(R.$$.fragment,e),D(ee.$$.fragment,e),D(te.$$.fragment,e),D(ne.$$.fragment,e),D(z.$$.fragment,e),D(ie.$$.fragment,e),D(ae.$$.fragment,e),Ve=!1},d(e){s(r),e&&s(M),e&&s(g),I(n),e&&s($),e&&s(S),e&&s(Se),e&&s(le),e&&s(je),e&&s(pe),e&&s(Ue),e&&s(V),e&&s(Le),I(C,e),e&&s(Be),e&&s(J),I(X),e&&s(Je),e&&s(P),I(H),I(K),I(R),e&&s(Ee),e&&s(E),I(ee),e&&s(ke),e&&s(x),I(te),I(ne),I(z),e&&s(Ge),e&&s(k),I(ie),e&&s(Ze),e&&s(G),I(ae)}}}const cs={local:"latent-diffusion",sections:[{local:"diffusers.LDMTextToImagePipeline",title:"LDMTextToImagePipeline"},{local:"diffusers.LDMSuperResolutionPipeline",title:"LDMSuperResolutionPipeline"},{local:"diffusers.ImagePipelineOutput",title:"ImagePipelineOutput"}],title:"Latent Diffusion"};function us(Z){return as(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ms extends ts{constructor(r){super();ss(this,r,us,ds,ns,{})}}export{Ms as default,cs as metadata};
