Commit
·
ea43110
1
Parent(s):
16e8da8
Improve the README.
Browse files
README.md
CHANGED
|
@@ -8,7 +8,7 @@ tags:
|
|
| 8 |
- Salient Object Detection
|
| 9 |
- pytorch_model_hub_mixin
|
| 10 |
- model_hub_mixin
|
| 11 |
-
repo_url: https://github.com/ZhengPeng7/BiRefNet
|
| 12 |
pipeline_tag: image-segmentation
|
| 13 |
---
|
| 14 |
<h1 align="center">Bilateral Reference for High-Resolution Dichotomous Image Segmentation</h1>
|
|
@@ -44,7 +44,7 @@ pipeline_tag: image-segmentation
|
|
| 44 |
| :------------------------------: | :-------------------------------: |
|
| 45 |
| <img src="https://drive.google.com/thumbnail?id=1ItXaA26iYnE8XQ_GgNLy71MOWePoS2-g&sz=w400" /> | <img src="https://drive.google.com/thumbnail?id=1Z-esCujQF_uEa_YJjkibc3NUrW4aR_d4&sz=w400" /> |
|
| 46 |
|
| 47 |
-
This repo is the official implementation of "[**Bilateral Reference for High-Resolution Dichotomous Image Segmentation**](https://arxiv.org/pdf/2401.03407.pdf)" (
|
| 48 |
|
| 49 |
Visit our GitHub repo: [https://github.com/ZhengPeng7/BiRefNet](https://github.com/ZhengPeng7/BiRefNet) for more details -- **codes**, **docs**, and **model zoo**!
|
| 50 |
|
|
@@ -52,6 +52,15 @@ Visit our GitHub repo: [https://github.com/ZhengPeng7/BiRefNet](https://github.c
|
|
| 52 |
|
| 53 |
### 1. Load BiRefNet:
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
#### Use codes from GitHub + weights from HuggingFace
|
| 56 |
> Only use the weights on HuggingFace -- Pro: codes are always latest; Con: Need to clone the BiRefNet repo from my GitHub.
|
| 57 |
|
|
@@ -62,18 +71,25 @@ cd BiRefNet
|
|
| 62 |
```
|
| 63 |
|
| 64 |
```python
|
| 65 |
-
#
|
| 66 |
from models.birefnet import BiRefNet
|
|
|
|
|
|
|
| 67 |
birefnet = BiRefNet.from_pretrained('zhengpeng7/birefnet-portrait')
|
| 68 |
```
|
| 69 |
|
| 70 |
-
#### Use codes + weights from HuggingFace
|
| 71 |
-
> Only use the weights
|
| 72 |
|
| 73 |
```python
|
| 74 |
-
#
|
| 75 |
-
|
| 76 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
```
|
| 78 |
|
| 79 |
#### Use the loaded BiRefNet for inference
|
|
@@ -121,7 +137,7 @@ plt.show()
|
|
| 121 |
|
| 122 |
> This BiRefNet for standard dichotomous image segmentation (DIS) is trained on **DIS-TR** and validated on **DIS-TEs and DIS-VD**.
|
| 123 |
|
| 124 |
-
## This repo holds the official model weights of "[<ins>Bilateral Reference for High-Resolution Dichotomous Image Segmentation</ins>](https://arxiv.org/pdf/2401.03407)" (
|
| 125 |
|
| 126 |
This repo contains the weights of BiRefNet proposed in our paper, which has achieved the SOTA performance on three tasks (DIS, HRSOD, and COD).
|
| 127 |
|
|
@@ -144,10 +160,10 @@ Go to my GitHub page for BiRefNet codes and the latest updates: https://github.c
|
|
| 144 |
## Citation
|
| 145 |
|
| 146 |
```
|
| 147 |
-
@article{
|
| 148 |
title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
|
| 149 |
author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
|
| 150 |
-
journal={
|
| 151 |
year={2024}
|
| 152 |
}
|
| 153 |
```
|
|
|
|
| 8 |
- Salient Object Detection
|
| 9 |
- pytorch_model_hub_mixin
|
| 10 |
- model_hub_mixin
|
| 11 |
+
repo_url: https://github.com/ZhengPeng7/BiRefNet-portrait
|
| 12 |
pipeline_tag: image-segmentation
|
| 13 |
---
|
| 14 |
<h1 align="center">Bilateral Reference for High-Resolution Dichotomous Image Segmentation</h1>
|
|
|
|
| 44 |
| :------------------------------: | :-------------------------------: |
|
| 45 |
| <img src="https://drive.google.com/thumbnail?id=1ItXaA26iYnE8XQ_GgNLy71MOWePoS2-g&sz=w400" /> | <img src="https://drive.google.com/thumbnail?id=1Z-esCujQF_uEa_YJjkibc3NUrW4aR_d4&sz=w400" /> |
|
| 46 |
|
| 47 |
+
This repo is the official implementation of "[**Bilateral Reference for High-Resolution Dichotomous Image Segmentation**](https://arxiv.org/pdf/2401.03407.pdf)" (___CAAI AIR 2024___).
|
| 48 |
|
| 49 |
Visit our GitHub repo: [https://github.com/ZhengPeng7/BiRefNet](https://github.com/ZhengPeng7/BiRefNet) for more details -- **codes**, **docs**, and **model zoo**!
|
| 50 |
|
|
|
|
| 52 |
|
| 53 |
### 1. Load BiRefNet:
|
| 54 |
|
| 55 |
+
#### Use codes + weights from HuggingFace
|
| 56 |
+
> 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).
|
| 57 |
+
|
| 58 |
+
```python
|
| 59 |
+
# Load BiRefNet with weights
|
| 60 |
+
from transformers import AutoModelForImageSegmentation
|
| 61 |
+
birefnet = AutoModelForImageSegmentation.from_pretrained('zhengpeng7/birefnet-portrait', trust_remote_code=True)
|
| 62 |
+
```
|
| 63 |
+
|
| 64 |
#### Use codes from GitHub + weights from HuggingFace
|
| 65 |
> Only use the weights on HuggingFace -- Pro: codes are always latest; Con: Need to clone the BiRefNet repo from my GitHub.
|
| 66 |
|
|
|
|
| 71 |
```
|
| 72 |
|
| 73 |
```python
|
| 74 |
+
# Use codes locally
|
| 75 |
from models.birefnet import BiRefNet
|
| 76 |
+
|
| 77 |
+
# Load weights from Hugging Face Models
|
| 78 |
birefnet = BiRefNet.from_pretrained('zhengpeng7/birefnet-portrait')
|
| 79 |
```
|
| 80 |
|
| 81 |
+
#### Use codes from GitHub + weights from HuggingFace
|
| 82 |
+
> Only use the weights and codes both locally.
|
| 83 |
|
| 84 |
```python
|
| 85 |
+
# Use codes and weights locally
|
| 86 |
+
import torch
|
| 87 |
+
from utils import check_state_dict
|
| 88 |
+
|
| 89 |
+
birefnet = BiRefNet(bb_pretrained=False)
|
| 90 |
+
state_dict = torch.load(PATH_TO_WEIGHT, map_location='cpu')
|
| 91 |
+
state_dict = check_state_dict(state_dict)
|
| 92 |
+
birefnet.load_state_dict(state_dict)
|
| 93 |
```
|
| 94 |
|
| 95 |
#### Use the loaded BiRefNet for inference
|
|
|
|
| 137 |
|
| 138 |
> This BiRefNet for standard dichotomous image segmentation (DIS) is trained on **DIS-TR** and validated on **DIS-TEs and DIS-VD**.
|
| 139 |
|
| 140 |
+
## This repo holds the official model weights of "[<ins>Bilateral Reference for High-Resolution Dichotomous Image Segmentation</ins>](https://arxiv.org/pdf/2401.03407)" (_CAAI AIR 2024_).
|
| 141 |
|
| 142 |
This repo contains the weights of BiRefNet proposed in our paper, which has achieved the SOTA performance on three tasks (DIS, HRSOD, and COD).
|
| 143 |
|
|
|
|
| 160 |
## Citation
|
| 161 |
|
| 162 |
```
|
| 163 |
+
@article{BiRefNet,
|
| 164 |
title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
|
| 165 |
author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
|
| 166 |
+
journal={CAAI Artificial Intelligence Research},
|
| 167 |
year={2024}
|
| 168 |
}
|
| 169 |
```
|