Run this model with HF Jobs
Run anudit/BiRefNet_lite-2K-ONNX on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/anudit/BiRefNet_lite-2K-ONNX. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/anudit/BiRefNet_lite-2K-ONNX on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use anudit/BiRefNet_lite-2K-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- BiRefNet
How to use anudit/BiRefNet_lite-2K-ONNX with BiRefNet:
# Option 1: use with transformers from transformers import AutoModelForImageSegmentation birefnet = AutoModelForImageSegmentation.from_pretrained("anudit/BiRefNet_lite-2K-ONNX", trust_remote_code=True)# Option 2: use with BiRefNet # Install from https://github.com/ZhengPeng7/BiRefNet from models.birefnet import BiRefNet model = BiRefNet.from_pretrained("anudit/BiRefNet_lite-2K-ONNX") - Notebooks
- Google Colab
- Kaggle
Dynamic H×W export (multiples of 64); remove 1024 variant
Browse filesFiles changed (3)
- README.md+16-15
- onnx/model_fp16.onnx+2-2
- onnx/model_fp16_1024.onnxDeleted-3
10 unmodified lines111213141516171 unmodified line19202122232425262728293031323334353637383940414243444546474810 unmodified lines- birefnet---# BiRefNet_lite-2K — ONNX fp16 (static 2560×1440, low-memory graph)ONNX export of [ZhengPeng7/BiRefNet_lite-2K](https://huggingface.co/ZhengPeng7/BiRefNet_lite-2K)(Swin-T backbone, 44M params, trained for 2560×1440), made for in-browser inference with1 unmodified line| file | precision | input | output | size ||---|---|---|---|---|| `onnx/model_fp16.onnx` | fp16 weights, fp32 I/O | `input_image` `[1,3,1440,2560]` (ImageNet-normalised RGB) | `output_image` `[1,1,1440,2560]` logits (apply sigmoid) | ~99 MB |`onnx/model_fp16_1024.onnx` is the same weights exported at a fixed `[1,3,1024,1024]` input (~93 MB, ~4× faster, ~¼ the memory);`birefnet-webgpu` uses it automatically for small source images.The input size is **fixed**: resize (stretch, no aspect preservation — this matches training) your imageto 2560×1440, run, then resize the mask back.## What is different from a plain `torch.onnx.export`A naive export needs ~11 GB of activations at this resolution, which is impossible in a browser tab.This graph computes the same function with ~0.45 GB peak live activations (~1.1 GB allocated on GPU inthe WebGPU engine):* 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) isalgebraically collapsed into a 1×1 conv at low resolution plus one 5×5 conv on the input image.This is exact except for a ~1 px outer ring where zero-padding interacts with the folded convolutions(≤ 3e-5 sigmoid difference on a test image).* GELU is exported as the `Gelu` op (opset 20).Validated against the original PyTorch model on a 2560×1440 image: fp32 graph IoU 0.999996, fp16 graph IoU 0.9995 (ORT CPU).Requires a runtime that implements `DeformConv` and `Gelu` (verified with onnxruntime on CPU; the `birefnet-webgpu` engine on WebGPU).## License / credits10 unmodified lines111213141516171 unmodified line1920212223242526272829303132333435363738394041424344454647484910 unmodified lines- birefnet---# BiRefNet_lite-2K — ONNX fp16 (dynamic input size, low-memory graph)ONNX export of [ZhengPeng7/BiRefNet_lite-2K](https://huggingface.co/ZhengPeng7/BiRefNet_lite-2K)(Swin-T backbone, 44M params, trained for 2560×1440), made for in-browser inference with1 unmodified line| 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-resolutionmulti-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 inthe 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) isalgebraically collapsed into a 1×1 conv at low resolution plus one 5×5 conv on the input image, with thebranch'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
123version https://git-lfs.github.com/spec/v1oid sha256:5d03dc5de5f3295dfcf4b84829fbbcd52bc3adfac890965c7316b99d40739a02size 98728016123version https://git-lfs.github.com/spec/v1oid sha256:30359ab09268c342c71308f836db45485c5f8ac4f4b55c268dce99cf174bc25bsize 91435003
123version https://git-lfs.github.com/spec/v1oid sha256:ab11fddbecb0bbb8b07aa698d07f8fe15771b2714c992404a90588d7df2dc028size 93445455README.md+16-15
onnx/model_fp16.onnx+2-2
onnx/model_fp16_1024.onnxDeleted-3