Image Segmentation
Transformers
PyTorch
ONNX
Safetensors
Transformers.js
SegformerForSemanticSegmentation
remove background
background
background-removal
Pytorch
vision
legal liability
custom_code
Instructions to use briaai/RMBG-1.4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use briaai/RMBG-1.4 with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-segmentation", model="briaai/RMBG-1.4", trust_remote_code=True)# Load model directly from transformers import AutoModelForImageSegmentation model = AutoModelForImageSegmentation.from_pretrained("briaai/RMBG-1.4", trust_remote_code=True, device_map="auto") - Transformers.js
How to use briaai/RMBG-1.4 with Transformers.js:
// npm i @huggingface/transformers import { pipeline } from '@huggingface/transformers'; // Allocate pipeline const pipe = await pipeline('image-segmentation', 'briaai/RMBG-1.4'); - Notebooks
- Google Colab
- Kaggle
Update code snippet
#11
by nielsr HF Staff - opened
README.md
CHANGED
|
@@ -107,7 +107,6 @@ import torch, os
|
|
| 107 |
from PIL import Image
|
| 108 |
from briarmbg import BriaRMBG
|
| 109 |
from utilities import preprocess_image, postprocess_image
|
| 110 |
-
from huggingface_hub import hf_hub_download
|
| 111 |
|
| 112 |
im_path = f"{os.path.dirname(os.path.abspath(__file__))}/example_input.jpg"
|
| 113 |
|
|
@@ -115,7 +114,6 @@ net = BriaRMBG()
|
|
| 115 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 116 |
net = BriaRMBG.from_pretrained("briaai/RMBG-1.4")
|
| 117 |
net.to(device)
|
| 118 |
-
net.eval()
|
| 119 |
|
| 120 |
# prepare input
|
| 121 |
model_input_size = [1024,1024]
|
|
|
|
| 107 |
from PIL import Image
|
| 108 |
from briarmbg import BriaRMBG
|
| 109 |
from utilities import preprocess_image, postprocess_image
|
|
|
|
| 110 |
|
| 111 |
im_path = f"{os.path.dirname(os.path.abspath(__file__))}/example_input.jpg"
|
| 112 |
|
|
|
|
| 114 |
device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
|
| 115 |
net = BriaRMBG.from_pretrained("briaai/RMBG-1.4")
|
| 116 |
net.to(device)
|
|
|
|
| 117 |
|
| 118 |
# prepare input
|
| 119 |
model_input_size = [1024,1024]
|