- Blog
- Batch Watermark Removal at Scale: Open-Source Python Script Using YOLOv11 + LaMA, 1000+ Images/Min
Batch Watermark Removal at Scale: Open-Source Python Script Using YOLOv11 + LaMA, 1000+ Images/Min
Batch Watermark Removal at Scale: Open-Source Python Script Using YOLOv11 + LaMA, 1000+ Images/Min
Background
When working with large-scale image datasets, watermarks are a persistent headache. Training diffusion models on watermarked images causes artifacts to appear in generated outputs — the watermark pattern shows up in the corners. But manually removing watermarks from tens of thousands of images is simply not feasible.
A Reddit developer, jferments, faced exactly this problem: a dataset of 3.6 million images, over 500GB, spread across 180,000 subdirectories. Existing watermark removal tools work fine for single images or small batches, but none were designed for this scale.
His solution is an open-source Python script: watermark_remover. It combines a fine-tuned YOLOv11 model for watermark detection with LaMA for inpainting, and supports multi-GPU parallel processing. On a dual RTX 4090 machine, it achieves 1000+ images per minute.
Core Workflow
The script follows a simple pipeline:
- Recursively scan the input directory, preserving directory structure
- Use YOLOv11 (fine-tuned for watermark detection) to locate watermarks in each image
- Generate a watermark mask with optional dilation to cover edge artifacts
- Apply LaMA (Simple-LaMa) inpainting to reconstruct masked areas
- Output to the target directory, preserving the original folder structure
The entire process supports pause and resume — pressing Ctrl+C triggers a graceful shutdown that saves progress to .processing_log.txt. Re-running the same command automatically skips already-processed images.
Installation
git clone https://github.com/jferments/watermark_remover.git
cd watermark_remover
pip install -r requirements.txt
Download the watermark detection model weights:
wget https://huggingface.co/spaces/fancyfeast/joycaption-watermark-detection/resolve/main/yolo11x-train28-best.pt
Usage
# Basic: process a single directory
python3 watermark_remover.py -i /path/to/inputs -o /path/to/outputs
# Recursive: scan all subdirectories
python3 watermark_remover.py -i /path/to/inputs -o /path/to/outputs -R
Command-Line Options
| Option | Description | Default |
|---|---|---|
-i, --input | Input folder path (required) | — |
-o, --output | Output folder path (required), preserves directory structure | — |
-w, --weights | YOLOv11 model weights path | yolo11x-train28-best.pt |
--conf | Detection confidence threshold (0.0-1.0); lower = more detections | 0.1 |
--dilate | Mask dilation in pixels; covers edge glow/aliasing; set 0 to disable | 15 |
-R, --recursive | Recursively scan all subdirectories | Off |
--cpu-workers | CPU processes for writing output | All CPU cores |
--debug | Save intermediate debug images (_mask_raw, _mask_preview) | Off |
Technical Details
YOLOv11 Watermark Detection
The detection model comes from the fancyfeast/joycaption-watermark-detection project on HuggingFace, fine-tuned from YOLOv11x on a large corpus of watermarked images. YOLO is known for real-time object detection, and the v11x variant is the largest in the family, offering the highest detection accuracy.
The confidence threshold is set to 0.1, meaning the model flags potential watermarks even with only 10% confidence — better to over-detect than miss. Combined with LaMA's inpainting, false positives are naturally reconstructed without visible artifacts.
Mask Dilation
Watermark edges often have a semi-transparent transition zone or glow. Detecting and removing only the core area can leave a visible "border line." The --dilate 15 setting expands the mask by 15 pixels to cover this transition zone. For most cases the default is sufficient, but you can increase it for watermarks with pronounced glow effects.
Multi-GPU Architecture
The script leverages PyTorch's multi-GPU support, distributing detection and inpainting tasks across available GPUs. CPU handles I/O (reading/writing images) while GPUs handle inference — pipeline parallelism that maximizes throughput.
Use Cases
- Training data cleaning: Remove watermarks from large image datasets to prevent watermark artifacts in trained models
- E-commerce image processing: Batch-remove platform watermarks or logos from product images
- Archive cleanup: Clean copyright marks from legacy image archives
- Academic research: Prepare clean images as training or testing data
- Enterprise pipelines: Integrate into automated image processing workflows
Performance
| Hardware | Processing Speed | Best For |
|---|---|---|
| Dual RTX 4090 | 1000+ images/min | Million-scale datasets |
| Single RTX 4090 | 400-600 images/min | Hundred-thousand scale |
| RTX 3060/4060 | 100-200 images/min | Ten-thousand scale |
| CPU only | 5-20 images/min | Small batches |
Pause and Resume
Processing large datasets is rarely interruption-free. The script handles this gracefully:
- Maintains a
.processing_log.txtfile in the output directory tracking processed files - Re-running the same command reads the log and skips already-processed files
- Newly added images are handled correctly — same filename ≠ same image
This makes the script safe for long-running tasks, even across server reboots.
Comparison with Other Batch Solutions
| Solution | Scale | GPU Required | Automation |
|---|---|---|---|
| watermark_remover script | Million-scale | ✅ Required | Fully automatic, resume support |
| ComfyUI workflows | Thousand-scale | ✅ Required | Semi-automatic |
| Online batch tools | Hundred-scale | ❌ Not needed | Automatic, quantity limits |
| Manual editing | Tens-scale | ❌ Not needed | Manual |
Important Note
The script includes a clear disclaimer: it is provided for educational and technical demonstration purposes only. Removing watermarks may violate copyright or intellectual property rights. Users are solely responsible for legal compliance. For images you own or have explicit permission to modify, this tool is appropriate.
Summary
watermark_remover solves a very specific but painful problem: batch watermark removal from large datasets. It doesn't aim for a fancy UI or feature bloat — it focuses on one thing: fast, reliable processing of images at scale. YOLOv11's precise detection, LaMA's natural inpainting, multi-GPU parallelism, and checkpoint-based resume make it a pragmatic solution that engineers and researchers will appreciate.
Project page: https://github.com/jferments/watermark_remover
