Skip to content

This is a made easy code for starters who want to use point prompt for recently released ground breaking foundational model Segment anything (SAM) by Meta AI. This code is to make easy to jump in a project where you can select point then apply to a directory and then evaluate on binary ground truth mask. You will also get binary mask from the code.

Notifications You must be signed in to change notification settings

aia39/Segment-Anything-Model-SAM-Point-prompt-Made-Easy-for-Segmentation-Binary-Mask-Evaluation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 

Repository files navigation

Segment-Anything-Model-SAM-Point-prompt-Made-Easy-for-Segmentation-Mask

This is a made easy code for starters who want to use point prompt for recently released ground breaking foundational model Segment anything (SAM) by Meta AI. This code is to make easy to jump in a project where you can select point then apply to a directory and then evaluate on binary ground truth mask. You will also get binary mask from the code. The code will output binary segmented masks in folder. In 'outputs_prompt' named folder there will be binary masks based on point prompt segmentation and in the 'outputs_auto' there will be binary masks based on automatic segmentation.

Organization of input image directory:

img/
     img1.jpg
     img2.jpg
     img3.jpg
     img4.jpg
     ...

gt/
     img1.jpg
     img2.jpg
     img3.jpg
     img4.jpg
     ...

The prompt needs to be enter by clicking mouse where Left click is for Foreground (BLUE DOT) and Right click is for background(RED DOT). Like the below image one has to put point prompt in the image. demoofprompt

Getting Started

  1. First run the git clone
git clone https://github.com/facebookresearch/segment-anything.git
  1. Secondly, download the weight file from the main repo, or download in colab by
!wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_h_4b8939.pth -O sam_vit_h.pth
!wget https://dl.fbaipublicfiles.com/segment_anything/sam_vit_b_01ec64.pth -O sam_vit_b.pth
  1. Thirdly, organize the desired dataset like above mentioned structure.
  2. Then, run the code
python sam_with_widget.py

N.B: For inputting other arguments like: input images folder name, groundtruth folder name, put

python sam_with_widget.py -i input_folder -g groundtruth_folder 

Acknowledgement

About

This is a made easy code for starters who want to use point prompt for recently released ground breaking foundational model Segment anything (SAM) by Meta AI. This code is to make easy to jump in a project where you can select point then apply to a directory and then evaluate on binary ground truth mask. You will also get binary mask from the code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages