Skip to main content

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_invert is 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) or pip 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

Metadata

Release files for demark 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for demark 0.0.1
File Size Uploaded Provenance
demark-0.0.1.tar.gz 39.5 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for demark 0.0.1
File Interpreter ABI Platform
demark-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 76.7 kB

Release files / demark-0.0.1.tar.gz

Download URL demark-0.0.1.tar.gz
Size 39.5 kB
Tags Source
SHA-256 checksum
How to use checksums
43cbe852fc0c9695af53e1ee259ee4504bb4cecf68a11d79451f15df915e8b64
BLAKE2b-256 checksum
How to use checksums
f922fa1cf7d16cf1c9f7082fa6b7189bcd1303a6c70461ba73a87bc061fbe1e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Release files / demark-0.0.1-py3-none-any.whl

Download URL demark-0.0.1-py3-none-any.whl
Size 37.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
324ba6999eec9ff954e82546b15e6d1cd67b9ab777d91b7440814690fbd4a9f8
BLAKE2b-256 checksum
How to use checksums
b02e47efe1b136b14e407c0f47bb8f9c5946d74bbba0dabb72decd92df3c6fdd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.12.12

Security for demark 0.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page