fix(invisible): process at native resolution by default

The invisible pipeline force-downscaled inputs >1024px to 1024 before
diffusion, then upscaled the result back -- a lossy round-trip that was
the main cause of the quality loss reported in #10. The hosted raiw.cc
backend (fal fast-sdxl) does no pre-downscale, and at strength ~0.05
SDXL img2img doesn't need it.

Default is now native resolution (max_resolution=0). New --max-resolution
flag (invisible / all / batch) re-introduces an opt-in long-side cap only
to bound GPU/MPS memory on very large inputs.

Addresses #10. End-to-end quality/removal not re-verified locally (no GPU
here); matches raiw-app's proven production config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
test-user
2026-05-25 09:50:06 -07:00
parent 93c664f7fb
commit 18740969ae
3 changed files with 42 additions and 7 deletions
+26
View File
@@ -278,6 +278,12 @@ def cmd_visible(
@click.option(
"--humanize", type=float, default=0.0, help="Analog Humanizer film grain intensity (0 = off, typical: 2.0-6.0)."
)
@click.option(
"--max-resolution",
type=int,
default=0,
help="Cap long side (px) before diffusion; 0 = native (best quality, like raiw.cc). Raise only on GPU/MPS OOM.",
)
@click.pass_context
def cmd_invisible(
ctx: click.Context,
@@ -290,6 +296,7 @@ def cmd_invisible(
seed: int | None,
hf_token: str | None,
humanize: float,
max_resolution: int,
) -> None:
"""Remove invisible AI watermarks (SynthID, StableSignature, TreeRing).
@@ -336,6 +343,7 @@ def cmd_invisible(
guidance_scale=None,
seed=seed,
humanize=humanize,
max_resolution=max_resolution,
)
elapsed = time.monotonic() - t0
@@ -476,6 +484,12 @@ def cmd_identify(ctx: click.Context, source: Path, no_visible: bool, as_json: bo
@click.option(
"--humanize", type=float, default=0.0, help="Analog Humanizer film grain intensity (0 = off, typical: 2.0-6.0)."
)
@click.option(
"--max-resolution",
type=int,
default=0,
help="Cap long side (px) before diffusion; 0 = native (best quality, like raiw.cc). Raise only on GPU/MPS OOM.",
)
@click.pass_context
def cmd_all(
ctx: click.Context,
@@ -491,6 +505,7 @@ def cmd_all(
seed: int | None,
hf_token: str | None,
humanize: float,
max_resolution: int,
) -> None:
"""Remove ALL watermarks: visible + invisible + metadata.
@@ -582,6 +597,7 @@ def cmd_all(
num_inference_steps=steps,
seed=seed,
humanize=humanize,
max_resolution=max_resolution,
)
console.print(" [green]✓[/] Invisible watermark removed")
@@ -633,6 +649,7 @@ def _process_batch_image(
seed: int | None,
hf_token: str | None,
humanize: float,
max_resolution: int = 0,
) -> None:
"""Process a single image for batch mode.
@@ -695,6 +712,7 @@ def _process_batch_image(
num_inference_steps=steps,
seed=seed,
humanize=humanize,
max_resolution=max_resolution,
)
if mode in ("metadata", "all"):
@@ -737,6 +755,12 @@ def _process_batch_image(
@click.option("--device", type=click.Choice(["auto", "cpu", "mps", "cuda"]), default="auto", help="Inference device.")
@click.option("--seed", type=int, default=None, help="Random seed for reproducibility.")
@click.option("--hf-token", type=str, default=None, help="HuggingFace API token.")
@click.option(
"--max-resolution",
type=int,
default=0,
help="Cap long side (px) before diffusion; 0 = native (best quality, like raiw.cc). Raise only on GPU/MPS OOM.",
)
@click.pass_context
def cmd_batch(
ctx: click.Context,
@@ -751,6 +775,7 @@ def cmd_batch(
hf_token: str | None,
inpaint: bool,
humanize: float,
max_resolution: int,
) -> None:
"""Process all images in a directory."""
_banner()
@@ -800,6 +825,7 @@ def cmd_batch(
seed=seed,
hf_token=hf_token,
humanize=humanize,
max_resolution=max_resolution,
)
processed += 1