CoolFace
Modelpublic

yamura4/RMBG-2.0-ONNX

sourceHugging Facecc-by-nc-4.0updated 3mo agoView on Hugging Face
0likes46downloads
Model Card

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

IssueFix
config.json missing model_typeAdded "model_type": "birefnet"
BiRefNet_config.py had wrong model_typeChanged "SegformerForSemanticSegmentation" → "birefnet"
model_fp16.onnx crashed on loadRe-exported: all weights stored as fp16, Cast to fp32 before use. Half the file size, full precision compute.

Models

FileSizeTypeOptimizations
onnx/model.onnx977 MBFP32ALL
onnx/model_fp16.onnx490 MBFP16 weights → FP32 computeALL
onnx/model_int8.onnx350 MBINT8 quantizedALL
onnx/model_q4.onnx351 MBQ4 quantizedALL
onnx/model_bnb4.onnx339 MB4-bitALL
onnx/model_quantized.onnx350 MBQuantizedALL
onnx/model_uint8.onnx350 MBUINT8 quantizedALL

Usage

python
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).