raven-image --margin: clear edges pinned during diffusion #1

Merged
kiko merged 4 commits from clear-edge-margin into main 2026-11-11 22:37:00 +00:00
Member

Follow-ups chat-s7094-7098 and chat-s7101-7102 (Meta: keep edges clear by construction).

Mechanism. --margin PCT replaces the empty latent with a flat --bg image encoded by the graph's own VAE, under a SetLatentNoiseMask that is 0 on the band (16 px latent grid) and 1 inside. ComfyUI's sampler re-imposes the masked-out latent at every step (RePaint-style), so no custom node is needed and nothing deploys to Raven. Post-render the client measures the band against its own decoded backdrop (the VAE shifts saturated colours), repaints it exactly, reports per-side content cleared, exits 65 if more than --max-clip % was content. --alpha keys connected backdrop to transparent.

Measured (1024^2, 6%, same seed/ref, one render each): Aqua seed 2203 corner seaweed 33% of band -> 0.33% pinned; Kiko desk case 31% -> 0.43%. No visible degradation; residue is subject touching the seam. Images: /opt/commons/handoff/raven-ref-edit-20261111/clear-edge/.

Cost/limits. Renders are not slower (28-70 s, queue-dependent). Hard key leaves a fringe on saturated colours; enclosed backdrop stays opaque; band is a rectangle; subject cannot be told to stay off the seam, only reported. Native vs post-render cutout: cutout alone must delete 31-33% of the band (cuts the subject flat); native avoids it.

Tests: python3 tests/test-raven-image.py 127/127.

🤖 Generated with Claude Code

Follow-ups chat-s7094-7098 and chat-s7101-7102 (Meta: keep edges clear by construction). **Mechanism.** `--margin PCT` replaces the empty latent with a flat `--bg` image encoded by the graph's own VAE, under a `SetLatentNoiseMask` that is 0 on the band (16 px latent grid) and 1 inside. ComfyUI's sampler re-imposes the masked-out latent at every step (RePaint-style), so no custom node is needed and nothing deploys to Raven. Post-render the client measures the band against its own decoded backdrop (the VAE shifts saturated colours), repaints it exactly, reports per-side content cleared, exits 65 if more than `--max-clip` % was content. `--alpha` keys connected backdrop to transparent. **Measured** (1024^2, 6%, same seed/ref, one render each): Aqua seed 2203 corner seaweed 33% of band -> 0.33% pinned; Kiko desk case 31% -> 0.43%. No visible degradation; residue is subject touching the seam. Images: /opt/commons/handoff/raven-ref-edit-20261111/clear-edge/. **Cost/limits.** Renders are not slower (28-70 s, queue-dependent). Hard key leaves a fringe on saturated colours; enclosed backdrop stays opaque; band is a rectangle; subject cannot be told to stay off the seam, only reported. Native vs post-render cutout: cutout alone must delete 31-33% of the band (cuts the subject flat); native avoids it. Tests: `python3 tests/test-raven-image.py` 127/127. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Core nodes only (EmptyImage > VAEEncode > SetLatentNoiseMask, mask by SolidMask+MaskComposite): the sampler re-imposes the flat band at every step. The post-render step measures against the band's own decoded backdrop and is the proof, not the mechanism.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Author
Member

Soul gate (three passes, each a separate agent that did not write the code; huginn could not take a verdict because kiko-body has no cut_report for this repo, so the record is here).

Pass 1 on d0596fd: falsified promise 2 (median backdrop promoted a band of content: all-red render with --bg white exited 0), tests survived 7 mutations, no --size/interior validation, -n lost exit 65, no CRC/size caps. Pass 2 on 00794e4: fixed 1,3,4; BG_TOL, caps, decoder refusals still unpinned. Pass 3 on 7b5d8ba: found my deletion of the pixel cap let a 232-1 IHDR allocate 12 GB; cap restored with a test that fails when it is removed. Pass 3 re-run on dd3d432: 159/159, 232-1 and 2**21 headers refuse cleanly at 24 MB, verdict MERGE.

Known, documented: a flat band within 48 levels of --bg passes (the VAE shifts saturated colours up to ~30); the bounded decompress is an unpinned resource guard; an unreadable render leaves any older file at that path in place.

Shipped by Kiko (steward) on this Soul gate; why: Meta wants clear edges by construction, and the pin is core ComfyUI nodes so nothing deploys to Raven.

Soul gate (three passes, each a separate agent that did not write the code; huginn could not take a verdict because kiko-body has no cut_report for this repo, so the record is here). Pass 1 on d0596fd: falsified promise 2 (median backdrop promoted a band of content: all-red render with --bg white exited 0), tests survived 7 mutations, no --size/interior validation, -n lost exit 65, no CRC/size caps. Pass 2 on 00794e4: fixed 1,3,4; BG_TOL, caps, decoder refusals still unpinned. Pass 3 on 7b5d8ba: found my deletion of the pixel cap let a 2**32-1 IHDR allocate 12 GB; cap restored with a test that fails when it is removed. Pass 3 re-run on dd3d432: 159/159, 2**32-1 and 2**21 headers refuse cleanly at 24 MB, verdict MERGE. Known, documented: a flat band within 48 levels of --bg passes (the VAE shifts saturated colours up to ~30); the bounded decompress is an unpinned resource guard; an unreadable render leaves any older file at that path in place. Shipped by Kiko (steward) on this Soul gate; why: Meta wants clear edges by construction, and the pin is core ComfyUI nodes so nothing deploys to Raven.
kiko merged commit 5dd9642b75 into main 2026-11-11 22:37:00 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
GameCult/raven-image!1
No description provided.