import{s as _e,o as ve,n as be}from"../chunks/scheduler.182ea377.js";import{S as $e,i as Se,g as s,s as r,r as T,A as we,h as d,f as n,c as a,j as G,u as C,x as f,k as N,y as m,a as i,v as V,d as E,t as L,w as k}from"../chunks/index.1ea56653.js";import{H as se,g as Pe}from"../chunks/Heading.71ac6e9f.js";import{T as ye}from"../chunks/Tip.67abc998.js";import{D as de}from"../chunks/Docstring.59aaf0cd.js";function xe(U){let o,_='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(){o=s("p"),o.innerHTML=_},l(c){o=d(c,"P",{"data-svelte-h":!0}),f(o)!=="svelte-1wmc0l4"&&(o.innerHTML=_)},m(c,M){i(c,o,M)},p:be,d(c){c&&n(o)}}}function Ie(U){let o,_,c,M,v,W,b,le='<a href="https://huggingface.co/papers/2011.13456" rel="nofollow">Score-Based Generative Modeling through Stochastic Differential Equations</a> (Score SDE) is by Yang Song, Jascha Sohl-Dickstein, Diederik P. Kingma, Abhishek Kumar, Stefano Ermon and Ben Poole. This pipeline implements the variance expanding (VE) variant of the stochastic differential equation method.',j,$,ce="The abstract from the paper is:",B,S,pe="<em>Creating noise from data is easy; creating data from noise is generative modeling. We present a stochastic differential equation (SDE) that smoothly transforms a complex data distribution to a known prior distribution by slowly injecting noise, and a corresponding reverse-time SDE that transforms the prior distribution back into the data distribution by slowly removing the noise. Crucially, the reverse-time SDE depends only on the time-dependent gradient field (\\aka, score) of the perturbed data distribution. By leveraging advances in score-based generative modeling, we can accurately estimate these scores with neural networks, and use numerical SDE solvers to generate samples. We show that this framework encapsulates previous approaches in score-based generative modeling and diffusion probabilistic modeling, allowing for new sampling procedures and new modeling capabilities. In particular, we introduce a predictor-corrector framework to correct errors in the evolution of the discretized reverse-time SDE. We also derive an equivalent neural ODE that samples from the same distribution as the SDE, but additionally enables exact likelihood computation, and improved sampling efficiency. In addition, we provide a new way to solve inverse problems with score-based models, as demonstrated with experiments on class-conditional generation, image inpainting, and colorization. Combined with multiple architectural improvements, we achieve record-breaking performance for unconditional image generation on CIFAR-10 with an Inception score of 9.89 and FID of 2.20, a competitive likelihood of 2.99 bits/dim, and demonstrate high fidelity generation of 1024 x 1024 images for the first time from a score-based generative model.</em>",F,w,me='The original codebase can be found at <a href="https://github.com/yang-song/score_sde_pytorch" rel="nofollow">yang-song/score_sde_pytorch</a>.',K,h,R,P,J,l,y,ne,O,ue="Pipeline for unconditional image generation.",ie,H,fe=`This model inherits from <a href="/docs/diffusers/main/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.).`,oe,g,x,re,q,he="The call function to the pipeline for generation.",Y,I,Q,u,D,ae,z,ge="Output class for image pipelines.",X,A,Z;return v=new se({props:{title:"Score SDE VE",local:"score-sde-ve",headingTag:"h1"}}),h=new ye({props:{$$slots:{default:[xe]},$$scope:{ctx:U}}}),P=new se({props:{title:"ScoreSdeVePipeline",local:"diffusers.ScoreSdeVePipeline",headingTag:"h2"}}),y=new de({props:{name:"class diffusers.ScoreSdeVePipeline",anchor:"diffusers.ScoreSdeVePipeline",parameters:[{name:"unet",val:": UNet2DModel"},{name:"scheduler",val:": ScoreSdeVeScheduler"}],parametersDescription:[{anchor:"diffusers.ScoreSdeVePipeline.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.ScoreSdeVePipeline.scheduler",description:`<strong>scheduler</strong> (<a href="/docs/diffusers/main/en/api/schedulers/score_sde_ve#diffusers.ScoreSdeVeScheduler">ScoreSdeVeScheduler</a>) &#x2014;
A <code>ScoreSdeVeScheduler</code> to be used in combination with <code>unet</code> to denoise the encoded image.`,name:"scheduler"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py#L25"}}),x=new de({props:{name:"__call__",anchor:"diffusers.ScoreSdeVePipeline.__call__",parameters:[{name:"batch_size",val:": int = 1"},{name:"num_inference_steps",val:": int = 2000"},{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"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.ScoreSdeVePipeline.__call__.batch_size",description:`<strong>batch_size</strong> (<code>int</code>, <em>optional</em>, defaults to 1) &#x2014;
The number of images to generate.`,name:"batch_size"},{anchor:"diffusers.ScoreSdeVePipeline.__call__.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <code>optional</code>) &#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.ScoreSdeVePipeline.__call__.output_type",description:`<strong>output_type</strong> (<code>str</code>, <code>optional</code>, 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.ScoreSdeVePipeline.__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/ddim#diffusers.ImagePipelineOutput">ImagePipelineOutput</a> instead of a plain tuple.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/score_sde_ve/pipeline_score_sde_ve.py#L45",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If <code>return_dict</code> is <code>True</code>, <a
  href="/docs/diffusers/main/en/api/pipelines/ddim#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/main/en/api/pipelines/ddim#diffusers.ImagePipelineOutput"
>ImagePipelineOutput</a> or <code>tuple</code></p>
`}}),I=new se({props:{title:"ImagePipelineOutput",local:"diffusers.ImagePipelineOutput",headingTag:"h2"}}),D=new de({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#L111"}}),{c(){o=s("meta"),_=r(),c=s("p"),M=r(),T(v.$$.fragment),W=r(),b=s("p"),b.innerHTML=le,j=r(),$=s("p"),$.textContent=ce,B=r(),S=s("p"),S.innerHTML=pe,F=r(),w=s("p"),w.innerHTML=me,K=r(),T(h.$$.fragment),R=r(),T(P.$$.fragment),J=r(),l=s("div"),T(y.$$.fragment),ne=r(),O=s("p"),O.textContent=ue,ie=r(),H=s("p"),H.innerHTML=fe,oe=r(),g=s("div"),T(x.$$.fragment),re=r(),q=s("p"),q.textContent=he,Y=r(),T(I.$$.fragment),Q=r(),u=s("div"),T(D.$$.fragment),ae=r(),z=s("p"),z.textContent=ge,X=r(),A=s("p"),this.h()},l(e){const t=we("svelte-u9bgzb",document.head);o=d(t,"META",{name:!0,content:!0}),t.forEach(n),_=a(e),c=d(e,"P",{}),G(c).forEach(n),M=a(e),C(v.$$.fragment,e),W=a(e),b=d(e,"P",{"data-svelte-h":!0}),f(b)!=="svelte-9dttqv"&&(b.innerHTML=le),j=a(e),$=d(e,"P",{"data-svelte-h":!0}),f($)!=="svelte-1cwsb16"&&($.textContent=ce),B=a(e),S=d(e,"P",{"data-svelte-h":!0}),f(S)!=="svelte-omf9ly"&&(S.innerHTML=pe),F=a(e),w=d(e,"P",{"data-svelte-h":!0}),f(w)!=="svelte-ldw3oh"&&(w.innerHTML=me),K=a(e),C(h.$$.fragment,e),R=a(e),C(P.$$.fragment,e),J=a(e),l=d(e,"DIV",{class:!0});var p=G(l);C(y.$$.fragment,p),ne=a(p),O=d(p,"P",{"data-svelte-h":!0}),f(O)!=="svelte-1byevm7"&&(O.textContent=ue),ie=a(p),H=d(p,"P",{"data-svelte-h":!0}),f(H)!=="svelte-496sm0"&&(H.innerHTML=fe),oe=a(p),g=d(p,"DIV",{class:!0});var ee=G(g);C(x.$$.fragment,ee),re=a(ee),q=d(ee,"P",{"data-svelte-h":!0}),f(q)!=="svelte-50j04k"&&(q.textContent=he),ee.forEach(n),p.forEach(n),Y=a(e),C(I.$$.fragment,e),Q=a(e),u=d(e,"DIV",{class:!0});var te=G(u);C(D.$$.fragment,te),ae=a(te),z=d(te,"P",{"data-svelte-h":!0}),f(z)!=="svelte-19wetgi"&&(z.textContent=ge),te.forEach(n),X=a(e),A=d(e,"P",{}),G(A).forEach(n),this.h()},h(){N(o,"name","hf:doc:metadata"),N(o,"content",De),N(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),N(l,"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")},m(e,t){m(document.head,o),i(e,_,t),i(e,c,t),i(e,M,t),V(v,e,t),i(e,W,t),i(e,b,t),i(e,j,t),i(e,$,t),i(e,B,t),i(e,S,t),i(e,F,t),i(e,w,t),i(e,K,t),V(h,e,t),i(e,R,t),V(P,e,t),i(e,J,t),i(e,l,t),V(y,l,null),m(l,ne),m(l,O),m(l,ie),m(l,H),m(l,oe),m(l,g),V(x,g,null),m(g,re),m(g,q),i(e,Y,t),V(I,e,t),i(e,Q,t),i(e,u,t),V(D,u,null),m(u,ae),m(u,z),i(e,X,t),i(e,A,t),Z=!0},p(e,[t]){const p={};t&2&&(p.$$scope={dirty:t,ctx:e}),h.$set(p)},i(e){Z||(E(v.$$.fragment,e),E(h.$$.fragment,e),E(P.$$.fragment,e),E(y.$$.fragment,e),E(x.$$.fragment,e),E(I.$$.fragment,e),E(D.$$.fragment,e),Z=!0)},o(e){L(v.$$.fragment,e),L(h.$$.fragment,e),L(P.$$.fragment,e),L(y.$$.fragment,e),L(x.$$.fragment,e),L(I.$$.fragment,e),L(D.$$.fragment,e),Z=!1},d(e){e&&(n(_),n(c),n(M),n(W),n(b),n(j),n($),n(B),n(S),n(F),n(w),n(K),n(R),n(J),n(l),n(Y),n(Q),n(u),n(X),n(A)),n(o),k(v,e),k(h,e),k(P,e),k(y),k(x),k(I,e),k(D)}}}const De='{"title":"Score SDE VE","local":"score-sde-ve","sections":[{"title":"ScoreSdeVePipeline","local":"diffusers.ScoreSdeVePipeline","sections":[],"depth":2},{"title":"ImagePipelineOutput","local":"diffusers.ImagePipelineOutput","sections":[],"depth":2}],"depth":1}';function Te(U){return ve(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=Pe}),[]}class Me extends $e{constructor(o){super(),Se(this,o,Te,Ie,_e,{})}}export{Me as component};
