Add BiRefNet semantic segmentation module
Adds bgfilter/segmentation.py: BiRefNetSegmenter produces a soft subject mask that defines topology -- it includes colour-contaminated foreground (green-tinted hair) and excludes see-through holes (finger gaps), the distinction chroma/colour cues cannot make. Validated on both samples: green hair -> foreground, finger gap -> background, both correct. Foundation of the semantic-guided redesign; the mask will drive trimap construction next, with ViTMatte still refining soft edges. - SegmentationSettings (ZhengPeng7/BiRefNet, 1024 input, fp32). - Deps: torchvision, timm, einops, kornia. Weights load from HuggingFace via trust_remote_code; behind a firewall set HF_ENDPOINT=https://hf-mirror.com and bypass the proxy. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -78,6 +78,14 @@ class ModelSettings:
|
||||
fallback_to_chroma_alpha: bool = False
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class SegmentationSettings:
|
||||
enabled: bool = True
|
||||
model_name: str = "ZhengPeng7/BiRefNet"
|
||||
device: str = "cuda"
|
||||
input_size: int = 1024
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
class PipelineSettings:
|
||||
chroma: ChromaSettings = ChromaSettings()
|
||||
|
||||
Reference in New Issue
Block a user