BiRefNet_lite, converted for mask-foreground

BiRefNet_lite (Zheng, Gao, Fan, Liu, Laaksonen, Ouyang, Sebe: Bilateral Reference for High-Resolution Dichotomous Image Segmentation, CAAI AIR 2024), converted for the mask-foreground Rust crate: MLX (Apple silicon GPU) and ONNX Runtime (CPU, elsewhere). The network is unchanged; only its form is.

Source: ZhengPeng7/BiRefNet_lite at revision aa62cd87eafb9cc43056d08ef3615a14628b831d (model.safetensors), MIT, by the paper's authors. Code: ZhengPeng7/BiRefNet (MIT).

File Bytes SHA-256
birefnet-lite.mlx.safetensors 89226150 0f4582904365f02fe9d587ebb107c77954c42b82bed73ce36f08446e7a229bd4
birefnet-lite.onnx 182732446 6e954a77d90d257dca9a51eaef513fe2aa1af8216db849530763d6cafcbd2545

What the files are

Both take a 1024x1024 RGB image, normalised with ImageNet's mean and deviation ((x / 255 - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]), and give the foreground's logits at 1024x1024 (the original's last output, model(x)[-1]). Resizing the image (Pillow's bilinear), and the mask (sigmoid, x255, Pillow's bicubic back to the image's size) are left to the caller, as in BiRefNet's own extract_object.

  • birefnet-lite.mlx.safetensors: inference-ready weights in float16 (as BiRefNet's own GPU inference runs): batch norm folded into the convolutions, the training-only heads (multi-scale supervision, gradient predictions) dropped, each Swin block's relative position bias gathered into (heads, 49, 49), the last 1x1 convolution split around the last upsampling (it is linear, so this is exact), convolutions in MLX's (out, kh, kw, in) layout.
  • birefnet-lite.onnx: the same network in float32, opset 17, input image (1, 3, 1024, 1024), output logits (1, 1, 1024, 1024). The deformable convolutions are written as gathers and matrix products, so it needs no custom operator.

How they were checked

conversion/convert.py in the crate's repository made them: it restates the network from the converted weights alone (with its own deformable convolution, not torchvision's) and checks that against the authors' model on four test images: logits within 1e-3. ONNX Runtime's output is within 1.2e-3 of the original's. The MLX engine (float16, Apple M5 GPU) puts at most 22 of the 1,048,576 pixels on the other side of 0.5.

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 octamap/mask-foreground

Quantized
(43)
this model