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 PramaLLC/BEN2 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- BEN2
How to use PramaLLC/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("PramaLLC/BEN2") model.to("cuda").eval() foreground = model.inference(image) - Notebooks
- Google Colab
- Kaggle
Update README.md
Browse files
README.md
CHANGED
|
@@ -109,7 +109,7 @@ import torch
|
|
| 109 |
|
| 110 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 111 |
|
| 112 |
-
|
| 113 |
|
| 114 |
model = BEN2.BEN_Base().to(device).eval() #init pipeline
|
| 115 |
|
|
@@ -119,7 +119,7 @@ model.loadcheckpoints("./BEN2_Base.pth")
|
|
| 119 |
|
| 120 |
|
| 121 |
model.segment_video(
|
| 122 |
-
video_path=
|
| 123 |
output_path="./", # Outputs will be saved as foreground.webm or foreground.mp4. The default value is "./"
|
| 124 |
fps=0, # If this is set to 0 CV2 will detect the fps in the original video. The default value is 0.
|
| 125 |
refine_foreground=False, #refine foreground is an extract postprocessing step that increases inference time but can improve matting edges. The default value is False.
|
|
|
|
| 109 |
|
| 110 |
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
| 111 |
|
| 112 |
+
video_path = "/path_to_your_video.mp4"# input video
|
| 113 |
|
| 114 |
model = BEN2.BEN_Base().to(device).eval() #init pipeline
|
| 115 |
|
|
|
|
| 119 |
|
| 120 |
|
| 121 |
model.segment_video(
|
| 122 |
+
video_path= video_path,
|
| 123 |
output_path="./", # Outputs will be saved as foreground.webm or foreground.mp4. The default value is "./"
|
| 124 |
fps=0, # If this is set to 0 CV2 will detect the fps in the original video. The default value is 0.
|
| 125 |
refine_foreground=False, #refine foreground is an extract postprocessing step that increases inference time but can improve matting edges. The default value is False.
|