At a glance
| Model repo | studioludens/birefnet-lite-512 (re-exported from ZhengPeng7/BiRefNet_lite, trained on DIS5K — Zheng et al., CAAI AIR 2024) |
|---|---|
| Download size |
onnx/model_fp16.onnx (98,484,532 B) + config.json
(81 B) + preprocessor_config.json (389 B) =
98,485,002 B / 98.49 MB (93.92 MiB; catalogue 98.5 MB)
|
| Task & architecture |
image-segmentation (dichotomous image segmentation / alpha matting) ·
BiRefNet_lite (model_type: "swin", Swin-Tiny encoder +
Bilateral Reference inward/outward decoder at 512×512)
|
| Preprocessing |
ViTFeatureExtractor: resize 512×512, rescale 1/255,
ImageNet normalize mean [0.485, 0.456, 0.406], std
[0.229, 0.224, 0.225]
|
| Tensor I/O shape |
Input input_image [1, 3, 512, 512] → Output
output_image [1, 1, 512, 512] raw saliency logits
(typical range [-26, +20]; sigmoid → continuous [0, 1] alpha matte)
|
| Runtime & backend |
Shared ../../lib/webai.js (@huggingface/transformers@3.7.5 ) ·
CPU WASM fp16 (logSeverityLevel: 3) off the main thread in
worker.js · License: MIT
|
1. Live 512×512 Saliency Matte & Logit Inspector
Pick a curated zero-person test image below, drop any PNG/JPEG/WebP here, or paste from
clipboard (Ctrl/⌘+V). Click or arrow-key the canvas to aim the 5× edge-detail loupe.
Initialise BiRefNet-lite 512 above to segment the 512×512 saliency matte locally on CPU WASM.
Interactive Matte Stage & Split Wipe
See Inside · 5× Edge-Detail Loupe & Logit Spectrum
Inspect zoomed sub-pixel alpha transitions alongside the raw output_image
logit distribution (262,144 values) and threshold sweep curve.
32-Bin Saliency Logit Distribution (Log Scale)
Threshold Sweep Curve (FG Area & Soft-Edge Band)
Why BiRefNet-lite 512 matters on the web
Full 1024×1024 BiRefNet ONNX exports allocate massive multi-scale decoder concatenations
that hit std::bad_alloc inside the browser's 2–4 GB WASM heap. Re-exporting
BiRefNet_lite at 512×512 cuts activation memory by 4× while
preserving its Bilateral Reference edge-refinement architecture under a permissive
MIT license:
- Zero-upload e-commerce cutouts: strip complex backgrounds from product catalogs locally inside the browser tab with no per-image API billing.
- Real continuous alpha mattes: inspect and bias raw saliency logits (
[-26, +20]) instead of hard jagged binary masks. - Composable optical pipelines: pair BiRefNet alpha mattes with on-device monocular depth (Depth Anything v2 Small) for studio bokeh and 3D pop-out effects.
Use-case ladder
Basics · Background & Feather Studio
Swap solid, gradient, or custom backdrops and dial threshold, choke, and separable alpha feathering live.
Practical · E-Commerce Batch Cutout Queue
Process multiple studio items with Pause, Resume, Cancel, marketplace backdrop presets, and PNG/CSV/JSON exports.
Wild · Edge Torture Stress-Test
Probe spokes, glass refraction, and backlit edges under noise, downsample blur, haze, and gamma perturbations.
Multi-Model · Depth-Layered Bokeh & 3D Pop
Chain BiRefNet-lite 512 (98.5 MB) with Depth Anything v2 Small (27.3 MB) for tap-to-focus depth bokeh.
How the API works
import { AutoModel, AutoProcessor, RawImage } from "@huggingface/transformers";
const model = await AutoModel.from_pretrained("studioludens/birefnet-lite-512", {
device: "wasm",
dtype: "fp16",
session_options: { logSeverityLevel: 3 },
});
const processor = await AutoProcessor.from_pretrained("studioludens/birefnet-lite-512");
const { pixel_values } = await processor(rawImage);
const { output_image } = await model({ input_image: pixel_values });
// output_image: Float32Array [1, 1, 512, 512] logits -> sigmoid(z) = [0, 1] alpha matte
Show the code — worker.js: segmentImage() (off-main-thread fp16 WASM forward pass + portrait letterbox)
Show the code — birefnet-core.mjs: analyzeLogits() (262,144-element NaN scan + 32-bin histogram)
References & media attribution
- Model card — studioludens/birefnet-lite-512 (MIT)
- Upstream checkpoint — ZhengPeng7/BiRefNet_lite
- Paper — Bilateral Reference for High-Resolution Dichotomous Image Segmentation (CAAI AIR 2024)
- Transformers.js documentation
Curated sample photography (reused from media/assets/, rights-cleared Wikimedia Commons):
Ingolfson (Public domain), steven powell (CC BY 2.0), Germán Gaviria Mesa (CC BY-SA 2.0), Smirkybec (CC BY-SA 4.0).