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
Commit ·
4c63fb6
1
Parent(s): 9faaf0e
Add half precision setting in README.
Browse files
README.md
CHANGED
|
@@ -124,6 +124,7 @@ birefnet = ... # -- BiRefNet should be loaded with codes above, either way.
|
|
| 124 |
torch.set_float32_matmul_precision(['high', 'highest'][0])
|
| 125 |
birefnet.to('cuda')
|
| 126 |
birefnet.eval()
|
|
|
|
| 127 |
|
| 128 |
def extract_object(birefnet, imagepath):
|
| 129 |
# Data settings
|
|
@@ -135,7 +136,7 @@ def extract_object(birefnet, imagepath):
|
|
| 135 |
])
|
| 136 |
|
| 137 |
image = Image.open(imagepath)
|
| 138 |
-
input_images = transform_image(image).unsqueeze(0).to('cuda')
|
| 139 |
|
| 140 |
# Prediction
|
| 141 |
with torch.no_grad():
|
|
|
|
| 124 |
torch.set_float32_matmul_precision(['high', 'highest'][0])
|
| 125 |
birefnet.to('cuda')
|
| 126 |
birefnet.eval()
|
| 127 |
+
birefnet.half()
|
| 128 |
|
| 129 |
def extract_object(birefnet, imagepath):
|
| 130 |
# Data settings
|
|
|
|
| 136 |
])
|
| 137 |
|
| 138 |
image = Image.open(imagepath)
|
| 139 |
+
input_images = transform_image(image).unsqueeze(0).to('cuda').half()
|
| 140 |
|
| 141 |
# Prediction
|
| 142 |
with torch.no_grad():
|