Downloads · 30 days
26
31% of all-time downloads
baby2008/RMBG-2.0-ONNX
RMBG-2.0-ONNX is a image segmentation model from baby2008. Use it for the image segmentation task on the model card, and read the license before you ship it in a product. It is set up for onnx. The card lists the license as cc-by-nc-4.0.
Fixed ONNX exports of briaai/RMBG-2.0. All models work with ONNX Runtime default (ALL) optimizations.
Downloads · 30 days
26
31% of all-time downloads
All-time downloads
84
Public
Repo size
9 GB
Likes
1
Public
Click a slice to open those files.
.onnx3.4 GB · 100%
From the Hugging Face model README
Fixed ONNX exports of briaai/RMBG-2.0. All models work with ONNX Runtime default (ALL) optimizations.
| Issue | Fix |
|---|---|
config.json missing model_type | Added "model_type": "birefnet" |
BiRefNet_config.py had wrong model_type | Changed "SegformerForSemanticSegmentation" → "birefnet" |
model_fp16.onnx crashed on load | Re-exported: all weights stored as fp16, Cast to fp32 before use. Half the file size, full precision compute. |
| File | Size | Type | Optimizations |
|---|---|---|---|
onnx/model.onnx | 977 MB | FP32 | ALL |
onnx/model_fp16.onnx | 490 MB | FP16 weights → FP32 compute | ALL |
onnx/model_int8.onnx | 350 MB | INT8 quantized | ALL |
onnx/model_q4.onnx | 351 MB | Q4 quantized | ALL |
onnx/model_bnb4.onnx | 339 MB | 4-bit | ALL |
onnx/model_quantized.onnx | 350 MB | Quantized | ALL |
onnx/model_uint8.onnx | 350 MB | UINT8 quantized | ALL |
import onnxruntime as ort
import numpy as np
from PIL import Image
from torchvision import transforms
sess = ort.InferenceSession("onnx/model_fp16.onnx")
img = Image.open("photo.jpg").convert("RGB")
transform = transforms.Compose([
transforms.Resize((1024, 1024)),
transforms.ToTensor(),
transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
input_tensor = transform(img).unsqueeze(0).numpy().astype(np.float32)
alphas = sess.run(["alphas"], {"pixel_values": input_tensor})[0][0, 0]
mask = (alphas * 255).astype(np.uint8)
Image.fromarray(mask).save("mask.png")
CC-BY-NC-4.0 (same as original briaai/RMBG-2.0).