mirror of
https://github.com/wiltodelta/remove-ai-watermarks.git
synced 2026-08-09 23:50:40 +02:00
qwen-zimage becomes the default and sdxl-zimage the only alternative. The
controlnet, sdxl, qwen and default profiles are gone, and with them the CPU and
MPS paths for invisible-watermark removal: neither matched the two-stage
recipe's face preservation, so keeping them advertised a quality this library no
longer delivers. Visible-mark removal and every identify command still run
anywhere.
Retired names are rejected rather than remapped. Silently routing --pipeline
sdxl onward would run an old script at a different strength, on a different
model, at a different quality, and report success.
CUDA is now checked when the remover is constructed instead of when the model
loads. Auto-detection cheerfully returned mps on a Mac, so the failure arrived
several layers down, after the dependency check and the pipeline import, in a
message naming whichever internal pipeline happened to raise. _DEVICES collapses
to {"cuda"} and the cpu/mps float32 branch goes with it.
resolve_strength stays total. It briefly returned None for qwen-zimage, meaning
"ask the resolution curve", which pushed a branch onto both callers and left one
of the two strength policies outside the strength module; the CLI copy had
already grown an `or 0.0` guarding a path its own comment called unreachable. It
now takes the image size and answers for both profiles, so the displayed value
cannot drift from the executed one.
Deletion fallout removed with it: img2img_runner and progress.py (the MPS
recovery path and its progress monitor had no callers left), viable_steps, the
fp16 degenerate-output retry, the fp16 VAE fix, and the Qwen img2img call
builders. try_empty_device_cache moved into watermark_remover rather than
leaving a module whose docstring outlived its code. _HAS_DIFFUSERS routes
through optional_deps.module_available, which is what the rest of the library
uses and what correctly rejects a pruned namespace remnant.
--steps, --guidance-scale and --model now have exactly one legal value each and
are still accepted at parse time, then rejected in remove(). Their help text
says so, but validating them beside the option would be better.
Not addressed, and worth its own decision: invisible_engine forces
min_resolution to 0 for both profiles, so the --min-resolution floor, --upscaler,
_esrgan_upscale, upscaler.py and the esrgan extra are all unreachable.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
83 lines
3.0 KiB
Python
83 lines
3.0 KiB
Python
"""Remove-AI-Watermarks: Unified tool for removing visible and invisible AI watermarks.
|
|
|
|
High-level API (lazy, so ``import remove_ai_watermarks`` stays cheap)::
|
|
|
|
import remove_ai_watermarks as raiw
|
|
raiw.remove_visible("in.png", "out.png") # clean a file (provenance auto)
|
|
result, removed = raiw.remove_visible(bgr_array) # array -> array
|
|
raiw.visible_provenance("in.png") # -> frozenset of confirmed vendors
|
|
raiw.identify_video("in.mp4") # -> VideoProvenanceReport
|
|
raiw.inspect_video_metadata("in.mp4") # -> VideoMetadataReport
|
|
raiw.remove_video_all("in.mp4", "out.mp4") # visible + verified metadata
|
|
raiw.remove_video_batch("videos", "videos_clean") # complete per-file results
|
|
raiw.remove_video_metadata("in.mp4", "out.mp4") # verified metadata strip
|
|
raiw.remove_video_invisible("in.mp4", "out.mp4") # oracle-certified SynthID removal
|
|
raiw.remove_video_visible("in.mp4", "out.mp4") # stable visible video-mark removal
|
|
|
|
For a provenance verdict use the ``identify`` submodule::
|
|
|
|
from remove_ai_watermarks.identify import identify
|
|
report = identify("in.png")
|
|
"""
|
|
|
|
import os as _os
|
|
import warnings as _warnings
|
|
from typing import TYPE_CHECKING
|
|
|
|
# transformers prints a noisy deprecation for the Siglip2ImageProcessorFast
|
|
# alias when it is imported (by the optional GPU/ML path). Silence it before
|
|
# any submodule pulls transformers in, so the CLI startup stays quiet. Uses
|
|
# setdefault so a user-set TRANSFORMERS_VERBOSITY still wins.
|
|
_os.environ.setdefault("TRANSFORMERS_VERBOSITY", "error")
|
|
_warnings.filterwarnings("ignore", message=r".*ImageProcessorFast.*")
|
|
|
|
|
|
__version__ = "0.24.0"
|
|
|
|
__all__ = [
|
|
"__version__",
|
|
"identify_video",
|
|
"inspect_video_metadata",
|
|
"remove_video_all",
|
|
"remove_video_batch",
|
|
"remove_video_invisible",
|
|
"remove_video_metadata",
|
|
"remove_video_visible",
|
|
"remove_visible",
|
|
"visible_provenance",
|
|
]
|
|
|
|
if TYPE_CHECKING:
|
|
from remove_ai_watermarks.api import remove_visible, visible_provenance
|
|
from remove_ai_watermarks.video import (
|
|
identify_video,
|
|
inspect_video_metadata,
|
|
remove_video_all,
|
|
remove_video_batch,
|
|
remove_video_invisible,
|
|
remove_video_metadata,
|
|
remove_video_visible,
|
|
)
|
|
|
|
|
|
def __getattr__(name: str) -> object:
|
|
"""Lazily resolve the high-level API (PEP 562), so the heavy imports (cv2, the
|
|
metadata/identify stack) load only when a caller actually reaches for them."""
|
|
if name in ("remove_visible", "visible_provenance"):
|
|
from remove_ai_watermarks import api
|
|
|
|
return getattr(api, name)
|
|
if name in (
|
|
"identify_video",
|
|
"inspect_video_metadata",
|
|
"remove_video_all",
|
|
"remove_video_batch",
|
|
"remove_video_invisible",
|
|
"remove_video_metadata",
|
|
"remove_video_visible",
|
|
):
|
|
from remove_ai_watermarks import video
|
|
|
|
return getattr(video, name)
|
|
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|