Add foreground color estimation pass

This commit is contained in:
Codex
2026-06-30 16:25:56 +08:00
parent 1a670088c0
commit d6bb658244
9 changed files with 158 additions and 70 deletions
+5 -1
View File
@@ -8,6 +8,7 @@ from .settings import (
AlphaPostSettings,
ChromaSettings,
DespillSettings,
ForegroundSettings,
ModelSettings,
PipelineSettings,
TrimapSettings,
@@ -41,7 +42,7 @@ def _update_dataclass(instance: T, values: dict[str, Any] | None) -> T:
def settings_from_dict(data: dict[str, Any]) -> PipelineSettings:
allowed_sections = {"chroma", "trimap", "alpha_post", "despill", "model"}
allowed_sections = {"chroma", "trimap", "alpha_post", "foreground", "despill", "model"}
unknown_sections = sorted(set(data) - allowed_sections)
if unknown_sections:
raise ValueError(f"Unknown config section(s): {', '.join(unknown_sections)}")
@@ -50,6 +51,7 @@ def settings_from_dict(data: dict[str, Any]) -> PipelineSettings:
chroma=_update_dataclass(ChromaSettings(), data.get("chroma")),
trimap=_update_dataclass(TrimapSettings(), data.get("trimap")),
alpha_post=_update_dataclass(AlphaPostSettings(), data.get("alpha_post")),
foreground=_update_dataclass(ForegroundSettings(), data.get("foreground")),
despill=_update_dataclass(DespillSettings(), data.get("despill")),
model=_update_dataclass(ModelSettings(), data.get("model")),
)
@@ -65,6 +67,7 @@ def override_settings(settings: PipelineSettings, **overrides: Any) -> PipelineS
chroma = settings.chroma
trimap = settings.trimap
alpha_post = settings.alpha_post
foreground = settings.foreground
despill = settings.despill
model = settings.model
@@ -91,6 +94,7 @@ def override_settings(settings: PipelineSettings, **overrides: Any) -> PipelineS
chroma=chroma,
trimap=_update_dataclass(trimap, trimap_updates),
alpha_post=alpha_post,
foreground=foreground,
despill=_update_dataclass(despill, despill_updates),
model=_update_dataclass(model, model_updates),
)