← all repositories
MathiasGruber/PConv-Keras

Teaching Keras to paint over your mistakes

A from-scratch Keras port of NVIDIA's partial-convolution inpainting, with notebooks that actually show you how the sausage gets made.

907 stars Jupyter Notebook Image · Video · Audio
PConv-Keras
Velocity · 7d
+0.3
★ / day
Trend
steady
star history

What it does

This repo implements NVIDIA’s 2018 paper on partial convolutions for image inpainting — the trick where a neural network fills in missing chunks of an image (think: removing photobombers, repairing tears) without smearing surrounding details. The author built a custom PConv2D Keras layer, wired it into a UNet, and trained it on ImageNet. There’s also a live demo at fixmyphoto.ai if you want to test-drive someone else’s GPU bill.

The interesting bit

The real value here isn’t the model weights — it’s the pedagogy. The author broke the implementation into five Jupyter notebooks that walk through mask generation, layer testing, architecture assembly, and training. If you’ve ever read a paper and wondered “but how do you actually code that mask update rule?”, this is your answer. The partial convolution itself is elegant: the layer tracks a binary mask alongside the image, updating it after each convolution so that “valid” pixels gradually reclaim territory from holes.

Key highlights

  • Custom PConv2D Keras layer with mask-propagation logic, built from the paper’s equations
  • UNet architecture with all standard convolutions swapped for partial convolutions
  • VGG16 weights ported from PyTorch to Keras for perceptual/style loss computation
  • Five step-by-step notebooks covering masks → layer → architecture → training → chunking for arbitrary sizes
  • CLI training script and pre-trained ImageNet weights available
  • Live serverless demo via AWS Lambda at fixmyphoto.ai

Caveats

  • Dependencies are pinned to older versions: Python 3.6, Keras 2.2.4, TensorFlow 1.12
  • Training is slow; the author notes ~10 days on a 1080Ti at batch size 4, matching the paper
  • Places2 and CelebaHQ weights are listed as “needs training” — only ImageNet weights are provided
  • Batch normalization requires a two-stage training workaround because mean/variance calculations get confused by hole pixels

Verdict

Worth your time if you’re implementing custom Keras layers or studying how computer vision papers translate to code. Skip it if you just need a production inpainting tool — this is a learning implementation, not a polished product.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.