feat(auto): adaptive detail-targeting polish + --adaptive-polish flag

The fixed mild auto polish (unsharp 0.5 / grain 2.0) under-corrected soft
photo/face output (gemini_3 stayed at lap-var 84 vs its 592 original) and its
grain speckled small text. Replace it with humanizer.adaptive_polish: target the
input's Laplacian variance with a capped unsharp scaled to the deficit + edge-
masked grain (smooth regions only), calibrated by a short sigma search. Self-
limiting on text/graphics -- already high-frequency, so almost no polish lands
and text edges are masked out. Validated on the spaces corpus (gemini_3 84 -> 334
end-to-end; openai_1 text near-untouched).

Interface: every --auto decision is now independently overridable -- add
--adaptive-polish/--no-adaptive-polish (matching --restore-faces; works without
--auto too) so the polish can be disabled or used manually. _apply_auto overrides
exactly the three content-adaptive modes (pipeline, restore-faces, adaptive-
polish); --unsharp/--humanize stay independent fixed filters.

cv2-only, no new deps. Threaded through invisible/all (not batch).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Victor Kuznetsov
2026-06-03 21:37:51 -07:00
parent 9bd2c17cc4
commit b686dbdd79
8 changed files with 223 additions and 44 deletions
+5 -3
View File
@@ -284,9 +284,11 @@ remove-ai-watermarks invisible image.png -o clean.png --humanize 4.0 --unsharp 0
# GPU/MPS, cap the long side: --max-resolution 2048
# Strength is vendor-adaptive by default (OpenAI 0.10 / Google 0.15); override
# with --strength. To preserve text/face structure, use --pipeline controlnet
# Or let it choose: --auto picks the pipeline, face restore, and polish from the
# image content (controlnet when there is text/structure, face restore when a face
# is present). Explicit flags override it. Experimental.
# Or let it choose: --auto picks the pipeline, face restore, and an adaptive polish
# from the image content (controlnet when there is text/structure, face restore when
# a face is present, polish that restores the input's detail level while sparing
# text). Every choice is overridable: --pipeline, --no-restore-faces,
# --no-adaptive-polish all win over the auto pick. Experimental.
# (SDXL + canny ControlNet); tune preservation with --controlnet-scale. Add
# Check / strip AI metadata (C2PA, EXIF, "Made with AI" labels)