BiRefNet_lite-2K β€” ONNX fp16 (dynamic input size, low-memory graph)

ONNX export of ZhengPeng7/BiRefNet_lite-2K (Swin-T backbone, 44M params, trained for 2560Γ—1440), made for in-browser inference with birefnet-webgpu.

file precision input output size
onnx/model_fp16.onnx fp16 weights, fp32 I/O input_image [1,3,H,W] (ImageNet-normalised RGB) output_image [1,1,H,W] logits (apply sigmoid) ~91 MB

H and W are dynamic but must both be multiples of 64 (Swin patch merging, including the half-resolution multi-scale path). Resize your image to such a size (the 2K model was trained at 2560Γ—1440; birefnet-webgpu buckets the long side to 512 / 1024 / 1536 / 2048 / 2560 and keeps the aspect ratio), run, then resize the mask back. Verified against PyTorch at 512Β², 640Γ—960, 1024Β², 1536Γ—1024 and 1472Γ—2560.

What is different from a plain torch.onnx.export

A naive export needs 11 GB of activations at 2560Γ—1440, which is impossible in a browser tab. This graph computes the same function with ~0.45 GB peak live activations at 2560Γ—1472 (1.1 GB allocated on GPU in the WebGPU engine; far less at smaller sizes):

  • Deformable convolutions use the standard ONNX DeformConv op (opset 19+) instead of an im2col gather chain.
  • The 5-branch ASPP concat (1280 ch) followed by a 1Γ—1 conv is rewritten as a sum of five 1Γ—1 convs.
  • The full-resolution decoder tail (bilinear upsample β†’ concat β†’ 1Γ—1 conv, and the ipt_blk1 branch) is algebraically collapsed into a 1Γ—1 conv at low resolution plus one 5Γ—5 conv on the input image, with the branch's bias response built exactly from a single-channel conv over a ones image. This is exact except for a ~1 px outer ring where zero-padding interacts with the folded convolutions (max logit difference β‰ˆ 0.64 there, ≀ 7e-3 anywhere else).
  • GELU is exported as the Gelu op (opset 20).

fp32 graph IoU vs the original PyTorch model: β‰₯ 0.999997 on the test sizes; fp16 graph IoU 0.9995 (2560Γ—1440, ORT CPU). Requires a runtime that implements DeformConv and Gelu (verified with onnxruntime on CPU; the birefnet-webgpu engine on WebGPU).

License / credits

Weights and architecture: Zheng Peng et al., BiRefNet (MIT). Please check the upstream card for the training-data (DIS5K) terms before commercial use.

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for anudit/BiRefNet_lite-2K-ONNX

Quantized
(1)
this model