Repository navigation
BiRefNet Lite (FP16, 98 MB) in onnxruntime-web on a single WASM thread: streaming load, memory settings, low-RAM gating #33309
Mehmet (xenitV1)
started this conversation in
Show & Tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Sharing a small production use of onnxruntime-web in case the details help someone doing the same: a background remover that runs BiRefNet Lite entirely in the browser, on the plain WASM backend.
Live: https://sticraft.com/background-eraser (the "detailed cutout" button)
Setup
onnxruntime-web/wasmimport,executionProviders: ["wasm"],numThreads = 1. The site isn't cross-origin isolated, so WASM threads aren't available; one thread in a dedicated worker keeps the page responsive..mjs/.wasmfiles are served from the same origin, so a strict CSPconnect-src 'self'holds and no image or model request leaves the site. The build pins the model by SHA-256.Things that mattered for memory
Uint8Arrayof the exact size (which also gives an honest download progress bar), passed toInferenceSession.create, and the reference is dropped right after the session is created.enableCpuMemArena: falseandenableMemPattern: false: there is exactly one inference per session, so there is nothing for them to reuse.navigator.deviceMemory <= 4, or phone-sized touch viewports when that hint is missing, don't get the detailed option at all; they keep a small U²-Net (u2netp) first pass. Total first-use download for the detailed path is about 112 MB including the runtime, and the UI says so before starting.Open question for anyone who has tried it: has WebGPU with FP16 BiRefNet been stable for you on integrated GPUs? I stayed on WASM because I couldn't test enough hardware.
Disclosure: I'm the developer of the site, and this post was drafted with an AI assistant from my project notes and code.
All reactions