RMBG-2.0 ONNX β€” Fixed

Fixed ONNX exports of briaai/RMBG-2.0. All models work with ONNX Runtime default (ALL) optimizations.

What was fixed

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.

Models

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

Usage

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")

License

CC-BY-NC-4.0 (same as original briaai/RMBG-2.0).

Downloads last month
203
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support