import{s as ke,n as Ce,o as Me}from"../chunks/scheduler.182ea377.js";import{S as Fe,i as Oe,g as o,s,r as _,A as Le,h as d,f as t,c as r,j,u as v,x as p,k as I,y as i,a,v as b,d as P,t as x,w as $}from"../chunks/index.abf12888.js";import{D as W}from"../chunks/Docstring.93f6f462.js";import{H as _e}from"../chunks/Heading.16916d63.js";function je(ve){let u,U,V,B,T,J,R,be='<code>RePaintScheduler</code> is a DDPM-based inpainting scheduler for unsupervised inpainting with extreme masks. It is designed to be used with the <a href="/docs/diffusers/v0.22.0/en/api/pipelines/repaint#diffusers.RePaintPipeline">RePaintPipeline</a>, and it is based on the paper <a href="https://huggingface.co/papers/2201.09865" rel="nofollow">RePaint: Inpainting using Denoising Diffusion Probabilistic Models</a> by Andreas Lugmayr et al.',K,S,Pe="The abstract from the paper is:",Q,w,xe="<em>Free-form inpainting is the task of adding new content to an image in the regions specified by an arbitrary binary mask. Most existing approaches train for a certain distribution of masks, which limits their generalization capabilities to unseen mask types. Furthermore, training with pixel-wise and perceptual losses often leads to simple textural extensions towards the missing areas instead of semantically meaningful generation. In this work, we propose RePaint: A Denoising Diffusion Probabilistic Model (DDPM) based inpainting approach that is applicable to even extreme masks. We employ a pretrained unconditional DDPM as the generative prior. To condition the generation process, we only alter the reverse diffusion iterations by sampling the unmasked regions using the given image information. Since this technique does not modify or condition the original DDPM network itself, the model produces high-quality and diverse output images for any inpainting form. We validate our method for both faces and general-purpose image inpainting using standard and extreme masks. RePaint outperforms state-of-the-art Autoregressive, and GAN approaches for at least five out of six mask distributions. Github Repository: git.io/RePaint</em>.",X,y,$e='The original implementation can be found at <a href="https://github.com/andreas128/" rel="nofollow">andreas128/RePaint</a>.',Y,D,Z,l,k,de,H,Te="<code>RePaintScheduler</code> is a scheduler for DDPM inpainting inside a given mask.",le,E,Re=`This model inherits from <a href="/docs/diffusers/v0.22.0/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/v0.22.0/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.`,ce,h,C,pe,q,Se=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ue,f,M,me,A,we="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",he,g,F,fe,N,ye=`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).`,ee,O,te,m,L,ge,z,De="Output class for the scheduler’s step function output.",ne,G,se;return T=new _e({props:{title:"RePaintScheduler",local:"repaintscheduler",headingTag:"h1"}}),D=new _e({props:{title:"RePaintScheduler",local:"diffusers.RePaintScheduler",headingTag:"h2"}}),k=new W({props:{name:"class diffusers.RePaintScheduler",anchor:"diffusers.RePaintScheduler",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:"eta",val:": float = 0.0"},{name:"trained_betas",val:": typing.Optional[numpy.ndarray] = None"},{name:"clip_sample",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.RePaintScheduler.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.RePaintScheduler.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.RePaintScheduler.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.RePaintScheduler.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>, <code>squaredcos_cap_v2</code>, or <code>sigmoid</code>.`,name:"beta_schedule"},{anchor:"diffusers.RePaintScheduler.eta",description:`<strong>eta</strong> (<code>float</code>) &#x2014;
The weight of noise for added noise in diffusion step. If its value is between 0.0 and 1.0 it corresponds
to the DDIM scheduler, and if its value is between -0.0 and 1.0 it corresponds to the DDPM scheduler.`,name:"eta"},{anchor:"diffusers.RePaintScheduler.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.RePaintScheduler.clip_sample",description:`<strong>clip_sample</strong> (<code>bool</code>, defaults to <code>True</code>) &#x2014;
Clip the predicted sample between -1 and 1 for numerical stability.`,name:"clip_sample"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.0/src/diffusers/schedulers/scheduling_repaint.py#L91"}}),C=new W({props:{name:"scale_model_input",anchor:"diffusers.RePaintScheduler.scale_model_input",parameters:[{name:"sample",val:": FloatTensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.RePaintScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.FloatTensor</code>) &#x2014;
The input sample.`,name:"sample"},{anchor:"diffusers.RePaintScheduler.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.22.0/src/diffusers/schedulers/scheduling_repaint.py#L165",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.FloatTensor</code></p>
`}}),M=new W({props:{name:"set_timesteps",anchor:"diffusers.RePaintScheduler.set_timesteps",parameters:[{name:"num_inference_steps",val:": int"},{name:"jump_length",val:": int = 10"},{name:"jump_n_sample",val:": int = 10"},{name:"device",val:": typing.Union[str, torch.device] = None"}],parametersDescription:[{anchor:"diffusers.RePaintScheduler.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. If used,
<code>timesteps</code> must be <code>None</code>.`,name:"num_inference_steps"},{anchor:"diffusers.RePaintScheduler.set_timesteps.jump_length",description:`<strong>jump_length</strong> (<code>int</code>, defaults to 10) &#x2014;
The number of steps taken forward in time before going backward in time for a single jump (&#x201C;j&#x201D; in
RePaint paper). Take a look at Figure 9 and 10 in the paper.`,name:"jump_length"},{anchor:"diffusers.RePaintScheduler.set_timesteps.jump_n_sample",description:`<strong>jump_n_sample</strong> (<code>int</code>, defaults to 10) &#x2014;
The number of times to make a forward time jump for a given chosen time sample. Take a look at Figure 9
and 10 in the paper.`,name:"jump_n_sample"},{anchor:"diffusers.RePaintScheduler.set_timesteps.device",description:`<strong>device</strong> (<code>str</code> or <code>torch.device</code>, <em>optional</em>) &#x2014;
The device to which the timesteps should be moved to. If <code>None</code>, the timesteps are not moved.`,name:"device"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.0/src/diffusers/schedulers/scheduling_repaint.py#L182"}}),F=new W({props:{name:"step",anchor:"diffusers.RePaintScheduler.step",parameters:[{name:"model_output",val:": FloatTensor"},{name:"timestep",val:": int"},{name:"sample",val:": FloatTensor"},{name:"original_image",val:": FloatTensor"},{name:"mask",val:": FloatTensor"},{name:"generator",val:": typing.Optional[torch._C.Generator] = None"},{name:"return_dict",val:": bool = True"}],parametersDescription:[{anchor:"diffusers.RePaintScheduler.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.RePaintScheduler.step.timestep",description:`<strong>timestep</strong> (<code>int</code>) &#x2014;
The current discrete timestep in the diffusion chain.`,name:"timestep"},{anchor:"diffusers.RePaintScheduler.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.RePaintScheduler.step.original_image",description:`<strong>original_image</strong> (<code>torch.FloatTensor</code>) &#x2014;
The original image to inpaint on.`,name:"original_image"},{anchor:"diffusers.RePaintScheduler.step.mask",description:`<strong>mask</strong> (<code>torch.FloatTensor</code>) &#x2014;
The mask where a value of 0.0 indicates which part of the original image to inpaint.`,name:"mask"},{anchor:"diffusers.RePaintScheduler.step.generator",description:`<strong>generator</strong> (<code>torch.Generator</code>, <em>optional</em>) &#x2014;
A random number generator.`,name:"generator"},{anchor:"diffusers.RePaintScheduler.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.22.0/en/api/schedulers/repaint#diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput">RePaintSchedulerOutput</a> or <code>tuple</code>.`,name:"return_dict"}],source:"https://github.com/huggingface/diffusers/blob/v0.22.0/src/diffusers/schedulers/scheduling_repaint.py#L248",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


<p>If return_dict is <code>True</code>, <a
  href="/docs/diffusers/v0.22.0/en/api/schedulers/repaint#diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput"
>RePaintSchedulerOutput</a> 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><a
  href="/docs/diffusers/v0.22.0/en/api/schedulers/repaint#diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput"
>RePaintSchedulerOutput</a> or <code>tuple</code></p>
`}}),O=new _e({props:{title:"RePaintSchedulerOutput",local:"diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput",headingTag:"h2"}}),L=new W({props:{name:"class diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput",anchor:"diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput",parameters:[{name:"prev_sample",val:": FloatTensor"},{name:"pred_original_sample",val:": FloatTensor"}],parametersDescription:[{anchor:"diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput.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 (x_{t-1}) 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_repaint.RePaintSchedulerOutput.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 (x_{0}) 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.22.0/src/diffusers/schedulers/scheduling_repaint.py#L29"}}),{c(){u=o("meta"),U=s(),V=o("p"),B=s(),_(T.$$.fragment),J=s(),R=o("p"),R.innerHTML=be,K=s(),S=o("p"),S.textContent=Pe,Q=s(),w=o("p"),w.innerHTML=xe,X=s(),y=o("p"),y.innerHTML=$e,Y=s(),_(D.$$.fragment),Z=s(),l=o("div"),_(k.$$.fragment),de=s(),H=o("p"),H.innerHTML=Te,le=s(),E=o("p"),E.innerHTML=Re,ce=s(),h=o("div"),_(C.$$.fragment),pe=s(),q=o("p"),q.textContent=Se,ue=s(),f=o("div"),_(M.$$.fragment),me=s(),A=o("p"),A.textContent=we,he=s(),g=o("div"),_(F.$$.fragment),fe=s(),N=o("p"),N.textContent=ye,ee=s(),_(O.$$.fragment),te=s(),m=o("div"),_(L.$$.fragment),ge=s(),z=o("p"),z.textContent=De,ne=s(),G=o("p"),this.h()},l(e){const n=Le("svelte-u9bgzb",document.head);u=d(n,"META",{name:!0,content:!0}),n.forEach(t),U=r(e),V=d(e,"P",{}),j(V).forEach(t),B=r(e),v(T.$$.fragment,e),J=r(e),R=d(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-b02j1t"&&(R.innerHTML=be),K=r(e),S=d(e,"P",{"data-svelte-h":!0}),p(S)!=="svelte-1cwsb16"&&(S.textContent=Pe),Q=r(e),w=d(e,"P",{"data-svelte-h":!0}),p(w)!=="svelte-1im6vlq"&&(w.innerHTML=xe),X=r(e),y=d(e,"P",{"data-svelte-h":!0}),p(y)!=="svelte-1baf0s2"&&(y.innerHTML=$e),Y=r(e),v(D.$$.fragment,e),Z=r(e),l=d(e,"DIV",{class:!0});var c=j(l);v(k.$$.fragment,c),de=r(c),H=d(c,"P",{"data-svelte-h":!0}),p(H)!=="svelte-1c6l7p4"&&(H.innerHTML=Te),le=r(c),E=d(c,"P",{"data-svelte-h":!0}),p(E)!=="svelte-6ikkut"&&(E.innerHTML=Re),ce=r(c),h=d(c,"DIV",{class:!0});var re=j(h);v(C.$$.fragment,re),pe=r(re),q=d(re,"P",{"data-svelte-h":!0}),p(q)!=="svelte-1rkfgpx"&&(q.textContent=Se),re.forEach(t),ue=r(c),f=d(c,"DIV",{class:!0});var ie=j(f);v(M.$$.fragment,ie),me=r(ie),A=d(ie,"P",{"data-svelte-h":!0}),p(A)!=="svelte-1vzm9q"&&(A.textContent=we),ie.forEach(t),he=r(c),g=d(c,"DIV",{class:!0});var ae=j(g);v(F.$$.fragment,ae),fe=r(ae),N=d(ae,"P",{"data-svelte-h":!0}),p(N)!=="svelte-hi84tp"&&(N.textContent=ye),ae.forEach(t),c.forEach(t),ee=r(e),v(O.$$.fragment,e),te=r(e),m=d(e,"DIV",{class:!0});var oe=j(m);v(L.$$.fragment,oe),ge=r(oe),z=d(oe,"P",{"data-svelte-h":!0}),p(z)!=="svelte-7snghh"&&(z.textContent=De),oe.forEach(t),ne=r(e),G=d(e,"P",{}),j(G).forEach(t),this.h()},h(){I(u,"name","hf:doc:metadata"),I(u,"content",Ie),I(h,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(f,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(g,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(l,"class","docstring border-l-2 border-t-2 pl-4 pt-3.5 border-gray-100 rounded-tl-xl mb-6 mt-8"),I(m,"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){i(document.head,u),a(e,U,n),a(e,V,n),a(e,B,n),b(T,e,n),a(e,J,n),a(e,R,n),a(e,K,n),a(e,S,n),a(e,Q,n),a(e,w,n),a(e,X,n),a(e,y,n),a(e,Y,n),b(D,e,n),a(e,Z,n),a(e,l,n),b(k,l,null),i(l,de),i(l,H),i(l,le),i(l,E),i(l,ce),i(l,h),b(C,h,null),i(h,pe),i(h,q),i(l,ue),i(l,f),b(M,f,null),i(f,me),i(f,A),i(l,he),i(l,g),b(F,g,null),i(g,fe),i(g,N),a(e,ee,n),b(O,e,n),a(e,te,n),a(e,m,n),b(L,m,null),i(m,ge),i(m,z),a(e,ne,n),a(e,G,n),se=!0},p:Ce,i(e){se||(P(T.$$.fragment,e),P(D.$$.fragment,e),P(k.$$.fragment,e),P(C.$$.fragment,e),P(M.$$.fragment,e),P(F.$$.fragment,e),P(O.$$.fragment,e),P(L.$$.fragment,e),se=!0)},o(e){x(T.$$.fragment,e),x(D.$$.fragment,e),x(k.$$.fragment,e),x(C.$$.fragment,e),x(M.$$.fragment,e),x(F.$$.fragment,e),x(O.$$.fragment,e),x(L.$$.fragment,e),se=!1},d(e){e&&(t(U),t(V),t(B),t(J),t(R),t(K),t(S),t(Q),t(w),t(X),t(y),t(Y),t(Z),t(l),t(ee),t(te),t(m),t(ne),t(G)),t(u),$(T,e),$(D,e),$(k),$(C),$(M),$(F),$(O,e),$(L)}}}const Ie='{"title":"RePaintScheduler","local":"repaintscheduler","sections":[{"title":"RePaintScheduler","local":"diffusers.RePaintScheduler","sections":[],"depth":2},{"title":"RePaintSchedulerOutput","local":"diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput","sections":[],"depth":2}],"depth":1}';function He(ve){return Me(()=>{new URLSearchParams(window.location.search).get("fw")}),[]}class ze extends Fe{constructor(u){super(),Oe(this,u,He,je,ke,{})}}export{ze as component};
