BiRefNet ONNX files for onnxruntime-web (WebGPU)

fp16 ONNX conversions of three BiRefNet checkpoints, changed so that they run in a browser with onnxruntime-web on WebGPU. They are used by Glinfs, a browser-only screen-capture-to-GIF tool. The weights are the upstream authors' work; this repository only converts them.

File Bytes SHA-256 Converted from
birefnet-general-fp16.onnx 519,348,204 809c204052cb841141fb261e4beefd313dd8035587246940bd73aa3c6d20207e ZhengPeng7/BiRefNet @ e2bf8e4460fc8fa32bba5ea4d94b3233d367b0e4, model.safetensors
birefnet-lite-fp16.onnx 122,466,609 dd67588b7b3fe3d4b311a5f30d4298f3a3b5e2bd513c0c72c0e41c29fcb8e05e ZhengPeng7/BiRefNet_lite @ aa62cd87eafb9cc43056d08ef3615a14628b831d, model.safetensors
birefnet-toonout-fp16.onnx 519,348,204 dd9c9fbc1a831b34aa8e2b7f9e28d42d44ac2debc37eedea85df33d1abbf038e joelseytre/toonout @ cbf720eca394edcde66b861a8a8c20fbabe9c748, birefnet_finetuned_toonout.pth

What was changed

The published ONNX exports of these networks fail or return empty masks on WebGPU. These files:

  • split every Split with more than 7 outputs and every Concat with more than 7 inputs (WebGPU allows a limited number of storage buffers per shader);
  • replace Sum with a chain of Add;
  • keep the deformable-convolution index arithmetic in float32;
  • keep GlobalAveragePool / ReduceMean in float32 (in fp16 the pooling overflows on WebGPU and the mask becomes NaN);
  • are otherwise fp16, with a float32 input and output.

The conversion is reproducible byte for byte with scripts/export-birefnet-onnx.py in the Glinfs repository.

Use

  • Input: float32 [1, 3, 1024, 1024], RGB, scaled to 0..1 and normalised with the ImageNet mean [0.485, 0.456, 0.406] and std [0.229, 0.224, 0.225].
  • Output: float32 [1, 1, 1024, 1024]. See the Glinfs model registry (model-registry.js) for the exact input / output names and whether the output needs a sigmoid.
  • Measured with Chrome 157 and onnxruntime-web 1.30.0 on an RTX 3080 Ti: about 485 ms per frame and 7.7 GB of GPU memory for general and ToonOut, about 260 ms and 5.8 GB for lite. Not tested on GPUs with 8 GB or less.

Licence and credit

MIT, as upstream.

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