Instructions to use nobg/BiRefNet-Finetuned with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- nobg
How to use nobg/BiRefNet-Finetuned with nobg:
pip install nobg
import torch from loadimg import load_img from nobg import AutoModel, AutoProcessor model = AutoModel.from_pretrained("nobg/BiRefNet-Finetuned").eval() processor = AutoProcessor.from_pretrained("nobg/BiRefNet-Finetuned") image = load_img("input.jpg").convert("RGB") inputs = processor(image, return_tensors="pt") with torch.no_grad(): outputs = model(pixel_values=inputs["pixel_values"]) alpha = processor.post_process_alpha_matting(outputs, target_sizes=[(image.height, image.width)])[0] processor.cutout(image, alpha).save("output.png") - BiRefNet
How to use nobg/BiRefNet-Finetuned with BiRefNet:
# Option 1: use with transformers from transformers import AutoModelForImageSegmentation birefnet = AutoModelForImageSegmentation.from_pretrained("nobg/BiRefNet-Finetuned", trust_remote_code=True)# Option 2: use with BiRefNet # Install from https://github.com/ZhengPeng7/BiRefNet from models.birefnet import BiRefNet model = BiRefNet.from_pretrained("nobg/BiRefNet-Finetuned") - Notebooks
- Google Colab
- Kaggle
Remap weights to refactored transformers SwinBackbone layout (nobg 0.2.0); weights unchanged
Browse files- README.md +14 -0
- config.json +2 -0
- model.safetensors +2 -2
README.md
CHANGED
|
@@ -31,5 +31,19 @@ from nobg import BiRefNet
|
|
| 31 |
model = BiRefNet.from_pretrained("nobg/BiRefNet-Finetuned")
|
| 32 |
```
|
| 33 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
## Contributions
|
| 35 |
Any contributions are welcome at https://github.com/feyninc/nobg
|
|
|
|
| 31 |
model = BiRefNet.from_pretrained("nobg/BiRefNet-Finetuned")
|
| 32 |
```
|
| 33 |
|
| 34 |
+
|
| 35 |
+
## Citation
|
| 36 |
+
If you use this model, please cite the original paper
|
| 37 |
+
(https://arxiv.org/abs/2401.03407):
|
| 38 |
+
```bibtex
|
| 39 |
+
@article{zheng2024birefnet,
|
| 40 |
+
title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
|
| 41 |
+
author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and
|
| 42 |
+
Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
|
| 43 |
+
journal={CAAI Artificial Intelligence Research},
|
| 44 |
+
year={2024}
|
| 45 |
+
}
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
## Contributions
|
| 49 |
Any contributions are welcome at https://github.com/feyninc/nobg
|
config.json
CHANGED
|
@@ -10,12 +10,14 @@
|
|
| 10 |
"embed_dim": 192,
|
| 11 |
"image_size": 1024,
|
| 12 |
"mlp_ratio": 4.0,
|
|
|
|
| 13 |
"num_heads": [
|
| 14 |
6,
|
| 15 |
12,
|
| 16 |
24,
|
| 17 |
48
|
| 18 |
],
|
|
|
|
| 19 |
"patch_size": 4,
|
| 20 |
"use_gradient_attention": true,
|
| 21 |
"use_image_patch_injection": true,
|
|
|
|
| 10 |
"embed_dim": 192,
|
| 11 |
"image_size": 1024,
|
| 12 |
"mlp_ratio": 4.0,
|
| 13 |
+
"nobg_version": "0.2.0",
|
| 14 |
"num_heads": [
|
| 15 |
6,
|
| 16 |
12,
|
| 17 |
24,
|
| 18 |
48
|
| 19 |
],
|
| 20 |
+
"num_layers": 4,
|
| 21 |
"patch_size": 4,
|
| 22 |
"use_gradient_attention": true,
|
| 23 |
"use_image_patch_injection": true,
|
model.safetensors
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ea77387d72ce19029a3fb808a6d05b86fe05d849c066c68b68fe97b3773cf74e
|
| 3 |
+
size 880926192
|