import{S as at,i as it,s as dt,e as r,k as l,w as V,t as i,M as ct,c as o,d as s,m as p,a as n,x as z,h as d,b as a,G as e,g as $,y as R,L as lt,q as U,o as G,B as J,v as pt}from"../../../chunks/vendor-hf-doc-builder.js";import{D as pe}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as nt}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function ut(Ue){let m,te,_,D,W,x,ue,H,he,se,h,B,fe,me,w,_e,ge,T,ve,De,re,g,b,Y,E,be,j,Ie,oe,c,C,Se,I,K,Me,ye,k,$e,xe,we,v,Te,L,Ee,Ce,q,Pe,Ae,Fe,S,P,Ne,Q,ke,Le,M,A,qe,X,Oe,Ve,y,F,ze,Z,Re,ne;return x=new nt({}),E=new nt({}),C=new pe({props:{name:"class diffusers.DDIMInverseScheduler",anchor:"diffusers.DDIMInverseScheduler",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:"clip_sample_range",val:": float = 1.0"},{name:"timestep_spacing",val:": str = 'leading'"},{name:"rescale_betas_zero_snr",val:": bool = False"},{name:"**kwargs",val:""}],parametersDescription:[{anchor:"diffusers.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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 0, otherwise
it uses the alpha value at step <code>num_train_timesteps - 1</code>.`,name:"set_alpha_to_one"},{anchor:"diffusers.DDIMInverseScheduler.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 <code>num_train_timesteps - 1</code> for the previous alpha
product.`,name:"steps_offset"},{anchor:"diffusers.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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/main/src/diffusers/schedulers/scheduling_ddim_inverse.py#L130"}}),P=new pe({props:{name:"scale_model_input",anchor:"diffusers.DDIMInverseScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.DDIMInverseScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.DDIMInverseScheduler.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/main/src/diffusers/schedulers/scheduling_ddim_inverse.py#L238",returnDescription:`
<p>A scaled input sample.</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),A=new pe({props:{name:"set_timesteps",anchor:"diffusers.DDIMInverseScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.DDIMInverseScheduler.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/main/src/diffusers/schedulers/scheduling_ddim_inverse.py#L255"}}),F=new pe({props:{name:"step",anchor:"diffusers.DDIMInverseScheduler.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:"variance_noise",val:": typing.Optional[torch.FloatTensor] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDIMInverseScheduler.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.DDIMInverseScheduler.step.timestep",description:`<strong>timestep</strong> (<code>float</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.DDIMInverseScheduler.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.DDIMInverseScheduler.step.eta",description:`<strong>eta</strong> (<code>float</code>) &#x2014;
The weight of noise for added noise in diffusion step.`,name:"eta"},{anchor:"diffusers.DDIMInverseScheduler.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.DDIMInverseScheduler.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.DDIMInverseScheduler.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 <code>~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput</code> or
<code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/main/src/diffusers/schedulers/scheduling_ddim_inverse.py#L296",returnDescription:`
<p>If return_dict is <code>True</code>, <code>~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput</code> is
returned, otherwise a tuple is returned where the first element is the sample tensor.</p>
`,returnType:`
<p><code>~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput</code> or <code>tuple</code></p>
`}}),{c(){m=r("meta"),te=l(),_=r("h1"),D=r("a"),W=r("span"),V(x.$$.fragment),ue=l(),H=r("span"),he=i("DDIMInverseScheduler"),se=l(),h=r("p"),B=r("code"),fe=i("DDIMInverseScheduler"),me=i(" is the inverted scheduler from "),w=r("a"),_e=i("Denoising Diffusion Implicit Models"),ge=i(` (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
The implementation is mostly based on the DDIM inversion definition from `),T=r("a"),ve=i("Null-text Inversion for Editing Real Images using Guided Diffusion Models"),De=i("."),re=l(),g=r("h2"),b=r("a"),Y=r("span"),V(E.$$.fragment),be=l(),j=r("span"),Ie=i("DDIMInverseScheduler"),oe=l(),c=r("div"),V(C.$$.fragment),Se=l(),I=r("p"),K=r("code"),Me=i("DDIMInverseScheduler"),ye=i(" is the reverse scheduler of "),k=r("a"),$e=i("DDIMScheduler"),xe=i("."),we=l(),v=r("p"),Te=i("This model inherits from "),L=r("a"),Ee=i("SchedulerMixin"),Ce=i(" and "),q=r("a"),Pe=i("ConfigMixin"),Ae=i(`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),Fe=l(),S=r("div"),V(P.$$.fragment),Ne=l(),Q=r("p"),ke=i(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),Le=l(),M=r("div"),V(A.$$.fragment),qe=l(),X=r("p"),Oe=i("Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),Ve=l(),y=r("div"),V(F.$$.fragment),ze=l(),Z=r("p"),Re=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).`),this.h()},l(t){const f=ct('[data-svelte="svelte-1phssyn"]',document.head);m=o(f,"META",{name:!0,content:!0}),f.forEach(s),te=p(t),_=o(t,"H1",{class:!0});var ae=n(_);D=o(ae,"A",{id:!0,class:!0,href:!0});var Ge=n(D);W=o(Ge,"SPAN",{});var Je=n(W);z(x.$$.fragment,Je),Je.forEach(s),Ge.forEach(s),ue=p(ae),H=o(ae,"SPAN",{});var We=n(H);he=d(We,"DDIMInverseScheduler"),We.forEach(s),ae.forEach(s),se=p(t),h=o(t,"P",{});var N=n(h);B=o(N,"CODE",{});var He=n(B);fe=d(He,"DDIMInverseScheduler"),He.forEach(s),me=d(N," is the inverted scheduler from "),w=o(N,"A",{href:!0,rel:!0});var Be=n(w);_e=d(Be,"Denoising Diffusion Implicit Models"),Be.forEach(s),ge=d(N,` (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
The implementation is mostly based on the DDIM inversion definition from `),T=o(N,"A",{href:!0,rel:!0});var Ye=n(T);ve=d(Ye,"Null-text Inversion for Editing Real Images using Guided Diffusion Models"),Ye.forEach(s),De=d(N,"."),N.forEach(s),re=p(t),g=o(t,"H2",{class:!0});var ie=n(g);b=o(ie,"A",{id:!0,class:!0,href:!0});var je=n(b);Y=o(je,"SPAN",{});var Ke=n(Y);z(E.$$.fragment,Ke),Ke.forEach(s),je.forEach(s),be=p(ie),j=o(ie,"SPAN",{});var Qe=n(j);Ie=d(Qe,"DDIMInverseScheduler"),Qe.forEach(s),ie.forEach(s),oe=p(t),c=o(t,"DIV",{class:!0});var u=n(c);z(C.$$.fragment,u),Se=p(u),I=o(u,"P",{});var ee=n(I);K=o(ee,"CODE",{});var Xe=n(K);Me=d(Xe,"DDIMInverseScheduler"),Xe.forEach(s),ye=d(ee," is the reverse scheduler of "),k=o(ee,"A",{href:!0});var Ze=n(k);$e=d(Ze,"DDIMScheduler"),Ze.forEach(s),xe=d(ee,"."),ee.forEach(s),we=p(u),v=o(u,"P",{});var O=n(v);Te=d(O,"This model inherits from "),L=o(O,"A",{href:!0});var et=n(L);Ee=d(et,"SchedulerMixin"),et.forEach(s),Ce=d(O," and "),q=o(O,"A",{href:!0});var tt=n(q);Pe=d(tt,"ConfigMixin"),tt.forEach(s),Ae=d(O,`. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`),O.forEach(s),Fe=p(u),S=o(u,"DIV",{class:!0});var de=n(S);z(P.$$.fragment,de),Ne=p(de),Q=o(de,"P",{});var st=n(Q);ke=d(st,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),st.forEach(s),de.forEach(s),Le=p(u),M=o(u,"DIV",{class:!0});var ce=n(M);z(A.$$.fragment,ce),qe=p(ce),X=o(ce,"P",{});var rt=n(X);Oe=d(rt,"Sets the discrete timesteps used for the diffusion chain (to be run before inference)."),rt.forEach(s),ce.forEach(s),Ve=p(u),y=o(u,"DIV",{class:!0});var le=n(y);z(F.$$.fragment,le),ze=p(le),Z=o(le,"P",{});var ot=n(Z);Re=d(ot,`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).`),ot.forEach(s),le.forEach(s),u.forEach(s),this.h()},h(){a(m,"name","hf:doc:metadata"),a(m,"content",JSON.stringify(ht)),a(D,"id","ddiminversescheduler"),a(D,"class","header-link block pr-1.5 text-lg no-hover:hidden with-hover:absolute with-hover:p-1.5 with-hover:opacity-0 with-hover:group-hover:opacity-100 with-hover:right-full"),a(D,"href","#ddiminversescheduler"),a(_,"class","relative group"),a(w,"href","https://huggingface.co/papers/2010.02502"),a(w,"rel","nofollow"),a(T,"href","https://huggingface.co/papers/2211.09794.pdf"),a(T,"rel","nofollow"),a(b,"id","diffusers.DDIMInverseScheduler"),a(b,"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"),a(b,"href","#diffusers.DDIMInverseScheduler"),a(g,"class","relative group"),a(k,"href","/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler"),a(L,"href","/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin"),a(q,"href","/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin"),a(S,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(M,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(y,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),a(c,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8")},m(t,f){e(document.head,m),$(t,te,f),$(t,_,f),e(_,D),e(D,W),R(x,W,null),e(_,ue),e(_,H),e(H,he),$(t,se,f),$(t,h,f),e(h,B),e(B,fe),e(h,me),e(h,w),e(w,_e),e(h,ge),e(h,T),e(T,ve),e(h,De),$(t,re,f),$(t,g,f),e(g,b),e(b,Y),R(E,Y,null),e(g,be),e(g,j),e(j,Ie),$(t,oe,f),$(t,c,f),R(C,c,null),e(c,Se),e(c,I),e(I,K),e(K,Me),e(I,ye),e(I,k),e(k,$e),e(I,xe),e(c,we),e(c,v),e(v,Te),e(v,L),e(L,Ee),e(v,Ce),e(v,q),e(q,Pe),e(v,Ae),e(c,Fe),e(c,S),R(P,S,null),e(S,Ne),e(S,Q),e(Q,ke),e(c,Le),e(c,M),R(A,M,null),e(M,qe),e(M,X),e(X,Oe),e(c,Ve),e(c,y),R(F,y,null),e(y,ze),e(y,Z),e(Z,Re),ne=!0},p:lt,i(t){ne||(U(x.$$.fragment,t),U(E.$$.fragment,t),U(C.$$.fragment,t),U(P.$$.fragment,t),U(A.$$.fragment,t),U(F.$$.fragment,t),ne=!0)},o(t){G(x.$$.fragment,t),G(E.$$.fragment,t),G(C.$$.fragment,t),G(P.$$.fragment,t),G(A.$$.fragment,t),G(F.$$.fragment,t),ne=!1},d(t){s(m),t&&s(te),t&&s(_),J(x),t&&s(se),t&&s(h),t&&s(re),t&&s(g),J(E),t&&s(oe),t&&s(c),J(C),J(P),J(A),J(F)}}}const ht={local:"ddiminversescheduler",sections:[{local:"diffusers.DDIMInverseScheduler",title:"DDIMInverseScheduler"}],title:"DDIMInverseScheduler"};function ft(Ue){return pt(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class vt extends at{constructor(m){super();it(this,m,ft,ut,dt,{})}}export{vt as default,ht as metadata};
