Background Remover Block
- from @localmode
- by LocalMode
Remove an image's background entirely on-device: SegFormer (Xenova/segformer-b0-finetuned-ade-512-512, ~15MB) segments the subject, the highest-scoring mask is composited as an alpha channel (promoted applyMaskToImage) to a transparent-background PNG shown on a checkerboard Original/Result comparison, with a processing overlay + cancel, best-mask confidence, Download PNG (promoted downloadDataUrl), clear/reset, and dismissible errors with a retry path. The model loads lazily on the first dropped image; nothing downloads on page load. Split out of the tabbed image-studio Remove BG tool (split-image-privacy).
Install
New to shadcn? Set up your project
If your project already has a shadcn components.json, skip initialization. Otherwise, run this once from your project root.
pnpm dlx shadcn@latest initpnpm dlx shadcn@latest add @localmode/ui/blocks/image-studio/background-removerRegistry dependencies6
- @localmode/ui/lib/utils
- @localmode/ui/lib/browser-utils
- @localmode/ui/media-vision/media-dropzone
- @localmode/ui/media-vision/before-after-image-viewer
- @localmode/ui/media-vision/image-processing-overlay
- @localmode/ui/results/confidence-score-badge
