
mmagic_partial_conv
Diffusion and generative46 ops234.7K params
U-Net inpainter whose masked, renormalized convolutions ignore hole pixels and shrink the mask each layer.
Diffusion and generative · 46 operations Checked
Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.
The file opened in a new tab. Use your browser's Save command there to keep it.
The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.
How this diagram was made
menagerie.classics.partialconv_unet:build_partialconv_unet_places: build({}) This is the partial-convolution U-Net for image inpainting, trained on the Places2 scene dataset, which fills irregular holes in an image with plausible content and no post-processing. The problem it attacks is that ordinary convolutions over a corrupted image respond to the substitute values placed in the holes, typically the mean, which produces color discrepancy and blurriness.
A partial convolution masks the input window and renormalizes the result, so the output depends only on valid pixels, with a scaling factor sum(1)/sum(M) that corrects for how many valid inputs the window held. After each layer the mask is updated: any location where the convolution saw at least one valid input is marked valid, so the holes shrink layer by layer. With enough layers any mask becomes all ones, provided the input had some valid pixels.
The network is a UNet-like architecture with every convolution replaced by a partial convolution and nearest neighbor up-sampling in the decoder; skip links concatenate both feature maps and masks. The final layer also receives the original holed image and mask, so the model can simply copy non-hole pixels, and partial convolution with boundary masking replaces padding at the image border.
Training combines per-pixel losses on valid and hole regions with VGG-based perceptual and style losses and a total variation term, weighted as 1, 6, 0.05, 120 and 0.1. The authors found the style loss necessary to avoid checkerboard artifacts and the perceptual loss important against grid-shaped ones. Because holes corrupt batch statistics, training runs first with Batch Normalization on, then fine-tunes with the encoder's Batch Normalization parameters frozen while the decoder keeps it enabled. The ImageNet and Places2 models trained for 10 days on a single NVIDIA V100 GPU with a batch size of 6, and inference on a 512×512 image takes 0.029s regardless of hole size.
Key idea. A convolution that is masked and renormalized to depend only on valid pixels, paired with an automatic mask update each layer, so a U-Net can inpaint irregular holes without conditioning on hole values or post-processing.
AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.
@misc{liu2018imageinpaintingirregularholes,
title={Image Inpainting for Irregular Holes Using Partial Convolutions},
author={Guilin Liu and Fitsum A. Reda and Kevin J. Shih and Ting-Chun Wang and Andrew Tao and Bryan Catanzaro},
year={2018},
eprint={1804.07723},
archivePrefix={arXiv},
primaryClass={cs.CV},
url={https://arxiv.org/abs/1804.07723},
}