ViTMatte
ViTMatte predicts a foreground alpha matte from an image and a trimap.
- 任务
- background removal
- 尺寸
- s at 512 px
- 安装
pip install libreyolo- 支持层级
- 仅推理,自 v1.6.0 起。仅支持预测、验证和导出。训练相关的功能不适用。
- 许可
- 代码采用 MIT,权重采用 MIT code; Apache-2.0 weights。商用
Install
bash
pip install "libreyolo"Predict
Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreViTMattes-matte.pt", device="cpu")import numpy as npfrom PIL import Image image = Image.open(SAMPLE_IMAGE).convert("RGB")# An all-unknown guide demonstrates the input contract. Supply a real trimap for matting.trimap = np.full((image.height, image.width), 128, dtype=np.uint8)result = model(image, trimap=trimap)result.save("cutout.png")A trimap marks background as 0, unknown pixels as 128 and foreground as 255. Pass it through trimap= for a single image. Validation accepts trimap_dir or derives guides with trimap_radius. Training and export are not supported.
Validate
Python
from libreyolo import LibreYOLO, SAMPLE_IMAGE model = LibreYOLO("LibreViTMattes-matte.pt", device="cpu")# A folder with images/ and mattes/ (grayscale alpha mattes, same file stems), or a matte YAML.metrics = model.val(data="path/to/your/matte_dataset", workers=0)print(metrics)Use the dataset format for this task. Validation explains the dataset requirements and returned metrics.
Checkpoints
| 文件 | 权重许可 |
|---|---|
| Background removal | |
| LibreViTMattes-matte.pt | other |
上面的每个文件目前都在 LibreYOLO 组织中,并会在首次使用时下载。
Licensing
请检查你所下载的具体权重在 Hugging Face 仓库中的许可。LibreYOLO 组织里的每个检查点都附有许可,同一家族内也不一定相同。该仓库是权威来源;以下摘要说明本页上次验证时适用的情况。
这里只说明涉及的许可证,不构成法律意见。如果答案对商用很重要,请自行阅读许可证并咨询法律顾问。
- 原始工作
- ViTMatte, HUST Vision Lab
- 上游许可
- MIT code; Apache-2.0 weights
- LibreYOLO 代码
- MIT
- 权重
- 采用 MIT code; Apache-2.0 weights 许可,重新发布在 huggingface.co/LibreYOLO
- 解读
- The original code is MIT. The publisher card for hustvl/vitmatte-small-composition-1k declares Apache-2.0 for the weights.
Citation
@article{yao2024vitmatte,
title={ViTMatte: Boosting image matting with pre-trained plain vision transformers},
author={Yao, Jingfeng and Wang, Xinggang and Yang, Shusheng and Wang, Baoyuan},
journal={Information Fusion},
volume={103},
pages={102091},
year={2024},
publisher={Elsevier}
}复制自作者在 raw.githubusercontent.com/hustvl/ViTMatte/main/README.md 上提供的引用块。