Views
No views yet
pip install nobg>=0.2.51import torch
2from loadimg import load_img
3from nobg import AutoModel, AutoProcessor
4
5model = AutoModel.from_pretrained("feyninc/FeyNobg").eval()
6processor = AutoProcessor.from_pretrained("feyninc/FeyNobg")
7
8image = load_img("input.jpg").convert("RGB")
9inputs = processor(image, return_tensors="pt")
10
11with torch.no_grad():
12 outputs = model(pixel_values=inputs["pixel_values"])
13
14alpha = processor.post_process_alpha_matting(
15 outputs, target_sizes=[(image.height, image.width)]
16)[0]
17processor.cutout(image, alpha).save("output.png")1@article{zheng2024birefnet,
2 title={Bilateral Reference for High-Resolution Dichotomous Image Segmentation},
3 author={Zheng, Peng and Gao, Dehong and Fan, Deng-Ping and Liu, Li and Laaksonen, Jorma and Ouyang, Wanli and Sebe, Nicu},
4 journal={CAAI Artificial Intelligence Research},
5 volume={3},
6 pages={9150038},
7 year={2024},
8 url={https://arxiv.org/abs/2401.03407},
9}