Paper commentary
RePaint: Inpainting using Denoising Diffusion Probabilistic Models
RePaint fills masked image regions using an unconditionally trained diffusion model
- Problem Inpainting models trained on one mask distribution generalize poorly to mask shapes they never saw, especially extreme masks. Training them also tends to produce textures rather than meaningful content.
- Method RePaint keeps a pretrained unconditional DDPM fixed and changes only the reverse steps, filling known pixels from the ground truth. It repeats steps by diffusing the output back to a noisier state and denoising again.
- Results RePaint reaches LPIPS 0.029 on CelebA-HQ Super-Resolve 2× masks, versus 0.177 for LaMa.
Why mask-specific training limits inpainting
Free-form inpainting asks a model to fill regions of arbitrary shape, from thin brushes to masks that hide most of the image. The filled content has to blend with the surrounding pixels and also make semantic sense.
The strongest recent approaches rely on GANs or autoregressive models, and they are typically trained against a particular family of masks. A model tuned to one mask distribution can generalize poorly to mask types it did not see during training. The question this work asks is whether a DDPM trained only for unconditional image synthesis can be steered at inference time, so that no mask-specific training is needed.
Conditioning a fixed DDPM through the reverse steps
A DDPM is trained to reverse a fixed Gaussian noising process, and sampling starts from noise and applies the learned reverse step over many iterations. RePaint keeps this network as it is and changes only how each reverse step is assembled from two sources. The unknown pixels come from the DDPM's reverse step, while the known pixels come from the forward process applied to the ground truth image at the current time.
The forward process gives a closed form for the noisy version of the ground truth at any time step, which is what makes the known pixels available at every step of the reverse trajectory.
The text defines m⊙x as the unknown pixels and (1−m)⊙x as the known ones, but the combination equation multiplies the known-region sample by m. The two conventions for the mask therefore disagree in the paper, and the combination equation is the one used here as written. The known-region sample is built from the ground truth pixels, while the DDPM output fills the complementary part of the image.
Because the composition is done after every reverse step, the sampled known pixels always follow the schedule of the current time step.
Resampling to harmonize the fill
With one pass of the conditioning, the fill tends to match the texture of the neighbouring pixels while getting the content wrong. In one example, a masked region of a dog is filled with fur that matches the hair texture but is semantically incorrect.
The known-region sample is drawn without looking at what the DDPM has generated in the unknown part, so the two sources disagree at every step. The maximum change per reverse step also shrinks with the variance schedule, so a disagreement made early cannot easily be corrected later.
Resampling uses the DDPM's tendency to produce consistent structures. After a reverse step, the output is pushed back to a noisier state with the forward step \[ x_t \sim \mathcal{N}(\sqrt{1-\beta_t}\,x_{t-1},\ \beta_t I) \] and then denoised again, so the generated region can be re-harmonized with the known region. Repeating this forward and backward move only harmonizes over one step, so the jump length j generalizes it to a time horizon of j diffusion steps.
The procedure runs r resampling iterations per step, and in Algorithm 1 the forward move at each iteration uses β_{t-1}.
The final approach uses T = 250 timesteps, r = 10 resamplings and jump length j = 10. The ImageNet model is the provided guided diffusion model, and the CelebA-HQ model was trained for 250,000 iterations with the same hyper-parameters as for ImageNet. Resampling is a different use of extra computation from slowing down the diffusion, which reduces the added variance per step and uses more steps.
The authors argue that slowing down does not harmonize the image, which is why the comparison in the ablation is needed.
Comparison with state-of-the-art on standard and thin masks
The comparison uses 100 images of size 256 × 256 from the CelebA-HQ and ImageNet test sets. The baselines are the autoregressive DSI and ICT and the GAN-based DeepFillv2, AOT and LaMa, with publicly available pretrained models, except that LaMa was trained by the authors on ImageNet for 300,000 iterations with batch size five.
Quality is measured by LPIPS, where lower is better, and by a user study in which five humans answer each query and each comparison gathers 1000 votes. Each user had to be at least 75% self-consistent to have answers kept.
For Wide and Narrow masks the authors report that RePaint is preferred over every other method at a 95% significance margin on both datasets, although the Wide and Narrow LPIPS values alone do not show this. On CelebA-HQ with Wide masks, LaMa has LPIPS 0.045 against 0.059 for RePaint, and LaMa's vote share is 41.8 ± 3.1 percent in the same table.
On ImageNet, LaMa also has the lower Wide LPIPS, at 0.105 against 0.134.
For Super-Resolve 2× masks on CelebA-HQ, RePaint reaches LPIPS 0.029, compared with 0.128 for DSI and 0.177 for LaMa. The authors describe AOT as failing completely on these thin masks, while the other baselines produce blurry images or visible artifacts. In the user study the authors report that RePaint gets between 73.1% and 99.3% of the votes on the thin-structure masks.
For the thick masks, LaMa has lower LPIPS than RePaint on CelebA-HQ, at 0.138 against 0.165 for Half and 0.342 against 0.435 for Expand. The authors argue that RePaint is more flexible and produces semantically different fills from the ground truth, so LPIPS is unsuitable for this case. The ImageNet numbers show the same pattern, with LaMa at 0.254 against 0.304 for Half and 0.534 against 0.629 for Expand.
The authors note that RePaint is preferred with 95% confidence in the user study, except for the inconclusive comparison with ICT on Half masks.
On Places2 in the appendix, the comparison with LaMa on Wide masks is inconclusive, with users voting 52.4% for RePaint and a significance interval overlapping the 50% border.
Diversity of sampled completions
Each reverse step adds fresh Gaussian noise, so every run produces a different sample. Since no loss directly fixes the inpainted region, the model can fill it with any content that fits the training distribution.
The Diversity Score is used because it rewards diversity among plausible outputs and penalizes extreme predictions or failures, unlike a mean pairwise LPIPS. Higher values are better, and the authors report it alongside LPIPS on CelebA-HQ with 32 images per mask setting.
On Narrow masks RePaint has a Diversity Score of 23.79 with LPIPS 0.0337, compared with 18.74 and LPIPS 0.0454 for DSI and 18.65 with LPIPS 0.0402 for ICT. On Expand, ICT is ahead of RePaint on both measures, with LPIPS 0.4779 against 0.4832 and Diversity Score 17.25 against 17.11. The authors report that no single method has both the best LPIPS and the best Diversity Score on Wide and Half masks.
Resampling versus slowing down at equal budget
Slowing down the diffusion is the usual way to spend extra computation, so the comparison is made with a similar number of network evaluations. The experiment uses 32 ImageNet validation images with the LaMa Wide mask.
Slowing down with T = 250, 500, 750 and 1000 and r = 1 gives LPIPS 0.168, 0.167, 0.179 and 0.161, so more diffusion steps do not reliably improve the result. Resampling with T = 250 and r = 1, 2, 3 and 4 gives LPIPS 0.168, 0.148, 0.142 and 0.134.
The authors conclude that the resampling uses the extra budget to harmonize the image, while slowing down shows no visible gain. Only one scene and one mask were measured in this table, so the comparison supports this reading for that setting alone.
Jump length and number of resamplings
The ablation varies j over 1, 5 and 10 and r over 5, 10 and 15, using 32 images from the CelebA validation set with the LaMa Wide mask setting. Votes are measured against LaMa, and LPIPS is reported alongside them.
With j = 10, the vote shares are 53.12, 56.25 and 53.75 for r = 5, 10 and 15, and the corresponding LPIPS values are 0.073, 0.068 and 0.065. With j = 1 the vote shares are 42.50, 42.50 and 46.25, and the authors observe blurrier images for j = 1 across the numbers of resamplings.
The vote intervals are about ±7.8 points, so the gaps between j = 5 and j = 10, or between r = 5 and r = 10, fall within those intervals. The visual examples for the jump-length and resampling grid are in the appendix.
Comparison with the SDEdit resampling schedule
SDEdit starts reverse diffusion from a guiding image at an intermediate time, so it cannot start from only the non-masked pixels. For the comparison, the authors run reverse diffusion from T to T/2 and then repeat the reverse process from T/2 to 0.
On the super-resolution masks, SDEdit gives LPIPS 0.3902 on ImageNet, 0.2712 on Places2 and 0.1132 on CelebA-HQ, while RePaint gives 0.1831, 0.0991 and 0.0291. The authors report that RePaint reduces LPIPS by over 53% on all datasets for super-resolution masks.
The exception is the Expand mask on ImageNet, where SDEdit has LPIPS 0.6281 and RePaint 0.6292. The authors consider LPIPS above 0.6 outside a meaningful range for comparison.
Limitations
The 512 × 512 experiment is qualitative only, because the full analysis could not be run at that resolution. The model also tends to inpaint dogs more often than expected on ImageNet, which the authors attribute to dogs being over-represented in the training set.
Paper info
- Authors
- Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, Luc Van Gool
- Venue
- arXiv · Preprint
- First published
- 2022-1-24
- Added
- 2026-11-12
- Updated
- 2022-8-31
- Version
- v4
- arXiv
- 2201.09865
- Category
- cs.CV
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Andreas Lugmayr, Martin Danelljan, Andres Romero, Fisher Yu, Radu Timofte, Luc Van Gool (2022). RePaint: Inpainting using Denoising Diffusion Probabilistic Models. arXiv:2201.09865v4. https://arxiv.org/abs/2201.09865v4
BibTeX
@misc{lugmayr2022repaint,
title = {{RePaint: Inpainting using Denoising Diffusion Probabilistic Models}},
author = {Andreas Lugmayr and Martin Danelljan and Andres Romero and Fisher Yu and Radu Timofte and Luc Van Gool},
year = {2022},
eprint = {2201.09865},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/2201.09865v4}
}