Skip to content

[#84] Detail-loss recovery (P2 detector) — R&D record, DO NOT MERGE#85

Draft
realproject7 wants to merge 1 commit into
mainfrom
task/84-p2-detail-loss-detector
Draft

[#84] Detail-loss recovery (P2 detector) — R&D record, DO NOT MERGE#85
realproject7 wants to merge 1 commit into
mainfrom
task/84-p2-detail-loss-detector

Conversation

@realproject7

Copy link
Copy Markdown
Owner

Draft / record only — not for merge. Refs #84 (intentionally no Fixes, so nothing auto-closes).

Preserves the P2 detail-loss recovery work so it is not lost. Live/PyPI stays v0.8.0; this is not in any release.

Change (2 files, +98)

  • pipeline.py: _fine_mark_density() detector + constants; ConvertOptions.retrace_time_budget_s; coverage-branch wiring (time the default trace → DROP = fmd(orig) − fmd(default_render) → if > 0.7 retrace with pre-trace flatten OFF + fine region merge → skip when the default trace already exceeded the budget). Emits a report note on apply/skip.
  • cli.py: --retrace-time-budget-s SECONDS.

Validation

  • Detector routing reproduces the anchored set (all flagged detail-loss → recovery; all clean-flats → default).
  • In-engine on the canonical corpus: flagged fire, clean-flats add zero paths; full pytest passes; ruff clean; retrace_time_budget_s=0 correctly skips recovery.

Why not shipping

Operator eye-gate: on the flat/solid-art target class the recovery output reads busier / net-negative vs the clean, economical default — the shipped v0.8.0 output is at-or-better than the reference vectorizer by eye. The detector also over-fires on a borderline speckle clean-flat under a different input encoding. Shelved; reopen if a non-regressing recovery mechanism is found (esp. the harder translucency/glass case, tracked separately).

🤖 Generated with Claude Code

…, not shipping)

Coverage-path detector routing detail-rich inputs to a recovery retrace (pre-trace
flatten OFF + fine region merge) that traces back fine interior marks the default
flattens (stipple/hatch/thin lines), while clean-flat art keeps the economical
default. Signal = fine-mark density of original minus that of the default render.
Adds opt-in ConvertOptions.retrace_time_budget_s (+ --retrace-time-budget-s) to skip
the recovery retrace when the default trace already exceeded the budget.

Validated (routing reproduces the anchored set; in-engine flagged fire / clean-flats
add zero paths; full test suite passes; ruff clean). NOT shipping: operator eye-gate
found the recovery output busier / net-negative vs the clean economical default on the
flat/solid-art target class. Preserved for the record per #84.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
realproject7 added a commit that referenced this pull request Jul 8, 2026
…puts (#89)

The long-edge cap (#82, default 1280) is the primary detail-killer for
high-res detail-rich art: a 1648x2944 illustration is LANCZOS-downscaled to
717x1280 before tracing, shredding face features nothing downstream can
recover. Make the cap detail-aware.

- Port _fine_mark_density (+ constants) from the shelved P2 detector (#84/#85).
- In convert()'s downscale block: at the DEFAULT cap only, measure the
  original's fine-mark density; if >= 8.0, relax the effective cap to
  _DETAIL_CAP_EDGE_PX (2048, == _TRACE_RESOLUTION). Any explicit
  --max-input-edge-px (incl. 0) bypasses the heuristic verbatim.
- Report note records the relax (fmd + 1280->2048).

Structurally non-regressing: inputs <= 1280 never enter the branch
(byte-identical; golden corpus green), low-density inputs keep 1280.
Calibrated on the pv-corpus + new-test sweep; relaxing the few dense "flat"
cartoons that cross the floor is visually harmless (verified montage).

Verified: popgirl 1648x2944 -> relax 2048 (fmd 10.4, 1668 paths); 03-flatcartoon
(fmd 6.93) stays 1280. Tests: detector separation, flat-stays + explicit
override, dense-relaxes. ruff + full suite green.

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant