Image Segmentation
BEN2
ONNX
Safetensors
PyTorch
BEN2
background-remove
mask-generation
Dichotomous image segmentation
background remove
foreground
background
remove background
model_hub_mixin
pytorch_model_hub_mixin
background removal
background-removal
Instructions to use RedbeardNZ/BEN2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- BEN2
How to use RedbeardNZ/BEN2 with BEN2:
import requests from PIL import Image from ben2 import AutoModel url = "https://huggingface.co/datasets/mishig/sample_images/resolve/main/teapot.jpg" image = Image.open(requests.get(url, stream=True).raw) model = AutoModel.from_pretrained("RedbeardNZ/BEN2") model.to("cuda").eval() foreground = model.inference(image) - Notebooks
- Google Colab
- Kaggle
| import BEN2 | |
| from PIL import Image | |
| import torch | |
| device = torch.device('cuda' if torch.cuda.is_available() else 'cpu') | |
| file = "./image.png" # input image | |
| model = BEN2.BEN_Base().to(device).eval() #init pipeline | |
| model.loadcheckpoints("./BEN2_Base.pth") | |
| image = Image.open(file) | |
| foreground = model.inference(image) | |
| foreground.save("./foreground.png") | |