← All projects

SAM Foreground API

Stable service · 2025–2026

Production image-segmentation service — SAM 2.1 + depth-aware candidate ranking, benchmarked to 0.995 mIoU on a human-evaluated suite.

0.9954 mean IoU6-method ensemble60+ tunable parametersVRAM-bounded ≤ 5.1 GB pipeline

A self-hosted segmentation service that turns photos into clean RGBA cutouts. Prompted segmentation, automatic mask generation, and a hybrid fallback chain feed a six-method candidate ensemble; DepthAnything-v2 scores candidates by nearness as a non-invasive ranking signal — depth never forces the mask shape, only orders the options.

The engineering depth is in the tuning surface: sixty-plus parameters covering prompt thresholds, morphological cleanup, edge refinement, and anti-erosion guards, each independently sweepable through a dedicated endpoint that emits parameter-perturbation archives for visual comparison. A 21-image human-evaluated benchmark holds the line at 0.9954 mean IoU across methods.

The production variant runs a two-model cooperative pipeline (BiRefNet on a YOLO crop, then a high-resolution pass) deliberately serialized to keep peak VRAM at 5.1 GB on the shared GPU — a design constraint enforced by the GPU timeshare scheduler it runs under.

Status & limits — stable and consumed by other services on the platform; test coverage is smoke-level, with quality regression handled by the visual benchmark rather than unit tests.

Stack

PythonFastAPISAM 2.1 Hiera-LBiRefNetDepthAnything-v2YOLOAVIF/WebP encoders

← All projects