From: ZhengPeng7 <huggingface.co/ZhengPeng7>Newsgroups: alt.freeweights.visionSubject:

BiRefNet_HR

Date: 2026-11-15Commit: a7a562fSigned: 2DC28CC7B26A283B ✓

Image segmentation model with 221M parameters. Safetensors weights, 445 MB in all. Published by ZhengPeng7 under MIT.

221M params445MBBiRefNet_HRsafetensorspermissive
FactsParams221MSize445 MBFormatssafetensorsTaskimage segmentationLicenseMITFrom sourcepermissive
$ fw get ZhengPeng7/BiRefNet_HR
# manifest sha256 7a2db2e6a5dd… · 445 MB · 8 files
$ fw verify ./BiRefNet_HR ZhengPeng7/BiRefNet_HR
From sourceHosted (signed)ZhengPeng7/BiRefNet_HRLast check: 2026-11-15 02:33 UTC

Get help: custom fine-tune or private deploy. We review your setup before we quote.

Works with

Runs with

Ranked by fit to this model (safetensors), then by GitHub stars.

Overview

Size
445 MB
Weights
444 MB (safetensors)
Parameters
221M
Formats
safetensors
Task
image segmentation
License
MIT (permissive)
Files
8, each with a sha256
Publisher
ZhengPeng7
Added
2026-11-15
Section
alt.freeweights.vision
Lineage

Original release from the publisher.

Where these bytes come from
Publisher at the pinned commit→You

Sources are tried in order. A file counts only when its size and sha256 match the manifest. Sources are checked when you ask for them, not on a timer.

Sources
BadgeHostLast checkResult
From sourcehuggingface.co2026-11-15 02:33 UTCpassed

Model card

From the publisher at commit a7a562f. Shown as plain text with links; images open at the publisher.

This BiRefNet was trained with images in 2048x2048 for higher resolution inference.

Performance:#

All tested in FP16 mode.

DatasetMethodResolutionmaxFmwFmeasureMAESmeasuremeanEmHCEmaxEmmeanFmadpEmadpFmmBAmaxBIoUmeanBIoU
DIS-VDBiRefNet_HR-general-epoch_1302048x2048.925.894.026.927.952811.960.909.944.888.828.837.817
DIS-VDBiRefNet_HR-general-epoch_1301024x1024.876.840.041.893.9131348.926.860.930.857.765.769.742
DIS-VDBiRefNet-general-epoch_2442048x2048.888.858.037.898.934811.941.878.927.862.802.790.776
DIS-VDBiRefNet-general-epoch_2441024x1024.908.877.034.912.9431128.953.894.944.881.796.812.789

Bilateral Reference for High-Resolution Dichotomous Image Segmentation#

Peng Zheng 1,4,5,6,&thinsp; Dehong Gao 2,&thinsp; Deng-Ping Fan 1*,&thinsp; Li Liu 3,&thinsp; Jorma Laaksonen 4,&thinsp; Wanli Ouyang 5,&thinsp; Nicu Sebe 6

1 Nankai University&ensp; 2 Northwestern Polytechnical University&ensp; 3 National University of Defense Technology&ensp; 4 Aalto University&ensp; 5 Shanghai AI Laboratory&ensp; 6 University of Trento&ensp;

https://www.sciopen.com/article/pdf/10.26599/AIR.2024.9150038.pdf&ensp; https://arxiv.org/pdf/2401.03407&ensp; https://drive.google.com/file/d/1aBnJ_R9lbnC2dm8dqD0-pzP2Cu-U1Xpt/view?usp=drive_link&ensp; https://www.birefnet.top&ensp; https://drive.google.com/drive/folders/1s2Xe0cjq-2ctnJBR24563yMSCOu4CcxM&ensp; LICENSE&ensp; https://huggingface.co/spaces/ZhengPeng7/BiRefNet_demo&ensp; https://huggingface.co/ZhengPeng7/BiRefNet&ensp; https://colab.research.google.com/drive/14Dqg7oeBkFEtchaHLNpig2BcdkZEogba?usp=drive_link&ensp; https://colab.research.google.com/drive/1MaEiBfJ4xIaZZn0DqKrhydHB8X97hNXl#scrollTo=DJ4meUYjia6S&ensp;

DIS-Sample_1DIS-Sample_2
Image: imageImage: image

This repo is the official implementation of "Bilateral Reference for High-Resolution Dichotomous Image Segmentation" (___CAAI AIR 2024___).

Visit our GitHub repo: https://github.com/ZhengPeng7/BiRefNet for more details -- codes, docs, and model zoo!

How to use#

0. Install Packages:#
pip install -qr https://raw.githubusercontent.com/ZhengPeng7/BiRefNet/main/requirements.txt
1. Load BiRefNet:#
Use codes + weights from HuggingFace#

Only use the weights on HuggingFace -- Pro: No need to download BiRefNet codes manually; Con: Codes on HuggingFace might not be latest version (I'll try to keep them always latest).

# Load BiRefNet with weights
from transformers import AutoModelForImageSegmentation
birefnet = AutoModelForImageSegmentation.from_pretrained('ZhengPeng7/BiRefNet_HR', trust_remote_code=True)
Use codes from GitHub + weights from HuggingFace#

Only use the weights on HuggingFace -- Pro: codes are always latest; Con: Need to clone the BiRefNet repo from my GitHub.

# Download codes
git clone https://github.com/ZhengPeng7/BiRefNet.git
cd BiRefNet
# Use codes locally
from models.birefnet import BiRefNet

# Load weights from Hugging Face Models
birefnet = BiRefNet.from_pretrained('ZhengPeng7/BiRefNet_HR')
Use codes from GitHub + weights from local space#

Only use the weights and codes both locally.

# Use codes and weights locally
import torch
from utils import check_state_dict

birefnet = BiRefNet(bb_pretrained=False)
state_dict = torch.load(PATH_TO_WEIGHT, map_location='cpu')
state_dict = check_state_dict(state_dict)
birefnet.load_state_dict(state_dict)
Use the loaded BiRefNet for inference#
# Imports
from PIL import Image
import matplotlib.pyplot as plt
import torch
from torchvision import transforms
from models.birefnet import BiRefNet

birefnet = ... # -- BiRefNet should be loaded with codes above, either way.
torch.set_float32_matmul_precision(['high', 'highest'][0])
birefnet.to('cuda')
birefnet.eval()
birefnet.half()

def extract_object(birefnet, imagepath):
    # Data settings
    image_size = (2048, 2048)
    transform_image = transforms.Compose([
        transforms.Resize(image_size),
        transforms.ToTensor(),
        transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
    ])

    image = Image.open(imagepath)
    input_images = transform_image(image).unsqueeze(0).to('cuda').half()

    # Prediction
    with torch.no_grad():
        preds = birefnet(input_images)[-1].sigmoid().cpu()
    pred = preds[0].squeeze()
    pred_pil = transforms.ToPILImage()(pred)
    mask = pred_pil.resize(image.size)
    image.putalpha(mask)
    return image, mask

# Visualization
plt.axis("off")
plt.imshow(extract_object(birefnet, imagepath='PATH-TO-YOUR_IMAGE.jpg')[0])
plt.show()
2. Use inference endpoint locally:#

You may need to click the deploy and set up the endpoint by yourself, which would make some costs.

import requests
import base64
from io import BytesIO
from PIL import Image


YOUR_HF_TOKEN = 'xxx'
API_URL = "xxx"
headers = {
	"Authorization": "Bearer {}".format(YOUR_HF_TOKEN)
}

def base64_to_bytes(base64_string):
    # Remove the data URI prefix if present
    if "data:image" in base64_string:
        base64_string = base64_string.split(",")[1]

    # Decode the Base64 string into bytes
    image_bytes = base64.b64decode(base64_string)
    return image_bytes

def bytes_to_base64(image_bytes):
    # Create a BytesIO object to handle the image data
    image_stream = BytesIO(image_bytes)

    # Open the image using Pillow (PIL)
    image = Image.open(image_stream)
    return image

def query(payload):
	response = requests.post(API_URL, headers=headers, json=payload)
	return response.json()

output = query({
	"inputs": "https://hips.hearstapps.com/hmg-prod/images/gettyimages-1229892983-square.jpg",
	"parameters": {}
})

output_image = bytes_to_base64(base64_to_bytes(output))
output_image

This BiRefNet for standard dichotomous image segmentation (DIS) is trained on DIS-TR and validated on DIS-TEs and DIS-VD.

This repo holds the official model weights of "Bilateral Reference for High-Resolution Dichotomous Image Segmentation" (CAAI AIR 2024).#

This repo contains the weights of BiRefNet proposed in our paper, which has achieved the SOTA performance on three tasks (DIS, HRSOD, and COD).

Go to my GitHub page for BiRefNet codes and the latest updates: https://github.com/ZhengPeng7/BiRefNet :)

Try our online demos for inference:#

Image: image

Acknowledgement:#

  • Many thanks to @freepik for their generous support on GPU resources for training this model!

Citation#

@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}
}

Files

8 files · 445 MBWeights 444 MB (safetensors). Sizes and sha256 from the signed manifest.
Hide all 8 files with their sha256
FileSizesha256
.gitattributes1.52 KB11ad7efa24975ee4b0c3c3a38ed18737f0658a5f75a0a96787b576a78a023361
BiRefNet_config.py298 Be7b8c2a74f6cea6a59553d517f71d47f2c1d90e670a13416af17c25fe2f3dc52
README.md11.0 KB63502855ce590d269b9458a2b66151580de8216208d686effc735792a8d922f9
birefnet.py92.1 KB2a45b4e0ece72d7c4212bca1a988e7d7e52bfe9f98ec59c58b8809c8a8b7a831
config.json408 B9afedeafb3250180fb7f74a7c7b179e192b20927feedcb10761f26568a86ce4a
handler.py4.71 KBc06a4da84ea747d5c38aee5076bcda7c83cb1402daa7bffb537a6fb1435aa4e3
model.safetensors444 MB9d678bafec0b0019fbb073b7fd02f05ede25dc4b15254f23b2fb0be333200c0d
requirements.txt149 Bbdfdd83a090d31a2acf64f7350653fa63cd8b5d9d6e0ff3e135bea7ce3786341
VersionsEach time the pinned upstream commit or file list changed in this repo. Newest first.
Upstream commitDateContents
a7a562f6fd pinned now2026-11-15 02:33 UTC8 files · 445 MB

Use it

$ fw get ZhengPeng7/BiRefNet_HR
# manifest sha256 7a2db2e6a5dd… · 445 MB · 8 files
$ fw verify ./BiRefNet_HR ZhengPeng7/BiRefNet_HR
fw.pyChecks the signature and every sha256, tries each source in order, resumes.
$ python3 fw.py get https://freeweights.allternit.com/manifests/ZhengPeng7/BiRefNet_HR.json --dir ./BiRefNet_HR $ python3 fw.py verify ./BiRefNet_HR ./ZhengPeng7__BiRefNet_HR.json
hfThe Hugging Face CLI with one setting. Same repo id.
$ HF_ENDPOINT=https://freeweights.allternit.com hf download ZhengPeng7/BiRefNet_HR --revision a7a562f6fd16021180f2f4348f4de003a2d3d1e1 --local-dir ./BiRefNet_HR

License

Name
MIT License
Id
MIT
Class
Permissive
Redistribution
yes
Listing
Hosted (signed)
Decided
License as declared by the publisher. No person read it. 2026-11-15
Text in
README.md
Text sha256
63502855ce590d269b9458a2b66151580de8216208d686effc735792a8d922f9
Terms gate
No extra terms beyond the license.

Read the license text

Licenses are checked against the license table. A custom license passes only after a person reads it.

Provenance

From: ZhengPeng7 <huggingface.co/ZhengPeng7>Newsgroups: alt.freeweights.visionSubject: BiRefNet_HRDate: 2026-11-15Commit: a7a562fSigned: 2DC28CC7B26A283B ✓
Upstream
ZhengPeng7/BiRefNet_HR
Pinned commit
a7a562f6fd16021180f2f4348f4de003a2d3d1e1
Manifest
BiRefNet_HR.json · .minisig
Manifest sha256
7a2db2e6a5ddb3efa1aac3ffc6ead24577315b43dfc337ff3fe40b119f1fd401
Signature
minisign, Ed25519, key 2DC28CC7B26A283B
Created
2026-11-15 02:33 UTC
Generator
freeweights-manifest/0.1.0
Takedowns
None.

How to verify

$ curl -O https://freeweights.allternit.com/manifests/ZhengPeng7/BiRefNet_HR.json $ curl -O https://freeweights.allternit.com/manifests/ZhengPeng7/BiRefNet_HR.json.minisig $ minisign -Vm BiRefNet_HR.json -P RWQ7KGqyx4zCLXtUFOqvfv8L3g+8fpKJ1FsuxPyOYMF+4KufbUxKq1Oq $ shasum -a 256 <file> # compare with the Files tab

A manifest whose signature fails must be rejected. A file whose size or sha256 does not match must be discarded. Verify a download

Model tree

1 model in the catalog name this one as their parent.

Fine-tunes
1
Fine-tunes 1
Get it
Download
$ HF_ENDPOINT=https://freeweights.allternit.com hf download ZhengPeng7/BiRefNet_HR
Open in Freeweights Studio

Pull, verify and run it in the Allternit app on Desktop, web or phone.

Signed manifest
minisign, key 2DC28CC7B26A283B. BiRefNet_HR.json. Provenance. Takedown history: none.
From: dima806 <huggingface.co/dima806>Subject: ai_vs_real_image_detection
From: legekka <huggingface.co/legekka>Subject: AI-Anime-Image-Detector-ViT
From: onnx-community <huggingface.co/onnx-community>Subject: AI-Anime-Image-Detector-ViT-ONNX
From: AICodexLab <huggingface.co/AICodexLab>Subject: answerdotai-ModernBERT-base-ai-detector
From: onnx-community <huggingface.co/onnx-community>Subject: answerdotai-ModernBERT-base-ai-detector-ONNX
From: onnx-community <huggingface.co/onnx-community>Subject: bart-large-cnn-ONNX