image-segmentation · BiRefNet_lite (Swin-Tiny 512×512) · CPU WASM fp16 (98.5 MB) · MIT

BiRefNet-lite 512 — High-Resolution Foreground Alpha Matting

A browser-runnable 512×512 ONNX re-export of ZhengPeng7/BiRefNet_lite (studioludens/birefnet-lite-512, 98.49 MB fp16, MIT) that unblocks BiRefNet inside the browser by shrinking decoder activations 4× compared to the 1024×1024 OOM variants. Every pass emits [1, 1, 512, 512] raw saliency logits (262,144 floats) for crisp spokes, fur, and translucent rims — 100% locally in a Web Worker.

At a glance

Verified model card and Hub metadata for studioludens/birefnet-lite-512
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

Sample: Bicycle Spokes (1600×1200) Loupe target (34%, 64%)

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.

Original 5×
Alpha Matte 5×
Cutout 5×

32-Bin Saliency Logit Distribution (Log Scale)

Threshold Sweep Curve (FG Area & Soft-Edge Band)

Backend–
Tensor Shape–
Infer Latency–
Logit Range–
Foreground Area–
Soft-Edge Band–
Loupe Logit / σ–
Tensor NaN Count–

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:

Use-case ladder

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

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).