BEN2
BEN2 predicts a soft foreground alpha matte for background removal.
- Tasks
- background removal
- Sizes
- b at 1024 px
- Install
pip install libreyolo- Support tier
- Inference only, since v1.6.0. Predict, validate and export only. Training features do not apply.
- Licenses
- Code MIT, weights MIT. Commercial use
Install
pip install "libreyolo"Predict
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreBEN2b-matte.pt", device="cpu")result = model(SAMPLE_IMAGE)print(result.matte.array.shape)result.save("cutout.png")Prediction uses a fixed 1024-pixel canvas. Native prediction accepts batches; exports require batch 1. result.save() writes a transparent cutout. Training is not supported.
Validate
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreBEN2b-matte.pt", device="cpu")# data: a matte dataset YAML, or a folder with images/ and mattes/ (grayscale alpha, same file stems)metrics = model.val(data="path/to/your/matte_dataset.yaml", workers=0)print(metrics)Use the dataset format for this task. Validation explains the dataset requirements and returned metrics.
Export
| Task | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Background removal | Background removal to ONNX: supported | Background removal to TorchScript: supported | Background removal to ExecuTorch: supported | Background removal to TensorRT: supported | Background removal to OpenVINO: supported | Background removal to Paddle: not supported | Background removal to MNN: not supported | Background removal to RKNN: not supported | Background removal to ncnn: supported | Background removal to TFLite: not supported | Background removal to CoreML: not supported | Background removal to Core AI: not supported |
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreBEN2b-matte.pt", device="cpu")model.export(format="onnx")Export setup lists format dependencies and loading exported artifacts.
Checkpoints
| File | Weights license |
|---|---|
| Background removal | |
| LibreBEN2b-matte.pt | mit |
Every file above exists in the LibreYOLO org today and downloads on first use.
Licensing
Check the license on the Hugging Face repository of the specific weights you download. Every checkpoint in the LibreYOLO org carries one, and they are not always the same across a family. That repository is the authoritative source; the summary below describes what applied when this page was last verified.
This is a description of the licenses involved, not legal advice. If the answer matters commercially, read the licenses yourself and take your own counsel.
- Original work
- BEN2, Prama LLC
- Upstream license
- MIT
- Upstream source
- github.com/PramaLLC/BEN2
- LibreYOLO code
- MIT
- Weights
- MIT, republished at huggingface.co/LibreYOLO
- Interpretation
- The publisher declares MIT for the source and pretrained model.