remove-ai-watermarks 0.3.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. remove_ai_watermarks-0.3.3/.claude/settings.json +14 -0
  2. remove_ai_watermarks-0.3.3/.env.example +3 -0
  3. remove_ai_watermarks-0.3.3/.gitattributes +9 -0
  4. remove_ai_watermarks-0.3.3/.github/dependabot.yml +29 -0
  5. remove_ai_watermarks-0.3.3/.github/workflows/publish.yml +24 -0
  6. remove_ai_watermarks-0.3.3/.gitignore +32 -0
  7. remove_ai_watermarks-0.3.3/CLAUDE.md +12 -0
  8. remove_ai_watermarks-0.3.3/LICENSE +21 -0
  9. remove_ai_watermarks-0.3.3/PKG-INFO +309 -0
  10. remove_ai_watermarks-0.3.3/README.md +265 -0
  11. remove_ai_watermarks-0.3.3/data/samples/chatgpt-1.png +0 -0
  12. remove_ai_watermarks-0.3.3/data/samples/chatgpt-2.png +0 -0
  13. remove_ai_watermarks-0.3.3/data/samples/firefly-1.png +0 -0
  14. remove_ai_watermarks-0.3.3/data/samples/mj-1.png +0 -0
  15. remove_ai_watermarks-0.3.3/data/samples/mj-2.png +0 -0
  16. remove_ai_watermarks-0.3.3/data/samples/nano-banana-1.png +0 -0
  17. remove_ai_watermarks-0.3.3/data/samples/nano-banana-2.png +0 -0
  18. remove_ai_watermarks-0.3.3/data/samples/not-ai-1.jpeg +0 -0
  19. remove_ai_watermarks-0.3.3/data/samples/not-ai-2.jpeg +0 -0
  20. remove_ai_watermarks-0.3.3/data/samples/not-ai-3.webp +0 -0
  21. remove_ai_watermarks-0.3.3/demo_banana_after.png +0 -0
  22. remove_ai_watermarks-0.3.3/demo_banana_before.png +0 -0
  23. remove_ai_watermarks-0.3.3/maintain.sh +11 -0
  24. remove_ai_watermarks-0.3.3/pyproject.toml +92 -0
  25. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/__init__.py +3 -0
  26. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/assets/__init__.py +1 -0
  27. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/assets/gemini_bg_48.png +0 -0
  28. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/assets/gemini_bg_96.png +0 -0
  29. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/cli.py +684 -0
  30. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/face_protector.py +147 -0
  31. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/gemini_engine.py +548 -0
  32. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/humanizer.py +51 -0
  33. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/invisible_engine.py +257 -0
  34. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/metadata.py +215 -0
  35. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/__init__.py +9 -0
  36. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/c2pa.py +296 -0
  37. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/cleaner.py +178 -0
  38. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/constants.py +112 -0
  39. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/ctrlregen/__init__.py +18 -0
  40. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/ctrlregen/color.py +40 -0
  41. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/ctrlregen/engine.py +364 -0
  42. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/ctrlregen/ip_adapter.py +149 -0
  43. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/ctrlregen/pipeline.py +35 -0
  44. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/ctrlregen/tiling.py +177 -0
  45. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/extractor.py +151 -0
  46. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/img2img_runner.py +152 -0
  47. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/progress.py +332 -0
  48. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/utils.py +43 -0
  49. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/watermark_profiles.py +51 -0
  50. remove_ai_watermarks-0.3.3/src/remove_ai_watermarks/noai/watermark_remover.py +630 -0
  51. remove_ai_watermarks-0.3.3/tests/__init__.py +1 -0
  52. remove_ai_watermarks-0.3.3/tests/conftest.py +66 -0
  53. remove_ai_watermarks-0.3.3/tests/test_cli.py +330 -0
  54. remove_ai_watermarks-0.3.3/tests/test_face_protector.py +63 -0
  55. remove_ai_watermarks-0.3.3/tests/test_gemini_engine.py +216 -0
  56. remove_ai_watermarks-0.3.3/tests/test_humanizer.py +52 -0
  57. remove_ai_watermarks-0.3.3/tests/test_invisible_engine.py +27 -0
  58. remove_ai_watermarks-0.3.3/tests/test_metadata.py +150 -0
  59. remove_ai_watermarks-0.3.3/tests/test_noai.py +130 -0
  60. remove_ai_watermarks-0.3.3/tests/test_platform.py +165 -0
  61. remove_ai_watermarks-0.3.3/uv.lock +2812 -0
@@ -0,0 +1,14 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "WebSearch",
5
+ "WebFetch"
6
+ ]
7
+ },
8
+ "enabledPlugins": {
9
+ "pyright-lsp@claude-plugins-official": true,
10
+ "context7@claude-plugins-official": true,
11
+ "code-simplifier@claude-plugins-official": true,
12
+ "claude-md-management@claude-plugins-official": true
13
+ }
14
+ }
@@ -0,0 +1,3 @@
1
+ # HuggingFace token (required for invisible watermark removal)
2
+ # Get yours at: https://huggingface.co/settings/tokens
3
+ HF_TOKEN=
@@ -0,0 +1,9 @@
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+
4
+ # Binary files
5
+ *.png binary
6
+ *.jpg binary
7
+ *.jpeg binary
8
+ *.webp binary
9
+ *.pt binary
@@ -0,0 +1,29 @@
1
+ version: 2
2
+
3
+ updates:
4
+ - package-ecosystem: "uv"
5
+ directory: "/"
6
+ schedule:
7
+ interval: "weekly"
8
+ open-pull-requests-limit: 10
9
+ labels:
10
+ - "dependencies"
11
+ - "python"
12
+ groups:
13
+ minor-and-patch:
14
+ update-types:
15
+ - "minor"
16
+ - "patch"
17
+
18
+ - package-ecosystem: "github-actions"
19
+ directory: "/"
20
+ schedule:
21
+ interval: "weekly"
22
+ open-pull-requests-limit: 5
23
+ labels:
24
+ - "dependencies"
25
+ - "github-actions"
26
+ groups:
27
+ actions:
28
+ patterns:
29
+ - "*"
@@ -0,0 +1,24 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+
7
+ permissions:
8
+ id-token: write
9
+ contents: read
10
+
11
+ jobs:
12
+ publish:
13
+ runs-on: ubuntu-latest
14
+ environment: pypi
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+
18
+ - uses: astral-sh/setup-uv@v6
19
+
20
+ - name: Build package
21
+ run: uv build
22
+
23
+ - name: Publish to PyPI
24
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,32 @@
1
+ # Dependencies
2
+ .venv/
3
+ __pycache__/
4
+ *.egg-info/
5
+ dist/
6
+ build/
7
+
8
+ # Environment secrets
9
+ .env
10
+
11
+ # OS files
12
+ .DS_Store
13
+ Thumbs.db
14
+
15
+ # IDE
16
+ .idea/
17
+ .vscode/
18
+ *.swp
19
+ *.swo
20
+
21
+ # Test results
22
+ data/results/
23
+
24
+ # Reference materials
25
+ _refs/
26
+
27
+ # Downloaded model weights
28
+ yolov8n.pt
29
+ .coverage
30
+
31
+ # Claude Code local settings
32
+ .claude/settings.local.json
@@ -0,0 +1,12 @@
1
+ # Remove-AI-Watermarks
2
+
3
+ You are a **principal Python engineer** maintaining a CLI tool and library for removing visible and invisible AI watermarks from images.
4
+
5
+ ## How to run
6
+
7
+ - `uv run remove-ai-watermarks all <image.png> -o <output.png>`
8
+
9
+ ## Configuration
10
+
11
+ - GPU/ML modules (invisible_engine, ctrlregen, watermark_remover) are optional — guard imports with `is_available()` checks
12
+ - Tests for ML modules are limited to availability checks (require multi-GB downloads)
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 wiltodelta
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,309 @@
1
+ Metadata-Version: 2.4
2
+ Name: remove-ai-watermarks
3
+ Version: 0.3.3
4
+ Summary: Remove visible and invisible AI watermarks from images (Gemini / Nano Banana, ChatGPT, Stable Diffusion)
5
+ Project-URL: Repository, https://github.com/wiltodelta/remove-ai-watermarks
6
+ License: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.10
9
+ Requires-Dist: click>=8.0.0
10
+ Requires-Dist: numpy>=1.24.0
11
+ Requires-Dist: opencv-python-headless>=4.8.0
12
+ Requires-Dist: piexif>=1.1.3
13
+ Requires-Dist: pillow>=10.0.0
14
+ Requires-Dist: python-dotenv>=1.0.0
15
+ Requires-Dist: rich>=13.0.0
16
+ Provides-Extra: all
17
+ Requires-Dist: accelerate>=0.25.0; extra == 'all'
18
+ Requires-Dist: color-matcher>=0.5.0; extra == 'all'
19
+ Requires-Dist: controlnet-aux>=0.0.9; extra == 'all'
20
+ Requires-Dist: diffusers>=0.25.0; extra == 'all'
21
+ Requires-Dist: pyright>=1.1.0; extra == 'all'
22
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'all'
23
+ Requires-Dist: pytest>=8.0.0; extra == 'all'
24
+ Requires-Dist: ruff>=0.4.0; extra == 'all'
25
+ Requires-Dist: safetensors; extra == 'all'
26
+ Requires-Dist: torch>=2.0.0; extra == 'all'
27
+ Requires-Dist: transformers>=4.35.0; extra == 'all'
28
+ Requires-Dist: ultralytics>=8.0.0; extra == 'all'
29
+ Provides-Extra: dev
30
+ Requires-Dist: pyright>=1.1.0; extra == 'dev'
31
+ Requires-Dist: pytest-cov>=4.1.0; extra == 'dev'
32
+ Requires-Dist: pytest>=8.0.0; extra == 'dev'
33
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
34
+ Provides-Extra: gpu
35
+ Requires-Dist: accelerate>=0.25.0; extra == 'gpu'
36
+ Requires-Dist: color-matcher>=0.5.0; extra == 'gpu'
37
+ Requires-Dist: controlnet-aux>=0.0.9; extra == 'gpu'
38
+ Requires-Dist: diffusers>=0.25.0; extra == 'gpu'
39
+ Requires-Dist: safetensors; extra == 'gpu'
40
+ Requires-Dist: torch>=2.0.0; extra == 'gpu'
41
+ Requires-Dist: transformers>=4.35.0; extra == 'gpu'
42
+ Requires-Dist: ultralytics>=8.0.0; extra == 'gpu'
43
+ Description-Content-Type: text/markdown
44
+
45
+ # Remove-AI-Watermarks
46
+
47
+ Remove **visible** and **invisible** AI watermarks from images generated by Google Gemini (Nano Banana), ChatGPT / DALL-E, Stable Diffusion, Adobe Firefly, Midjourney, and other AI models.
48
+
49
+ Strips SynthID, C2PA Content Credentials, EXIF/XMP "Made with AI" labels, and visible sparkle overlays — all in one command.
50
+
51
+ ## Features
52
+
53
+ - **Visible watermark removal** — Gemini / Nano Banana sparkle logo via reverse alpha blending (fast, offline, deterministic)
54
+ - **Invisible watermark removal** — SynthID, StableSignature, TreeRing via diffusion-based regeneration
55
+ - **AI metadata stripping** — EXIF, PNG text chunks, C2PA provenance manifests, XMP DigitalSourceType
56
+ - **"Made with AI" label removal** — removes the metadata that triggers AI labels on Instagram, Facebook, X (Twitter)
57
+ - **Analog Humanizer** — film grain and chromatic aberration to bypass AI image classifiers
58
+ - **Smart Face Protection** — automatic extraction and blending of human faces to prevent AI distortion
59
+ - **Batch processing** — process entire directories
60
+ - **Detection** — three-stage NCC watermark detection with confidence scoring
61
+
62
+ > **Try it online** — don't want to install anything? Use [raiw.cc](https://raiw.cc), a free web service powered by this library.
63
+
64
+ ## Examples
65
+
66
+ | Before (Watermarked) | After (Cleaned) |
67
+ | --- | --- |
68
+ | ![Before](demo_banana_before.png) | ![After](demo_banana_after.png) |
69
+
70
+ ## Supported models
71
+
72
+ | AI model | Visible watermark | Invisible watermark | Metadata | Our approach |
73
+ | --- | --- | --- | --- | --- |
74
+ | **Google Gemini / Nano Banana** | ✅ Sparkle logo | ✅ SynthID | ✅ C2PA + EXIF | Alpha reversal + diffusion + metadata strip |
75
+ | **OpenAI DALL-E 3 / ChatGPT** | — | — | ✅ C2PA manifest | Metadata strip |
76
+ | **Stable Diffusion (AUTOMATIC1111, ComfyUI)** | — | ✅ DWT / steganographic | ✅ PNG text chunks | Diffusion regeneration + metadata strip |
77
+ | **Adobe Firefly** | — | — | ✅ Content Credentials (C2PA) | Metadata strip |
78
+ | **Midjourney** | — | — | ✅ EXIF + XMP (prompt, model, seed) | Metadata strip |
79
+ | **StableSignature** (Meta) | — | ✅ In-model watermark | — | Diffusion regeneration |
80
+ | **TreeRing** | — | ✅ Latent space watermark | — | Diffusion regeneration |
81
+
82
+ > Visible watermarks (logo overlays) are currently used only by Google Gemini / Nano Banana. Other services rely on invisible watermarks and/or metadata. Our diffusion-based regeneration works against any invisible watermark in pixel or frequency domain.
83
+
84
+ ## How it works
85
+
86
+ ### Removing the Gemini / Nano Banana sparkle watermark
87
+
88
+ Google Gemini (internally codenamed **Nano Banana**) adds a visible sparkle logo to generated images using alpha blending:
89
+
90
+ ```text
91
+ watermarked = α × logo + (1 − α) × original
92
+ ```
93
+
94
+ We reverse this with a known alpha map (extracted from Gemini / Nano Banana output on a pure-black background):
95
+
96
+ ```text
97
+ original = (watermarked − α × logo) / (1 − α)
98
+ ```
99
+
100
+ A three-stage NCC (Normalized Cross-Correlation) detector finds the watermark position and scale dynamically, so it works even if the image was resized or cropped. After removal, residual sparkle-edge artifacts are cleaned via gradient-masked inpainting.
101
+
102
+ **Speed**: ~0.05s per image. No GPU needed.
103
+
104
+ ### Removing SynthID and other invisible watermarks
105
+
106
+ Google embeds **SynthID** into every image generated by Gemini / Nano Banana. Other AI services use StableSignature, TreeRing, and similar schemes. These imperceptible frequency-domain patterns survive cropping, resizing, and JPEG compression.
107
+
108
+ The removal pipeline:
109
+
110
+ ```text
111
+ image → downscale to 768px → encode to latent space (VAE)
112
+ → add controlled noise (forward diffusion)
113
+ → denoise (reverse diffusion, ~2 steps at strength 0.02)
114
+ → decode back to pixels (VAE) → upscale to original resolution
115
+ ```
116
+
117
+ The key insight: even minimal noise injection (strength 0.02 = 2% perturbation) breaks the watermark signal while preserving visual quality. The diffusion model acts as a learned image prior — it reconstructs the image faithfully while destroying the watermark pattern.
118
+
119
+ **Face Protection**: before diffusion, YOLO detects people in the image and extracts them. After diffusion, the original faces are blended back with a soft elliptical mask to prevent AI distortion of facial features.
120
+
121
+ **Analog Humanizer**: optional film grain and chromatic aberration injection that makes the output indistinguishable from a photo of a screen, defeating AI-generated image classifiers.
122
+
123
+ ### Stripping C2PA, EXIF, and "Made with AI" metadata
124
+
125
+ AI tools embed generation metadata that social platforms use to show "Made with AI" labels:
126
+
127
+ - **EXIF tags** — prompt, seed, model hash, sampler settings (Stable Diffusion, Midjourney)
128
+ - **XMP DigitalSourceType** — `trainedAlgorithmicMedia` tag used by Instagram, Facebook, and X (Twitter) to show "Made with AI"
129
+ - **PNG text chunks** — ComfyUI workflows, AUTOMATIC1111 parameters
130
+ - **C2PA Content Credentials** — cryptographic provenance manifests from Google Imagen, OpenAI DALL-E, Adobe Firefly
131
+
132
+ The cleaner parses each layer, removes AI-related fields, and preserves standard metadata (Author, Copyright, Title).
133
+
134
+ ## Installation
135
+
136
+ ### Recommended
137
+
138
+ Install as an isolated CLI tool — no need to manage virtual environments:
139
+
140
+ ```bash
141
+ # Using pipx (https://pipx.pypa.io)
142
+ pipx install git+https://github.com/wiltodelta/remove-ai-watermarks.git
143
+
144
+ # Or using uv (https://docs.astral.sh/uv)
145
+ uv tool install git+https://github.com/wiltodelta/remove-ai-watermarks.git
146
+ ```
147
+
148
+ To update to the latest version:
149
+
150
+ ```bash
151
+ pipx upgrade remove-ai-watermarks
152
+
153
+ # or
154
+ uv tool upgrade remove-ai-watermarks
155
+ ```
156
+
157
+ ### Install from repository
158
+
159
+ **Prerequisites:** Python 3.10+ and `pip` (or [`uv`](https://docs.astral.sh/uv/)).
160
+
161
+ ```bash
162
+ # 1. Clone the repository
163
+ git clone https://github.com/wiltodelta/remove-ai-watermarks.git
164
+ cd remove-ai-watermarks
165
+
166
+ # 2. Install the package in editable mode
167
+ pip install -e .
168
+
169
+ # Or, if you use uv:
170
+ uv pip install -e .
171
+ ```
172
+
173
+ After installation the `remove-ai-watermarks` command is available system-wide.
174
+
175
+ > **Note**: The base install covers visible watermark removal and metadata stripping.
176
+ > For invisible watermark removal (SynthID etc.), install GPU dependencies:
177
+ >
178
+ > ```bash
179
+ > pip install -e ".[gpu]" # or: uv pip install -e ".[gpu]"
180
+ > ```
181
+
182
+ #### Invisible watermark removal
183
+
184
+ Invisible removal uses diffusion models and a GPU for reasonable speed.
185
+
186
+ ```bash
187
+ # On first run, the model (~2 GB) will be downloaded automatically.
188
+ # Device is auto-detected: CUDA (Linux/Windows) > MPS (macOS) > CPU.
189
+ # To force a device: --device cuda / --device mps / --device cpu
190
+
191
+ # Optional: set a HuggingFace token for gated/private models
192
+ cp .env.example .env
193
+ # Edit .env and set HF_TOKEN=hf_your_token_here
194
+ ```
195
+
196
+ #### Developer setup
197
+
198
+ ```bash
199
+ # Install with dev dependencies (pytest, ruff, pyright)
200
+ pip install -e ".[dev]"
201
+ # Or with uv:
202
+ uv pip install -e ".[dev]"
203
+
204
+ # Run tests
205
+ pytest
206
+
207
+ # Run linters
208
+ ./maintain.sh
209
+ ```
210
+
211
+ ## Usage
212
+
213
+ ### CLI
214
+
215
+ ```bash
216
+ # Remove all watermarks from a single image (visible + invisible + metadata)
217
+ remove-ai-watermarks all image.png -o clean.png
218
+
219
+ # Process an entire directory
220
+ remove-ai-watermarks batch ./images/ --mode all
221
+ ```
222
+
223
+ #### Individual commands
224
+
225
+ ```bash
226
+ # Visible watermark only (Gemini / Nano Banana sparkle) — fast, offline
227
+ remove-ai-watermarks visible image.png -o clean.png
228
+
229
+ # Invisible watermark only (SynthID etc.) — requires GPU
230
+ remove-ai-watermarks invisible image.png -o clean.png --humanize 4.0
231
+
232
+ # Check / strip AI metadata (C2PA, EXIF, "Made with AI" labels)
233
+ remove-ai-watermarks metadata image.png --check
234
+ remove-ai-watermarks metadata image.png --remove
235
+
236
+ # Batch with a specific mode
237
+ remove-ai-watermarks batch ./images/ --mode visible
238
+ ```
239
+
240
+ ### Python API
241
+
242
+ ```python
243
+ from remove_ai_watermarks.gemini_engine import GeminiEngine
244
+ import cv2
245
+
246
+ engine = GeminiEngine()
247
+ image = cv2.imread("watermarked.png")
248
+
249
+ # Detect
250
+ result = engine.detect_watermark(image)
251
+ print(f"Detected: {result.detected} (confidence: {result.confidence:.1%})")
252
+
253
+ # Remove
254
+ clean = engine.remove_watermark(image)
255
+ cv2.imwrite("clean.png", clean)
256
+ ```
257
+
258
+ ### Metadata stripping
259
+
260
+ ```python
261
+ from remove_ai_watermarks.metadata import has_ai_metadata, remove_ai_metadata
262
+ from pathlib import Path
263
+
264
+ if has_ai_metadata(Path("image.png")):
265
+ remove_ai_metadata(Path("image.png"), Path("clean.png"))
266
+ ```
267
+
268
+ ## Requirements
269
+
270
+ - Python ≥ 3.10
271
+ - **Visible removal / metadata**: CPU only, no GPU required
272
+ - **Invisible removal**: GPU recommended (CUDA or MPS), works on CPU (slow)
273
+
274
+ ## Troubleshooting
275
+
276
+ **SSL certificate error** (`CERTIFICATE_VERIFY_FAILED`):
277
+
278
+ ```bash
279
+ # Install certifi (the tool auto-detects it)
280
+ pip install certifi
281
+
282
+ # macOS only: run the Python certificate installer
283
+ /Applications/Python\ 3.*/Install\ Certificates.command
284
+ ```
285
+
286
+ **First run is slow** — this is expected. The tool downloads model weights (~2 GB) on first launch. Subsequent runs use cached models.
287
+
288
+ ## Credits
289
+
290
+ - [noai-watermark](https://github.com/mertizci/noai-watermark) by mertizci — invisible watermark removal engine
291
+ - [GeminiWatermarkTool](https://github.com/allenk/GeminiWatermarkTool) by Allen Kuo (MIT) — visible watermark removal algorithm
292
+ - [CtrlRegen](https://github.com/yepengliu/CtrlRegen) by Liu et al. (ICLR 2025) — controllable regeneration pipeline
293
+ - NeuralBleach (MIT) — analog humanizer technique
294
+
295
+ ## ⚠️ Disclaimer
296
+
297
+ This tool is provided for **educational and research purposes only**.
298
+
299
+ Removing AI watermarks to misrepresent AI-generated content as human-created
300
+ may violate applicable laws, including the U.S. Digital Millennium Copyright Act
301
+ (DMCA) and the COPIED Act. Users are solely responsible for ensuring their use
302
+ complies with all applicable laws and platform terms of service.
303
+
304
+ The authors do not condone the use of this tool for deception, fraud,
305
+ or any activity that violates applicable laws or regulations.
306
+
307
+ ## License
308
+
309
+ MIT