DeMark
Automatic image watermark detection and removal toolkit. Multiple methods from classic CV to deep learning, pick what fits your watermark type.
What it does
Detects watermark regions in images and removes them while preserving underlying content. Ten methods are implemented:
| Method | Type | Best for | Lossless? |
|---|---|---|---|
auto |
— | Auto-selects best method | — |
cv_telea |
CV inpaint [6] | Small/thin watermarks | No |
cv_ns |
CV inpaint [7] | Smooth gradients around watermark | No |
fft_notch |
Frequency | Repeating/tiled periodic watermarks | Partial |
color_mask |
CV segmentation | Solid-color text (white on photo) | No |
edge_inpaint |
Edge + inpaint [5] | Text/logos with sharp edges | No |
template |
Template match | Known watermark logo | No |
alpha_invert |
Alpha matting [8] | Known watermark + transparency | Yes |
lama |
Deep learning [1] | Large masked regions | No |
sd_inpaint |
Diffusion [2] | Generative content fill | No |
precise |
Alpha inversion + line protection | Semi-transparent text on line art | Partial |
harmonic |
Multi-scale + auto-optimisation | Any scale, self-tuning | Partial |
What it does NOT do
- No batch GUI — CLI and Python API only. For a GUI, use IOPaint (23k stars) which wraps LaMa.
- No video watermark removal — for video use ProPainter (sczhou/ProPainter).
- No invisible/digital watermark removal — those require diffusion-based attacks (see [10]).
alpha_invertis the only truly lossless method, and it requires the watermark pattern and alpha to be known.
Requirements
- Python 3.9+
- OpenCV, NumPy, SciPy, scikit-image, Pillow
- For deep learning methods:
pip install demark[deep](LaMa) orpip install demark[sd](Stable Diffusion)
Installation
# From PyPI
pip install demark
# Optional deep learning extras (LaMa / Stable Diffusion)
pip install "demark[deep]" # LaMa inpainting
pip install "demark[sd]" # Stable Diffusion inpainting
# From source
git clone https://github.com/cycleuser/demark.git
cd demark
pip install -e .
Quick Start
# Auto-detect and remove
demark remove watermarked.jpg clean.jpg
# Use specific method
demark remove watermarked.jpg clean.jpg --method fft_notch
# Known watermark logo — template matching
demark remove watermarked.jpg clean.jpg --method template --template logo.png
# Known watermark overlay + alpha — lossless removal
demark remove watermarked.jpg clean.jpg --method alpha_invert --watermark wm_overlay.png --alpha 0.4
# Scale-adaptive multi-scale + auto-optimisation (works at any scale)
demark remove watermarked.jpg clean.jpg --method harmonic --bbox 1056 1249 1304 1305
# Just detect the mask
demark detect watermarked.jpg mask.png
# JSON output
demark --json remove watermarked.jpg clean.jpg
Usage
CLI
demark [-V] [-v] [-o OUTPUT] [--json] [-q] <command> ...
Commands:
remove <input> <output> [--method M] [--mask M.png] [--template T.png]
[--watermark W.png] [--alpha 0.4] [--radius 5]
detect <input> <output> [--method auto|edge|color|otsu]
list-methods
Python API
from demark import remove_watermark, detect_watermark
# Auto remove
r = remove_watermark(input_path="wm.jpg", output_path="clean.jpg")
print(r.success) # True
print(r.data["method"]) # "edge_inpaint"
print(r.data["elapsed"])# 0.123
# Specific method
r = remove_watermark(
input_path="wm.jpg",
output_path="clean.jpg",
method="fft_notch"
)
# Detect only
r = detect_watermark(input_path="wm.jpg", output_path="mask.png")
print(r.data["coverage"]) # 0.0523
Agent Integration (OpenAI Function Calling)
from demark.tools import TOOLS, dispatch
# Pass TOOLS to your LLM's function-calling API
result = dispatch("demark_remove_watermark", {
"input_path": "/data/wm.jpg",
"output_path": "/data/clean.jpg",
"method": "auto"
})
print(result["success"]) # True
References
| # | Paper | Year | Venue |
|---|---|---|---|
| [1] | Suvorov et al., "Resolution-robust Large Mask Inpainting with Fourier Convolutions" | 2021 | WACV 2022 |
| [2] | Rombach et al., "High-Resolution Image Synthesis with Latent Diffusion Models" | 2022 | CVPR |
| [3] | Liu et al., "WDNet: Watermark-Decomposition Network for Visible Watermark Removal" | 2020 | WACV 2021 |
| [4] | Cun & Pun, "Split then Refine: Stacked Attention-guided ResUNets for Blind Watermark Removal" | 2020 | AAAI 2021 |
| [5] | Robinette & Johnson, "Blind Visible Watermark Removal with Morphological Dilation" | 2025 | arXiv:2502.02676 |
| [6] | Telea, "An Image Inpainting Technique Based on the Fast Marching Method" | 2004 | J. Graphics Tools |
| [7] | Bertalmio et al., "Navier-Stokes, Fluid Dynamics, and Image and Video Inpainting" | 2001 | CVPR |
| [8] | Levin et al., "A Closed-Form Solution to Natural Image Matting" | 2006 | IEEE TPAMI |
| [9] | Huo et al., "WMFormer++: Nested Transformer for Visible Watermark Removal" | 2023 | arXiv:2308.10195 |
| [10] | "Vanishing Watermarks: Diffusion-Based Image Editing Undermines Robust Invisible Watermarking" | 2026 | arXiv:2602.20680 |
Development
pip install -e ".[dev]"
pytest tests/test_unified_api.py -v
ruff check demark/
License
GPL-3.0
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
demark-0.0.1.tar.gz
(39.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
demark-0.0.1-py3-none-any.whl
(37.2 kB
view details)
File details
Details for the file demark-0.0.1.tar.gz.
File metadata
- Download URL: demark-0.0.1.tar.gz
- Upload date:
- Size: 39.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43cbe852fc0c9695af53e1ee259ee4504bb4cecf68a11d79451f15df915e8b64
|
|
| MD5 |
3d90d8098ef720edec1811d5aa6fae5c
|
|
| BLAKE2b-256 |
f922fa1cf7d16cf1c9f7082fa6b7189bcd1303a6c70461ba73a87bc061fbe1e4
|
File details
Details for the file demark-0.0.1-py3-none-any.whl.
File metadata
- Download URL: demark-0.0.1-py3-none-any.whl
- Upload date:
- Size: 37.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
324ba6999eec9ff954e82546b15e6d1cd67b9ab777d91b7440814690fbd4a9f8
|
|
| MD5 |
463b381c4292c7a96eaf53deece1c9da
|
|
| BLAKE2b-256 |
b02e47efe1b136b14e407c0f47bb8f9c5946d74bbba0dabb72decd92df3c6fdd
|