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

bash
pip install "libreyolo"

Predict

Python
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

Python
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

TaskONNXTorchScriptExecuTorchTensorRTOpenVINOPaddleMNNRKNNncnnTFLiteCoreMLCore AI
Background removalBackground removal to ONNX: supportedBackground removal to TorchScript: supportedBackground removal to ExecuTorch: supportedBackground removal to TensorRT: supportedBackground removal to OpenVINO: supportedBackground removal to Paddle: not supportedBackground removal to MNN: not supportedBackground removal to RKNN: not supportedBackground removal to ncnn: supportedBackground removal to TFLite: not supportedBackground removal to CoreML: not supportedBackground removal to Core AI: not supported
Python
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

FileWeights license
Background removal
LibreBEN2b-matte.ptmit

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
LibreYOLO code
MIT
Weights
MIT, republished at huggingface.co/LibreYOLO
Interpretation
The publisher declares MIT for the source and pretrained model.

Verified against LibreYOLO v1.6.0. Support tables, checkpoints and benchmark numbers on this page are generated from the released library and the published weights, not written by hand.

BEN2 architecture

Select a variant or family overview, then select a block for details. Open the full diagram to zoom or download SVG and PNG.