Background → zero.
BG0 is an open-source background remover that runs locally in the browser. It uses WebGPU when available, falls back to WebAssembly, and produces a transparent PNG without uploading the source image.
- Images and derived pixels stay in browser memory.
- There is no account, API key, server inference, billing, or usage limit.
- The browser downloads a pinned BiRefNet ONNX model selected for the available hardware and caches it locally.
@bg0/browsercan add the same private flow to another web application.
Install Bun 1.4, then:
bun install --frozen-lockfile
bun run devThe web app starts on port 3000 and the docs start on port 4321. During
development, the web app serves the docs at /docs.
bun run lint
bun run typecheck
bun run test
bun run buildWith the web app running locally, run:
bunx playwright install chromium
bun run --cwd apps/web test:layoutThis uses the licensed cat sample and real model inference, then checks export
controls at 11 viewport widths, transparent output, download, reset, and an
invalid upload. The first run needs network access for the model. Set
BG0_TEST_URL for a different local port, BG0_TEST_BROWSER to firefox or
webkit (install that Playwright engine first), and optionally
BG0_TEST_SCREENSHOTS to an output directory outside the repository.
import { removeBackground } from '@bg0/browser'
const result = await removeBackground(file, {
quality: 'quality',
onProgress: ({ progress, message }) => console.log(progress, message),
})
const url = URL.createObjectURL(result.blob)The package owns capability detection, model loading and caching, preprocessing, ONNX inference, mask postprocessing, alpha compositing, progress, cancellation, and useful errors. Application code does not depend on ONNX internals.
| Area | Responsibility |
|---|---|
apps/web |
TanStack Start site and anonymous local remover |
apps/docs |
Blume documentation served at bg0.dev/docs |
packages/browser |
Reusable WebGPU/WASM inference and PNG output |
ARCHITECTURE.md |
Runtime, privacy, and deployment boundaries |
No backend is needed for background removal. See
ARCHITECTURE.md for the complete data flow.
Read AGENTS.md before changing the application. Keep the product focused on
local background removal, never send image contents or metadata to analytics,
and run the root checks before opening a pull request.
BG0 source is licensed under Apache License 2.0. Model weights retain
the licenses listed in
THIRD_PARTY_NOTICES.md.