Image Segmentation
BiRefNet
Safetensors
background-removal
mask-generation
Dichotomous Image Segmentation
Camouflaged Object Detection
Salient Object Detection
pytorch_model_hub_mixin
model_hub_mixin
custom_code
Instructions to use ZhengPeng7/BiRefNet_HR with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- BiRefNet
How to use ZhengPeng7/BiRefNet_HR with BiRefNet:
# Option 1: use with transformers from transformers import AutoModelForImageSegmentation birefnet = AutoModelForImageSegmentation.from_pretrained("ZhengPeng7/BiRefNet_HR", 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("ZhengPeng7/BiRefNet_HR") - Notebooks
- Google Colab
- Kaggle
For the compatibility with the latest transformers lib.
Browse files- birefnet.py +5 -0
birefnet.py
CHANGED
|
@@ -7,6 +7,11 @@ from transformers import PretrainedConfig
|
|
| 7 |
|
| 8 |
class Config(PretrainedConfig):
|
| 9 |
def __init__(self) -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
# PATH settings
|
| 11 |
self.sys_home_dir = os.path.expanduser('~') # Make up your file system as: SYS_HOME_DIR/codes/dis/BiRefNet, SYS_HOME_DIR/datasets/dis/xx, SYS_HOME_DIR/weights/xx
|
| 12 |
|
|
|
|
| 7 |
|
| 8 |
class Config(PretrainedConfig):
|
| 9 |
def __init__(self) -> None:
|
| 10 |
+
# Compatible with the latest version of transformers.
|
| 11 |
+
# Error source: https://github.com/huggingface/transformers/commit/9568b506ed511c76ab4d0c6ed591c7fce8e048a5
|
| 12 |
+
# Previous solution in the users' end: https://github.com/ZhengPeng7/BiRefNet/issues/189#issuecomment-2716688688
|
| 13 |
+
super().__init__()
|
| 14 |
+
|
| 15 |
# PATH settings
|
| 16 |
self.sys_home_dir = os.path.expanduser('~') # Make up your file system as: SYS_HOME_DIR/codes/dis/BiRefNet, SYS_HOME_DIR/datasets/dis/xx, SYS_HOME_DIR/weights/xx
|
| 17 |
|