Image Segmentation
Transformers
PyTorch
ONNX
Safetensors
Transformers.js
remove background
background
background-removal
Pytorch
vision
legal liability
custom_code
Instructions to use UrNinja/RMBG-2.0 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use UrNinja/RMBG-2.0 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="UrNinja/RMBG-2.0", trust_remote_code=True)# pip install -U transformers accelerate # Load model directly from transformers import AutoModelForImageSegmentation model = AutoModelForImageSegmentation.from_pretrained("UrNinja/RMBG-2.0", trust_remote_code=True, device_map="auto") - Transformers.js
How to use UrNinja/RMBG-2.0 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-segmentation', 'UrNinja/RMBG-2.0'); - Notebooks
- Google Colab
- Kaggle
Download BiRefNet_config.py from UrNinja/RMBG-2.0: direct link, hf CLI and curl.
- Browser
- Download file 298 Bytes
-
https://huggingface.co/UrNinja/RMBG-2.0/resolve/main/BiRefNet_config.py
- Command line
-
hf download hf://UrNinja/RMBG-2.0/BiRefNet_config.py
-
curl -L -o BiRefNet_config.py https://huggingface.co/UrNinja/RMBG-2.0/resolve/main/BiRefNet_config.py
298 Bytes
| from transformers import PretrainedConfig | |
| class BiRefNetConfig(PretrainedConfig): | |
| model_type = "SegformerForSemanticSegmentation" | |
| def __init__( | |
| self, | |
| bb_pretrained=False, | |
| **kwargs | |
| ): | |
| self.bb_pretrained = bb_pretrained | |
| super().__init__(**kwargs) | |