$ show zuruoke/watermark-removal
This repository implements a deep learning image inpainting model for watermark removal, based on the Contextual Attention (CVPR 2018) and Gated Convolution (ICCV 2019) papers. It provides a CLI tool (main.py) that loads a pre-trained TensorFlow 1.x checkpoint, applies a user-supplied mask (defaulting to a specific watermark pattern like iStock), and outputs the inpainted image. The code includes the full model definition (inpaint_model.py), custom operations (inpaint_ops.py), preprocessing utilities, batch inference scripts, and a Dockerfile. The architecture is a two-stage generator with a spectral normalization discriminator, trained on datasets like CelebA-HQ and Places2. However, the repository is primarily designed for inference; training code is present but not the primary focus. The project is heavily dependent on TensorFlow 1.15, the neuralgym library, and deprecated tf.contrib APIs, making it incompatible with modern TensorFlow 2.x without significant refactoring. The codebase is well-structured academically but not production-ready, with no tests and minimal documentation beyond the README.
The LLM identified 2 files worth highlighting for reuse:
Implements the contextual attention layer from the 'Generative Image Inpainting with Contextual Attention' paper. This function is self-contained (except for a resize utility from neuralgym) and demonstrates non-trivial tensor manipulation for patch matching and reconstruction. It can be extracted and reused in other inpainting or image generation projects that require attention-based feature matching.
The brush_stroke_mask function generates random irregular masks simulating brush strokes. It uses PIL and numpy to create diverse mask shapes and is fully self-contained. This is a common data augmentation technique for inpainting tasks and can be easily extracted and reused in other projects to generate training masks.