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
pip install "libreyolo"Predict
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
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
- Джерело першоджерела
- github.com/hustvl/ViTMatte
- Код 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.