danielgatis / rembg

Rembg is a tool to remove images background
MIT License
16.48k stars 1.84k forks source link

Need sam document usage #497

Closed elcolie closed 1 year ago

elcolie commented 1 year ago

When I use sam what are input_labels and input_points? Here is my code:

import typing as typ

from PIL import Image
from tqdm import tqdm

from rembg import remove, new_session

MODELS: typ.List[str] = [
    "u2net",
    "u2netp",
    "u2net_human_seg",
    "silueta",
    "u2net_cloth_seg",
    "isnet-general-use",
    "isnet-anime",
    "sam",
]

def main() -> None:
    """Run main function."""
    samples = [
        ('man', '/Users/sarit/Pictures/me/IMG_6031.JPG'),
        ('car', '/Users/sarit/Pictures/accord2022/S__11427850.jpg')
    ]
    for model_name in tqdm(MODELS):
        for title, input_path in samples:
            input = Image.open(input_path)
            session = new_session(model_name)
            if model_name == "sam":
                output = remove(input, session=session, input_labels=[1], input_points=[[300, 300]])
            else:
                output = remove(input, session=session)
            output.save(f"el/{model_name}_{title}.png")
arnold408 commented 1 year ago

I got error trying to use "sam" : ValueError: input_labels is required

elcolie commented 1 year ago

@arnold408 You have to put input_labels, and input_points arguments. But I don't know the definition and range of it. That's why I am asking here. output = remove(input, session=session, input_labels=[1], input_points=[[300, 300]])

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 1 year ago

This issue was closed because it has been inactive for 14 days since being marked as stale.