BEN2
BEN2 predicts a soft foreground alpha matte for background removal.
- 任务
- background removal
- 尺寸
- b at 1024 px
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v1.6.0 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 许可
- 代码采用 MIT,权重采用 MIT。商用
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
| 任务 | ONNX | TorchScript | ExecuTorch | TensorRT | OpenVINO | Paddle | MNN | RKNN | ncnn | TFLite | CoreML | Core AI |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Background removal | Background removal to ONNX:支持 | Background removal to TorchScript:支持 | Background removal to ExecuTorch:支持 | Background removal to TensorRT:支持 | Background removal to OpenVINO:支持 | Background removal to Paddle:不支持 | Background removal to MNN:不支持 | Background removal to RKNN:不支持 | Background removal to ncnn:支持 | Background removal to TFLite:不支持 | Background removal to CoreML:不支持 | Background removal to Core AI:不支持 |
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
| 文件 | 权重许可 |
|---|---|
| Background removal | |
| LibreBEN2b-matte.pt | mit |
上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。
Licensing
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- BEN2, Prama LLC
- 上游许可
- MIT
- LibreYOLO 代码
- MIT
- 权重
- 采用 MIT 许可,重新发布在 huggingface.co/LibreYOLO
- 解读
- The publisher declares MIT for the source and pretrained model.