Image Segmentation
BiRefNet
Safetensors
Transformers
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_dynamic with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- BiRefNet
How to use ZhengPeng7/BiRefNet_dynamic with BiRefNet:
# Option 1: use with transformers from transformers import AutoModelForImageSegmentation birefnet = AutoModelForImageSegmentation.from_pretrained("ZhengPeng7/BiRefNet_dynamic", 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_dynamic") - Transformers
How to use ZhengPeng7/BiRefNet_dynamic with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="ZhengPeng7/BiRefNet_dynamic", trust_remote_code=True)# Load model directly from transformers import AutoModelForImageSegmentation model = AutoModelForImageSegmentation.from_pretrained("ZhengPeng7/BiRefNet_dynamic", trust_remote_code=True, dtype="auto") - Notebooks
- Google Colab
- Kaggle
Commit ·
2803060
1
Parent(s): ce51266
Fix the no attribute 'all_tied_weights_keys' issue in transformers==5.0.0.
Browse files- birefnet.py +2 -0
birefnet.py
CHANGED
|
@@ -2038,6 +2038,8 @@ class BiRefNet(
|
|
| 2038 |
if 'bb.' in key and 'refiner.' not in key:
|
| 2039 |
value.requires_grad = False
|
| 2040 |
|
|
|
|
|
|
|
| 2041 |
def forward_enc(self, x):
|
| 2042 |
if self.config.bb in ['vgg16', 'vgg16bn', 'resnet50']:
|
| 2043 |
x1 = self.bb.conv1(x); x2 = self.bb.conv2(x1); x3 = self.bb.conv3(x2); x4 = self.bb.conv4(x3)
|
|
|
|
| 2038 |
if 'bb.' in key and 'refiner.' not in key:
|
| 2039 |
value.requires_grad = False
|
| 2040 |
|
| 2041 |
+
self.post_init()
|
| 2042 |
+
|
| 2043 |
def forward_enc(self, x):
|
| 2044 |
if self.config.bb in ['vgg16', 'vgg16bn', 'resnet50']:
|
| 2045 |
x1 = self.bb.conv1(x); x2 = self.bb.conv2(x1); x3 = self.bb.conv3(x2); x4 = self.bb.conv4(x3)
|