Add optional BiRefNet-gated intersection for the dropout-fill

Add seg_fill_intersect (default off) and seg_fill_gate_min to AlphaPostSettings, plus a gate_mask arg to fill_seg_dropouts. When enabled, the anime-seg dropout-fill is intersected with the reliable BiRefNet mask (>= gate_min): anime-seg proposes wisps at a low seg_fill_seg_min, but only rescues BiRefNet also endorses survive, trimming anime-seg's over-inclusive fringe while keeping its smooth value. Default off, so the shipped Option B (union) output is byte-identical.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 14:47:09 +08:00
parent 9805b51b99
commit 87359ca304
3 changed files with 25 additions and 2 deletions
+5 -1
View File
@@ -117,7 +117,11 @@ def _run_image(
alpha = clean_alpha(alpha, trimap, settings.alpha_post)
if seg_mask is not None:
fill_mask = pipeline._segment_fill(rgb, seg_mask)
alpha = fill_seg_dropouts(alpha, fill_mask, settings.alpha_post)
# seg_mask is the reliable trimap backend (BiRefNet); it gates the fill
# when seg_fill_intersect is on (fill_mask ∧ seg_mask).
alpha = fill_seg_dropouts(
alpha, fill_mask, settings.alpha_post, gate_mask=seg_mask
)
foreground = estimate_foreground_rgb(
rgb, alpha, bg_confidence, model, settings.foreground
)