NOTICE — Background removal — BiRefNet_lite (ONNX: fp32 1024 px and 768 px for the CPU, fp16 1024 px for WebGPU) Model id: bg-remove-lite (v3) Redistributed by MokshX Pvt Ltd as a downloadable component of Moksh PDF Editor. Authors / copyright: Peng Zheng, Dehong Gao, Deng-Ping Fan, Li Liu, Jorma Laaksonen, Wanli Ouyang, Nicu Sebe (BiRefNet); ONNX exports by MokshX Pvt Ltd from the official weights Licence: MIT Licence text: https://raw.githubusercontent.com/ZhengPeng7/BiRefNet/main/LICENSE Upstream: https://huggingface.co/ZhengPeng7/BiRefNet_lite/tree/aa62cd87eafb9cc43056d08ef3615a14628b831d Source repository: https://github.com/ZhengPeng7/BiRefNet Licence evidence recorded at publish time: - Upstream LICENSE text: "MIT License" / "Copyright (c) 2024 ZhengPeng" (https://raw.githubusercontent.com/ZhengPeng7/BiRefNet/main/LICENSE, sha256 92a7089e0915fc32bc40067560b398f1e6a7a5958abd7d04eda393629a5acefb, fetched 2026-10-11) - HF model card tag: license:mit (ZhengPeng7/BiRefNet_lite@aa62cd87eafb9cc43056d08ef3615a14628b831d, the official weights: model.safetensors sha256 4417d89795250e698c3cb0ae8df15743810065f646f48a694fdfa7ca052d0815) - Swin Transformer backbone: MIT, Copyright (c) 2021 Microsoft (network structure re-implemented for the export; no Microsoft code is shipped) Modified by MokshX Pvt Ltd (the licence below applies to the modified files too): - All three files are exported by MokshX from the official MIT weights (ZhengPeng7/BiRefNet_lite@aa62cd87eafb9cc43056d08ef3615a14628b831d, model.safetensors) with a MokshX re-implementation of the inference graph (mokshx-models-staging/tools/birefnet/): weights unchanged; the deformable convolutions are computed per kernel row with Gathers (the same arithmetic as torchvision deform_conv2d, checked to 1e-14), the shifted-window attention masks are constants, the decoder's input patches use the channel order the weights were trained with (upstream get_patches_batch, see v3 in the notes), and no node has more than 8 inputs or outputs (onnxruntime-web's WebGPU limit is 16 storage buffers per shader). - model_fp16.onnx (fp16-webgpu-1024): fixed 1024x1024 input, half-precision weights and activations with float32 I/O; the sampling coordinates, bilinear weights and gather indices stay float32. Replaces the onnx-community fp16 export, which fails on WebGPU with "Too many storage buffers in shader. Current: 17, Max is 16" (a fan-out rewrite of that graph removes the error but its first run on the test GPU took longer than 25 minutes without finishing; the MokshX fp16 file's took 191-223 s). - model.onnx (fp32-wasm-768): fixed 768x768 input, float32, for the CPU (WASM) path: peaks at about 1.5 GB instead of exceeding the 4 GB wasm32 heap like the onnx-community 1024 px export (v1). - model_1024.onnx (fp32-wasm-1024): fixed 1024x1024 input, float32, the same MokshX graph as model.onnx (exported 2026-10-12, v3, with mokshx-models-staging/tools/birefnet/export_birefnet_lite.py): the full-detail CPU file for PCs with 8 GB of RAM or more (about 2.6 GB at peak in onnxruntime-web WASM). Files (SHA-256): 9789a8941412b61363a002850cead712cfba59ac23ee1427e3ab6ca228713a15 model.onnx (209546119 bytes) [fp32-wasm-768] from https://huggingface.co/ZhengPeng7/BiRefNet_lite/resolve/aa62cd87eafb9cc43056d08ef3615a14628b831d/model.safetensors 427198a17dcaee11d84216bba21d7b65ae22641f56cd82b80e5d8854550136f7 model_fp16.onnx (130219877 bytes) [fp16-webgpu-1024] from https://huggingface.co/ZhengPeng7/BiRefNet_lite/resolve/aa62cd87eafb9cc43056d08ef3615a14628b831d/model.safetensors 051b25d3115d21d8551c62c68952f7d1d3d3c4df894da30707001b54dcf9736a model_1024.onnx (231783708 bytes) [fp32-wasm-1024] from https://huggingface.co/ZhengPeng7/BiRefNet_lite/resolve/aa62cd87eafb9cc43056d08ef3615a14628b831d/model.safetensors MIT License Copyright (c) 2024 ZhengPeng Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Notes: v3 (2026-10-12): all three files re-exported because the v2 graph fed the decoder's input patches to the ipt_blk convolutions in the WRONG channel order: v2 followed the current upstream birefnet.py, whose einops image2patches order (c hg wg) arrived on GitHub on 2024-11-05 (commit 5198d3f) and on the HF repo on 2025-02-02, while the BiRefNet_lite weights (uploaded 2024-08-02, never changed) were trained with get_patches_batch (wg hg c). v2 vs the onnx-community export: mean |logit| error 0.28, max 1.5 on the demo photo, thresholded IoU down to 0.76-0.88 on stock wallpapers; v3 matches that export to 1.1e-4 (IoU 1.0 on all 28 wallpapers for the 1024 px file). The graphs differ from v2 only in five Transpose permutations (same weights, same node count). The v2 files stay on R2 for app builds that point at them. v2 (2026-10-11). The v1 files (unmodified onnx-community exports, 1024 px) stay on R2 for older app builds: v1 fp16 fails on WebGPU adapters limited to 16 storage buffers per shader (Intel Arc xe-lpg), v1 fp32 exceeds the 4 GB wasm32 heap. Measured for v2: model.onnx in onnxruntime-web 1.30 WASM (Node, 1 thread) peak RSS 1.52 GB, 16.5 s per photo; on WebGPU (Intel Arc) 8.0 s after a 181 s first run. Thresholded-matte IoU vs the 1024 px fp32 reference on 6 test photos: model.onnx >= 0.995, model_fp16.onnx >= 0.999. Added 2026-10-12: model_1024.onnx (fp32, 1024 px, CPU), the default HD file on PCs with 8 GB of RAM or more: the 768 px file is poor on real photos (thresholded IoU vs 1024 px on 28 stock wallpapers: median 0.866, min 0.0), and the WebGPU file compiles shaders for 191-285 s on the first run of every app session, so the graphics card is used only when the user opts in (config.webgpuOptIn). model_1024.onnx in onnxruntime-web 1.30 WASM (Node): 7.4 s with 8 threads, 28.2 s with 1, peak RSS 2.58 GB. Generated 2026-10-12 by scripts/publish-models.mjs