Filling holes in photos by cheating at texture Sudoku
A 2017 CVPR paper's reference implementation that speeds up neural inpainting 6× by reusing nearest-patch indices across iterations.

What it does
Given a photo with a masked region, this Torch/Lua pipeline infers what should fill the gap. It runs a content network first, then a texture optimization network, and finally blends the results. The code ships with pre-trained models and a three-step demo.
The interesting bit
The speedup comes from a lazy evaluation trick: instead of recomputing nearest patches for all 100 iterations at each of three scales, it computes them once at the first iteration and reuses the indices. The authors admit this trades “very subtle inpainting quality” for a 6× speed boost (down to ~30 seconds per image on GPU).
Key highlights
- CVPR 2017 paper implementation; adapted from Context Encoders and CNNMRF
- Content + texture networks with joint optimization
- Pre-trained models available via Google Drive
- Batch normalization quirk: feeding 32 images at once reportedly works better than single images
- Research-only license; contact author for questions
Caveats
- Requires Torch, which is effectively a dead framework (last meaningful release ~2017)
- Pre-trained model download lives on Google Drive with a long opaque ID
- Single-image inference may underperform due to batch norm coefficient mismatch
Verdict
Worth a look if you’re studying the evolution of inpainting methods or need to reproduce this specific paper’s results. Skip it if you want something production-ready; modern diffusion-based inpainters have largely superseded this approach.