查看 Markdown

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 起。仅支持预测、验证和导出。训练相关的功能不适用。
上游
ViTMatte,由 HUST Vision Lab 发布,采用 MIT code; Apache-2.0 weights 许可。论文、源码
许可
代码采用 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.ptother

上面的每个文件目前都在 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 上提供的引用块。

已针对 LibreYOLO v1.6.0 验证。本页的支持表、检查点和基准测试数据由已发布的库和权重生成,并非手工编写。

选择具体变体或系列概览,然后选择模块查看详情。打开完整架构图可缩放或下载 SVG 和 PNG。图中标签为英文。