ONNX Model Zoo

onnx-community/BiRefNet-DIS5K-ONNX

By onnx-community · ↓ 4 · ♥ 0 · Updated 2025-03-07

What's in this repo

This page lists the files in onnx-community/BiRefNet-DIS5K-ONNX, including model.onnx, model_fp16.onnx.

  • 2 ONNX models (.onnx files)
  • 6 files, including 2 .json, 2 .onnx, 1 .md
  • Last updated 2025-03-07

ONNX files

File Size Download
onnx/model.onnx — Download
onnx/model_fp16.onnx — Download

How to use

These ONNX files can be loaded with ONNX Runtime. To inspect a model graph, upload the file to the Netron viewer. Download links point to the original files on Hugging Face.

README

Bilateral Reference for High-Resolution Dichotomous Image Segmentation

[Peng Zheng](https://scholar.google.com/citations?user=TZRzWOsAAAAJ) 1,4,5,6, 
[Dehong Gao](https://scholar.google.com/citations?user=0uPb8MMAAAAJ) 2, 
[Deng-Ping Fan](https://scholar.google.com/citations?user=kakwJ5QAAAAJ) 1*, 
[Li Liu](https://scholar.google.com/citations?user=9cMQrVsAAAAJ) 3, 
[Jorma Laaksonen](https://scholar.google.com/citations?user=qQP6WXIAAAAJ) 4, 
[Wanli Ouyang](https://scholar.google.com/citations?user=pw_0Z_UAAAAJ) 5, 
[Nicu Sebe](https://scholar.google.com/citations?user=stFCYOAAAAAJ) 6

1 Nankai University   2 Northwestern Polytechnical University   3 National University of Defense Technology  4 Aalto University   5 Shanghai AI Laboratory   6 University of Trento  
DIS-Sample_1 DIS-Sample_2

For more information, check out the official repository.

Usage (Transformers.js)

If you haven't already, you can install the Transformers.js JavaScript library from NPM using:

npm i @huggingface/transformers

You can then use the model for image matting, as follows:

import { AutoModel, AutoProcessor, RawImage } from '@huggingface/transformers';

// Load model and processor
const model_id = 'onnx-community/BiRefNet-DIS5K-ONNX';
const model = await AutoModel.from_pretrained(model_id, { dtype: 'fp32' });
const processor = await AutoProcessor.from_pretrained(model_id);

// Load image from URL
const url = 'https://images.pexels.com/photos/5965592/pexels-photo-5965592.jpeg?auto=compress&cs=tinysrgb&w=1024';
const image = await RawImage.fromURL(url);

// Pre-process image
const { pixel_values } = await processor(image);

// Predict alpha matte
const { output_image } = await model({ input_image: pixel_values });

// Save output mask
const mask = await RawImage.fromTensor(output_image[0].sigmoid().mul(255).to('uint8')).resize(image.width, image.height);
mask.save('mask.png');
Input image Output mask
image/png image/png

Citation

@article{BiRefNet,
  title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
  author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
  journal={CAAI Artificial Intelligence Research},
  year={2024}
}

Note: Having a separate repo for ONNX weights is intended to be a temporary solution until WebML gains more traction. If you would like to make your models web-ready, we recommend converting to ONNX using 🤗 Optimum and structuring your repo like this one (with ONNX weights located in a subfolder named onnx).

Model info

image-segmentation transformers.js
transformers.js onnx birefnet background-removal mask-generation Dichotomous Image Segmentation Camouflaged Object Detection Salient Object Detection image-segmentation base_model:ZhengPeng7/BiRefNet-DIS5K base_model:quantized:ZhengPeng7/BiRefNet-DIS5K license:mit
↓ 4 ♥ 0

Created: 2024-08-19

Updated: 2025-03-07

View on Hugging Face

Files (6)

.gitattributes
README.md
config.json
onnx/model.onnx ONNX
onnx/model_fp16.onnx ONNX
preprocessor_config.json

Related models