BiRefNet_lite 512×512, low-memory ONNX
studioludens/birefnet-lite-512 (an export of ZhengPeng7/BiRefNet_lite) with its 20 deformable convolutions rewritten to use far less memory. Same weights, same input/output, same masks.
What changed
The original export turns each deformable convolution into one big step that samples every kernel position at once. In the last decoder stage (7×7 kernel, 128×128) that creates about 20 tensors of 205 MB each. This version samples one kernel position at a time and adds it into the output right away.
Measured with ONNX Runtime 1.31 on CPU, one 512×512 image:
| Original | This repo | |
|---|---|---|
| Peak memory, fp32 | 3,336 MB | ~600–730 MB |
| Largest intermediate tensor | 205 MB | 126 MB |
| Mask difference vs original fp32 | n/a | max 1/255 |
| CPU time | 3.0 s | 3.0 s |
No int8 file: dynamic int8 quantization visibly drops parts of the subject on some photos (with the original export too), so only fp32 and fp16 are provided.
Files
| File | Precision | Size |
|---|---|---|
onnx/model.onnx |
fp32 | 184 MB |
onnx/model_fp16.onnx |
fp16 (float32 input/output) | 96 MB |
Input input_image [1, 3, 512, 512], ImageNet-normalized. Output: logits [1, 1, 512, 512]; apply sigmoid.
License
MIT, see LICENSE. Copyright (c) 2024 ZhengPeng, Copyright (c) 2026 Studio Ludens V.O.F.