Run this model with HF Jobs

Run ZhengPeng7/BiRefNet-V2-HRSOD on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.

Paste one of these prompts into your coding agent:

Fine-tune on my dataset

Use HF Jobs to fine-tune https://huggingface.co/ZhengPeng7/BiRefNet-V2-HRSOD. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.

Run batch inference

Use HF Jobs to run batch inference with https://huggingface.co/ZhengPeng7/BiRefNet-V2-HRSOD on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.

BiRefNet-V2-HRSOD

BiRefNet-V2 with a DINOv3-L backbone for high-resolution salient object detection (HRSOD), trained on DUTS-TR, HRSOD-TR, UHRSD-TR. It is one of the checkpoints of the paper "BiRefNet-V2: Rethinking Bilateral Reference for High-Resolution Dichotomous Image Segmentation" (arXiv:2611.11272).

Code, the other checkpoints and the full result tables: https://github.com/ZhengPeng7/BiRefNet-V2

Results

Results of these weights on the test sets of the task, copied from the evaluation logs released with the checkpoint (row sota_hrsod_canonical_dhu_1--epoch_16). Higher is better except for MAE.

Test set S-measure max F mean E MAE
DAVIS-S .979 .984 .993 .00396
TE-HRSOD .968 .969 .980 .010
TE-UHRSD .960 .967 .973 .015
TE-DUTS .950 .949 .969 .016
DUT-OMRON .895 .864 .916 .035

The test sets:

Test set Images Description Paper License of the data
DAVIS-S 92 Images suitable for saliency detection (1920 x 1080), collected from the video segmentation dataset DAVIS. ICCV 2019 Not stated; its source, DAVIS, is CC BY-NC 4.0
TE-HRSOD 400 Test set of HRSOD, high-resolution images for salient object detection collected from Flickr. ICCV 2019 Not stated
TE-UHRSD 988 Test set of UHRSD, images in 4K (3840 x 2160) or higher resolution for salient object detection. CVPR 2022 Not stated for the data; the code repository is MIT
TE-DUTS 5,019 Test set of DUTS, collected from the ImageNet DET test set and the SUN data set. CVPR 2017 Not stated; annotations: all rights reserved
DUT-OMRON 5,168 Natural images with one or more salient objects and relatively complex backgrounds. CVPR 2013 Not stated; annotations: all rights reserved

License of the data is what the authors of a dataset state for its data, with a link to their statement, or to the official page where they state none.

Training

Trained on DUTS-TR, HRSOD-TR, UHRSD-TR for 20 epochs, the schedule of scripts/train.sh of the code repository for this task; these are the weights saved at epoch 16. The training sets, 17,095 images in total:

Training set Images Description Paper License of the data
DUTS-TR 10,553 Training set of DUTS, collected from the ImageNet DET training and validation sets. CVPR 2017 Not stated; annotations: all rights reserved
HRSOD-TR 1,610 Training set of HRSOD, high-resolution images for salient object detection collected from Flickr. ICCV 2019 Not stated
UHRSD-TR 4,932 Training set of UHRSD, images in 4K (3840 x 2160) or higher resolution for salient object detection. CVPR 2022 Not stated for the data; the code repository is MIT

How to use

from transformers import AutoModelForImageSegmentation
model = AutoModelForImageSegmentation.from_pretrained('ZhengPeng7/BiRefNet-V2-HRSOD', trust_remote_code=True)

model.safetensors holds the whole model, backbone and decoder, so nothing else is downloaded and the model then works offline. Packages needed: torch, torchvision, timm (1.0.23 or newer), transformers and einops; for the full environment, see the GitHub repository. requirements.txt pins the versions this repository was verified with (torch==2.14.1, torchvision==0.29.1, timm==1.0.30, transformers==5.14.1, einops==0.8.2); it is a reference, and only Hugging Face Inference Endpoints installs it automatically.

A complete example on one image:

import torch
from PIL import Image
from torchvision import transforms
from transformers import AutoModelForImageSegmentation

model = AutoModelForImageSegmentation.from_pretrained('ZhengPeng7/BiRefNet-V2-HRSOD', trust_remote_code=True)
model.to('cuda').eval()

image = Image.open('your_image.jpg').convert('RGB')
transform = transforms.Compose([
    transforms.Resize(model.config.size[::-1]),   # model.config.size is (W, H): 1024x1024
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])
inputs = transform(image).unsqueeze(0).to('cuda')

with torch.no_grad():
    pred = model(inputs)[-1].sigmoid()   # 1 x 1 x H x W, values in [0, 1]

mask = transforms.functional.to_pil_image(pred[0].cpu()).resize(image.size)
mask.save('your_image_mask.png')
image.putalpha(mask)
image.save('your_image_foreground.png')

On a GPU the model runs under bfloat16 autocast by itself, the precision it was trained and evaluated in, so nothing has to be added around it. Keep the model and its input in float32, as loaded: model.half() is refused, since float16 gives NaN outputs.

The model works at model.config.size and resizes its input to that size internally. To run it at another resolution, set both sizes before the forward pass, each side a multiple of 32:

model.config.size = model.config.ir_size = [2048, 2048]   # (W, H)

Files

File Content
model.safetensors the weights of the whole model, backbone and decoder: the tensors of the released checkpoint BiRefNet-V2-HRSOD_DHU-epoch_16.pth, unchanged (bf16)
config.json the architecture settings of this checkpoint
configuration_birefnet_v2.py, modeling_birefnet_v2.py, blocks_birefnet_v2.py the model code that trust_remote_code=True loads: the inference part of the code repository
handler.py, requirements.txt custom handler for Hugging Face Inference Endpoints, and the packages it and the model code need
LICENSE-DINOv3.md the DINOv3 License, which the use of these weights must also follow

The checkpoint file itself, the prediction maps of this checkpoint on every test set, its evaluation logs and its training log are in the Google Drive folder of BiRefNet-V2; the checkpoint file is also attached to the weights release of the code repository.

License

Everything we release for BiRefNet-V2 -- the code, the models and the weights -- is under the MIT License. Since BiRefNet-V2 uses the DINOv3 weights for its backbone, the use of the weights in this repository must also follow the DINOv3 License (LICENSE-DINOv3.md).

Citation

@article{zheng2026birefnetv2,
  title={BiRefNet-V2: Rethinking Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
  author={Zheng, Peng and Fan, Deng-Ping and Wang, Binglu and Sebe, Nicu},
  journal={arXiv preprint arXiv:2611.11272},
  year={2026}
}

@article{zheng2024birefnet,
  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},
  volume={3},
  pages={9150038},
  year={2024}
}
Downloads last month
-
Safetensors
Model size
0.3B params
Tensor type
BF16
Β·
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for ZhengPeng7/BiRefNet-V2-HRSOD

Finetuned
(17)
this model

Space using ZhengPeng7/BiRefNet-V2-HRSOD 1

Collection including ZhengPeng7/BiRefNet-V2-HRSOD

Papers for ZhengPeng7/BiRefNet-V2-HRSOD

Evaluation results