Merge master: matte-confidence gate + cross-model hair-gap veto
Brings in the two algorithm optimisations from master: - Gate chroma suppression by the matte's own confidence (639fdf0) - Add cross-model veto of hair-gap background residue (adbbb9d) Server-edition integration on top of the plain merge: - PipelineManager caches the cross-check model (BiRefNet_HR-matting) and injects it into MattingPipeline, so HTTP requests never reload it. - MattingResult carries cross_check_alpha; debug output matches master. - /healthz reports crossCheck; README lists models/BiRefNet_HR-matting in the local-weights bundle. Verified: CLI --no-cross-check baseline and full cross-check run both pass on samples/TestImage3.png; cross_check_alpha.png written to debug. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ RGB input
|
||||
-> chroma bg-confidence (keyed to the auto-detected or given colour)
|
||||
-> [optional] semantic segmentation mask
|
||||
-> trimap -> ViTMatte -> alpha cleanup
|
||||
-> cross-model veto (second matting opinion on bg-hued residue)
|
||||
-> pymatting foreground -> despill -> RGBA PNG -> QA previews
|
||||
```
|
||||
|
||||
@@ -28,6 +29,15 @@ Both share pymatting foreground estimation and a colour de-spill. There is **no*
|
||||
green-contamination rescue / recolour layer — with clean source images it is
|
||||
unnecessary, so it was removed.
|
||||
|
||||
Both also run a **cross-model veto** by default: a second, trimap-free matting
|
||||
model (`ZhengPeng7/BiRefNet_HR-matting`) may only *lower* alpha, only on
|
||||
background-hued bright pixels the primary result is confident about — this clears
|
||||
colour-drifted background residue trapped between hair strands that the chroma
|
||||
key, the segmenter and ViTMatte all read as foreground. Costs one extra model
|
||||
download (~0.9 GB) and one inference pass per image; disable with
|
||||
`--no-cross-check` (see the `cross_check` config section, and
|
||||
`docs/hair_gap_artifacts.md` for the analysis behind it).
|
||||
|
||||
The segmentation trimap defaults to `directional` mode (chroma + seg + a hue-direction
|
||||
split: it keeps a background-coloured garment such as a white shirt while dropping a
|
||||
background-hued residual such as blue trapped between hair strands). Switch with
|
||||
@@ -207,7 +217,8 @@ D:\MiniConda\envs\lightML\python.exe scripts\smoke_samples.py `
|
||||
(as the service does in production).
|
||||
- Bundling weights in the project — instead of the HF cache, drop each model into a
|
||||
plain folder named after the repo basename under `models/`:
|
||||
`models/vitmatte-base-composition-1k`, `models/BiRefNet`, `models/anime-seg`. The loader
|
||||
`models/vitmatte-base-composition-1k`, `models/BiRefNet`, `models/anime-seg`,
|
||||
`models/BiRefNet_HR-matting` (cross-check second opinion, default on). The loader
|
||||
prefers a matching local folder and falls back to the HF repo id / cache when absent, so
|
||||
it is opt-in. Populate them with e.g. `hf download ZhengPeng7/BiRefNet --local-dir
|
||||
models/BiRefNet`. Override the base directory with `BGFILTER_WEIGHTS_DIR`. `models/` is
|
||||
|
||||
Reference in New Issue
Block a user