Add non-flat background mode (--no-chroma / chroma.enabled: false)
No colour key at all: segmentation alone drives the trimap (mode forced to 'seg', whose chroma terms degrade to no-ops on a zero background- confidence map), ViTMatte still refines the unknown band at full resolution, and pymatting still estimates edge foreground colour. Every colour-keyed stage is bypassed: background auto-detect, the directional hue split, chroma alpha suppression, despill, the cross-check veto (its suspect zone is background-hued by definition; with reuse_as_seg the second opinion still serves as the segmenter), and the unmix fallback. Guards: requires segmentation.enabled and matting_method 'vitmatte' (clear errors otherwise); despill/foreground handle model=None. Validation: flat-background default path is bit-identical pre/post (alpha and RGB |D|max = 0 on TestImage3). On a known-alpha subject composited over a gradient+blotch background, recovered alpha scores MAE 0.0018 / IoU@0.5 0.993 (0.995 with --cross-check-as-seg); the same input correctly fails auto-detection in default mode. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ def main(
|
||||
device: str | None = typer.Option(None, "--device"),
|
||||
precision: str | None = typer.Option(None, "--precision", help="Compute precision for all models (ViTMatte cast + BiRefNet autocast): fp32 (default) | bf16 (faster + halves matting activation memory; needs bf16-capable hardware, else falls back to fp32)"),
|
||||
screen_color: str | None = typer.Option(None, "--screen-color", help="Background colour prior as #RRGGBB (default: auto-detect the flat background colour)"),
|
||||
chroma: bool | None = typer.Option(None, "--chroma/--no-chroma", help="Colour-key the flat background (default: on). --no-chroma = non-flat background mode: segmentation alone drives the trimap; auto-detect, hue split, chroma suppression, despill and the cross-check veto are bypassed"),
|
||||
matting_method: str | None = typer.Option(None, "--matting-method"),
|
||||
fallback_to_chroma_alpha: bool | None = typer.Option(None, "--fallback-to-chroma-alpha/--no-fallback-to-chroma-alpha"),
|
||||
sure_bg_threshold: float | None = typer.Option(None, "--sure-bg-threshold", min=0.0, max=1.0),
|
||||
@@ -42,6 +43,7 @@ def main(
|
||||
device=device,
|
||||
precision=precision,
|
||||
screen_color=screen_color,
|
||||
chroma=chroma,
|
||||
matting_method=matting_method,
|
||||
fallback_to_chroma_alpha=fallback_to_chroma_alpha,
|
||||
sure_bg_threshold=sure_bg_threshold,
|
||||
|
||||
Reference in New Issue
Block a user