import{s as he,n as ge,o as _e}from"../chunks/scheduler.53228c21.js";import{S as ve,i as be,e as a,s as o,c as h,h as De,a as d,d as t,b as i,f as H,g,j as N,k as V,l as r,m as l,n as _,t as v,o as b,p as D}from"../chunks/index.100fac89.js";import{C as Ie}from"../chunks/CopyLLMTxtMenu.fb2ec027.js";import{D as Y}from"../chunks/Docstring.86a664ae.js";import{H as fe,E as xe}from"../chunks/MermaidChart.svelte_svelte_type_style_lang.09d4dba9.js";function $e(ae){let p,F,k,O,I,R,x,U,$,de=`<code>DDIMInverseScheduler</code> is the inverted scheduler from <a href="https://huggingface.co/papers/2010.02502" rel="nofollow">Denoising Diffusion Implicit Models</a> (DDIM) by Jiaming Song, Chenlin Meng and Stefano Ermon.
The implementation is mostly based on the DDIM inversion definition from <a href="https://huggingface.co/papers/2211.09794" rel="nofollow">Null-text Inversion for Editing Real Images using Guided Diffusion Models</a>.`,W,M,G,n,S,Z,L,ce='<code>DDIMInverseScheduler</code> is the reverse scheduler of <a href="/docs/diffusers/main/en/api/schedulers/ddim#diffusers.DDIMScheduler">DDIMScheduler</a>.',ee,E,le=`This model inherits from <a href="/docs/diffusers/main/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/main/en/api/configuration#diffusers.ConfigMixin">ConfigMixin</a>. Check the superclass documentation for the generic
methods the library implements for all schedulers such as loading and saving.`,te,u,y,se,P,pe=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ne,m,T,re,q,ue="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",oe,f,w,ie,z,me=`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).`,j,C,J,A,B;return I=new Ie({props:{containerStyle:"float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"}}),x=new fe({props:{title:"DDIMInverseScheduler",local:"ddiminversescheduler",headingTag:"h1"}}),M=new fe({props:{title:"DDIMInverseScheduler",local:"diffusers.DDIMInverseScheduler",headingTag:"h2"}}),S=new Y({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, as required by some model families.`,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"}}),y=new Y({props:{name:"scale_model_input",anchor:"diffusers.DDIMInverseScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.DDIMInverseScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</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#L234",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>A scaled input sample.</p>
`,returnType:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>torch.Tensor</code></p>
`}}),T=new Y({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#L251"}}),w=new Y({props:{name:"step",anchor:"diffusers.DDIMInverseScheduler.step",parameters:[{name:"model_output",val:": Tensor"},{name:"timestep",val:": int"},{name:"sample",val:": Tensor"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.DDIMInverseScheduler.step.model_output",description:`<strong>model_output</strong> (<code>torch.Tensor</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.Tensor</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.Tensor</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#L289",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<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:`<script context="module">export const metadata = 'undefined';<\/script>


<p><code>~schedulers.scheduling_ddim_inverse.DDIMInverseSchedulerOutput</code> or <code>tuple</code></p>
`}}),C=new xe({props:{source:"https://github.com/huggingface/diffusers/blob/main/docs/source/en/api/schedulers/ddim_inverse.md"}}),{c(){p=a("meta"),F=o(),k=a("p"),O=o(),h(I.$$.fragment),R=o(),h(x.$$.fragment),U=o(),$=a("p"),$.innerHTML=de,W=o(),h(M.$$.fragment),G=o(),n=a("div"),h(S.$$.fragment),Z=o(),L=a("p"),L.innerHTML=ce,ee=o(),E=a("p"),E.innerHTML=le,te=o(),u=a("div"),h(y.$$.fragment),se=o(),P=a("p"),P.textContent=pe,ne=o(),m=a("div"),h(T.$$.fragment),re=o(),q=a("p"),q.textContent=ue,oe=o(),f=a("div"),h(w.$$.fragment),ie=o(),z=a("p"),z.textContent=me,j=o(),h(C.$$.fragment),J=o(),A=a("p"),this.h()},l(e){const s=De("svelte-u9bgzb",document.head);p=d(s,"META",{name:!0,content:!0}),s.forEach(t),F=i(e),k=d(e,"P",{}),H(k).forEach(t),O=i(e),g(I.$$.fragment,e),R=i(e),g(x.$$.fragment,e),U=i(e),$=d(e,"P",{"data-svelte-h":!0}),N($)!=="svelte-1s84ru"&&($.innerHTML=de),W=i(e),g(M.$$.fragment,e),G=i(e),n=d(e,"DIV",{class:!0});var c=H(n);g(S.$$.fragment,c),Z=i(c),L=d(c,"P",{"data-svelte-h":!0}),N(L)!=="svelte-1ulcci3"&&(L.innerHTML=ce),ee=i(c),E=d(c,"P",{"data-svelte-h":!0}),N(E)!=="svelte-linuuh"&&(E.innerHTML=le),te=i(c),u=d(c,"DIV",{class:!0});var K=H(u);g(y.$$.fragment,K),se=i(K),P=d(K,"P",{"data-svelte-h":!0}),N(P)!=="svelte-1rkfgpx"&&(P.textContent=pe),K.forEach(t),ne=i(c),m=d(c,"DIV",{class:!0});var Q=H(m);g(T.$$.fragment,Q),re=i(Q),q=d(Q,"P",{"data-svelte-h":!0}),N(q)!=="svelte-1vzm9q"&&(q.textContent=ue),Q.forEach(t),oe=i(c),f=d(c,"DIV",{class:!0});var X=H(f);g(w.$$.fragment,X),ie=i(X),z=d(X,"P",{"data-svelte-h":!0}),N(z)!=="svelte-hi84tp"&&(z.textContent=me),X.forEach(t),c.forEach(t),j=i(e),g(C.$$.fragment,e),J=i(e),A=d(e,"P",{}),H(A).forEach(t),this.h()},h(){V(p,"name","hf:doc:metadata"),V(p,"content",Me),V(u,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(m,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),V(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,s){r(document.head,p),l(e,F,s),l(e,k,s),l(e,O,s),_(I,e,s),l(e,R,s),_(x,e,s),l(e,U,s),l(e,$,s),l(e,W,s),_(M,e,s),l(e,G,s),l(e,n,s),_(S,n,null),r(n,Z),r(n,L),r(n,ee),r(n,E),r(n,te),r(n,u),_(y,u,null),r(u,se),r(u,P),r(n,ne),r(n,m),_(T,m,null),r(m,re),r(m,q),r(n,oe),r(n,f),_(w,f,null),r(f,ie),r(f,z),l(e,j,s),_(C,e,s),l(e,J,s),l(e,A,s),B=!0},p:ge,i(e){B||(v(I.$$.fragment,e),v(x.$$.fragment,e),v(M.$$.fragment,e),v(S.$$.fragment,e),v(y.$$.fragment,e),v(T.$$.fragment,e),v(w.$$.fragment,e),v(C.$$.fragment,e),B=!0)},o(e){b(I.$$.fragment,e),b(x.$$.fragment,e),b(M.$$.fragment,e),b(S.$$.fragment,e),b(y.$$.fragment,e),b(T.$$.fragment,e),b(w.$$.fragment,e),b(C.$$.fragment,e),B=!1},d(e){e&&(t(F),t(k),t(O),t(R),t(U),t($),t(W),t(G),t(n),t(j),t(J),t(A)),t(p),D(I,e),D(x,e),D(M,e),D(S),D(y),D(T),D(w),D(C,e)}}}const Me='{"title":"DDIMInverseScheduler","local":"ddiminversescheduler","sections":[{"title":"DDIMInverseScheduler","local":"diffusers.DDIMInverseScheduler","sections":[],"depth":2}],"depth":1}';function Se(ae){return _e(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class Ee extends ve{constructor(p){super(),be(this,p,Se,$e,he,{})}}export{Ee as component};
