facebookresearch / segment-anything

The repository provides code for running inference with the SegmentAnything Model (SAM), links for downloading the trained model checkpoints, and example notebooks that show how to use the model.
Apache License 2.0
46.9k stars 5.56k forks source link

What is the best way to get only the objects I want? #715

Open hanjoonwon opened 6 months ago

hanjoonwon commented 6 months ago

https://drive.google.com/drive/folders/1Q9zSM8sCsQ4n-6QKl4GEujuznx-abxvh?usp=drive_link my images

With the existing script, I only want to mask the battery, but it grabs the base underneath. Can I just run a jupyter notebook file and take images one by one to get exactly the battery?

heyoeyo commented 6 months ago

Since the battery is in the center of the image, you might be able to get away with using the points-per-side argument set to something really low (and an odd number), like 3.

Otherwise, the best way to get something specific is definitely to provide the prompt directly. That can be inconvenient using the notebook, but there are repos available that may make this easier (found by searching for 'sam ui' or 'sam webui', for example SAM-webui). There's also the original SAM demo page itself which allows you to select things and download the cut-outs.

Alternatively, if you wanted to automated the selection, you can try something like grounded-SAM, which would let you detect/segment objects based on a text-prompt.