Gate seg-reuse to the birefnet backend

reuse_as_seg swaps one BiRefNet-family model for another (the validated
equivalence); it must not silently override an explicitly chosen anime-seg
backend. With --seg-backend anime-seg the segmenter now keeps its own
forward and the cross-check veto runs independently on top -- both
combinable, no flag juggling. Default birefnet path is untouched
(verified byte-identical); anime-seg + cross-check verified to run both
models.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-06 15:52:21 +08:00
parent 10134ad492
commit 72655dea91
4 changed files with 19 additions and 3 deletions
+10 -1
View File
@@ -111,7 +111,16 @@ def _run_image(
)
second_alpha = None
if settings.segmentation.enabled:
if settings.cross_check.enabled and settings.cross_check.reuse_as_seg:
reuse = (
settings.cross_check.enabled
and settings.cross_check.reuse_as_seg
# Reuse swaps one BiRefNet-family model for another (validated
# equivalent topology). A different backend chosen explicitly
# (anime-seg) keeps its own forward; cross-check still runs
# independently on top of it.
and settings.segmentation.backend == "birefnet"
)
if reuse:
# One HR-matting forward serves both the trimap topology and the
# cross-check second opinion; the primary seg model is never loaded.
second_alpha = pipeline._second_opinion(rgb)