import{S as ao,i as no,s as io,e as o,k as p,w as g,t as i,M as lo,c as r,d as t,m as u,a,x as _,h as l,b as d,G as s,g as c,y as v,q as b,o as D,B as y,v as co}from"../../../chunks/vendor-hf-doc-builder.js";import{T as po}from"../../../chunks/Tip-hf-doc-builder.js";import{D as Fe}from"../../../chunks/Docstring-hf-doc-builder.js";import{C as Ae}from"../../../chunks/CodeBlock-hf-doc-builder.js";import{I as Dt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function uo(Be){let h,j;return{c(){h=o("p"),j=i("\u{1F9EA} This is an experimental feature!")},l(m){h=r(m,"P",{});var M=a(h);j=l(M,"\u{1F9EA} This is an experimental feature!"),M.forEach(t)},m(m,M){c(m,h,M),s(h,j)},d(m){m&&t(h)}}}function fo(Be){let h,j,m,M,Me,A,yt,$e,Mt,Ce,B,C,$t,wt,Re,fe,St,qe,he,we,It,Xe,S,Tt,R,xt,Et,q,Nt,jt,Oe,I,k,Se,X,kt,Ie,Zt,Le,Z,Ut,O,Jt,Gt,Qe,U,Ye,me,Te,Vt,ze,L,He,Q,w,Wt,xe,Pt,Ft,Y,At,Bt,z,Ct,Rt,Ke,H,et,K,Ee,qt,tt,ee,st,te,Ne,Xt,ot,se,rt,ge,Ot,at,oe,nt,T,J,je,re,Lt,ke,Qt,it,f,ae,Yt,_e,Ze,zt,Ht,Kt,x,es,ve,ts,ss,be,os,rs,as,G,ne,ns,Ue,is,ls,V,ie,ds,Je,cs,ps,W,le,us,Ge,fs,lt,E,P,Ve,de,hs,We,ms,dt,N,ce,gs,pe,_s,Pe,vs,bs,ct;return A=new Dt({}),X=new Dt({}),U=new po({props:{warning:!0,$$slots:{default:[uo]},$$scope:{ctx:Be}}}),L=new Ae({props:{code:"cGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBERElNU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHJlc2NhbGVfYmV0YXNfemVyb19zbnIlM0RUcnVlKQ==",highlighted:'pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, rescale_betas_zero_snr=<span class="hljs-literal">True</span>)'}}),H=new Ae({props:{code:"LS1wcmVkaWN0aW9uX3R5cGUlM0QlMjJ2X3ByZWRpY3Rpb24lMjI=",highlighted:'--prediction_type=<span class="hljs-string">&quot;v_prediction&quot;</span>'}}),ee=new Ae({props:{code:"cGlwZS5zY2hlZHVsZXIlMjAlM0QlMjBERElNU2NoZWR1bGVyLmZyb21fY29uZmlnKHBpcGUuc2NoZWR1bGVyLmNvbmZpZyUyQyUyMHRpbWVzdGVwX3NwYWNpbmclM0QlMjJ0cmFpbGluZyUyMik=",highlighted:'pipe.scheduler = DDIMScheduler.from_config(pipe.scheduler.config, timestep_spacing=<span class="hljs-string">&quot;trailing&quot;</span>)'}}),se=new Ae({props:{code:"aW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBndWlkYW5jZV9yZXNjYWxlJTNEMC43KS5pbWFnZXMlNUIwJTVE",highlighted:'image = pipeline(prompt, guidance_rescale=<span class="hljs-number">0.7</span>).images[<span class="hljs-number">0</span>]'}}),oe=new Ae({props:{code:"ZnJvbSUyMGRpZmZ1c2VycyUyMGltcG9ydCUyMERpZmZ1c2lvblBpcGVsaW5lJTJDJTIwRERJTVNjaGVkdWxlciUwQSUwQXBpcGUlMjAlM0QlMjBEaWZmdXNpb25QaXBlbGluZS5mcm9tX3ByZXRyYWluZWQoJTIycHR4MCUyRnBzZXVkby1qb3VybmV5LXYyJTIyJTJDJTIwdG9yY2hfZHR5cGUlM0R0b3JjaC5mbG9hdDE2KSUwQXBpcGUuc2NoZWR1bGVyJTIwJTNEJTIwRERJTVNjaGVkdWxlci5mcm9tX2NvbmZpZyglMEElMjAlMjAlMjAlMjBwaXBlLnNjaGVkdWxlci5jb25maWclMkMlMjByZXNjYWxlX2JldGFzX3plcm9fc25yJTNEVHJ1ZSUyQyUyMHRpbWVzdGVwX3NwYWNpbmclM0QlMjJ0cmFpbGluZyUyMiUwQSklMEFwaXBlLnRvKCUyMmN1ZGElMjIpJTBBJTBBcHJvbXB0JTIwJTNEJTIwJTIyQSUyMGxpb24lMjBpbiUyMGdhbGF4aWVzJTJDJTIwc3BpcmFscyUyQyUyMG5lYnVsYWUlMkMlMjBzdGFycyUyQyUyMHNtb2tlJTJDJTIwaXJpZGVzY2VudCUyQyUyMGludHJpY2F0ZSUyMGRldGFpbCUyQyUyMG9jdGFuZSUyMHJlbmRlciUyQyUyMDhrJTIyJTBBaW1hZ2UlMjAlM0QlMjBwaXBlbGluZShwcm9tcHQlMkMlMjBndWlkYW5jZV9yZXNjYWxlJTNEMC43KS5pbWFnZXMlNUIwJTVE",highlighted:`<span class="hljs-keyword">from</span> diffusers <span class="hljs-keyword">import</span> DiffusionPipeline, DDIMScheduler

pipe = DiffusionPipeline.from_pretrained(<span class="hljs-string">&quot;ptx0/pseudo-journey-v2&quot;</span>, torch_dtype=torch.float16)
pipe.scheduler = DDIMScheduler.from_config(
    pipe.scheduler.config, rescale_betas_zero_snr=<span class="hljs-literal">True</span>, timestep_spacing=<span class="hljs-string">&quot;trailing&quot;</span>
)
pipe.to(<span class="hljs-string">&quot;cuda&quot;</span>)

prompt = <span class="hljs-string">&quot;A lion in galaxies, spirals, nebulae, stars, smoke, iridescent, intricate detail, octane render, 8k&quot;</span>
image = pipeline(prompt, guidance_rescale=<span class="hljs-number">0.7</span>).images[<span class="hljs-number">0</span>]`}}),re=new Dt({}),ae=new Fe({props:{name:"class diffusers.DDIMScheduler",anchor:"diffusers.DDIMScheduler",parameters:[{name:"num_train_timesteps",val:": int = 1000"},{name:"beta_start",val:": float = 0.0001"},{name:"beta_end",val:": float = 0.02"},{name:"beta_schedule",val:": str = 'linear'"},{name:"trained_betas",val:": typing.Union[numpy.ndarray, typing.List[float], NoneType] = None"},{name:"clip_sample",val:": bool = True"},{name:"set_alpha_to_one",val:": bool = True"},{name:"steps_offset",val:": int = 0"},{name:"prediction_type",val:": str = 'epsilon'"},{name:"thresholding",val:": bool = False"},{name:"dynamic_thresholding_ratio",val:": float = 0.995"},{name:"clip_sample_range",val:": float = 1.0"},{name:"sample_max_value",val:": float = 1.0"},{name:"timestep_spacing",val:": str = 'leading'"},{name:"rescale_betas_zero_snr",val:": bool = False"}],parametersDescription:[{anchor:"diffusers.DDIMScheduler.num_train_timesteps",description:`<strong>num_train_timesteps</strong> (<code>int</code>, defaults to 1000) &#x2014;
The number of diffusion steps to train the model.`,name:"num_train_timesteps"},{anchor:"diffusers.DDIMScheduler.beta_start",description:`<strong>beta_start</strong> (<code>float</code>, defaults to 0.0001) &#x2014;
The starting <code>beta</code> value of inference.`,name:"beta_start"},{anchor:"diffusers.DDIMScheduler.beta_end",description:`<strong>beta_end</strong> (<code>float</code>, defaults to 0.02) &#x2014;
The final <code>beta</code> value.`,name:"beta_end"},{anchor:"diffusers.DDIMScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</code>, defaults to <code>&quot;linear&quot;</code>) &#x2014;
The beta schedule, a mapping from a beta range to a sequence of betas for stepping the model. Choose from
<code>linear</code>, <code>scaled_linear</code>, or <code>squaredcos_cap_v2</code>.`,name:"beta_schedule"},{anchor:"diffusers.DDIMScheduler.trained_betas",description:`<strong>trained_betas</strong> (<code>np.ndarray</code>, <em>optional</em>) &#x2014;
Pass an array of betas directly to the constructor to bypass <code>beta_start</code> and <code>beta_end</code>.`,name:"trained_betas"},{anchor:"diffusers.DDIMScheduler.clip_sample",description:`<strong>clip_sample</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Clip the predicted sample for numerical stability.`,name:"clip_sample"},{anchor:"diffusers.DDIMScheduler.clip_sample_range",description:`<strong>clip_sample_range</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The maximum magnitude for sample clipping. Valid only when <code>clip_sample=True</code>.`,name:"clip_sample_range"},{anchor:"diffusers.DDIMScheduler.set_alpha_to_one",description:`<strong>set_alpha_to_one</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Each diffusion step uses the alphas product value at that step and at the previous one. For the final step
there is no previous alpha. When this option is <code>True</code> the previous alpha product is fixed to <code>1</code>,
otherwise it uses the alpha value at step 0.`,name:"set_alpha_to_one"},{anchor:"diffusers.DDIMScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, defaults to 0) &#x2014;
An offset added to the inference steps. You can use a combination of <code>offset=1</code> and
<code>set_alpha_to_one=False</code> to make the last step use step 0 for the previous alpha product like in Stable
Diffusion.`,name:"steps_offset"},{anchor:"diffusers.DDIMScheduler.prediction_type",description:`<strong>prediction_type</strong> (<code>str</code>, defaults to <code>epsilon</code>, <em>optional</em>) &#x2014;
Prediction type of the scheduler function; can be <code>epsilon</code> (predicts the noise of the diffusion process),
<code>sample</code> (directly predicts the noisy sample<code>) or </code>v_prediction\` (see section 2.4 of <a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">Imagen
Video</a> paper).`,name:"prediction_type"},{anchor:"diffusers.DDIMScheduler.thresholding",description:`<strong>thresholding</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to use the &#x201C;dynamic thresholding&#x201D; method. This is unsuitable for latent-space diffusion models such
as Stable Diffusion.`,name:"thresholding"},{anchor:"diffusers.DDIMScheduler.dynamic_thresholding_ratio",description:`<strong>dynamic_thresholding_ratio</strong> (<code>float</code>, defaults to 0.995) &#x2014;
The ratio for the dynamic thresholding method. Valid only when <code>thresholding=True</code>.`,name:"dynamic_thresholding_ratio"},{anchor:"diffusers.DDIMScheduler.sample_max_value",description:`<strong>sample_max_value</strong> (<code>float</code>, defaults to 1.0) &#x2014;
The threshold value for dynamic thresholding. Valid only when <code>thresholding=True</code>.`,name:"sample_max_value"},{anchor:"diffusers.DDIMScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, defaults to <code>&quot;leading&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2 of the <a href="https://huggingface.co/papers/2305.08891" rel="nofollow">Common Diffusion Noise Schedules and
Sample Steps are Flawed</a> for more information.`,name:"timestep_spacing"},{anchor:"diffusers.DDIMScheduler.rescale_betas_zero_snr",description:`<strong>rescale_betas_zero_snr</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
Whether to rescale the betas to have zero terminal SNR. This enables the model to generate very bright and
dark samples instead of limiting it to samples with medium brightness. Loosely related to
<a href="https://github.com/huggingface/diffusers/blob/74fd735eb073eb1d774b1ab4154a0876eb82f055/examples/dreambooth/train_dreambooth.py#L506" rel="nofollow"><code>--offset_noise</code></a>.`,name:"rescale_betas_zero_snr"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/schedulers/scheduling_ddim.py#L130"}}),ne=new Fe({props:{name:"scale_model_input",anchor:"diffusers.DDIMScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.DDIMScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.DDIMScheduler.scale_model_input.timestep",description:`<strong>timestep</strong> (<code>int</code>, <em>optional</em>) &#x2014;
The current timestep in the diffusion chain.`,name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/schedulers/scheduling_ddim.py#L239",returnDescription:`
<p>A scaled input sample.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),ie=new Fe({props:{name:"set_timesteps",anchor:"diffusers.DDIMScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.DDIMScheduler.set_timesteps.num_inference_steps",description:`<strong>num_inference_steps</strong> (<code>int</code>) &#x2014;
The number of diffusion steps used when generating samples with a pre-trained model.`,name:"num_inference_steps"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/schedulers/scheduling_ddim.py#L301"}}),le=new Fe({props:{name:"step",anchor:"diffusers.DDIMScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"},{name:"eta",val:": float = 0.0"},{name:"use_clipped_model_output",val:": bool = False"},{name:"generator",val:" = None"},{name:"variance_noise",val:": typing.Optional[torch.FloatTensor] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDIMScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.FloatTensor</code>) &#x2014;
The direct output from learned diffusion model.`,name:"model_output"},{anchor:"diffusers.DDIMScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.DDIMScheduler.step.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
A current instance of a sample created by the diffusion process.`,name:"sample"},{anchor:"diffusers.DDIMScheduler.step.eta",description:`<strong>eta</strong> (<code>float</code>) &#x2014;
The weight of noise for added noise in diffusion step.`,name:"eta"},{anchor:"diffusers.DDIMScheduler.step.use_clipped_model_output",description:`<strong>use_clipped_model_output</strong> (<code>bool</code>, defaults to <code>False</code>) &#x2014;
If <code>True</code>, computes &#x201C;corrected&#x201D; <code>model_output</code> from the clipped predicted original sample. Necessary
because predicted original sample is clipped to [-1, 1] when <code>self.config.clip_sample</code> is <code>True</code>. If no
clipping has happened, &#x201C;corrected&#x201D; <code>model_output</code> would coincide with the one provided as input and
<code>use_clipped_model_output</code> has no effect.`,name:"use_clipped_model_output"},{anchor:"diffusers.DDIMScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.DDIMScheduler.step.variance_noise",description:`<strong>variance_noise</strong> (<code>torch.FloatTensor</code>) &#x2014;
Alternative to generating noise with <code>generator</code> by directly providing the noise for the variance
itself. Useful for methods such as <code>CycleDiffusion</code>.`,name:"variance_noise"},{anchor:"diffusers.DDIMScheduler.step.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.20.0/en/api/schedulers/ddim#diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput">DDIMSchedulerOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/schedulers/scheduling_ddim.py#L346",returnDescription:`
<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/v0.20.0/en/api/schedulers/ddim#diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput"
>DDIMSchedulerOutput</a> is returned, otherwise a
tuple is returned where the first element is the sample tensor.</p>
`,returnType:`
<p><code>~schedulers.scheduling_utils.DDIMSchedulerOutput</code> or <code>tuple</code></p>
`}}),de=new Dt({}),ce=new Fe({props:{name:"class diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput",anchor:"diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"},{name:"pred_original_sample",val:": typing.Optional[torch.FloatTensor] = None"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput.prev_sample",description:`<strong>prev_sample</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
Computed sample <code>(x_{t-1})</code> of previous timestep. <code>prev_sample</code> should be used as next model input in the
denoising loop.`,name:"prev_sample"},{anchor:"diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput.pred_original_sample",description:`<strong>pred_original_sample</strong> (<code>torch.FloatTensor</code> of shape <code>(batch_size, num_channels, height, width)</code> for images) &#x2014;
The predicted denoised sample <code>(x_{0})</code> based on the model output from the current timestep.
<code>pred_original_sample</code> can be used to preview progress or for guidance.`,name:"pred_original_sample"}],source:"https://github.com/huggingface/diffusers/blob/v0.20.0/src/diffusers/schedulers/scheduling_ddim.py#L32"}}),{c(){h=o("meta"),j=p(),m=o("h1"),M=o("a"),Me=o("span"),g(A.$$.fragment),yt=p(),$e=o("span"),Mt=i("DDIMScheduler"),Ce=p(),B=o("p"),C=o("a"),$t=i("Denoising Diffusion Implicit Models"),wt=i(" (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon."),Re=p(),fe=o("p"),St=i("The abstract from the paper is:"),qe=p(),he=o("p"),we=o("em"),It=i(`Denoising diffusion probabilistic models (DDPMs) have achieved high quality image generation without adversarial training,
yet they require simulating a Markov chain for many steps to produce a sample.
To accelerate sampling, we present denoising diffusion implicit models (DDIMs), a more efficient class of iterative implicit probabilistic models
with the same training procedure as DDPMs. In DDPMs, the generative process is defined as the reverse of a Markovian diffusion process.
We construct a class of non-Markovian diffusion processes that lead to the same training objective, but whose reverse process can be much faster to sample from.
We empirically demonstrate that DDIMs can produce high quality samples 10\xD7 to 50\xD7 faster in terms of wall-clock time compared to DDPMs, allow us to trade off
computation for sample quality, and can perform semantically meaningful image interpolation directly in the latent space.`),Xe=p(),S=o("p"),Tt=i("The original codebase of this paper can be found at "),R=o("a"),xt=i("ermongroup/ddim"),Et=i(", and you can contact the author on "),q=o("a"),Nt=i("tsong.me"),jt=i("."),Oe=p(),I=o("h2"),k=o("a"),Se=o("span"),g(X.$$.fragment),kt=p(),Ie=o("span"),Zt=i("Tips"),Le=p(),Z=o("p"),Ut=i("The paper "),O=o("a"),Jt=i("Common Diffusion Noise Schedules and Sample Steps are Flawed"),Gt=i(" claims that a mismatch between the training and inference settings leads to suboptimal inference generation results for Stable Diffusion. To fix this, the authors propose:"),Qe=p(),g(U.$$.fragment),Ye=p(),me=o("ol"),Te=o("li"),Vt=i("rescale the noise schedule to enforce zero terminal signal-to-noise ratio (SNR)"),ze=p(),g(L.$$.fragment),He=p(),Q=o("ol"),w=o("li"),Wt=i("train a model with "),xe=o("code"),Pt=i("v_prediction"),Ft=i(" (add the following argument to the "),Y=o("a"),At=i("train_text_to_image.py"),Bt=i(" or "),z=o("a"),Ct=i("train_text_to_image_lora.py"),Rt=i(" scripts)"),Ke=p(),g(H.$$.fragment),et=p(),K=o("ol"),Ee=o("li"),qt=i("change the sampler to always start from the last timestep"),tt=p(),g(ee.$$.fragment),st=p(),te=o("ol"),Ne=o("li"),Xt=i("rescale classifier-free guidance to prevent over-exposure"),ot=p(),g(se.$$.fragment),rt=p(),ge=o("p"),Ot=i("For example:"),at=p(),g(oe.$$.fragment),nt=p(),T=o("h2"),J=o("a"),je=o("span"),g(re.$$.fragment),Lt=p(),ke=o("span"),Qt=i("DDIMScheduler"),it=p(),f=o("div"),g(ae.$$.fragment),Yt=p(),_e=o("p"),Ze=o("code"),zt=i("DDIMScheduler"),Ht=i(` extends the denoising procedure introduced in denoising diffusion probabilistic models (DDPMs) with
non-Markovian guidance.`),Kt=p(),x=o("p"),es=i("This model inherits from "),ve=o("a"),ts=i("SchedulerMixin"),ss=i(" and "),be=o("a"),os=i("ConfigMixin"),rs=i(`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),as=p(),G=o("div"),g(ne.$$.fragment),ns=p(),Ue=o("p"),is=i(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),ls=p(),V=o("div"),g(ie.$$.fragment),ds=p(),Je=o("p"),cs=i("Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),ps=p(),W=o("div"),g(le.$$.fragment),us=p(),Ge=o("p"),fs=i(`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`),lt=p(),E=o("h2"),P=o("a"),Ve=o("span"),g(de.$$.fragment),hs=p(),We=o("span"),ms=i("DDIMSchedulerOutput"),dt=p(),N=o("div"),g(ce.$$.fragment),gs=p(),pe=o("p"),_s=i("Output class for the scheduler\u2019s "),Pe=o("code"),vs=i("step"),bs=i(" function output."),this.h()},l(e){const n=lo('[data-svelte="svelte-1phssyn"]',document.head);h=r(n,"META",{name:!0,content:!0}),n.forEach(t),j=u(e),m=r(e,"H1",{class:!0});var ue=a(m);M=r(ue,"A",{id:!0,class:!0,href:!0});var Ms=a(M);Me=r(Ms,"SPAN",{});var $s=a(Me);_(A.$$.fragment,$s),$s.forEach(t),Ms.forEach(t),yt=u(ue),$e=r(ue,"SPAN",{});var ws=a($e);Mt=l(ws,"DDIMScheduler"),ws.forEach(t),ue.forEach(t),Ce=u(e),B=r(e,"P",{});var Ds=a(B);C=r(Ds,"A",{href:!0,rel:!0});var Ss=a(C);$t=l(Ss,"Denoising Diffusion Implicit Models"),Ss.forEach(t),wt=l(Ds," (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon."),Ds.forEach(t),Re=u(e),fe=r(e,"P",{});var Is=a(fe);St=l(Is,"The abstract from the paper is:"),Is.forEach(t),qe=u(e),he=r(e,"P",{});var Ts=a(he);we=r(Ts,"EM",{});var xs=a(we);It=l(xs,`Denoising diffusion probabilistic models (DDPMs) have achieved high quality image generation without adversarial training,
yet they require simulating a Markov chain for many steps to produce a sample.
To accelerate sampling, we present denoising diffusion implicit models (DDIMs), a more efficient class of iterative implicit probabilistic models
with the same training procedure as DDPMs. In DDPMs, the generative process is defined as the reverse of a Markovian diffusion process.
We construct a class of non-Markovian diffusion processes that lead to the same training objective, but whose reverse process can be much faster to sample from.
We empirically demonstrate that DDIMs can produce high quality samples 10\xD7 to 50\xD7 faster in terms of wall-clock time compared to DDPMs, allow us to trade off
computation for sample quality, and can perform semantically meaningful image interpolation directly in the latent space.`),xs.forEach(t),Ts.forEach(t),Xe=u(e),S=r(e,"P",{});var De=a(S);Tt=l(De,"The original codebase of this paper can be found at "),R=r(De,"A",{href:!0,rel:!0});var Es=a(R);xt=l(Es,"ermongroup/ddim"),Es.forEach(t),Et=l(De,", and you can contact the author on "),q=r(De,"A",{href:!0,rel:!0});var Ns=a(q);Nt=l(Ns,"tsong.me"),Ns.forEach(t),jt=l(De,"."),De.forEach(t),Oe=u(e),I=r(e,"H2",{class:!0});var pt=a(I);k=r(pt,"A",{id:!0,class:!0,href:!0});var js=a(k);Se=r(js,"SPAN",{});var ks=a(Se);_(X.$$.fragment,ks),ks.forEach(t),js.forEach(t),kt=u(pt),Ie=r(pt,"SPAN",{});var Zs=a(Ie);Zt=l(Zs,"Tips"),Zs.forEach(t),pt.forEach(t),Le=u(e),Z=r(e,"P",{});var ut=a(Z);Ut=l(ut,"The paper "),O=r(ut,"A",{href:!0,rel:!0});var Us=a(O);Jt=l(Us,"Common Diffusion Noise Schedules and Sample Steps are Flawed"),Us.forEach(t),Gt=l(ut," claims that a mismatch between the training and inference settings leads to suboptimal inference generation results for Stable Diffusion. To fix this, the authors propose:"),ut.forEach(t),Qe=u(e),_(U.$$.fragment,e),Ye=u(e),me=r(e,"OL",{});var Js=a(me);Te=r(Js,"LI",{});var Gs=a(Te);Vt=l(Gs,"rescale the noise schedule to enforce zero terminal signal-to-noise ratio (SNR)"),Gs.forEach(t),Js.forEach(t),ze=u(e),_(L.$$.fragment,e),He=u(e),Q=r(e,"OL",{start:!0});var Vs=a(Q);w=r(Vs,"LI",{});var F=a(w);Wt=l(F,"train a model with "),xe=r(F,"CODE",{});var Ws=a(xe);Pt=l(Ws,"v_prediction"),Ws.forEach(t),Ft=l(F," (add the following argument to the "),Y=r(F,"A",{href:!0,rel:!0});var Ps=a(Y);At=l(Ps,"train_text_to_image.py"),Ps.forEach(t),Bt=l(F," or "),z=r(F,"A",{href:!0,rel:!0});var Fs=a(z);Ct=l(Fs,"train_text_to_image_lora.py"),Fs.forEach(t),Rt=l(F," scripts)"),F.forEach(t),Vs.forEach(t),Ke=u(e),_(H.$$.fragment,e),et=u(e),K=r(e,"OL",{start:!0});var As=a(K);Ee=r(As,"LI",{});var Bs=a(Ee);qt=l(Bs,"change the sampler to always start from the last timestep"),Bs.forEach(t),As.forEach(t),tt=u(e),_(ee.$$.fragment,e),st=u(e),te=r(e,"OL",{start:!0});var Cs=a(te);Ne=r(Cs,"LI",{});var Rs=a(Ne);Xt=l(Rs,"rescale classifier-free guidance to prevent over-exposure"),Rs.forEach(t),Cs.forEach(t),ot=u(e),_(se.$$.fragment,e),rt=u(e),ge=r(e,"P",{});var qs=a(ge);Ot=l(qs,"For example:"),qs.forEach(t),at=u(e),_(oe.$$.fragment,e),nt=u(e),T=r(e,"H2",{class:!0});var ft=a(T);J=r(ft,"A",{id:!0,class:!0,href:!0});var Xs=a(J);je=r(Xs,"SPAN",{});var Os=a(je);_(re.$$.fragment,Os),Os.forEach(t),Xs.forEach(t),Lt=u(ft),ke=r(ft,"SPAN",{});var Ls=a(ke);Qt=l(Ls,"DDIMScheduler"),Ls.forEach(t),ft.forEach(t),it=u(e),f=r(e,"DIV",{class:!0});var $=a(f);_(ae.$$.fragment,$),Yt=u($),_e=r($,"P",{});var ys=a(_e);Ze=r(ys,"CODE",{});var Qs=a(Ze);zt=l(Qs,"DDIMScheduler"),Qs.forEach(t),Ht=l(ys,` extends the denoising procedure introduced in denoising diffusion probabilistic models (DDPMs) with
non-Markovian guidance.`),ys.forEach(t),Kt=u($),x=r($,"P",{});var ye=a(x);es=l(ye,"This model inherits from "),ve=r(ye,"A",{href:!0});var Ys=a(ve);ts=l(Ys,"SchedulerMixin"),Ys.forEach(t),ss=l(ye," and "),be=r(ye,"A",{href:!0});var zs=a(be);os=l(zs,"ConfigMixin"),zs.forEach(t),rs=l(ye,`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),ye.forEach(t),as=u($),G=r($,"DIV",{class:!0});var ht=a(G);_(ne.$$.fragment,ht),ns=u(ht),Ue=r(ht,"P",{});var Hs=a(Ue);is=l(Hs,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),Hs.forEach(t),ht.forEach(t),ls=u($),V=r($,"DIV",{class:!0});var mt=a(V);_(ie.$$.fragment,mt),ds=u(mt),Je=r(mt,"P",{});var Ks=a(Je);cs=l(Ks,"Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),Ks.forEach(t),mt.forEach(t),ps=u($),W=r($,"DIV",{class:!0});var gt=a(W);_(le.$$.fragment,gt),us=u(gt),Ge=r(gt,"P",{});var eo=a(Ge);fs=l(eo,`Predict the sample from the previous timestep by reversing the SDE. This function propagates the diffusion
process from the learned model outputs (most often the predicted noise).`),eo.forEach(t),gt.forEach(t),$.forEach(t),lt=u(e),E=r(e,"H2",{class:!0});var _t=a(E);P=r(_t,"A",{id:!0,class:!0,href:!0});var to=a(P);Ve=r(to,"SPAN",{});var so=a(Ve);_(de.$$.fragment,so),so.forEach(t),to.forEach(t),hs=u(_t),We=r(_t,"SPAN",{});var oo=a(We);ms=l(oo,"DDIMSchedulerOutput"),oo.forEach(t),_t.forEach(t),dt=u(e),N=r(e,"DIV",{class:!0});var vt=a(N);_(ce.$$.fragment,vt),gs=u(vt),pe=r(vt,"P",{});var bt=a(pe);_s=l(bt,"Output class for the scheduler\u2019s "),Pe=r(bt,"CODE",{});var ro=a(Pe);vs=l(ro,"step"),ro.forEach(t),bs=l(bt," function output."),bt.forEach(t),vt.forEach(t),this.h()},h(){d(h,"name","hf:doc:metadata"),d(h,"content",JSON.stringify(ho)),d(M,"id","ddimscheduler"),d(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"),d(M,"href","#ddimscheduler"),d(m,"class","relative group"),d(C,"href","https://huggingface.co/papers/2010.02502"),d(C,"rel","nofollow"),d(R,"href","https://github.com/ermongroup/ddim"),d(R,"rel","nofollow"),d(q,"href","https://tsong.me/"),d(q,"rel","nofollow"),d(k,"id","tips"),d(k,"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"),d(k,"href","#tips"),d(I,"class","relative group"),d(O,"href","https://huggingface.co/papers/2305.08891"),d(O,"rel","nofollow"),d(Y,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image.py"),d(Y,"rel","nofollow"),d(z,"href","https://github.com/huggingface/diffusers/blob/main/examples/text_to_image/train_text_to_image_lora.py"),d(z,"rel","nofollow"),d(Q,"start","2"),d(K,"start","3"),d(te,"start","4"),d(J,"id","diffusers.DDIMScheduler"),d(J,"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"),d(J,"href","#diffusers.DDIMScheduler"),d(T,"class","relative group"),d(ve,"href","/docs/diffusers/v0.20.0/en/api/schedulers/overview#diffusers.SchedulerMixin"),d(be,"href","/docs/diffusers/v0.20.0/en/api/configuration#diffusers.ConfigMixin"),d(G,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(V,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(W,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(P,"id","diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput"),d(P,"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"),d(P,"href","#diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput"),d(E,"class","relative group"),d(N,"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,n){s(document.head,h),c(e,j,n),c(e,m,n),s(m,M),s(M,Me),v(A,Me,null),s(m,yt),s(m,$e),s($e,Mt),c(e,Ce,n),c(e,B,n),s(B,C),s(C,$t),s(B,wt),c(e,Re,n),c(e,fe,n),s(fe,St),c(e,qe,n),c(e,he,n),s(he,we),s(we,It),c(e,Xe,n),c(e,S,n),s(S,Tt),s(S,R),s(R,xt),s(S,Et),s(S,q),s(q,Nt),s(S,jt),c(e,Oe,n),c(e,I,n),s(I,k),s(k,Se),v(X,Se,null),s(I,kt),s(I,Ie),s(Ie,Zt),c(e,Le,n),c(e,Z,n),s(Z,Ut),s(Z,O),s(O,Jt),s(Z,Gt),c(e,Qe,n),v(U,e,n),c(e,Ye,n),c(e,me,n),s(me,Te),s(Te,Vt),c(e,ze,n),v(L,e,n),c(e,He,n),c(e,Q,n),s(Q,w),s(w,Wt),s(w,xe),s(xe,Pt),s(w,Ft),s(w,Y),s(Y,At),s(w,Bt),s(w,z),s(z,Ct),s(w,Rt),c(e,Ke,n),v(H,e,n),c(e,et,n),c(e,K,n),s(K,Ee),s(Ee,qt),c(e,tt,n),v(ee,e,n),c(e,st,n),c(e,te,n),s(te,Ne),s(Ne,Xt),c(e,ot,n),v(se,e,n),c(e,rt,n),c(e,ge,n),s(ge,Ot),c(e,at,n),v(oe,e,n),c(e,nt,n),c(e,T,n),s(T,J),s(J,je),v(re,je,null),s(T,Lt),s(T,ke),s(ke,Qt),c(e,it,n),c(e,f,n),v(ae,f,null),s(f,Yt),s(f,_e),s(_e,Ze),s(Ze,zt),s(_e,Ht),s(f,Kt),s(f,x),s(x,es),s(x,ve),s(ve,ts),s(x,ss),s(x,be),s(be,os),s(x,rs),s(f,as),s(f,G),v(ne,G,null),s(G,ns),s(G,Ue),s(Ue,is),s(f,ls),s(f,V),v(ie,V,null),s(V,ds),s(V,Je),s(Je,cs),s(f,ps),s(f,W),v(le,W,null),s(W,us),s(W,Ge),s(Ge,fs),c(e,lt,n),c(e,E,n),s(E,P),s(P,Ve),v(de,Ve,null),s(E,hs),s(E,We),s(We,ms),c(e,dt,n),c(e,N,n),v(ce,N,null),s(N,gs),s(N,pe),s(pe,_s),s(pe,Pe),s(Pe,vs),s(pe,bs),ct=!0},p(e,[n]){const ue={};n&2&&(ue.$$scope={dirty:n,ctx:e}),U.$set(ue)},i(e){ct||(b(A.$$.fragment,e),b(X.$$.fragment,e),b(U.$$.fragment,e),b(L.$$.fragment,e),b(H.$$.fragment,e),b(ee.$$.fragment,e),b(se.$$.fragment,e),b(oe.$$.fragment,e),b(re.$$.fragment,e),b(ae.$$.fragment,e),b(ne.$$.fragment,e),b(ie.$$.fragment,e),b(le.$$.fragment,e),b(de.$$.fragment,e),b(ce.$$.fragment,e),ct=!0)},o(e){D(A.$$.fragment,e),D(X.$$.fragment,e),D(U.$$.fragment,e),D(L.$$.fragment,e),D(H.$$.fragment,e),D(ee.$$.fragment,e),D(se.$$.fragment,e),D(oe.$$.fragment,e),D(re.$$.fragment,e),D(ae.$$.fragment,e),D(ne.$$.fragment,e),D(ie.$$.fragment,e),D(le.$$.fragment,e),D(de.$$.fragment,e),D(ce.$$.fragment,e),ct=!1},d(e){t(h),e&&t(j),e&&t(m),y(A),e&&t(Ce),e&&t(B),e&&t(Re),e&&t(fe),e&&t(qe),e&&t(he),e&&t(Xe),e&&t(S),e&&t(Oe),e&&t(I),y(X),e&&t(Le),e&&t(Z),e&&t(Qe),y(U,e),e&&t(Ye),e&&t(me),e&&t(ze),y(L,e),e&&t(He),e&&t(Q),e&&t(Ke),y(H,e),e&&t(et),e&&t(K),e&&t(tt),y(ee,e),e&&t(st),e&&t(te),e&&t(ot),y(se,e),e&&t(rt),e&&t(ge),e&&t(at),y(oe,e),e&&t(nt),e&&t(T),y(re),e&&t(it),e&&t(f),y(ae),y(ne),y(ie),y(le),e&&t(lt),e&&t(E),y(de),e&&t(dt),e&&t(N),y(ce)}}}const ho={local:"ddimscheduler",sections:[{local:"tips",title:"Tips"},{local:"diffusers.DDIMScheduler",title:"DDIMScheduler"},{local:"diffusers.schedulers.scheduling_ddim.DDIMSchedulerOutput",title:"DDIMSchedulerOutput"}],title:"DDIMScheduler"};function mo(Be){return co(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class yo extends ao{constructor(h){super();no(this,h,mo,fo,io,{})}}export{yo as default,ho as metadata};
