import{s as Me,n as Oe,o as Le}from"../chunks/scheduler.8c3d61f6.js";import{S as Ee,i as He,g as o,s,r as h,A as Ie,h as d,f as t,c as r,j as I,u as f,x as p,k as j,y as a,a as i,v as g,d as _,t as b,w as v}from"../chunks/index.da70eac4.js";import{D as W}from"../chunks/Docstring.6b390b9a.js";import{H as ve,E as je}from"../chunks/EditOnGithub.1e64e623.js";function qe(Pe){let u,B,F,J,T,K,R,xe='<code>RePaintScheduler</code> is a DDPM-based inpainting scheduler for unsupervised inpainting with extreme masks. It is designed to be used with the <code>RePaintPipeline</code>, 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.',Q,S,$e="The abstract from the paper is:",X,w,Te='<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: <a href="http://git.io/RePaint" rel="nofollow">this http URL</a>.</em>',Y,y,Re='The original implementation can be found at <a href="https://github.com/andreas128/" rel="nofollow">andreas128/RePaint</a>.',Z,D,ee,c,C,le,q,Se="<code>RePaintScheduler</code> is a scheduler for DDPM inpainting inside a given mask.",pe,A,we=`This model inherits from <a href="/docs/diffusers/pr_10033/en/api/schedulers/overview#diffusers.SchedulerMixin">SchedulerMixin</a> and <a href="/docs/diffusers/pr_10033/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.`,ue,P,k,me,N,ye=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,he,x,M,fe,z,De="Sets the discrete timesteps used for the diffusion chain (to be run before inference).",ge,$,O,_e,G,Ce=`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).`,te,L,ne,m,E,be,V,ke="Output class for the scheduler’s step function output.",se,H,re,U,ie;return T=new ve({props:{title:"RePaintScheduler",local:"repaintscheduler",headingTag:"h1"}}),D=new ve({props:{title:"RePaintScheduler",local:"diffusers.RePaintScheduler",headingTag:"h2"}}),C=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/vr_10033/src/diffusers/schedulers/scheduling_repaint.py#L91"}}),k=new W({props:{name:"scale_model_input",anchor:"diffusers.RePaintScheduler.scale_model_input",parameters:[{name:"sample",val:": Tensor"},{name:"timestep",val:": typing.Optional[int] = None"}],parametersDescription:[{anchor:"diffusers.RePaintScheduler.scale_model_input.sample",description:`<strong>sample</strong> (<code>torch.Tensor</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/vr_10033/src/diffusers/schedulers/scheduling_repaint.py#L163",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>
`}}),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/vr_10033/src/diffusers/schedulers/scheduling_repaint.py#L180"}}),O=new W({props:{name:"step",anchor:"diffusers.RePaintScheduler.step",parameters:[{name:"model_output",val:": Tensor"},{name:"timestep",val:": int"},{name:"sample",val:": Tensor"},{name:"original_image",val:": Tensor"},{name:"mask",val:": Tensor"},{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.Tensor</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.Tensor</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.Tensor</code>) &#x2014;
The original image to inpaint on.`,name:"original_image"},{anchor:"diffusers.RePaintScheduler.step.mask",description:`<strong>mask</strong> (<code>torch.Tensor</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/pr_10033/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/vr_10033/src/diffusers/schedulers/scheduling_repaint.py#L246",returnDescription:`<script context="module">export const metadata = 'undefined';<\/script>


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