Views
No views yet
onnx-community/BiRefNet_lite-ONNX) fail there three ways
(see microsoft/onnxruntime#21968):Concat nodes with up to 1024 inputs and Split nodes with
32 outputs, exceeding WebGPU's storage-buffers-per-shader limit.Sum op has no WebGPU kernel; its CPU fallback sits exactly where the
unrolled deformable convolutions materialize ~784 MB tensors, which walks the 4 GB
wasm heap into std::bad_alloc.ConstantOfShape islands.Concat/Split fanouts rewritten into cascades capped at 6, so any shader needs
at most 7 storage buffers (safe even at the WebGPU minimum limit of 8);Sum rewritten into Add chains;keep_io_types — graph I/O stays float32, so you feed and
read plain Float32Arrays.ort.webgpu.min.mjs — use the JSEP build, not the
.bundle native-EP build).| name | shape | dtype | |
|---|---|---|---|
| input | input_image | [1, 3, 1024, 1024] | float32, RGB, ImageNet mean/std, squish-resized |
| output | output_image | [1, 1, 1024, 1024] | float32 logits — apply sigmoid |
1const ort = (await import('https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/ort.webgpu.min.mjs')).default;
2ort.env.wasm.wasmPaths = 'https://cdn.jsdelivr.net/npm/onnxruntime-web@1.27.0/dist/';
3const sess = await ort.InferenceSession.create(modelArrayBuffer, { executionProviders: ['webgpu'] });
4const out = await sess.run({ input_image: new ort.Tensor('float32', chw, [1, 3, 1024, 1024]) });
5// sigmoid(out.output_image.data[i]) = foreground alphastudio/tools/export-birefnet.py from the
Lowkey Studio project; the same script converts the other BiRefNet variants
(general / HR / matting / dynamic).