import{s as be,o as ye,n as $e}from"../chunks/scheduler.182ea377.js";import{S as Me,i as we,g as p,s as o,r as M,A as xe,h as d,f as n,c as r,j as Z,u as w,x as $,k as N,y as m,a as s,v as x,d as P,t as D,w as L}from"../chunks/index.abf12888.js";import{T as Pe}from"../chunks/Tip.230e2334.js";import{D as pe}from"../chunks/Docstring.93f6f462.js";import{C as De}from"../chunks/CodeBlock.57fe6e13.js";import{E as Le}from"../chunks/ExampleCodeBlock.658f5cd6.js";import{H as de}from"../chunks/Heading.16916d63.js";function Te(B){let i,_='Make sure to check out the Schedulers <a href="../../using-diffusers/schedulers">guide</a> to learn how to explore the tradeoff between scheduler speed and quality, and see the <a href="../../using-diffusers/loading#reuse-components-across-pipelines">reuse components across pipelines</a> section to learn how to efficiently load the same components into multiple pipelines.';return{c(){i=p("p"),i.innerHTML=_},l(l){i=d(l,"P",{"data-svelte-h":!0}),$(i)!=="svelte-1wmc0l4"&&(i.innerHTML=_)},m(l,c){s(l,i,c)},p:$e,d(l){l&&n(i)}}}function Ie(B){let i,_="Example:",l,c,f;return c=new De({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMExETVBpcGVsaW5lJTBBJTBBJTIzJTIwbG9hZCUyMG1vZGVsJTIwYW5kJTIwc2NoZWR1bGVyJTBBcGlwZSUyMCUzRCUyMExETVBpcGVsaW5lLmZyb21fcHJldHJhaW5lZCglMjJDb21wVmlzJTJGbGRtLWNlbGViYWhxLTI1NiUyMiklMEElMEElMjMlMjBydW4lMjBwaXBlbGluZSUyMGluJTIwaW5mZXJlbmNlJTIwKHNhbXBsZSUyMHJhbmRvbSUyMG5vaXNlJTIwYW5kJTIwZGVub2lzZSklMEFpbWFnZSUyMCUzRCUyMHBpcGUoKS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-meta">&gt;&gt;&gt; </span><span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> LDMPipeline

<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>pipe = LDMPipeline.from_pretrained(<span class="hljs-string">&quot;CompVis/ldm-celebahq-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>image = pipe().images[<span class="hljs-number">0</span>]`,wrap:!1}}),{c(){i=p("p"),i.textContent=_,l=o(),M(c.$$.fragment)},l(a){i=d(a,"P",{"data-svelte-h":!0}),$(i)!=="svelte-11lpom8"&&(i.textContent=_),l=r(a),w(c.$$.fragment,a)},m(a,g){s(a,i,g),s(a,l,g),x(c,a,g),f=!0},p:$e,i(a){f||(P(c.$$.fragment,a),f=!0)},o(a){D(c.$$.fragment,a),f=!1},d(a){a&&(n(i),n(l)),L(c,a)}}}function Ce(B){let i,_,l,c,f,a,g,ce='Unconditional Latent Diffusion was proposed in <a href="https://huggingface.co/papers/2112.10752" rel="nofollow">High-Resolution Image Synthesis with Latent Diffusion Models</a> by Robin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser, Björn Ommer.',W,C,ue="The abstract from the paper is:",R,U,fe="<em>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.</em>",A,G,me='The original codebase can be found at <a href="https://github.com/CompVis/latent-diffusion" rel="nofollow">CompVis/latent-diffusion</a>.',X,T,Q,k,F,u,V,ie,H,ge="Pipeline for unconditional image generation using latent diffusion.",se,j,he=`This model inherits from <a href="/docs/diffusers/v0.22.0/en/api/pipelines/overview#diffusers.DiffusionPipeline">DiffusionPipeline</a>. Check the superclass documentation for the generic methods
implemented for all pipelines (downloading, saving, running on a particular device, etc.).`,ae,v,E,oe,S,_e="The call function to the pipeline for generation.",re,I,Y,q,K,b,J,le,z,ve="Output class for image pipelines.",ee,O,te;return f=new de({props:{title:"Unconditional Latent Diffusion",local:"unconditional-latent-diffusion",headingTag:"h1"}}),T=new Pe({props:{$$slots:{default:[Te]},$$scope:{ctx:B}}}),k=new de({props:{title:"LDMPipeline",local:"diffusers.LDMPipeline",headingTag:"h2"}}),V=new pe({props:{name:"class diffusers.LDMPipeline",anchor:"diffusers.LDMPipeline",parameters:[{name:"vqvae",val:": VQModel"},{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": DDIMScheduler"}],parametersDescription:[{anchor:"diffusers.LDMPipeline.vqvae",description:`<strong>vqvae</strong> (<a href="/docs/diffusers/v0.22.0/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.LDMPipeline.unet",description:`<strong>unet</strong> (<a href="/docs/diffusers/v0.22.0/en/api/models/unet2d#diffusers.UNet2DModel">UNet2DModel</a>) &#x2014;
A <code>UNet2DModel</code> to denoise the encoded image latents.`,name:"unet"},{anchor:"diffusers.LDMPipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/v0.22.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a>) &#x2014;
<a href="/docs/diffusers/v0.22.0/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a> is used in combination with <code>unet</code> to denoise the encoded image latents.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.0/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py#L26"}}),E=new pe({props:{name:"__call__",anchor:"diffusers.LDMPipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"generator",val:": typing.Union[torch._C.Generator, typing.List[torch._C.Generator], NoneType] = None"},{name:"eta",val:": float = 0.0"},{name:"num_inference_steps",val:": int = 50"},{name:"output_type",val:": typing.Optional[str] = 'pil'"},{name:"return_dict",val:": bool = True"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.LDMPipeline.__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.LDMPipeline.__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.LDMPipeline.__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.LDMPipeline.__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.LDMPipeline.__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.22.0/en/api/pipelines/stable_unclip#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.0/src/diffusers/pipelines/latent_diffusion_uncond/pipeline_latent_diffusion_uncond.py#L46",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/v0.22.0/en/api/pipelines/stable_unclip#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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><a
  href="/docs/diffusers/v0.22.0/en/api/pipelines/stable_unclip#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),I=new Le({props:{anchor:"diffusers.LDMPipeline.__call__.example",$$slots:{default:[Ie]},$$scope:{ctx:B}}}),q=new de({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),J=new pe({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/v0.22.0/src/diffusers/pipelines/pipeline_utils.py#L110"}}),{c(){i=p("meta"),_=o(),l=p("p"),c=o(),M(f.$$.fragment),a=o(),g=p("p"),g.innerHTML=ce,W=o(),C=p("p"),C.textContent=ue,R=o(),U=p("p"),U.innerHTML=fe,A=o(),G=p("p"),G.innerHTML=me,X=o(),M(T.$$.fragment),Q=o(),M(k.$$.fragment),F=o(),u=p("div"),M(V.$$.fragment),ie=o(),H=p("p"),H.textContent=ge,se=o(),j=p("p"),j.innerHTML=he,ae=o(),v=p("div"),M(E.$$.fragment),oe=o(),S=p("p"),S.textContent=_e,re=o(),M(I.$$.fragment),Y=o(),M(q.$$.fragment),K=o(),b=p("div"),M(J.$$.fragment),le=o(),z=p("p"),z.textContent=ve,ee=o(),O=p("p"),this.h()},l(e){const t=xe("svelte-u9bgzb",document.head);i=d(t,"META",{name:!0,content:!0}),t.forEach(n),_=r(e),l=d(e,"P",{}),Z(l).forEach(n),c=r(e),w(f.$$.fragment,e),a=r(e),g=d(e,"P",{"data-svelte-h":!0}),$(g)!=="svelte-yxeqnc"&&(g.innerHTML=ce),W=r(e),C=d(e,"P",{"data-svelte-h":!0}),$(C)!=="svelte-1cwsb16"&&(C.textContent=ue),R=r(e),U=d(e,"P",{"data-svelte-h":!0}),$(U)!=="svelte-mfilaa"&&(U.innerHTML=fe),A=r(e),G=d(e,"P",{"data-svelte-h":!0}),$(G)!=="svelte-13wc5yz"&&(G.innerHTML=me),X=r(e),w(T.$$.fragment,e),Q=r(e),w(k.$$.fragment,e),F=r(e),u=d(e,"DIV",{class:!0});var h=Z(u);w(V.$$.fragment,h),ie=r(h),H=d(h,"P",{"data-svelte-h":!0}),$(H)!=="svelte-izlq44"&&(H.textContent=ge),se=r(h),j=d(h,"P",{"data-svelte-h":!0}),$(j)!=="svelte-cgt1gx"&&(j.innerHTML=he),ae=r(h),v=d(h,"DIV",{class:!0});var y=Z(v);w(E.$$.fragment,y),oe=r(y),S=d(y,"P",{"data-svelte-h":!0}),$(S)!=="svelte-50j04k"&&(S.textContent=_e),re=r(y),w(I.$$.fragment,y),y.forEach(n),h.forEach(n),Y=r(e),w(q.$$.fragment,e),K=r(e),b=d(e,"DIV",{class:!0});var ne=Z(b);w(J.$$.fragment,ne),le=r(ne),z=d(ne,"P",{"data-svelte-h":!0}),$(z)!=="svelte-19wetgi"&&(z.textContent=ve),ne.forEach(n),ee=r(e),O=d(e,"P",{}),Z(O).forEach(n),this.h()},h(){N(i,"name","hf:doc:metadata"),N(i,"content",Ue),N(v,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(b,"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,t){m(document.head,i),s(e,_,t),s(e,l,t),s(e,c,t),x(f,e,t),s(e,a,t),s(e,g,t),s(e,W,t),s(e,C,t),s(e,R,t),s(e,U,t),s(e,A,t),s(e,G,t),s(e,X,t),x(T,e,t),s(e,Q,t),x(k,e,t),s(e,F,t),s(e,u,t),x(V,u,null),m(u,ie),m(u,H),m(u,se),m(u,j),m(u,ae),m(u,v),x(E,v,null),m(v,oe),m(v,S),m(v,re),x(I,v,null),s(e,Y,t),x(q,e,t),s(e,K,t),s(e,b,t),x(J,b,null),m(b,le),m(b,z),s(e,ee,t),s(e,O,t),te=!0},p(e,[t]){const h={};t&2&&(h.$$scope={dirty:t,ctx:e}),T.$set(h);const y={};t&2&&(y.$$scope={dirty:t,ctx:e}),I.$set(y)},i(e){te||(P(f.$$.fragment,e),P(T.$$.fragment,e),P(k.$$.fragment,e),P(V.$$.fragment,e),P(E.$$.fragment,e),P(I.$$.fragment,e),P(q.$$.fragment,e),P(J.$$.fragment,e),te=!0)},o(e){D(f.$$.fragment,e),D(T.$$.fragment,e),D(k.$$.fragment,e),D(V.$$.fragment,e),D(E.$$.fragment,e),D(I.$$.fragment,e),D(q.$$.fragment,e),D(J.$$.fragment,e),te=!1},d(e){e&&(n(_),n(l),n(c),n(a),n(g),n(W),n(C),n(R),n(U),n(A),n(G),n(X),n(Q),n(F),n(u),n(Y),n(K),n(b),n(ee),n(O)),n(i),L(f,e),L(T,e),L(k,e),L(V),L(E),L(I),L(q,e),L(J)}}}const Ue='{"title":"Unconditional Latent Diffusion","local":"unconditional-latent-diffusion","sections":[{"title":"LDMPipeline","local":"diffusers.LDMPipeline","sections":[],"depth":2},{"title":"ImagePipelineOutput","local":"diffusers.ImagePipelineOutput","sections":[],"depth":2}],"depth":1}';function Ge(B){return ye(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class je extends Me{constructor(i){super(),we(this,i,Ge,Ce,be,{})}}export{je as component};
