Fuse semantic segmentation mask into the trimap
Wire BiRefNet into the pipeline (lazy-loaded) and build the trimap from the semantic subject mask refined by the green key, used when segmentation is enabled. generate_trimap (chroma-only) stays as the no-segmentation fallback. Authority split: the mask decides subject topology (keeps green-tinted hair as foreground, drops see-through holes), the bright-green key sharpens the screen boundary, ViTMatte refines a small protective band. Background follows the mask directly so interior holes survive; the band is small so it does not swallow finger gaps. End-to-end on the samples: green hair preserved, finger-gap green 99% transparent (BiRefNet marks it background; was 100% foreground before), leg edges smooth -- topology/colour/edge problems local cues could not solve, with no hard alpha surgery. - SegmentationSettings wired into PipelineSettings/config; --device propagates. - TrimapSettings: seg_core_threshold, seg_loose_threshold. - New debug output seg_mask.png. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -25,6 +25,9 @@ class TrimapSettings:
|
||||
fg_safe_radius_ratio: float = 0.006
|
||||
min_unknown_radius: int = 4
|
||||
min_fg_safe_radius: int = 2
|
||||
# Semantic fusion thresholds (used by fuse_trimap when segmentation is on).
|
||||
seg_core_threshold: float = 0.60
|
||||
seg_loose_threshold: float = 0.15
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -94,3 +97,4 @@ class PipelineSettings:
|
||||
foreground: ForegroundSettings = ForegroundSettings()
|
||||
despill: DespillSettings = DespillSettings()
|
||||
model: ModelSettings = ModelSettings()
|
||||
segmentation: SegmentationSettings = SegmentationSettings()
|
||||
|
||||
Reference in New Issue
Block a user