Default to BiRefNet + CPU; add --seg-backend to pick the segmenter

- Segmentation backend now defaults to birefnet (ZhengPeng7/BiRefNet); anime-seg is
  selected at runtime with --seg-backend anime-seg, which also swaps in the matching
  weights (unknown backends raise). Config files stay for detailed tuning, not
  backend selection.
- Default device is now cpu everywhere (dataclass defaults, default.yaml,
  birefnet.yaml); pass --device cuda for GPU. Avoids a hard CUDA-required failure on
  machines without a CUDA-enabled PyTorch build.
- Docs: README + workflow status note updated (backend via --seg-backend, CPU
  default, examples no longer force --device cuda).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-02 16:32:13 +08:00
parent 62f175948e
commit a6d84845c6
7 changed files with 32 additions and 20 deletions
+4 -4
View File
@@ -93,7 +93,7 @@ class DespillSettings:
@dataclass(frozen=True)
class ModelSettings:
model_name: str = "hustvl/vitmatte-small-composition-1k"
device: str = "cuda"
device: str = "cpu"
matting_method: str = "vitmatte"
fallback_to_chroma_alpha: bool = False
@@ -101,9 +101,9 @@ class ModelSettings:
@dataclass(frozen=True)
class SegmentationSettings:
enabled: bool = True # False = chroma-only pipeline (no seg model)
backend: str = "anime-seg" # "anime-seg" or "birefnet"
model_name: str = "skytnt/anime-seg"
device: str = "cuda"
backend: str = "birefnet" # "birefnet" (general) or "anime-seg" (anime characters)
model_name: str = "ZhengPeng7/BiRefNet"
device: str = "cpu"
input_size: int = 1024