Skip to content

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.

License

Notifications You must be signed in to change notification settings

chwilms/SOS_segment-anything

 
 

Repository files navigation

SAM for SOS

This is the Segment Anything Model (SAM) version for our Segment Object System (SOS).

Installation

Please follow the general installation instructions of SAM as described in the original README.md. Additionally, install the following packages to your Python environment:

pip install scikit-image tqdm

Usage

This version of SAM contains two new scripts for applying SAM to images based on the prompts provided by the object priors evaluated in our SOS paper. See also our main SOS git for example prompt files from various object priors.

To apply SAM as part of SOS with object priors other than the Grid, use the applySAM.py script with the following parameters: the path to input images, e.g. COCO's train2017 folder, the path to the SAM checkpoint, the path to the prompt file, and the path for the output directory:

python applySAM.py /data/SOS/coco/train2017 /data/SOS/SAM_checkpoints/sam_vit_h_4b8939.pth /data/SOS/prompts/prompts_DINO.json /data/SOS/segments/segments_DINO.json

For the Grid obejct prior, which is essentially SAM's everything mode, use the applySAM_grid.py script with the same parameters, except for the prompt file, which is not necessary here:

python applySAM_grid.py /data/SOS/coco/train2017 /data/SOS/SAM_checkpoints/sam_vit_h_4b8939.pth /data/SOS/segments/segments_Grid.json

About

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.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Jupyter Notebook 99.1%
  • Other 0.9%