import{S as Tt,i as At,s as kt,e as r,k as p,w as H,t as a,M as Nt,c as n,d as s,m as h,a as o,x as J,h as i,b as d,G as e,g as v,y as U,L as Pt,q as B,o as W,B as Y,v as Ct}from"../../../chunks/vendor-hf-doc-builder.js";import{D as nt}from"../../../chunks/Docstring-hf-doc-builder.js";import{I as ot}from"../../../chunks/IconCopyLink-hf-doc-builder.js";function Ft(at){let _,ie,g,y,j,$,be,K,De,de,b,M,Q,E,Ie,X,ye,le,D,Me,T,Se,we,A,xe,ce,I,S,Z,k,$e,ee,Ee,fe,c,N,Te,P,Ae,L,ke,Ne,Pe,l,O,Ce,Fe,te,ze,Le,se,Oe,qe,re,Re,Ve,q,Ge,He,R,Je,Ue,V,Be,We,Ye,G,je,C,Ke,Qe,w,F,Xe,ne,Ze,et,x,z,tt,oe,st,pe;return $=new ot({}),E=new ot({}),k=new ot({}),N=new nt({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>) &#x2014; number of diffusion steps used to train the model.",name:"num_train_timesteps"},{anchor:"diffusers.DDIMInverseScheduler.beta_start",description:"<strong>beta_start</strong> (<code>float</code>) &#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>) &#x2014; the final <code>beta</code> value.",name:"beta_end"},{anchor:"diffusers.DDIMInverseScheduler.beta_schedule",description:`<strong>beta_schedule</strong> (<code>str</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>, optional) &#x2014;
option to pass an array of betas directly to the constructor to bypass <code>beta_start</code>, <code>beta_end</code> etc.`,name:"trained_betas"},{anchor:"diffusers.DDIMInverseScheduler.clip_sample",description:`<strong>clip_sample</strong> (<code>bool</code>, default <code>True</code>) &#x2014;
option to clip predicted sample for numerical stability.`,name:"clip_sample"},{anchor:"diffusers.DDIMInverseScheduler.clip_sample_range",description:`<strong>clip_sample_range</strong> (<code>float</code>, default <code>1.0</code>) &#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_zero",description:`<strong>set_alpha_to_zero</strong> (<code>bool</code>, default <code>True</code>) &#x2014;
each diffusion step uses the value of alphas product 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>0</code>,
otherwise it uses the value of alpha at step <code>num_train_timesteps - 1</code>.`,name:"set_alpha_to_zero"},{anchor:"diffusers.DDIMInverseScheduler.steps_offset",description:`<strong>steps_offset</strong> (<code>int</code>, default <code>0</code>) &#x2014;
an offset added to the inference steps. You can use a combination of <code>offset=1</code> and
<code>set_alpha_to_zero=False</code>, to make the last step use step <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>, default <code>epsilon</code>, optional) &#x2014;
prediction type of the scheduler function, one of <code>epsilon</code> (predicting the noise of the diffusion
process), <code>sample</code> (directly predicting the noisy sample<code>) or </code>v_prediction\` (see section 2.4
<a href="https://imagen.research.google/video/paper.pdf" rel="nofollow">https://imagen.research.google/video/paper.pdf</a>)`,name:"prediction_type"},{anchor:"diffusers.DDIMInverseScheduler.timestep_spacing",description:`<strong>timestep_spacing</strong> (<code>str</code>, default <code>&quot;leading&quot;</code>) &#x2014;
The way the timesteps should be scaled. Refer to Table 2. of <a href="https://arxiv.org/abs/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>, default <code>False</code>) &#x2014;
whether to rescale the betas to have zero terminal SNR (proposed by <a href="https://arxiv.org/pdf/2305.08891.pdf" rel="nofollow">https://arxiv.org/pdf/2305.08891.pdf</a>).
This can enable 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.19.2/src/diffusers/schedulers/scheduling_ddim_inverse.py#L130"}}),F=new nt({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; input sample",name:"sample"},{anchor:"diffusers.DDIMInverseScheduler.scale_model_input.timestep",description:"<strong>timestep</strong> (<code>int</code>, optional) &#x2014; current timestep",name:"timestep"}],source:"https://github.com/huggingface/diffusers/blob/v0.19.2/src/diffusers/schedulers/scheduling_ddim_inverse.py#L240",returnDescription:`
<p>scaled input sample</p>
`,returnType:`
<p><code>torch.FloatTensor</code></p>
`}}),z=new nt({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/v0.19.2/src/diffusers/schedulers/scheduling_ddim_inverse.py#L254"}}),{c(){_=r("meta"),ie=p(),g=r("h1"),y=r("a"),j=r("span"),H($.$$.fragment),be=p(),K=r("span"),De=a("Inverse Denoising Diffusion Implicit Models (DDIMInverse)"),de=p(),b=r("h2"),M=r("a"),Q=r("span"),H(E.$$.fragment),Ie=p(),X=r("span"),ye=a("Overview"),le=p(),D=r("p"),Me=a("This scheduler is the inverted scheduler of "),T=r("a"),Se=a("Denoising Diffusion Implicit Models"),we=a(` (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
The implementation is mostly based on the DDIM inversion definition of `),A=r("a"),xe=a("Null-text Inversion for Editing Real Images using Guided Diffusion Models"),ce=p(),I=r("h2"),S=r("a"),Z=r("span"),H(k.$$.fragment),$e=p(),ee=r("span"),Ee=a("DDIMInverseScheduler"),fe=p(),c=r("div"),H(N.$$.fragment),Te=p(),P=r("p"),Ae=a("DDIMInverseScheduler is the reverse scheduler of "),L=r("a"),ke=a("DDIMScheduler"),Ne=a("."),Pe=p(),l=r("p"),O=r("a"),Ce=a("~ConfigMixin"),Fe=a(" takes care of storing all config attributes that are passed in the scheduler\u2019s "),te=r("code"),ze=a("__init__"),Le=a(`
function, such as `),se=r("code"),Oe=a("num_train_timesteps"),qe=a(". They can be accessed via "),re=r("code"),Re=a("scheduler.config.num_train_timesteps"),Ve=a(`.
`),q=r("a"),Ge=a("SchedulerMixin"),He=a(" provides general loading and saving functionality via the "),R=r("a"),Je=a("SchedulerMixin.save_pretrained()"),Ue=a(` and
`),V=r("a"),Be=a("from_pretrained()"),We=a(" functions."),Ye=p(),G=r("p"),je=a("For more details, see the original paper: "),C=r("a"),Ke=a("https://arxiv.org/abs/2010.02502"),Qe=p(),w=r("div"),H(F.$$.fragment),Xe=p(),ne=r("p"),Ze=a(`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),et=p(),x=r("div"),H(z.$$.fragment),tt=p(),oe=r("p"),st=a("Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference."),this.h()},l(t){const u=Nt('[data-svelte="svelte-1phssyn"]',document.head);_=n(u,"META",{name:!0,content:!0}),u.forEach(s),ie=h(t),g=n(t,"H1",{class:!0});var he=o(g);y=n(he,"A",{id:!0,class:!0,href:!0});var it=o(y);j=n(it,"SPAN",{});var dt=o(j);J($.$$.fragment,dt),dt.forEach(s),it.forEach(s),be=h(he),K=n(he,"SPAN",{});var lt=o(K);De=i(lt,"Inverse Denoising Diffusion Implicit Models (DDIMInverse)"),lt.forEach(s),he.forEach(s),de=h(t),b=n(t,"H2",{class:!0});var ue=o(b);M=n(ue,"A",{id:!0,class:!0,href:!0});var ct=o(M);Q=n(ct,"SPAN",{});var ft=o(Q);J(E.$$.fragment,ft),ft.forEach(s),ct.forEach(s),Ie=h(ue),X=n(ue,"SPAN",{});var pt=o(X);ye=i(pt,"Overview"),pt.forEach(s),ue.forEach(s),le=h(t),D=n(t,"P",{});var ae=o(D);Me=i(ae,"This scheduler is the inverted scheduler of "),T=n(ae,"A",{href:!0,rel:!0});var ht=o(T);Se=i(ht,"Denoising Diffusion Implicit Models"),ht.forEach(s),we=i(ae,` (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
The implementation is mostly based on the DDIM inversion definition of `),A=n(ae,"A",{href:!0,rel:!0});var ut=o(A);xe=i(ut,"Null-text Inversion for Editing Real Images using Guided Diffusion Models"),ut.forEach(s),ae.forEach(s),ce=h(t),I=n(t,"H2",{class:!0});var me=o(I);S=n(me,"A",{id:!0,class:!0,href:!0});var mt=o(S);Z=n(mt,"SPAN",{});var vt=o(Z);J(k.$$.fragment,vt),vt.forEach(s),mt.forEach(s),$e=h(me),ee=n(me,"SPAN",{});var _t=o(ee);Ee=i(_t,"DDIMInverseScheduler"),_t.forEach(s),me.forEach(s),fe=h(t),c=n(t,"DIV",{class:!0});var m=o(c);J(N.$$.fragment,m),Te=h(m),P=n(m,"P",{});var ve=o(P);Ae=i(ve,"DDIMInverseScheduler is the reverse scheduler of "),L=n(ve,"A",{href:!0});var gt=o(L);ke=i(gt,"DDIMScheduler"),gt.forEach(s),Ne=i(ve,"."),ve.forEach(s),Pe=h(m),l=n(m,"P",{});var f=o(l);O=n(f,"A",{href:!0});var bt=o(O);Ce=i(bt,"~ConfigMixin"),bt.forEach(s),Fe=i(f," takes care of storing all config attributes that are passed in the scheduler\u2019s "),te=n(f,"CODE",{});var Dt=o(te);ze=i(Dt,"__init__"),Dt.forEach(s),Le=i(f,`
function, such as `),se=n(f,"CODE",{});var It=o(se);Oe=i(It,"num_train_timesteps"),It.forEach(s),qe=i(f,". They can be accessed via "),re=n(f,"CODE",{});var yt=o(re);Re=i(yt,"scheduler.config.num_train_timesteps"),yt.forEach(s),Ve=i(f,`.
`),q=n(f,"A",{href:!0});var Mt=o(q);Ge=i(Mt,"SchedulerMixin"),Mt.forEach(s),He=i(f," provides general loading and saving functionality via the "),R=n(f,"A",{href:!0});var St=o(R);Je=i(St,"SchedulerMixin.save_pretrained()"),St.forEach(s),Ue=i(f,` and
`),V=n(f,"A",{href:!0});var wt=o(V);Be=i(wt,"from_pretrained()"),wt.forEach(s),We=i(f," functions."),f.forEach(s),Ye=h(m),G=n(m,"P",{});var rt=o(G);je=i(rt,"For more details, see the original paper: "),C=n(rt,"A",{href:!0,rel:!0});var xt=o(C);Ke=i(xt,"https://arxiv.org/abs/2010.02502"),xt.forEach(s),rt.forEach(s),Qe=h(m),w=n(m,"DIV",{class:!0});var _e=o(w);J(F.$$.fragment,_e),Xe=h(_e),ne=n(_e,"P",{});var $t=o(ne);Ze=i($t,`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`),$t.forEach(s),_e.forEach(s),et=h(m),x=n(m,"DIV",{class:!0});var ge=o(x);J(z.$$.fragment,ge),tt=h(ge),oe=n(ge,"P",{});var Et=o(oe);st=i(Et,"Sets the discrete timesteps used for the diffusion chain. Supporting function to be run before inference."),Et.forEach(s),ge.forEach(s),m.forEach(s),this.h()},h(){d(_,"name","hf:doc:metadata"),d(_,"content",JSON.stringify(zt)),d(y,"id","inverse-denoising-diffusion-implicit-models-ddiminverse"),d(y,"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(y,"href","#inverse-denoising-diffusion-implicit-models-ddiminverse"),d(g,"class","relative group"),d(M,"id","overview"),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","#overview"),d(b,"class","relative group"),d(T,"href","https://arxiv.org/abs/2010.02502"),d(T,"rel","nofollow"),d(A,"href","https://arxiv.org/pdf/2211.09794.pdf"),d(A,"rel","nofollow"),d(S,"id","diffusers.DDIMInverseScheduler"),d(S,"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(S,"href","#diffusers.DDIMInverseScheduler"),d(I,"class","relative group"),d(L,"href","/docs/diffusers/v0.19.2/en/api/schedulers/ddim#diffusers.DDIMScheduler"),d(O,"href","/docs/diffusers/v0.19.2/en/api/configuration#diffusers.ConfigMixin"),d(q,"href","/docs/diffusers/v0.19.2/en/api/schedulers/overview#diffusers.SchedulerMixin"),d(R,"href","/docs/diffusers/v0.19.2/en/api/schedulers/overview#diffusers.SchedulerMixin.save_pretrained"),d(V,"href","/docs/diffusers/v0.19.2/en/api/schedulers/overview#diffusers.SchedulerMixin.from_pretrained"),d(C,"href","https://arxiv.org/abs/2010.02502"),d(C,"rel","nofollow"),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(x,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),d(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,u){e(document.head,_),v(t,ie,u),v(t,g,u),e(g,y),e(y,j),U($,j,null),e(g,be),e(g,K),e(K,De),v(t,de,u),v(t,b,u),e(b,M),e(M,Q),U(E,Q,null),e(b,Ie),e(b,X),e(X,ye),v(t,le,u),v(t,D,u),e(D,Me),e(D,T),e(T,Se),e(D,we),e(D,A),e(A,xe),v(t,ce,u),v(t,I,u),e(I,S),e(S,Z),U(k,Z,null),e(I,$e),e(I,ee),e(ee,Ee),v(t,fe,u),v(t,c,u),U(N,c,null),e(c,Te),e(c,P),e(P,Ae),e(P,L),e(L,ke),e(P,Ne),e(c,Pe),e(c,l),e(l,O),e(O,Ce),e(l,Fe),e(l,te),e(te,ze),e(l,Le),e(l,se),e(se,Oe),e(l,qe),e(l,re),e(re,Re),e(l,Ve),e(l,q),e(q,Ge),e(l,He),e(l,R),e(R,Je),e(l,Ue),e(l,V),e(V,Be),e(l,We),e(c,Ye),e(c,G),e(G,je),e(G,C),e(C,Ke),e(c,Qe),e(c,w),U(F,w,null),e(w,Xe),e(w,ne),e(ne,Ze),e(c,et),e(c,x),U(z,x,null),e(x,tt),e(x,oe),e(oe,st),pe=!0},p:Pt,i(t){pe||(B($.$$.fragment,t),B(E.$$.fragment,t),B(k.$$.fragment,t),B(N.$$.fragment,t),B(F.$$.fragment,t),B(z.$$.fragment,t),pe=!0)},o(t){W($.$$.fragment,t),W(E.$$.fragment,t),W(k.$$.fragment,t),W(N.$$.fragment,t),W(F.$$.fragment,t),W(z.$$.fragment,t),pe=!1},d(t){s(_),t&&s(ie),t&&s(g),Y($),t&&s(de),t&&s(b),Y(E),t&&s(le),t&&s(D),t&&s(ce),t&&s(I),Y(k),t&&s(fe),t&&s(c),Y(N),Y(F),Y(z)}}}const zt={local:"inverse-denoising-diffusion-implicit-models-ddiminverse",sections:[{local:"overview",title:"Overview"},{local:"diffusers.DDIMInverseScheduler",title:"DDIMInverseScheduler"}],title:"Inverse Denoising Diffusion Implicit Models (DDIMInverse)"};function Lt(at){return Ct(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Vt extends Tt{constructor(_){super();At(this,_,Lt,Ft,kt,{})}}export{Vt as default,zt as metadata};
