Mask Generation
Transformers.js
ONNX
swin
onnxruntime
onnxruntime-web
webgpu
vision
image-segmentation
background-removal
salient-object-detection
matting
mvanet
Instructions to use MarcinEU/finegrain-box-segmenter-ONNX with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers.js
How to use MarcinEU/finegrain-box-segmenter-ONNX with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('mask-generation', 'MarcinEU/finegrain-box-segmenter-ONNX');
Add fp32 ONNX model, card, usage example, comparison samples, and conversion tooling
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .gitattributes +3 -0
- README.md +276 -0
- assets/samples/01-ben2-crop.png +3 -0
- assets/samples/01-ben2-full.png +3 -0
- assets/samples/01-ben2-mini.png +3 -0
- assets/samples/01-birefnet-massive-crop.png +3 -0
- assets/samples/01-birefnet-massive-full.png +3 -0
- assets/samples/01-birefnet-massive-mini.png +3 -0
- assets/samples/01-bria-crop.png +3 -0
- assets/samples/01-bria-full.png +3 -0
- assets/samples/01-bria-mini.png +3 -0
- assets/samples/01-finegrain-crop.png +3 -0
- assets/samples/01-finegrain-full.png +3 -0
- assets/samples/01-finegrain-mini.png +3 -0
- assets/samples/01-orig-crop.png +3 -0
- assets/samples/01-orig-full.png +3 -0
- assets/samples/01-orig-mini.png +3 -0
- assets/samples/02-ben2-crop.png +3 -0
- assets/samples/02-ben2-full.png +3 -0
- assets/samples/02-ben2-mini.png +3 -0
- assets/samples/02-birefnet-massive-crop.png +3 -0
- assets/samples/02-birefnet-massive-full.png +3 -0
- assets/samples/02-birefnet-massive-mini.png +3 -0
- assets/samples/02-bria-crop.png +3 -0
- assets/samples/02-bria-full.png +3 -0
- assets/samples/02-bria-mini.png +3 -0
- assets/samples/02-finegrain-crop.png +3 -0
- assets/samples/02-finegrain-full.png +3 -0
- assets/samples/02-finegrain-mini.png +3 -0
- assets/samples/02-orig-crop.png +3 -0
- assets/samples/02-orig-full.png +3 -0
- assets/samples/02-orig-mini.png +3 -0
- assets/samples/03-ben2-crop.png +3 -0
- assets/samples/03-ben2-full.png +3 -0
- assets/samples/03-ben2-mini.png +3 -0
- assets/samples/03-birefnet-massive-crop.png +3 -0
- assets/samples/03-birefnet-massive-full.png +3 -0
- assets/samples/03-birefnet-massive-mini.png +3 -0
- assets/samples/03-bria-crop.png +3 -0
- assets/samples/03-bria-full.png +3 -0
- assets/samples/03-bria-mini.png +3 -0
- assets/samples/03-finegrain-crop.png +3 -0
- assets/samples/03-finegrain-full.png +3 -0
- assets/samples/03-finegrain-mini.png +3 -0
- assets/samples/03-orig-crop.png +3 -0
- assets/samples/03-orig-full.png +3 -0
- assets/samples/03-orig-mini.png +3 -0
- assets/samples/04-ben2-crop.png +3 -0
- assets/samples/04-ben2-full.png +3 -0
- assets/samples/04-ben2-mini.png +3 -0
.gitattributes
CHANGED
|
@@ -33,3 +33,6 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
| 33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
|
| 37 |
+
# comparison images via LFS (HF requires binaries in LFS/Xet, not raw git)
|
| 38 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
|
@@ -1,3 +1,279 @@
|
|
| 1 |
---
|
| 2 |
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
license: mit
|
| 3 |
+
library_name: transformers.js
|
| 4 |
+
pipeline_tag: mask-generation
|
| 5 |
+
base_model:
|
| 6 |
+
- finegrain/finegrain-box-segmenter
|
| 7 |
+
base_model_relation: quantized
|
| 8 |
+
tags:
|
| 9 |
+
- onnx
|
| 10 |
+
- onnxruntime
|
| 11 |
+
- onnxruntime-web
|
| 12 |
+
- webgpu
|
| 13 |
+
- vision
|
| 14 |
+
- image-segmentation
|
| 15 |
+
- mask-generation
|
| 16 |
+
- background-removal
|
| 17 |
+
- salient-object-detection
|
| 18 |
+
- matting
|
| 19 |
+
- mvanet
|
| 20 |
---
|
| 21 |
+
|
| 22 |
+
# finegrain-box-segmenter — ONNX
|
| 23 |
+
|
| 24 |
+
FP32 ONNX export of [**finegrain/finegrain-box-segmenter**](https://huggingface.co/finegrain/finegrain-box-segmenter) (an MVANet high-resolution background remover), ready to run in the browser, Node.js and Python with [ONNX Runtime](https://onnxruntime.ai/) (CPU, WebGPU (recommended), DirectML).
|
| 25 |
+
|
| 26 |
+
- **Base model:** `finegrain/finegrain-box-segmenter` (MIT) — MVANet, SafeTensors, [arXiv:2404.07445](https://arxiv.org/abs/2404.07445)
|
| 27 |
+
- **Architecture:** MVANet with a **Swin-B** backbone, **~94.6 M parameters**; static 1024×1024
|
| 28 |
+
input, batch fixed at 1.
|
| 29 |
+
- **What this repo adds:** the same network exported to ONNX (full-precision floating-point **fp32**), so it runs
|
| 30 |
+
without PyTorch/refiners.
|
| 31 |
+
- **Why fp32:** maximum compatibility with zero precision risk — the fp32 graph runs on CPU, WebGPU and DirectML, and stays **bit-identical** to the original release; at ~94.6 M parameters it is still cheap enough to run on a local machine. (An fp16 build (~403 MB) exists and its masks matched fp32 in testing, but it is not published, to keep the release simple — open a discussion if you need it.) Regarding why this release uses the "quantized" tag: it's a fairly common convention for ONNX / format derivatives (same as e.g. `onnx-community/BiRefNet-ONNX`), so I decided to go this route for tagging.
|
| 32 |
+
- **Output is bit-identical to the PyTorch reference** on CPU (mask MAE `0.000 / 255`; random-input logits `max|Δ| = 1.5e-5`).
|
| 33 |
+
|
| 34 |
+
## Examples
|
| 35 |
+
|
| 36 |
+
These tests are **intentionally made to be difficult** for the models, doing their best to expose the weak points of each model.
|
| 37 |
+
|
| 38 |
+
1. Sub-pixel hair strands
|
| 39 |
+
2. Refraction + small object touching frame edge
|
| 40 |
+
3. Large shape touching edge in a style rarely seen in the training data (impasto), no obvious dominant subject
|
| 41 |
+
4. 3D/miniature with glows and object blending under water
|
| 42 |
+
5. Cartoon / flat 2D
|
| 43 |
+
6. Complex fire pattern
|
| 44 |
+
7. Reflections on a confusing background
|
| 45 |
+
8. Intricate many-holed topology
|
| 46 |
+
|
| 47 |
+
The short version: **finegrain-box-segmenter is strongest on soft, semi-transparent edges** — it keeps more sub-pixel hair strands (1), cleaner glass/refraction edges (2) and more of the flame and fur tips (6) than the other tools, and it resolves the many-holed branch topology (8) cleanly. Its weak spots in this set: the ultra-thin rigging wires in (4) (the BiRefNet variants preserve them better) and the unusual impasto style of (3), where part of the rooster's comb goes semi-transparent. All cutouts were produced the same way: each tool's standard whole-image pipeline — no boxes or prompts — on identical source images, and every crop is the same pixel window. The competitors: `ben2-base` = [BEN2](https://huggingface.co/PramaLLC/BEN2), `bria-rmbg` = [BRIA RMBG-2.0](https://huggingface.co/briaai/RMBG-2.0), `birefnet-massive` = [BiRefNet](https://huggingface.co/ZhengPeng7/BiRefNet-DIS5K-TR_TEs), the massive-trained checkpoint (`BiRefNet-massive-TR_DIS5K_TR_TEs-epoch_420`, run via [rembg](https://github.com/danielgatis/rembg)).
|
| 48 |
+
|
| 49 |
+
<table>
|
| 50 |
+
<thead>
|
| 51 |
+
<tr><th></th><th>Original</th><th>finegrain-box-segmenter</th><th>ben2-base</th><th>bria-rmbg</th><th>birefnet-massive</th></tr>
|
| 52 |
+
</thead>
|
| 53 |
+
<tbody>
|
| 54 |
+
<tr><th rowspan="2" align="left">1</th><td><a href="assets/samples/01-orig-full.png"><img src="assets/samples/01-orig-mini.png" width="130" alt="test 1 — original image"></a></td><td><a href="assets/samples/01-finegrain-full.png"><img src="assets/samples/01-finegrain-mini.png" width="130" alt="test 1 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/01-ben2-full.png"><img src="assets/samples/01-ben2-mini.png" width="130" alt="test 1 — BEN2 cutout"></a></td><td><a href="assets/samples/01-bria-full.png"><img src="assets/samples/01-bria-mini.png" width="130" alt="test 1 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/01-birefnet-massive-full.png"><img src="assets/samples/01-birefnet-massive-mini.png" width="130" alt="test 1 — BiRefNet-massive cutout"></a></td></tr>
|
| 55 |
+
<tr><td><img src="assets/samples/01-orig-crop.png" width="180" alt="test 1 — original detail crop"></td><td><img src="assets/samples/01-finegrain-crop.png" width="180" alt="test 1 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/01-ben2-crop.png" width="180" alt="test 1 — BEN2 detail crop"></td><td><img src="assets/samples/01-bria-crop.png" width="180" alt="test 1 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/01-birefnet-massive-crop.png" width="180" alt="test 1 — BiRefNet-massive detail crop"></td></tr>
|
| 56 |
+
<tr><th rowspan="2" align="left">2</th><td><a href="assets/samples/02-orig-full.png"><img src="assets/samples/02-orig-mini.png" width="130" alt="test 2 — original image"></a></td><td><a href="assets/samples/02-finegrain-full.png"><img src="assets/samples/02-finegrain-mini.png" width="130" alt="test 2 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/02-ben2-full.png"><img src="assets/samples/02-ben2-mini.png" width="130" alt="test 2 — BEN2 cutout"></a></td><td><a href="assets/samples/02-bria-full.png"><img src="assets/samples/02-bria-mini.png" width="130" alt="test 2 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/02-birefnet-massive-full.png"><img src="assets/samples/02-birefnet-massive-mini.png" width="130" alt="test 2 — BiRefNet-massive cutout"></a></td></tr>
|
| 57 |
+
<tr><td><img src="assets/samples/02-orig-crop.png" width="180" alt="test 2 — original detail crop"></td><td><img src="assets/samples/02-finegrain-crop.png" width="180" alt="test 2 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/02-ben2-crop.png" width="180" alt="test 2 — BEN2 detail crop"></td><td><img src="assets/samples/02-bria-crop.png" width="180" alt="test 2 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/02-birefnet-massive-crop.png" width="180" alt="test 2 — BiRefNet-massive detail crop"></td></tr>
|
| 58 |
+
<tr><th rowspan="2" align="left">3</th><td><a href="assets/samples/03-orig-full.png"><img src="assets/samples/03-orig-mini.png" width="130" alt="test 3 — original image"></a></td><td><a href="assets/samples/03-finegrain-full.png"><img src="assets/samples/03-finegrain-mini.png" width="130" alt="test 3 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/03-ben2-full.png"><img src="assets/samples/03-ben2-mini.png" width="130" alt="test 3 — BEN2 cutout"></a></td><td><a href="assets/samples/03-bria-full.png"><img src="assets/samples/03-bria-mini.png" width="130" alt="test 3 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/03-birefnet-massive-full.png"><img src="assets/samples/03-birefnet-massive-mini.png" width="130" alt="test 3 — BiRefNet-massive cutout"></a></td></tr>
|
| 59 |
+
<tr><td><img src="assets/samples/03-orig-crop.png" width="180" alt="test 3 — original detail crop"></td><td><img src="assets/samples/03-finegrain-crop.png" width="180" alt="test 3 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/03-ben2-crop.png" width="180" alt="test 3 — BEN2 detail crop"></td><td><img src="assets/samples/03-bria-crop.png" width="180" alt="test 3 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/03-birefnet-massive-crop.png" width="180" alt="test 3 — BiRefNet-massive detail crop"></td></tr>
|
| 60 |
+
<tr><th rowspan="2" align="left">4</th><td><a href="assets/samples/04-orig-full.png"><img src="assets/samples/04-orig-mini.png" width="130" alt="test 4 — original image"></a></td><td><a href="assets/samples/04-finegrain-full.png"><img src="assets/samples/04-finegrain-mini.png" width="130" alt="test 4 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/04-ben2-full.png"><img src="assets/samples/04-ben2-mini.png" width="130" alt="test 4 — BEN2 cutout"></a></td><td><a href="assets/samples/04-bria-full.png"><img src="assets/samples/04-bria-mini.png" width="130" alt="test 4 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/04-birefnet-massive-full.png"><img src="assets/samples/04-birefnet-massive-mini.png" width="130" alt="test 4 — BiRefNet-massive cutout"></a></td></tr>
|
| 61 |
+
<tr><td><img src="assets/samples/04-orig-crop.png" width="180" alt="test 4 — original detail crop"></td><td><img src="assets/samples/04-finegrain-crop.png" width="180" alt="test 4 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/04-ben2-crop.png" width="180" alt="test 4 — BEN2 detail crop"></td><td><img src="assets/samples/04-bria-crop.png" width="180" alt="test 4 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/04-birefnet-massive-crop.png" width="180" alt="test 4 — BiRefNet-massive detail crop"></td></tr>
|
| 62 |
+
<tr><th rowspan="2" align="left">5</th><td><a href="assets/samples/05-orig-full.png"><img src="assets/samples/05-orig-mini.png" width="130" alt="test 5 — original image"></a></td><td><a href="assets/samples/05-finegrain-full.png"><img src="assets/samples/05-finegrain-mini.png" width="130" alt="test 5 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/05-ben2-full.png"><img src="assets/samples/05-ben2-mini.png" width="130" alt="test 5 — BEN2 cutout"></a></td><td><a href="assets/samples/05-bria-full.png"><img src="assets/samples/05-bria-mini.png" width="130" alt="test 5 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/05-birefnet-massive-full.png"><img src="assets/samples/05-birefnet-massive-mini.png" width="130" alt="test 5 — BiRefNet-massive cutout"></a></td></tr>
|
| 63 |
+
<tr><td><img src="assets/samples/05-orig-crop.png" width="180" alt="test 5 — original detail crop"></td><td><img src="assets/samples/05-finegrain-crop.png" width="180" alt="test 5 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/05-ben2-crop.png" width="180" alt="test 5 — BEN2 detail crop"></td><td><img src="assets/samples/05-bria-crop.png" width="180" alt="test 5 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/05-birefnet-massive-crop.png" width="180" alt="test 5 — BiRefNet-massive detail crop"></td></tr>
|
| 64 |
+
<tr><th rowspan="2" align="left">6</th><td><a href="assets/samples/06-orig-full.png"><img src="assets/samples/06-orig-mini.png" width="130" alt="test 6 — original image"></a></td><td><a href="assets/samples/06-finegrain-full.png"><img src="assets/samples/06-finegrain-mini.png" width="130" alt="test 6 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/06-ben2-full.png"><img src="assets/samples/06-ben2-mini.png" width="130" alt="test 6 — BEN2 cutout"></a></td><td><a href="assets/samples/06-bria-full.png"><img src="assets/samples/06-bria-mini.png" width="130" alt="test 6 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/06-birefnet-massive-full.png"><img src="assets/samples/06-birefnet-massive-mini.png" width="130" alt="test 6 — BiRefNet-massive cutout"></a></td></tr>
|
| 65 |
+
<tr><td><img src="assets/samples/06-orig-crop.png" width="180" alt="test 6 — original detail crop"></td><td><img src="assets/samples/06-finegrain-crop.png" width="180" alt="test 6 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/06-ben2-crop.png" width="180" alt="test 6 — BEN2 detail crop"></td><td><img src="assets/samples/06-bria-crop.png" width="180" alt="test 6 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/06-birefnet-massive-crop.png" width="180" alt="test 6 — BiRefNet-massive detail crop"></td></tr>
|
| 66 |
+
<tr><th rowspan="2" align="left">7</th><td><a href="assets/samples/07-orig-full.png"><img src="assets/samples/07-orig-mini.png" width="130" alt="test 7 — original image"></a></td><td><a href="assets/samples/07-finegrain-full.png"><img src="assets/samples/07-finegrain-mini.png" width="130" alt="test 7 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/07-ben2-full.png"><img src="assets/samples/07-ben2-mini.png" width="130" alt="test 7 — BEN2 cutout"></a></td><td><a href="assets/samples/07-bria-full.png"><img src="assets/samples/07-bria-mini.png" width="130" alt="test 7 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/07-birefnet-massive-full.png"><img src="assets/samples/07-birefnet-massive-mini.png" width="130" alt="test 7 — BiRefNet-massive cutout"></a></td></tr>
|
| 67 |
+
<tr><td><img src="assets/samples/07-orig-crop.png" width="180" alt="test 7 — original detail crop"></td><td><img src="assets/samples/07-finegrain-crop.png" width="180" alt="test 7 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/07-ben2-crop.png" width="180" alt="test 7 — BEN2 detail crop"></td><td><img src="assets/samples/07-bria-crop.png" width="180" alt="test 7 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/07-birefnet-massive-crop.png" width="180" alt="test 7 — BiRefNet-massive detail crop"></td></tr>
|
| 68 |
+
<tr><th rowspan="2" align="left">8</th><td><a href="assets/samples/08-orig-full.png"><img src="assets/samples/08-orig-mini.png" width="130" alt="test 8 — original image"></a></td><td><a href="assets/samples/08-finegrain-full.png"><img src="assets/samples/08-finegrain-mini.png" width="130" alt="test 8 — finegrain-box-segmenter cutout"></a></td><td><a href="assets/samples/08-ben2-full.png"><img src="assets/samples/08-ben2-mini.png" width="130" alt="test 8 — BEN2 cutout"></a></td><td><a href="assets/samples/08-bria-full.png"><img src="assets/samples/08-bria-mini.png" width="130" alt="test 8 — RMBG-2.0 cutout"></a></td><td><a href="assets/samples/08-birefnet-massive-full.png"><img src="assets/samples/08-birefnet-massive-mini.png" width="130" alt="test 8 — BiRefNet-massive cutout"></a></td></tr>
|
| 69 |
+
<tr><td><img src="assets/samples/08-orig-crop.png" width="180" alt="test 8 — original detail crop"></td><td><img src="assets/samples/08-finegrain-crop.png" width="180" alt="test 8 — finegrain-box-segmenter detail crop"></td><td><img src="assets/samples/08-ben2-crop.png" width="180" alt="test 8 — BEN2 detail crop"></td><td><img src="assets/samples/08-bria-crop.png" width="180" alt="test 8 — RMBG-2.0 detail crop"></td><td><img src="assets/samples/08-birefnet-massive-crop.png" width="180" alt="test 8 — BiRefNet-massive detail crop"></td></tr>
|
| 70 |
+
</tbody>
|
| 71 |
+
</table>
|
| 72 |
+
|
| 73 |
+
## Files
|
| 74 |
+
|
| 75 |
+
| File | Precision | Size | Notes |
|
| 76 |
+
|------|-----------|-----:|-------|
|
| 77 |
+
| `onnx/model.onnx` | fp32 | ~805 MB | full precision; CPU + WebGPU; bit-identical parity with PyTorch |
|
| 78 |
+
|
| 79 |
+
ONNX operator set version 17, ~94.6 M parameters, SHA256(onnx/model.onnx) = `d3f60fc778f2b14435a8df3d61511c293cec3a88c670ad8ecac5035c6b9730d5`
|
| 80 |
+
|
| 81 |
+
> Why 805 MB for a 94.6 M-param model: ~378 MB is fp32 weights; the other ~425 MB is constant-folded shifted-window (Swin) attention masks / position embeddings baked in at export (`do_constant_folding=True`). Note that disabling the folding will make the file *larger*, not smaller.
|
| 82 |
+
|
| 83 |
+
## I/O contract
|
| 84 |
+
|
| 85 |
+
| | name | shape | dtype |
|
| 86 |
+
|---|---|---|---|
|
| 87 |
+
| input | `input` | `[1, 3, 1024, 1024]` | float32 |
|
| 88 |
+
| output | `logits` | `[1, 1, 1024, 1024]` | float32 (raw logits) |
|
| 89 |
+
|
| 90 |
+
**Pre-processing** (must be reproduced by the caller): take the RGB image, resize to 1024×1024 (bilinear or a comparable resampler — mild resampler differences don't visibly change the mask), scale to `[0,1]` (`/255`), normalize with ImageNet statistics `mean = [0.485, 0.456, 0.406]`, `std = [0.229, 0.224, 0.225]`, layout NCHW.
|
| 91 |
+
|
| 92 |
+
**Post-processing:** apply **`sigmoid`** to the logits to get an alpha matte in `[0,1]`, then resize it back to the original image size. Use it directly as a mask, or as the alpha channel of an RGBA cutout. (Note: this model emits **raw logits** — apply sigmoid; do *not* min-max normalize the output the way some other ONNX matting models, e.g. BEN2, require.)
|
| 93 |
+
|
| 94 |
+
## How it was converted
|
| 95 |
+
|
| 96 |
+
Exported from the published [v0.1 SafeTensors weights](https://huggingface.co/finegrain/finegrain-box-segmenter) with PyTorch's **legacy TorchScript exporter** (`torch.onnx.export` with the dynamo path disabled) at opset 17, with constant folding enabled. The raw `nn.Module` — obtained from refiners' `BoxSegmenter` and put in eval / float mode — is traced on a single `1×3×1024×1024` float input, and its tensors are named `input` and `logits`. There are no architecture changes and no retraining: the exported graph is exactly `image → logits`.
|
| 97 |
+
|
| 98 |
+
Two non-obvious choices were required:
|
| 99 |
+
|
| 100 |
+
- **Legacy exporter, not dynamo.** torch's dynamo / `torch.export` path fails decomposing Swin's `transpose(1,2).reshape(...)` (it lowers the non-contiguous view to a strict `aten.view` that can't represent the transposed strides). The legacy TorchScript tracer records a real `Reshape` and exports cleanly.
|
| 101 |
+
- `adaptive_avg_pool2d` → `avg_pool2d`. Refiners' pooling always divides evenly (`adaptive_avg_pool2d(x, (h//r, w//r))`), so it is **numerically identical** to a plain `avg_pool2d(kernel=r, stride=r)` that maps to ONNX `AveragePool` — an exact swap, not an approximation.
|
| 102 |
+
|
| 103 |
+
The graph uses only standard ops (`Conv, AveragePool, MatMul, Gemm, Resize, Softmax, LayerNormalization, PRelu, Add, Mul, Concat, Split, Slice, Reshape, Transpose`) — no `grid_sample` / `einsum` / `unfold` — so it runs on ORT CPU and WebGPU as-is.
|
| 104 |
+
|
| 105 |
+
**Parity** (`verify_parity.py`, CPU fp32): random input → torch vs ORT logits `max|Δ| = 1.5e-5` (sigmoid `3e-6`); refiners' golden cactus image → mask **MAE = 0.000 / 255** (bit-identical). The full sourced write-up lives in this repo at [`docs/HOW-CONVERSION-WAS-MADE.md`](docs/HOW-CONVERSION-WAS-MADE.md); to reproduce the export yourself, see [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md) and the [`python/`](python) scripts.
|
| 106 |
+
|
| 107 |
+
## Quality — measured on *this* ONNX
|
| 108 |
+
|
| 109 |
+
The base model's published benchmark was re-run **on this ONNX export**: the full [`finegrain/finegrain-product-masks-lite`](https://huggingface.co/datasets/finegrain/finegrain-product-masks-lite) set (120 masks), scored with [PySODMetrics](https://github.com/lartpang/PySODMetrics). It was scored in two modes, which measure different things — don't mix them up when comparing models:
|
| 110 |
+
|
| 111 |
+
| Mode (same 120 masks) | MAE ↓ | S-measure ↑ | E-measure (mean) ↑ | Dice (mean) ↑ |
|
| 112 |
+
|---|--:|--:|--:|--:|
|
| 113 |
+
| **Box-prompted crop** — the base model's published protocol | **0.0079** | **0.9738** | **0.9854** | **0.9669** |
|
| 114 |
+
| **Whole-image (no box)** — how this release is used | 0.086 | 0.796 | 0.793 | 0.712 |
|
| 115 |
+
|
| 116 |
+
**Box-prompted crop mode** confirms the conversion: bit-identical parity implies identical task quality, and running the base model's own protocol on this ONNX reproduces its published numbers to within rounding:
|
| 117 |
+
|
| 118 |
+
| Metric | **This ONNX** | Published (base) | Δ |
|
| 119 |
+
|---|--:|--:|--:|
|
| 120 |
+
| MAE ↓ | **0.0079** | 0.0078 | +0.0001 |
|
| 121 |
+
| S-measure ↑ | **0.9738** | 0.974 | −0.0002 |
|
| 122 |
+
| E-measure (mean) ↑ | **0.9854** | 0.985 | +0.0004 |
|
| 123 |
+
| Dice (mean) ↑ | **0.9669** | 0.967 | −0.0001 |
|
| 124 |
+
|
| 125 |
+
n = 120. The sub-0.001 deltas are host-side resize / box-derivation rounding, **not** conversion error — the ONNX **inherits the original's quality** (which, on this set, beats `briaai/RMBG-1.4` and box-guided `ZhengPeng7/BiRefNet`; see the base card).
|
| 126 |
+
|
| 127 |
+
**Whole-image mode (no box)** scores far lower *by construction*: this dataset's ground truth is one *specific boxed object*, so scoring the no-prompt salient output against it penalizes the model whenever the image's salient region isn't exactly that boxed target. It's a worst-case lower bound on a box-oriented set — not representative of ordinary single-subject background removal (see the [Examples](#examples) above for what whole-image output actually looks like).
|
| 128 |
+
|
| 129 |
+
## Usage — Transformers.js (easiest)
|
| 130 |
+
|
| 131 |
+
This repo ships the standard `onnx/model.onnx` + `config.json` + `preprocessor_config.json` layout, so [Transformers.js](https://huggingface.co/docs/transformers.js) drives the whole pipeline for you — pre-process, sigmoid, and resize-back included:
|
| 132 |
+
|
| 133 |
+
```js
|
| 134 |
+
import { pipeline } from '@huggingface/transformers';
|
| 135 |
+
|
| 136 |
+
const segmenter = await pipeline('background-removal', 'MarcinEU/finegrain-box-segmenter-ONNX');
|
| 137 |
+
const out = await segmenter(['https://example.com/photo.jpg']);
|
| 138 |
+
out[0].save('cutout.png'); // RawImage RGBA - alpha is the matte
|
| 139 |
+
// out[0].toCanvas() / await out[0].toBlob() if you'd rather not save to disk
|
| 140 |
+
```
|
| 141 |
+
|
| 142 |
+
Verified end-to-end (`@huggingface/transformers` v4.2.0): the model resolves to `SwinForSemanticSegmentation`, Transformers.js remaps the processor output onto our `input` tensor and auto-applies `sigmoid` to the raw `logits` — no custom code. Add `{ device: 'webgpu' }` for the GPU. Use **v4.2.0 or newer** (the automatic input-name remap and auto-sigmoid are required). If you need full control over pre/post-processing, use the hand-rolled paths below.
|
| 143 |
+
|
| 144 |
+
## Usage — onnxruntime-web (browser, WebGPU)
|
| 145 |
+
|
| 146 |
+
```js
|
| 147 |
+
import * as ort from 'onnxruntime-web/webgpu';
|
| 148 |
+
|
| 149 |
+
const SIZE = 1024, MEAN = [0.485,0.456,0.406], STD = [0.229,0.224,0.225];
|
| 150 |
+
const session = await ort.InferenceSession.create(
|
| 151 |
+
'https://huggingface.co/MarcinEU/finegrain-box-segmenter-ONNX/resolve/main/onnx/model.onnx',
|
| 152 |
+
{ executionProviders: ['webgpu'] });
|
| 153 |
+
|
| 154 |
+
// draw your image into a 1024x1024 canvas, then:
|
| 155 |
+
const { data } = ctx.getImageData(0, 0, SIZE, SIZE); // RGBA, Uint8ClampedArray
|
| 156 |
+
const plane = SIZE * SIZE, chw = new Float32Array(3 * plane);
|
| 157 |
+
for (let p = 0; p < plane; p++) {
|
| 158 |
+
chw[p] = (data[p*4] / 255 - MEAN[0]) / STD[0];
|
| 159 |
+
chw[plane + p] = (data[p*4+1] / 255 - MEAN[1]) / STD[1];
|
| 160 |
+
chw[2*plane + p] = (data[p*4+2] / 255 - MEAN[2]) / STD[2];
|
| 161 |
+
}
|
| 162 |
+
const out = await session.run({ input: new ort.Tensor('float32', chw, [1,3,SIZE,SIZE]) });
|
| 163 |
+
const logits = out.logits.data; // Float32Array, 1024*1024
|
| 164 |
+
const alpha = logits.map(v => 1 / (1 + Math.exp(-v))); // sigmoid -> [0,1]
|
| 165 |
+
// resize `alpha` back to your image size and composite as the alpha channel.
|
| 166 |
+
```
|
| 167 |
+
|
| 168 |
+
## Usage — onnxruntime-node (Node.js, with `sharp`)
|
| 169 |
+
|
| 170 |
+
A complete, runnable background remover is in [`usage/remove_bg.mjs`](usage/remove_bg.mjs) — run it from the repo root (with `onnx/model.onnx` downloaded):
|
| 171 |
+
|
| 172 |
+
```bash
|
| 173 |
+
npm i onnxruntime-node sharp
|
| 174 |
+
node usage/remove_bg.mjs --image photo.jpg --model onnx/model.onnx # CPU
|
| 175 |
+
node usage/remove_bg.mjs --image photo.jpg --model onnx/model.onnx --ep webgpu # GPU (often 3-10x faster; see Performance below)
|
| 176 |
+
```
|
| 177 |
+
|
| 178 |
+
It resizes the whole image to 1024², normalizes, runs the session, applies sigmoid, resizes the mask back, and writes `*_mask.png` and `*_cutout.png` (RGBA). Outputs carry real transparency — view them over a checkerboard/solid background.
|
| 179 |
+
|
| 180 |
+
## Usage — Python (onnxruntime)
|
| 181 |
+
|
| 182 |
+
Verified against this exact export (`pip install onnxruntime pillow numpy huggingface_hub`); masks match the Node reference pipeline to ~1/255 mean difference:
|
| 183 |
+
|
| 184 |
+
```python
|
| 185 |
+
from huggingface_hub import hf_hub_download
|
| 186 |
+
from PIL import Image
|
| 187 |
+
import numpy as np, onnxruntime as ort
|
| 188 |
+
|
| 189 |
+
model_path = hf_hub_download("MarcinEU/finegrain-box-segmenter-ONNX", "onnx/model.onnx")
|
| 190 |
+
session = ort.InferenceSession(model_path)
|
| 191 |
+
|
| 192 |
+
img = Image.open("photo.jpg").convert("RGB")
|
| 193 |
+
x = np.asarray(img.resize((1024, 1024), Image.BILINEAR), dtype=np.float32) / 255.0
|
| 194 |
+
x = ((x - [0.485, 0.456, 0.406]) / [0.229, 0.224, 0.225]).transpose(2, 0, 1)[None].astype(np.float32)
|
| 195 |
+
|
| 196 |
+
logits = session.run(None, {"input": x})[0][0, 0]
|
| 197 |
+
alpha = 1.0 / (1.0 + np.exp(-logits)) # sigmoid -> [0,1]
|
| 198 |
+
mask = Image.fromarray((alpha * 255).astype(np.uint8)).resize(img.size, Image.BILINEAR)
|
| 199 |
+
|
| 200 |
+
cutout = img.copy(); cutout.putalpha(mask)
|
| 201 |
+
cutout.save("cutout.png"); mask.save("mask.png")
|
| 202 |
+
```
|
| 203 |
+
|
| 204 |
+
## Performance across environments
|
| 205 |
+
|
| 206 |
+
The graph is a **static 1024×1024 fp32** Swin-B (MVANet) running at internal **batch-5**, so it is **compute-bound and the inference time is ~constant regardless of input image size** — the source resolution only changes the negligible host-side resize (`pre` + `post`, ≈30–500 ms for 1080p→8K). The numbers below are therefore "**per image**" for any resolution. All EPs run the **same fp32 model** (no fp16/NPU path). Measured with `onnxruntime-node` 1.26, **15 runs/cell, median**.
|
| 207 |
+
|
| 208 |
+
### Measured — median inference time, seconds per image (lower is better)
|
| 209 |
+
|
| 210 |
+
| Machine (form factor) | CPU (cores/threads) | GPU | RAM | **CPU EP** | **WebGPU** | **DirectML** |
|
| 211 |
+
|---|---|---|--:|--:|--:|--:|
|
| 212 |
+
| Desktop + discrete GPU | i7-8700K (6C/12T) | **NVIDIA RTX 5070 Ti** 16 GB | 32 GB | 9.7 | **0.9** ⭐ | 1.5 |
|
| 213 |
+
| Laptop (Arrow Lake-H) | Core Ultra 7 255H (16C/16T) | Intel **Arc 140T** iGPU | 48 GB | **4.6** | 8.6 | **1.6** ⭐ |
|
| 214 |
+
| Laptop (Tiger Lake) | i7-1165G7 (4C/8T) | Intel Iris Xe 96 EU iGPU | 16 GB | 13.9 | **9.6** ⭐ | ✗ OOM at init |
|
| 215 |
+
| Laptop (Raptor Lake-U) | i5-1335U (10C/12T, 15 W) | Intel Iris Xe 80 EU iGPU | 8 GB | **≈15** ⭐ | ✗ OOM ~3934 MB¹ | ✗ device-hung |
|
| 216 |
+
|
| 217 |
+
⭐ = fastest working backend on that machine. ✗ = execution provider failed (footnotes ¹–³ below give the byte-level cause). Numbers here are the steady-state median across sizes; the **per-size mean ± std** is in the Reference anchors tables below. Add **pre+post** for end-to-end total: ≈0.05 s at 512��/1080p, ≈0.5 s at 8K.
|
| 218 |
+
|
| 219 |
+
**Neither the NPU nor any other accelerator is involved.** `onnxruntime-node` has no NPU EP here: the **CPU EP** uses CPU cores, **DirectML/WebGPU** use the **GPU**. The Core Ultra 7 255H's "Intel AI Boost" NPU is *not* used — its NPU TOPS are irrelevant to these numbers; the iGPU figures above are the **Arc 140T graphics**, not the NPU.
|
| 220 |
+
|
| 221 |
+
### Reference anchors — match your own machine
|
| 222 |
+
|
| 223 |
+
Every **hardware × EP combination measured**, broken out by input size. Cells are **mean ± std** of the per-image **inference** time in seconds (the warm-up run is dropped, so n ≈ 14; n = 10 where noted). ✗ = the EP failed — see footnotes. Because inference is ~size-independent (static 1024² input) a row's four cells are nearly equal; the size axis mainly exposes **where memory runs out** (e.g. the 8 GB laptop clears 8K but not the smaller sizes). fp16 TFLOPS are a published **proxy** for ranking GPUs (the model runs fp32, so real rates are lower); discrete-GPU bandwidth is on-card VRAM, iGPU bandwidth is the shared-RAM `memcpy` rate measured. `″` = same as the row above; the Arc 140T additionally has XMX matrix engines (74 INT8 TOPS) that its fp32 path does not use.
|
| 224 |
+
|
| 225 |
+
**GPU backends** (anchor = fp16 throughput + memory bandwidth):
|
| 226 |
+
|
| 227 |
+
| GPU (arch) | EP | fp16 (proxy) | Mem BW | 8K (s) | 4K (s) | 1080p (s) | 512² (s) |
|
| 228 |
+
|---|---|--:|--:|--:|--:|--:|--:|
|
| 229 |
+
| RTX 5070 Ti (Blackwell), discrete 16 GB | WebGPU | 88 TFLOPS | 896 GB/s | 0.95 ± 0.07 | 0.85 ± 0.06 | 0.85 ± 0.07 | 0.89 ± 0.08 |
|
| 230 |
+
| RTX 5070 Ti | DirectML | ″ | ″ | 1.50 ± 0.03 | 1.50 ± 0.06 | 1.48 ± 0.04 | 1.50 ± 0.04 |
|
| 231 |
+
| Arc 140T iGPU (Xe-LPG, 8 Xe @2.25 GHz) | DirectML | ~9 TFLOPS | ~39 GB/s sh. | 1.58 ± 0.02 | 1.57 ± 0.00 | 1.57 ± 0.00 | 1.57 ± 0.00 |
|
| 232 |
+
| Arc 140T | WebGPU | ″ | ″ | 8.61 ± 0.05 | 8.64 ± 0.08 | 8.64 ± 0.09 | 8.65 ± 0.07 |
|
| 233 |
+
| Iris Xe 96 EU iGPU (Tiger Lake) | WebGPU | 3.4 TFLOPS | ~31 GB/s sh. | 9.79 ± 0.40 | 9.52 ± 0.34 | 9.46 ± 0.25 | 9.77 ± 0.46 |
|
| 234 |
+
| Iris Xe 96 EU | DirectML | ″ | ″ | ✗² | ✗² | ✗² | ✗² |
|
| 235 |
+
| Iris Xe 80 EU iGPU (Raptor Lake-U) | WebGPU | ~3 TFLOPS | ~29 GB/s sh. | 33.4 ± 2.8¹ | ✗¹ | ✗¹ | ✗¹ |
|
| 236 |
+
| Iris Xe 80 EU | DirectML | ″ | ″ | ✗³ | ✗³ | ✗³ | ✗³ |
|
| 237 |
+
|
| 238 |
+
¹ **WebGPU / Iris Xe 80 EU (8 GB RAM):** peaked at **~3934 MB — essentially the entire ~3940 MB shared budget** (≈50% of 8 GB RAM). Only 8K ran (11 of 15 runs, ~33 s mean) before it OOM'd; every 4K / 1080p / 512 run failed. WebGPU is **unusable at 8 GB RAM**. <br>
|
| 239 |
+
² **DirectML / Iris Xe 96 EU (16 GB RAM):** out of memory (`8007000E`) **during session creation** (~12.7 s in) — never ran. DirectML's footprint is **~16–19 GB** (peak where it ran) vs only **~8032 MB** shared iGPU budget (≈50% of 16 GB RAM). <br>
|
| 240 |
+
³ **DirectML / Iris Xe 80 EU (8 GB RAM):** init failed with a GPU **device-hung** error (`887A0007`, "GPU will not respond to more commands") — not strictly OOM, likely a cascade from the preceding WebGPU crash on the same ~3940 MB shared budget.
|
| 241 |
+
|
| 242 |
+
**CPU backend** (anchor = cores × clock × AVX width + RAM bandwidth; EP = CPU on every row):
|
| 243 |
+
|
| 244 |
+
| CPU (cores/threads, arch) | RAM BW | 8K (s) | 4K (s) | 1080p (s) | 512² (s) |
|
| 245 |
+
|---|--:|--:|--:|--:|--:|
|
| 246 |
+
| Core Ultra 7 255H (16C/16T, Arrow Lake-H, AVX2) | ~39 GB/s | 4.57 ± 0.08 | 4.61 ± 0.05 | 4.63 ± 0.12 | 4.65 ± 0.17 |
|
| 247 |
+
| i7-8700K (6C/12T, Coffee Lake, AVX2) | ~25 GB/s | 9.75 ± 0.24 | 9.69 ± 0.10 | 9.67 ± 0.11 | 9.67 ± 0.13 |
|
| 248 |
+
| i7-1165G7 (4C/8T, Tiger Lake, AVX2/512) | ~31 GB/s | 14.6 ± 1.5 | 13.9 ± 0.5 | 13.8 ± 0.3 | 13.9 ± 0.2 |
|
| 249 |
+
| i5-1335U (10C/12T, 15 W, Raptor Lake-U) | ~29 GB/s | 14.3 ± 2.1 | 14.9 ± 1.6 | 15.7 ± 2.0 | 14.3 ± 1.8 |
|
| 250 |
+
|
| 251 |
+
(The CPU EP was also run on the RTX 5070 Ti box — that's the i7-8700K row — since the CPU EP ignores the GPU. The 1335U's larger ± is real run-to-run jitter on a 15 W thermally-throttled laptop.)
|
| 252 |
+
|
| 253 |
+
**How to read it / rules of thumb:**
|
| 254 |
+
|
| 255 |
+
- **Choose the EP, not just the chip.** Discrete NVIDIA/AMD → **WebGPU** (fastest). Intel **Arc** iGPU → **DirectML** (its WebGPU path is ~5× slower here). Older Intel **Iris Xe** → **WebGPU** if you have ≥16 GB RAM, else **CPU**. No usable GPU → **CPU** (scales with cores × clock × AVX width; the 16-core 255H is ~3× the 4-core 1165G7).
|
| 256 |
+
- **RAM is the gate for iGPUs.** The fp32 model is ~805 MB on disk but a GPU session peaks at **8–20 GB** (VRAM on discrete cards; *shared system RAM* on iGPUs — WebGPU peaked ~8 GB, DirectML ~15–19 GB in our runs). So: iGPU WebGPU needs **≥16 GB system RAM**; iGPU DirectML wants **≥32 GB**; **8 GB machines can only use the CPU**. Discrete GPUs need **≥8 GB VRAM** free.
|
| 257 |
+
- **DirectML is hit-or-miss.** It gave the best iGPU time (Arc 140T, 1.6 s) but failed to initialize on three of four machines (driver/VRAM dependent). Always have the CPU EP as a fallback.
|
| 258 |
+
- **Predict GPU time** ≈ scale the RTX 5070 Ti's 0.9 s by its fp16 proxy vs yours, then add ~30–50 % headroom because the model is fp32 and won't fully use tensor cores. (e.g. a ~40 TFLOPS-fp16 card → expect ~2 s; a ~9 TFLOPS iGPU via a *good* runtime → ~1.5–2 s, which matches the Arc 140T on DML.)
|
| 259 |
+
|
| 260 |
+
## Notes
|
| 261 |
+
|
| 262 |
+
- **Resolution / batch are fixed** at `1×3×1024×1024` (the network hard-codes 1024² internally). Any aspect ratio works — the squash-resize matches the original model's behavior (a very common approach among mask-generation and image-segmentation models).
|
| 263 |
+
- **Runtime requirement:** the graph is opset 17, so it needs **`onnxruntime-node` ≥ 1.12.0** (July 2022; earlier versions will crash on load). Current `onnxruntime-web` is fine.
|
| 264 |
+
- **WebGPU:** runs as-is on standard adapters — the widest `Concat`/`Split` is only 4–5 inputs, well under the `maxStorageBuffersPerShaderStage` limit, so no graph surgery is needed (verified on the machines in the Performance section above). Only WebGPU "compatibility mode" (limit 4) devices would need a cascade rewrite.
|
| 265 |
+
|
| 266 |
+
## License & attribution
|
| 267 |
+
|
| 268 |
+
**MIT**, inherited from the base model. All credit for the weights and architecture goes to **Finegrain** ([finegrain/finegrain-box-segmenter](https://huggingface.co/finegrain/finegrain-box-segmenter)) and the **MVANet** authors. This repository only provides an ONNX conversion of the public `v0.1` weights (`model.safetensors`, SHA256 `fd5f13919dfc0dda102df1af648c3773c61221aa65fe58d6af978637baded1ae`).
|
| 269 |
+
|
| 270 |
+
## Citation
|
| 271 |
+
|
| 272 |
+
```bibtex
|
| 273 |
+
@article{mvanet,
|
| 274 |
+
title = {Multi-view Aggregation Network for Dichotomous Image Segmentation},
|
| 275 |
+
author = {Yu, Qian and Zhao, Xiaoqi and Pang, Youwei and Zhang, Lihe and Lu, Huchuan},
|
| 276 |
+
journal = {CVPR},
|
| 277 |
+
year = {2024}
|
| 278 |
+
}
|
| 279 |
+
```
|
assets/samples/01-ben2-crop.png
ADDED
|
Git LFS Details
|
assets/samples/01-ben2-full.png
ADDED
|
Git LFS Details
|
assets/samples/01-ben2-mini.png
ADDED
|
Git LFS Details
|
assets/samples/01-birefnet-massive-crop.png
ADDED
|
Git LFS Details
|
assets/samples/01-birefnet-massive-full.png
ADDED
|
Git LFS Details
|
assets/samples/01-birefnet-massive-mini.png
ADDED
|
Git LFS Details
|
assets/samples/01-bria-crop.png
ADDED
|
Git LFS Details
|
assets/samples/01-bria-full.png
ADDED
|
Git LFS Details
|
assets/samples/01-bria-mini.png
ADDED
|
Git LFS Details
|
assets/samples/01-finegrain-crop.png
ADDED
|
Git LFS Details
|
assets/samples/01-finegrain-full.png
ADDED
|
Git LFS Details
|
assets/samples/01-finegrain-mini.png
ADDED
|
Git LFS Details
|
assets/samples/01-orig-crop.png
ADDED
|
Git LFS Details
|
assets/samples/01-orig-full.png
ADDED
|
Git LFS Details
|
assets/samples/01-orig-mini.png
ADDED
|
Git LFS Details
|
assets/samples/02-ben2-crop.png
ADDED
|
Git LFS Details
|
assets/samples/02-ben2-full.png
ADDED
|
Git LFS Details
|
assets/samples/02-ben2-mini.png
ADDED
|
Git LFS Details
|
assets/samples/02-birefnet-massive-crop.png
ADDED
|
Git LFS Details
|
assets/samples/02-birefnet-massive-full.png
ADDED
|
Git LFS Details
|
assets/samples/02-birefnet-massive-mini.png
ADDED
|
Git LFS Details
|
assets/samples/02-bria-crop.png
ADDED
|
Git LFS Details
|
assets/samples/02-bria-full.png
ADDED
|
Git LFS Details
|
assets/samples/02-bria-mini.png
ADDED
|
Git LFS Details
|
assets/samples/02-finegrain-crop.png
ADDED
|
Git LFS Details
|
assets/samples/02-finegrain-full.png
ADDED
|
Git LFS Details
|
assets/samples/02-finegrain-mini.png
ADDED
|
Git LFS Details
|
assets/samples/02-orig-crop.png
ADDED
|
Git LFS Details
|
assets/samples/02-orig-full.png
ADDED
|
Git LFS Details
|
assets/samples/02-orig-mini.png
ADDED
|
Git LFS Details
|
assets/samples/03-ben2-crop.png
ADDED
|
Git LFS Details
|
assets/samples/03-ben2-full.png
ADDED
|
Git LFS Details
|
assets/samples/03-ben2-mini.png
ADDED
|
Git LFS Details
|
assets/samples/03-birefnet-massive-crop.png
ADDED
|
Git LFS Details
|
assets/samples/03-birefnet-massive-full.png
ADDED
|
Git LFS Details
|
assets/samples/03-birefnet-massive-mini.png
ADDED
|
Git LFS Details
|
assets/samples/03-bria-crop.png
ADDED
|
Git LFS Details
|
assets/samples/03-bria-full.png
ADDED
|
Git LFS Details
|
assets/samples/03-bria-mini.png
ADDED
|
Git LFS Details
|
assets/samples/03-finegrain-crop.png
ADDED
|
Git LFS Details
|
assets/samples/03-finegrain-full.png
ADDED
|
Git LFS Details
|
assets/samples/03-finegrain-mini.png
ADDED
|
Git LFS Details
|
assets/samples/03-orig-crop.png
ADDED
|
Git LFS Details
|
assets/samples/03-orig-full.png
ADDED
|
Git LFS Details
|
assets/samples/03-orig-mini.png
ADDED
|
Git LFS Details
|
assets/samples/04-ben2-crop.png
ADDED
|
Git LFS Details
|
assets/samples/04-ben2-full.png
ADDED
|
Git LFS Details
|
assets/samples/04-ben2-mini.png
ADDED
|
Git LFS Details
|