ViTMatte
ViTMatte predicts a foreground alpha matte from an image and a trimap.
- Tarefas
- background removal
- Tamanhos
- s at 512 px
- Instalação
pip install libreyolo- Nível de suporte
- Somente inferência, desde a v1.6.0. Somente predição, validação e exportação. Os recursos de treinamento não se aplicam.
- Origem
- ViTMatte por HUST Vision Lab, MIT code; Apache-2.0 weights. Artigo, código-fonte
- Licenças
- Código MIT, pesos MIT code; Apache-2.0 weights. Uso comercial
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
| Arquivo | Licença dos pesos |
|---|---|
| Background removal | |
| LibreViTMattes-matte.pt | other |
Todos os arquivos acima existem hoje na organização LibreYOLO e são baixados no primeiro uso.
Licensing
Confira a licença no repositório do Hugging Face correspondente aos pesos que você baixar. Cada checkpoint na organização LibreYOLO tem uma licença, e ela nem sempre é a mesma em toda a família. Esse repositório é a fonte oficial. O resumo abaixo descreve o que se aplicava na última verificação desta página.
Esta é uma descrição das licenças envolvidas, não uma orientação jurídica. Se a resposta tiver importância comercial, leia as licenças e procure sua própria assessoria.
- Trabalho original
- ViTMatte, HUST Vision Lab
- Licença original
- MIT code; Apache-2.0 weights
- Código-fonte original
- github.com/hustvl/ViTMatte
- Código do LibreYOLO
- MIT
- Pesos
- MIT code; Apache-2.0 weights, republicado em huggingface.co/LibreYOLO
- Interpretação
- 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}
}Copiado do bloco de citação dos autores em raw.githubusercontent.com/hustvl/ViTMatte/main/README.md.