import{s as Ce,n as ke,o as Me}from"../chunks/scheduler.182ea377.js";import{S as Fe,i as Le,g as o,s,r as _,A as Oe,h as d,f as t,c as r,j as H,u as b,x as p,k as I,y as i,a,v,d as P,t as x,w as $}from"../chunks/index.1ea56653.js";import{H as _e,g as He}from"../chunks/Heading.71ac6e9f.js";import{D as U}from"../chunks/Docstring.59aaf0cd.js";function Ie(be){let u,W,G,B,T,J,R,ve='<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/main/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: <a href="http://git.io/RePaint" rel="nofollow">this http URL</a>.</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,C,de,j,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/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.`,ce,h,k,pe,A,Se=`Ensures interchangeability with schedulers that need to scale the denoising model input depending on the
current timestep.`,ue,f,M,me,q,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,L,te,m,O,ge,z,De="Output class for the scheduler’s step function output.",ne,V,se;return T=new _e({props:{title:"RePaintScheduler",local:"repaintscheduler",headingTag:"h1"}}),D=new _e({props:{title:"RePaintScheduler",local:"diffusers.RePaintScheduler",headingTag:"h2"}}),C=new U({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/main/src/diffusers/schedulers/scheduling_repaint.py#L91"}}),k=new U({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/main/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 U({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/main/src/diffusers/schedulers/scheduling_repaint.py#L182"}}),F=new U({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/main/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/main/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/main/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/main/en/api/schedulers/repaint#diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput"
>RePaintSchedulerOutput</a> or <code>tuple</code></p>
`}}),L=new _e({props:{title:"RePaintSchedulerOutput",local:"diffusers.schedulers.scheduling_repaint.RePaintSchedulerOutput",headingTag:"h2"}}),O=new U({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/main/src/diffusers/schedulers/scheduling_repaint.py#L29"}}),{c(){u=o("meta"),W=s(),G=o("p"),B=s(),_(T.$$.fragment),J=s(),R=o("p"),R.innerHTML=ve,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"),_(C.$$.fragment),de=s(),j=o("p"),j.innerHTML=Te,le=s(),E=o("p"),E.innerHTML=Re,ce=s(),h=o("div"),_(k.$$.fragment),pe=s(),A=o("p"),A.textContent=Se,ue=s(),f=o("div"),_(M.$$.fragment),me=s(),q=o("p"),q.textContent=we,he=s(),g=o("div"),_(F.$$.fragment),fe=s(),N=o("p"),N.textContent=ye,ee=s(),_(L.$$.fragment),te=s(),m=o("div"),_(O.$$.fragment),ge=s(),z=o("p"),z.textContent=De,ne=s(),V=o("p"),this.h()},l(e){const n=Oe("svelte-u9bgzb",document.head);u=d(n,"META",{name:!0,content:!0}),n.forEach(t),W=r(e),G=d(e,"P",{}),H(G).forEach(t),B=r(e),b(T.$$.fragment,e),J=r(e),R=d(e,"P",{"data-svelte-h":!0}),p(R)!=="svelte-19byr4y"&&(R.innerHTML=ve),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-7o5mek"&&(w.innerHTML=xe),X=r(e),y=d(e,"P",{"data-svelte-h":!0}),p(y)!=="svelte-1baf0s2"&&(y.innerHTML=$e),Y=r(e),b(D.$$.fragment,e),Z=r(e),l=d(e,"DIV",{class:!0});var c=H(l);b(C.$$.fragment,c),de=r(c),j=d(c,"P",{"data-svelte-h":!0}),p(j)!=="svelte-1c6l7p4"&&(j.innerHTML=Te),le=r(c),E=d(c,"P",{"data-svelte-h":!0}),p(E)!=="svelte-linuuh"&&(E.innerHTML=Re),ce=r(c),h=d(c,"DIV",{class:!0});var re=H(h);b(k.$$.fragment,re),pe=r(re),A=d(re,"P",{"data-svelte-h":!0}),p(A)!=="svelte-1rkfgpx"&&(A.textContent=Se),re.forEach(t),ue=r(c),f=d(c,"DIV",{class:!0});var ie=H(f);b(M.$$.fragment,ie),me=r(ie),q=d(ie,"P",{"data-svelte-h":!0}),p(q)!=="svelte-1vzm9q"&&(q.textContent=we),ie.forEach(t),he=r(c),g=d(c,"DIV",{class:!0});var ae=H(g);b(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),b(L.$$.fragment,e),te=r(e),m=d(e,"DIV",{class:!0});var oe=H(m);b(O.$$.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),V=d(e,"P",{}),H(V).forEach(t),this.h()},h(){I(u,"name","hf:doc:metadata"),I(u,"content",je),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,W,n),a(e,G,n),a(e,B,n),v(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),v(D,e,n),a(e,Z,n),a(e,l,n),v(C,l,null),i(l,de),i(l,j),i(l,le),i(l,E),i(l,ce),i(l,h),v(k,h,null),i(h,pe),i(h,A),i(l,ue),i(l,f),v(M,f,null),i(f,me),i(f,q),i(l,he),i(l,g),v(F,g,null),i(g,fe),i(g,N),a(e,ee,n),v(L,e,n),a(e,te,n),a(e,m,n),v(O,m,null),i(m,ge),i(m,z),a(e,ne,n),a(e,V,n),se=!0},p:ke,i(e){se||(P(T.$$.fragment,e),P(D.$$.fragment,e),P(C.$$.fragment,e),P(k.$$.fragment,e),P(M.$$.fragment,e),P(F.$$.fragment,e),P(L.$$.fragment,e),P(O.$$.fragment,e),se=!0)},o(e){x(T.$$.fragment,e),x(D.$$.fragment,e),x(C.$$.fragment,e),x(k.$$.fragment,e),x(M.$$.fragment,e),x(F.$$.fragment,e),x(L.$$.fragment,e),x(O.$$.fragment,e),se=!1},d(e){e&&(t(W),t(G),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(V)),t(u),$(T,e),$(D,e),$(C),$(k),$(M),$(F),$(L,e),$(O)}}}const je='{"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 Ee(be){return Me(()=>{new URLSearchParams(window.location.search).get("fw"),window.hfDocGoto=He}),[]}class Ge extends Fe{constructor(u){super(),Le(this,u,Ee,Ie,Ce,{})}}export{Ge as component};
